From 897ef891ba043e6c25012faa1d2fa388c132d44e Mon Sep 17 00:00:00 2001 From: Jonathan Eiten Date: Tue, 2 Feb 2016 17:18:07 -0500 Subject: [PATCH] update v0.2 example --- examples/v0.2/index.html | 60 ++++++++------- examples/v0.2/index.js | 154 +++++++++++++++++-------------------- examples/v0.2/index.min.js | 16 ++-- 3 files changed, 111 insertions(+), 119 deletions(-) diff --git a/examples/v0.2/index.html b/examples/v0.2/index.html index 5904d10d4..95266b306 100644 --- a/examples/v0.2/index.html +++ b/examples/v0.2/index.html @@ -362,22 +362,22 @@ // } // }; -jsonGrid.addFinEventListener('fin-double-click', function(e){ +jsonGrid.addEventListener('fin-double-click', function(e){ var cell = e.detail.gridCell; var rowContext = jsonModel.getRow(cell.y); console.log('fin-double-click row-context:', rowContext); }); -jsonGrid.addFinEventListener('fin-button-pressed', function(e){ +jsonGrid.addEventListener('fin-button-pressed', function(e){ var p = e.detail.gridCell; jsonModel.setValue(p.x, p.y, !jsonModel.getValue(p.x,p.y)); }); -jsonGrid.addFinEventListener('fin-scroll-x', function(e){ +jsonGrid.addEventListener('fin-scroll-x', function(e){ console.log('fin-scroll-x ', e.detail.value); }); -jsonGrid.addFinEventListener('fin-scroll-y', function(e){ +jsonGrid.addEventListener('fin-scroll-y', function(e){ console.log('fin-scroll-y', e.detail.value); }); @@ -385,25 +385,29 @@ readOnly: false }); -jsonGrid.addFinEventListener('fin-cell-enter', function(e) { +jsonGrid.addEventListener('fin-cell-enter', function(e) { var cell = e.detail.gridCell; //console.log('fin-cell-enter', cell.x, cell.y); //how to set the tooltip.... - jsonGrid.setAttribute('title', 'fin-cell-enter(' + cell.x +', '+ cell.y+')'); + jsonGrid.setAttribute('title', 'fin-cell-enter(' + cell.x + ', ' + cell.y+')'); }); -jsonGrid.addFinEventListener('fin-set-totals-value', function(e) { - var details = e.detail; - var x = details.x; - var y = details.y; - var value = details.value; - jsonModel.getDataModel().getTotals()[0][x] = value; +jsonGrid.addEventListener('fin-set-totals-value', function(e) { + var detail = e.detail, + areas = detail.areas || ['top', 'bottom']; + + areas.forEach(function(area) { + var methodName = 'get' + area[0].toUpperCase() + area.substr(1) + 'Totals', + totalsRow = jsonModel.getDataModel().getComponent()[methodName](); + + totalsRow[detail.y][detail.x] = detail.value; + }); + jsonGrid.repaint(); }); - -jsonGrid.addFinEventListener('fin-filter-applied', function(e) { +jsonGrid.addEventListener('fin-filter-applied', function(e) { console.log('fin-filter-applied', e); }); @@ -450,9 +454,9 @@ return true; } -jsonGrid.addFinEventListener('fin-keydown', handleCursorKey); +jsonGrid.addEventListener('fin-keydown', handleCursorKey); -jsonGrid.addFinEventListener('fin-editor-keydown', function(e) { +jsonGrid.addEventListener('fin-editor-keydown', function(e) { var detail = e.detail, ke = detail.keyEvent; @@ -465,7 +469,7 @@ }); -jsonGrid.addFinEventListener('fin-selection-changed', function(e){ +jsonGrid.addEventListener('fin-selection-changed', function(e){ //lets mirror the cell selection into the rows and or columns jsonGrid.selectRowsFromCells(); @@ -487,7 +491,7 @@ }); -jsonGrid.addFinEventListener('fin-row-selection-changed', function(e) { +jsonGrid.addEventListener('fin-row-selection-changed', function(e) { console.log('fin-row-selection-changed', e.detail); if (e.detail.rows.length === 0) { console.log('no rows selected'); @@ -500,7 +504,7 @@ console.log(jsonGrid.getRowSelection()); }); -jsonGrid.addFinEventListener('fin-column-selection-changed', function(e) { +jsonGrid.addEventListener('fin-column-selection-changed', function(e) { console.log('fin-column-selection-changed', e.detail); if (e.detail.columns.length === 0) { @@ -514,42 +518,42 @@ console.log(jsonGrid.getColumnSelection()); }); -jsonGrid.addFinEventListener('fin-editor-data-change', function(e) { +jsonGrid.addEventListener('fin-editor-data-change', function(e) { console.log('fin-editor-data-change', e.detail); }); -jsonGrid.addFinEventListener('fin-request-cell-edit', function(e) { +jsonGrid.addEventListener('fin-request-cell-edit', function(e) { console.log('fin-request-cell-edit', e); //e.preventDefault(); //uncomment to cancel editor popping up }); -jsonGrid.addFinEventListener('fin-before-cell-edit', function(e) { +jsonGrid.addEventListener('fin-before-cell-edit', function(e) { console.log('fin-before-cell-edit', e); //e.preventDefault(); //uncomment to cancel updating the model with the new data }); -jsonGrid.addFinEventListener('fin-after-cell-edit', function(e) { +jsonGrid.addEventListener('fin-after-cell-edit', function(e) { console.log('fin-after-cell-edit', e); }); -jsonGrid.addFinEventListener('fin-editor-keyup', function(e) { +jsonGrid.addEventListener('fin-editor-keyup', function(e) { console.log('fin-editor-keyup', e.detail); }); -jsonGrid.addFinEventListener('fin-editor-keypress', function(e) { +jsonGrid.addEventListener('fin-editor-keypress', function(e) { console.log('fin-editor-keypress', e.detail); }); -jsonGrid.addFinEventListener('fin-editor-keydown', function(e) { +jsonGrid.addEventListener('fin-editor-keydown', function(e) { console.log('fin-editor-keydown', e.detail); }); -jsonGrid.addFinEventListener('fin-groups-changed', function(e) { +jsonGrid.addEventListener('fin-groups-changed', function(e) { console.log('fin-groups-changed', e.detail); }); -jsonGrid.addFinEventListener('fin-context-menu', function(e) { +jsonGrid.addEventListener('fin-context-menu', function(e) { var modelPoint = e.detail.gridCell; var headerRowCount = jsonGrid.getHeaderRowCount(); console.log('fin-context-menu(' + modelPoint.x + ', ' + (modelPoint.y - headerRowCount) + ')'); diff --git a/examples/v0.2/index.js b/examples/v0.2/index.js index c3618e947..c92fc3cc8 100644 --- a/examples/v0.2/index.js +++ b/examples/v0.2/index.js @@ -55,7 +55,7 @@ function addStylesheet(key, referenceElement) { module.exports = addStylesheet; },{"css-injector":4}],2:[function(require,module,exports){ -module.exports = { // This file generated by gulp-imagine-64 at 11:53:23 AM on 2/1/2016 +module.exports = { // This file generated by gulp-imagine-64 at 5:14:49 PM on 2/2/2016 "calendar": { type: "image/png", data: "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAc0lEQVR4nIXQwQkCMRSE4U9ZLMCT9Xjaq2AfNhfYU5oQLMAOtoN48EWei5iBIRPe/yYQ3qrhf1lFG7iKcEaJxSfukUvMWgdHavt0uWHtg2QwxXnAnJZ2uOLyVZtybzzhgWNmfoFl0/YB87NbzR1cjP9xeQHSDC6mcL1xFQAAAABJRU5ErkJggg==" @@ -2816,15 +2816,11 @@ Canvas.prototype = { } var width = this.canvas.getAttribute('width'); var height = this.canvas.getAttribute('height'); - this.canvas.width = width * ratio; - this.canvas.height = height * ratio; - this.buffer.width = width * ratio; - this.buffer.height = height * ratio; + this.canvas.width = this.buffer.width = width * ratio; + this.canvas.height = this.buffer.height = height * ratio; - this.canvas.style.width = width + 'px'; - this.canvas.style.height = height + 'px'; - this.buffer.style.width = width + 'px'; - this.buffer.style.height = height + 'px'; + this.canvas.style.width = this.buffer.style.width = width + 'px'; + this.canvas.style.height = this.buffer.style.height = height + 'px'; this.bufferCTX.scale(ratio, ratio); if (isHIDPI && !useBitBlit) { @@ -2858,7 +2854,7 @@ Canvas.prototype = { var comp = self.component; if (comp) { - comp._paint(gc); + comp.paint(gc); } self.dirty = false; @@ -9345,12 +9341,14 @@ Hypergrid.prototype = { }, getMatrixSelectionAsTSV: function(selections) { + var result = ''; + //only use the data from the last selection if (selections.length) { var width = selections.length, height = selections[0].length, area = width * height, - collector = []; + last = width - 1; //disallow if selection is too big if (area > 20000) { @@ -9360,21 +9358,12 @@ Hypergrid.prototype = { for (var h = 0; h < height; h++) { for (var w = 0; w < width; w++) { - collector.push(selections[w][h]); - if (w < width) { - collector.push('\t'); - } - } - if (h < height) { - collector.push('\n'); + result += selections[w][h] + (w < last ? '\t' : '\n'); } } - - var result = collector.join(''); - - return result; } - return ''; + + return result; }, /** @@ -9611,7 +9600,7 @@ Hypergrid.prototype = { self.resized(); }; - this.addFinEventListener('fin-canvas-mousemove', function(e) { + this.addEventListener('fin-canvas-mousemove', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9621,7 +9610,7 @@ Hypergrid.prototype = { self.delegateMouseMove(mouseEvent); }); - this.addFinEventListener('fin-canvas-mousedown', function(e) { + this.addEventListener('fin-canvas-mousedown', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9637,7 +9626,7 @@ Hypergrid.prototype = { }); - // this.addFinEventListener('fin-canvas-click', function(e) { + // this.addEventListener('fin-canvas-click', function(e) { // if (self.resolveProperty('readOnly')) { // return; // } @@ -9648,7 +9637,7 @@ Hypergrid.prototype = { // self.fireSyntheticClickEvent(mouseEvent); // }); - this.addFinEventListener('fin-canvas-mouseup', function(e) { + this.addEventListener('fin-canvas-mouseup', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9671,7 +9660,7 @@ Hypergrid.prototype = { self.fireSyntheticMouseUpEvent(mouseEvent); }); - this.addFinEventListener('fin-canvas-dblclick', function(e) { + this.addEventListener('fin-canvas-dblclick', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9682,7 +9671,7 @@ Hypergrid.prototype = { self.delegateDoubleClick(mouseEvent); }); - this.addFinEventListener('fin-canvas-tap', function(e) { + this.addEventListener('fin-canvas-tap', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9695,7 +9684,7 @@ Hypergrid.prototype = { self.delegateTap(tapEvent); }); - this.addFinEventListener('fin-canvas-drag', function(e) { + this.addEventListener('fin-canvas-drag', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9706,7 +9695,7 @@ Hypergrid.prototype = { self.delegateMouseDrag(mouseEvent); }); - this.addFinEventListener('fin-canvas-keydown', function(e) { + this.addEventListener('fin-canvas-keydown', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9740,7 +9729,7 @@ Hypergrid.prototype = { self.delegateKeyDown(e); }); - this.addFinEventListener('fin-canvas-keyup', function(e) { + this.addEventListener('fin-canvas-keyup', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9748,7 +9737,7 @@ Hypergrid.prototype = { self.delegateKeyUp(e); }); - this.addFinEventListener('fin-canvas-track', function(e) { + this.addEventListener('fin-canvas-track', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9771,7 +9760,7 @@ Hypergrid.prototype = { } }); - // this.addFinEventListener('fin-canvas-holdpulse', function(e) { + // this.addEventListener('fin-canvas-holdpulse', function(e) { // console.log('holdpulse'); // if (self.resolveProperty('readOnly')) { // return; @@ -9782,14 +9771,14 @@ Hypergrid.prototype = { // self.delegateHoldPulse(mouseEvent); // }); - this.addFinEventListener('fin-canvas-wheelmoved', function(e) { + this.addEventListener('fin-canvas-wheelmoved', function(e) { var mouse = e.detail.mouse; var mouseEvent = self.getGridCellFromMousePoint(mouse); mouseEvent.primitiveEvent = e.detail.primitiveEvent; self.delegateWheelMoved(mouseEvent); }); - this.addFinEventListener('fin-canvas-mouseout', function(e) { + this.addEventListener('fin-canvas-mouseout', function(e) { if (self.resolveProperty('readOnly')) { return; } @@ -9799,7 +9788,7 @@ Hypergrid.prototype = { self.delegateMouseExit(mouseEvent); }); - this.addFinEventListener('fin-canvas-context-menu', function(e) { + this.addEventListener('fin-canvas-context-menu', function(e) { var mouse = e.detail.mouse; var mouseEvent = self.getGridCellFromMousePoint(mouse); mouseEvent.primitiveEvent = e.detail.primitiveEvent; @@ -9824,10 +9813,15 @@ Hypergrid.prototype = { * @param {string} eventName - The type of event we are interested in. * @param {function} callback - The event handler. */ - addFinEventListener: function(eventName, callback) { + addEventListener: function(eventName, callback) { this.canvas.addEventListener(eventName, callback); }, + addFinEventListener: function(eventName, callback) { + console.warn('.addEventListener() method is deprecated as of v0.2. Use .addEventListener() instead. (Will be removed in a future release.)'); + this.addEventListener(eventName, callback); + }, + /** * @memberOf Hypergrid.prototype * @summary Set for `scrollingNow` field. @@ -10245,10 +10239,10 @@ Hypergrid.prototype = { * @param {number} x - column index * @param {number} y - totals row index local to the totals area * @param value - * @param {boolean} atBottom - this value is in the "bottom" totals area + * @param {string[]} [areas=['top', 'bottom']] - may include `'top'` and/or `'bottom'` */ - setTotalsValueNotification: function(x, y, value, atBottom) { - this.fireSyntheticSetTotalsValue(x, y, value, atBottom); + setTotalsValueNotification: function(x, y, value, areas) { + this.fireSyntheticSetTotalsValue(x, y, value, areas); }, /** @@ -10256,15 +10250,15 @@ Hypergrid.prototype = { * @param {number} x - column index * @param {number} y - totals row index local to the totals area * @param value - * @param {boolean} atBottom - this value is in the "bottom" totals area + * @param {string[]} [areas=['top', 'bottom']] - may include `'top'` and/or `'bottom'` */ - fireSyntheticSetTotalsValue: function(x, y, value, atBottom) { + fireSyntheticSetTotalsValue: function(x, y, value, areas) { var clickEvent = new CustomEvent('fin-set-totals-value', { detail: { x: x, y: y, value: value, - area: atBottom ? 'bottom' : 'top' + areas: areas } }); this.canvas.dispatchEvent(clickEvent); @@ -13623,10 +13617,10 @@ var Behavior = Base.extend('Behavior', { * @param {number} x - column index * @param {number} y - totals row index local to the totals area * @param value - * @param {boolean} [atBottom=false] - this value is in the "bottom" totals area + * @param {string[]} [areas=['top', 'bottom']] - may include `'top'` and/or `'bottom'` */ - setTotalsValue: function(x, y, value, atBottom) { - this.grid.setTotalsValueNotification(x, y, value, !!atBottom); + setTotalsValue: function(x, y, value, areas) { + this.grid.setTotalsValueNotification(x, y, value, areas); }, /** @@ -14126,7 +14120,7 @@ var ListDragon = require('list-dragon'); var Local = require('./Local'); var DataModelDecorator = require('./DataModelDecorator'); var DataModelJSON = require('../dataModels/JSON'); -var features = require('../features/index'); +var features = require('../features'); var addStylesheet = require('../../css/stylesheets'); //var aggregations = require('hyper-analytics').util.aggregations; //var aggregations = require('../local_node_modules/hyper-analytics').util.aggregations; @@ -14187,10 +14181,7 @@ var JSON = Local.extend('behaviors.JSON', { }, getDefaultDataModel: function() { - var model = new DataModelJSON(); - var wrapper = new DataModelDecorator(this.grid, model); - wrapper.setComponent(model); // TODO: Redundant? Already performed in DataModelDecorator()? - return wrapper; + return new DataModelDecorator(this.grid, new DataModelJSON); }, applyAnalytics: function() { @@ -14448,7 +14439,7 @@ var JSON = Local.extend('behaviors.JSON', { module.exports = JSON; -},{"../../css/stylesheets":1,"../dataModels/JSON":46,"../features/index":65,"../local_node_modules/finanalytics":90,"./DataModelDecorator":30,"./Local":32,"list-dragon":18}],32:[function(require,module,exports){ +},{"../../css/stylesheets":1,"../dataModels/JSON":46,"../features":65,"../local_node_modules/finanalytics":90,"./DataModelDecorator":30,"./Local":32,"list-dragon":18}],32:[function(require,module,exports){ 'use strict'; //var ListDragon = require('list-dragon'); @@ -14456,7 +14447,7 @@ module.exports = JSON; var Behavior = require('./Behavior'); //var DataModelDecorator = require('./DataModelDecorator'); //var DataModelJSON = require('../dataModels/JSON'); -//var features = require('../features/index'); +//var features = require('../features'); //var addStylesheet = require('../stylesheets'); ////var aggregations = require('hyper-analytics').util.aggregations; ////var aggregations = require('../local_node_modules/hyper-analytics').util.aggregations; @@ -16045,10 +16036,7 @@ var JSON = DataModel.extend('dataModels.JSON', { * @returns {Array} */ getTopTotals: function() { - if (!this.hasAggregates()) { - return this.topTotals; - } - return this.getDataSource().getGrandTotals(); + return this.hasAggregates() ? this.getDataSource().getGrandTotals() : this.topTotals; }, /** @@ -16064,10 +16052,7 @@ var JSON = DataModel.extend('dataModels.JSON', { * @returns {Array} */ getBottomTotals: function() { - if (!this.hasAggregates()) { - return this.bottomTotals; - } - return this.getDataSource().getGrandTotals(); + return this.hasAggregates() ? this.getDataSource().getGrandTotals() : this.bottomTotals; }, /** @@ -17313,13 +17298,13 @@ require('object-iterators'); // Installs the Array.find polyfill, as needed var Hypergrid = require('./Hypergrid'); Hypergrid.images = require('../images'); -Hypergrid.behaviors = require('./behaviors/index'); -Hypergrid.cellEditors = require('./cellEditors/index'); -Hypergrid.features = require('./features/index'); +Hypergrid.behaviors = require('./behaviors'); +Hypergrid.cellEditors = require('./cellEditors'); +Hypergrid.features = require('./features'); (window.fin = window.fin || {}).Hypergrid = Hypergrid; -},{"../images":3,"./Hypergrid":27,"./behaviors/index":34,"./cellEditors/index":44,"./features/index":65,"object-iterators":21}],49:[function(require,module,exports){ +},{"../images":3,"./Hypergrid":27,"./behaviors":34,"./cellEditors":44,"./features":65,"object-iterators":21}],49:[function(require,module,exports){ 'use strict'; var Feature = require('./Feature.js'); @@ -21603,13 +21588,18 @@ function CustomFilter() { return this.filter; }; - this.setState = function(state) { - return ( - this.filterTree = new FilterTree({ - state: state, - fields: this.fieldsProvider() - }) - ); + this.setState = function(stateObjectOrJsonString) { + var options = { + fields: this.fieldsProvider() + }; + + if (typeof stateObjectOrJsonString === 'string') { + options.state = stateObjectOrJsonString; + } else { + options.json = stateObjectOrJsonString; + } + + return (this.filterTree = new FilterTree(options)); }; } @@ -21775,7 +21765,7 @@ module.exports = (function() { var _ = require('object-iterators'); var Base = require('./Base'); -var images = require('../../images/index'); +var images = require('../../images'); /** @typedef {object} CanvasRenderingContext2D * @see [CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D) @@ -21962,7 +21952,7 @@ var Renderer = Base.extend('Renderer', { * @desc This is the entry point from fin-canvas. * @param {CanvasRenderingContext2D} gc */ - _paint: function(gc) { + paint: function(gc) { if (this.grid) { this.renderGrid(gc); this.grid.gridRenderedNotification(); @@ -22846,13 +22836,11 @@ var Renderer = Base.extend('Renderer', { }, startAnimator: function() { - var animate; var self = this; - animate = function() { + requestAnimationFrame(function animate() { self.animate(); requestAnimationFrame(animate); - }; - requestAnimationFrame(animate); + }); }, animate: function() { @@ -22886,7 +22874,7 @@ function setNumberColumnWidth(gc, behavior, maxRow) { module.exports = Renderer; -},{"../../images/index":3,"./Base":66,"object-iterators":21}],72:[function(require,module,exports){ +},{"../../images":3,"./Base":66,"object-iterators":21}],72:[function(require,module,exports){ 'use strict'; var RangeSelectionModel = require('sparse-boolean-array'); @@ -23688,7 +23676,7 @@ module.exports = deprecated; },{}],75:[function(require,module,exports){ 'use strict'; -var images = require('../../images/index'); +var images = require('../../images'); /** * @summary Writes error message into cell. @@ -23747,7 +23735,7 @@ function renderCellError(gc, message, x, y, width, height) { module.exports = renderCellError; -},{"../../images/index":3}],76:[function(require,module,exports){ +},{"../../images":3}],76:[function(require,module,exports){ 'use strict'; module.exports = (function() { @@ -24909,4 +24897,4 @@ module.exports = (function() { })();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VpcmUoJ2Nzcy1pbmplY3RvcicpO1xuXG52YXIgc3R5bGVzaGVldHMgPSB7XG4gICAgZ3JpZDogW1xuICAgICAgICAnZGl2I2dyaWQtY29udGFpbmVyIHsnLFxuICAgICAgICAnICAgIHBvc2l0aW9uOiByZWxhdGl2ZTsnLFxuICAgICAgICAnICAgIGRpc3BsYXk6IGlubGluZS1ibG9jazsnLFxuICAgICAgICAnICAgIC13ZWJraXQtdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICAtbW96LXVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgLW1zLXVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgLW8tdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICB1c2VyLXNlbGVjdDogbm9uZTsnLFxuICAgICAgICAnICAgIG92ZXJmbG93OiBoaWRkZW47IH0nLFxuICAgICAgICAndmlzaWJsZSB7IG9wYWNpdHk6IDAuNzU7IH0nLFxuICAgICAgICAnaGlkZGVuIHsgb3BhY2l0eTogMC4wOyB9JyxcbiAgICAgICAgJ2VkaXRvciB7JyxcbiAgICAgICAgJyAgICBwb3NpdGlvbjogYWJzb2x1dGU7JyxcbiAgICAgICAgJyAgICBkaXNwbGF5OiBub25lOycsXG4gICAgICAgICcgICAgYm9yZGVyOiBzb2xpZCAycHggYmxhY2s7JyxcbiAgICAgICAgJyAgICBvdXRsaW5lOiAwOycsXG4gICAgICAgICcgICAgcGFkZGluZzogMDsnLFxuICAgICAgICAnICAgIHotaW5kZXg6IDEwMDA7IH0nXG4gICAgXSxcbiAgICAnbGlzdC1kcmFnb24nOiBbXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3QsIGxpLmRyYWdvbi1wb3AgeycsXG4gICAgICAgICcgICAgZm9udC1mYW1pbHk6IFJvYm90bywgc2Fucy1zZXJpZjsnLFxuICAgICAgICAnICAgIHRleHQtdHJhbnNmb3JtOiBjYXBpdGFsaXplO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ZWVkZWQgaW4gcHJvdG90eXBlXG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ2FsaWFzZXMnOlxuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBhbGlhcyBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLmhhc093blByb3BlcnR5KGFsaWFzKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VBbGlhcyh2YWx1ZVthbGlhc10sIGFsaWFzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnc3RyaW5nJyAmJiB2YWx1ZVswXSA9PT0gJyMnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlQWxpYXModmFsdWUsIGtleS5zdWJzdHIoMSkpO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgcHJvdG90eXBlW2tleV0gPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIENvbnN0cnVjdG9yO1xuXG4gICAgZnVuY3Rpb24gbWFrZUFsaWFzKHZhbHVlLCBrZXkpIHsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1zaGFkb3dcbiAgICAgICAgcHJvdG90eXBlW2tleV0gPSBwcm90b3R5cGVBZGRpdGlvbnNbdmFsdWVdO1xuICAgIH1cbn1cblxuZXh0ZW5kLkJhc2UgPSBmdW5jdGlvbiAoKSB7fTtcbmV4dGVuZC5CYXNlLmV4dGVuZCA9IGV4dGVuZDtcblxuLyoqIEB0eXBlZGVmIHtmdW5jdG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gICB2YXIgZm9jdXMgPSBvcHRpb25zLmZvY3VzID09PSB1bmRlZmluZWQgfHwgb3B0aW9ucy5mb2N1cyxcbiAgICAgICAgICAgIGFsZXJ0ID0gb3B0aW9ucy5hbGVydCA9PT0gdW5kZWZpbmVkIHx8IG9wdGlvbnMuYWxlcnQsXG4gICAgICAgICAgICByZXRocm93ID0gb3B0aW9ucy5yZXRocm93ID09PSB0cnVlLFxuICAgICAgICAgICAgcmVzdWx0O1xuXG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgICB2YWxpZGF0ZS5jYWxsKHRoaXMsIGZvY3VzKTtcbiAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICByZXN1bHQgPSBlcnIubWVzc2FnZTtcblxuICAgICAgICAgICAgLy8gVGhyb3cgd2hlbiBub3QgYSBmaWx0ZXIgdHJlZSBlcnJvclxuICAgICAgICAgICAgaWYgKHJldGhyb3cgfHwgIXJlRmlsdGVyVHJlZUVycm9yU3RyaW5nLnRlc3QocmVzdWx0KSkge1xuICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGFsZXJ0KSB7XG4gICAgICAgICAgICAgICAgcmVzdWx0ID0gcmVzdWx0LnJlcGxhY2UocmVGaWx0ZXJUcmVlRXJyb3JTdHJpbmcsICcnKTtcbiAgICAgICAgICAgICAgICB3aW5kb3cuYWxlcnQocmVzdWx0KTsgLy8gZXNsaW50LWRpc2FibGUtbGluZSBuby1hbGVydFxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9LFxuXG4gICAgdGVzdDogZnVuY3Rpb24gdGVzdChkYXRhUm93KSB7XG4gICAgICAgIHZhciBvcGVyYXRvciA9IG9wZXJhdG9yc1t0aGlzLm9wZXJhdG9yXSxcbiAgICAgICAgICAgIHJlc3VsdCA9IG9wZXJhdG9yLnNlZWQsXG4gICAgICAgICAgICBub0NoaWxkcmVuRGVmaW5lZCA9IHRydWU7XG5cbiAgICAgICAgdGhpcy5jaGlsZHJlbi5maW5kKGZ1bmN0aW9uKGNoaWxkKSB7XG4gICAgICAgICAgICBpZiAoY2hpbGQpIHtcbiAgICAgICAgICAgICAgICBub0NoaWxkcmVuRGVmaW5lZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIGlmIChjaGlsZCBpbnN0YW5jZW9mIERlZmF1bHRGaWx0ZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gb3BlcmF0b3IucmVkdWNlKHJlc3VsdCwgY2hpbGQudGVzdChkYXRhUm93KSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGlsZC5jaGlsZHJlbi5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gb3BlcmF0b3IucmVkdWNlKHJlc3VsdCwgdGVzdC5jYWxsKGNoaWxkLCBkYXRhUm93KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQgPT09IG9wZXJhdG9yLmFib3J0O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiBub0NoaWxkcmVuRGVmaW5lZCB8fCAob3BlcmF0b3IubmVnYXRlID8gIXJlc3VsdCA6IHJlc3VsdCk7XG4gICAgfSxcblxuICAgIHRvSlNPTjogZnVuY3Rpb24gdG9KU09OKCkge1xuICAgICAgICB2YXIgc3RhdGUgPSB7XG4gICAgICAgICAgICBvcGVyYXRvcjogdGhpcy5vcGVyYXRvcixcbiAgICAgICAgICAgIGNoaWxkcmVuOiBbXVxuICAgICAgICB9O1xuXG4gICAgICAgIHRoaXMuY2hpbGRyZW4uZm9yRWFjaChmdW5jdGlvbihjaGlsZCkge1xuICAgICAgICAgICAgaWYgKGNoaWxkKSB7XG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkIGluc3RhbmNlb2YgRGVmYXVsdEZpbHRlcikge1xuICAgICAgICAgICAgICAgICAgICBzdGF0ZS5jaGlsZHJlbi5wdXNoKGNoaWxkKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGNoaWxkLmNoaWxkcmVuLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcmVhZHkgPSB0b0pTT04uY2FsbChjaGlsZCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChyZWFkeSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuY2hpbGRyZW4ucHVzaChyZWFkeSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHZhciBtZXRhZGF0YSA9IEZpbHRlck5vZGUucHJvdG90eXBlLnRvSlNPTi5jYWxsKHRoaXMpO1xuICAgICAgICBPYmplY3Qua2V5cyhtZXRhZGF0YSkuZm9yRWFjaChmdW5jdGlvbihrZXkpIHtcbiAgICAgICAgICAgIHN0YXRlW2tleV0gPSBtZXRhZGF0YVtrZXldO1xuICAgICAgICB9KTtcblxuICAgICAgICByZXR1cm4gc3RhdGUuY2hpbGRyZW4ubGVuZ3RoID8gc3RhdGUgOiB1bmRlZmluZWQ7XG4gICAgfSxcblxuICAgIGdldFNxbFdoZXJlQ2xhdXNlOiBmdW5jdGlvbiBnZXRTcWxXaGVyZUNsYXVzZSgpIHtcbiAgICAgICAgdmFyIGxleGVtZSA9IG9wZXJhdG9yc1t0aGlzLm9wZXJhdG9yXS5TUUwsXG4gICAgICAgICAgICB3aGVyZSA9ICcnO1xuXG4gICAgICAgIHRoaXMuY2hpbGRyZW4uZm9yRWFjaChmdW5jdGlvbihjaGlsZCwgaWR4KSB7XG4gICAgICAgICAgICB2YXIgb3AgPSBpZHggPyAnICcgKyBsZXhlbWUub3AgKyAnICcgOiAnJztcbiAgICAgICAgICA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WwpO1xuICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZENoaWxkKGVsKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBlbDtcbiAgICB9LFxuXG4gICAgbG9hZDogZnVuY3Rpb24oc3RhdGUpIHtcbiAgICAgICAgaWYgKHN0YXRlKSB7XG4gICAgICAgICAgICB2YXIgdmFsdWUsIGVsLCBpLCBiLCBzZWxlY3RlZCwgbm90ZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzdGF0ZSkge1xuICAgICAgICAgICAgICAgIGlmIChrZXkgIT09ICdmaWVsZHMnICYmIGtleSAhPT0gJ2VkaXRvcicpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBzdGF0ZVtrZXldO1xuICAgICAgICAgICAgICAgICAgICBlbCA9IHRoaXMuY29udHJvbHNba2V5XTtcbiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChlbC50eXBlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdjaGVja2JveCc6XG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdyYWRpbyc6XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWwgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCdpbnB1dFtuYW1lPVxcJycgKyBlbC5uYW1lICsgJ1xcJ10nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZWwubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxbaV0uY2hlY2tlZCA9IHZhbHVlLmluZGV4T2YoZWxbaV0udmFsdWUpID49IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnc2VsZWN0LW11bHRpcGxlJzpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbCA9IGVsLm9wdGlvbnM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgYiA9IGZhbHNlOyBpIDwgZWwubGVuZ3RoOyBpKyssIGIgPSBiIHx8IHNlbGVjdGVkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkID0gdmFsdWUuaW5kZXhPZihlbFtpXS52YWx1ZSkgPj0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxbaV0uc2VsZWN0ZWQgPSBzZWxlY3RlZDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgRmlsdGVyTm9kZS5zZXRXYXJuaW5nQ2xhc3MoZWwsIGIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbC52YWx1ZSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghRmlsdGVyTm9kZS5zZXRXYXJuaW5nQ2xhc3MoZWwpICYmIGVsLnZhbHVlICE9PSB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub3Rlcy5wdXNoKHsga2V5OiBrZXksIHZhbHVlOiB2YWx1ZSB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobm90ZXMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgdmFyIG11bHRpcGxlID0gbm90ZXMubGVuZ3RoID4gMSxcbiAgICAgICAgICAgICAgICAgICAgZm9vdG5vdGVzID0gdGVtcGxhdGUobXVsdGlwbGUgPyAnbm90ZXMnIDogJ25vdGUnKSxcbiAgICAgICAgICAgICAgICAgICAgaW5uZXIgPSBmb290bm90ZXMubGFzdEVsZW1lbnRDaGlsZDtcbiAgICAgICAgICAgICAgICBub3Rlcy5mb3JFYWNoKGZ1bmN0aW9uKG5vdGUpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGZvb3Rub3RlID0gbXVsdGlwbGUgPyBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdsaScpIDogaW5uZXI7XG4gICAgICAgICAgICAgICAgICAgIG5vdGUgPSB0ZW1wbGF0ZSgnb3B0aW9uTWlzc2luZycsIG5vdGUua2V5LCBub3RlLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKG5vdGUubGVuZ3RoKSB7IGZvb3Rub3RlLmFwcGVuZENoaWxkKG5vdGVbMF0pOyB9XG4gICAgICAgICAgICAgICAgICAgIGlmIChtdWx0aXBsZSkgeyBpbm5lci5hcHBlbmRDaGlsZChmb290bm90ZSk7IH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBlbC5wYXJlbnROb2RlLnJlcGxhY2VDaGlsZChmb290bm90ZXMsIGVsLnBhcmVudE5vZGUubGFzdEVsZW1lbnRDaGlsZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQHByb3BlcnR5IHtjb252ZXJ0ZXJ9IG51bWJlclxuICAgICAqIEBwcm9wZXJ0eSB7Y29udmVydGVyfSBkYXRlXG4gICAgICovXG4gICAgY29udmVydGVyczoge1xuICAgICAgICBudW1iZXI6IG51bWJlckNvbnZlcnRlcixcbiAgICAgICAgaW50OiBudW1iZXJDb252ZXJ0ZXIsIC8vIHBzZXVkby10eXBlOiByZWFsbHkganVzdCBhIE51bWJlclxuICAgICAgICBmbG9hdDogbnVtYmVyQ29udmVydGVyLCAvLyBwc2V1ZG8tdHlwZTogcmVhbGx5IGp1c3QgYSBOdW1iZXJcbiAgICAgICAgZGF0ZTogZGF0ZUNvb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BGaWx0ZXJOb2RlLkVycm9yKCdCbGFuayAnICsgZWxlbWVudE5hbWUgKyAnIGNvbnRyb2wuXFxuQ29tcGxldGUgdGhlIGZpbHRlciBvciBkZWxldGUgaXQuJyk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIENvcHkgZWFjaCBjb250cm9scydzIHZhbHVlIHRvIHByb3BlcnR5IG9mIHRoaXMgb2JqZWN0LlxuICAgICAgICAgICAgICAgIHRoaXNbZWxlbWVudE5hbWVdID0gdmFsdWU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLm9wID0gdGhpcy5vcGVyYXRvcnNbdGhpcy5vcGVyYXRvcl07XG5cbiAgICAgICAgdGhpcy5jb252ZXJ0ZXIgPSB1bmRlZmluZWQ7IC8vIHJlbWFpbnMgdW5kZWZpbmVkIHdoZW4gbmVpdGhlciBvcGVyYXRvciBub3IgY29sdW1uIGlzIHR5cGVkXG4gICAgICAgIGlmICh0aGlzLm9wLnR5cGUpIHtcbiAgICAgICAgICAgIHRoaXMuY29udmVydGVyID0gdGhpcy5jb252ZXJ0ZXJzW3RoaXMub3AudHlwZV07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBmb3IgKGVsZW1lbnROYW1lIGluIHRoaXMuY29udHJvbHMpIHtcbiAgICAgICAgICAgICAgICBpZiAoL15jb2x1bW4vLnRlc3QoZWxlbWVudE5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkcyA9IHRoaXMucGFyZW50Lm5vZGVGaWVsZHMgfHwgdGhpcy5maWVsZHM7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkID0gZmluZEZpZWxkKGZpZWxkcywgdGhpc1tlbGVtZW50TmFtZV0pO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZmllbGQgJiYgZmllbGQudHlwZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb252ZXJ0ZXIgPSB0aGlzLmNvbnZlcnRlcnNbZmllbGQudHlwZV07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgcDogZnVuY3Rpb24oZGF0YVJvdykgeyByZXR1cm4gZGF0YVJvd1t0aGlzLmNvbHVtbl07IH0sXG4gICAgcTogZnVuY3Rpb24oKSB7IHJldHVybiB0aGlzLnZhbHVlOyB9LFxuXG4gICAgdGVzdDogZnVuY3Rpb24oZGF0YVJvdykge1xuICAgICAgICB2YXIgcCwgcSwgLy8gdW50eXBlZCB2ZXJzaW9ucyBvZiBhcmdzXG4gICAgICAgICAgICBQLCBRLCAvLyB0eXBlZCB2ZXJzaW9ucyBvZiBwIGFuZCBxXG4gICAgICAgICAgICBjb252ZXJ0O1xuXG4gICAgICAgIHJldHVybiAocCA9IHRoaXMucChkYXRhUm93KSkgPT09IHVuZGVmaW5lZCB8fCAocSA9IHRoaXMucShkYXRhUm93KSkgPT09IHVuZGVmaW5lZFxuICAgICAgICAgICAgPyBmYWxzZVxuICAgICAgICAgICAgOiAoXG4gICAgICAgICAgICAgICAgKGNvbnZlcnQgPSB0aGlzLmNvbnZlcnRlcikgJiZcbiAgICAgICAgICAgICAgICAhY29udmVydC5ub3QoUCA9IGNvbnZlcnQudG8ocCkpICYmXG4gICAgICAgICAgICAgICAgIWNvbnZlcnQubm90KFEgPSBjb252ZXJ0LnRvKHEpKVxuICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgID8gdGhpcy5vcC50ZXN0KFAsIFEpXG4gICAgICAgICAgICAgICAgOiB0aGlzLm9wLnRlc3QocCwgcSk7XG4gICAgfSxcblxuICAgIHRvSlNPTjogZnVuY3Rpb24ob3B0aW9ucykgeyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXVudXNlZC12YXJzXG4gICAgICAgIHZhciBzdGF0ZSA9IHt9O1xuICAgICAgICBpZiAodGhpcy5lZGl0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29tcGFyYXRvcik7IC8vIGNsb25lIGl0IGFuZCBzb3J0IHRoZSBjbG9uZVxuICAgICAgICB9XG5cbiAgICAgICAgb3B0aW9ucy5mb3JFYWNoKGZ1bmN0aW9uKG9wdGlvbikge1xuICAgICAgICAgICAgaWYgKChvcHRpb24ub3B0aW9ucyB8fCBvcHRpb24pIGluc3RhbmNlb2YgQXJyYXkpIHtcbiAgICAgICAgICAgICAgICB2YXIgb3B0Z3JvdXAgPSBhZGRPcHRpb25zKCdvcHRncm91cCcsIG9wdGlvbi5vcHRpb25zIHx8IG9wdGlvbiwgb3B0aW9uLmxhYmVsKTtcbiAgICAgICAgICAgICAgICBlbC5hZGQob3B0Z3JvdXApO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YXIgbmV3RWxlbWVudCA9IHR5cGVvZiBvcHRpb24gIT09ICdvYmplY3QnXG4gICAgICAgICAgICAgICAgICAgID8gbmV3IE9wdGlvbihvcHRpb24pXG4gICAgICAgICAgICAgICAgICAgIDogbmV3IE9wdGlvbihcbiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbi5hbGlhcyB8fCBvcHRpb24ubmFtZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbi5uYW1lIHx8IG9wdGlvbi5hbGlhc1xuICAgICAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICAgIGFkZC5jYWxsKGVsLCBuZXdFbGVtZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfSBlbHNlIHtcbiAgICAgICAgZWwudHlwZSA9ICd0ZXh0JztcbiAgICB9XG5cbiAgICByZXR1cm4gZWw7XG59XG5cbmZ1bmN0aW9uIGZpZWxkQ29tcGFyYXRvcihhLCBiKSB7XG4gICAgYSA9IGEuYWxpYXMgfHwgYS5uYW1lIHx8IGEubGFiZWwgfHwgYTtcbiAgICBiID0gYi5hbGlhcyB8fCBiLm5hbWUgfHwgYi5sYWJlbCB8fCB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VxuICAgICAqIEBtZW1iZXJPZiBGaW5CYXIucHJvdG90eXBlXG4gICAgICovXG4gICAgdmFyIHRodW1iID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2Jyk7XG4gICAgdGh1bWIuY2xhc3NMaXN0LmFkZCgndGh1bWInKTtcbiAgICB0aHVtYi5vbmNsaWNrID0gYm91bmQuc2hvcnRTdG9wO1xuICAgIHRodW1iLm9ubW91c2VvdmVyID0gYm91bmQub25tb3VzZW92ZXI7XG4gICAgdGhpcy50aHVtYiA9IHRodW1iO1xuXG4gICAgLyoqXG4gICAgICogQG5hbWUgYmFyXG4gICAgICogQHN1bW1hcnkgVGhlIGdlbmVyYXRlZCBzY3JvbGxiYXIgZWxlbWVudC5cbiAgICAgKiBAZGVzYyBUaGUgY2FsbGVyIGluc2VydHMgdGhpcyBlbGVtZW50IGludG8gdGhlIERPTSAodHlwaWNhbGx5IGludG8gdGhlIGNvbnRlbnQgY29udGFpbmVyKSBhbmQgdGhlbiBjYWxscyBpdHMge0BsaW5rIEZpbkJhciNyZXNpemV8cmVzaXplKCl9IG1ldGhvZC5cbiAgICAgKlxuICAgICAqIFRodXMgdGhlIG5vZGUgdHJlZSBpcyB0eXBpY2FsbHk6XG4gICAgICogKiBBICoqY29udGVudCBjb250YWluZXIqKiBlbGVtZW50LCB3aGljaCBjb250YWluczpcbiAgICAgKiAgICAqIFRoZSBjb250ZW50IGVsZW1lbnQocylcbiAgICAgKiAgICAqIFRoaXMgKipzY3JvbGxiYXIgZWxlbWVudCoqLCB3aGljaCBpbiB0dXJuIGNvbnRhaW5zOlxuICAgICAqICAgICAgICAqIFRoZSAqKnRodW1iIGVsZW1lbnQqKlxuICAgICAqXG4gICAgICogQHR5cGUge0VsZW1lbnR9XG4gICAgICogQG1lbWJlck9mIEZpbkJhci5wcm90b3R5cGVcbiAgICAgKi9cbiAgICB2YXIgYmFyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2Jyk7XG5cbiAgICBiYXIuY2xhc3NMaXN0LmFkZCgnZmluYmFyLXZlcnRpY2FsJyk7XG5cbiAgICBiYXIuYXBwZW5kQ2hpbGQodGh1bWIpO1xuICAgIGlmICh0aGlzLnBhZ2luZykge1xuICAgICAgICBiYXIub25jbGljayA9IGJvdW5kLm9uY2xpY2s7XG4gICAgfVxuICAgIHRoaXMuYmFyID0gYmFyO1xuXG4gICAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307XG5cbiAgICAvLyBwcmVzZXRzXG4gICAgdGhpcy5vcmllbnRhdGlvbiA9ICd2ZXJ0aWNhbCc7XG4gICAgdGhpcy5fbWluID0gdGhpcy5faW5kZXggPSAwO1xuICAgIHRoaXMuX21heCA9IDEwMDtcblxuICAgIC8vIG9wdGlvbnNcbiAgICBmb3IgKHZhciBrZXkgaW4gb3B0aW9ucykge1xuICAgICAgICBpZiAob3B0aW9ucy5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgICAgICB2YXIgb3B0aW9uID0gb3B0aW9uc1trZXldO1xuICAgICAgICAgICAgc3dpdGNoIChrZXkpIHtcblxuICAgICAgICAgICAgY2FzZSAnaW5kZXgnOlxuICAgICAgICAgICAgICAgIHRoaXMuX2luZGV4ID0gb3B0aW9uO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBjYXNlICdyYW5nZSc6XG4gICAgICAgICAgICAgICAgdmFsaWRSYW5nZShvcHRpb24pO1xuICAgICAgICAgICAgICAgIHRoaXMuX21pbiA9IG9wdGlvbi5taW47XG4gICAgICAgICAgICAgICAgdGhpcy5fbWF4ID0gb3B0aW9uLm1heDtcbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRTaXplID0gb3B0aW9uLm1heCAtIG9wdGlvbi5taW4gKyAxO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgICAgICAga2V5LmNoYXJBdCgwKSAhPT0gJ18nICYmXG4gICAgICAgICAgICAgICAgICAgIHR5cGVvZiBGaW5CYXIucHJvdG90eXBlW2tleV0gIT09ICdmdW5jdGlvbidcbiAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gb3ZlcnJpZGUgcHJvdG90eXBlIGRlZmF1bHRzIGZvciBzdGFuZGFyZCA7XG4gICAgICAgICAgICAgICAgICAgIC8vIGV4dGVuZCB3aXRoIGFkZGl0aW9uYWwgcHJvcGVydGllcyAoZm9yIHVzZSBpbiBvbmNoYW5nZSBldmVudCBoYW5kbGVycylcbiAgICAgICAgICAgICAgICAgICAgdGhpc1trZXldID0gb3B0aW9uO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgY3NzSW5qZWN0b3IoY3NzRmluQmFycywgJ2ZpbmJhci1iYXNlJywgb3B0aW9ucy5jc3NTdHlsZXNoZWV0UmVmZXJlbmNlRWxlbWVudCk7XG59XG5cbkZpbkJhci5wcm90b3R5cGUgPSB7XG5cbiAgICAvKipcbiAgICAgKiBAc3VtbWFyeSBUaGUgc2Nyb2xsYmFyIG9yaWVudGF0aW9uLlxuICAgICAqIEBkZXNjIFNldCBieSB0aGUgY29uc3RydWN0b3IgdG8gZWl0aGVyIGAndmVydGljYWwnYCBvciBgJ2hvcml6b250YWwnYC4gU2VlIHRoZSBzaW1pbGFybHkgbmFtZWQgcHJvcGVydHkgaW4gdGhlIHtAbGluayBmaW5iYXJPcHRpb25zfSBvYmplY3QuXG4gICAgICpcbiAgICAgKiBVc2VmdWwgdmFsdWVzIGFyZSBgJ3ZlcnRpY2FsJ2AgKHRoZSBkZWZhdWx0KSBvciBgJ2hvcml6b250YWwnYC5cbiAgICAgKlxuICAgICAqIFNldHRpbmcgdGhpcyBwcm9wZXJ0eSByZXNldHMgYHRoaXMub2hgIGFuZC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AgICAqL1xuICAgIHNldCBzdHlsZShzdHlsZXMpIHtcbiAgICAgICAgdmFyIGtleXMgPSBPYmplY3Qua2V5cyhzdHlsZXMgPSBleHRlbmQoe30sIHN0eWxlcywgdGhpcy5fYXV4U3R5bGVzKSk7XG5cbiAgICAgICAgaWYgKGtleXMubGVuZ3RoKSB7XG4gICAgICAgICAgICB2YXIgYmFyID0gdGhpcy5iYXIsXG4gICAgICAgICAgICAgICAgYmFyUmVjdCA9IGJhci5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKSxcbiAgICAgICAgICAgICAgICBjb250YWluZXIgPSB0aGlzLmNvbnRhaW5lciB8fCBiYXIucGFyZW50RWxlbWVudCxcbiAgICAgICAgICAgICAgICBjb250YWluZXJSZWN0ID0gY29udGFpbmVyLmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpLFxuICAgICAgICAgICAgICAgIG9oID0gdGhpcy5vaDtcblxuICAgICAgICAgICAgLy8gQmVmb3JlIGFwcGx5aW5nIG5ldyBzdHlsZXMsIHJldmVydCBhbGwgc3R5bGVzIHRvIHZhbHVlcyBpbmhlcml0ZWQgZnJvbSBzdHlsZXNoZWV0c1xuICAgICAgICAgICAgYmFyLnJlbW92ZUF0dHJpYnV0ZSgnc3R5bGUnKTtcblxuICAgICAgICAgICAga2V5cy5mb3JFYWNoKGZ1bmN0aW9uIChrZXkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdmFsID0gc3R5bGVzW2tleV07XG5cbiAgICAgICAgICAgICAgICBpZiAoa2V5IGluIG9oKSB7XG4gICAgICAgICAgICAgICAgICAgIGtleSA9IG9oW2tleV07XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCFpc05hTihOdW1iZXIodmFsKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFsID0gKHZhbCB8fCAwKSArICdweCc7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICgvJSQvLnRlc3QodmFsKSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBXaGVuIGJhciBzaXplIGdpdmVuIGFzIHBlcmNlbnRhZ2Ugb2YgY29udGFpbmVyLCBpZiBiYXIgaGFzIG1hcmdpbnMsIHJlc3RhdGUgc2l6ZSBpbiBwaXhlbHMgbGVzcyBtYXJnaW5zLlxuICAgICAgICAgICAgICAgICAgICAvLyAoSWYgbGVmdCBhcyBwZXJjZW50YWdlLCBDU1MncyBjYWxjdWxhdGlvbiB3aWxsIG5vdCBleGNsdWRlIG1hcmdpbnMuKVxuICAgICAgICAgICAgICAgICAgICB2YXIgb3JpZW50ZWQgPSBheGlzW2tleV0sXG4gICAgICAgICAgICAgICAgICAgICAgICBtYXJnaW5zID0gYmFyUmVjdFtvcmllbnRlZC5tYXJnaW5MZWFkaW5nXSArIGJhclJlY3Rbb3JpZW50ZWQubWFyZ2luVHJhaWxpbmddO1xuICAgICAgICAgICAgICAgICAgICBpZiAobWFyZ2lucykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFsID0gcGFyc2VJbnQodmFsLCAxMCkgLyAxMDAgKiBjb250YWluZXJSZWN0W29yaWVudGVkLnNpemVdIC0gbWFyZ2lucyArICdweCc7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBiYXIuc3R5bGVba2V5XSA9IHZhbDtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEByZWFkb25seVxuICAgICAqIEBuYW1lIHBhZ2luZ1xuICAgICAqIEBzdW1tYXJ5IEVuYWJsZSBwYWdlIHVwL2RuIGNsaWNrcy5cbiAgICAgKiBAZGVzYyBTZXQgYnkgdGhlIGNvbnN0cnVjdG9yLiBTZWUgdGhlIHNpbWlsYXJseSBuYW1lZCBwcm9wZXJ0eSBpbiB0aGUge0BsaW5rIGZpbmJhck9wdGlvbnN9IG9iamVjdC5cbiAgICAgKlxuICAgICAqIElmIHRydXRoeSwgbG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uZ2UpIHtcbiAgICAgICAgICAgICAgICB0aGlzLm9uY2hhbmdlID0gdGhpcy5zY3JvbGxSZWFsQ29udGVudDtcbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRTaXplID0gdGhpcy5jb250ZW50W3RoaXMub2guc2l6ZV07XG4gICAgICAgICAgICAgICAgdGhpcy5fbWluID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLl9tYXggPSB0aGlzLmNvbnRlbnRTaXplIC0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5vbmNoYW5nZSA9PT0gdGhpcy5zY3JvbGxSZWFsQ29udGVudCkge1xuICAgICAgICAgICAgdGhpcy5jb250YWluZXJTaXplID0gY29udGFpbmVyUmVjdFt0aGlzLm9oLnNpemVdO1xuICAgICAgICAgICAgdGhpcy5pbmNyZW1lbnQgPSB0aGlzLmNvbnRhaW5lclNpemUgLyAodGhpcy5jb250ZW50U2l6ZSAtIHRoaXMuY29udGFpbmVyU2l6ZSkgKiAodGhpcy5fbWF4IC0gdGhpcy5fbWluKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuY29udGFpbmVyU2l6ZSA9IDE7XG4gICAgICAgICAgICB0aGlzLmluY3JlbWVudCA9IGluY3JlbWVudCB8fCB0aGlzLmluY3JlbWVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBpbmRleCA9IHRoaXMuaW5kZXg7XG4gICAgICAgIHRoaXMudGVzdFBhbmVsSXRlbSA9IHRoaXMudGVzdFBhbmVsSXRlbSB8fCB0aGlzLl9hZGRUZXN0UGFuZWxJdGVtKCk7XG4gICAgICAgIHRoaXMuX3NldFRodW1iU2l6ZSgpO1xuICAgICAgICB0aGlzLmluZGV4ID0gaW5kZXg7XG5cbiAgICAgICAgaWYgKHRoaXMuZGVsdGFQcm9wICE9PSBudWxsKSB7XG4gICAgICAgICAgICBjb250YWluZXIuYWRkRXZlbnRMaXN0Z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ICdoZWlnaHQnLFxuICAgICAgICBvdXRzaWRlOiAgICAgICAgJ3JpZ2h0JyxcbiAgICAgICAgaW5zaWRlOiAgICAgICAgICdsZWZ0JyxcbiAgICAgICAgbGVhZGluZzogICAgICAgICd0b3AnLFxuICAgICAgICB0cmFpbGluZzogICAgICAgJ2JvdHRvbScsXG4gICAgICAgIG1hcmdpbkxlYWRpbmc6ICAnbWFyZ2luVG9wJyxcbiAgICAgICAgbWFyZ2luVHJhaWxpbmc6ICdtYXJnaW5Cb3R0b20nLFxuICAgICAgICB0aGlja25lc3M6ICAgICAgJ3dpZHRoJyxcbiAgICAgICAgZGVsdGE6ICAgICAgICAgICdkZWx0YVknXG4gICAgfSxcbiAgICBob3Jpem9udGFsOiB7XG4gICAgICAgIGNvb3JkaW5hdGU6ICAgICAnY2xpZW50WCcsXG4gICAgICAgIGF4aXM6ICAgICAgICAgICAncGFnZVgnLFxuICAgICAgICBzaXplOiAgICAgICAgICAgJ3dpZHRoJyxcbiAgICAgICAgb3V0c2lkZTogICAgICAgICdib3R0b20nLFxuICAgICAgICBpbnNpZGU6ICAgICAgICAgJ3RvcCcsXG4gICAgICAgIGxlYWRpbmc6ICAgICAgICAnbGVmdCcsXG4gICAgICAgIHRyYWlsaW5nOiAgICAgICAncmlnaHQnLFxuICAgICAgICBtYXJnaW5MZWFkaW5nOiAgJ21hcmdpbkxlZnQnLFxuICAgICAgICBtYXJnaW5UcmFpbGluZzogJ21hcmdpblJpZ2h0JyxcbiAgICAgICAgdGhpY2tuZXNzOiAgICAgICdoZWlnaHQnLFxuICAgICAgICBkZWx0YTogICAgICAgICAgJ2RlbHRhWCdcbiAgICB9XG59O1xuXG52YXIgYXhpcyA9IHtcbiAgICB0b3A6ICAgICd2ZXJ0aWNhbCcsXG4gICAgYm90dG9tOiAndmVydGljYWwnLFxuICAgIGhlaWdodDogJ3ZlcnRpY2FsJyxcbiAgICBsZWZ0OiAgICdob3Jpem9udGFsJyxcbiAgICByaWdodDogICdob3Jpem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hcnNlSW50KGZwcykgOiAwO1xuICAgIH0sXG5cbiAgICB0aWNrUGFpbnQ6IGZ1bmN0aW9uKG5vdykge1xuICAgICAgICB2YXIgZnBzID0gdGhpcy5nZXRGUFMoKTtcbiAgICAgICAgaWYgKGZwcyA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBpbnRlcnZhbCA9IDEwMDAgLyBmcHM7XG5cbiAgICAgICAgdmFyIGVsYXBzZWQgPSBub3cgLSB0aGlzLmxhc3RSZXBhaW50VGltZTtcbiAgICAgICAgaWYgKGVsYXBzZWQgPiBpbnRlcnZhbCAmJiB0aGlzLmRpcnR5KSB7XG4gICAgICAgICAgICB0aGlzLmxhc3RSZXBhaW50VGltZSA9IG5vdyAtIChlbGFwc2VkICUgaW50ZXJ2YWwpO1xuICAgICAgICAgICAgdGhpcy5wYWludE5vdygpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGJlZ2luUGFpbnRpbmc6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgICAgIHRoaXMuZGlydHkgPSB0cnVlO1xuICAgICAgICB0aGlzLnRpY2tQYWludGVyID0gZnVuY3Rpb24obm93KSB7XG4gICAgICAgICAgICBzZWxmLnRpY2tQYWludChub3cpO1xuICAgICAgICB9O1xuICAgICAgICBwYWludGFibGVzLnB1c2godGhpcyk7XG4gICAgfSxcblxuICAgIHN0b3BQYWludGluZzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHBhaW50YWJsZXMuc3BsaWNlKHBhaW50YWJsZXMuaW5kZXhPZih0aGlzKSwgMSk7XG4gICAgfSxcblxuICAgIGJlZ2luUmVzaXppbmc6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgICAgIHRoaXMudGlja1Jlc2l6ZXIgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHNlbGYuY2hlY2tza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F0aC5yb3VuZCh0aGlzLnNpemUudG9wKSk7XG4gICAgICAgIHRoaXMuYm91bmRzID0gbmV3IHJlY3Rhbmd1bGFyLlJlY3RhbmdsZSgwLCAwLCBib3gud2lkdGgsIGJveC5oZWlnaHQpO1xuICAgICAgICAvL3NldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBjb21wID0gdGhpcy5jb21wb25lbnQ7XG4gICAgICAgIGlmIChjb21wKSB7XG4gICAgICAgICAgICBjb21wLnNldEJvdW5kcyh0aGlzLmJvdW5kcyk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yZXNpemVOb3RpZmljYXRpb24oKTtcbiAgICAgICAgdGhpcy5wYWludE5vdygpO1xuICAgICAgICAvL30pO1xuICAgIH0sXG5cbiAgICByZXNpemVOb3RpZmljYXRpb246IGZ1bmN0aW9uKCkge1xuICAgICAgICAvL3RvIGJlIG92ZXJyaWRkZW5cbiAgICB9LFxuXG4gICAgZ2V0Qm91bmRzOiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuYm91bmRzO1xuICAgIH0sXG5cbiAgICBwYWludE5vdzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdGhpcy5zYWZlUGFpbnRJbW1lZGlhdGVseShmdW5jdGlvbihnYykge1xuICAgICAgICAgICAgZ2MuY2xlYXJSZWN0KDAsIDAsIHNlbGYuY2FudmFzLndpZHRoLCBzZWxmLmNhbnZhcy5oZWlnaHQpO1xuXG4gICAgICAgICAgICB2YXIgY29tcCA9IHNlbGYuY29tcG9uZW50O1xuICAgICAgICAgICAgaWYgKGNvbXApIHtcbiAgICAgICAgICAgICAgICBjb21wLl9wYWludChnYyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHNlbGYuZGlydHkgPSBmYWxzZTtcbiAgICAgICAgfSk7XG4gICAgfSxcblxuICAgIHNhZmVQYWludEltbWVkaWF0ZWx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NhdXNpbmcgYSB0YXBcbiAgICAgICAgLy9sZXRzIGZpeCB0aGlzIGhlcmVcbiAgICAgICAgaWYgKG5vdyAtIHRoaXMuZHJhZ0VuZHRpbWUgPCAxMDApIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgc2VsZi5fZmludGFwKGUpO1xuICAgICAgICB9LCAxODApO1xuICAgIH0sXG5cbiAgICBfZmludGFwOiBmdW5jdGlvbihlKSB7XG4gICAgICAgIC8vdGhpcyBub25zZW5zZSBpcyB0byBob2xkIGEgdGFwIGlmIGl0J3MgcmVhbGx5IGEgZG91YmxlIGNsaWNrXG4gICAgICAgIHZhciBub3cgPSBEYXRlLm5vdygpO1xuICAgICAgICB2YXIgZGlmID0gbm93IC0gdGhpcy5sYXN0RG91YmxlQ2xpY2tUaW1lO1xuICAgICAgICBpZiAoZGlmIDwgMzAwKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAodGhpcy5tb3VzZURvd25Mb2NhdGlvbikgeyAvLyBtYXliZSBubyBtb3VzZWRvd24gb24gYSBwaG9uZT9cbiAgICAgICAgICAgIHRoaXMubW91c2VMb2NhdGlvbiA9IHRoaXMubW91c2VEb3duTG9jYXRpb247IC8vIG1vdXNlIG1heSBoYXZlIG1vdmVkIHNpbmNlIG1vdXNlZG93blxuICAgICAgICAgICAgdGhpcy5tb3VzZURvd25Mb2NhdGlvbiA9IHVuZGVmaW5lZDsgLy8gY29uc3VtZSBpdCAobWF5YmUgbm90IG5lZWRlZDsgb25jZSBhIG1vdXNlZG93biBhbHdheXMgYSBtb3VzZWRvd24pXG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLmRpc3BhdGNoTmV3TW91c2VLZXlzRXZlbnQoZSwgJ2Zpbi1jYW52YXMtdGFwJywge1xuICAgICAgICAgICAgaXNSaWdodENsaWNrOiB0aGl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gICAgICAgICAgdGhpcy5yZXBlYXRLZXkgPSBrZXlDaGFyO1xuICAgICAgICAgICAgICAgIHRoaXMucmVwZWF0S2V5U3RhcnRUaW1lID0gRGF0ZS5ub3coKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMucmVwZWF0S2V5ID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMucmVwZWF0S2V5Q291bnQgPSAwO1xuICAgICAgICAgICAgdGhpcy5yZXBlYXRLZXlTdGFydFRpbWUgPSAwO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmN1cnJlbnRLZXlzLmluZGV4T2Yoa2V5Q2hhcikgPT09IC0xKSB7XG4gICAgICAgICAgICB0aGlzLmN1cnJlbnRLZXlzLnB1c2goa2V5Q2hhcik7XG4gICAgICAgIH1cbiAgICAgICAgLy9jb25zb2xlLmxvZyhrZXlDaGFyLCBlLmtleUNvZGUpO1xuICAgICAgICB0aGlzLmRpc3BhdGNoTmV3RXZlbnQoZSwgJ2Zpbi1jYW52YXMta2V5ZG93bicsIHtcbiAgICAgICAgICAgIGFsdDogZS5hbHRLZXksXG4gICAgICAgICAgICBjdHJsOiBlLmN0cmxLZXksXG4gICAgICAgICAgICBjaGFyOiBrZXlDaGFyLFxuICAgICAgICAgICAgY29kZTogZS5jaGFyQ29kZSxcbiAgICAgICAgICAgIGtleTogZS5rZXlDb2RlLFxuICAgICAgICAgICAgbWV0YTogZS5tZXRhS2V5LFxuICAgICAgICAgICAgcmVwZWF0Q291bnQ6IHRoaXMucmVwZWF0S2V5Q291bnQsXG4gICAgICAgICAgICByZXBlYXRTdGFydFRpbWU6IHRoaXMucmVwZWF0S2V5U3RhcnRUaW1lLFxuICAgICAgICAgICAgc2hpZnQ6IGUuc2hpZnRLZXksXG4gICAgICAgICAgICBpZGVudGlmaWVyOiBlLmtleUlkZW50aWZpZXIsXG4gICAgICAgICAgICBjdXJyZW50S2V5czogdGhpcy5jdXJyZW50S2V5cy5zbGljZSgwKVxuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgZmlua2V5dXA6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgdmFyIGtleUNoYXIgPSBlLnNoaWZ0S2V5ID8gY2hhck1hcFtlLmtleUNvZGVdWzFdIDogY2hhck1hcFtlLmtleUNvZGVdWzBdO1xuICAgICAgICB0aGlzLmN1cnJlbnRLZXlzLnNwbGljZSh0aGlzLmN1cnJlbnRLZXlzLmluZGV4T2Yoa2V5Q2hhciksIDEpO1xuICAgICAgICBpZiAoIXRoaXMuaGFzRm9jdXMoKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMucmVwZWF0S2V5Q291bnQgPSAwO1xuICAgICAgICB0aGlzLnJlcGVhdEtleSA9IG51bGw7XG4gICAgICAgIHRoaXMucmVwZWF0S2V5U3RhcnRUaW1lID0gMDtcbiAgICAgICAgdGhpcy5kaXNwYXRjaE5ld0V2ZW50KGUsICdmaW4tY2FudmFzLWtleXVwJywge1xuICAgICAgICAgICAgYWx0OiBlLmFsdEtleSxcbiAgICAgICAgICAgIGN0cmw6IGUuY3RybEtleSxcbiAgICAgICAgICAgIGNoYXI6IGtleUNoYXIsXG4gICAgICAgICAgICBjb2RlOiBlLmNoYXJDb2RlLFxuICAgICAgICAgICAga2V5OiBlLmtleUNvZGUsXG4gICAgICAgICAgICBtZXRhOiBlLm1ldGFLZXksXG4gICAgICAgICAgICByZXBlYXQ6IGUucmVwZWF0LFxuICAgICAgICAgICAgc2hpZnQ6IGUuc2hpZnRLZXksXG4gICAgICAgICAgICBpZGVudGlmaWVyOiBlLmtleUlkZW50aWZpZXIsXG4gICAgICAgICAgICBjdXJyZW50S2V5czogdGhpcy5jdXJyZW50S2V5cy5zbGljZSgwKVxuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgZmluZm9jdXNnYWluZWQ6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgdG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5XSA9IFsnMScsICchJ107XG4gICAgbWFwWzUwXSA9IFsnMicsICdAJ107XG4gICAgbWFwWzUxXSA9IFsnMycsICcjJ107XG4gICAgbWFwWzUyXSA9IFsnNCcsICckJ107XG4gICAgbWFwWzUzXSA9IFsnNScsICclJ107XG4gICAgbWFwWzU0XSA9IFsnNicsICdeJ107XG4gICAgbWFwWzU1XSA9IFsnNycsICcmJ107XG4gICAgbWFwWzU2XSA9IFsnOCcsICcqJ107XG4gICAgbWFwWzU3XSA9IFsnOScsICcoJ107XG4gICAgbWFwWzQ4XSA9IFsnMCcsICcpJ107XG4gICAgbWFwWzE4OV0gPSBbJy0nLCAnXyddO1xuICAgIG1hcFsxODddID0gWyc9JywgJysnXTtcbiAgICBtYXBbOF0gPSBbJ0JBQ0tTUEFDRScsICdCQUNLU1BBQ0VTSElGVCddO1xuICAgIG1hcFs0Nl0gPSBbJ0RFTEVURScsICdERUxFVEVTSElGVCddO1xuICAgIG1hcFs5XSA9IFsnVEFCJywgJ1RBQlNISUZUJ107XG4gICAgbWFwWzgxXSA9IFsncScsICdRJ107XG4gICAgbWFwWzg3XSA9IFsndycsICdXJ107XG4gICAgbWFwWzY5XSA9IFsnZScsICdFJ107XG4gICAgbWFwWzgyXSA9IFsncicsICdSJ107XG4gICAgbWFwWzg0XSA9IFsndCcsICdUJ107XG4gICAgbWFwWzg5XSA9IFsneScsICdZJ107XG4gICAgbWFwWzg1XSA9IFsndScsICdVJ107XG4gICAgbWFwWzczXSA9IFsnaScsICdJJ107XG4gICAgbWFwWzc5XSA9IFsnbycsICdPJ107XG4gICAgbWFwWzgwXSA9IFsncCcsICdQJ107XG4gICAgbWFwWzIxOV0gPSBbJ1snLCAneyddO1xuICAgIG1hcFsyMjFdID0gWyddJywgJ30nXTtcbiAgICBtYXBbMjIwXSA9IFsnXFxcXCcsICd8J107XG4gICAgbWFwWzIyMF0gPSBbJ0NBUFNMT0NLJywgJ0NBUFNMT0NLU0hJRlQnXTtcbiAgICBtYXBb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W5nJykge1xuICAgICAgICByZXN1bHQgPSAnXCInICsgcmVzdWx0ICsgJ1wiJztcbiAgICB9XG5cbiAgICBuYW1lID0gcHJlZml4ICsgbmFtZTtcblxuICAgIHN3aXRjaCAoYXJncykge1xuICAgICAgICBjYXNlICdnZXR0ZXInOlxuICAgICAgICAgICAgY29uc29sZS5sb2cobmFtZSwgJz0nLCByZXN1bHQpO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgY2FzZSAnc2V0dGVyJzpcbiAgICAgICAgICAgIGNvbnNvbGUubG9nKG5hbWUsIFlJRUxEUywgcmVzdWx0KTtcbiAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgIGRlZmF1bHQ6IC8vIG1ldGhvZCBjYWxsXG4gICAgICAgICAgICBuYW1lICs9ICcoJyArIEFycmF5LnByb3RvdHlwZS5zbGljZS5jYWxsKGFyZ3MpLmpvaW4oJywgJykgKyAnKSc7XG4gICAgICAgICAgICBpZiAocmVzdWx0ID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhuYW1lKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2cobmFtZSwgWUlFTERTLCByZXN1bHQpO1xuICAgICAgICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiB2YWx1ZTtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBjb25zb2xlTG9nZ2VyO1xuIiwiLyogZXNsaW50LWRpc2FibGUgKi9cblxuLyoqXG4gKiBAbGljZW5zZVxuICogQ29weXJpZ2h0IChjKSAyMDE0IFRoZSBQb2x5bWVyIFByb2plY3QgQXV0aG9ycy4gQWxsIHJpZ2h0cyByZXNlcnZlZC5cbiAqIFRoaXMgY29kZSBtYXkgb25seSBiZSB1c2VkIHVuZGVyIHRoZSBCU0Qgc3R5bGUgbGljZW5zZSBmb3VuZCBhdCBodHRwOi8vcG9seW1lci5naXRodWIuaW8vTElDRU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B7XG4gICAgICAgICAgICB2YXIgcyA9IHRoaXMuc2hhZG93KGluRWwpO1xuICAgICAgICAgICAgaWYgKHRoaXMuY2FuVGFyZ2V0KHMpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHM7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG9sZGVyU2hhZG93OiBmdW5jdGlvbihzaGFkb3cpIHtcbiAgICAgICAgICAgIHZhciBvcyA9IHNoYWRvdy5vbGRlclNoYWRvd1Jvb3Q7XG4gICAgICAgICAgICBpZiAoIW9zKSB7XG4gICAgICAgICAgICAgICAgdmFyIHNlID0gc2hhZG93LnF1ZXJ5U2VsZWN0b3IoJ3NoYWRvdycpO1xuICAgICAgICAgICAgICAgIGlmIChzZSkge1xuICAgICAgICAgICAgICAgICAgICBvcyA9IHNlLm9sZGVyU2hhZG93Um9vdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gb3M7XG4gICAgICAgIH0sXG4gICAgICAgIGFsbFNoYWRvd3M6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIHZhciBzaGFkb3dzID0gW10sXG4gICAgICAgICAgICAgICAgcyA9IHRoaXMuc2hhZG93KGVsZW1lbnQpO1xuICAgICAgICAgICAgd2hpbGUgKHMpIHtcbiAgICAgICAgICAgICAgICBzaGFkb3dzLnB1c2gocyk7XG4gICAgICAgICAgICAgICAgcyA9IHRoaXMub2xkZXJTaGFkb3cocyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gc2hhZG93cztcbiAgICAgICAgfSxcbiAgICAgICAgc2VhcmNoUm9vdDogZnVuY3Rpb24oaW5Sb290LCB4LCB5KSB7XG4gICAgICAgICAgICB2YXIgdCwgc3QsIHNyLCBvcztcbiAgICAgICAgICAgIGlmIChpblJvb3QpIHtcbiAgICAgICAgICAgICAgICB0ID0gaW5Sb290LmVsZW1lbnRGcm9tUG9pbnQoeCwgeSk7XG4gICAgICAgICAgICAgICAgaWYgKHQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZm91bmQgZWxlbWVudCwgY2hlY2sgaWYgaXQgaGFzIGEgU2hhZG93Um9vdFxuICAgICAgICAgICAgICAgICAgICBzciA9IHRoaXMudGFyZ2V0aW5nU2hhZG93KHQpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5Sb290ICE9PSBkb2N1bWVudCkge1xuICAgICAgICAgICAgICAgICAgICAvLyBjaGVjayBmb3Igc2libGluZyByb290c1xuICAgICAgICAgICAgICAgICAgICBzciA9IHRoaXMub2xkZXJTaGFkb3coaW5Sb290KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgLy8gc2VhcmNoIG90aGVyIHJvb3RzLCBmYWxsIGJhY2sgdG8gbGlnaHQgZG9tIGVsZW1lbnRcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zZWFyY2hSb290KHNyLCB4LCB5KSB8fCB0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBvd25lcjogZnVuY3Rpb24oZWxlbWVudCkge1xuICAgICAgICAgICAgaWYgKCFlbGVtZW50KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGRvY3VtZW50O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHMgPSBlbGVtZW50O1xuICAgICAgICAgICAgLy8gd2FsayB1cCB1bnRpbCB5b3UgaGl0IHRoZSBzaGFkb3cgcm9vdCBvciBkb2N1bWVudFxuICAgICAgICAgICAgd2hpbGUgKHMucGFyZW50Tm9kZSkge1xuICAgICAgICAgICAgICAgIHMgPSBzLnBhcmVudE5vZGU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyB0aGUgb3duZXIgZWxlbWVudCBpcyBleHBlY3RlZCB0byBiZSBhIERvY3VtZW50IG9yIFNoYWRvd1Jvb3RcbiAgICAgICAgICAgIGlmIChzLm5vZGVUeXBlICE9IE5vZGUuRE9DVU1FTlRfTk9ERSAmJiBzLm5vZGVUeXBlICE9IE5vZGUuRE9DVU1FTlRfRlJBR01FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHMgPSBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBzO1xuICAgICAgICB9LFxuICAgICAgICBmaW5kVGFyZ2V0OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgaW5FdmVudC5wYXRoICYmIGluRXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5FdmVudC5wYXRoWzBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHggPSBpbkV2ZW50LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgeSA9IGluRXZlbnQuY2xpZW50WTtcbiAgICAgICAgICAgIC8vIGlmIHRoZSBsaXN0ZW5lciBpcyBpbiB0aGUgc2hhZG93IHJvb3QsIGl0IGlzIG11Y2ggZmFzdGVyIHRvIHN0YXJ0IHRoZXJlXG4gICAgICAgICAgICB2YXIgcyA9IHRoaXMub3duZXIoaW5FdmVudC50YXJnZXQpO1xuICAgICAgICAgICAgLy8gaWYgeCwgeSBpcyBub3QgaW4gdGhpcyByb290LCBmYWxsIGJhY2sgdG8gZG9jdW1lbnQgc2VhcmNoXG4gICAgICAgICAgICBpZiAoIXMuZWxlbWVudEZyb21Qb2ludCh4LCB5KSkge1xuICAgICAgICAgICAgICAgIHMgPSBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzLnNlYXJjaFJvb3QocywgeCwgeSk7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUb3VjaEFjdGlvbjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIG47XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgaW5FdmVudC5wYXRoICYmIGluRXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB2YXIgcGF0aCA9IGluRXZlbnQucGF0aDtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHBhdGgubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgbiA9IHBhdGhbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChuLm5vZGVUeXBlID09PSBOb2RlLkVMRU1FTlRfTk9ERSAmJiBuLmhhc0F0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuLmdldEF0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIG4gPSBpbkV2ZW50LnRhcmdldDtcbiAgICAgICAgICAgICAgICB3aGlsZSAobikge1xuICAgICAgICAgICAgICAgICAgICBpZiAobi5ub2RlVHlwZSA9PT0gTm9kZS5FTEVNRU5UX05PREUgJiYgbi5oYXNBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbi5nZXRBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGF1dG8gaXMgZGVmYXVsdFxuICAgICAgICAgICAgcmV0dXJuIFwiYXV0b1wiO1xuICAgICAgICB9LFxuICAgICAgICBMQ0E6IGZ1bmN0aW9uKGEsIGIpIHtcbiAgICAgICAgICAgIGlmIChhID09PSBiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYSAmJiAhYikge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGIgJiYgIWEpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghYiAmJiAhYSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGZhc3QgY2FzZSwgYSBpcyBhIGRpcmVjdCBkZXNjZW5kYW50IG9mIGIgb3IgdmljZSB2ZXJzYVxuICAgICAgICAgICAgaWYgKGEuY29udGFpbnMgJiYgYS5jb250YWlucyhiKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGIuY29udGFpbnMgJiYgYi5jb250YWlucyhhKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGFkZXB0aCA9IHRoaXMuZGVwdGgoYSk7XG4gICAgICAgICAgICB2YXIgYmRlcHRoID0gdGhpcy5kZXB0aChiKTtcbiAgICAgICAgICAgIHZhciBkID0gYWRlcHRoIC0gYmRlcHRoO1xuICAgICAgICAgICAgaWYgKGQgPj0gMCkge1xuICAgICAgICAgICAgICAgIGEgPSB0aGlzLndhbGsoYSwgZCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGIgPSB0aGlzLndhbGsoYiwgLWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd2hpbGUgKGEgJiYgYiAmJiBhICE9PSBiKSB7XG4gICAgICAgICAgICAgICAgYSA9IGEucGFyZW50Tm9kZSB8fCBhLmhvc3Q7XG4gICAgICAgICAgICAgICAgYiA9IGIucGFyZW50Tm9kZSB8fCBiLmhvc3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gYTtcbiAgICAgICAgfSxcbiAgICAgICAgd2FsazogZnVuY3Rpb24obiwgdSkge1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IG4gJiYgKGkgPCB1KTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbiA9IG4ucGFyZW50Tm9kZSB8fCBuLmhvc3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gbjtcbiAgICAgICAgfSxcbiAgICAgICAgZGVwdGg6IGZ1bmN0aW9uKG4pIHtcbiAgICAgICAgICAgIHZhciBkID0gMDtcbiAgICAgICAgICAgIHdoaWxlIChuKSB7XG4gICAgICAgICAgICAgICAgZCsrO1xuICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGQ7XG4gICAgICAgIH0sXG4gICAgICAgIGRlZXBDb250YWluczogZnVuY3Rpb24oYSwgYikge1xuICAgICAgICAgICAgdmFyIGNvbW1vbiA9IHRoaXMuTENBKGEsIGIpO1xuICAgICAgICAgICAgLy8gaWYgYSBpcyB0aGUgY29tbW9uIGFuY2VzdG9yLCBpdCBtdXN0IFwiZGVlcGx5XCIgY29udGFpbiBiXG4gICAgICAgICAgICByZXR1cm4gY29tbW9uID09PSBhO1xuICAgICAgICB9LFxuICAgICAgICBpbnNpZGVOb2RlOiBmdW5jdGlvbihub2RlLCB4LCB5KSB7XG4gICAgICAgICAgICB2YXIgcmVjdCA9IG5vZGUuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7XG4gICAgICAgICAgICByZXR1cm4gKHJlY3QubGVmdCA8PSB4KSAmJiAoeCA8PSByZWN0LnJpZ2h0KSAmJiAocmVjdC50b3AgPD0geSkgJiYgKHkgPD0gcmVjdC5ib3R0b20pO1xuICAgICAgICB9LFxuICAgICAgICBwYXRoOiBmdW5jdGlvbihldmVudCkge1xuICAgICAgICAgICAgdmFyIHA7XG4gICAgICAgICAgICBpZiAoaGFzRnVsbFBhdGggJiYgZXZlbnQucGF0aCAmJiBldmVudC5wYXRoLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHAgPSBldmVudC5wYXRoO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwID0gW107XG4gICAgICAgICAgICAgICAgdmFyIG4gPSB0aGlzLmZpbmRUYXJnZXQoZXZlbnQpO1xuICAgICAgICAgICAgICAgIHdoaWxlIChuKSB7XG4gICAgICAgICAgICAgICAgICAgIHAucHVzaChuKTtcbiAgICAgICAgICAgICAgICAgICAgbiA9IG4ucGFyZW50Tm9kZSB8fCBuLmhvc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHA7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIHNjb3BlLnRhcmdldEZpbmRpbmcgPSB0YXJnZXQ7XG4gICAgLyoqXG4gICAgICogR2l2ZW4gYW4gZXZlbnQsIGZpbmRzIHRoZSBcImRlZXBlc3RcIiBub2RlIHRoYXQgY291bGQgaGF2ZSBiZWVuIHRoZSBvcmlnaW5hbCB0YXJnZXQgYmVmb3JlIFNoYWRvd0RPTSByZXRhcmdldHRpbmdcbiAgICAgKlxuICAgICAqIEBwYXJhbSB7RXZlbnR9IEV2ZW50IEFuIGV2ZW50IG9iamVjdCB3aXRoIGNsaWVudFggYW5kIGNsaWVudFkgcHJvcGVydGllc1xuICAgICAqIEByZXR1cm4ge0VsZW1lbnR9IFRoZSBwcm9iYWJsZSBldmVudCBvcmlnbmluYXRvclxuICAgICAqL1xuICAgIHNjb3BlLmZpbmRUYXJnZXQgPSB0YXJnZXQuZmluZFRhcmdldC5iaW5kKHRhcmdldCk7XG4gICAgLyoqXG4gICAgICogRGV0ZXJtaW5lcyBpZiB0aGUgXCJjb250YWluZXJcIiBub2RlIGRlZXBseSBjb250YWlucyB0aGUgXCJjb250YWluZWVcIiBub2RlLCBpbmNsdWRpbmcgc2l0dWF0aW9ucyB3aGVyZSB0aGUgXCJjb250YWluZWVcIiBpcyBjb250YWluZWQgYnkgb25lIG9yIG1vcmUgU2hhZG93RE9NXG4gICAgICogcm9vdHMuXG4gICAgICpcbiAgICAgKiBAcGFyYW0ge05vZGV9IGNvbnRhaW5lclxuICAgICAqIEBwYXJhbSB7Tm9kZX0gY29udGFpbmVlXG4gICAgICogQHJldHVybiB7Qm9vbGVhbn1cbiAgICAgKi9cbiAgICBzY29wZS5kZWVwQ29udGFpbnMgPSB0YXJnZXQuZGVlcENvbnRhaW5zLmJpbmQodGFyZ2V0KTtcblxuICAgIC8qKlxuICAgICAqIERldGVybWluZXMgaWYgdGhlIHgveSBwb3NpdGlvbiBpcyBpbnNpZGUgdGhlIGdpdmVuIG5vZGUuXG4gICAgICpcbiAgICAgKiBFeGFtcGxlOlxuICAgICAqXG4gICAgICogICAgIGZ1bmN0aW9uIHVwSGFuZGxlcihldmVudCkge1xuICAgICAqICAgICAgIHZhciBpbm5vZGUgPSBQb2x5bWVyR2VzdHVyZXMuaW5zaWRlTm9kZShldmVudC50YXJnZXQsIGV2ZW50LmNsaWVudFgsIGV2ZW50LmNsaWVudFkpO1xuICAgICAqICAgICAgIGlmIChpbm5vZGUpIHtcbiAgICAgKiAgICAgICAgIC8vIHdhaXQgZm9yIHRhcD9cbiAgICAgKiAgICAgICB9IGVsc2Uge1xuICAgICAqICAgICAgICAgLy8gdGFwIHdpbGwgbmV2ZXIgaGFwcGVuXG4gICAgICogICAgICAgfVxuICAgICAqICAgICB9XG4gICAgICpcbiAgICAgKiBAcGFyYW0ge05vZGV9IG5vZGVcbiAgICAgKiBAcGFyYW0ge051bWJlcn0geCBTY3JlZW4gWCBwb3NpdGlvblxuICAgICAqIEBwYXJhbSB7TnVtYmVyfSB5IHNjcmVlbiBZIHBvc2l0aW9uXG4gICAgICogQHJldHVybiB7Qm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ZGQgc2hhZG93IHNlbGVjdG9ycyBpZiBzaGFkb3dkb20gaXMgc3VwcG9ydGVkXG4gICAgdmFyIGhhc1NoYWRvd1Jvb3QgPSAhd2luZG93LlNoYWRvd0RPTVBvbHlmaWxsICYmIGRvY3VtZW50LmhlYWQuY3JlYXRlU2hhZG93Um9vdDtcblxuICAgIGlmIChoYXNUb3VjaEFjdGlvbikge1xuICAgICAgICBhdHRyaWIyY3NzLmZvckVhY2goZnVuY3Rpb24ocikge1xuICAgICAgICAgICAgaWYgKFN0cmluZyhyKSA9PT0gcikge1xuICAgICAgICAgICAgICAgIHN0eWxlcyArPSBzZWxlY3RvcihyKSArIHJ1bGUocikgKyAnXFxuJztcbiAgICAgICAgICAgICAgICBpZiAoaGFzU2hhZG93Um9vdCkge1xuICAgICAgICAgICAgICAgICAgICBzdHlsZXMgKz0gc2hhZG93U2VsZWN0b3IocikgKyBydWxlKHIpICsgJ1xcbic7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzdHlsZXMgKz0gci5zZWxlY3RvcnMubWFwKHNlbGVjdG9yKSArIHJ1bGUoci5ydWxlKSArICdcXG4nO1xuICAgICAgICAgICAgICAgIGlmIChoYXNTaGFkb3dSb290KSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlcyArPSByLnNlbGVjdG9ycy5tYXAoc2hhZG93U2VsZWN0b3IpICsgcnVsZShyLnJ1bGUpICsgJ1xcbic7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICB2YXIgZWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzdHlsZScpO1xuICAgICAgICBlbC50ZXh0Q29udGVudCA9IHN0eWxlcztcbiAgICAgICAgZG9jdW1lbnQuaGVhZC5hcHBlbmRDaGlsZChlbCk7XG4gICAgfVxufSkoKTtcblxuLyoqXG4gKiBUaGlzIGlzIHRoZSBjb25zd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JyxcbiAgICAgICAgJ3JlbGF0ZWRUYXJnZXQnLFxuICAgICAgICAncGFnZVgnLFxuICAgICAgICAncGFnZVknXG4gICAgXTtcblxuICAgIHZhciBNT1VTRV9ERUZBVUxUUyA9IFtcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBudWxsLFxuICAgICAgICBudWxsLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgMCxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgMCxcbiAgICAgICAgMFxuICAgIF07XG5cbiAgICB2YXIgTk9QX0ZBQ1RPUlkgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKCkge307XG4gICAgfTtcblxuICAgIHZhciBldmVudEZhY3RvcnkgPSB7XG4gICAgICAgIC8vIFRPRE8oZGZyZWVkbSk6IHRoaXMgaXMgb3ZlcnJpZGRlbiBieSB0YXAgcmVjb2duaXplciwgbmVlZHMgcmV2aWV3XG4gICAgICAgIHByZXZlbnRUYXA6IE5PUF9GQUNUT1JZLFxuICAgICAgICBtYWtlQmFzZUV2ZW50OiBmdW5jdGlvbihpblR5cGUsIGluRGljdCkge1xuICAgICAgICAgICAgdmFyIGUgPSBkb2N1bWVudC5jcmVhdGVFdmVudCgnRXZlbnQnKTtcbiAgICAgICAgICAgIGUuaW5pdEV2ZW50KGluVHlwZSwgaW5EaWN0LmJ1YmJsZXMgfHwgZmFsc2UsIGluRGljdC5jYW5jZWxhYmxlIHx8IGZhbHNlKTtcbiAgICAgICAgICAgIGUucHJldmVudFRhcCA9IGV2ZW50RmFjdG9yeS5wcmV2ZW50VGFwKGUpO1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIG1ha2VHZXN0dXJlRXZlbnQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5EaWN0KSB7XG4gICAgICAgICAgICBpbkRpY3QgPSBpbkRpY3QgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTtcblxuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLm1ha2VCYXNlRXZlbnQoaW5UeXBlLCBpbkRpY3QpO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGtleXMgPSBPYmplY3Qua2V5cyhpbkRpY3QpLCBrOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIGsgPSBrZXlzW2ldO1xuICAgICAgICAgICAgICAgIGlmIChrICE9PSAnYnViYmxlcycgJiYgayAhPT0gJ2NhbmNlbGFibGUnKSB7XG4gICAgICAgICAgICAgICAgICAgIGVba10gPSBpbkRpY3Rba107XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIG1ha2VQb2ludGVyRXZlbnQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5EaWN0KSB7XG4gICAgICAgICAgICBpbkRpY3QgPSBpbkRpY3QgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTtcblxuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLm1ha2VCYXNlRXZlbnQoaW5UeXBlLCBpbkRpY3QpO1xuICAgICAgICAgICAgLy8gZGVmaW5lIGluaGVyaXRlZCBNb3VzZUV2ZW50IHByb3BlcnRpZXNcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAyLCBwOyBpIDwgTU9VU0VfUFJPUFMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBwID0gTU9VU0VfUFJPUFNbaV07XG4gICAgICAgICAgICAgICAgZVtwXSA9IGluRGljdFtwXSB8fCBNT1VTRV9ERUZBVUxUU1tpXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGUuYnV0dG9ucyA9IGluRGljdC5idXR0b25zIHx8IDA7XG5cbiAgICAgICAgICAgIC8vIFNwZWMgcmVxdWlyZXMgdGhhdCBwb2ludGVycyB3aXRob3V0IHByZXNzdXJlIHNwZWNpZmllZCB1c2UgMC41IGZvciBkb3duXG4gICAgICAgICAgICAvLyBzdGF0ZSBhbmQgMCBmb3IgdXAgc3RhdGUuXG4gICAgICAgICAgICB2YXIgcHJlc3N1cmUgPSAwO1xuICAgICAgICAgICAgaWYgKGluRGljdC5wcmVzc3VyZSkge1xuICAgICAgICAgICAgICAgIHByZXNzdXJlID0gaW5EaWN0LnByZXNzdXJlO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwcmVzc3VyZSA9IGUuYnV0dG9ucyA/IDAuNSA6IDA7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIGFkZCB4L3kgcHJvcGVydGllcyBhbGlhc2VkIHRvIGNsaWVudFgvWVxuICAgICAgICAgICAgZS54ID0gZS5jbGllbnRYO1xuICAgICAgICAgICAgZS55ID0gZS5jbGllbnRZO1xuXG4gICAgICAgICAgICAvLyBkZWZpbmUgdGhlIHByb3BlcnRpZXMgb2YgdGhlIFBvaW50ZXJFdmVudCBpbnRlcmZhY2VcbiAgICAgICAgICAgIGUucG9pbnRlcklkID0gaW5EaWN0LnBvaW50ZXJJZCB8fCAwO1xuICAgICAgICAgICAgZS53aWR0aCA9IGluRGljdC53aWR0aCB8fCAwO1xuICAgICAgICAgICAgZS5oZWlnaHQgPSBpbkRpY3QuaGVpZ2h0IHx8IDA7XG4gICAgICAgICAgICBlLnByZXNzdXJlID0gcHJlc3N1cmU7XG4gICAgICAgICAgICBlLnRpbHRYID0gaW5EaWN0LnRpbHRYIHx8IDA7XG4gICAgICAgICAgICBlLnRpbHRZID0gaW5EaWN0LnRpbHRZIHx8IDA7XG4gICAgICAgICAgICBlLnBvaW50ZXJUeXBlID0gaW5EaWN0LnBvaW50ZXJUeXBlIHx8ICc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gICAgICAgaWYgKGkgPiAtMSkge1xuICAgICAgICAgICAgICAgIHRoaXMudmFsdWVzW2ldID0gaW5FdmVudDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5rZXlzLnB1c2goaW5JZCk7XG4gICAgICAgICAgICAgICAgdGhpcy52YWx1ZXMucHVzaChpbkV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgaGFzOiBmdW5jdGlvbihpbklkKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5rZXlzLmluZGV4T2YoaW5JZCkgPiAtMTtcbiAgICAgICAgfSxcbiAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uKGluSWQpIHtcbiAgICAgICAgICAgIHZhciBpID0gdGhpcy5rZXlzLmluZGV4T2YoaW5JZCk7XG4gICAgICAgICAgICBpZiAoaSA+IC0xKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5rZXlzLnNwbGljZShpLCAxKTtcbiAgICAgICAgICAgICAgICB0aGlzLnZhbHVlcy5zcGxpY2UoaSwgMSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGdldDogZnVuY3Rpb24oaW5JZCkge1xuICAgICAgICAgICAgdmFyIGkgPSB0aGlzLmtleXMuaW5kZXhPZihpbklkKTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnZhbHVlc1tpXTtcbiAgICAgICAgfSxcbiAgICAgICAgY2xlYXI6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdGhpcy5rZXlzLmxlbmd0aCA9IDA7XG4gICAgICAgICAgICB0aGlzLnZhbHVlcy5sZW5ndGggPSAwO1xuICAgICAgICB9LFxuICAgICAgICAvLyByZXR1cm4gdmFsdWUsIGtleSwgbWFwXG4gICAgICAgIGZvckVhY2g6IGZ1bmN0aW9uKGNhbGxiYWNrLCB0aGlzQXJnKSB7XG4gICAgICAgICAgICB0aGlzLnZhbHVlcy5mb3JFYWNoKGZ1bmN0aW9uKHYsIGkpIHtcbiAgICAgICAgICAgICAgICBjYWxsYmFjay5jYWxsKHRoaXNBcmcsIHYsIHRoaXMua2V5c1tpXSwgdGhpcyk7XG4gICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgfSxcbiAgICAgICAgcG9pbnRlcnM6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMua2V5cy5sZW5ndGg7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc2NvcGUuUG9pbnRlck1hcCA9IFBvaW50ZXJNYXA7XG59KShleHBvcnRzKTtcblxuKGZ1bmN0aW9uKHNjb3BlKSB7XG4gICAgdmFyIENMT05FX1BST1BTID0gW1xuICAgICAgICAvLyBNb3VzZUV2ZW50XG4gICAgICAgICdidWJibGVzJyxcbiAgICAgICAgJ2NhbmNlbGFibGUnLFxuICAgICAgICAndmlldycsXG4gICAgICAgICdkZXRhaWwnLFxuICAgICAgICAnc2NyZWVuWCcsXG4gICAgICAgICdzY3JlZW5ZJyxcbiAgICAgICAgJ2NsaWVudFgnLFxuICAgICAgICAnY2xpZW50WScsXG4gICAgICAgICdjdHJsS2V5JyxcbiAgICAgICAgJ2FsdEtleScsXG4gICAgICAgICdzaGlmdEtleScsXG4gICAgICAgICdtZXRhS2V5JyxcbiAgICAgICAgJ2J1dHRvbicsXG4gICAgICAgICdyZWxhdGVkVGFyZ2V0JyxcbiAgICAgICAgLy8gRE9NIExldmVsIDNcbiAgICAgICAgJ2J1dHRvbnMnLFxuICAgICAgICAvLyBQb2ludGVyRXZlbnRcbiAgICAgICAgJ3BvaW50ZXJJZCcsXG4gICAgICAgICd3aWR0aCcsXG4gICAgICAgICdoZWlnaHQnLFxuICAgICAgICAncHJlc3N1cmUnLFxuICAgICAgICAndGlsdFgnLFxuICAgICAgICAndGlsdFknLFxuICAgICAgICAncG9pbnRlclR5cGUnLFxuICAgICAgICAnaHdUaW1lc3RhbXAnLFxuICAgICAgICAnaXNQcmltYXJ5JyxcbiAgICAgICAgLy8gZXZlbnQgaW5zdGFuY2VcbiAgICAgICAgJ3R5cGUnLFxuICAgICAgICAndGFyZ2V0JyxcbiAgICAgICAgJ2N1cnJlbnRUYXJnZXQnLFxuICAgICAgICAnd2hpY2gnLFxuICAgICAgICAncGFnZVgnLFxuICAgICAgICAncGFnZVknLFxuICAgICAgICAndGltZVN0YW1wJyxcbiAgICAgICAgLy8gZ2VzdHVyZSBhZGRvbnNcbiAgICAgICAgJ3ByZXZlbnRUYXAnLFxuICAgICAgICAndGFwUHJldmVudGVkJyxcbiAgICAgICAgJ19zb3VyY2UnXG4gICAgXTtcblxuICAgIHZhciBDTE9ORV9ERUZBVUxUUyA9IFtcbiAgICAgICAgLy8gTW91c2VFdmVudFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIG51bGwsXG4gICAgICAgIG51bGwsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICAwLFxuICAgICAgICBudWxsLFxuICAgICAgICAvLyBET00gTGV2ZWwgM1xuICAgICAgICAwLFxuICAgICAgICAvLyBQb2ludGVyRXZlbnRcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgJycsXG4gICAgICAgIDAsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICAvLyBldmVudCBpbnN0YW5jZVxuICAgICAgICAnJyxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgMCxcbiAgICAgICAgZnVuY3Rpb24oKSB7fSxcbiAgICAgICAgZmFsc2V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IGNvbnRhaW4gYW4gYXJyYXkgb2YgZXZlbnQgbmFtZXMgbmFtZWQgYGV2ZW50c2AsIGFuZFxuICAgICAgICAgKiBmdW5jdGlvbnMgd2l0aCB0aGUgbmFtZXMgc3BlY2lmaWVkIGluIHRoZSBgZXZlbnRzYCBhcnJheS5cbiAgICAgICAgICogQHBhcmFtIHtzdHJpbmd9IG5hbWUgQSBuYW1lIGZvciB0aGUgZXZlbnQgc291cmNlXG4gICAgICAgICAqIEBwYXJhbSB7T2JqZWN0fSBzb3VyY2UgQSBuZXcgc291cmNlIG9mIHBsYXRmb3JtIGV2ZW50cy5cbiAgICAgICAgICovXG4gICAgICAgIHJlZ2lzdGVyU291cmNlOiBmdW5jdGlvbihuYW1lLCBzb3VyY2UpIHtcbiAgICAgICAgICAgIHZhciBzID0gc291cmNlO1xuICAgICAgICAgICAgdmFyIG5ld0V2ZW50cyA9IHMuZXZlbnRzO1xuICAgICAgICAgICAgaWYgKG5ld0V2ZW50cykge1xuICAgICAgICAgICAgICAgIG5ld0V2ZW50cy5mb3JFYWNoKGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNbZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXZlbnRNYXBbZV0gPSBzW2VdLmJpbmQocyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgICAgICAgICB0aGlzLmV2ZW50U291cmNlc1tuYW1lXSA9IHM7XG4gICAgICAgICAgICAgICAgdGhpcy5ldmVudFNvdXJjZUxpc3QucHVzaChzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgcmVnaXN0ZXJHZXN0dXJlOiBmdW5jdGlvbihuYW1lLCBzb3VyY2UpIHtcbiAgICAgICAgICAgIHZhciBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpO1xuICAgICAgICAgICAgb2JqLmxpc3RlbmVycyA9IDA7XG4gICAgICAgICAgICBvYmouaW5kZXggPSB0aGlzLmdlc3R1cmVzLmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBnOyBpIDwgc291cmNlLmV4cG9zZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBnID0gc291cmNlLmV4cG9zZXNbaV0udG9Mb3dlckNhc2UoKTtcbiAgICAgICAgICAgICAgICB0aGlzLmRlcGVuZGVuY3lNYXBbZ10gPSBvYmo7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmdlc3R1cmVzLnB1c2goc291cmNlKTtcbiAgICAgICAgfSxcbiAgICAgICAgcmVnaXN0ZXI6IGZ1bmN0aW9uKGVsZW1lbnQsIGluaXRpYWwpIHtcbiAgICAgICAgICAgIHZhciBsID0gdGhpcy5ldmVudFNvdXJjZUxpc3QubGVuZ3RoO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGVzO1xuICAgICAgICAgICAgICAgIChpIDwgbCkgJiYgKGVzID0gdGhpcy5ldmVudFNvdXJjZUxpc3RbaV0pOyBpKyspIHtcbiAgICAgICAgICAgICAgICAvLyBjYWxsIGV2ZW50c291cmNlIHJlZ2lzdGVyXG4gICAgICAgICAgICAgICAgZXMucmVnaXN0ZXIuY2FsbChlcywgZWxlbWVudCwgaW5pdGlhbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHVucmVnaXN0ZXI6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIHZhciBsID0gdGhpcy5ldmVudFNvdXJjZUxpc3QubGVuZ3RoO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGVzO1xuICAgICAgICAgICAgICAgIChpIDwgbCkgJiYgKGVzID0gdGhpcy5ldmVudFNvdXJjZUxpc3RbaV0pOyBpKyspIHtcbiAgICAgICAgICAgICAgICAvLyBjYWxsIGV2ZW50c291cmNlIHJlZ2lzdGVyXG4gICAgICAgICAgICAgICAgZXMudW5yZWdpc3Rlci5jYWxsKGVzLCBlbGVtZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gRVZFTlRTXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMucmVxdWlyZWRHZXN0dXJlcy5zZXQoaW5FdmVudC5wb2ludGVySWQsIGN1cnJlbnRHZXN0dXJlcyk7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgnZG93bicsIGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICBtb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICAvLyBwaXBlIG1vdmUgZXZlbnRzIGludG8gZ2VzdHVyZSBxdWV1ZSBkaXJlY3RseVxuICAgICAgICAgICAgaW5FdmVudC50eXBlID0gJ21vdmUnO1xuICAgICAgICAgICAgdGhpcy5maWxsR2VzdHVyZVF1ZXVlKGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdGhpcy5maXJlRXZlbnQoJ3VwJywgaW5FdmVudCk7XG4gICAgICAgICAgICB0aGlzLnJlcXVpcmVkR2VzdHVyZXMuZGVsZXRlKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpbkV2ZW50LnRhcFByZXZlbnRlZCA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgndXAnLCBpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMucmVxdWlyZWRHZXN0dXJlcy5kZWxldGUoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBhZGRHZXN0dXJlRGVwZW5kZW5jeTogZnVuY3Rpb24obm9kZSwgY3VycmVudEdlc3R1cmVzKSB7XG4gICAgICAgICAgICB2YXIgZ2VzdHVyZXNXYW50ZWQgPSBub2RlLl9wZ0V2ZW50cztcbiAgICAgICAgICAgIGlmIChnZXN0dXJlc1dhbnRlZCAmJiBjdXJyZW50R2VzdHVyZXMpIHtcbiAgICAgICAgICAgICAgICB2YXIgZ2sgPSBPYmplY3Qua2V5cyhnZXN0dXJlc1dhbnRlZCk7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIHIsIHJpLCBnOyBpIDwgZ2subGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZ2VzdHVyZVxuICAgICAgICAgICAgICAgICAgICBnID0gZ2tbaV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChnZXN0dXJlc1dhbnRlZFtnXSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGxvb2t1cCBnZXN0dXJlIHJlY29nbml6ZXJcbiAgICAgICAgICAgICAgICAgICAgICAgIHIgPSB0aGlzLmRlcGVuZGVuY3lNYXBbZ107XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyByZWNvZ25pemVyIGluZGV4XG4gICAgICAgICAgICAgICAgICAgICAgICByaSA9IHIgPyByLmluZGV4IDogLTE7XG4gICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50R2VzdHVyZXNbcmldID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gTElTVEVORVIgTE9HSUNcbiAgICAgICAgZXZlbnRIYW5kbGVyOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICAvLyBUaGlzIGlzIHVzZWQgdG8gcHJldmVudCBtdWx0aXBsZSBkaXNwYXRjaCBvZiBldmVudHMgZnJvbVxuICAgICAgICAgICAgLy8gcGxhdGZvcm0gZXZlbnRzLiBUaGlzIGNhbiBoYXBwZW4gd2hlbiB0d28gZWxlbWVudHMgaW4gZGlmZmVyZW50IHNjb3Blc1xuICAgICAgICAgICAgLy8gYXJlIHNldCB1cCB0byBjcmVhdGUgcG9pbnRlciBldmVudHMsIHdoaWNoIGlzIHJlbGV2YW50IHRvIFNoYWRvdyBET00uXG5cbiAgICAgICAgICAgIHZhciB0eXBlID0gaW5FdmVudC50eXBlO1xuXG4gICAgICAgICAgICAvLyBvbmx5IGdlbmVyYXRlIHRoZSBsaXN0IG9mIGRlc2lyZWQgZXZlbnRzIG9uIFwiZG93blwiXG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnIHx8IHR5cGUgPT09ICdtb3VzZWRvd24nIHx8IHR5cGUgPT09ICdwb2ludGVyZG93bicgfHwgdHlwZSA9PT0gJ01TUG9pbnRlckRvd24nKSB7XG4gICAgICAgICAgICAgICAgaWYgKCFpbkV2ZW50Ll9oYW5kbGVkQnlQRykge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50R2VzdHVyZXMgPSB7fTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBpbiBJT1MgbW9kZSwgdGhlcmUgaXMgb25seSBhIGxpc3RlbmVyIG9uIHRoZSBkb2N1bWVudCwgc28gdGhpcyBpcyBub3QgcmUtZW50cmFudFxuICAgICAgICAgICAgICAgIGlmICh0aGlzLklTX0lPUykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZXYgPSBpbkV2ZW50O1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgY3QgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gc2V0IHVwIGEgZmFrZSBldmVudCB0byBnaXZlIHRvIHRoZSBwYXRoIGJ1aWxkZXJcbiAgICAgICAgICAgICAgICAgICAgICAgIGV2ID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaW5FdmVudC50YXJnZXQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WDogY3QuY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRZOiBjdC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IGluRXZlbnQucGF0aFxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAvLyB1c2UgZXZlbnQgcGF0aCBpZiBhdmFpbGFibGUsIG90aGVyd2lzZSBidWlsZCBhIHBhdGggZnJvbSB0YXJnZXQgZmluZGluZ1xuICAgICAgICAgICAgICAgICAgICB2YXIgbm9kZXMgPSBpbkV2ZW50LnBhdGggfHwgc2NvcGUudGFyZ2V0RmluZGluZy5wYXRoKGV2KTtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIG47IGkgPCBub2Rlcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbiA9IG5vZGVzW2ldO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRHZXN0dXJlRGVwZW5kZW5jeShuLCBjdXJyZW50R2VzdHVyZXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRHZXN0dXJlRGVwZW5kZW5jeShpbkV2ZW50LmN1cnJlbnRUYXJnZXQsIGN1cnJlbnRHZXN0dXJlcyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoaW5FdmVudC5faGFuZGxlZEJ5UEcpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZm4gPSB0aGlzLmV2ZW50TWFwICYmIHRoaXMuZXZlbnRNYXBbdHlwZV07XG4gICAgICAgICAgICBpZiAoZm4pIHtcbiAgICAgICAgICAgICAgICBmbihpbkV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGluRXZlbnQuX2hhbmRsZWRCeVBHID0gdHJ1ZTtcbiAgICAgICAgfSxcbiAgICAgICAgLy8gc2V0IHVwIGV2ZW50IGxpc3RlbmVyc1xuICAgICAgICBsaXN0ZW46IGZ1bmN0aW9uKHRhcmdldCwgZXZlbnRzKSB7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbCA9IGV2ZW50cy5sZW5ndGgsIGU7XG4gICAgICAgICAgICAgICAgKGkgPCBsKSAmJiAoZSA9IGV2ZW50c1tpXSk7IGkrKykge1xuICAgICAgICAgICAgICAgIHRoaXMuYWRkRXZlbnQodGFyZ2V0LCBlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgLy8gcmVtb3ZlIGV2ZW50IGxpc3RlbmVyc1xuICAgICAgICB1bmxpc3RlbjogZnVuY3Rpb24odGFyZ2V0LCBldmVudHMpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsID0gZXZlbnRzLmxlbmd0aCwgZTtcbiAgICAgICAgICAgICAgICAoaSA8IGwpICYmIChlID0gZXZlbnRzW2ldKTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVFdmVudCh0YXJnZXQsIGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBhZGRFdmVudDogZnVuY3Rpb24odGFyZ2V0LCBldmVudE5hbWUpIHtcbiAgICAgICAgICAgIHRhcmdldC5hZGRFdmVudExpc3RlbmVyKGV2ZW50TmFtZSwgdGhpcy5ib3VuZEhhbmRsZXIpO1xuICAgICAgICB9LFxuICAgICAgICByZW1vdmVFdmVudDogZnVuY3Rpb24odGFyZ2V0LCBldmVudE5hbWUpIHtc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sXG4gICAgICAgIGZpcmVFdmVudDogZnVuY3Rpb24oaW5UeXBlLCBpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMubWFrZUV2ZW50KGluVHlwZSwgaW5FdmVudCk7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogUmV0dXJucyBhIHNuYXBzaG90IG9mIGluRXZlbnQsIHdpdGggd3JpdGFibGUgcHJvcGVydGllcy5cbiAgICAgICAgICpcbiAgICAgICAgICogQHBhcmFtIHtFdmVudH0gaW5FdmVudCBBbiBldmVudCB0aGF0IGNvbnRhaW5zIHByb3BlcnRpZXMgdG8gY29weS5cbiAgICAgICAgICogQHJldHVybiB7T2JqZWN0fSBBbiBvYmplY3QgY29udGFpbmluZyBzaGFsbG93IGNvcGllcyBvZiBgaW5FdmVudGAnc1xuICAgICAgICAgKiAgICBwcm9wZXJ0aWVzLlxuICAgICAgICAgKi9cbiAgICAgICAgY2xvbmVFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGV2ZW50Q29weSA9IE9iamVjdC5jcmVhdGUobnVsbCksXG4gICAgICAgICAgICAgICAgcDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgQ0xPTkVfUFJPUFMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBwID0gQ0xPTkVfUFJPUFNbaV07XG4gICAgICAgICAgICAgICAgZXZlbnRDb3B5W3BdID0gaW5FdmVudFtwXSB8fCBDTE9ORV9ERUZBVUxUU1tpXTtcbiAgICAgICAgICAgICAgICAvLyBXb3JrIGFyb3VuZCBTVkdJbnN0YW5jZUVsZW1lbnQgc2hhZG93IHRyZWVcbiAgICAgICAgICAgICAgICAvLyBSZXR1cm4gdGhlIDx1c2U+IGVsZW1lbnQgdGhhdCBpcyByZXByZXNlbnRlZCBieSB0aGUgaW5zdGFuY2UgZm9yIFNhZmFyaSwgQ2hyb21lLCBJRS5cbiAgICAgICAgICAgICAgICAvLyBUaGlzIGlzIHRoZSBiZWhhdmlvciBpbXBsZW1lbnRlZCBieSBGaXJlZm94LlxuICAgICAgICAgICAgICAgIGlmIChwID09PSAndGFyZ2V0JyB8fCBwID09PSAncmVsYXRlZFRhcmdldCcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKEhBU19TVkdfSU5TVEFOQ0UgJiYgZXZlbnRDb3B5W3BdIGluc3RhbmNlb2YgU1ZHRWxlbWVudEluc3RhbmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBldmVudENvcHlbcF0gPSBldmVudENvcHlbcF0uY29ycmVzcG9uZGluZ1VzZUVsZW1lbnQ7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBrZWVwIHRoZSBzZW1hbnRpY3Mgb2YgcHJldmVudERlZmF1bHRcbiAgICAgICAgICAgIGV2ZW50Q29weS5wcmV2ZW50RGVmYXVsdCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGluRXZlbnQucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICByZXR1cm4gZXZlbnRDb3B5O1xuICAgICAgICB9LFxuICAgICAgICAvKipcbiAgICAgICAgICogRGlzcGF0Y2hlcyB0aGUgZXZlbnQgdG8gaXRzIHRhcmdldC5cbiAgICAgICAgICpcbiAgICAgICAgICogQHBhcmFtIHtFdmVudH0gaW5FdmVudCBUaGUgZXZlbnQgdG8gYmUgZGlzcGF0Y2hlZC5cbiAgICAgICAgICogQHJldHVybiB7Qm9vbGVhbn0gVHJ1ZSBpZiBhbiBldmVudCBoYW5kbGVyIHJldHVybnMgdHJ1ZSwgZmFsc2Ugb3RoZXJ3aXNlLlxuICAgICAgICAgKi9cbiAgICAgICAgZGlzcGF0Y2hFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHQgPSBpbkV2ZW50Ll90YXJnZXQ7XG4gICAgICAgICAgICBpZiAodCkge1xuICAgICAgICAgICAgICAgIHQuZGlzcGF0Y2hFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICAvLyBjbG9uZSB0aGUgZXZlbnQgZm9yIHRoZSBnZXN0dXJlIHN5c3RlbSB0byBwcm9jZXNzXG4gICAgICAgICAgICAgICAgLy8gY2xvbmUgYWZ0ZXIgZGlzcGF0Y2ggdG8gcGljayB1cCBnZXN0dXJlIHByZXZlbnRpb24gY29kZVxuICAgICAgICAgICAgICAgIHZhciBjbG9uZSA9IHRoaXMuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBjbG9uZS50YXJnZXQgPSB0O1xuICAgICAgICAgICAgICAgIHRoaXMuZmlsbEdlc3R1cmVRdWV1ZShjbG9uZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGdlc3R1cmVUcmlnZ2VyOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIC8vIHByb2Nlc3MgdGhlIGdlc3R1cmUgcXVldWVcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBlLCByZzsgaSA8IHRoaXMuZ2VzdHVyZVF1ZXVlLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgZSA9IHRoaXMuZ2VzdHVyZVF1ZXVlW2ldO1xuICAgICAgICAgICAgICAgIHJnID0gZS5fcmVxdWlyZWRHZXN0dXJlcztcbiAgICAgICAgICAgICAgICBpZiAocmcpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IDAsIGcsIGZuOyBqIDwgdGhpcy5nZXN0dXJlcy5sZW5ndGg7IGorKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gb25seSBydW4gcmVjb2duaXplciBpZiBhbiBlbGVtZW50IGluIHRoZSBzb3VyY2UgZXZlbnQncyBwYXRoIGlzIGxpc3RlbmluZyBmb3IgdGhvc2UgZ2VzdHVyZXNcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZ1tqXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGcgPSB0aGlzLmdlc3R1cmVzW2pdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuID0gZ1tlLnR5cGVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbi5jYWxsKGcsIGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuZ2VzdHVyZVF1ZXVlLmxlbmd0aCA9IDA7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbGxHZXN0dXJlUXVldWU6IGZ1bmN0aW9uKGV2KSB7XG4gICAgICAgICAgICAvLyBvbmx5IHRyaWdnZXIgdGhlIGdlc3R1cmUgcXVldWUgb25jZVxuICAgICAgICAgICAgaWYgKCF0aGlzLmdlc3R1cmVRdWV1ZS5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUodGhpcy5ib3VuZEdlc3R1cmVUcmlnZ2VyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGV2Ll9yZXF1aXJlZEdlc3R1cmVzID0gdGhpcy5yZXF1aXJlZEdlc3R1cmVzLmdldChldi5wb2ludGVySWQpO1xuICAgICAgICAgICAgdGhpcy5nZXN0dXJlUXVldWUucHVzaChldik7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIGRpc3BhdGNoZXIuYm91bmRIYW5kbGVyID0gZGlzcGF0Y2hlci5ldmVudEhhbmRsZXIuYmluZChkaX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gICAgICAgICB9XG4gICAgICAgICAgICAvLyBUT0RPKGRmcmVlZG0pOiByZS1ldmFsdWF0ZSBib29ra2VlcGluZyB0byBhdm9pZCB1c2luZyBhdHRyaWJ1dGVzXG4gICAgICAgICAgICBpZiAocmVjb2duaXplcikge1xuICAgICAgICAgICAgICAgIHZhciB0b3VjaEFjdGlvbiA9IHJlY29nbml6ZXIuZGVmYXVsdEFjdGlvbnMgJiYgcmVjb2duaXplci5kZWZhdWx0QWN0aW9uc1tnXTtcbiAgICAgICAgICAgICAgICB2YXIgYWN0aW9uTm9kZTtcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKG5vZGUubm9kZVR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBOb2RlLkVMRU1FTlRfTk9ERTpcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbk5vZGUgPSBub2RlO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgTm9kZS5ET0NVTUVOVF9GUkFHTUVOVF9OT0RFOlxuICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZSA9IG5vZGUuaG9zdDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZSA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHRvdWNoQWN0aW9uICYmIGFjdGlvbk5vZGUgJiYgIWFjdGlvbk5vZGUuaGFzQXR0cmlidXRlKCd0b3VjaC1hY3Rpb24nKSkge1xuICAgICAgICAgICAgICAgICAgICBhY3Rpb25Ob2RlLnNldEF0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJywgdG91Y2hBY3Rpb24pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAg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sIHRoZSB1bmRlcmx5aW5nIGdlc3R1cmUgcmVjb2duaXplciBpcyBkaXNhYmxlZC5cbiAgICAgKlxuICAgICAqIEBwYXJhbSB7RWxlbWVudH0gbm9kZVxuICAgICAqIEBwYXJhbSB7c3RyaW5nfSBnZXN0dXJlXG4gICAgICogQHJldHVybiBCb29sZWFuIGBnZXN0dXJlYCBpcyBhIHZhbGlkIGdlc3R1cmVcbiAgICAgKi9cbiAgICBzY29wZS5kZWFjdGl2YXRlR2VzdHVyZSA9IGZ1bmN0aW9uKG5vZGUsIGdlc3R1cmUpIHtcbiAgICAgICAgdmFyIGcgPSBnZXN0dXJlLnRvTG93ZXJDYXNlKCk7XG4gICAgICAgIHZhciBkZXAgPSBkaXNwYXRjaGVyLmRlcGVuZGVuY3lNYXBbZ107XG4gICAgICAgIGlmIChkZXApIHtcbiAgICAgICAgICAgIGlmIChub2RlLl9wZ0xpc3RlbmVycyA+IDApIHtcbiAgICAgICAgICAgICAgICBub2RlLl9wZ0xpc3RlbmVycy0tO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG5vZGUuX3BnTGlzdGVuZXJzID09PSAwKSB7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci51bnJlZ2lzdGVyKG5vZGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG5vZGUuX3BnRXZlbnRzKSB7XG4gICAgICAgICAgICAgICAgaWYgKG5vZGUuX3BnRXZlbnRzW2ddID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBub2RlLl9wZ0V2ZW50c1tnXS0tO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGUuX3BnRXZlbnRzW2ddID0gMDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIEJvb2xlYW4oZGVwKTtcbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogU3RvcCBsa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Z2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQubm9kZVR5cGUgPT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIGxhc3RUb3VjaGVzOiBbXSxcbiAgICAgICAgLy8gY29sbGlkZSB3aXRoIHRoZSBnbG9iYWwgbW91c2UgbGlzdGVuZXJcbiAgICAgICAgaXNFdmVudFNpbXVsYXRlZEZyb21Ub3VjaDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGx0cyA9IHRoaXMubGFzdFRvdWNoZXM7XG4gICAgICAgICAgICB2YXIgeCA9IGluRXZlbnQuY2xpZW50WCxcbiAgICAgICAgICAgICAgICB5ID0gaW5FdmVudC5jbGllbnRZO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBsdHMubGVuZ3RoLCB0OyBpIDwgbCAmJiAodCA9IGx0c1tpXSk7IGkrKykge1xuICAgICAgICAgICAgICAgIC8vIHNpbXVsYXRlZCBtb3VzZSBldmVudHMgd2lsbCBiZSBzd2FsbG93ZWQgbmVhciBhIHByaW1hcnkgdG91Y2hlbmRcbiAgICAgICAgICAgICAgICB2YXIgZHggPSBNYXRoLmFicyh4IC0gdC54KSxcbiAgICAgICAgICAgICAgICAgICAgZHkgPSBNYXRoLmFicyh5IC0gdC55KTtcbiAgICAgICAgICAgICAgICBpZiAoZHggPD0gREVEVVBfRElTVCAmJiBkeSA8PSBERURVUF9ESVNUKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucG9pbnRlcklkID0gdGhpcy5QT0lOVEVSX0lEO1xuICAgICAgICAgICAgZS5pc1ByaW1hcnkgPSB0cnVlO1xuICAgICAgICAgICAgZS5wb2ludGVyVHlwZSA9IHRoaXMuUE9JTlRFUl9UWVBFO1xuICAgICAgICAgICAgZS5fc291cmNlID0gJ21vdXNlJztcbiAgICAgICAgICAgIGlmICghSEFTX0JVVFRPTlMpIHtcbiAgICAgICAgICAgICAgICB2YXIgdHlwZSA9IGluRXZlbnQudHlwZTtcbiAgICAgICAgICAgICAgICB2YXIgYml0ID0gV0hJQ0hfVE9fQlVUVE9OU1tpbkV2ZW50LndoaWNoXSB8fCAwO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlID09PSAnbW91c2Vkb3duJykge1xuICAgICAgICAgICAgICAgICAgICBjdXJyZW50QnV0dG9ucyB8PSBiaXQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlID09PSAnbW91c2V1cCcpIHtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudEJ1dHRvbnMgJj0gfmJpdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZS5idXR0b25zID0gY3VycmVudEJ1dHRvbnM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gZTtcbiAgICAgICAgfSxcbiAgICAgICAgbW91c2Vkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuaXNFdmVudFNpbXVsYXRlZEZyb21Ub3VjaChpbkV2ZW50KSkge1xuICAgICAgICAgICAgICAgIHZhciBwID0gcG9pbnRlcm1hcC5oYXModGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gc2NvcGUuZmluZFRhcmdldChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldCh0aGlzLlBPSU5URVJfSUQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLmRvd24oZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdXNlbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRXZlbnRTaW11bGF0ZWRGcm9tVG91Y2goaW5FdmVudCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQodGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gdGFyZ2V0O1xuICAgICAgICAgICAgICAgICAgICAvLyBoYW5kbGUgY2FzZSB3aGVyZSB3ZSBtaXNzZWQgYSBtb3VzZXVwXG4gICAgICAgICAgICAgICAgICAgIGlmICgoSEFTX0JVVFRPTlMgPyBlLmJ1dHRvbnMgOiBlLndoaWNoKSA9PT0gMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFIQVNfQlVUVE9OUykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRCdXR0b25zID0gZS5idXR0b25zID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIuY2FuY2VsKGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbGVhbnVwTW91c2UoZS5idXR0b25zKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIubW92ZShlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW91c2V1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRXZlbnRTaW11bGF0ZWRGcm9tVG91Y2goaW5FdmVudCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgZS50YXJnZXQgPSBwb2ludGVybWFwLmdldCh0aGlzLlBPSU5URVJfSUQpO1xuICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIudXAoZSk7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGVhbnVwTW91c2UoZS5idXR0b25zKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2xlYW51cE1vdXNlOiBmdW5jdGlvbihidXR0b25zKSB7XG4gICAgICAgICAgICBpZiAoYnV0dG9ucyA9PT0gMCkge1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuZGVsZXRlKHRoaXMuUE9JTlRFUl9JRCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgc2NvcGUubW91c2VFdmVudHMgPSBtb3VzZUV2ZW50cztcbn0pKGV4cG9ydHMpO1xuXG4oZnVuY3Rpb24oc2NvcGUp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ndG91Y2hlbmQnLFxuICAgICAgICAgICAgJ3RvdWNoY2FuY2VsJ1xuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAnZG93bicsXG4gICAgICAgICAgICAndXAnLFxuICAgICAgICAgICAgJ21vdmUnXG4gICAgICAgIF0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQsIGluaXRpYWwpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLklTX0lPUyA/IGluaXRpYWwgOiAhaW5pdGlhbCkge1xuICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbih0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5JU19JT1MpIHtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLnVubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBzY3JvbGxUeXBlczoge1xuICAgICAgICAgICAgRU1JVFRFUjogJ25vbmUnLFxuICAgICAgICAgICAgWFNDUk9MTEVSOiAncGFuLXgnLFxuICAgICAgICAgICAgWVNDUk9MTEVSOiAncGFuLXknLFxuICAgICAgICB9LFxuICAgICAgICB0b3VjaEFjdGlvblRvU2Nyb2xsVHlwZTogZnVuY3Rpb24odG91Y2hBY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciB0ID0gdG91Y2hBY3Rpb247XG4gICAgICAgICAgICB2YXIgc3QgPSB0aGlzLnNjcm9sbFR5cGVzO1xuICAgICAgICAgICAgaWYgKHQgPT09IHN0LkVNSVRURVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ25vbmUnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09PSBzdC5YU0NST0xMRVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1gnO1xuICAgICAgICAgICAgfSBlbHNlIGlmICh0ID09PSBzdC5ZU0NST0xMRVIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1knO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gJ1hZJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgUE9JTlRFUl9UWVBFOiAndG91Y2gnLFxuICAgICAgICBmaXJzdFRvdWNoOiBudWxsLFxuICAgICAgICBpc1ByaW1hcnlUb3VjaDogZnVuY3Rpb24oaW5Ub3VjaCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlyc3RUb3VjaCA9PT0gaW5Ub3VjaC5pZGVudGlmaWVyO1xuICAgICAgICB9LFxuICAgICAgICBzZXRQcmltYXJ5VG91Y2g6IGZ1bmN0aW9uKGluVG91Y2gpIHtcbiAgICAgICAgICAgIC8vIHNldCBwcmltYXJ5IHRvdWNoIGlmIHRoZXJlIG5vIHBvaW50ZXJzLCBvciB0aGUgb25seSBwb2ludGVyIGlzIHRoZSBtb3VzZVxuICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAucG9pbnRlcnMoKSA9PT0gMCB8fCAocG9pbnRlcm1hcC5wb2ludGVycygpID09PSAxICYmIHBvaW50ZXJtYXAuaGFzKDEpKSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyc3RUb3VjaCA9IGluVG91Y2guaWRlbnRpZmllcjtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0WFkgPSB7XG4gICAgICAgICAgICAgICAgICAgIFg6IGluVG91Y2guY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgWTogaW5Ub3VjaC5jbGllbnRZXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0VGFyZ2V0ID0gaW5Ub3VjaC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxpbmcgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsUmVzZXRDbGlja0NvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHJlbW92ZVByaW1hcnlQb2ludGVyOiBmdW5jdGlvbihpblBvaW50ZXIpIHtcbiAgICAgICAgICAgIGlmIChpblBvaW50ZXIuaXNQcmltYXJ5KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJzdFRvdWNoID0gbnVsbDtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0WFkgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXRDbGlja0NvdW50KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNsaWNrQ291bnQ6IDAsXG4gICAgICAgIHJlc2V0SWQ6IG51bGwsXG4gICAgICAgIHJlc2V0Q2xpY2tDb3VudDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgZm4gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmNsaWNrQ291bnQgPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXRJZCA9IG51bGw7XG4gICAgICAgICAgICB9LmJpbmQodGhpcyk7XG4gICAgICAgICAgICB0aGlzLnJlc2V0SWQgPSBzZXRUaW1lb3V0KGZuLCBDTElDS19DT1VOVF9USU1FT1VUKTtcbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsUmVzZXRDbGlja0NvdW50OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnJlc2V0SWQpIHtcbiAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5yZXNldElkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdHlwZVRvQnV0dG9uczogZnVuY3Rpb24odHlwZSkge1xuICAgICAgICAgICAgdmFyIHJldCA9IDA7XG4gICAgICAgICAgICBpZiAodHlwZSA9PT0gJ3RvdWNoc3RhcnQnIHx8IHR5cGUgPT09ICd0b3VjaG1vdmUnKSB7XG4gICAgICAgICAgICAgICAgcmV0ID0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUYXJnZXQ6IGZ1bmN0aW9uKHRvdWNoLCBpZCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudFRvdWNoRXZlbnQudHlwZSA9PT0gJ3RvdWNoc3RhcnQnKSB7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNQcmltYXJ5VG91Y2godG91Y2gpKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBmYXN0UGF0aCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudFg6IHRvdWNoLmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRZOiB0b3VjaC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgcGF0aDogdGhpcy5jdXJyZW50VG91Y2hFdmVudC5wYXRoLFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiB0aGlzLmN1cnJlbnRUb3VjaEV2ZW50LnRhcmdldFxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gc2NvcGUuZmluZFRhcmdldChmYXN0UGF0aCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNjb3BlLmZpbmRUYXJnZXQodG91Y2gpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIHJldXNlIHRhcmdldCB3ZSBmb3VuZCBpbiB0b3VjaHN0YXJ0XG4gICAgICAgICAgICByZXR1cm4gcG9pbnRlcm1hcC5nZXQoaWQpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaFRv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SA9IHRoaXMuaXNQcmltYXJ5VG91Y2goaW5Ub3VjaCk7XG4gICAgICAgICAgICBlLnBvaW50ZXJUeXBlID0gdGhpcy5QT0lOVEVSX1RZUEU7XG4gICAgICAgICAgICBlLl9zb3VyY2UgPSAndG91Y2gnO1xuICAgICAgICAgICAgLy8gZm9yd2FyZCB0b3VjaCBwcmV2ZW50RGVmYXVsdHNcbiAgICAgICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIHNlbGYuZmlyc3RYWSA9IG51bGw7XG4gICAgICAgICAgICAgICAgY3RlLnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIHByb2Nlc3NUb3VjaGVzOiBmdW5jdGlvbihpbkV2ZW50LCBpbkZ1bmN0aW9uKSB7XG4gICAgICAgICAgICB2YXIgdGwgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzO1xuICAgICAgICAgICAgdGhpcy5jdXJyZW50VG91Y2hFdmVudCA9IGluRXZlbnQ7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgdCwgcDsgaSA8IHRsLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgdCA9IHRsW2ldO1xuICAgICAgICAgICAgICAgIHAgPSB0aGlzLnRvdWNoVG9Qb2ludGVyKHQpO1xuICAgICAgICAgICAgICAgIGlmIChpbkV2ZW50LnR5cGUgPT09ICd0b3VjaHN0YXJ0Jykge1xuICAgICAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldChwLnBvaW50ZXJJZCwgcC50YXJnZXQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5oYXMocC5wb2ludGVySWQpKSB7XG4gICAgICAgICAgICAgICAgICAgIGluRnVuY3Rpb24uY2FsbCh0aGlzLCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGluRXZlbnQudHlwZSA9PT0gJ3RvdWNoZW5kJyB8fCBpbkV2ZW50Ll9jYW5jZWwpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jbGVhblVwUG9pbnRlcihwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8vIEZvciBzaW5nbGUgYXhpcyBzY3JvbGxlcnMsIGRldGVybWluZXMgd2hldGhlciB0aGUgZWxlbWVudCBzaG91bGQgZW1pdFxuICAgICAgICAvLyBwb2ludGVyIGV2ZW50cyBvciBiZWhhdmUgYXMgYSBzY3JvbGxlclxuICAgICAgICBzaG91bGRTY3JvbGw6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZpcnN0WFkpIHtcbiAgICAgICAgICAgICAgICB2YXIgcmV0O1xuICAgICAgICAgICAgICAgIHZhciB0b3VjaEFjdGlvbiA9IHNjb3BlLnRhcmdldEZpbmRpbmcuZmluZFRvdWNoQWN0aW9uKGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIHZhciBzY3JvbGxBeGlzID0gdGhpcy50b3VjaEFjdGlvblRvU2Nyb2xsVHlwZSh0b3VjaEFjdGlvbik7XG4gICAgICAgICAgICAgICAgaWYgKHNjcm9sbEF4aXMgPT09ICdub25lJykge1xuICAgICAgICAgICAgICAgICAgICAvLyB0aGlzIGVsZW1lbnQgaXMgYSB0b3VjaC1hY3Rpb246IG5vbmUsIHNob3VsZCBuZXZlciBzY3JvbGxcbiAgICAgICAgICAgICAgICAgICAgcmV0ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzY3JvbGxBeGlzID09PSAnWFknKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIHRoaXMgZWxlbWVudCBzaG91bGQgYWx3YXlzIHNjcm9sbFxuICAgICAgICAgICAgICAgICAgICByZXQgPSB0cnVlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgdGhlIGludGVuZGVkIHNjcm9sbCBheGlzLCBhbmQgb3RoZXIgYXhpc1xuICAgICAgICAgICAgICAgICAgICB2YXIgYSA9IHNjcm9sbEF4aXM7XG4gICAgICAgICAgICAgICAgICAgIHZhciBvYSA9IHNjcm9sbEF4aXMgPT09ICdZJyA/ICdYJyA6ICdZJztcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRhID0gTWF0aC5hYnModFsnY2xpZW50JyArIGFdIC0gdGhpcy5maXJzdFhZW2FdKTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRvYSA9IE1hdGguYWJzKHRbJ2NsaWVudCcgKyBvYV0gLSB0aGlzLmZpcnN0WFlbb2FdKTtcbiAgICAgICAgICAgICAgICAgICAgLy8gaWYgZGVsdGEgaW4gdGhlIHNjcm9sbCBheGlzID4gZGVsdGEgb3RoZXIgYXhpcywgc2Nyb2xsIGluc3RlYWQgb2ZcbiAgICAgICAgICAgICAgICAgICAgLy8gbWFraW5nIGV2ZW50c1xuICAgICAgICAgICAgICAgICAgICByZXQgPSBkYSA+PSBkb2E7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiByZXQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGZpbmRUb3VjaDogZnVuY3Rpb24oaW5UTCwgaW5JZCkge1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIGwgPSBpblRMLmxlbmd0aCwgdDsgaSA8IGwgJiYgKHQgPSBpblRMW2ldKTsgaSsrKSB7XG4gICAgICAg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AgICAgICAgICAgLy8gTmV2ZXIgcmVtb3ZlIHBvaW50ZXJJZCA9PSAxLCB3aGljaCBpcyBtb3VzZS5cbiAgICAgICAgICAgICAgICAgICAgLy8gVG91Y2ggaWRlbnRpZmllcnMgYXJlIDIgc21hbGxlciB0aGFuIHRoZWlyIHBvaW50ZXJJZCwgd2hpY2ggaXMgdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIGluZGV4IGluIHBvaW50ZXJtYXAuXG4gICAgICAgICAgICAgICAgICAgIGlmIChrZXkgIT09IDEgJiYgIXRoaXMuZmluZFRvdWNoKHRsLCBrZXkgLSAyKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHAgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaChwKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0sIHRoaXMpO1xuICAgICAgICAgICAgICAgIGQuZm9yRWFjaChmdW5jdGlvbihwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsKHApO1xuICAgICAgICAgICAgICAgICAgICBwb2ludGVybWFwLmRlbGV0ZShwLnBvaW50ZXJJZCk7XG4gICAgICAgICAgICAgICAgfSwgdGhpcyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHRvdWNoc3RhcnQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMudmFjdXVtVG91Y2hlcyhpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMuc2V0UHJpbWFyeVRvdWNoKGluRXZlbnQuY2hhbmdlZFRvdWNoZXNbMF0pO1xuICAgICAgICAgICAgdGhpcy5kZWR1cFN5bnRoTW91c2UoaW5FdmVudCk7XG4gICAgICAgICAgICBpZiAoIXRoaXMuc2Nyb2xsaW5nKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlja0NvdW50Kys7XG4gICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLmRvd24pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpblBvaW50ZXIpIHtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihpblBvaW50ZXIpO1xuICAgICAgICB9LFxuICAgICAgICB0b3VjaG1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChIQVNfVE9VQ0hfQUNUSU9OKSB7XG4gICAgICAgICAgICAgICAgLy8gdG91Y2hldmVudC5jYW5jZWxhYmxlID09IGZhbHNlIGlzIHNlbnQgd2hlbiB0aGUgcGFnZSBpcyBzY3JvbGxpbmcgdW5kZXIgbmF0aXZlIFRvdWNoIEFjdGlvbiBpbiBDaHJvbWUgMzZcbiAgICAgICAgICAgICAgICAvLyBodHRwczovL2dyb3Vwcy5nb29nbGUuY29tL2EvY2hyb21pdW0ub3JnL2QvbXNnL2lucHV0LWRldi93SG55dWtjWUJjQS9iOWttdHdNMWpKUUpcbiAgICAgICAgICAgICAgICBpZiAoaW5FdmVudC5jYW5jZWxhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc1RvdWNoZXMoaW5FdmVudCwgdGhpcy5tb3ZlKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICghdGhpcy5zY3JvbGxpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc2Nyb2xsaW5nID09PSBudWxsICYmIHRoaXMuc2hvdWxkU2Nyb2xsKGluRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbGluZyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjcm9sbGluZyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5FdmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wcm9jZXNzVG91Y2hlcyhpbkV2ZW50LCB0aGlzLm1vdmUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLmZpcnN0WFkpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHQgPSBpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZHggPSB0LmNsaWVudFggLSB0aGlzLmZpcnN0WFkuWDtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGR5ID0gdC5jbGllbnRZIC0gdGhpcy5maXJzdFhZLlk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkZCA9IE1hdGguc3FydChkeCAqIGR4ICsgZHkgKiBkeSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkZCA+PSBIWVNURVJFU0lTKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRvdWNoY2FuY2VsKGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY3JvbGxpbmcgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maXJzdFhZID0gbnVsbDtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoaW5Qb2ludGVyKTtcbiAgICAgICAgfSxcbiAgICAgICAgdG91Y2hlbmQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHRoaXMuZGVkdXBTeW50aE1vdXNlKGluRXZlbnQpO1xuICAgICAgICAgICAgdGhpcy5wcm9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GhlIHByaW1hcnkgZmluZ2VyIHdpbGwgc3ludGggbW91c2UgZXZlbnRzXG4gICAgICAgICAgICBpZiAodGhpcy5pc1ByaW1hcnlUb3VjaCh0KSkge1xuICAgICAgICAgICAgICAgIC8vIHJlbWVtYmVyIHgveSBvZiBsYXN0IHRvdWNoXG4gICAgICAgICAgICAgICAgdmFyIGx0ID0ge1xuICAgICAgICAgICAgICAgICAgICB4OiB0LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgIHk6IHQuY2xpZW50WVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgbHRzLnB1c2gobHQpO1xuICAgICAgICAgICAgICAgIHZhciBmbiA9IChmdW5jdGlvbihsdHMsIGx0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpID0gbHRzLmluZGV4T2YobHQpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaSA+IC0xKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBsdHMuc3BsaWNlKGksIDEpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkuYmluZChudWxsLCBsdHMsIGx0KTtcbiAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KGZuLCBERURVUF9USU1FT1VUKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICAvLyBwcmV2ZW50IFwiZ2hvc3QgY2xpY2tzXCIgdGhhdCBjb21lIGZyb20gZWxlbWVudHMgdGhhdCB3ZXJlIHJlbW92ZWQgaW4gYSB0b3VjaCBoYW5kbGVyXG4gICAgdmFyIFNUT1BfUFJPUF9GTiA9IEV2ZW50LnByb3RvdHlwZS5zdG9wSW1tZWRpYXRlUHJvcGFnYXRpb24gfHwgRXZlbnQucHJvdG90eXBlLnN0b3BQcm9wYWdhdGlvbjtcbiAgICBkb2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uKGV2KSB7XG4gICAgICAgIHZhciB4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PT09IE5vZGUuRE9DVU1FTlRfTk9ERSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRpc3BhdGNoZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIFBPSU5URVJfVFlQRVM6IFtcbiAgICAgICAgICAgICcnLFxuICAgICAgICAgICAgJ3VuYXZhaWxhYmxlJyxcbiAgICAgICAgICAgICd0b3VjaCcsXG4gICAgICAgICAgICAncGVuJyxcbiAgICAgICAgICAgICdtb3VzZSdcbiAgICAgICAgXSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGluRXZlbnQ7XG4gICAgICAgICAgICBlID0gZGlzcGF0Y2hlci5jbG9uZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKEhBU19CSVRNQVBfVFlQRSkge1xuICAgICAgICAgICAgICAgIGUucG9pbnRlclR5cGUgPSB0aGlzLlBPSU5URVJfVFlQRVNbaW5FdmVudC5wb2ludGVyVHlwZV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlLl9zb3VyY2UgPSAnbXMnO1xuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXA6IGZ1bmN0aW9uKGlkKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpZCk7XG4gICAgICAgIH0sXG4gICAgICAgIE1TUG9pbnRlckRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBwb2ludGVybWFwLnNldChpbkV2ZW50LnBvaW50ZXJJZCwgZS50YXJnZXQpO1xuICAgICAgICAgICAgZGlzcGF0Y2hlci5kb3duKGUpO1xuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJNb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHRhcmdldCkge1xuICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgZS50YXJnZXQgPSB0YXJnZXQ7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci5tb3ZlKGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJVcDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KGUucG9pbnRlcklkKTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIudXAoZSk7XG4gICAgICAgICAgICB0aGlzLmNsZWFudXAoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJDYW5jZWw6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBwb2ludGVybWFwLmdldChlLnBvaW50ZXJJZCk7XG4gICAgICAgICA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oZXIudW5saXN0ZW4odGFyZ2V0LCB0aGlzLmV2ZW50cyk7XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXA6IGZ1bmN0aW9uKGlkKSB7XG4gICAgICAgICAgICBwb2ludGVybWFwWydkZWxldGUnXShpZCk7XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQoZS5wb2ludGVySWQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihlKTtcbiAgICAgICAgfSxcbiAgICAgICAgcG9pbnRlcm1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciB0YXJnZXQgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAodGFyZ2V0KSB7XG4gICAgICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBlLnRhcmdldCA9IHRhcmdldDtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJ1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUucmVsYXRlZFRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KGUucG9pbnRlcklk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tcbiAgICAgICAgfSxcbiAgICAgICAgY2FsY1Bvc2l0aW9uRGVsdGE6IGZ1bmN0aW9uKGluQSwgaW5CKSB7XG4gICAgICAgICAgICB2YXIgeCA9IDAsXG4gICAgICAgICAgICAgICAgeSA9IDA7XG4gICAgICAgICAgICBpZiAoaW5BICYmIGluQikge1xuICAgICAgICAgICAgICAgIHggPSBpbkIucGFnZVggLSBpbkEucGFnZVg7XG4gICAgICAgICAgICAgICAgeSA9IGluQi5wYWdlWSAtIGluQS5wYWdlWTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuICAgICAgICBmaXJlVHJhY2s6IGZ1bmN0aW9uKGluVHlwZSwgaW5FdmVudCwgaW5UcmFja2luZ0RhdGEpIHtcbiAgICAgICAgICAgIHZhciB0ID0gaW5UcmFja2luZ0RhdGE7XG4gICAgICAgICAgICB2YXIgZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEodC5kb3duRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgdmFyIGRkID0gdGhpcy5jYWxjUG9zaXRpb25EZWx0YSh0Lmxhc3RNb3ZlRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKGRkLngpIHtcbiAgICAgICAgICAgICAgICB0LnhEaXJlY3Rpb24gPSB0aGlzLmNsYW1wRGlyKGRkLngpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpblR5cGUgPT09ICd0cmFja3gnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGRkLnkpIHtcbiAgICAgICAgICAgICAgICB0LnlEaXJlY3Rpb24gPSB0aGlzLmNsYW1wRGlyKGRkLnkpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChpblR5cGUgPT09ICd0cmFja3knKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGdlc3R1cmVQcm90byA9IHtcbiAgICAgICAgICAgICAgICBidWJibGVzOiB0cnVlLFxuICAgICAgICAgICAgICAgIGNhbmNlbGFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgdHJhY2tJbmZvOiB0LnRyYWNrSW5mbyxcbiAgICAgICAgICAgICAgICByZWxhdGVkVGFyZ2V0OiBpbkV2ZW50LnJlbGF0ZWRUYXJnZXQsXG4gICAgICAgICAgICAgICAgcG9pbnRlclR5cGU6IGluRXZlbnQucG9pbnRlclR5cGUsXG4gICAgICAgICAgICAgICAgcG9pbnRlcklkOiBpbkV2ZW50LnBvaW50ZXJJZCxcbiAgICAgICAgICAgICAgICBfc291cmNlOiAndHJhY2snXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGluVHlwZSAhPT0gJ3RyYWNreScpIHtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueCA9IGluRXZlbnQueDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uZHggPSBkLng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmRkeCA9IGRkLng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmNsaWVudFggPSBpbkV2ZW50LmNsaWVudFg7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnBhZ2VYID0gaW5FdmVudC5wYWdlWDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uc2NyZWVuWCA9IGluRXZlbnQuc2NyZWVuWDtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueERpcmVjdGlvbiA9IHQueERpcmVjdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChpblR5cGUgIT09ICd0cmFja3gnKSB7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmR5ID0gZC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5kZHkgPSBkZC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by55ID0gaW5FdmVudC55O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5jbGllbnRZID0gaW5FdmVudC5jbGllbnRZO1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5wYWdlWSA9IGluRXZlbnQucGFnZVk7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnNjcmVlblkgPSBpbkV2ZW50LnNjcmVlblk7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnlEaXJlY3Rpb24gPSB0LnlEaXJlY3Rpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB2YXIgZSA9IGV2ZW50RmFjdG9yeS5tYWtlR2VzdHVyZUV2ZW50KGluVHlwZSwgZ2VzdHVyZVByb3RvKTtcbiAgICAgICAgICAgIHQuZG93blRhcmdldC5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaW5FdmVudC5pc1ByaW1hcnkgJiYgKGluRXZlbnQucG9pbnRlclR5cGUgPT09ICdtb3VzZScgPyBpbkV2ZW50LmJ1dHRvbnMgPT09IDEgOiB0cnVlKSkge1xuICAgICAgICAgICAgICAgIHZhciBwID0ge1xuICAgICAgICAgICAgICAgICAgICBkb3duRXZlbnQ6IGluRXZlbnQsXG4gICAgICAgICAgICAgICAgICAgIGRvd25UYXJnZXQ6IGluRXZlbnQudGFyZ2V0LFxuICAgICAgICAgICAgICAgICAgICB0cmFja0luZm86IHt9LFxuICAgICAgICAgICAgICAgICAgICBsYXN0TW92ZUV2ZW50OiBudWxsLFxuICAgICAgICAgICAgICAgICAgICB4RGlyZWN0aW9uOiAwLFxuICAgICAgICAgICAgICAgICAgICB5RGlyZWN0aW9uOiAwLFxuICAgICAgICAgICAgICAgICAgICB0cmFja2luZzogZmFsc2VcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHAgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGlmICghcC50cmFja2luZykge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEocC5kb3duRXZlbnQsIGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICB2YXIgbW92ZSA9IGQueCAqIGQueCArIGQueSAqIGQueTtcbiAgICAgICAgICAgICAgICAgICAgLy8gc3RhcnQgdHJhY2tpbmcgb25seSBpZiBmaW5nZXIgbW92ZXMgbW9yZSB0aGFuIFdJR0dMRV9USFJFU0hPTERcbiAgICAgICAgICAgICAgICAgICAgaWYgKG1vdmUgPiB0aGlzLldJR0dMRV9USFJFU0hPTEQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAudHJhY2tpbmcgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgcC5sYXN0TW92ZUV2ZW50ID0gcC5kb3duRXZlbnQ7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2tzdGFydCcsIGluRXZlbnQsIHApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChwLnRyYWNraW5nKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVRyYWNrKCd0cmFjaycsIGluRXZlbnQsIHApO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2t4JywgaW5FdmVudCwgcCk7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVRyYWNrKCd0cmFja3knLCBpbkV2ZW50LCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcC5sYXN0TW92ZUV2ZW50ID0gaW5FdmVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdXA6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBwID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICAgICAgICBpZiAocC50cmFja2luZykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2tlbmQnLCBpbkV2ZW50LCBwKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcG9pbnRlcm1hcC5kZWxldGUoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcbiAgICBkaXNwYXRjaGVyLnJlZ2lzdGVyR2VzdHVyZSgndHJhY2snLCB0cmFjayk7XG59KShleHBvcnRzKTtcblxuLyoqXG4gKiBUaGlzIGV2ZW50IGlzIGZpcmVkIHdoZW4gYSBwb2ludGVyIGlzIGhlbGQgZG93biBmb3IgMjAwbXMuXG4gKlxuICogQG1vZHVsZSBQb2ludGVyR2VzdHVyZXNcbiAqIEBzdWJtb2R1bGUgRXZlbnRzXG4gKiBAY2xhc3MgaG9sZFxuICovXG4vKipcbiAqIFR5cGUgb2YgcG9pbnRlciB0aGF0IG1hZGUgdGhlIGhvbGRpbmcgZXZlbnQuXG4gKiBAdHlwZSBTdHJpbmdcbiAqIEBwcm9wZXJ0eSBwb2ludGVyVHlwZVxuICovXG4vKipcbiAqIFNjcmVlbiBYIGF4aXMgcG9zaXRpb24gb2YgdGhlIGhlbG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nRlciBjYW4gbW92ZSBXSUdHTEVfVEhSRVNIT0xEIHBpeGVscyBiZWZvcmUgbm90IGNvdW50aW5nIGFzIGEgaG9sZFxuICAgICAgICBXSUdHTEVfVEhSRVNIT0xEOiAxNixcbiAgICAgICAgZXZlbnRzOiBbXG4gICAgICAgICAgICAnZG93bicsXG4gICAgICAgICAgICAnbW92ZScsXG4gICAgICAgICAgICAndXAnLFxuICAgICAgICBdLFxuICAgICAgICBleHBvc2VzOiBbXG4gICAgICAgICAgICAnaG9sZCcsXG4gICAgICAgICAgICAnaG9sZHB1bHNlJyxcbiAgICAgICAgICAgICdyZWxlYXNlJ1xuICAgICAgICBdLFxuICAgICAgICBoZWxkUG9pbnRlcjogbnVsbCxcbiAgICAgICAgaG9sZEpvYjogbnVsbCxcbiAgICAgICAgcHVsc2U6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdmFyIGhvbGQgPSBEYXRlLm5vdygpIC0gdGhpcy5oZWxkUG9pbnRlci50aW1lU3RhbXA7XG4gICAgICAgICAgICB2YXIgdHlwZSA9IHRoaXMuaGVsZCA/ICdob2xkcHVsc2UnIDogJ2hvbGQnO1xuICAgICAgICAgICAgdGhpcy5maXJlSG9sZCh0eXBlLCBob2xkKTtcbiAgICAgICAgICAgIHRoaXMuaGVsZCA9IHRydWU7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBjbGVhckludGVydmFsKHRoaXMuaG9sZEpvYik7XG4gICAgICAgICAgICBpZiAodGhpcy5oZWxkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlSG9sZCgncmVsZWFzZScpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5oZWxkID0gZmFsc2U7XG4gICAgICAgICAgICB0aGlzLmhlbGRQb2ludGVyID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gbnVsbDtcbiAgICAgICAgICAgIHRoaXMuaG9sZEpvYiA9IG51bGw7XG4gICAgICAgIH0sXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChpbkV2ZW50LmlzUHJpbWFyeSAmJiAhdGhpcy5oZWxkUG9pbnRlcikge1xuICAgICAgICAgICAgICAgIHRoaXMuaGVsZFBvaW50ZXIgPSBpbkV2ZW50O1xuICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gaW5FdmVudC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgdGhpcy5ob2xkSm9iID0gc2V0SW50ZXJ2YWwodGhpcy5wdWxzZS5iaW5kKHRoaXMpLCB0aGlzLkhPTERfREVMQVkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZFBvaW50ZXIgJiYgdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQgPT09IGluRXZlbnQucG9pbnRlcklkKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jYW5jZWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZFBvaW50ZXIgJiYgdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQgPT09IGluRXZlbnQucG9pbnRlcklkKSB7XG4gICAgICAgICAgICAgICAgdmFyIHggPSBpbkV2ZW50LmNsaWVudFggLSB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFg7XG4gICAgICAgICAgICAgICAgdmFyIHkgPSBpbkV2ZW50LmNsaWVudFkgLSB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFk7XG4gICAgICAgICAgICAgICAgaWYgKCh4ICogeCArIHkgKiB5KSA+IHRoaXMuV0lHR0xFX1RIUkVTSE9MRCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbCgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgZmlyZUhvbGQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5Ib2xkVGltZSkge1xuICAgICAgICAgICAgdmFyIHAgPSB7XG4gICAgICAgICAgICAgICAgYnViYmxlczogdHJ1ZSxcbiAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIHBvaW50ZXJUeXBlOiB0aGlzLmhlbGRQb2ludGVyLnBvaW50ZXJUeXBlLFxuICAgICAgICAgICAgICAgIHBvaW50ZXJJZDogdGhpcy5oZWxkUG9pbnRlci5wb2ludGVySWQsXG4gICAgICAgICAgICAgICAgeDogdGhpcy5oZWxkUG9pbnRlci5jbGllbnRYLFxuICAgICAgICAgICAgICAgIHk6IHRoaXMuaGVsZFBvaW50ZXIuY2xpZW50WSxcbiAgICAgICAgICAgICAgICBfc291cmNlOiAnaG9sZCdcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAoaW5Ib2xkVGltZSkge1xuICAgICAgICAgICAgICAgIHAuaG9sZFRpbWUgPSBpbkhvbGRUaW1lO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGUgPSBldmVudEZhY3RvcnkubWFrZUdlc3R1cmVFdmVudChpblR5cGUsIHApO1xuICAgICAgICAgICAgdGhpcy50YXJnZXQuZGlzcGF0Y2hFdmVudChlKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgZGlzcGF0Y2hlci5yZWdpc3Rlckdlc3R1cmUoJ2hvbGQnLCBob2xkKTtcbn0pKGV4cG9ydHMpO1xuXG4vKipcbiAqIFRoaXMgZXZlbnQgaXMgZmlyZWQgd2hlbiBhIHBvaW50ZXIgcXVpY2tseSBnb2VzIGRvd24gYW5kIHVwLCBhbmQgaXMgdXNlZCB0b1xuICogZGVub3RlIGFjdGl2YXRpb24uXG4gKlxuICogQW55IGd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gICBkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaW5FdmVudC5pc1ByaW1hcnkgJiYgIWluRXZlbnQudGFwUHJldmVudGVkKSB7XG4gICAgICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQoaW5FdmVudC5wb2ludGVySWQsIHtcbiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBpbkV2ZW50LnRhcmdldCxcbiAgICAgICAgICAgICAgICAgICAgYnV0dG9uczogaW5FdmVudC5idXR0b25zLFxuICAgICAgICAgICAgICAgICAgICB4OiBpbkV2ZW50LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgIHk6IGluRXZlbnQuY2xpZW50WVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBzaG91bGRUYXA6IGZ1bmN0aW9uKGUsIGRvd25TdGF0ZSkge1xuICAgICAgICAgICAgdmFyIHRhcCA9IHRydWU7XG4gICAgICAgICAgICBpZiAoZS5wb2ludGVyVHlwZSA9PT0gJ21vdXNlJykge1xuICAgICAgICAgICAgICAgIC8vIG9ubHkgYWxsb3cgbGVmdCBjbGljayB0byB0YXAgZm9yIG1vdXNlXG4gICAgICAgICAgICAgICAgdGFwID0gKGUuYnV0dG9ucyBeIDEpICYmIChkb3duU3RhdGUuYnV0dG9ucyAmIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRhcCAmJiAhZS50YXBQcmV2ZW50ZWQ7XG4gICAgICAgIH0sXG4gICAgICAgIHVwOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgc3RhcnQgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBpZiAoc3RhcnQgJiYgdGhpcy5zaG91bGRUYXAoaW5FdmVudCwgc3RhcnQpKSB7XG4gICAgICAgICAgICAgICAgLy8gdXAucmVsYXRlZFRhcmdldCBpcyB0YXJnZXQgY3VycmVudGx5IHVuZGVyIGZpbmdlclxuICAgICAgICAgICAgICAgIHZhciB0ID0gc2NvcGUudGFyZ2V0RmluZGluZy5MQ0Eoc3RhcnQudGFyZ2V0LCBpbkV2ZW50LnJlbGF0ZWRUYXJnZXQpO1xuICAgICAgICAgICAgICAgIGlmICh0KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQoJ3RhcCcsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgeDogaW5FdmVudC5jbGllbnRYLFxuICAgICAgICAgICAgICAgICAgICAgICAgeTogaW5FdmVudC5jbGllbnRZLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiBpbkV2ZW50LmRldGFpbCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ZXJUeXBlOiBpbkV2ZW50LnBvaW50ZXJUeXBlLFxuICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRlcklkOiBpbkV2ZW50LnBvaW50ZXJJZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFsdEtleTogaW5FdmVudC5hbHRLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBjdHJsS2V5OiBpbkV2ZW50LmN0cmxLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBtZXRhS2V5OiBpbkV2ZW50Lm1ldGFLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBzaGlmdEtleTogaW5FdmVudC5zaGlmdEtleSxcbiAgICAgICAgICAgICAgICAgICAgICAgIF9zb3VyY2U6ICd0YXAnXG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgICA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Bvc2VzOiBbXG4gICAgICAgICAgICAncGluY2hzdGFydCcsXG4gICAgICAgICAgICAncGluY2gnLFxuICAgICAgICAgICAgJ3BpbmNoZW5kJyxcbiAgICAgICAgICAgICdyb3RhdGUnXG4gICAgICAgIF0sXG4gICAgICAgIGRlZmF1bHRBY3Rpb25zOiB7XG4gICAgICAgICAgICAncGluY2gnOiAnbm9uZScsXG4gICAgICAgICAgICAncm90YXRlJzogJ25vbmUnXG4gICAgICAgIH0sXG4gICAgICAgIHJlZmVyZW5jZToge30sXG4gICAgICAgIGRvd246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBpbkV2ZW50KTtcbiAgICAgICAgICAgIGlmIChwb2ludGVybWFwLnBvaW50ZXJzKCkgPT0gMikge1xuICAgICAgICAgICAgICAgIHZhciBwb2ludHMgPSB0aGlzLmNhbGNDaG9yZCgpO1xuICAgICAgICAgICAgICAgIHZhciBhbmdsZSA9IHRoaXMuY2FsY0FuZ2xlKHBvaW50cyk7XG4gICAgICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UgPSB7XG4gICAgICAgICAgICAgICAgICAgIGFuZ2xlOiBhbmdsZSxcbiAgICAgICAgICAgICAgICAgICAgZGlhbWV0ZXI6IHBvaW50cy5kaWFtZXRlcixcbiAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBzY29wZS50YXJnZXRGaW5kaW5nLkxDQShwb2ludHMuYS50YXJnZXQsIHBvaW50cy5iLnRhcmdldClcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgdGhpcy5maXJlUGluY2goJ3BpbmNoc3RhcnQnLCBwb2ludHMuZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHVwOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgcCA9IHBvaW50ZXJtYXAuZ2V0KGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIHZhciBudW0gPSBwb2ludGVybWFwLnBvaW50ZXJzKCk7XG4gICAgICAgICAgICBpZiAocCkge1xuICAgICAgICAgICAgICAgIGlmIChudW0gPT09IDIpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gZmlyZSAncGluY2hlbmQnIGJlZm9yZSBkZWxldGluZyBwb2ludGVyXG4gICAgICAgICAgICAgICAgICAgIHZhciBwb2ludHMgPSB0aGlzLmNhbGNDaG9yZCgpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVQaW5jaCgncGluY2hlbmQnLCBwb2ludHMuZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuZGVsZXRlKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgbW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAuaGFzKGluRXZlbnQucG9pbnRlcklkKSkge1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCBpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5wb2ludGVycygpID4gMSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGNQaW5jaFJvdGF0ZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB0aGlzLnVwKGluRXZlbnQpO1xuICAgICAgICB9LFxuICAgICAgICBmaXJlUGluY2g6IGZ1bmN0aW9uKHR5cGUsIGRpYW1ldGVyLCBwb2ludHMpIHtcbiAgICAgICAgICAgIHZhciB6b29tID0gZGlhbWV0ZXIgLyB0aGlzLnJlZmVyZW5jZS5kaWFtZXRlcjtcbiAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQodHlwZSwge1xuICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBzY2FsZTogem9vbSxcbiAgICAgICAgICAgICAgICBjZW50ZXJYOiBwb2ludHMuY2VudGVyLngsXG4gICAgICAgICAgICAgICAgY2VudGVyWTogcG9pbnRzLmNlbnRlci55LFxuICAgICAgICAgICAgICAgIF9zb3VyY2U6ICdwaW5jaCdcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UudGFyZ2V0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgIH0sXG4gICAgICAgIGZpcmVSb3RhdGU6IGZ1bmN0aW9uKGFuZ2xlLCBwb2ludHMpIHtcbiAgICAgICAgICAgIHZhciBkaWZmID0gTWF0aC5yb3VuZCgoYW5nbGUgLSB0aGlzLnJlZmVyZW5jZS5hbmdsZSkgJSAzNjApO1xuICAgICAgICAgICAgdmFyIGUgPSBldmVudEZhY3RvcnkubWFrZUdlc3R1cmVFdmVudCgncm90YXRlJywge1xuICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBhbmdsZTogZGlmZixcbiAgICAgICAgICAgICAgICBjZW50ZXJYOiBwb2ludHMuY2VudGVyLngsXG4gICAgICAgICAgICAgICAgY2VudGVyWTogcG9pbnRzLmNlbnRlci55LFxuICAgICAgICAgICAgICAgIF9zb3VyY2U6ICdwaW5jaCdcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5yZWZlcmVuY2UudGFyZ2V0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbGNQaW5jaFJvdGF0ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgcG9pbnRzID0gdGhpcy5jYWxjQ2hvcmQoKTtcbiAgICAgICAgICAgIHZhciBkaWFtZXRlciA9IHBvaW50cy5kaWFtZXRlcjtcbiAgICAgICAgICAgIHZhciBhbmdsZSA9IHRoaXMuY2FsY0FuZ2xlKHBvaW50cyk7XG4gICAgICAgICAgICBpZiAoZGlhbWV0ZXIgIT0gdGhpcy5yZWZlcmVuY2UuZGlhbWV0ZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVQaW5jaCgncGluY2gnLCBkaWFtZXRlciwgcG9pbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChhbmdsZSAhPSB0aGlzLnJlZmVyZW5jZS5hbmdsZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZVJvdGF0ZShhbmdsZSwgcG9pbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FsY0Nob3JkOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciBwb2ludGVycyA9IFtdO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5mb3JFYWNoKGZ1bmN0aW9uKHApIHtcbiAgICAgICAgICAgICAgICBwb2ludGVycy5wdXNoKHApO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB2YXIgZGlzdCA9IDA7XG4gICAgICAgICAgICAvLyBzdGFydCB3aXRoIGF0IGxlYXN0IHR3byBwb2ludGVyc1xuICAgICAgICAgICAgdmFyIHBvaW50cyA9IHtcbiAgICAgICAgICAgICAgICBhOiBwb2ludGVyc1swXSxcbiAgICAgICAgICAgICAgICBiOiBwb2ludGVyc1sxXVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHZhciB4LCB5LCBkO1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBwb2ludGVycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIHZhciBhID0gcG9pbnRlcnNbaV07XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaiA9IGkgKyAxOyBqIDwgcG9pbnRlcnMubGVuZ3RoOyBqKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGIgPSBwb2ludGVyc1tqXTtcbiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGguYWJzKGEuY2xpZW50WCAtIGIuY2xpZW50WCk7XG4gICAgICAgICAgICAgICAgICAgIHkgPSBNYXRoLmFicyhhLmNsaWVudFkgLSBiLmNsaWVudFkpO1xuICAgICAgICAgICAgICAgICAgICBkID0geCArIHk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChkID4gZGlzdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZGlzdCA9IGQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYTogYSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiOiBiXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgeCA9IE1hdGguYWJzKHBvaW50cy5hLmNsaWVudFggKyBwb2ludHMuYi5jbGllbnRYKSAvIDI7XG4gICAgICAgICAgICB5ID0gTWF0aC5hYnMocG9pbnRzLmEuY2xpZW50WSArIHBvaW50cy5iLmNsaWVudFkpIC8gMjtcbiAgICAgICAgICAgIHBvaW50cy5jZW50ZXIgPSB7XG4gICAgICAgICAgICAgICAgeDogeCxcbiAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcG9pbnRzLmRpYW1ldGVyID0gZGlzdDtcbiAgICAgICAgICAgIHJldHVybiBwb2ludHM7XG4gICAgICAgIH0sXG4gICAg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gICAgICAgICAgICAgICAgIGlmIChib3R0b20gPCByZWN0LnRvcCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgYm90dG9tID0gcmVjdC50b3AgKyAoaGVpZ2h0IHx8IDUwKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IHJlY3QuaGVpZ2h0O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHJlY3QgPSB7XG4gICAgICAgICAgICAgICAgICAgIGxlZnQ6ICAgd2luZG93LnNjcm9sbFggKyByZWN0LmxlZnQsXG4gICAgICAgICAgICAgICAgICAgIHJpZ2h0OiAgd2luZG93LnNjcm9sbFggKyByZWN0LnJpZ2h0LFxuICAgICAgICAgICAgICAgICAgICB0b3A6ICAgIHdpbmRvdy5zY3JvbGxZICsgcmVjdC50b3AgICAgKyBsaXN0RWxlbWVudC5zY3JvbGxUb3AsXG4gICAgICAgICAgICAgICAgICAgIGJvdHRvbTogd2luZG93LnNjcm9sbFkgKyBib3R0b20gKyBsaXN0RWxlbWVudC5zY3JvbGxUb3BcbiAgICAgICAgICAgICAgICB9O1xuXG4gICAgICAgICAgICAgICAgaXRlbS5yZWN0ID0gcmVjdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfSxcblxuICAgIHJlaW5zZXJ0OiBmdW5jdGlvbiAodGFyZ2V0KSB7XG4gICAgICAgIHZhciBzdHlsZSA9IHRhcmdldC5zdHlsZTtcbiAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZVt0cmFuc2Zvcm1dID0gc3R5bGUudHJhbnNpdGlvbiA9IFJFVkVSVF9UT19TVFlMRVNIRUVUX1ZBTFVFO1xuXG4gICAgICAgIHRhcmdldC5jbGFzc0xpc3QucmVtb3ZlKCdkcmFnb24tcG9wJyk7XG5cbiAgICAgICAgdGhpcy5kcm9wLnN0eWxlLnRyYW5zaXRpb25E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iAgICAgICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgICAgIHR5cGVvZiBTaGFkb3dSb290ICE9PSAndW5kZWZpbmVkJyAmJiBjb250YWluZXIgaW5zdGFuY2VvZiBTaGFkb3dSb290IHx8XG4gICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci50YWdOYW1lID09PSAnQk9EWSdcbiAgICAgICAgICAgICAgICApe1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkcmFnb24uY29udGFpbmVyID0gY29udGFpbmVyO1xuICAgICAgICB9XG5cbiAgICAgICAgZHJhZ29uLmNvbnRhaW5lci5hcHBlbmRDaGlsZCh0aGlzKTtcblxuICAgICAgICByZWN0LmxlZnQgICArPSB3aW5kb3cuc2Nyb2xsWDtcbiAgICAgICAgcmVjdC50b3AgICAgKz0gd2luZG93LnNjcm9sbFk7XG4gICAgICAgIHJlY3QucmlnaHQgICs9IHdpbmRvdy5zY3JvbGxYO1xuICAgICAgICByZWN0LmJvdHRvbSArPSB3aW5kb3cuc2Nyb2xsWTtcblxuICAgICAgICBkcmFnb24uYWRkRXZ0KHRoaXMsICdtb3VzZW1vdmUnKTtcbiAgICAgICAgZHJhZ29uLmFkZEV2dCh0aGlzLCAnbW91c2V1cCcpO1xuICAgIH0sXG5cbiAgICBtb3VzZW1vdmU6IGZ1bmN0aW9uIChkcmFnb24sIGV2dCkge1xuICAgICAgICBkcmFnb24uZHJvcC5zdHlsZS50cmFuc2l0aW9uID0gUkVWRVJUX1RPX1NUWUxFU0hFRVRfVkFMVUU7XG5cbiAgICAgICAgdmFyIGhvdmVyTGlzdCA9IGRyYWdvbi5wb2ludEluTGlzdFJlY3RzKHsgeDogZXZ0LmNsaWVudFgsIHk6IGV2dC5jbGllbnRZIH0pIHx8IGRyYWdvbi5tb3N0UmVjZW50SG92ZXJMaXN0O1xuXG4gICAgICAgIGlmIChob3Zlckxpc3Q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AgICAgICAvLyBtb3VzZSBuZWFyIG9yIGJlbG93IGJvdHRvbSBhbmQgbGlzdCBub3Qgc2Nyb2xsZWQgdG8gYm90dG9tIHlldFxuICAgICAgICAgICAgICAgICAgICByZXNldEF1dG9TY3JvbGxUaW1lcihtYWduaXR1ZGUsIG1heFNjcm9sbFksIGhvdmVyTGlzdC5lbGVtZW50KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBtb3VzZSBpbnNpZGVcbiAgICAgICAgICAgICAgICAgICAgcmVzZXRBdXRvU2Nyb2xsVGltZXIoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBvdGhlciA9IGRyYWdvbi5wb2ludEluSXRlbVJlY3RzKHtcbiAgICAgICAgICAgICAgICB4OiBldnQuY2xpZW50WCxcbiAgICAgICAgICAgICAgICB5OiBkcmFnb24ucmVjdC5ib3R0b20gKyB3aW5kb3cuc2Nyb2xsWSArIGR5ICsgaG92ZXJMaXN0LmVsZW1lbnQuc2Nyb2xsVG9wXG4gICAgICAgICAgICB9LCB0aGlzLCBkcmFnb24uZHJvcCk7XG5cbiAgICAgICAgICAgIHRoaXMuc3R5bGVbdHJhbnNmb3JtXSA9IHRyYW5zbGF0ZShcbiAgICAgICAgICAgICAgICBkcmFnb24ucmVjdC5sZWZ0IC0gd2luZG93LnNjcm9sbFggKyBkeCxcbiAgICAgICAgICAgICAgICBkcmFnb24ucmVjdC50b3AgLSB3aW5kb3cuc2Nyb2xsWSArIGR5XG4gICAgICAgICAgICApO1xuXG4gICAgICAgICAgICBpZiAob3RoZXIpIHtcbiAgICAgICAgICAgICAgICB2YXIgZWxlbWVudCA9IG90aGVyLmVsZW1lbnQ7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS50cmFuc2l0aW9uID0gUkVWRVJUX1RPX1NUWUxFU0hFRVRfVkFMVUU7XG4gICAgICAgICAgICAgICAgZW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YgKGtleSAhPT0gJ21vZGVscycpIHtcbiAgICAgICAgICAgICAgICAgICAgbW9kZWxMaXN0Lm1vZGVsc1trZXldID0gbW9kZWxMaXN0W2tleV07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBtb2RlbExpc3RzW2xpc3RJbmRleF0gPSBtb2RlbExpc3QgPSBtb2RlbExpc3QubW9kZWxzO1xuICAgICAgICB9IGVsc2UgaWYgKG1vZGVsTGlzdCBpbnN0YW5jZW9mIEFycmF5KSB7XG4gICAgICAgICAgICBtb2RlbExpc3QubW9kZWxzID0gbW9kZWxMaXN0OyAvLyBwb2ludCB0byBzZWxmXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aHJvdyBlcnJvcignTGlzdCBbezF9XSBub3QgYW4gYXJyYXkgb2YgbW9kZWxzICh3aXRoIG9yIHdpdGhvdXQgYWRkaXRpb25hbCBwcm9wZXJ0aWVzKSBPUiAnICtcbiAgICAgICAgICAgICAgICAnYW4gb2JqZWN0ICh3aXRoIGEgYG1vZGVsc2AgcHJvcGVydHkgY29udGFpbmluZyBhbiBhcnJheSBvZiBtb2RlbHMpLicsIGxpc3RJbmRleCk7XG4gICAgICAgIH1cblxuICAgICAgICBtb2RlbExpc3QuZm9yRWFjaChmdW5jdGlvbiAobW9kZWwpIHtcbiAgICAgICAgICAgIHZhciBtb2RlbExhYmVsID0gbW9kZWwubGFiZWwgfHwgbGlzdExhYmVsLFxuICAgICAgICAgICAgICAgIG1vZGVsSHRtbEVuY29kZSA9IG1vZGVsLmh0bWxFbmNvZGUgIT09IHVuZGVmaW5lZCAmJiBtb2RlbC5odG1sRW5jb2RlIHx8IGxpc3RIdG1sRW5jb2RlLFxuICAgICAgICAgICAgICAgIG1vZGVsT2JqZWN0ID0gdHlwZW9mIG1vZGVsID09PSAnb2JqZWN0JyA/IG1vZGVsIDogeyBsYWJlbDogbW9kZWx9LFxuICAgICAgICAgICAgICAgIGxhYmVsID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FufSBgdHJ1ZWAgaWZmIF9ib3RoXyBjb29yZGluYXRlcyBvZiB0aGlzIHBvaW50IGFyZSBleGFjdGx5IGVxdWFsIHRvIHRob3NlIG9mIGdpdmVuIGBwb2ludGAuXG4gICAgICogQHBhcmFtIHtQb2ludH0gcG9pbnQgLSBBIHBvaW50IHRvIGNvbXBhcmUgdG8gdGhpcyBwb2ludC5cbiAgICAgKiBAbWVtYmVyT2YgUG9pbnQucHJvdG90eXBlXG4gICAgICovXG4gICAgZXF1YWxzOiBmdW5jdGlvbihwb2ludCkge1xuICAgICAgICB2YXIgcmVzdWx0ID0gZmFsc2U7XG5cbiAgICAgICAgaWYgKHBvaW50KSB7XG4gICAgICAgICAgICByZXN1bHQgPVxuICAgICAgICAgICAgICAgIHRoaXMueCA9PT0gcG9pbnQueCAmJlxuICAgICAgICAgICAgICAgIHRoaXMueSA9PT0gcG9pbnQueTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBgdHJ1ZWAgaWZmIF9ib3RoXyBjb29yZGluYXRlcyBvZiB0aGlzIHBvaW50IGFyZSBncmVhdGVyIHRoYW4gdGhvc2Ugb2YgZ2l2ZW4gYHBvaW50YC5cbiAgICAgKiBAcGFyYW0ge1BvaW50fSBwb2ludCAtIEEgcG9pbnQgdG8gY29tcGFyZSB0byB0aGlzIHBvaW50XG4gICAgICogQG1lbWJlck9mIFBvaW50LnByb3RvdHlwZVxuICAgICAqL1xuICAgIGdyZWF0ZXJUaGFuOiBmdW5jdGlvbihwb2ludCkge1xuICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgdGhpcy54ID4gcG9pbnQueCAmJlxuICAgICAgICAgICAgdGhpcy55ID4gcG9pbnQueVxuICAgICAgICApO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gYHRydWVgIGlmZiBfY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uICAgICAgICAgICAgICAgIGlmICghaXRlbS5rZWVwKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBhZ2VzOyArK2kpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLndoZW4gPCBhZ2VbaV0uaXRlbS53aGVuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgYWdlLnNwbGljZShpLCAwLCB7IGtleToga2V5LCBpdGVtOiBpdGVtIH0pO1xuICAgICAgICAgICAgICAgICAgICBhZ2VzKys7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCFhZ2UubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlZ0V4cExJS0UocGF0dGVybiwgaWdub3JlQ2FzZSk7IC8vIGNhY2hlIGlzIGZ1bGwhXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpID0gTWF0aC5jZWlsKGFnZS5sZW5ndGggLyAxMCk7IC8vIHdpbGwgYWx3YXlzIGJlIGF0IGxlYXN0IDFcbiAgICAgICAgICAgIHNpemUgLT0gaTtcbiAgICAgICAgICAgIHdoaWxlIChpLS0pIHtcbiAgICAgICAgICAgICAgICBkZWxldGUgY2FjaGVbYWdlW2ldLmtleV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaXRlbSA9IGNhY2hlW3BhdHRlcm5BbmRDYXNlXSA9IHtcbiAgICAgICAgICAgIHJlZ2V4OiByZWdFeHBMSUtFKHBhdHRlcm4sIGlnbm9yZUNhc2UpLFxuICAgICAgICAgICAga2VlcDoga2VlcCxcbiAgICAgICAgICAgIHdoZW46IG5ldyBEYXRlKCkuZ2V0VGltZSgpXG4gICAgICAgIH07XG4gICAgICAgIHNpemUrKztcbiAgICB9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AgIHJldHVybiBlYWNoWzBdIDw9IGNlbGwgJiYgY2VsbCA8PSBlYWNoWzFdO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sXG5cbiAgICAgICAgaXNFbXB0eTogZnVuY3Rpb24gKCl7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5zZWxlY3Rpb24ubGVuZ3RoID09PSAwO1xuICAgICAgICB9LFxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBAc3VtbWFyeSBSZXR1cm4gdGhlIGluZGV4ZXMgdGhhdCBhcmUgc2VsZWN0ZWQuXG4gICAgICAgICAqIEBkZXNjIFJldHVybiB0aGUgaW5kZXhlcyB0aGF0IGFyZSBzZWxlY3RlZC5cbiAgICAgICAgICogQHJldHVybnMge0FycmF5LkFycmF5Lm51bWJlcn1cbiAgICAgICAgICogQG1lbWJlck9mIFJhbmdlU2VsZWN0aW9uTW9kZWwucHJvdG90eXBlXG4gICAgICAgICAqL1xuICAgICAgICBnZXRTZWxlY3Rpb25zOiBmdW5jdGlvbiAoKXtcbiAgICAgICAgICAgIHZhciByZXN1bHQgPSBbXTtcbiAgICAgICAgICAgIHRoaXMuc2VsZWN0aW9uLmZvckVhY2goZnVuY3Rpb24gKGVhY2gpIHtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gZWFjaFswXTsgaSA8PSBlYWNoWzFdOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0LnB1c2goaSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXN1bHQuc29ydChmdW5jdGlvbiAoYSwgYil7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGEgLSBiO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9XG5cbiAgICB9O1xuXG4gICAgLyoqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAc3VtbWFyeSBQcmVwcyBgc3RhcnRg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oOyB3KyspIHtcbiAgICAgICAgICAgICAgICAgICAgY29sbGVjdG9yLnB1c2goc2VsZWN0aW9uc1t3XVtoXSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh3IDwgd2lkdGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3Rvci5wdXNoKCdcXHQnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoaCA8IGhlaWdodCkge1xuICAgICAgICAgICAgICAgICAgICBjb2xsZWN0b3IucHVzaCgnXFxuJyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gY29sbGVjdG9yLmpvaW4oJycpO1xuXG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAnJztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gV2UgaGF2ZSBmb2N1cy5cbiAgICAgKi9cbiAgICBoYXNGb2N1czogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmdldENhbnZhcygpLmhhc0ZvY3VzKCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQGRlc2MgQ2xlYXIgYWxsIHRoZSBzZWxlY3Rpb25zLlxuICAgICAqL1xuICAgIGNsZWFyU2VsZWN0aW9uczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBkb250Q2xlYXJSb3dzID0gdGhpcy5pc0NoZWNrYm94T25seVJvd1NlbGVjdGlvbnMoKTtcbiAgICAgICAgdGhpcy5zZWxlY3Rpb25Nb2RlbC5jbGVhcihkb250Q2xlYXJSb3dzKTtcbiAgIC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sZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzZWxmLmRyYWdnaW5nID0gZmFsc2U7XG4gICAgICAgICAgICBpZiAoc2VsZi5pc1Njcm9sbGluZ05vdygpKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zZXRTY3JvbGxpbmdOb3coZmFsc2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHNlbGYuY29sdW1uRHJhZ0F1dG9TY3JvbGxpbmcpIHtcbiAgICAgICAgICAgICAgICBzZWxmLmNvbHVtbkRyYWdBdXRvU2Nyb2xsaW5nID0gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvL3NlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAgICAgdmFyIG1vdXNlRXZlbnQgPSBzZWxmLmdldEdyaWRDZWxsRnJvbU1vdXNlUG9pbnQobW91c2UpO1xuICAgICAgICAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlTW91c2VVcChtb3VzZUV2ZW50KTtcbiAgICAgICAgICAgIGlmIChzZWxmLm1vdXNlRG93blN0YXRlKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljQnV0dG9uUHJlc3NlZEV2ZW50KHNlbGYubW91c2VEb3duU3RhdGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5tb3VzZURvd25TdGF0ZSA9IG51bGw7XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNNb3VzZVVwRXZlbnQobW91c2VFdmVudCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1kYmxjbGljaycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAgICAgdmFyIG1vdXNlRXZlbnQgPSBzZWxmLmdldEdyaWRDZWxsRnJvbU1vdXNlUG9pbnQobW91c2UpO1xuICAgICAgICAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNEb3VibGVDbGlja0V2ZW50KG1vdXNlRXZlbnQsIGUpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZURvdWJsZUNsaWNrKG1vdXNlRXZlbnQpO1xuICAgICAgICB9KTtcblxuICAgICAgICB0aGlzLmFkZEZpbkV2ZW50TGlzdGVuZXIoJ2Zpbi1jYW52YXMtdGFwJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy9zZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciB0YXBFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgICAgICB0YXBFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICB0YXBFdmVudC5rZXlzID0gZS5kZXRhaWwua2V5cztcbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0NsaWNrRXZlbnQodGFwRXZlbnQpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZVRhcCh0YXBFdmVudCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1kcmFnJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5kcmFnZ2luZyA9IHRydWU7XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZU1vdXNlRHJhZyhtb3VzZUV2ZW50KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLWtleWRvd24nLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ2VkaXRPbktleWRvd24nKSkge1xuICAgICAgICAgICAgICAgIHZhciBjaGFyID0gZS5kZXRhaWwuY2hhcixcbiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlQ2hhciwgaXNEZWxldGVDaGFyLCBjdXJyZW50Q2VsbCwgZWRpdG9yO1xuXG4gICAgICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgICAgICAhc2VsZi5pc0VkaXRpbmcoKSAmJlxuICAgICAgICAgICAgICAgICAgICAoXG4gICAgICAgICAgICAgICAgICAgICAgICBjaGFyID09PSAnRjInIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAoaXNWaXNpYmxlQ2hhciA9IGNoYXIubGVuZ3RoID09PSAxKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgKGlzRGVsZXRlQ2hhciA9IGNoYXIgPT09ICdERUxFVEUnIHx8IGNoYXIgPT09ICdCQUNLU1BBQ0UnKVxuICAgICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDZWxsID0gc2VsZi5zZWxlY3Rpb25Nb2RlbC5nZXRMYXN0U2VsZWN0aW9uKCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50Q2VsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yID0gc2VsZi5hY3RpdmF0ZUVkaXRvcihjdXJyZW50Q2VsbC5vcmlnaW4ueCwgY3VycmVudENlbGwub3JpZ2luLnkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvciBpbnN0YW5jZW9mIEh5cGVyZ3JpZC5jZWxsRWRpdG9ycy5TaW1wbGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNWaXNpYmxlQ2hhcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaW5wdXQudmFsdWUgPSBjaGFyO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNEZWxldGVDaGFyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pbnB1dC52YWx1ZSA9ICcnO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlLmRldGFpbC5wcmltaXRpdmVFdmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljS2V5ZG93bkV2ZW50KGUpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZUtleURvd24oZSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1rZXl1cCcsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0tleXVwRXZlbnQoZSk7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlS2V5VXAoZSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRmluRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy10cmFjaycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzZWxmLmRyYWdnaW5nKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHByaW1FdmVudCA9IGUuZGV0YWlsLnByaW1pdGl2ZUV2ZW50O1xuICAgICAgICAgICAgaWYgKE1hdGguYWJzKHByaW1FdmVudC5keSkgPiBNYXRoLmFicyhwcmltRXZlbnQuZHgpKSB7XG4gICAgICAgICAgICAgICAgaWYgKHByaW1FdmVudC55RGlyZWN0aW9uID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbFZCeSgtMik7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwcmltRXZlbnQueURpcmVjdGlvbiA8IC0wKSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Nyb2xsVkJ5KDIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHByaW1FdmVudC54RGlyZWN0aW9uID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbEhCeSgtMSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwcmltRXZlbnQueERpcmVjdGlvbiA8IC0wKSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Nyb2xsSEJ5KDEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgLy8gdGhpcy5hZGRGaW5FdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLWhvbGRwdWxzZScsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgLy8gICAgIGNvbnNvbGUubG9nKCdob2xkcHVsc2UnKTtcbiAgICAgICAgLy8gICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAvLyAgICAgICAgIHJldHVybjtcbiAgICAgICAgLy8gICAgIH1cbiAgICAgICAgLy8gICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAvLyAgICAgdmFyIG1vdXNlRXZlbnQgPSBzZWxmLmdldEdyaWRDZWxsRnJvbU1vdXNlUG9pbnQobW91c2UpO1xuICAgICAgICAvLyAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgIC8vICAgICBzZWxmLmRlbGVnYXRlSG9sZFB1bHNlKG1vdXNlRXZlbnQpO1xuICAgICAgICAvLyB9KTtcblxuICA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icsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGlucHV0OiBpbnB1dENvbnRyb2wsXG4gICAgICAgICAgICAgICAga2V5RXZlbnQ6IGtleUV2ZW50XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGNsaWNrRXZlbnQpO1xuICAgIH0sXG5cbiAgICBmaXJlU3ludGhldGljRWRpdG9yS2V5UHJlc3NFdmVudDogZnVuY3Rpb24oaW5wdXRDb250cm9sLCBrZXlFdmVudCkge1xuICAgICAgICB2YXIgY2xpY2tFdmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLWVkaXRvci1rZXlwcmVzcycsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGlucHV0OiBpbnB1dENvbnRyb2wsXG4gICAgICAgICAgICAgICAga2V5RXZlbnQ6IGtleUV2ZW50XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGNsaWNrRXZlbnQpO1xuICAgIH0sXG5cbiAgICBmaXJlU3ludGhldGljRWRpdG9yRGF0YUNoYW5nZUV2ZW50OiBmdW5jdGlvbihpbnB1dENvbnRyb2wsIG9sZFZhbHVlLCBuZXdWYWx1ZSkge1xuICAgICAgICB2YXIgY2xpY2tFdmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLWVkaXRvci1kYXRhLWNoYW5nZScsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGlucHV0OiBpbnB1dENvbnRyb2wsXG4gICAgICAgICAgICAgICAgb2xkVmFsdWU6IG9sZFZhbHVlLFxuICAgICAgICAgICAgICAgIG5ld1ZhbHVlOiBuZXdWYWx1ZVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNhbmNlbGFibGU6IHRydWVcbiAgICAgICAgfSk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pKSB7XG4gICAgICAgICAgICByZXN1bHRbaV0gPSBzZWxmLl9nZXRTZWxlY3Rpb24oc2VsZWN0aW9uUmVjdCk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH0sXG5cbiAgICBfZ2V0U2VsZWN0aW9uOiBmdW5jdGlvbihyZWN0KSB7XG4gICAgICAgIHJlY3QgPSBub3JtYWxpemVSZWN0KHJlY3QpO1xuICAgICAgICB2YXIgY29sQ291bnQgPSByZWN0LmV4dGVudC54ICsgMTtcbiAgICAgICAgdmFyIHJvd0NvdW50ID0gcmVjdC5leHRlbnQueSArIDE7XG4gICAgICAgIHZhciBveCA9IHJlY3Qub3JpZ2luLng7XG4gICAgICAgIHZhciBveSA9IHJlY3Qub3JpZ2luLnk7XG4gICAgICAgIHZhciByZXN1bHQgPSB7fTtcbiAgICAgICAgdmFyIHI7XG4gICAgICAgIGZvciAodmFyIGMgPSAwOyBjIDwgY29sQ291bnQ7IGMrKykge1xuICAgICAgICAgICAgdmFyIGNvbHVtbiA9IG5ldyBBcnJheShyb3dDb3VudCk7XG4gICAgICAgICAgICByZXN1bHRbdGhpcy5nZXRGaWVsZChjICsgb3gpXSA9IGNvbHVtbjtcbiAgICAgICAgICAgIGZvciAociA9IDA7IHIgPCByb3dDb3VudDsgcisrKSB7XG4gICAgICAgICAgICAgICAgY29sdW1uW3JdID0gdmFsdWVPckZ1bmN0aW9uRXhlY3V0ZSh0aGlzLmdldFZhbHVlKG94ICsgYywgb3kgKyByKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9LFxuXG4gICAgZ2V0U2VsZWN0aW9uTWF0cml4OiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xuICAgICAgICB2YXIgc2VsZWN0aW9ucyA9IHRoaXMuZ2V0U2VsZWN0aW9ucygpO1xuICAgICAgICB2YXIgcmVzdWx0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U3ludGhlc2l6ZSBhbmQgZmlyZSBhIGBmaW4tY29udGV4dC1tZW51YCBldmVudFxuICAgICAqIEBwYXJhbSB7a2V5RXZlbnR9IGV2ZW50IC0gVGhlIGNhbnZhcyBldmVudC5cbiAgICAgKi9cbiAgICBmaXJlU3ludGhldGljQ29udGV4dE1lbnVFdmVudDogZnVuY3Rpb24oZSkge1xuICAgICAgICBlLmdyaWRDZWxsID0gdGhpcy5jb252ZXJ0Vmlld1BvaW50VG9EYXRhUG9pbnQoZS5ncmlkQ2VsbCk7XG4gICAgICAgIHZhciBldmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLWNvbnRleHQtbWVudScsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBlLmdyaWRDZWxsLFxuICAgICAgICAgICAgICAgIG1vdXNlUG9pbnQ6IGUubW91c2VQb2ludCxcbiAgICAgICAgICAgICAgICB2aWV3UG9pbnQ6IGUudmlld1BvaW50LFxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZUV2ZW50OiBlLnByaW1pdGl2ZUV2ZW50LFxuICAgICAgICAgICAgICAgIHJvd3M6IHRoaXMuZ2V0U2VsZWN0ZWRSb3dzKCksXG4gICAgICAgICAgICAgICAgY29sdW1uczogdGhpcy5nZXRTZWxlY3RlZENvbHVtbnMoKSxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiB0aGlzLnNlbGVjdGlvbk1vZGVsLmdldFNlbGVjdGlvbnMoKVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChldmVudCk7XG4gICAgfSxcblxuICAgIGZpcmVTeW50aGV0aWNNb3VzZVVwRXZlbnQ6IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgdmFyIGV2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tbW91c2V1cCcsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBlLmdyaWRDZWxsLFxuICAgICAgICAgICAgICAgIG1vdXNlUG9pbnQ6IGUubW91c2VQb2ludCxcbiAgICAgICAgICAgICAgICB2aWV3UG9pbnQ6IGUudmlld1BvaW50LFxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZUV2ZW50OiBlLnByaW1pdGl2ZUV2ZW50LFxuICAgICAgICAgICAgICAgIHJvd3M6IHRoaXMuZ2V0U2VsZWN0ZWRSb3dzKCksXG4gICAgICAgICAgICAgICAgY29sdW1uczogdGhpcy5nZXRTZWxlY3RlZENvbHVtbnMoKSxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiB0aGlzLnNlbGVjdGlvbk1vZGVsLmdldFNlbGVjdGlvbnMoKVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChldmVudCk7XG4gICAgfSxcblxuICAgIGZpcmVTeW50aGV0aWNNb3VzZURvd25FdmVudDogZnVuY3Rpb24oZSkge1xuICAgICAgICB0aGlzLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgIHZhciBldmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLW1vdXNlZG93bicsIHtcbiAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBlLmdyaWRDZWxsLFxuICAgICAgICAgICAgICAgIG1vdXNlUG9pbnQ6IGUubW91c2VQb2ludCxcbiAgICAgICAgICAgICAgICB2aWV3UG9pbnQ6IGUudmlld1BvaW50LFxuICAgICAgICAgICAgICAgIHByaW1pdGl2ZUV2ZW50OiBlLnByaW1pdGl2ZUV2ZW50LFxuICAgICAgICAgICAgICAgIHJvd3M6IHRoaXMuZ2V0U2VsZWN0ZWRSb3dzKCksXG4gICAgICAgICAgICAgICAgY29sdW1uczogdGhpcy5nZXRTZWxlY3RlZENvbHVtbnMoKSxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiB0aGlzLnNlbGVjdGlvbk1vZGVsLmdldFNlbGVjdGlvbnMoKVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChldmVudCk7XG4gICAgfSxcblxuICAgIGlzVmlld2FibGVCdXR0b246IGZ1bmN0aW9uKGMsIHIpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0UmVuZGVyZXIoKS5pc1ZpZXdhYmxlQnV0dG9uKGMsIHIpO1xuICAgIH0sXG5cbiAgICBmaXJlU3ludGhldGljQnV0dG9uUHJlc3NlZEV2ZW50OiBmdW5jdGlvbihldnQpIHtcbiAgICAgICAgdmFyIGRhdGFDZWxsID0gZXZ0LmRhdGFDZWxsO1xuICAgICAgICB2YXIgZ3JpZENlbGwgPSBldnQuZ3JpZENlbGw7XG4gICAgICAgIGlmICh0aGlzLmlzVmlld2FibGVCdXR0b24oZGF0YUNlbGwueCwgZGF0YUNlbGwueSkpIHtcbiAgICAgICAgICAgIHZhciBldmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLWJ1dHRvbi1wcmVzc2VkJywge1xuICAgICAgICAgICAgICAgIGRldGFpbDoge1xuICAgICAgICAgICAgICAgICAgICBncmlkQ2VsbDogZ3JpZENlbGxcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMuY2FudmFzLmRpc3BhdGNoRXZlbnQoZXZlbnQpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBIeXBlcmdyaWQucHJvdG90eXBlXG4gICAgICogQGRlc2MgU3ludGhlc2l6ZSBhbmQgZmlyZSBhIGBmaW4ta2V5ZG93bmAgZXZlbnQuXG4gICAgICogQHBhcmFtIHtrZXlFdmVudH0gZXZlbnQgLSBUaGUgY2FudmFzIGV2ZW50LlxuICAgICAqL1xu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b29yZGluYXRlLlxuICAgICAqIEBwYXJhbSB7eX0geSAtIFRoZSB2ZXJ0aWNhbCBjb29yZGluYXRlLlxuICAgICAqIEByZXR1cm5zIHtDZWxsRWRpdG9yfSAob3Igb2JqZWN0ZWQgZXh0ZW5kZWQgZnJvbSBzYW1lKSBUaGUgZWRpdG9yIG9iamVjdC5cbiAgICAgKi9cbiAgICBhY3RpdmF0ZUVkaXRvcjogZnVuY3Rpb24oeCwgeSkge1xuICAgICAgICB2YXIgZWRpdG9yO1xuXG4gICAgICAgIGlmICh0aGlzLmlzRWRpdGFibGUoKSB8fCB0aGlzLmlzRmlsdGVyUm93KHkpKSB7XG4gICAgICAgICAgICBlZGl0b3IgPSB0aGlzLmdldENlbGxFZGl0b3JBdCh4LCB5KTtcblxuICAgICAgICAgICAgaWYgKGVkaXRvcikge1xuICAgICAgICAgICAgICAgIHZhciBwb2ludCA9IGVkaXRvci5nZXRFZGl0b3JQb2ludCgpO1xuICAgICAgICAgICAgICAgIGlmIChlZGl0b3IpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBvaW50LnggPT09IHggJiYgcG9pbnQueSA9PT0geSAmJiBlZGl0b3IuaXNFZGl0aW5nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47IC8vd2UncmUgYWxyZWFkeSBvcGVuIGF0IHRoaXMgbG9jYXRpb25cbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRWRpdGluZygpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0b3BFZGl0aW5nKCk7IC8vb3RoZXIgZWRpdG9yIGlzIG9wZW4sIGNsb3NlIGl0IGZpcnN0XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZXZlbnQuZ3JpZENlbGwgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB4OiB4LFxuICAgICAgICAgICAgICAgICAgICAgICAgeTogeVx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PSBuZXcgQXJyYXkoY29sQ291bnQpLFxuICAgICAgICAgICAgcmVzdWx0cyA9IG5ldyBBcnJheShyb3dDb3VudCksXG4gICAgICAgICAgICByb3c7XG5cbiAgICAgICAgaGVhZGVycy5mb3JFYWNoKGZ1bmN0aW9uKGhlYWRlciwgYykge1xuICAgICAgICAgICAgaGVhZGVyc1tjXSA9IGJlaGF2aW9yLmdldENvbHVtbklkKGMsIDApO1xuICAgICAgICB9KTtcblxuICAgICAgICByZXN1bHRzLmZvckVhY2goZnVuY3Rpb24ocmVzdWx0LCByKSB7XG4gICAgICAgICAgICByb3cgPSByZXN1bHRzW3JdID0ge1xuICAgICAgICAgICAgICAgIGhpZXJhcmNoeTogYmVoYXZpb3IuZ2V0Rml4ZWRDb2x1bW5WYWx1ZSgwLCByKVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGhlYWRlcnMuZm9yRWFjaChmdW5jdGlvbihmaWVsZCwgYykge1xuICAgICAgICAgICAgICAgIHJvd1tmaWVsZF0gPSBiZWhhdmlvci5nZXRWYWx1ZShjLCByKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcblxuICAgICAgICByZXR1cm4gcmVzdWx0cztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7b2JqZWN0fSBBbiBvYmplY3QgdGhhdCByZXByZXNlbnRzIHRoZSBjdXJyZW50bHkgc2VsZWN0aW9uIHJvdy5cbiAgICAgKi9cbiAgICBnZXRTZWxlY3RlZFJvdzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBzZWxzID0gdGhpcy5zZWxlY3Rpb25Nb2RlbC5nZXRTZWxlY3Rpb25zKCk7XG4gICAgICAgIGlmIChzZWxzLmxlbmd0aCkge1xuICAgICAgICAgICAgdmFyIGJlaGF2aW9yID0gdGhpcy5iZWhhdmlvcixcbiAgICAgICAgICAgICAgICBjb2xDb3VudCA9IHRoaXMuZ2V0Q29sdW1uQ291bnQoKSxcbiAgICAgICAgICAgICAgICB0b3BSb3cgPSBzZWxzWzBdLm9yaWdpbi55LFxuICAgICAgICAgICAgICAgIHJvdyA9IHtcbiAgICAgICAgICAgICAgICAgICAgLy9oaWVyYXJjaHk6IGJlaGF2aW9yLmdldEZpeGVkQ29sdW1uVmFsdWUoMCwgdG9wUm93KVxuICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIGZvciAodmFyIGMgPSAwOyBjIDwgY29sQ291bnQ7IGMrKykge1xuICAgICAgICAgICAgICAgIHJvd1tiZWhhdmlvci5nZXRDb2x1bW5JZChjLCAwKV0gPSBiZWhhdmlvci5nZXRWYWx1ZShjLCB0b3BSb3cpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gcm93O1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGZpcmVSZXF1ZXN0Q2VsbEVkaXQ6IGZ1bmN0aW9uKGNlbGwsIHZhbHVlKSB7XG4gICAgICAgIHZhciBjbGlja0V2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tcmVxdWVzdC1jZWxsLWVkaXQnLCB7XG4gICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgZGV0YWlsOiB7XG4gICAgICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxuICAgICAgICAgICAgICAgIGdyaWRDZWxsOiBjZWxsLFxuICAgICAgICAgICAgICAgIHRpbWU6IERhdGUubm93KClcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGNsaWNrRXZlbnQpOyAvL0kgd2Fzbid0IGNhbmNlbGxlZFxuICAgIH0sXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBTeW50aGVzaXpl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AgaWYgKCFhbHJlYWR5U2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICBtb2RlbC5zZWxlY3RDb2x1bW4oeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpZiAoaGFzQ1RSTCkge1xuICAgICAgICAgICAgICAgIGlmIChhbHJlYWR5U2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgbW9kZWwuZGVzZWxlY3RDb2x1bW4oeCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Q29sdW1uKHgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChoYXNTSElGVCkge1xuICAgICAgICAgICAgICAgIG1vZGVsLmNsZWFyKCk7XG4gICAgICAgICAgICAgICAgbW9kZWwuc2VsZWN0Q29sdW1uKHRoaXMubGFzdEVkZ2VTZWxlY3Rpb25bMF0sIHgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICghYWxyZWFkeVNlbGVjdGVkICYmICFoYXNTSElGVCkge1xuICAgICAgICAgICAgdGhpcy5sYXN0RWRnZVNlbGVjdGlvblswXSA9IHg7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yZXBhaW50KCk7XG4gICAgICAgIHRoaXMuZmlyZVN5bnRoZXRpY0NvbHVtblNlbGVjdGlvbkNoYW5nZWRFdmVudCgpO1xuICAgIH0sXG5cbiAgICB0b2dnbGVTZWxlY3RSb3c6IGZ1bmN0aW9uKHksIGtleXMpIHtcbiAgICAgICAgLy93ZSBjYW4gc2VsZWN0IHRoZSB0b3RhbHMgcm93cyBpZiB0aGV5IGV4aXN0LCBidXQgbm90IHJvd3MgYWJvdmUgdGhhdFxuICAgICAgICBpZiAoeSA+IHRoaXMuZ2V0RmlsdGVyUm93SW5kZXgoKSkge1xuICAgICAgICAgICAga2V5cyA9IGtleXMgfHwgW107XG5cbiAgICAgICAgICAgIHZhciBzbSA9IHRoaXMuc2VsZWN0aW9uTW9kZWw7XG4gICAgICAgICAgICB2YXIgYWxyZWFkeVNlbGVjdGVkID0gc20uaXNSb3dTZWxlY3RlZCh5KTtcbiAgICAgICAgICAgIHZhciBoYXNTSElGVCA9IGtleXMuaW5kZXhPZignU0hJRlQnKSA+PSAwO1xuXG4gICAgICAgICAgICBpZiAoYWxyZWFkeVNlbGVjdGVkKSB7XG4gICAgICAgICAgICAgICAgc20uZGVzZWxlY3RSb3coeSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuc2luZ2xlU2VsZWN0KCk7XG4gICAgICAgICAgICAgICAgc20uc2VsZWN0Um93KHkpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoaGFzU0hJRlQpIHtcbiAgICAgICAgICAgICAgICBzbS5jbGVhcigpO1xuICAgICAgICAgICAgICAgIHNtLnNlbGVjdFJvdyh0aGlzLmxhc3RFZGdlU2VsZWN0aW9uWzFdLCB5KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKCFhbHJlYWR5U2VsZWN0ZWQgJiYgIWhhc1NISUZUKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5sYXN0RWRnZVNlbGVjdGlvblsxXSA9IHk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLnJlcGFpbnQoKTtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICBzaW5nbGVTZWxlY3Q6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgaXNDaGVja2JveE9ubHlSb3dTZWxlY3Rpb25zID0gdGhpcy5pc0NoZWNrYm94T25seVJvd1NlbGVjdGlvbnMoKSxcbiAgICAgICAgICAgIGlzU2luZ2xlUm93U2VsZWN0aW9uTW9kZSA9IHRoaXMuaXNTaW5nbGVSb3dTZWxlY3Rpb25Nb2RlKCksXG4gICAgICAg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AgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy5yb3dIZWFkZXIgPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMsIHtcbiAgICAgICAgICAgIGZvbnQ6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyRm9udDtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJGb250ID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyQmFja2dyb3VuZENvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLmNvbHVtbkhlYWRlciA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9ybWF0OiB7XG4gICAgICAgICAgICAgICAgdmFsdWU6ICdkZWZhdWx0J1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGZvbnQ6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyRm9udDtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJGb250ID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZENvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLmNvbHVtbkhlYWRlckNvbHVtblNlbGVjdGlvbiA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcy5jb2x1bW5IZWFkZXIsIHtcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJGb3JlZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnJvd0hlYWRlclJvd1NlbGVjdGlvbiA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcy5yb3dIZWFkZXIsIHtcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJGb3JlZ3JvdW5kUm93U2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyRm9yZWdyb3VuZFJvd1NlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kUm93U2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyQmFja2dyb3VuZFJvd1NlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLmZpbHRlclByb3BlcnRpZXMgPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMsIHtcbiAgICAgICAgICAgIGZvbnQ6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyRm9udDtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJGb250ID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJCYWNrZ3JvdW5kQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyQmFja2dyb3VuZENvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNlbGxCb3JkZXJTdHlsZToge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJDZWxsQm9yZGVyU3R5bGU7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyQ2VsbEJvcmRlclN0eWxlID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNlbGxCb3JkZXJUaGlja25lc3M6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQ2VsbEJvcmRlclRoaWNrbmVzcztcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJDZWxsQm9yZGVyVGhpY2tuZXNzID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnRyZWVDb2x1bW5Qcm9wZXJ0aWVzID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb250OiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5Gb250O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5Gb250ID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRDb2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBmb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMudHJlZUNvbHVtblByb3BlcnRpZXNDb2x1bW5TZWxlY3Rpb24gPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMudHJlZUNvbHVtblByb3BlcnRpZXMsIHtcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uRm9yZWdyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5Gb3JlZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcmV0dXJuIHByb3BlcnRpZXM7XG4gICAgfSxcblxuICAgIGdld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XG4gICAgICAgICAgICBlYWNoVHlwZSA9IHRoaXMudHlwZU9mKHZhbHVlKTtcbiAgICAgICAgICAgIGlmICh0eXBlICE9PSBlYWNoVHlwZSkge1xuICAgICAgICAgICAgICAgIGlmIChpc051bWJlciAmJiAodHlwZW9mIHZhbHVlID09PSAnbnVtYmVyJykpIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZSA9ICdmbG9hdCc7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdtaXhlZCc7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0eXBlO1xuICAgIH0sXG5cbiAgICB0eXBlT2Y6IGZ1bmN0aW9uKHNvbWV0aGluZykge1xuICAgICAgICB2YXIgdHlwZU9mID0gdHlwZW9mIHNvbWV0aGluZztcbiAgICAgICAgc3dpdGNoICh0eXBlT2YpIHtcbiAgICAgICAgICAgIGNhc2UgJ29iamVjdCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIHNvbWV0aGluZy5jb25zdHJ1Y3Rvci5uYW1lLnRvTG93ZXJDYXNlKCk7XG4gICAgICAgICAgICBjYXNlICdudW1iZXInOlxuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUludChzb21ldGhpbmcpID09PSBzb21ldGhpbmcgPyAnaW50JyA6ICdmbG9hdCc7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHJldHVybiB0eXBlT2Y7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgZ2V0UHJvcGVydGllczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmJlaGF2aW9yLmdldFByaXZhdGVTdGF0ZSgpLmNvbHVtblByb3BlcnRpZXNbdGhpcy5pbmRleF07XG4gICAgfSxcblxuICAgIHNldFByb3BlcnRpZXM6IGZ1bmN0aW9uKHByb3BlcnRpZXMpIHtcbiAg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saWFzXG4gICAgICogQHR5cGUge3N0cmluZ31cbiAgICAgKiBAbWVtYmVyT2YgQ2hvaWNlLnByb3RvdHlwZVxuICAgICAqL1xuICAgIGFsaWFzOiAnY2hvaWNlJyxcblxuICAgIC8qKlxuICAgICAqIHRoZSBsaXN0IG9mIGl0ZW1zIHRvIHBpY2sgZnJvbVxuICAgICAqIEB0eXBlIHtBcnJheX1cbiAgICAgKiBAbWVtYmVyT2YgQ2hvaWNlLnByb3RvdHlwZVxuICAgICAqL1xuICAgIGl0ZW1zOiBbJ2EnLCAnYicsICdjJ10sXG5cbiAgICB0ZW1wbGF0ZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIC8qXG4gICAgICAgICAgICAgICAgPHNlbGVjdCBpZD1cImVkaXRvclwiPlxuICAgICAgICAgICAgICAgICAgICB7eyNpdGVtc319XG4gICAgICAgICAgICAgICAgICAgICAgICA8b3B0aW9uIHZhbHVlPVwie3sufX1cIj57ey59fTwvb3B0aW9uPlxuICAgICAgICAgICAgICAgICAgICB7ey9pdGVtc319XG4gICAgICAgICAgICAgICAgPC9zZWxlY3Q+XG4gICAgICAgICAgICAqL1xuICAgIH0sXG5cbiAgICBhdXRvcG9wdWxhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgYmVoYXZpb3IgPSB0aGlzLmdyaWQuYmVoYXZpb3I7XG4gICAgICAgIHZhciBwb2ludCA9IHRoaXMuZ2V0RWRpdG9yUG9pbnQoKTtcbiAgICAgICAgdmFyIGNvbFByb3BzID0gdGhpcy5ncmlkLmdldENvbHVtblByb3BlcnRpZXMocG9pbnQueCk7XG4gICAgICAgIGlmICghY29sUHJvcHMuYXV0b3BvcHVsYXRlRWRpdG9yKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGhlYWRlckNvdW50ID0gdGhpcy5ncmlkLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIHZhciByb3dDb3VudCA9IHRoaXMu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NTCA9ICdNYW5hZ2UgRmlsdGVycyc7XG4gICAgICAgIHZhciBmaWx0ZXIgPSB0aGlzLmdyaWQuZmlsdGVyO1xuICAgICAgICAvL3ZhciBzZWxmID0gdGhpcztcbiAgICAgICAgaWYgKGRpYWxvZy5pc09wZW4oKSkge1xuICAgICAgICAgICAgZGlhbG9nLmNsb3NlKCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG5cbiAgICAgICAgICAgIGRpYWxvZy5jbGVhcigpO1xuICAgICAgICAgICAgZGlhbG9nLm92ZXJsYXkuYXBwZW5kQ2hpbGQodGhpcy5kaWFsb2cpO1xuXG4gICAgICAgICAgICBmaWx0ZXIuaW5pdGlhbGl6ZShmaWVsZHNQcm92aWRlcik7XG5cbiAgICAgICAgICAgIGRpYWxvZy5vbk9rUHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25PayAmJiBmaWx0ZXIub25PaygpKSB7IC8vIG9uT0soKSB0cnV0aHkgcmVzdWx0IG1lYW5zIGFib3J0OyBmYWxzeSBtZWFucyBwcm9jZWVkXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2VsZi50ZWFyRG93bigpO1xuICAgICAgICAgICAgICAgIGJlaGF2aW9yLnNldENvbXBsZXhGaWx0ZXIoY29sdW1uSW5kZXgsIHtcbiAgICAgICAgICAgICAgICAgICAgLy90eXBlOiBmaWx0ZXIuYWxpYXMsXG4gICAgICAgICAgICAgICAgICAgIHN0YXRlOiBmaWx0ZXIuZ2V0U3RhdGUoKVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGRpYWxvZy5jbG9zZSgpO1xuICAgICAgICAgICAgICAgIGJlaGF2aW9yLmFwcGx5QW5hbHl0aWNzKCk7XG4gICAgICAgICAgICAgICAgYmVoYXZpb3IuY2hhbmdlZCgpO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGlhbG9nLm9uQ2FuY2VsUHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25DYW5jZWwgJiYgZmlsdGVyLm9uQ2FuY2VsKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzZWxmLnRlYXJEb3duKCk7XG4gICAgICAgICAgICAgICAgZGlhbG9nLmNsb3NlKCk7XG4gICAgICAgICAgICAgICAgZmlsdGVyID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGlhbG9nLm9uRGVsZXRlUHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25EZWxldGUgJiYgZmlsdGVyLm9uRGVsZXRlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzZWxmLnRlYXJEb3duKCk7XG4gICAgICAgICAgICAgICAgYmVoYXZpb3Iuc2V0Q29tcGxleEZpbHRlcihjb2x1bW5JbmRleCwgdW5kZWZpbmVkKTtcbiAgICAgICAgICAgICAgICBkaWFsb2cuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICBiZWhhdmlvci5hcHBseUFuYWx5dGljcygpO1xuICAgICAgICAgICAgICAgIGJlaGF2aW9yLmNoYW5nZWQoKTtcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIGRpYWxvZy5vblJlc2V0UHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25SZXNldCAmJiBmaWx0ZXIub25SZXNldCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2VsZi50ZWFyRG93bigpO1xuICAgICAgICAgICAgICAgIGZpbHRlci5pbml0aWFsaXplKGRpYWxvZyk7XG4gICAgICAgICAgICAgICAgaWYgKGZpbHRlci5vblNob3cpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlsdGVyLm9uU2hvdyhzZWxmLmNvbnRlbnQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIHZhciBjZWxsQm91bmRzID0gdGhpcy5ncmlkLl9nZXRCb3VuZHNPZkNlbGwoY29sdW1uSW5kZXgsIGVkaXRvclBvaW50LnkpO1xuXG4gICAgICAgICAgICAvL2hhY2sgdG8gYWNjb21vZGF0ZSBib290c3RyYXAgbWFyZ2luIGlzc3Vlcy4uLlxuICAgICAgICAgICAgdmFyIHhPZmZzZXQgPVxuICAgICAgICAgICAgICAgIHRoaXMuZ3JpZC5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCkubGVmdCAtXG4gICAgICAgICAgICAgICAgdGhpcy5ncmlkLmRpdkNhbnZhcy5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKS5sZWZ0O1xuICAgICAgICAgICAgY2VsbEJvdW5kcy54ID0gY2VsbEJvdW5kcy54IC0geE9mZnNldDtcbiAgICAgICAgICAgIGRpYWxvZy5vcGVuRnJvbShjZWxsQm91bmRzKTtcbiAgICAgICAgICAgIHZhciBwcmV2aW91c1N0YXRlID0gYmVoYXZpb3IuZ2V0Q29tcGxleEZpbHRlcihjb2x1bW5JbmRleCk7XG4gICAgICAgICAgICBpZiAocHJldmlvdXNTdGF0ZSkge1xuICAgICAgICAgICAgICAgIGZpbHRlci5zZXRTdGF0ZShwcmV2aW91c1N0YXRlLnN0YXRlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgaWYgKGZpbHRlci5vblNob3cpIHtcbiAgICAgICAgIC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RhU291cmNlKCk7XG4gICAgICAgIHZhciBjb3VudCA9IGRzLmdldFJvd0NvdW50KCk7XG4gICAgICAgIHZhciByZXN1bHQgPSBuZXcgQXJyYXkoY291bnQpO1xuICAgICAgICBmb3IgKHZhciB5ID0gMDsgeSA8IGNvdW50OyB5KyspIHtcbiAgICAgICAgICAgIHJlc3VsdFt5XSA9IGRzLmdldFJvdyh5KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB4XG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHlcbiAgICAgKiBAcmV0dXJucyB7Kn1cbiAgICAgKi9cbiAgICBnZXRWYWx1ZTogZnVuY3Rpb24oeCwgeSkge1xuICAgICAgICB2YXIgaGFzSGllcmFyY2h5Q29sdW1uID0gdGhpcy5oYXNIaWVyYXJjaHlDb2x1bW4oKTtcbiAgICAgICAgdmFyIGhlYWRlclJvd0NvdW50ID0gdGhpcy5ncmlkLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIHZhciB2YWx1ZTtcbiAgICAgICAgaWYgKGhhc0hpZXJhcmNoeUNvbHVtbikge1xuICAgICAgICAgICAgaWYgKHggPT09IC0yKSB7XG4gICAgICAgICAgICAgICAgeCA9IDA7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAodGhpcy5oYXNBZ2dyZWdhdGVzKCkpIHtcbiAgICAgICAgICAgIHggKz0gMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoeSA8IGhlYWRlclJvd0NvdW50KSB7XG4gICAgICAgICAgICB2YWx1ZSA9IHRoaXMuZ2V0SGVhZGVyUm93VmFsdWUoeCwgeSk7XG4gICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgICAgIH1cbiAgICAgICAgLy8gaWYgKG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KTtcbiAgICAgICAgdGhpcy5wb3N0c29ydGVyID0gbmV3IGFuYWx5dGljcy5EYXRhU291cmNlU29ydGVyQ29tcG9zaXRlKHRoaXMucG9zdGZpbHRlcik7XG5cbiAgICAgICAgdGhpcy5hcHBseUFuYWx5dGljcygpO1xuXG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtBcnJheTxBcnJheT59IHRvdGFsUm93c1xuICAgICAqL1xuICAgIHNldFRvcFRvdGFsczogZnVuY3Rpb24odG90YWxSb3dzKSB7XG4gICAgICAgIHRoaXMudG9wVG90YWxzID0gdG90YWxSb3dzO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtBcnJheTxBcnJheT59XG4gICAgICovXG4gICAgZ2V0VG9wVG90YWxzOiBmdW5jdGlvbigpIHtcbiAgICAgICAgaWYgKCF0aGlzLmhhc0FnZ3JlZ2F0ZXMoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMudG9wVG90YWxzO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLmdldERhdGFTb3VyY2UoKS5nZXRHcmFuZFRvdGFscygpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSB7QXJyYXk8QXJyYXk+fSB0b3RhbFJvd3NcbiAgICAgKi9cbiAgICBzZXRCb3R0b21Ub3RhbHM6IGZ1bmN0aW9uKHRvdGFsUm93cykge1xuICAgICAgICB0aGlzLmJvdHRvbVRvdGFscyA9IHRvdGFsUm93cztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5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3JvdXBCeXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBmaWVsZCA9IGhlYWRlcnNbZ3JvdXBCeXNbaV1dO1xuICAgICAgICAgICAgZ3JvdXBzLnB1c2goe1xuICAgICAgICAgICAgICAgIGlkOiBncm91cEJ5c1tpXSxcbiAgICAgICAgICAgICAgICBsYWJlbDogZmllbGQsXG4gICAgICAgICAgICAgICAgZmllbGQ6IGZpZWxkc1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGdyb3VwcztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7b2JqZWN0W119XG4gICAgICovXG4gICAgZ2V0QXZhaWxhYmxlR3JvdXBzOiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIGhlYWRlcnMgPSB0aGlzLnNvdXJjZS5nZXRIZWFkZXJzKCkuc2xpY2UoMCk7XG4gICAgICAgIHZhciBncm91cEJ5cyA9IHRoaXMuYW5hbHl0aWNzLmdyb3VwQnlzO1xuICAgICAgICB2YXIgZ3JvdXBzID0gW107XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgaGVhZGVycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgaWYgKGdyb3VwQnlzLmluZGV4T2YoaSkgPT09IC0xKSB7XG4gICAgICAgICAgICAgICAgdmFyIGZpZWxkID0gaGVhZGVyc1tpXTtcbiAgICAgICAgICAgICAgICBncm91cHMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIGlkOiBpLFxuICAgICAgICAgICAgICAgICAgICBsYWJlbDogZmllbGQsXG4gICAgICAgICAgICAgICAgICAgIGZpZWxkOiBmaWVsZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBncm91cHM7XG4gICAgfSxcbl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MudW5zaGlmdChjb2xJbmRleCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzdGF0ZS5zb3J0cy5sZW5ndGggPSAwO1xuICAgICAgICAgICAgc3RhdGUuc29ydHMudW5zaGlmdChjb2xJbmRleCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHN0YXRlLnNvcnRzLmxlbmd0aCA+IDMpIHtcbiAgICAgICAgICAgIHN0YXRlLnNvcnRzLmxlbmd0aCA9IDM7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gaW5kZXhcbiAgICAgKiBAcGFyYW0gcmV0dXJuQXNTdHJpbmdcbiAgICAgKiBAcmV0dXJucyB7Kn1cbiAgICAgKi9cbiAgICBnZXRTb3J0SW1hZ2VGb3JDb2x1bW46IGZ1bmN0aW9uKGluZGV4KSB7XG4gICAgICAgIGluZGV4Kys7XG4gICAgICAgIHZhciB1cCA9IHRydWU7XG4gICAgICAgIHZhciBzb3J0cyA9IHRoaXMuZ2V0UHJpdmF0ZVN0YXRlKCkuc29ydHM7XG4gICAgICAgIGlmICghc29ydHMpIHtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHZhciBwb3NpdGlvbiA9IHNvcnRzLmluZGV4T2YoaW5kZXgpO1xuICAgICAgICBpZiAocG9zaXRpb24gPCAwKSB7XG4gICAgICAgICAgICBwb3NpdGlvbiA9IHNvcnRzLmluZGV4T2YoLTEgKiBpbmRleCk7XG4gICAgICAgICAgICB1cCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChwb3NpdGlvbiA8IDApIHtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHZhciByYW5rID0gc29ydHMubGVuZ3RoIC0gcG9zaXRpb247XG4gICAgICAgIHZhciBhcnJvdyA9IHVwID8gVVBXQVJEU19CTEFDS19BUlJPVyA6IERPV05XQVJEU19CTEFDS19BUlJPVztcbiAgICAgICAgcmV0dXJuIHJhbmsgKyBhcnJvdyArICcgJztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gY2VsbFxuICAgICAqIEBwYXJhbSBldmVudFxuICAgICAqL1xuICAgIGNlbGxDbGlja2VkOiBmdW5jdGlvbihjZWxsLCBldmVudCkge1xuICAgICAgICBpZiAoIXRoaXMuaGFzQWdncmVnYXRlcygpKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGV2ZW50LmdyaWRDZWxsLnggIT09IDApIHtcbiAgICAgICAgICAgIHJldHVybjsgLy8gdGhpcyB3YXNuJ3QgYSBjbGljayBvbiB0aGUgaGllcmFyY2h5IGNvbHVtblxuICAgICAgICB9XG4gICAgICAgIHZhciBoZWFkZXJSb3dDb3VudCA9IHRoaXMuZ3JpZC5nZXRIZWFkZXJSb3dDb3VudCgpO1xuICAgICAgICB2YXIgeSA9IGV2ZW50LmdyaWRDZWxsLnkgLSBoZWFkZXJSb3dDb3VudDtcbiAgICAgICAgdGhpcy5nZXREYXRhU291cmNlKCkuY2xpY2soeSk7XG4gICAgICAgIHRoaXMuYXBwbHlBbmFseXRpY3ModHJ1ZSk7XG4gICAgICAgIHRoaXMuY2hhbmdlZCgpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgZGF0YU1vZGVscy5KU09OLnByb3RvdHlwZVxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSB5XG4gICAgICogQHJldHVybnMge29iamVjdH1cbiAgICAgKi9cbiAgICBnZXRSb3c6IGZ1bmN0aW9uKHkpIHtcbiAgICAgICAgdmFyIGhlYWRlclJvd0NvdW50ID0gdGhpcy5ncmlkLmdldEhl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gICAgICAgICAgIHZhciBudW1GaXhlZFJvd3MgPSBncmlkLmdldEZpeGVkUm93Q291bnQoKTtcblxuICAgICAgICAgICAgLy9pZiB3ZSBhcmUgaW4gdGhlIGZpeGVkIGFyZWEgZG8gbm90IGFwcGx5IHRoZSBzY3JvbGwgdmFsdWVzXG4gICAgICAgICAgICAvL2NoZWNrIGJvdGggeCBhbmQgeSB2YWx1ZXMgaW5kZXBlbmRlbnRseVxuICAgICAgICAgICAgaWYgKHZpZXdDZWxsLnggPCBudW1GaXhlZENvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICBkeCA9IHZpZXdDZWxsLng7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh2aWV3Q2VsbC55IDwgbnVtRml4ZWRSb3dzKSB7XG4gICAgICAgICAgICAgICAgZHkgPSB2aWV3Q2VsbC55O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgZENlbGwgPSBncmlkLm5ld1BvaW50KGR4LCBkeSk7XG5cbiAgICAgICAgICAgIHZhciBwcmltRXZlbnQgPSBldmVudC5wcmltaXRpdmVFdmVudDtcbiAgICAgICAgICAgIHZhciBrZXlzID0gcHJpbUV2ZW50LmRldGFpbC5rZXlzO1xuICAgICAgICAgICAgdGhpcy5kcmFnZ2luZyA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmV4dGVuZFNlbGVjdGlvbihncmlkLCBkQ2VsbCwga2V5cyk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENlbGxTZWxlY3Rpb24ucHJvdG90eXBlXG4gICAgICogQGRlc2MgSGFuZGxlIHRoaXMgZXZlbnQgZG93biB0aGUgZmVhdHVyZSBjaGFpbiBvZiByZXNwb25zaWJpbGl0eS5cbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VEcmFnOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICB2YXIgaXNSaWdodENsaWNrID0gZXZlbnQucHJpbWl0aXZlRXZlbnQuZGV0YWlsLmlzUmlnaHRDbGljaztcblxuICAgICAgICBpZiAoIWdyaWQuaXNDZWxsU2VsZWN0aW9uKCkgfHwgaXNSaWdodENsaWNrIHx8ICF0aGlzLmRyYWdnaW5nKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRHJhZyhncmlkLCBldmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG5cbiAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgICAgIHZhciBudW1GaXhlZFJvd3MgPSBncmlkLmdldEZpeGVkUm93Q291bnQoKTtcblxuICAgICAgICAgICAgdmFyIGNlbGwgPSBldmVudC5ncmlkQ2VsbDtcbiAgICAgICAgICAgIHZhciB2aWV3Q2VsbCA9IGV2ZW50LnZpZXdQb2ludDtcbiAgICAgICAgICAgIHZhciBkeCA9IGNlbGwueDtcbiAgICAgICAgICAgIHZhciBkeSA9IGNlbGwueTtcblxuICAgICAgICAgICAgLy9pZiB3ZSBhcmUgaW4gdGhlIGZpeGVkIGFyZWEgZG8gbm90IGFwcGx5IHRoZSBzY3JvbGwgdmFsdWVzXG4gICAgICAgICAgICAvL2NoZWNrIGJvdGggeCBhbmQgeSB2YWx1ZXMgaW5kZXBlbmRlbnRseVxuICAgICAgICAgICAgaWYgKHZpZXdDZWxsLnggPCBudW1GaXhlZENvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICBkeCA9IHZpZXdDZWxsLng7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh2aWV3Q2VsbC55IDwg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G4gICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgdmFyIG51bUZpeGVkUm93cyA9IGdyaWQuZ2V0Rml4ZWRSb3dDb3VudCgpO1xuXG4gICAgICAgIHZhciBkcmFnRW5kSW5GaXhlZEFyZWFYID0gbGFzdERyYWdDZWxsLnggPCBudW1GaXhlZENvbHVtbnM7XG4gICAgICAgIHZhciBkcmFnRW5kSW5GaXhlZEFyZWFZID0gbGFzdERyYWdDZWxsLnkgPCBudW1GaXhlZFJvd3M7XG5cbiAgICAgICAgaWYgKCFkcmFnU3RhcnRlZEluSGVhZGVyQXJlYSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudERyYWcueCA8IGIub3JpZ2luLngpIHtcbiAgICAgICAgICAgICAgICB4T2Zmc2V0ID0gLTE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50RHJhZy55IDwgYi5vcmlnaW4ueSkge1xuICAgICAgICAgICAgICAgIHlPZmZzZXQgPSAtMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5jdXJyZW50RHJhZy54ID4gYi5vcmlnaW4ueCArIGIuZXh0ZW50LngpIHtcbiAgICAgICAgICAgIHhPZmZzZXQgPSAxO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmN1cnJlbnREcmFnLnkgPiBiLm9yaWdpbi55ICsgYi5leHRlbnQueSkge1xuICAgICAgICAgICAgeU9mZnNldCA9IDE7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgZHJhZ0NlbGxPZmZzZXRYID0geE9mZnNldDtcbiAgICAgICAgdmFyIGRyYWdDZWxsT2Zmc2V0WSA9IHlPZmZzZXQ7XG5cbiAgICAgICAgaWYgKGRyYWdFbmRJbkZpeGVkQXJlYVgpIHtcbiAgICAgICAgICAgIGRyYWdDZWxsT2Zmc2V0WCA9I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DdXJzb3JOYW1lOiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuICctd2Via2l0LWdyYWJiaW5nJztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENlbGxNb3ZpbmcucHJvdG90eXBlXG4gICAgICogQGRlc2MgaGFuZGxlIHRoaXMgZXZlbnRcbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VEcmFnOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuXG4gICAgICAgIHZhciBncmlkQ2VsbCA9IGV2ZW50LmdyaWRDZWxsO1xuICAgICAgICB2YXIgeDtcbiAgICAgICAgLy92YXIgeTtcblxuICAgICAgICB2YXIgZGlzdGFuY2UgPSBNYXRoLmFicyhldmVudC5wcmltaXRpdmVFdmVudC5kZXRhaWwuZHJhZ3N0YXJ0LnggLSBldmVudC5wcmltaXRpdmVFdmVudC5kZXRhaWwubW91c2UueCk7XG5cbiAgICAgICAgaWYgKGRpc3RhbmNlIDwgMTApIHtcbiAgICAgICAgICAgIGlmICh0aGlzLm5leHQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLm5leHQuaGFuZGxlTW91c2VEcmFnKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0aGlzLmlzSGVhZGVyUm93KGdyaWQsIGV2ZW50KSAmJiB0aGlzLmRyYWdBcm1lZCAmJiAhdGhpcy5kcmFnZ2luZykge1xuICAgICAgICAgICAgdGhpcy5kcmFnZ2luZyA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmRyYWdDb2wgPSBncmlkQ2VsbC54O1xuICAgICAgICAgICAgdGhpcy5kcmFnT2Zmc2V0ID0gZXZlbnQubW91c2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c2xhdGUoJyArIGZsb2F0ZXJTdGFydFggKyAncHgsICcgKyAwICsgJ3B4KSc7XG5cbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBzZWxmLnNldENyb3NzQnJvd3NlclByb3BlcnR5KGQsICd0cmFuc2l0aW9uJywgKHNlbGYuaXNXZWJraXQgPyAnLXdlYmtpdC0nIDogJycpICsgJ3RyYW5zZm9ybSAnICsgY29sdW1uQW5pbWF0aW9uVGltZSArICdtcyBlYXNlJyk7XG4gICAgICAgICAgICAgICAgc2VsZi5zZXRDcm9zc0Jyb3dzZXJQcm9wZXJ0eShkLCAndHJhbnNmb3JtJywgJ3RyYW5zbGF0ZSgnICsgZHJhZ2dlclN0YXJ0WCArICdweCwgJyArIC0yICsgJ3B4KScpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBncmlkLnJlcGFpbnQoKTtcbiAgICAgICAgICAgIC8vbmVlZCB0byBjaGFuZ2UgdGhpcyB0byBrZXkgZnJhbWVzXG5cbiAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zZXRDcm9zc0Jyb3dzZXJQcm9wZXJ0eShkLCAndHJhbnNpdGlvbicsICcnKTtcbiAgICAgICAgICAgICAgICBncmlkLnJlbmRlck92ZXJyaWRlc0NhY2hlLmZsb2F0ZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIGdyaWQucmVwYWludCgpO1xuICAgICAgICAgICAgICAgIHNlbGYuZG9GbG9hdGVyQW5pbWF0aW9uKGdyaWQpO1xuICAgICAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgZC5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmlzRmxvYXRpbmdOb3cgPSBmYWxzZ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lUmlnaHQpIHtcbiAgICAgICAgICAgIC8vICAgICBvdmVyQ29sID0gb3ZlckNvbCAtIDE7XG4gICAgICAgICAgICAvLyB9XG4gICAgICAgICAgICBpZiAodGhpcy5pc0Zsb2F0aW5nTm93KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLmlzRmxvYXRpbmdOb3cgPSB0cnVlO1xuICAgICAgICAgICAgdGhpcy5jcmVhdGVGbG9hdENvbHVtbihncmlkLCBvdmVyQ29sKTtcbiAgICAgICAgICAgIHRoaXMuZmxvYXRDb2x1bW5UbyhncmlkLCBkcmFnZ2VkVG9UaGVSaWdodCk7XG4gICAgICAgIH0gZWxzZSB7XG5cbiAgICAgICAgICAgIGlmICh4IDwgbWluWCAtIDEwKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jaGVja0F1dG9TY3JvbGxUb0xlZnQoZ3JpZCwgeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoeCA+IG1pblggLSAxMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uRHJhZ0F1dG9TY3JvbGxpbmdMZWZ0ID0gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvL2xldHMgY2hlY2sgZm9yIGF1dG9zY3JvbGwgdG8gcmlnaHQgaWYgd2VyZSB1cCBhZ2FpbnN0IGl0XG4gICAgICAgICAgICBpZiAoYXRNYXggfHwgeCA+IG1heFggKyAxMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tBdXRvU2Nyb2xsVG9SaWdodChncmlkLCB4KTtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoeCA8IG1heFggKyAxMCkge1xuICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uRHJhZ0F1dG9TY3JvbGxpbmdSaWdodCA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgIC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AgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZURvdWJsZUNsaWNrKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgQ29sdW1uU2VsZWN0aW9uLnByb3RvdHlwZVxuICAgICAqIEBkZXNjICogQGRlc2MgSGFuZGxlIHRoaXMgZXZlbnQgZG93biB0aGUgZmVhdHVyZSBjaGFpbiBvZiByZXNwb25zaWJpbGl0eS5cbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VEb3duOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICBpZiAodGhpcy5kb3VibGVDbGlja1RpbWVyKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoKCFncmlkLmlzQ29sdW1uU2VsZWN0aW9uKCkgfHwgZXZlbnQubW91c2VQb2ludC55IDwgNSkgJiYgdGhpcy5uZXh0KSB7XG4gICAgICAgICAgICB0aGlzLm5leHQuaGFuZGxlTW91c2VEb3duKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBpc1JpZ2h0Q2xpY2sgPSBldmVudC5wcmltaXRpdmVFdmVudC5kZXRhaWwuaXNSaWdodENsaWNrO1xuICAgICAgICB2YXIgY2VsbCA9IGV2ZW50LmdyaWRDZWxsO1xuICAgICAgICB2YXIgdmlld0NlbGwgPSBldmVudC52aWV3UG9pbnQ7XG4gICAgICAgIHZhciBkeCA9IGNlbGwueDtcbiAgICAgICAgdmFyIGR5ID0gY2VsbC55O1xuXG4gICAgICAgIHZhciBpc0hlYWRlciA9IGdyaWQuaXNTaG93SGVhZGVyUm93KCkgJiYgZHkgPT09IDAgJiYgZHggIT09IC0xO1xuXG4gICAgICAgIGlmIChpc1JpZ2h0Q2xpY2sgfHwgIWlzSGVhZGVyKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRG93bihncmlkLCBldmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBIT0xEIE9GRiBXSElMRSBXQUlUSU5HIEZPUiBET1VCTEUtQ0xJQ0tcbiAgICAgICAgICAgIHRoaXMuZG91YmxlQ2xpY2tUaW1lciA9IHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5kb3VibGVDbGlja1RpbWVyID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcblxuICAgICAgICAgICAgICAgIC8vaWYgd2UgYXJlIGluIHRoZSBmaXhlZCBhcmVhIGRvIG5vdCBhcHBseSB0aGUgc2Nyb2xsIHZhbHVlc1xuICAgICAgICAgICAgICAgIC8vY2hlY2sgYm90aCB4IGFuZCB5IHZhbHVlcyBpbmRlcGVuZGVudGx5XG4gICAgICAgICAgICAgICAgaWYgKHZpZXdDZWxsLnggPCBudW1GaXhlZENvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICAgICAgZHggPSB2aWV3Q2VsbC54O1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHZhciBkQ2VsbCA9IGdyaWQubmV3UG9pbnQoZHgsIDApO1xuXG4gICAgICAgICAgICAgICAgdmFyIHByaW1FdmVudCA9IGV2ZW50LnByaW1pdGl2ZUV2ZW50O1xuICAgICAgICAgICAgICAgIHZhciBrZXlzID0gcHJpbUV2ZW50LmRldGFpbC5rZXlzO1xuIC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AgICAgKiBAcGFyYW0ge09iamVjdH0gZXZlbnQgLSB0aGUgZXZlbnQgZGV0YWlsc1xuICAgICAqL1xuICAgIGhhbmRsZU1vdXNlRG93bjogZnVuY3Rpb24oZ3JpZCwgZXZlbnQpIHtcbiAgICAgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRG93bihncmlkLCBldmVudCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEZlYXR1cmUucHJvdG90eXBlXG4gICAgICogQGRlc2MgaGFuZGxlIHRoaXMgZXZlbnQgZG93biB0aGUgZmVhdHVyZSBjaGFpbiBvZiByZXNwb25zaWJpbGl0eVxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICogQHBhcmFtIHtPYmplY3R9IGV2ZW50IC0gdGhlIGV2ZW50IGRldGFpbHNcbiAgICAgKi9cbiAgICBoYW5kbGVNb3VzZVVwOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICB0aGlzLm5leHQuaGFuZGxlTW91c2VVcChncmlkLCBldmVudCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEZlYXR1cmUucHJvdG90eXBlXG4gICAgICogQGRlc2MgaGFuZGxlIHRoaXMgZXZlbnQgZG93biB0aGUgZmVhdHVyZSBjaGFpbiBvZiByZXNwb25zaWJpbGl0eVxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICogQHBhcmFtIHtPYmplY3R9IGV2ZW50IC0gdGhlIGV2ZW50IGRldGFpbHNcbiAgICAgKi9cbiAgICBoYW5kbGVLZXlEb3duOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICB0aGl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aXlvZmZzZXQ7XG5cbiAgICAgICAgLy8gc2V0dGluZyBnYyBwcm9wZXJ0aWVzIGFyZSBleHBlbnNpdmUsIGxldCdzIG5vdCBkbyBpdCBuZWVkbGVzc2x5XG5cbiAgICAgICAgaWYgKHZhbCAmJiB2YWwuY29uc3RydWN0b3IgPT09IEFycmF5KSB7XG4gICAgICAgICAgICBsZWZ0SWNvbiA9IHZhbFswXTtcbiAgICAgICAgICAgIHJpZ2h0SWNvbiA9IHZhbFsyXTtcbiAgICAgICAgICAgIHZhbCA9IHZhbFsxXTtcbiAgICAgICAgICAgIGlmICh2YWwgJiYgdHlwZW9mIHZhbCA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgICAgICBpZiAodmFsLmNvbnN0cnVjdG9yLm5hbWUgPT09ICdIVE1MSW1hZ2VFbGVtZW50JykgeyAvLyBtdXN0IGJlIGFuIGltYWdlXG4gICAgICAgICAgICAgICAgICAgIGNlbnRlckljb24gPSB2YWw7XG4gICAgICAgICAgICAgICAgICAgIHZhbCA9IG51bGw7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGxlZnRJY29uICYmIGxlZnRJY29uLm5vZGVOYW1lICE9PSAnSU1HJykge1xuICAgICAgICAgICAgICAgIGxlZnRJY29uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChyaWdodEljb24gJiYgcmlnaHRJY29uLm5vZGVOYW1lICE9PSAnSU1HJykge1xuICAgICAgICAgICAgICAgIHJpZ2h0SWNvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY2VudGVySWNvbiAmJiBjZW50ZXJJY29uLm5vZGVOYW1lICE9PSAnSU1HJykge1xuICAgICAgICAgICAgICAgIGNlbnRlckljb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdmFsID0gdmFsdWVPckZ1bmN0aW9uRXhlY3V0Z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gICAgICBpZiAobGVmdEljb24pIHtcbiAgICAgICAgICAgIGl5b2Zmc2V0ID0gTWF0aC5yb3VuZCgoaGVpZ2h0IC0gbGVmdEljb24uaGVpZ2h0KSAvIDIpO1xuICAgICAgICAgICAgZ2MuZHJhd0ltYWdlKGxlZnRJY29uLCB4ICsgbGVmdFBhZGRpbmcsIHkgKyBpeW9mZnNldCk7XG4gICAgICAgICAgICBpY29uV2lkdGggPSBNYXRoLm1heChsZWZ0SWNvbi53aWR0aCArIDIpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyaWdodEljb24gJiYgd2lkdGggPiAxLjc1ICogaGVpZ2h0KSB7XG4gICAgICAgICAgICBpeW9mZnNldCA9IE1hdGgucm91bmQoKGhlaWdodCAtIHJpZ2h0SWNvbi5oZWlnaHQpIC8gMik7XG4gICAgICAgICAgICB2YXIgcmlnaHRYID0geCArIHdpZHRoIC0gcmlnaHRJY29uLndpZHRoO1xuICAgICAgICAgICAgaWYgKGJhY2tncm91bmRDb2xvciAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgZ2MuZmlsbFN0eWxlID0gYmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIGdjLmZpbGxSZWN0KHJpZ2h0WCwgeSwgcmlnaHRJY29uLndpZHRoLCBoZWlnaHQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBnYy5jbGVhclJlY3QocmlnaHRYLCB5LCByaWdodEljb24ud2lkdGgsIGhlaWdodCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBnYy5kcmF3SW1hZ2UocmlnaHRJY29uLCByaWdodFgsIHkgKyBpeW9mZnNldCk7XG4gICAgICAgICAgICBpY29uV2lkdGggPSBNYXRoLm1heChyaWdodEljb24ud2lkdGggKyAyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY2VudGVySWNvbikge1xuICAgICAgICAgICAgaXlvZmZzZXQgPSBNYXRoLnJvdW5kKChoZWlnaHQgLSBjZW50ZXJJY29uLmhlaWdodCkgLyAyKTtcbiAgICAgICAgICAgIGl4b2Zmc2V0ID0gTWF0aC5yb3VuZCgod2lkdGggLSBjZW50ZXJJY29uLndpZHRoKSAvIDIpO1xuICAgICAgICAgICAgZ2MuZHJhd0ltYWdlKGNlbnRlckljb24sIHggKyB3aWR0aCAtIGl4b2Zmc2V0IC0gY2VudGVySWNvbi53aWR0aCwgeSArIGl5b2Zmc2V0KTtcbiAgICAgICAgICAgIGljb25XaWR0aCA9IE1hdGgubWF4KGNlbnRlckljb24ud2lkdGggKyAyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY29uZmlnLmNlbGxCb3JkZXJUaGlja25lc3MpIHtcbiAgICAgICAgICAgIGdjLmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgZ2MucmVjdCh4LCB5LCB3aWR0aCwgaGVpZ2h0KTtcbiAgICAgICAgICAgIGdjLmxpbmVXaWR0aCA9IGNvbmZpZy5jZWxsQm9yZGVyVGhpY2tuZXNzO1xuICAgICAgICAgICAgZ2Muc3Ryb2tlU3R5bGUgPSBjb25maWcuY2VsbEJvcmRlclN0eWxlO1xuXG4gICAgICAgICAgICAvLyBhbmltYXRlIHRoZSBkYXNoZWQgbGluZSBhIGJpdCBoZXJlIGZvciBmdW5cblxuICAgICAgICAgICAgZ2Muc3Ryb2tlKCk7XG4gICAgICAgICAgICBnYy5jbG9zZVBhdGgoKTtcbiAgICAgICAgfVxuICAgICAgICBjb25maWcubWluV2lkdGggPSBjb25maWcubWluV2lkdGggKyAyICogKGljb25XaWR0aCk7XG4gICAgfSxcblxuICAgIHJlbmRlck11bHRpTGluZVRleHQ6IGZ1bmN0aW9uKGdjLCB4LCB5LCBoZWlnaHQsIHdpZHRoLCBjb25maWcsIHZhbCkge1xuICAgICAgICB2YXIgbGluZXMgPSBmaXRUZXh0KGdjLCBjb25maWcsIHZhbCwgd2lkdGgpO1xuICAgICAgICBpZiAobGluZXMubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5yZW5kZXJTaW5nbGVMaW5lVGV4dChnYywgeCwgeSwgaGVpZ2h0LCB3aWR0aCwgY29uZmlnLCBzcXVlZXplKHZhbCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGNvbEhFZGdlT2Zmc2V0ID0gY29uZmlnLmNlbGxQYWRkaW5nLFxuICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gMCxcbiAgICAgICAgICAgIHZhbGlnbk9mZnNldCA9IGNvbmZpZy52b2Zmc2V0LFxuICAgICAgICAgICAgaGFsaWduID0gY29uZmlnLmhhbGlnbixcbiAgICAgICAgICAgIHRleHRIZWlnaHQgPSBjb25maWcuZ2V0VGV4dEhlaWdodChjb25maWcuZm9udCkuaGVpZ2h0O1xuXG4gICAgICAgIHN3aXRjaCAoaGFsaWduKSB7XG4gICAgICAgICAgICBjYXNlICdyaWdodCc6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gd2lkdGggLSBjb2xIRWRnZU9mZnNldDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ2NlbnRlcic6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gd2lkdGggLyAyO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnbGVmdCc6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gY29sSEVkZ2VPZmZzZXQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaE1pbiA9IDAsIHZNaW4gPSBNYXRoLmNlaWwodGV4dEhlaWdodCAvIDIpO1xuXG4gICAgICAgIHZhbGlnbk9mZnNldCArPSBNYXRoLmNlaWwoKGhlaWdodCAtIChsaW5lcy5sZW5ndGggLSAxKSAqIHRleHRIZWlnaHQpIC8gMik7XG5cbiAgICAgICAgaGFsaWduT2Z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gICAgICBjYXNlICdudW1iZXInOlxuICAgICAgICAgICAgICAgIHJldHVybiBvaWRQcmVmaXggKyB0eXBlT2YgKyAnXycgKyBrZXk7XG4gICAgICAgICAgICBjYXNlICdzdHJpbmcnOlxuICAgICAgICAgICAgICAgIHJldHVybiBvaWRQcmVmaXggKyB0eXBlT2YgKyAnXycgKyBrZXk7XG4gICAgICAgICAgICBjYXNlICdib29sZWFuJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gb2lkUHJlZml4ICsgdHlwZU9mICsgJ18nICsga2V5O1xuICAgICAgICAgICAgY2FzZSAnc3ltYm9sJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gb2lkUHJlZml4ICsgdHlwZU9mICsgJ18nICsga2V5O1xuICAgICAgICAgICAgY2FzZSAndW5kZWZpbmVkJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gb2lkUHJlZml4ICsgJ3VuZGVmaW5lZCc7XG4gICAgICAgICAgICBjYXNlICdvYmplY3QnOlxuICAgICAgICAgICAgY2FzZSAnZnVuY3Rpb24nOlxuICAgICAgICAgICAgICAgIC8qZXNsaW50LWRpc2FibGUgKi9cbiAgICAgICAgICAgICAgICBpZiAoIWtleS5fX19maW5oYXNoKSB7XG4gICAgICAgICAgICAgICAgICAgIGtleS5fX19maW5oYXNoID0gb2lkUHJlZml4ICsgY291bnRlcisrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4ga2V5Ll9fX2Zpbmhhc2g7XG4gICAgICAgICAgICAgICAgLyplc2xpbnQtZW5hYmxlICovXG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgLy8gT2JqZWN0LmlzIHBvbHlmaWxsLCBjb3VydGVzeSBvZiBAV2ViUmVmbGVjdGlvblxuICAgIHZhciBpcyA9IE9iamVjdC5pcyB8fFxuICAgICAgICBmdW5jdGlvbihhLCBiKSB7XG4gICAgICAgICAgICByZXR1cm4gYSA9PT0gYiA/IGEgIT09IDAgfHwgMSAvIGEg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GV0ZSB0aGlzLmRhdGFbaGFzaENvZGVdO1xuICAgIH07XG5cbiAgICBNYXBweS5wcm90b3R5cGUuZm9yRWFjaCA9IGZ1bmN0aW9uKGZ1bmMpIHtcbiAgICAgICAgdmFyIGtleXMgPSB0aGlzLmtleXM7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgdmFyIGtleSA9IGtleXNbaV07XG4gICAgICAgICAgICB2YXIgdmFsdWUgPSB0aGlzLmdldChrZXkpO1xuICAgICAgICAgICAgZnVuYyh2YWx1ZSwga2V5LCB0aGlzKTtcbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBNYXBweS5wcm90b3R5cGUubWFwID0gZnVuY3Rpb24oZnVuYykge1xuICAgICAgICB2YXIga2V5cyA9IHRoaXMua2V5cztcbiAgICAgICAgdmFyIG5ld01hcCA9IG5ldyBNYXBweSgpO1xuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHZhciBrZXkgPSBrZXlzW2ldO1xuICAgICAgICAgICAgdmFyIHZhbHVlID0gdGhpcy5nZXQoa2V5KTtcbiAgICAgICAgICAgIHZhciB0cmFuc2Zvcm1lZCA9IGZ1bmModmFsdWUsIGtleSwgdGhpcyk7XG4gICAgICAgICAgICBuZXdNYXAuc2V0KGtleSwgdHJhbnNmb3JtZWQpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBuZXdNYXA7XG4gICAgfTtcblxuICAgIE1hcHB5LnByb3RvdHlwZS5jb3B5ID0gZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBrZXlzID0gdGhpcy5rZXlzO1xuICAgICAgICB2YXIgbmV3TWFwID0gbmV3IE1hcHB5KCk7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgdmFyIGtleSA9IGtleXN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0VkZ2VzLmxlbmd0aCA9IDA7XG5cbiAgICAgICAgdGhpcy5jb2x1bW5FZGdlc1swXSA9IDA7XG4gICAgICAgIHRoaXMucm93RWRnZXNbMF0gPSAwO1xuICAgICAgICB0aGlzLnNjcm9sbEhlaWdodCA9IDA7XG5cbiAgICAgICAgdGhpcy52aXNpYmxlQ29sdW1ucy5sZW5ndGggPSAwO1xuICAgICAgICB0aGlzLnZpc2libGVSb3dzLmxlbmd0aCA9IDA7XG4gICAgICAgIHRoaXMuY29sdW1uRWRnZXNJbmRleE1hcCA9IFtdO1xuICAgICAgICB0aGlzLnJvd0VkZ2VzSW5kZXhNYXAgPSBbXTtcblxuICAgICAgICB0aGlzLmluc2VydGlvbkJvdW5kcyA9IFtdO1xuXG4gICAgICAgIGlmICh0aGlzLmdyaWQuaXNTaG93Um93TnVtYmVycygpKSB7XG4gICAgICAgICAgICBzdGFydC0tO1xuICAgICAgICAgICAgdGhpcy5jb2x1bW5FZGdlc1stMV0gPSAtMTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAoYyA9IHN0YXJ0OyBjIDwgbnVtQ29sdW1uczsgYysrKSB7XG4gICAgICAgICAgICB2eCA9IGM7XG4gICAgICAgICAgICBpZiAoYyA+PSBudW1GaXhlZENvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICB2eCA9IHZ4ICsgc2Nyb2xsTGVmdDtcbiAgICAgICAgICAgICAgICBpZiAoZmlyc3RWWCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgICAgIGZpcnN0VlggPSB2eDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgbGFzdFZYID0gdng7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoeCA+IHZpZXdXaWR0aCB8fCBudW1Db2x1bW5zIDw9IHZ4KSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB3aWR0aCA9IGdyaWQuZ2V0Q29sdW1uV2lkdGgodngpO1xuICAgICAgICAgICAgeCA9IHggKyB3aWR0aDtcbiAgICAgICAgICAgIHRoaXMuY29sdW1uRWRnZXNbYyArIDFdID0gTWF0aC5yb3VuZCh4KTtcbiAgICAgICAgICAgIHRoaXMudmlzaWJsZUNvbHVtbnNbY10gPSB2eDtcbiAgICAgICAgICAgIHRoaXMuY29sdW1uRWRnZXNJbmRleE1hcFt2eF0gPSBjO1xuXG4gICAgICAgICAgICBpbnNlcnRpb25Cb3VuZHNDdXJzb3IgPSBpbnNlcnRpb25Cb3VuZHNDdXJzb3IgKyBNYXRoLnJvdW5kKHdpZHRoIC8gMikgKyBwcmV2aW91c0luc2VydGlvbkJvdW5kc0N1cnNvclZhbHVlO1xuICAgICAgICAgICAgdGhpcy5pbnNlcnRpb25Cb3VuZHMucHVzaChpbnNlcnRpb25Cb3VuZHNDdXJzb3IpO1xuICAgICAgICAgICAgcHJldmlvdXNJbnNlcnRpb25Cb3VuZHNDdXJzb3JWYWx1ZSA9IE1hdGgucm91bmQod2lkdGggLyAyKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAociA9IDA7IHIgPCBudW1Sb3dzOyByKyspIHtcbiAgICAgICAgICAgIHZ5ID0gcjtcbiAgICAgICAgICAgIGlmIChyID49IG51bUZpeGVkUm93cykge1xuICAgICAgICAgICAgICAgIHZ5ID0gdnkgKyBzY3JvbGxUb3A7XG4gICAgICAgICAgICAgICAgaWYgKGZpcnN0VlkgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFZZID0gdnk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGxhc3RWWSA9IHZ5O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHkgPiB2aWV3SGVpZ2h0IHx8IG51bVJvd3MgPD0gdnkpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGhlaWdodCA9I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KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAod2hpY2hDb2wgPCAwKSB7XG4gICAgICAgICAgICB3aGljaENvbCA9IGVkZ2VzLmluZGV4T2YoeCAtIDIpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh3aGljaENvbCA8IDApIHtcbiAgICAgICAgICAgIHdoaWNoQ29sID0gZWRnZXMuaW5kZXhPZih4ICsgMSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHdoaWNoQ29sIDwgMCkge1xuICAgICAgICAgICAgd2hpY2hDb2wgPSBlZGdlcy5pbmRleE9mKHggLSAzKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB3aGljaENvbDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFJlbmRlcmVyLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm5zIHtudW1iZXJ9IFRoZSByb3cgaW5kZXggd2hlbiB0aGUgbW91c2VFdmVudCBjb29yZGluYXRlcyBhcmUgb3ZlciBhIHJvdyBkaXZpZGVyLlxuICAgICAqL1xuICAgIG92ZXJSb3dEaXZpZGVyOiBmdW5jdGlvbih5KSB7XG4gICAgICAgIHkgPSBNYXRoLnJvdW5kKHkpO1xuICAgICAgICB2YXIgd2hpY2ggPSB0aGlzLnJvd0VkZ2VzLmluZGV4T2YoeSArIDEpO1xuICAgICAgICBpZiAod2hpY2ggPCAwKSB7XG4gICAgICAgICAgICB3aGljaCA9IHRoaXMucm93RWRnZXMuaW5kZXhPZih5KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAod2hpY2ggPCAwKSB7XG4gICAgICAgICAgICB3aGljaCA9IHRoaXMucm93RWRnZXMuaW5kZXhPZih5IC0gMSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHdoaWNoO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtQb2ludH0gY2V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gICAgICAgICAgICBleSwgZXggPSBjeCAtIG94O1xuXG4gICAgICAgIGNlbGwueCA9IHhPdXRzaWRlID8gY3ggOiBveDtcbiAgICAgICAgY2VsbC53aWR0aCA9IHhPdXRzaWRlID8gMCA6IGV4O1xuXG4gICAgICAgIGlmIChyIDwgMCkgeyAvLyBib3R0b20gdG90YWxzIHJvd3NcbiAgICAgICAgICAgIHZhciBiZWhhdmlvciA9IHRoaXMuZ3JpZC5iZWhhdmlvcixcbiAgICAgICAgICAgICAgICBib3VuZHMgPSB0aGlzLmdldEJvdW5kcygpO1xuXG4gICAgICAgICAgICBleSA9IGJlaGF2aW9yLmdldERlZmF1bHRSb3dIZWlnaHQoKTtcbiAgICAgICAgICAgIG95ID0gYm91bmRzLmhlaWdodCArIHIgKiBleTtcbiAgICAgICAgICAgIGN5ID0gb3kgKyBleTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHkgPSB0aGlzLnJvd0VkZ2VzSW5kZXhNYXBbcl07XG4gICAgICAgICAgICBpZiAoeSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgeSA9IHRoaXMucm93RWRnZXNJbmRleE1hcFtyIC0gMV07XG4gICAgICAgICAgICAgICAgeU91dHNpZGUgPSB0cnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBveSA9IHRoaXMucm93RWRnZXNbeV07XG4gICAgICAgICAgICBjeSA9IHRoaXMucm93RWRnZXNbeSArIDFdO1xuICAgICAgICAgICAgZXkgPSBjeSAtIG95O1xuICAgICAgICB9XG5cbiAgICAgICAgY2VsbC55ID0geU91dHNpZGUgPyBjeSA6IG95O1xuICAgICAgICBjZWxsLmhlaWdodCA9IHlPdXRzaWRlID8gMCA6IGV5O1xuXG4gICAgICAgIHJldHVybiBjZWxsO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQGRlc2MgYW5zd2VyIHRoZSBjb2x1bW4gaW5kZXggdW5kZXIgdGhlIGNvb3JkaW5hdGUgYXQgcGl4ZWxYXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHBpeGVsWCAtIFRoZSBob3Jpem9udGFsIGNvb3JkaW5hdGUuXG4gICAgICogQHJldHVybnMge251bWJlcn0gVGhlIGNvbHVtbiBpbmRleCB1bmRlciB0aGUgY29vcmRpbmF0ZSBhdCBwaXhlbFguXG4gICAgICovXG4gICAgZ2V0Q29sdW1uRnJvbVBpeGVsWDogZnVuY3Rpb24ocGl4ZWxYKSB7XG4gICAgICAgIHZhciB3aWR0aCA9IDAsXG4gICAgICAgICAgICBmaXhlZENvbHVtbkNvdW50ID0gdGhpcy5nZXRGaXhlZENvbHVtbkNvdW50KCksXG4gICAgICAgICAgICBzY3JvbGxMZWZ0ID0gdGhpcy5ncmlkLmdldEhTY3JvbGxWYWx1ZSgpLFxuICAgICAgICAgICAgZWRnZXMgPSB0aGlzLmdldENvbHVtbkVkZ2VzKCk7XG5cbiAgICAgICAgZm9yICh2YXIgYyA9IDE7IGMgPCBlZGdlcy5sZW5ndGggLSAxOyBjKyspIHtcbiAgICAgICAgICAgIHdpZHRoID0gZWRnZXNbY10gLSAoZWRnZXNbY10gLSBlZGdlc1tjIC0gMV0pIC8gMjtcbiAgICAgICAgICAgIGlmIChwaXhlbFggPCB3aWR0aCkge1xuICAgICAgICAgICAgICAgIGlmIChjID4gZml4ZWRDb2x1bW5Db3VudCkge1xuICAgICAgICAgICAgICAgICAgICBjID0gYyArIHNjcm9sbExlZnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBjIC0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoYyA+IGZpeGVkQ29sdW1uQ291bnQpIHtcbiAgICAgICAgICAgIGMgPSBjICsgc2Nyb2xsTGVmdDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYyAtIDE7XG4gICAgf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AwOyBjIDwgY29sdW1uRWRnZXMubGVuZ3RoOyBjKyspIHtcbiAgICAgICAgICAgIHdpZHRoID0gY29sdW1uRWRnZXNbY107XG4gICAgICAgICAgICBpZiAocG9pbnQueCA8IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgeCA9IE1hdGgubWF4KDAsIHBvaW50LnggLSBwcmV2aW91cyAtIDIpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcHJldmlvdXMgPSB3aWR0aDtcbiAgICAgICAgfVxuICAgICAgICBjLS07XG4gICAgICAgIHByZXZpb3VzID0gMDtcbiAgICAgICAgZm9yIChyID0gMDsgciA8IHRoaXMucm93RWRnZXMubGVuZ3RoOyByKyspIHtcbiAgICAgICAgICAgIGhlaWdodCA9IHRoaXMucm93RWRnZXNbcl07XG4gICAgICAgICAgICBpZiAocG9pbnQueSA8IGhlaWdodCkge1xuICAgICAgICAgICAgICAgIHkgPSBNYXRoLm1heCgwLCBwb2ludC55IC0gcHJldmlvdXMgLSAyKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHByZXZpb3VzID0gaGVpZ2h0O1xuICAgICAgICB9XG4gICAgICAgIHItLTtcbiAgICAgICAgaWYgKHBvaW50LnggPCAwKSB7XG4gICAgICAgICAgICBjID0gLTE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHBvaW50LnkgPCAwKSB7XG4gICAgICAgICAgICByID0gLTE7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgdmlld1BvaW50ID0gdGhpcy5ncmlkLm5ld1BvaW50KGMsIHIpO1xuXG4gICAgICAgIC8vY29tcGVuc2F0ZSBpZiB3ZSBhcmUgc2Nyb2xsZWRcbiAgICAgICAgaWYgKGMgPj0gZml4ZWRDb2x1bW5Db3VudCkge1xuICAgICAgICAgICAgYyA9IGMgKyBzY3JvbGxYO1xuICAgICAgICB9XG4gICAgICAgIGlmI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ybnMge251bWJlcn0gVGhlIHJvdyB0byBnb3RvIGZvciBhIHBhZ2UgZG93bi5cbiAgICAgKi9cbiAgICBnZXRQYWdlRG93blJvdzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBoZWFkZXJSb3dzID0gdGhpcy5ncmlkLmdldEZpeGVkUm93Q291bnQoKTtcbiAgICAgICAgdmFyIHJvd051bSA9IHRoaXMuZGF0YVdpbmRvdy5jb3JuZXIueSAtIGhlYWRlclJvd3MgLSAxO1xuICAgICAgICByZXR1cm4gcm93TnVtO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge251bWJlcn0gVGhlIG51bWJlciBvZiBjb2x1bW5zLlxuICAgICAqL1xuICAgIGdldENvbHVtbkNvdW50OiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZ3JpZC5nZXRDb2x1bW5Db3VudCgpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge251bWJlcn0gVGhlIG51bWJlciBvZiByb3dzLlxuICAgICAqL1xuICAgIGdldFJvd0NvdW50OiBmdW5jdGlvbigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZ3JpZC5nZXRSb3dDb3VudCgpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge251bWJlcn0gVGhlIG51bWJlciBvZiBmaXhlZCBjb2x1bW5zLlxuICAgICAqL1xuICAgIGdldEZpeGVkQ29sdW1uQ291bnQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5ncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck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ICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihtZXNzYWdlKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlckNlbGxFcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByYXdHYyA9IGdjLmdjIHx8IGdjLCAvLyBEb24ndCBsb2cgdGhlc2UgY2FudmFzIGNhbGxzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyclkgPSByb3dFZGdlc1t5XSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJySGVpZ2h0ID0gcm93RWRnZXNbeSArIDFdIC0gZXJyWTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhd0djLnNhdmUoKTsgLy8gZGVmaW5lIGNsaXBwaW5nIHJlZ2lvblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhd0djLmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhd0djLnJlY3QoY2xpcFgsIGVyclksIGNsaXBXaWR0aCwgZXJySGVpZ2h0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdHYy5jbGlwKCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJDZWxsRXJyb3IocmF3R2MsIG1lc3NhZ2UsIGNsaXBYLCBlcnJZLCBjbGlwV2lkdGgsIGVyckhlaWdodCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdHYy5yZXN0b3JlKCk7IC8vIGRpc2NhcmQgY2xpcHBpbmcgcmVnaW9uXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIEJvdHRvbSB0b3RhbHMgcm93cy4uLlxuICAgICAgICAgICAgICAgIGZvciAoeSA9IC1iZWhhdmlvci5nZXREYXRhTW9kZWwoKS5nZXRCb3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hlaWdodCA9IHRoaXMuZ2V0Qm91bmRzKCkuaGVpZ2h0OyAvL3Jvd0hlaWdodHNbcm93SGVpZ2h0cy5sZW5ndGggLSAxXTtcblxuICAgICAgICB2YXIgZHJhd1RoZW1IID0gdGhpcy5yZXNvbHZlUHJvcGVydHkoJ2dyaWRMaW5lc0gnKTtcbiAgICAgICAgdmFyIGRyYXdUaGVtViA9IHRoaXMucmVzb2x2ZVByb3BlcnR5KCdncmlkTGluZXNWJyk7XG4gICAgICAgIHZhciBsaW5lQ29sb3IgPSB0aGlzLnJlc29sdmVQcm9wZXJ0eSgnbGluZUNvbG9yJyk7XG5cbiAgICAgICAgZ2MuYmVnaW5QYXRoKCk7XG5cbiAgICAgICAgaWYgKGRyYXdUaGVtVikge1xuICAgICAgICAgICAgZm9yIChjID0gMDsgYyA8IGNvbFdpZHRocy5sZW5ndGggKyAxOyBjKyspIHtcbiAgICAgICAgICAgICAgICB4ID0gY29sV2lkdGhzW2NdICsgMC41O1xuICAgICAgICAgICAgICAgIGdjLm1vdmVUbyh4LCAwKTtcbiAgICAgICAgICAgICAgICBnYy5saW5lVG8oeCwgdmlld0hlaWdodCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZHJhd1RoZW1IKSB7XG4gICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgcm93SGVpZ2h0cy5sZW5ndGggLSAxOyByKyspIHtcbiAgICAgICAgICAgICAgICB5ID0gcm93SGVpZ2h0c1tyXSArIDAuNTtcbiAgICAgICAgICAgICAgICBnYy5tb3ZlVG8oMCwgeSk7XG4gICAgICAgICAgICAgICAgZ2MubGluZVRvKHZpZXdXaWR0aCwgeSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEJvdHRvbSB0b3RhbHMgcm93cy4uLlxuICAgICAgICAgICAgdmFyIGJlaGF2aW9yID0gdGhpcy5ncmlkLmJlaGF2aW9yLFxuICAgICAgICAgICAgICAgIHJvd0hlaWdod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ICB0aGlzLl9wYWludENlbGwoZ2MsIGMsIHIpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIF9wYWludENlbGw6IGZ1bmN0aW9uKGdjLCBjLCByKSB7XG5cbiAgICAgICAgdmFyIGdyaWQgPSB0aGlzLmdyaWQsXG4gICAgICAgICAgICBiZWhhdmlvciA9IGdyaWQuYmVoYXZpb3IsXG4gICAgICAgICAgICBiYXNlUHJvcGVydGllcyA9IGJlaGF2aW9yLmdldENvbHVtblByb3BlcnRpZXMoYyk7XG5cbiAgICAgICAgaWYgKGJhc2VQcm9wZXJ0aWVzLmlzTnVsbCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGNvbHVtblByb3BlcnRpZXMgPSBiYXNlUHJvcGVydGllcyxcblxuICAgICAgICAgICAgaGVhZGVyUm93Q291bnQgPSBiZWhhdmlvci5nZXRIZWFkZXJSb3dDb3VudCgpLFxuICAgICAgICAgICAgaXNHcmlkUm93ID0gciA+PSBoZWFkZXJSb3dDb3VudCxcbiAgICAgICAgICAgIGlzRm9vdGVyUm93ID0gciA8IDAsXG4gICAgICAgICAgICBpc0hlYWRlclJvdyA9ICFpc0dyaWRSb3cgJiYgIWlzRm9vdGVyUm93LFxuICAgICAgICAgICAgaXNGaWx0ZXJSb3cgPSBncmlkLmlzRmlsdGVyUm93KHIpLFxuXG4gICAgICAgICAgICBoZWFkZXJDb2x1bW5Db3VudCA9IGJlaGF2aW9yLmdldEhlYWRlckNvbHVtbkNvdW50KCksXG4gICAgICAgICAgICBpc0dyaWRDb2x1bW4gPSBjID49IGhlYWRlckNvbHVtbkNvdW50LFxuICAgICAgICAgICAgaXNTaG93Um93TnVtYmVycyA9IGdyaWQuaXNTaG93Um93TnVtYmVycygpLFxuICAgICAgICAgICAgaXNIaWVyYXJjaHlDb2x1bW4gPSBncmlkLmlzSGllcmFyY2h5Q29sdW1uKGMpLFxuXG4gICAgICAgICAgICBpc1Jvd1NlbGVjd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ZXJPZiBTZWxlY3Rpb25Nb2RlbC5wcm90b3R5cGVcbiAgICAgKiBAcmV0dXJucyB7QXJyYXl9XG4gICAgICovXG4gICAgZ2V0RmxhdHRlbmVkWXM6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgcmVzdWx0ID0gW107XG4gICAgICAgIHZhciBzZXQgPSB7fTtcbiAgICAgICAgdGhpcy5zZWxlY3Rpb25zLmZvckVhY2goZnVuY3Rpb24oc2VsZWN0aW9uKSB7XG4gICAgICAgICAgICB2YXIgdG9wID0gc2VsZWN0aW9uLm9yaWdpbi55O1xuICAgICAgICAgICAgdmFyIHNpemUgPSBzZWxlY3Rpb24uZXh0ZW50LnkgKyAxO1xuICAgICAgICAgICAgZm9yICh2YXIgciA9IDA7IHIgPCBzaXplOyByKyspIHtcbiAgICAgICAgICAgICAgICB2YXIgdGkgPSByICsgdG9wO1xuICAgICAgICAgICAgICAgIGlmICghc2V0W3RpXSkge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQucHVzaCh0aSk7XG4gICAgICAgICAgICAgICAgICAgIHNldFt0aV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHJlc3VsdC5zb3J0KGZ1bmN0aW9uKHgsIHkpIHtcbiAgICAgICAgICAgIHJldHVybiB4IC0geTtcbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBTZWxlY3Rpb25Nb2RlbC5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gb2Zmc2V0XG4gICAgICovXG4gICAgc2VsZWN0Um93c0Zyb21DZWxsczogZnVuY3Rpb24ob2Zmc2V0LCBkb250Q2xlYXJSb3dTZWxlY3Rpb25zKSB7XG4gICAgICAgIG9mZnNldCA9IG9mZnNldCB8fCAwO1xuICAgICAgICBkb250Q2xlYXJSb3dTZWxlY3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92ZXJsYXkuc3R5bGUubWFyZ2luID0gJzE1cHggMzVweCAzNXB4IDE1cHgnO1xuICAgICAgICB0aGlzLm92ZXJsYXkuc3R5bGUub3BhY2l0eSA9IDA7XG4gICAgICAgIHRoaXMub3ZlcmxheS5zdHlsZS56SW5kZXggPSAxMDA7XG5cbiAgICAgICAgdGhpcy5jbG9zZVRyYW5zaXRpb24gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHRoaXMub3ZlcmxheS5zdHlsZS5vcGFjaXR5ID0gMDtcbiAgICAgICAgfTtcblxuICAgICAgICBpZiAoIXRoaXMuX2Nsb3Nlcikge1xuICAgICAgICAgICAgdGhpcy5fY2xvc2VyID0gZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgICAgIHZhciBrZXkgPSBzZWxmLmdldENoYXJGb3IoZS5rZXlDb2RlKS50b0xvd2VyQ2FzZSgpO1xuICAgICAgICAgICAgICAgIHZhciBrZXlzID0gc2VsZi5ncmlkLnJlc29sdmVQcm9wZXJ0eSgnZWRpdG9yQWN0aXZhdGlvbktleXMnKTtcbiAgICAgICAgICAgICAgICBpZiAoa2V5cy5pbmRleE9mKGtleSkgPiAtMSB8fCBlLmtleUNvZGUgPT09IDI3KSB7XG4gICAgICAgICAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgICAgICAgICAgc2VsZi5jbG9zZSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICAgICAgcmVxdWVzdEFuaW1hdGlvbkZyYW1lKGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgc2VsZi5vdmVybGF5LnN0eWxlLndlYmtpdFRyYW5zaXRpb24gPSAnb3BhY2l0eSAnICsgQU5JTUFUSU9OX1RJTUUgKyAnbXMgZWFzZS1pbic7XG4gICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgZG9jdW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigna2V5ZG93bicsIHNlbGYuX2Nsb3NlciwgZmFsc2UpO1xuICAgICAgICAgICAgICAgIHNlbGYub3ZlcmxheS5zdHlsZS5vcGFjaXR5ID0gMC45NTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcblxuICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgc2VsZi5vdmVybGF5LmZvY3VzKCk7XG4gICAgICAgIH0sIDEwMCk7XG4gICAgfSxcbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgT3ZlcmxheS5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBvcGVuIHRoZSBvdmVybGF5XG4gICAgICogIyMjIyByZXR1cm5zOiB0eXBlXG4gICAgICogQHBhcmFtIHtIeXBlcmdyaWR9IGdyaWRcbiAgICAgKi9cbiAgICBvcGVuRnJvbTogZnVuY3Rpb24ocmVjdCkge1xuICAgICAgICBpZiAodGhpcy5pc09wZW4oKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMub3Blbk5vdyA9IHRydWU7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdmFyIHN0eWxlID0gdGhpcy5vdmVybGF5LnN0eWxlO1xuICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSB0aGlzLmdyaWQucmVzb2x2ZVByb3BlcnR5KCdiYWNrZ3JvdW5kQ29sb3InKTtcblxuICAgICAgICB2YXIgYm91bmRzID0gdGhpcy5ncmlkLmRpdi5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKSxcbiAgICAgICAgICAgIG1hcmdpbnMgPSByZWN0LnkgKyAncHggJyArXG4gICAgICAgICAgICAgICAgKGJvdW5kcy53aWR0aCAtIChyZWN0LnggKyByZWN0LndpZHRoKSkgKyAncHggJyArXG4gICAgICAgICAgICAgICAgKGJvdW5kcy5oZWlnaHQgLSAocmVjdC55ICsgcmVjdC5oZWlnaHQpKSArICdweCAnICtcbiAgICAgICAgICAgICAgICByZWN0LnggKyAncHgnO1xuXG4gICAgICAgIHN0eWxlLndlYmtpdFRyYW5zaXRpb24gPSAnJztcblxuICAgICAgICBzdHlsZS50b3AgPSBzdHlsZS5yaWdodCA9IHN0eWxlLmJvdHRvbSA9IHN0eWxlLmxlZnQgPSAwO1xuXG4gICAgICAgIHN0eWxlLm1hcmdpbiA9IG1hcmdpbnM7XG4gICAgICAgIHN0eWxlLnpJbmRleCA9IDEwMDtcbiAgICAgICAgc3R5bGUub3BhY2l0eSA9IDE7XG5cbiAgICAgICAgdGhpcy5jbG9zZVRyYW5zaXRpb24gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHN0eWxlLm1hcmdpbiA9IG1hcmdpbnM7XG4gICAgICAgIH07XG5cbiAgICAgICAgaWYgKCF0aGlzLl9jbG9zZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX2Nsb3NlciA9IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gc2VsZi5nZXRDaGFyRm9yKGUua2V5Q29kZSkudG9Mb3dlckNhc2UoKTtcbiAgICAgICAgICAgICAgICB2YXIga2V5cyA9IHNlbGYuZ3JpZC5yZXNvbHZlUHJvcGVydHkoJ2VkaXRvckFjdGl2YXRpb25LZXlzJyk7XG4gICAgICAgICAgICAgICAgaWYgKGtleXMuaW5kZXhPZihrZXkpID4gLTEgfHwgZS5rZXlDb2RlID09PSAyNykge1xuICAgICAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgLy9ncmlkLnNldEZvY3VzYWJsZShmYWxzZSk7XG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZSh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B0aFN0cmluZyA9ICcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICc7XG5cbiAgICBmdW5jdGlvbiBEYXRhTm9kZUdyb3VwKGtleSkge1xuICAgICAgICBEYXRhTm9kZUJhc2UuY2FsbCh0aGlzLCBrZXkpO1xuICAgICAgICB0aGlzLmNoaWxkcmVuID0gbmV3IE1hcCgpO1xuICAgIH1cblxuICAgIERhdGFOb2RlR3JvdXAucHJvdG90eXBlID0gT2JqZWN0LmNyZWF0ZShEYXRhTm9kZUJhc2UucHJvdG90eXBlKTtcblxuICAgIERhdGFOb2RlR3JvdXAucHJvdG90eXBlLnBydW5lID0gZnVuY3Rpb24oZGVwdGgpIHtcbiAgICAgICAgdGhpcy5kZXB0aCA9IGRlcHRoO1xuICAgICAgICB0aGlzLmNoaWxkcmVuID0gdGhpcy5jaGlsZHJlbi52YWx1ZXM7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdGhpcy5jaGlsZHJlbi5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgdmFyIGNoaWxkID0gdGhpcy5jaGlsZHJlbltpXTtcbiAgICAgICAgICAgIGNoaWxkLnBydW5lKHRoaXMuZGVwdGggKyAxKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmRhdGFbMF0gPSB0aGlzLmNvbXB1dGVEZXB0aFN0cmluZygpO1xuICAgIH07XG5cbiAgICBEYXRhTm9kZUdyb3VwLnByb3RvdHlwZS5jb21wdXRlRGVwdGhTdHJpbmcgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIGljb24gPSBFeHBhbmRlZE1hcFt0aGlzLmV4cGFuZGVkICsgJyddO1xuICAgICAgICB2YXIgc3RyaW5nID0gZGVwdGhTdHJpbmcuc3Vic3RyaW5nKDAsIHRoaXMuZGVwdGggKiAzKSArIGljb24gKyAnICcgKyB0aGlzLmxhYmVsO1xuICAgICAgIC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ubGVuZ3RoID0gMDtcbiAgICB9O1xuXG4gICAgRGF0YVNvdXJjZUZpbHRlci5wcm90b3R5cGUuYXBwbHlBbGwgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgaWYgKHRoaXMuZmlsdGVycy5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuaW5kZXhlcy5sZW5ndGggPSAwO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBpbmRleGVzID0gdGhpcy5pbmRleGVzO1xuICAgICAgICBpbmRleGVzLmxlbmd0aCA9IDA7XG4gICAgICAgIHZhciBjb3VudCA9IHRoaXMuZGF0YVNvdXJjZS5nZXRSb3dDb3VudCgpO1xuICAgICAgICBmb3IgKHZhciByID0gMDsgciA8IGNvdW50OyByKyspIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmFwcGx5RmlsdGVyc1RvKHIpKSB7XG4gICAgICAgICAgICAgICAgaW5kZXhlcy5wdXNoKHIpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIERhdGFTb3VyY2VGaWx0ZXIucHJvdG90eXBlLmFwcGx5RmlsdGVyc1RvID0gZnVuY3Rpb24ocikge1xuICAgICAgICB2YXIgZmlsdGVycyA9IHRoaXMuZmlsdGVycztcbiAgICAgICAgdmFyIGlzRmlsdGVyZWQgPSB0cnVlO1xuICAgICAgICBmb3IgKHZhciBmID0gMDsgZiA8IGZpbHRlcnMubGVuZ3RoOyBmKyspIHtcbiAgICAgICAgICAgIHZhciBmaWx0ZXIgPSBmaWx0ZXJzW2ZdO1xuICAgICAgICAgICAgdmFyIHJvd09iamVjdCA9IHRoaXMuZGF0YVNvdXJjZS5nZXRSb3cocik7XG4gICAgICAgICAgICBpc0ZpbHRlcmVkID0gaXNGaWx0ZXJlZCAmJiBmaWx0ZXIodGhpcy5kYXRhU291cmNlLmdldFZhbHVlKGZpbHRlci5jb2x1bW5JbmRleCwgciksIHJvd09iamVjdC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RhID0gZnVuY3Rpb24oYXJyYXlPZlVuaWZvcm1PYmplY3RzKSB7XG4gICAgICAgIHRoaXMuZGF0YSA9IGFycmF5T2ZVbmlmb3JtT2JqZWN0cztcbiAgICB9O1xuXG4gICAgcmV0dXJuIEpTRGF0YVNvdXJjZTtcblxufSkoKTtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIHN0YWJsZVNvcnQgPSByZXF1aXJlKCcuL3N0YWJsZVNvcnQuanMnKTtcbnZhciBNYXAgPSByZXF1aXJlKCcuL01hcC5qcycpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IChmdW5jdGlvbigpIHtcblxuICAgIHJldHVybiB7XG4gICAgICAgIHN0YWJsZVNvcnQ6IHN0YWJsZVNvcnQsXG4gICAgICAgIE1hcDogTWFwXG4gICAgfTtcblxufSkoKTtcbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSAoZnVuY3Rpb24oKSB7XG5cbiAgICByZXR1cm4ge1xuXG4gICAgICAgIGNvdW50OiBmdW5jdGlvbigpIHsgLyogY29sdW1JbmRleCAqL1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIHJldHVybiByb3dzO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSxcblxuICAgICAgICBzdW06IGZ1bmN0aW9uKGNvbHVtSW5kZXgpIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbihncm91cCkge1xuICAgICAgICAgICAgICAgIHZhciBzdW0gPSAwO1xuICAgICAgICAgICAgICAgIHZhciByb3dzID0gZ3JvdXAuZ2V0Um93Q291bnQoKTtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciByID0gMDsgciA8IHJvd3M7IHIrKykge1xuICAgICAgICAgICAgICAgICAgICBzdW0gPSBzdW0gKyBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHN1bTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0sXG5cbiAgICAgICAgbWluOiBmdW5jdGlvbihjb2x1bUluZGV4KSB7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24oZ3JvdXApIHtcbiAgICAgICAgICAgICAgICB2YXIgbWluID0gSW5maW5pdHk7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIHIgPSAwOyByIDwgcm93czsgcisrKSB7XG4gICAgICAgICAgICAgICAgICAgIG1pbiA9IE1hdGgubWluKG1pbiwgZ3JvdXAuZ2V0VmFsdWUoY29sdW1JbmRleCwgcikpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gbWluO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSxcblxuXG4gICAgICAgIG1heDogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIG1heCA9IC1JbmZpbml0eTtcbiAgICAgICAgICAgICAgICB2YXIgcm93cyA9IGdyb3VwLmdldFJvd0NvdW50KCk7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgciA9IDA7IHIgPCByb3dzOyByKyspIHtcbiAgICAgICAgICAgICAgICAgICAgbWF4ID0gTWF0aC5tYXgobWF4LCBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBtYXg7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuXG4gICAgICAgIGF2ZzogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN1bSA9IDA7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIHIgPSAwOyByIDwgcm93czsgcisrKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1bSA9IHN1bSArIGdyb3VwLmdldFZhbHVlKGNvbHVtSW5kZXgsIHIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gc3VtIC8gcm93cztcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0sXG5cbiAgICAgICAgZmlyc3Q6IGZ1bmN0aW9uKGNvbHVtSW5kZXgpIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbihncm91cCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCAwKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0sXG5cbiAgICAgICAgbGFzdDogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIHJldHVybiBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByb3dzIC0gMSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuXG4gICAgICAgIHN0ZGRldjogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHI7XG4gICAgICAgICAgICAgICAgdmFyIHN1bSA9IDA7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIGZvciAociA9IDA7IHIgPCByb3dzOyByKyspIHtcbiAgICAgICAgICAgICAgICAgICAgc3VtID0gc3VtICsgZ3JvdXAuZ2V0VmFsdWUoY29sdW1JbmRleCwgcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBtZWFuID0gc3VtIC8gcm93cztcbiAgICAgICAgICAgICAgICB2YXIgdmFyaWFuY2UgPSAwO1xuICAgICAgICAgICAgICAgIGZvciAociA9IDA7IHIgPCByb3dzOyByKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRldiA9IChncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByKSAtIG1lYW4pO1xuICAgICAgICAgICAgICAgICAgICB2YXJpYW5jZSA9IHZhcmlhbmNlICsgKGRldiAqIGRldik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBzdGRkZXYgPSBNYXRoLnNxcnQodmFyaWFuY2UgLyByb3dzKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gc3RkZGV2O1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgIH07XG5cbn0pKCk7XG4iLCIndXNlIHN0cmljdCc7XG5cbnZhciBKU0RhdGFTb3VyY2UgPSByZXF1aXJlKCcuL0pTRGF0YVNvdXJjZScpO1xudmFyIERhdGFTb3VyY2VTb3J0ZXIgPSByZXF1aXJlKCcuL0RhdGFTb3VyY2VTb3J0ZXInKTtcbnZhciBEYXRhU291cmNlU29ydGVyQ29tcG9zaXRlID0gcmVxdWlyZSgnLi9EYXRhU291cmNlU29ydGVyQ29tcG9zaXRlJyk7XG52YXIgRGF0YVNvdXJjZUZpbHRlciA9IHJlcXVpcmUoJy4vRGF0YVNvdXJjZUZpbHRlcicpO1xudmFyIERhdGFTb3VyY2VHbG9iYWxGaWx0ZXIgPSByZXF1aXJlKCcuL0RhdGFTb3VyY2VHbG9iYWxGaWx0ZXInKTtcbnZhciBEYXRhU291cmNlQWdncmVnYXRvciA9IHJlcXVp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pO3JldHVybiBzfSkiLCIndXNlIHN0cmljdCc7XG5cbnZhciBjc3NJbmplY3RvciA9IHJlcXVpcmUoJ2Nzcy1pbmplY3RvcicpO1xuXG52YXIgc3R5bGVzaGVldHMgPSB7XG4gICAgZ3JpZDogW1xuICAgICAgICAnZGl2I2dyaWQtY29udGFpbmVyIHsnLFxuICAgICAgICAnICAgIHBvc2l0aW9uOiByZWxhdGl2ZTsnLFxuICAgICAgICAnICAgIGRpc3BsYXk6IGlubGluZS1ibG9jazsnLFxuICAgICAgICAnICAgIC13ZWJraXQtdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICAtbW96LXVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgLW1zLXVzZXItc2VsZWN0OiBub25lOycsXG4gICAgICAgICcgICAgLW8tdXNlci1zZWxlY3Q6IG5vbmU7JyxcbiAgICAgICAgJyAgICB1c2VyLXNlbGVjdDogbm9uZTsnLFxuICAgICAgICAnICAgIG92ZXJmbG93OiBoaWRkZW47IH0nLFxuICAgICAgICAndmlzaWJsZSB7IG9wYWNpdHk6IDAuNzU7IH0nLFxuICAgICAgICAnaGlkZGVuIHsgb3BhY2l0eTogMC4wOyB9JyxcbiAgICAgICAgJ2VkaXRvciB7JyxcbiAgICAgICAgJyAgICBwb3NpdGlvbjogYWJzb2x1dGU7JyxcbiAgICAgICAgJyAgICBkaXNwbGF5OiBub25lOycsXG4gICAgICAgICcgICAgYm9yZGVyOiBzb2xpZCAycHggYmxhY2s7JyxcbiAgICAgICAgJyAgICBvdXRsaW5lOiAwOycsXG4gICAgICAgICcgICAgcGFkZGluZzogMDsnLFxuICAgICAgICAnICAgIHotaW5kZXg6IDEwMDA7IH0nXG4gICAgXSxcbiAgICAnbGlzdC1kcmFnb24nOiBbXG4gICAgICAgICdkaXYuZHJhZ29uLWxpc3QsIGxpLmRyYWdvbi1wb3AgeycsXG4gICAgICAgICcgICAgZm9udC1mYW1pbHk6IFJvYm90bywgc2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HJlYWR5IGNhbGxlZCBhYm92ZTsgbm90IG5lZWRlZCBpbiBwcm90b3R5cGVcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnYWxpYXNlcyc6XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGFsaWFzIGluIHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUuaGFzT3duUHJvcGVydHkoYWxpYXMpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUFsaWFzKHZhbHVlW2FsaWFzXSwgYWxpYXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdzdHJpbmcnICYmIHZhbHVlWzBdID09PSAnIycpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VBbGlhcyh2YWx1ZSwga2V5LnN1YnN0cigxKSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcm90b3R5cGVba2V5XSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICByZXR1cm4gQ29uc3RydWN0b3I7XG5cbiAgICBmdW5jdGlvbiBtYWtlQWxpYXModmFsdWUsIGtleSkgeyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXNoYWRvd1xuICAgICAgICBwcm90b3R5cGVba2V5XSA9IHByb3RvdHlwZUFkZGl0aW9uc1t2YWx1ZV07XG4gICAgfVxufVxuXG5leHRlbmQuQmFzZSA9IGZ1bmN0aW9uICgpIHt9O1xuZXh0ZW5kLkJhc2UuZXh0ZW5kID0gZXh0Z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b2RlLnNldFdhcm5pbmdDbGFzcyhlbCk7XG4gICAgICAgICAgICBjb250YWluZXIuYXBwZW5kQ2hpbGQoZWwpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGVsO1xuICAgIH0sXG5cbiAgICBsb2FkOiBmdW5jdGlvbihzdGF0ZSkge1xuICAgICAgICBpZiAoc3RhdGUpIHtcbiAgICAgICAgICAgIHZhciB2YWx1ZSwgZWwsIGksIGIsIHNlbGVjdGVkLCBub3RlcyA9IFtdO1xuICAgICAgICAgICAgZm9yICh2YXIga2V5IGluIHN0YXRlKSB7XG4gICAgICAgICAgICAgICAgaWYgKGtleSAhPT0gJ2ZpZWxkcycgJiYga2V5ICE9PSAnZWRpdG9yJykge1xuICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHN0YXRlW2tleV07XG4gICAgICAgICAgICAgICAgICAgIGVsID0gdGhpcy5jb250cm9sc1trZXldO1xuICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGVsLnR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ2NoZWNrYm94JzpcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ3JhZGlvJzpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbCA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3JBbGwoJ2lucHV0W25hbWU9XFwnJyArIGVsLm5hbWUgKyAnXFwnXScpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBlbC5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbFtpXS5jaGVja2VkID0gdmFsdWUuaW5kZXhPZihlbFtpXS52YWx1ZSkgPj0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdzZWxlY3QtbXVsdGlwbGUnOlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsID0gZWwub3B0aW9ucztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBiID0gZmFsc2U7IGkgPCBlbC5sZW5ndGg7IGkrKywgYiA9IGIgfHwgc2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0ZWQgPSB2YWx1ZS5pbmRleE9mKGVsW2ldLnZhbHVlKSA+PSAwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbFtpXS5zZWxlY3RlZCA9IHNlbGVjdGVkO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBGaWx0ZXJOb2RlLnNldFdhcm5pbmdDbGFzcyhlbCwgYik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsLnZhbHVlID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFGaWx0ZXJOb2RlLnNldFdhcm5pbmdDbGFzcyhlbCkgJiYgZWwudmFsdWUgIT09IHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vdGVzLnB1c2goeyBrZXk6IGtleSwgdmFsdWU6IHZhbHVlIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChub3Rlcy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICB2YXIgbXVsdGlwbGUgPSBub3Rlcy5sZW5ndGggPiAxLFxuICAgICAgICAgICAgICAgICAgICBmb290bm90ZXMgPSB0ZW1wbGF0ZShtdWx0aXBsZSA/ICdub3RlcycgOiAnbm90ZScpLFxuICAgICAgICAgICAgICAgICAgICBpbm5lciA9IGZvb3Rub3Rlcy5sYXN0RWxlbWVudENoaWxkO1xuICAgICAgICAgICAgICAgIG5vdGVzLmZvckVhY2goZnVuY3Rpb24obm90ZSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZm9vdG5vdGUgPSBtdWx0aXBsZSA/IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2xpJykgOiBpbm5lcjtcbiAgICAgICAgICAgICAgICAgICAgbm90ZSA9IHRlbXBsYXRlKCdvcHRpb25NaXNzaW5nJywgbm90ZS5rZXksIG5vdGUudmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB3aGlsZSAobm90ZS5sZW5ndGgpIHsgZm9vdG5vdGUuYXBwZW5kQ2hpbGQobm90ZVswXSk7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKG11bHRpcGxlKSB7IGlubmVyLmFwcGVuZENoaWxkKGZvb3Rub3RlKTsgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGVsLnBhcmVudE5vZGUucmVwbGFjZUNoaWxkKGZvb3Rub3RlcywgZWwucGFyZW50Tm9kZS5sYXN0RWxlbWVudENoaWxkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAcHJvcGVydHkge2NvbnZlcnRlcn0gbnVtYmVyXG4gICAgICogQHByb3BlcnR5IHtjb252ZXJ0ZXJ9IGRhdGVcbiAgICAgKi9cbiAgICBjb252ZXJ0ZXJzOiB7XG4gICAgICAgIG51bWJlcjogbnVtYmVyQ29udmVydGVyLFxuICAgICAgICBpbnQ6IG51bWJlckNvbnZlcnRlciwgLy8gcHNldWRvLXR5cGU6IHJlYWxseSBqdXN0IGEgTnVtYmVyXG4gICAgICAgIGZsb2F0OiBudW1iZXJDb252ZXJ0ZXIsIC8vIHBzZXVkby10eXBlOiByZWFsbHkganVzdC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VsZC50eXBlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnZlcnRlciA9IHRoaXMuY29udmVydGVyc1tmaWVsZC50eXBlXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICBwOiBmdW5jdGlvbihkYXRhUm93KSB7IHJldHVybiBkYXRhUm93W3RoaXMuY29sdW1uXTsgfSxcbiAgICBxOiBmdW5jdGlvbigpIHsgcmV0dXJuIHRoaXMudmFsdWU7IH0sXG5cbiAgICB0ZXN0OiBmdW5jdGlvbihkYXRhUm93KSB7XG4gICAgICAgIHZhciBwLCBxLCAvLyB1bnR5cGVkIHZlcnNpb25zIG9mIGFyZ3NcbiAgICAgICAgICAgIFAsIFEsIC8vIHR5cGVkIHZlcnNpb25zIG9mIHAgYW5kIHFcbiAgICAgICAgICAgIGNvbnZlcnQ7XG5cbiAgICAgICAgcmV0dXJuIChwID0gdGhpcy5wKGRhdGFSb3cpKSA9PT0gdW5kZWZpbmVkIHx8IChxID0gdGhpcy5xKGRhdGFSb3cpKSA9PT0gdW5kZWZpbmVkXG4gICAgICAgICAgICA/IGZhbHNlXG4gICAgICAgICAgICA6IChcbiAgICAgICAgICAgICAgICAoY29udmVydCA9IHRoaXMuY29udmVydGVyKSAmJlxuICAgICAgICAgICAgICAgICFjb252ZXJ0Lm5vdChQID0gY29udmVydC50byhwKSkgJiZcbiAgICAgICAgICAgICAgICAhY29udmVydC5ub3QoUSA9IGNvbnZlcnQudG8ocSkpXG4gICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgPyB0aGlzLm9wLnRlc3QoUCwgUSlcbiAgICAgICAgICAgICAgICA6IHRoaXMub3AudGVzdChwLCBxKTtcbiAgICB9LFxuXG4gICAgdG9KU09OOiBmdW5jdGlvbihvcHRpb25zKSB7IC8vIGVzbGludC1kaXNhYmxlLWxpbmUgbm8tdW51c2VkLXZ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SB7XG4gICAgICAgICAgICBvcHRpb25zID0gb3B0aW9ucy5zbGljZSgpLnNvcnQoZmllbGRDb21wYXJhdG9yKTsgLy8gY2xvbmUgaXQgYW5kIHNvcnQgdGhlIGNsb25lXG4gICAgICAgIH1cblxuICAgICAgICBvcHRpb25zLmZvckVhY2goZnVuY3Rpb24ob3B0aW9uKSB7XG4gICAgICAgICAgICBpZiAoKG9wdGlvbi5vcHRpb25zIHx8IG9wdGlvbikgaW5zdGFuY2VvZiBBcnJheSkge1xuICAgICAgICAgICAgICAgIHZhciBvcHRncm91cCA9IGFkZE9wdGlvbnMoJ29wdGdyb3VwJywgb3B0aW9uLm9wdGlvbnMgfHwgb3B0aW9uLCBvcHRpb24ubGFiZWwpO1xuICAgICAgICAgICAgICAgIGVsLmFkZChvcHRncm91cCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHZhciBuZXdFbGVtZW50ID0gdHlwZW9mIG9wdGlvbiAhPT0gJ29iamVjdCdcbiAgICAgICAgICAgICAgICAgICAgPyBuZXcgT3B0aW9uKG9wdGlvbilcbiAgICAgICAgICAgICAgICAgICAgOiBuZXcgT3B0aW9uKFxuICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uLmFsaWFzIHx8IG9wdGlvbi5uYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uLm5hbWUgfHwgb3B0aW9uLmFsaWFzXG4gICAgICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgICAgYWRkLmNhbGwoZWwsIG5ld0VsZW1lbnQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICB9IGVsc2Uge1xuICAgICAgICBlbC50eXBlID0gJ3RleHQnO1xuICAgIH1cblxuICAgIHJldHVybiBlbDtcbn1cblxuZnVuY3Rpb24gZmllbGRDb21wYXJhdG9yKGEsIGIpIHtcbiAgICBhID0gYS5hbGlhcyB8fCBhLm5hbWUgfHwgYS5sYWJlbCB8fCBhO1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b2N1bWVudC5jcmVhdGVFbGVtZW50KCdkaXYnKTtcblxuICAgIGJhci5jbGFzc0xpc3QuYWRkKCdmaW5iYXItdmVydGljYWwnKTtcblxuICAgIGJhci5hcHBlbmRDaGlsZCh0aHVtYik7XG4gICAgaWYgKHRoaXMucGFnaW5nKSB7XG4gICAgICAgIGJhci5vbmNsaWNrID0gYm91bmQub25jbGljaztcbiAgICB9XG4gICAgdGhpcy5iYXIgPSBiYXI7XG5cbiAgICBvcHRpb25zID0gb3B0aW9ucyB8fCB7fTtcblxuICAgIC8vIHByZXNldHNcbiAgICB0aGlzLm9yaWVudGF0aW9uID0gJ3ZlcnRpY2FsJztcbiAgICB0aGlzLl9taW4gPSB0aGlzLl9pbmRleCA9IDA7XG4gICAgdGhpcy5fbWF4ID0gMTAwO1xuXG4gICAgLy8gb3B0aW9uc1xuICAgIGZvciAodmFyIGtleSBpbiBvcHRpb25zKSB7XG4gICAgICAgIGlmIChvcHRpb25zLmhhc093blByb3BlcnR5KGtleSkpIHtcbiAgICAgICAgICAgIHZhciBvcHRpb24gPSBvcHRpb25zW2tleV07XG4gICAgICAgICAgICBzd2l0Y2ggKGtleSkge1xuXG4gICAgICAgICAgICBjYXNlICdpbmRleCc6XG4gICAgICAgICAgICAgICAgdGhpcy5faW5kZXggPSBvcHRpb247XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgIGNhc2UgJ3JhbmdlJzpcbiAgICAgICAgICAgICAgICB2YWxpZFJhbmdlKG9wdGlvbik7XG4gICAgICAgICAgICAgICAgdGhpcy5fbWluID0gb3B0aW9uLm1pbjtcbiAgICAgICAgICAgICAgICB0aGlzLl9tYXggPSBvcHRpb24ubWF4O1xuICAgICAgICAgICAgICAgIHRoaXMuY29udGVudFNpemUgPSBvcHRpb24ubWF4IC0gb3B0aW9uLm1pbiArIDE7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgIC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iBAdHlwZSB7ZmluYmFyU3R5bGVzfVxuICAgICAqIEBtZW1iZXJPZiBGaW5CYXIucHJvdG90eXBlXG4gICAgICovXG4gICAgc2V0IHN0eWxlKHN0eWxlcykge1xuICAgICAgICB2YXIga2V5cyA9IE9iamVjdC5rZXlzKHN0eWxlcyA9IGV4dGVuZCh7fSwgc3R5bGVzLCB0aGlzLl9hdXhTdHlsZXMpKTtcblxuICAgICAgICBpZiAoa2V5cy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHZhciBiYXIgPSB0aGlzLmJhcixcbiAgICAgICAgICAgICAgICBiYXJSZWN0ID0gYmFyLmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpLFxuICAgICAgICAgICAgICAgIGNvbnRhaW5lciA9IHRoaXMuY29udGFpbmVyIHx8IGJhci5wYXJlbnRFbGVtZW50LFxuICAgICAgICAgICAgICAgIGNvbnRhaW5lclJlY3QgPSBjb250YWluZXIuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCksXG4gICAgICAgICAgICAgICAgb2ggPSB0aGlzLm9oO1xuXG4gICAgICAgICAgICAvLyBCZWZvcmUgYXBwbHlpbmcgbmV3IHN0eWxlcywgcmV2ZXJ0IGFsbCBzdHlsZXMgdG8gdmFsdWVzIGluaGVyaXRlZCBmcm9tIHN0eWxlc2hlZXRzXG4gICAgICAgICAgICBiYXIucmVtb3ZlQXR0cmlidXRlKCdzdHlsZScpO1xuXG4gICAgICAgICAgICBrZXlzLmZvckVhY2goZnVuY3Rpb24gKGtleSkge1xuICAgICAgICAgICAgICAgIHZhciB2YWwgPSBzdHlsZXNba2V5XTtcblxuICAgICAgICAgICAgICAgIGlmIChrZXkgaW4gb2gpIHtcbiAgICAgICAgICAgICAgICAgICAga2V5ID0gb2hba2V5XTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBpZiAoIWlzTmFOKE51bWJlcih2YWwpKSkge1xuICAgICAgICAgICAgICAgICAgICB2YWwgPSAodmFsIHx8IDApICsgJ3B4JztcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKC8lJC8udGVzdCh2YWwpKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIFdoZW4gYmFyIHNpemUgZ2l2ZW4gYXMgcGVyY2VudGFnZSBvZiBjb250YWluZXIsIGlmIGJhciBoYXMgbWFyZ2lucywgcmVzdGF0ZSBzaXplIGluIHBpeGVscyBsZXNzIG1hcmdpbnMuXG4gICAgICAgICAgICAgICAgICAgIC8vIChJZiBsZWZ0IGFzIHBlcmNlbnRhZ2UsIENTUydzIGNhbGN1bGF0aW9uIHdpbGwgbm90IGV4Y2x1ZGUgbWFyZ2lucy4pXG4gICAgICAgICAgICAgICAgICAgIHZhciBvcmllbnRlZCA9IGF4aXNba2V5XSxcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hcmdpbnMgPSBiYXJSZWN0W29yaWVudGVkLm1hcmdpbkxlYWRpbmddICsgYmFyUmVjdFtvcmllbnRlZC5tYXJnaW5UcmFpbGluZ107XG4gICAgICAgICAgICAgICAgICAgIGlmIChtYXJnaW5zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YWwgPSBwYXJzZUludCh2YWwsIDEwKSAvIDEwMCAqIGNvbnRhaW5lclJlY3Rbb3JpZW50ZWQuc2l6ZV0gLSBtYXJnaW5zICsgJ3B4JztcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGJhci5zdHlsZVtrZXldID0gdmFsO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQHJlYWRvbmx5XG4gICAgICogQG5hbWUgcGFnaW5nXG4gICAgICogQHN1bW1hcnkgRW5hYmxlIHBhZ2UgdXAvZG4gY2xpY2tzLlxuICAgICAqIEBkZXNjIFNldCBieSB0aGUgY29uc3RydWN0b3IuIFNlZSB0aGUgc2ltaWxhcmx5IG5hbWVkIHByb3BlcnR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nRlbnQpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5vbmNoYW5nZSkge1xuICAgICAgICAgICAgICAgIHRoaXMub25jaGFuZ2UgPSB0aGlzLnNjcm9sbFJlYWxDb250ZW50O1xuICAgICAgICAgICAgICAgIHRoaXMuY29udGVudFNpemUgPSB0aGlzLmNvbnRlbnRbdGhpcy5vaC5zaXplXTtcbiAgICAgICAgICAgICAgICB0aGlzLl9taW4gPSAwO1xuICAgICAgICAgICAgICAgIHRoaXMuX21heCA9IHRoaXMuY29udGVudFNpemUgLSAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLm9uY2hhbmdlID09PSB0aGlzLnNjcm9sbFJlYWxDb250ZW50KSB7XG4gICAgICAgICAgICB0aGlzLmNvbnRhaW5lclNpemUgPSBjb250YWluZXJSZWN0W3RoaXMub2guc2l6ZV07XG4gICAgICAgICAgICB0aGlzLmluY3JlbWVudCA9IHRoaXMuY29udGFpbmVyU2l6ZSAvICh0aGlzLmNvbnRlbnRTaXplIC0gdGhpcy5jb250YWluZXJTaXplKSAqICh0aGlzLl9tYXggLSB0aGlzLl9taW4pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5jb250YWluZXJTaXplID0gMTtcbiAgICAgICAgICAgIHRoaXMuaW5jcmVtZW50ID0gaW5jcmVtZW50IHx8IHRoaXMuaW5jcmVtZW50O1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGluZGV4ID0gdGhpcy5pbmRleDtcbiAgICAgICAgdGhpcy50ZXN0UGFuZWxJdGVtID0gdGhpcy50ZXN0UGFuZWxJdGVtIHx8IHRoaXMuX2FkZFRlc3RQYW5lbEl0ZW0oKTtcbiAgICAgICAgdGhpcy5fc2V0VGh1bWJTaXplKCk7XG4gICAgICAgIHRoaXMuaW5kZXggPSBpbmRleDtcblxuICAgICAgICBpZiAodGhpcy5kZWx0YVByb3AgIT09IG51bGwpIHtcbiAgICAgICAgICAg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ScsXG4gICAgICAgIGF4aXM6ICAgICAgICAgICAncGFnZVknLFxuICAgICAgICBzaXplOiAgICAgICAgICAgJ2hlaWdodCcsXG4gICAgICAgIG91dHNpZGU6ICAgICAgICAncmlnaHQnLFxuICAgICAgICBpbnNpZGU6ICAgICAgICAgJ2xlZnQnLFxuICAgICAgICBsZWFkaW5nOiAgICAgICAgJ3RvcCcsXG4gICAgICAgIHRyYWlsaW5nOiAgICAgICAnYm90dG9tJyxcbiAgICAgICAgbWFyZ2luTGVhZGluZzogICdtYXJnaW5Ub3AnLFxuICAgICAgICBtYXJnaW5UcmFpbGluZzogJ21hcmdpbkJvdHRvbScsXG4gICAgICAgIHRoaWNrbmVzczogICAgICAnd2lkdGgnLFxuICAgICAgICBkZWx0YTogICAgICAgICAgJ2RlbHRhWSdcbiAgICB9LFxuICAgIGhvcml6b250YWw6IHtcbiAgICAgICAgY29vcmRpbmF0ZTogICAgICdjbGllbnRYJyxcbiAgICAgICAgYXhpczogICAgICAgICAgICdwYWdlWCcsXG4gICAgICAgIHNpemU6ICAgICAgICAgICAnd2lkdGgnLFxuICAgICAgICBvdXRzaWRlOiAgICAgICAgJ2JvdHRvbScsXG4gICAgICAgIGluc2lkZTogICAgICAgICAndG9wJyxcbiAgICAgICAgbGVhZGluZzogICAgICAgICdsZWZ0JyxcbiAgICAgICAgdHJhaWxpbmc6ICAgICAgICdyaWdodCcsXG4gICAgICAgIG1hcmdpbkxlYWRpbmc6ICAnbWFyZ2luTGVmdCcsXG4gICAgICAgIG1hcmdpblRyYWlsaW5nOiAnbWFyZ2luUmlnaHQnLFxuICAgICAgICB0aGlja25lc3M6ICAgICAgJ2hlaWdodCcsXG4gICAgICAgIGRlbHRhOiAgICAgICAgICAnZGVsdGFYJ1xuICAgIH1cbn07XG5cbnZhciBheGlzID0ge1xuICAgIHRvcDogICAgJ3ZlcnRpY2FsJyxcbiAgICBib3R0b206ICd2ZXJ0aWNhbCcsXG4gICAgaGVpZ2h0OiAndmVydGljYWwn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xuICAgICAgICByZXR1cm4gZnBzID8gcGFyc2VJbnQoZnBzKSA6IDA7XG4gICAgfSxcblxuICAgIHRpY2tQYWludDogZnVuY3Rpb24obm93KSB7XG4gICAgICAgIHZhciBmcHMgPSB0aGlzLmdldEZQUygpO1xuICAgICAgICBpZiAoZnBzID09PSAwKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGludGVydmFsID0gMTAwMCAvIGZwcztcblxuICAgICAgICB2YXIgZWxhcHNlZCA9IG5vdyAtIHRoaXMubGFzdFJlcGFpbnRUaW1lO1xuICAgICAgICBpZiAoZWxhcHNlZCA+IGludGVydmFsICYmIHRoaXMuZGlydHkpIHtcbiAgICAgICAgICAgIHRoaXMubGFzdFJlcGFpbnRUaW1lID0gbm93IC0gKGVsYXBzZWQgJSBpbnRlcnZhbCk7XG4gICAgICAgICAgICB0aGlzLnBhaW50Tm93KCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgYmVnaW5QYWludGluZzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdGhpcy5kaXJ0eSA9IHRydWU7XG4gICAgICAgIHRoaXMudGlja1BhaW50ZXIgPSBmdW5jdGlvbihub3cpIHtcbiAgICAgICAgICAgIHNlbGYudGlja1BhaW50KG5vdyk7XG4gICAgICAgIH07XG4gICAgICAgIHBhaW50YWJsZXMucHVzaCh0aGlzKTtcbiAgICB9LFxuXG4gICAgc3RvcFBhaW50aW5nOiBmdW5jdGlvbigpIHtcbiAgICAgICAgcGFpbnRhYmxlcy5zcGxpY2UocGFpbnRhYmxlcy5pbmRleE9mKHRoaXMpLCAxKTtcbiAgICB9LFxuXG4gICAgYmVnaW5SZXNpemluZzogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdGhpcy50aWNrUmVzaXplciA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgc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gICB0aGlzLnJlcGVhdEtleVN0YXJ0VGltZSA9IERhdGUubm93KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnJlcGVhdEtleSA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLnJlcGVhdEtleUNvdW50ID0gMDtcbiAgICAgICAgICAgIHRoaXMucmVwZWF0S2V5U3RhcnRUaW1lID0gMDtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5jdXJyZW50S2V5cy5pbmRleE9mKGtleUNoYXIpID09PSAtMSkge1xuICAgICAgICAgICAgdGhpcy5jdXJyZW50S2V5cy5wdXNoKGtleUNoYXIpO1xuICAgICAgICB9XG4gICAgICAgIC8vY29uc29sZS5sb2coa2V5Q2hhciwgZS5rZXlDb2RlKTtcbiAgICAgICAgdGhpcy5kaXNwYXRjaE5ld0V2ZW50KGUsICdmaW4tY2FudmFzLWtleWRvd24nLCB7XG4gICAgICAgICAgICBhbHQ6IGUuYWx0S2V5LFxuICAgICAgICAgICAgY3RybDogZS5jdHJsS2V5LFxuICAgICAgICAgICAgY2hhcjoga2V5Q2hhcixcbiAgICAgICAgICAgIGNvZGU6IGUuY2hhckNvZGUsXG4gICAgICAgICAgICBrZXk6IGUua2V5Q29kZSxcbiAgICAgICAgICAgIG1ldGE6IGUubWV0YUtleSxcbiAgICAgICAgICAgIHJlcGVhdENvdW50OiB0aGlzLnJlcGVhdEtleUNvdW50LFxuICAgICAgICAgICAgcmVwZWF0U3RhcnRUaW1lOiB0aGlzLnJlcGVhdEtleVN0YXJ0VGltZSxcbiAgICAgICAgICAgIHNoaWZ0OiBlLnNoaWZ0S2V5LFxuICAgICAgICAgICAgaWRlbnRpZmllcjogZS5rZXlJZGVudGlmaWVyLFxuICAgICAgICAgICAgY3VycmVudEtleXM6IHRoaXMuY3VycmVudEtleXMuc2xpY2UoMClcbiAgICAgICAgfSk7XG4gICAgfSxcblxuICAgIGZpbmtleXVwOiBmdW5j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iAgICB9LFxuXG4gICAgZmluZm9jdXNsb3N0OiBmdW5jdGlvbihlKSB7XG4gICAgICAgIHRoaXMuZGlzcGF0Y2hOZXdFdmVudChlLCAnZmluLWNhbnZhcy1mb2N1cy1sb3N0Jyk7XG4gICAgfSxcblxuICAgIGZpbmNvbnRleHRtZW51OiBmdW5jdGlvbihlKSB7XG4gICAgICAgIGlmIChlLmN0cmxLZXkgJiYgdGhpcy5jdXJyZW50S2V5cy5pbmRleE9mKCdDVFJMJykgPT09IC0xKSB7XG4gICAgICAgICAgICB0aGlzLmN1cnJlbnRLZXlzLnB1c2goJ0NUUkwnKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5kb3VibGVSaWdodENsaWNrVGltZXIgJiYgRGF0ZS5ub3coKSAtIHRoaXMubGFzdENsaWNrVGltZSA8IHRoaXMuZG91YmxlQ2xpY2tEZWxheSkge1xuICAgICAgICAgICAgLy90aGlzIGlzIGEgZG91YmxlIGNsaWNrLi4uXG4gICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5kb3VibGVSaWdodENsaWNrVGltZXIpOyAvLyBwcmV2ZW50IGNvbnRleHQgbWVudSBldmVudFxuICAgICAgICAgICAgdGhpcy5kb3VibGVSaWdodENsaWNrVGltZXIgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICB0aGlzLmZpbmRibGNsaWNrKGUpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5sYXN0Q2xpY2tUaW1lID0gRGF0ZS5ub3coKTtcblxuICAgICAgICAgICAgdGhpcy5kb3VibGVSaWdodENsaWNrVGltZXIgPSBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZG91YmxlUmlnaHRDbGlja1RpbWVyID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIHRoaXMuZGlzcGF0Y2hOZXdNb3VzZUtleXNFdmVudChlLCAnZmluLWNhbnZhcy1jb250ZXh0LW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gc291cmNlIGZvciBhbGwgZXZlbnRzXG4gICAgICAgICAgICAgICAgaGFzRnVsbFBhdGggPSBldi5wYXRoWzBdID09PSBzO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZXYuc3RvcFByb3BhZ2F0aW9uKCk7XG4gICAgICAgIH0pO1xuICAgICAgICB2YXIgZXYgPSBuZXcgQ3VzdG9tRXZlbnQoJ3Rlc3RwYXRoJywge1xuICAgICAgICAgICAgYnViYmxlczogdHJ1ZVxuICAgICAgICB9KTtcbiAgICAgICAgLy8gbXVzdCBhZGQgbm9kZSB0byBET00gdG8gdHJpZ2dlciBldmVudCBsaXN0ZW5lclxuICAgICAgICBkb2N1bWVudC5oZWFkLmFwcGVuZENoaWxkKHBhdGhUZXN0KTtcbiAgICAgICAgcy5kaXNwYXRjaEV2ZW50KGV2KTtcbiAgICAgICAgcGF0aFRlc3QucGFyZW50Tm9kZS5yZW1vdmVDaGlsZChwYXRoVGVzdCk7XG4gICAgICAgIHNyID0gcyA9IG51bGw7XG4gICAgfVxuICAgIHBhdGhUZXN0ID0gbnVsbDtcblxuICAgIHZhciB0YXJnZXQgPSB7XG4gICAgICAgIHNoYWRvdzogZnVuY3Rpb24oaW5FbCkge1xuICAgICAgICAgICAgaWYgKGluRWwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaW5FbC5zaGFkb3dSb290IHx8IGluRWwud2Via2l0U2hhZG93Um9vdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgY2FuVGFyZ2V0OiBmdW5jdGlvbihzaGFkb3cpIHtcbiAgICAgICAgICAgIHJldHVybiBzaGFkb3cgJiYgQm9vbGVhbihzaGFkb3cuZWxlbWVudEZyb21Qb2ludCk7XG4gICAgICAgIH0sXG4gICAgICAgIHRhcmdldGluZ1NoYWRvdzogZnVuY3Rpb24oaW5FbCkge1xuICAgICAgICAgICAgdmFyIHMgPSB0aGlzLnNoYWRvdyhpbkVsKTtcbiAgICAgICAgICAgIGlmICh0aGlzLmNhblRhcmdldChzKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBzO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBvbGRlclNoYWRvdzogZnVuY3Rpb24oc2hhZG93KSB7XG4gICAgICAgICAgICB2YXIgb3MgPSBzaGFkb3cub2xkZXJTaGFkb3dSb290O1xuICAgICAgICAgICAgaWYgKCFvcykge1xuICAgICAgICAgICAgICAgIHZhciBzZSA9IHNoYWRvdy5xdWVyeVNlbGVjdG9yKCdzaGFkb3cnKTtcbiAgICAgICAgICAgICAgICBpZiAoc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgb3MgPSBzZS5vbGRlclNoYWRvd1Jvb3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIG9zO1xuICAgICAgICB9LFxuICAgICAgICBhbGxTaGFkb3dzOiBmdW5jdGlvbihlbGVtZW50KSB7XG4gICAgICAgICAgICB2YXIgc2hhZG93cyA9IFtdLFxuICAgICAgICAgICAgICAgIHMgPSB0aGlzLnNoYWRvdyhlbGVtZW50KTtcbiAgICAgICAgICAgIHdoaWxlIChzKSB7XG4gICAgICAgICAgICAgICAgc2hhZG93cy5wdXNoKHMpO1xuICAgICAgICAgICAgICAgIHMgPSB0aGlzLm9sZGVyU2hhZG93KHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHNoYWRvd3M7XG4gICAgICAgIH0sXG4gICAgICAgIHNlYXJjaFJvb3Q6IGZ1bmN0aW9uKGluUm9vdCwgeCwgeSkge1xuICAgICAgICAgICAgdmFyIHQsIHN0LCBzciwgb3M7XG4gICAgICAgICAgICBpZiAoaW5Sb290KSB7XG4gICAgICAgICAgICAgICAgdCA9IGluUm9vdC5lbGVtZW50RnJvbVBvaW50KHgsIHkpO1xuICAgICAgICAgICAgICAgIGlmICh0KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGZvdW5kIGVsZW1lbnQsIGNoZWNrIGlmIGl0IGhhcyBhIFNoYWRvd1Jvb3RcbiAgICAgICAgICAgICAgICAgICAgc3IgPSB0aGlzLnRhcmdldGluZ1NoYWRvdyh0KTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGluUm9vdCAhPT0gZG9jdW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgZm9yIHNpYmxpbmcgcm9vdHNcbiAgICAgICAgICAgICAgICAgICAgc3IgPSB0aGlzLm9sZGVyU2hhZG93KGluUm9vdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIC8vIHNlYXJjaCBvdGhlciByb290cywgZmFsbCBiYWNrIHRvIGxpZ2h0IGRvbSBlbGVtZW50XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2VhcmNoUm9vdChzciwgeCwgeSkgfHwgdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgb3duZXI6IGZ1bmN0aW9uKGVsZW1lbnQpIHtcbiAgICAgICAgICAgIGlmICghZWxlbWVudCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkb2N1bWVudDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBzID0gZWxlbWVudDtcbiAgICAgICAgICAgIC8vIHdhbGsgdXAgdW50aWwgeW91IGhpdCB0aGUgc2hhZG93IHJvb3Qgb3IgZG9jdW1lbnRcbiAgICAgICAgICAgIHdoaWxlIChzLnBhcmVudE5vZGUpIHtcbiAgICAgICAgICAgICAgICBzID0gcy5wYXJlbnROb2RlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gdGhlIG93bmVyIGVsZW1lbnQgaXMgZXhwZWN0ZWQgdG8gYmUgYSBEb2N1bWVudCBvciBTaGFkb3dSb290XG4gICAgICAgICAgICBpZiAocy5ub2RlVHlwZSAhPSBOb2RlLkRPQ1VNRU5UX05PREUgJiYgcy5ub2RlVHlwZSAhPSBOb2RlLkRPQ1VNRU5UX0ZSQUdNRU5UX05PREUpIHtcbiAgICAgICAgICAgICAgICBzID0gZG9jdW1lbnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcztcbiAgICAgICAgfSxcbiAgICAgICAgZmluZFRhcmdldDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKGhhc0Z1bGxQYXRoICYmIGluRXZlbnQucGF0aCAmJiBpbkV2ZW50LnBhdGgubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGluRXZlbnQucGF0aFswXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciB4ID0gaW5FdmVudC5jbGllbnRYLFxuICAgICAgICAgICAgICAgIHkgPSBpbkV2ZW50LmNsaWVudFk7XG4gICAgICAgICAgICAvLyBpZiB0aGUgbGlzdGVuZXIgaXMgaW4gdGhlIHNoYWRvdyByb290LCBpdCBpcyBtdWNoIGZhc3RlciB0byBzdGFydCB0aGVyZVxuICAgICAgICAgICAgdmFyIHMgPSB0aGlzLm93bmVyKGluRXZlbnQudGFyZ2V0KTtcbiAgICAgICAgICAgIC8vIGlmIHgsIHkgaXMgbm90IGluIHRoaXMgcm9vdCwgZmFsbCBiYWNrIHRvIGRvY3VtZW50IHNlYXJjaFxuICAgICAgICAgICAgaWYgKCFzLmVsZW1lbnRGcm9tUG9pbnQoeCwgeSkpIHtcbiAgICAgICAgICAgICAgICBzID0gZG9jdW1lbnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5zZWFyY2hSb290KHMsIHgsIHkpO1xuICAgICAgICB9LFxuICAgICAgICBmaW5kVG91Y2hBY3Rpb246IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBuO1xuICAgICAgICAgICAgaWYgKGhhc0Z1bGxQYXRoICYmIGluRXZlbnQucGF0aCAmJiBpbkV2ZW50LnBhdGgubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgdmFyIHBhdGggPSBpbkV2ZW50LnBhdGg7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBwYXRoLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIG4gPSBwYXRoW2ldO1xuICAgICAgICAgICAgICAgICAgICBpZiAobi5ub2RlVHlwZSA9PT0gTm9kZS5FTEVNRU5UX05PREUgJiYgbi5oYXNBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbi5nZXRBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBuID0gaW5FdmVudC50YXJnZXQ7XG4gICAgICAgICAgICAgICAgd2hpbGUgKG4pIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKG4ubm9kZVR5cGUgPT09IE5vZGUuRUxFTUVOVF9OT0RFICYmIG4uaGFzQXR0cmlidXRlKCd0b3VjaC1hY3Rpb24nKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG4uZ2V0QXR0cmlidXRlKCd0b3VjaC1hY3Rpb24nKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBuID0gbi5wYXJlbnROb2RlIHx8IG4uaG9zdDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBhdXRvIGlzIGRlZmF1bHRcbiAgICAgICAgICAgIHJldHVybiBcImF1dG9cIjtcbiAgICAgICAgfSxcbiAgICAgICAgTENBOiBmdW5jdGlvbihhLCBiKSB7XG4gICAgICAgICAgICBpZiAoYSA9PT0gYikge1xuICAgICAgICAgICAgICAgIHJldHVybiBhO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGEgJiYgIWIpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChiICYmICFhKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWIgJiYgIWEpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBmYXN0IGNhc2UsIGEgaXMgYSBkaXJlY3QgZGVzY2VuZGFudCBvZiBiIG9yIHZpY2UgdmVyc2FcbiAgICAgICAgICAgIGlmIChhLmNvbnRhaW5zICYmIGEuY29udGFpbnMoYikpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChiLmNvbnRhaW5zICYmIGIuY29udGFpbnMoYSkpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gYjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBhZGVwdGggPSB0aGlzLmRlcHRoKGEpO1xuICAgICAgICAgICAgdmFyIGJkZXB0aCA9IHRoaXMuZGVwdGgoYik7XG4gICAgICAgICAgICB2YXIgZCA9IGFkZXB0aCAtIGJkZXB0aDtcbiAgICAgICAgICAgIGlmIChkID49IDApIHtcbiAgICAgICAgICAgICAgICBhID0gdGhpcy53YWxrKGEsIGQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBiID0gdGhpcy53YWxrKGIsIC1kKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHdoaWxlIChhICYmIGIgJiYgYSAhPT0gYikge1xuICAgICAgICAgICAgICAgIGEgPSBhLnBhcmVudE5vZGUgfHwgYS5ob3N0O1xuICAgICAgICAgICAgICAgIGIgPSBiLnBhcmVudE5vZGUgfHwgYi5ob3N0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGE7XG4gICAgICAgIH0sXG4gICAgICAgIHdhbGs6IGZ1bmN0aW9uKG4sIHUpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBuICYmIChpIDwgdSk7IGkrKykge1xuICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIG47XG4gICAgICAgIH0sXG4gICAgICAgIGRlcHRoOiBmdW5jdGlvbihuKSB7XG4gICAgICAgICAgICB2YXIgZCA9IDA7XG4gICAgICAgICAgICB3aGlsZSAobikge1xuICAgICAgICAgICAgICAgIGQrKztcbiAgICAgICAgICAgICAgICBuID0gbi5wYXJlbnROb2RlIHx8IG4uaG9zdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBkO1xuICAgICAgICB9LFxuICAgICAgICBkZWVwQ29udGFpbnM6IGZ1bmN0aW9uKGEsIGIpIHtcbiAgICAgICAgICAgIHZhciBjb21tb24gPSB0aGlzLkxDQShhLCBiKTtcbiAgICAgICAgICAgIC8vIGlmIGEgaXMgdGhlIGNvbW1vbiBhbmNlc3RvciwgaXQgbXVzdCBcImRlZXBseVwiIGNvbnRhaW4gYlxuICAgICAgICAgICAgcmV0dXJuIGNvbW1vbiA9PT0gYTtcbiAgICAgICAgfSxcbiAgICAgICAgaW5zaWRlTm9kZTogZnVuY3Rpb24obm9kZSwgeCwgeSkge1xuICAgICAgICAgICAgdmFyIHJlY3QgPSBub2RlLmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpO1xuICAgICAgICAgICAgcmV0dXJuIChyZWN0LmxlZnQgPD0geCkgJiYgKHggPD0gcmVjdC5yaWdodCkgJiYgKHJlY3QudG9wIDw9IHkpICYmICh5IDw9IHJlY3QuYm90dG9tKTtcbiAgICAgICAgfSxcbiAgICAgICAgcGF0aDogZnVuY3Rpb24oZXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBwO1xuICAgICAgICAgICAgaWYgKGhhc0Z1bGxQYXRoICYmIGV2ZW50LnBhdGggJiYgZXZlbnQucGF0aC5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICBwID0gZXZlbnQucGF0aDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcCA9IFtdO1xuICAgICAgICAgICAgICAgIHZhciBuID0gdGhpcy5maW5kVGFyZ2V0KGV2ZW50KTtcbiAgICAgICAgICAgICAgICB3aGlsZSAobikge1xuICAgICAgICAgICAgICAgICAgICBwLnB1c2gobik7XG4gICAgICAgICAgICAgICAgICAgIG4gPSBuLnBhcmVudE5vZGUgfHwgbi5ob3N0O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBwO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBzY29wZS50YXJnZXRGaW5kaW5nID0gdGFyZ2V0O1xuICAgIC8qKlxuICAgICAqIEdpdmVuIGFuIGV2ZW50LCBmaW5kcyB0aGUgXCJkZWVwZXN0XCIgbm9kZSB0aGF0IGNvdWxkIGhhdmUgYmVlbiB0aGUgb3JpZ2luYWwgdGFyZ2V0IGJlZm9yZSBTaGFkb3dET00gcmV0YXJnZXR0aW5nXG4gICAgICpcbiAgICAgKiBAcGFyYW0ge0V2ZW50fSBFdmVudCBBbiBldmVudCBvYmplY3Qgd2l0aCBjbGllbnRYIGFuZCBjbGllbnRZIHByb3BlcnRpZXNcbiAgICAgKiBAcmV0dXJuIHtFbGVtZW50fSBUaGUgcHJvYmFibGUgZXZlbnQgb3JpZ25pbmF0b3JcbiAgICAgKi9cbiAgICBzY29wZS5maW5kVGFyZ2V0ID0gdGFyZ2V0LmZpbmRUYXJnZXQuYmluZCh0YXJnZXQpO1xuICAgIC8qKlxuICAgICAqIERldGVybWluZXMgaWYgdGhlIFwiY29udGFpbmVyXCIgbm9kZSBkZWVwbHkgY29udGFpbnMgdGhlIFwiY29udGFpbmVlXCIgbm9kZSwgaW5jbHVkaW5nIHNpdHVhdGlvbnMgd2hlcmUgdGhlIFwiY29udGFpbmVlXCIgaXMgY29udGFpbmVkIGJ5IG9uZSBvciBtb3JlIFNoYWRvd0RPTVxuICAgICAqIHJvb3RzLlxuICAgICAqXG4gICAgICogQHBhcmFtIHtOb2RlfSBjb250YWluZXJcbiAgICAgKiBAcGFyYW0ge05vZGV9IGNvbnRhaW5lZVxuICAgICAqIEByZXR1cm4ge0Jvb2xlYW59XG4gICAgICovXG4gICAgc2NvcGUuZGVlcENvbnRhaW5zID0gdGFyZ2V0LmRlZXBDb250YWlucy5iaW5kKHRhcmdldCk7XG5cbiAgICAvKipcbiAgICAgKiBEZXRlcm1pbmVzIGlmIHRoZSB4L3kgcG9zaXRpb24gaXMgaW5zaWRlIHRoZSBnaXZlbiBub2RlLlxuICAgICAqXG4gICAgICogRXhhbXBsZTpcbiAgICAgKlxuICAgICAqICAgICBmdW5jdGlvbiB1cEhhbmRsZXIoZXZlbnQpIHtcbiAgICAgKiAgICAgICB2YXIgaW5ub2RlID0gUG9seW1lckdlc3R1cmVzLmluc2lkZU5vZGUoZXZlbnQudGFyZ2V0LCBldmVudC5jbGllbnRYLCBldmVudC5jbGllbnRZKTtcbiAgICAgKiAgICAgICBpZiAoaW5ub2RlKSB7XG4gICAgICogICAgICAgICAvLyB3YWl0IGZvciB0YXA/XG4gICAgICogICAgICAgfSBlbHNlIHtcbiAgICAgKiAgICAgICAgIC8vIHRhcCB3aWxsIG5ldmVyIGhhcHBlblxuICAgICAqICAgICAgIH1cbiAgICAgKiAgICAgfVxuICAgICAqXG4gICAgICogQHBhcmFtIHtOb2RlfSBub2RlXG4gICAgICogQHBhcmFtIHtOdW1iZXJ9IHggU2NyZWVuIFggcG9zaXRpb25cbiAgICAgKiBAcGFyYW0ge051bWJlcn0geSBzY3JlZW4gWSBwb3NpdGlvblxuICAgICAqIEByZXR1cm4ge0Jvb2xlYW59XG4gICAgICovXG4gICAgc2NvcGUua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UV2ZW50OiBmdW5jdGlvbihpblR5cGUsIGluRGljdCkge1xuICAgICAgICAgICAgaW5EaWN0ID0gaW5EaWN0IHx8IE9iamVjdC5jcmVhdGUobnVsbCk7XG5cbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5tYWtlQmFzZUV2ZW50KGluVHlwZSwgaW5EaWN0KTtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBrZXlzID0gT2JqZWN0LmtleXMoaW5EaWN0KSwgazsgaSA8IGtleXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBrID0ga2V5c1tpXTtcbiAgICAgICAgICAgICAgICBpZiAoayAhPT0gJ2J1YmJsZXMnICYmIGsgIT09ICdjYW5jZWxhYmxlJykge1xuICAgICAgICAgICAgICAgICAgICBlW2tdID0gaW5EaWN0W2tdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBlO1xuICAgICAgICB9LFxuICAgICAgICBtYWtlUG9pbnRlckV2ZW50OiBmdW5jdGlvbihpblR5cGUsIGluRGljdCkge1xuICAgICAgICAgICAgaW5EaWN0ID0gaW5EaWN0IHx8IE9iamVjdC5jcmVhdGUobnVsbCk7XG5cbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5tYWtlQmFzZUV2ZW50KGluVHlwZSwgaW5EaWN0KTtcbiAgICAgICAgICAgIC8vIGRlZmluZSBpbmhlcml0ZWQgTW91c2VFdmVudCBwcm9wZXJ0aWVzXG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMiwgcDsgaSA8IE1PVVNFX1BST1BTLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgcCA9IE1PVVNFX1BST1BTW2ldO1xuICAgICAgICAgICAgICAgIGVbcF0gPSBpbkRpY3RbcF0gfHwgTU9VU0VfREVGQVVMVFNbaV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlLmJ1dHRvbnMgPSBpbkRpY3QuYnV0dG9ucyB8fCAwO1xuXG4gICAgICAgICAgICAvLyBTcGVjIHJlcXVpcmVzIHRoYXQgcG9pbnRlcnMgd2l0aG91dCBwcmVzc3VyZSBzcGVjaWZpZWQgdXNlIDAuNSBmb3IgZG93blxuICAgICAgICAgICAgLy8gc3RhdGUgYW5kIDAgZm9yIHVwIHN0YXRlLlxuICAgICAgICAgICAgdmFyIHByZXNzdXJlID0gMDtcbiAgICAgICAgICAgIGlmIChpbkRpY3QucHJlc3N1cmUpIHtcbiAgICAgICAgICAgICAgICBwcmVzc3VyZSA9IGluRGljdC5wcmVzc3VyZTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcHJlc3N1cmUgPSBlLmJ1dHRvbnMgPyAwLjUgOiAwO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBhZGQgeC95IHByb3BlcnRpZXMgYWxpYXNlZCB0byBjbGllbnRYL1lcbiAgICAgICAgICAgIGUueCA9IGUuY2xpZW50WDtcbiAgICAgICAgICAgIGUueSA9IGUuY2xpZW50WTtcblxuICAgICAgICAgICAgLy8gZGVmaW5lIHRoZSBwcm9wZXJ0aWVzIG9mIHRoZSBQb2ludGVyRXZlbnQgaW50ZXJmYWNlXG4gICAgICAgICAgICBlLnBvaW50ZXJJZCA9IGluRGljdC5wb2ludGVySWQgfHwgMDtcbiAgICAgICAgICAgIGUud2lkdGggPSBpbkRpY3Qud2lkdGggfHwgMDtcbiAgICAgICAgICAgIGUuaGVpZ2h0ID0gaW5EaWN0LmhlaWdodCB8fCAwO1xuICAgICAgICAgICAgZS5wcmVzc3VyZSA9IHByZXNzdXJlO1xuICAgICAgICAgICAgZS50aWx0WCA9IGluRGljdC50aWx0WCB8fCAwO1xuICAgICAgICAgICAgZS50aWx0WSA9IGluRGljdC50aWx0WSB8fCAwO1xuICAgICAgICAgICAgZS5wb2ludGVyVHlwZSA9IGluRGljdC5wb2ludGVyVHlwZSB8fCAnJztcbiAgICAgICAgICAgI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GlmIChpID4gLTEpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnZhbHVlc1tpXSA9IGluRXZlbnQ7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMua2V5cy5wdXNoKGluSWQpO1xuICAgICAgICAgICAgICAgIHRoaXMudmFsdWVzLnB1c2goaW5FdmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGhhczogZnVuY3Rpb24oaW5JZCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMua2V5cy5pbmRleE9mKGluSWQpID4gLTE7XG4gICAgICAgIH0sXG4gICAgICAgICdkZWxldGUnOiBmdW5jdGlvbihpbklkKSB7XG4gICAgICAgICAgICB2YXIgaSA9IHRoaXMua2V5cy5pbmRleE9mKGluSWQpO1xuICAgICAgICAgICAgaWYgKGkgPiAtMSkge1xuICAgICAgICAgICAgICAgIHRoaXMua2V5cy5zcGxpY2UoaSwgMSk7XG4gICAgICAgICAgICAgICAgdGhpcy52YWx1ZXMuc3BsaWNlKGksIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBnZXQ6IGZ1bmN0aW9uKGluSWQpIHtcbiAgICAgICAgICAgIHZhciBpID0gdGhpcy5rZXlzLmluZGV4T2YoaW5JZCk7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy52YWx1ZXNbaV07XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFyOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHRoaXMua2V5cy5sZW5ndGggPSAwO1xuICAgICAgICAgICAgdGhpcy52YWx1ZXMubGVuZ3RoID0gMDtcbiAgICAgICAgfSxcbiAgICAgICAgLy8gcmV0dXJuIHZhbHVlLCBrZXksIG1hcFxuICAgICAgICBmb3JFYWNoOiBmdW5jdGlvbihjYWxsYmFjaywgdGhpc0FyZykge1xuICAgICAgICAgICAgdGhpcy52YWx1ZXMuZm9yRWFjaChmdW5jdGlvbih2LCBpKSB7XG4gICAgICAgICAgICAgICAgY2FsbGJhY2suY2FsbCh0aGlzQXJnLCB2LCB0aGlzLmtleXNbaV0sIHRoaXMpO1xuICAgICAgICAgICAgfSwgdGhpcyk7XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJzOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmtleXMubGVuZ3RoO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHNjb3BlLlBvaW50ZXJNYXAgPSBQb2ludGVyTWFwO1xufSkoZXhwb3J0cyk7XG5cbihmdW5jdGlvbihzY29wZSkge1xuICAgIHZhciBDTE9ORV9QUk9QUyA9IFtcbiAgICAgICAgLy8gTW91c2VFdmVudFxuICAgICAgICAnYnViYmxlcycsXG4gICAgICAgICdjYW5jZWxhYmxlJyxcbiAgICAgICAgJ3ZpZXcnLFxuICAgICAgICAnZGV0YWlsJyxcbiAgICAgICAgJ3NjcmVlblgnLFxuICAgICAgICAnc2NyZWVuWScsXG4gICAgICAgICdjbGllbnRYJyxcbiAgICAgICAgJ2NsaWVudFknLFxuICAgICAgICAnY3RybEtleScsXG4gICAgICAgICdhbHRLZXknLFxuICAgICAgICAnc2hpZnRLZXknLFxuICAgICAgICAnbWV0YUtleScsXG4gICAgICAgICdidXR0b24nLFxuICAgICAgICAncmVsYXRlZFRhcmdldCcsXG4gICAgICAgIC8vIERPTSBMZXZlbCAzXG4gICAgICAgICdidXR0b25zJyxcbiAgICAgICAgLy8gUG9pbnRlckV2ZW50XG4gICAgICAgICdwb2ludGVySWQnLFxuICAgICAgICAnd2lkdGgnLFxuICAgICAgICAnaGVpZ2h0JyxcbiAgICAgICAgJ3ByZXNzdXJlJyxcbiAgICAgICAgJ3RpbHRYJyxcbiAgICAgICAgJ3RpbHRZJyxcbiAgICAgICAgJ3BvaW50ZXJUeXBlJyxcbiAgICAgICAgJ2h3VGltZXN0YW1wJyxcbiAgICAgICAgJ2lzUHJpbWFyeScsXG4gICAgICAgIC8vIGV2ZW50IGluc3RhbmNlXG4gICAgICAgICd0eXBlJyxcbiAgICAgICAgJ3RhcmdldCcsXG4gICAgICAgICdjdXJyZW50VGFyZ2V0JyxcbiAgICAgICAgJ3doaWNoJyxcbiAgICAgICAgJ3BhZ2VYJyxcbiAgICAgICAgJ3BhZ2VZJyxcbiAgICAgICAgJ3RpbWVTdGFtcCcsXG4gICAgICAgIC8vIGdlc3R1cmUgYWRkb25zXG4gICAgICAgICdwcmV2ZW50VGFwJyxcbiAgICAgICAgJ3RhcFByZXZlbnRlZCcsXG4gICAgICAgICdfc291cmNlJ1xuICAgIF07XG5cbiAgICB2YXIgQ0xPTkVfREVGQVVMVFMgPSBbXG4gICAgICAgIC8vIE1vdXNlRXZlbnRcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBudWxsLFxuICAgICAgICBudWxsLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICAwLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgZmFsc2UsXG4gICAgICAgIGZhbHNlLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgMCxcbiAgICAgICAgbnVsbCxcbiAgICAgICAgLy8gRE9NIExldmVsIDNcbiAgICAgICAgMCxcbiAgICAgICAgLy8gUG9pbnRlckV2ZW50XG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgICcnLFxuICAgICAgICAwLFxuICAgICAgICBmYWxzZSxcbiAgICAgICAgLy8gZXZlbnQgaW5zdGFuY2VcbiAgICAgICAgJycsXG4gICAgICAgIG51bGwsXG4gICAgICAgIG51bGwsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIDAsXG4gICAgICAgIGZ1bmN0aW9uKCkge30sXG4gICAgICAgIGZhbHNlXG4gICAgXTtcblxuICAg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Y29wZS5Qb2ludGVyTWFwKCksXG4gICAgICAgIHJlcXVpcmVkR2VzdHVyZXM6IG5ldyBzY29wZS5Qb2ludGVyTWFwKCksXG4gICAgICAgIGV2ZW50TWFwOiBPYmplY3QuY3JlYXRlKG51bGwpLFxuICAgICAgICAvLyBTY29wZSBvYmplY3RzIGZvciBuYXRpdmUgZXZlbnRzLlxuICAgICAgICAvLyBUaGlzIGV4aXN0cyBmb3IgZWFzZSBvZiB0ZXN0aW5nLlxuICAgICAgICBldmVudFNvdXJjZXM6IE9iamVjdC5jcmVhdGUobnVsbCksXG4gICAgICAgIGV2ZW50U291cmNlTGlzdDogW10sXG4gICAgICAgIGdlc3R1cmVzOiBbXSxcbiAgICAgICAgLy8gbWFwIGdlc3R1cmUgZXZlbnQgLT4ge2xpc3RlbmVyczogaW50LCBpbmRleDogZ2VzdHVyZXNbaW50XX1cbiAgICAgICAgZGVwZW5kZW5jeU1hcDoge1xuICAgICAgICAgICAgLy8gbWFrZSBzdXJlIGRvd24gYW5kIHVwIGFyZSBpbiB0aGUgbWFwIHRvIHRyaWdnZXIgXCJyZWdpc3RlclwiXG4gICAgICAgICAgICBkb3duOiB7XG4gICAgICAgICAgICAgICAgbGlzdGVuZXJzOiAwLFxuICAgICAgICAgICAgICAgIGluZGV4OiAtMVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHVwOiB7XG4gICAgICAgICAgICAgICAgbGlzdGVuZXJzOiAwLFxuICAgICAgICAgICAgICAgIGluZGV4OiAtMVxuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBnZXN0dXJlUXVldWU6IFtdLFxuICAgICAgICAvKipcbiAgICAgICAgICogQWRkIGEgbmV3IGV2ZW50IHNvdXJjZSB0aGF0IHdpbGwgZ2VuZXJhdGUgcG9pbnRlciBldmVudHMuXG4gICAgICAgICAqXG4gICAgICAgICAqIGBpblNvdXJjZWAgbXVzdCBjb250YWluIGFuIGFycmF5IG9mIGV2ZW50IG5hbWVzIG5hbWVkIGBldmVudHNgLCBhbmRcbiAgICAgICAgICogZnVuY3Rpb25zIHdpdGggdGhlIG5hbWVzIHNwZWNpZmllZCBpbiB0aGUgYGV2ZW50c2AgYXJyYXkuXG4gICAgICAgICAqIEBwYXJhbSB7c3RyaW5nfSBuYW1lIEEgbmFtZSBmb3IgdGhlIGV2ZW50IHNvdXJjZVxuICAgICAgICAgKiBAcGFyYW0ge09iamVjdH0gc291cmNlIEEgbmV3IHNvdXJjZSBvZiBwbGF0Zm9ybSBldmVudHMuXG4gICAgICAgICAqL1xuICAgICAgICByZWdpc3RlclNvdXJjZTogZnVuY3Rpb24obmFtZSwgc291cmNlKSB7XG4gICAgICAgICAgICB2YXIgcyA9IHNvdXJjZTtcbiAgICAgICAgICAgIHZhciBuZXdFdmVudHMgPSBzLmV2ZW50cztcbiAgICAgICAgICAgIGlmIChuZXdFdmVudHMpIHtcbiAgICAgICAgICAgICAgICBuZXdFdmVudHMuZm9yRWFjaChmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzW2VdKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmV2ZW50TWFwW2VdID0gc1tlXS5iaW5kKHMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSwgdGhpcyk7XG4gICAgICAgICAgICAgICAgdGhpcy5ldmVudFNvdXJjZXNbbmFtZV0gPSBzO1xuICAgICAgICAgICAgICAgIHRoaXMuZXZlbnRTb3VyY2VMaXN0LnB1c2gocyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHJlZ2lzdGVyR2VzdHVyZTogZnVuY3Rpb24obmFtZSwgc291cmNlKSB7XG4gICAgICAgICAgICB2YXIgb2JqID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgICAgICAgIG9iai5saXN0ZW5lcnMgPSAwO1xuICAgICAgICAgICAgb2JqLmluZGV4ID0gdGhpcy5nZXN0dXJlcy5sZW5ndGg7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgZzsgaSA8IHNvdXJjZS5leHBvc2VzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgZyA9IHNvdXJjZS5leHBvc2VzW2ldLnRvTG93ZXJDYXNlKCk7XG4gICAgICAgICAgICAgICAgdGhpcy5kZXBlbmRlbmN5TWFwW2ddID0gb2JqO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5nZXN0dXJlcy5wdXNoKHNvdXJjZSk7XG4gICAgICAgIH0sXG4gICAgICAgIHJlZ2lzdGVyOiBmdW5jdGlvbihlbGVtZW50LCBpbml0aWFsKSB7XG4gICAgICAgICAgICB2YXIgbCA9IHRoaXMuZXZlbnRTb3VyY2VMaXN0Lmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBlcztcbiAgICAgICAgICAgICAgICAoaSA8IGwpICYmIChlcyA9IHRoaXMuZXZlbnRTb3VyY2VMaXN0W2ldKTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgLy8gY2FsbCBldmVudHNvdXJjZSByZWdpc3RlclxuICAgICAgICAgICAgICAgIGVzLnJlZ2lzdGVyLmNhbGwoZXMsIGVsZW1lbnQsIGluaXRpYWwpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1bnJlZ2lzdGVyOiBmdW5jdGlvbihlbGVtZW50KSB7XG4gICAgICAgICAgICB2YXIgbCA9IHRoaXMuZXZlbnRTb3VyY2VMaXN0Lmxlbmd0aDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBlcztcbiAgICAgICAgICAgICAgICAoaSA8IGwpICYmIChlcyA9IHRoaXMuZXZlbnRTb3VyY2VMaXN0W2ldKTsgaSsrKSB7XG4gICAgICAgICAgICAgICAgLy8gY2FsbCBldmVudHNvdXJjZSByZWdpc3RlclxuICAgICAgICAgICAgICAgIGVzLnVucmVnaXN0ZXIuY2FsbChlcywgZWxlbW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FyIGdlc3R1cmVzV2FudGVkID0gbm9kZS5fcGdFdmVudHM7XG4gICAgICAgICAgICBpZiAoZ2VzdHVyZXNXYW50ZWQgJiYgY3VycmVudEdlc3R1cmVzKSB7XG4gICAgICAgICAgICAgICAgdmFyIGdrID0gT2JqZWN0LmtleXMoZ2VzdHVyZXNXYW50ZWQpO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCByLCByaSwgZzsgaSA8IGdrLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGdlc3R1cmVcbiAgICAgICAgICAgICAgICAgICAgZyA9IGdrW2ldO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZ2VzdHVyZXNXYW50ZWRbZ10gPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBsb29rdXAgZ2VzdHVyZSByZWNvZ25pemVyXG4gICAgICAgICAgICAgICAgICAgICAgICByID0gdGhpcy5kZXBlbmRlbmN5TWFwW2ddO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmVjb2duaXplciBpbmRleFxuICAgICAgICAgICAgICAgICAgICAgICAgcmkgPSByID8gci5pbmRleCA6IC0xO1xuICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEdlc3R1cmVzW3JpXSA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIC8vIExJU1RFTkVSIExPR0lDXG4gICAgICAgIGV2ZW50SGFuZGxlcjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgLy8gVGhpcyBpcyB1c2VkIHRvIHByZXZlbnQgbXVsdGlwbGUgZGlzcGF0Y2ggb2YgZXZlbnRzIGZyb21cbiAgICAgICAgICAgIC8vIHBsYXRmb3JtIGV2ZW50cy4gVGhpcyBjYW4gaGFwcGVuIHdoZW4gdHdvIGVsZW1lbnRzIGluIGRpZmZlcmVudCBzY29wZXNcbiAgICAgICAgICAgIC8vIGFyZSBzZXQgdXAgdG8gY3JlYXRlIHBvaW50ZXIgZXZlbnRzLCB3aGljaCBpcyByZWxldmFudCB0byBTaGFkb3cgRE9NLlxuXG4gICAgICAgICAgICB2YXIgdHlwZSA9IGluRXZlbnQudHlwZTtcblxuICAgICAgICAgICAgLy8gb25seSBnZW5lcmF0ZSB0aGUgbGlzdCBvZiBkZXNpcmVkIGV2ZW50cyBvbiBcImRvd25cIlxuICAgICAgICAgICAgaWYgKHR5cGUgPT09ICd0b3VjaHN0YXJ0JyB8fCB0eXBlID09PSAnbW91c2Vkb3duJyB8fCB0eXBlID09PSAncG9pbnRlcmRvd24nIHx8IHR5cGUgPT09ICdNU1BvaW50ZXJEb3duJykge1xuICAgICAgICAgICAgICAgIGlmICghaW5FdmVudC5faGFuZGxlZEJ5UEcpIHtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudEdlc3R1cmVzID0ge307XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gaW4gSU9TIG1vZGUsIHRoZXJlIGlzIG9ubHkgYSBsaXN0ZW5lciBvbiB0aGUgZG9jdW1lbnQsIHNvIHRoaXMgaXMgbm90IHJlLWVudHJhbnRcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5JU19JT1MpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGV2ID0gaW5FdmVudDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGUgPT09ICd0b3VjaHN0YXJ0Jykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIHNldCB1cCBhIGZha2UgZXZlbnQgdG8gZ2l2ZSB0byB0aGUgcGF0aCBidWlsZGVyXG4gICAgICAgICAgICAgICAgICAgICAgICBldiA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQ6IGluRXZlbnQudGFyZ2V0LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudFg6IGN0LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WTogY3QuY2xpZW50WSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBpbkV2ZW50LnBhdGhcbiAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgLy8gdXNlIGV2ZW50IHBhdGggaWYgYXZhaWxhYmxlLCBvdGhlcndpc2UgYnVpbGQgYSBwYXRoIGZyb20gdGFyZ2V0IGZpbmRpbmdcbiAgICAgICAgICAgICAgICAgICAgdmFyIG5vZGVzID0gaW5FdmVudC5wYXRoIHx8IHNjb3BlLnRhcmdldEZpbmRpbmcucGF0aChldik7XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBuOyBpIDwgbm9kZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG4gPSBub2Rlc1tpXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkR2VzdHVyZURlcGVuZGVuY3kobiwgY3VycmVudEdlc3R1cmVzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkR2VzdHVyZURlcGVuZGVuY3koaW5FdmVudC5jdXJyZW50VGFyZ2V0LCBjdXJyZW50R2VzdHVyZXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKGluRXZlbnQuX2hhbmRsZWRCeVBHKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGZuID0gdGhpcy5ldmVudE1hcCAmJiB0aGlzLmV2ZW50TWFw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nQ6IGZ1bmN0aW9uKGluVHlwZSwgaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLm1ha2VFdmVudChpblR5cGUsIGluRXZlbnQpO1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGlzcGF0Y2hFdmVudChlKTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIFJldHVybnMgYSBzbmFwc2hvdCBvZiBpbkV2ZW50LCB3aXRoIHdyaXRhYmxlIHByb3BlcnRpZXMuXG4gICAgICAgICAqXG4gICAgICAgICAqIEBwYXJhbSB7RXZlbnR9IGluRXZlbnQgQW4gZXZlbnQgdGhhdCBjb250YWlucyBwcm9wZXJ0aWVzIHRvIGNvcHkuXG4gICAgICAgICAqIEByZXR1cm4ge09iamVjdH0gQW4gb2JqZWN0IGNvbnRhaW5pbmcgc2hhbGxvdyBjb3BpZXMgb2YgYGluRXZlbnRgJ3NcbiAgICAgICAgICogICAgcHJvcGVydGllcy5cbiAgICAgICAgICovXG4gICAgICAgIGNsb25lRXZlbnQ6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBldmVudENvcHkgPSBPYmplY3QuY3JlYXRlKG51bGwpLFxuICAgICAgICAgICAgICAgIHA7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IENMT05FX1BST1BTLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgcCA9IENMT05FX1BST1BTW2ldO1xuICAgICAgICAgICAgICAgIGV2ZW50Q29weVtwXSA9IGluRXZlbnRbcF0gfHwgQ0xPTkVfREVGQVVMVFNbaV07XG4gICAgICAgICAgICAgICAgLy8gV29yayBhcm91bmQgU1ZHSW5zdGFuY2VFbGVtZW50IHNoYWRvdyB0cmVlXG4gICAgICAgICAgICAgICAgLy8gUmV0dXJuIHRoZSA8dXNlPiBlbGVtZW50IHRoYXQgaXMgcmVwcmVzZW50ZWQgYnkgdGhlIGluc3RhbmNlIGZvciBTYWZhcmksIENocm9tZSwgSUUuXG4gICAgICAgICAgICAgICAgLy8gVGhpcyBpcyB0aGUgYmVoYXZpb3IgaW1wbGVtZW50ZWQgYnkgRmlyZWZveC5cbiAgICAgICAgICAgICAgICBpZiAocCA9PT0gJ3RhcmdldCcgfHwgcCA9PT0gJ3JlbGF0ZWRUYXJnZXQnKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChIQVNfU1ZHX0lOU1RBTkNFICYmIGV2ZW50Q29weVtwXSBpbnN0YW5jZW9mIFNWR0VsZW1lbnRJbnN0YW5jZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnRDb3B5W3BdID0gZXZlbnRDb3B5W3BdLmNvcnJlc3BvbmRpbmdVc2VFbGVtZW50O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8ga2VlcCB0aGUgc2VtYW50aWNzIG9mIHByZXZlbnREZWZhdWx0XG4gICAgICAgICAgICBldmVudENvcHkucHJldmVudERlZmF1bHQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBpbkV2ZW50LnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgcmV0dXJuIGV2ZW50Q29weTtcbiAgICAgICAgfSxcbiAgICAgICAgLyoqXG4gICAgICAgICAqIERpc3BhdGNoZXMgdGhlIGV2ZW50IHRvIGl0cyB0YXJnZXQuXG4gICAgICAgICAqXG4gICAgICAgICAqIEBwYXJhbSB7RXZlbnR9IGluRXZlbnQgVGhlIGV2ZW50IHRvIGJlIGRpc3BhdGNoZWQuXG4gICAgICAgICAqIEByZXR1cm4ge0Jvb2xlYW59IFRydWUgaWYgYW4gZXZlbnQgaGFuZGxlciByZXR1cm5zIHRydWUsIGZhbHNlIG90aGVyd2lzZS5cbiAgICAgICAgICovXG4gICAgICAgIGRpc3BhdGNoRXZlbnQ6IGZ1bmN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GUgc291cmNlIGV2ZW50J3MgcGF0aCBpcyBsaXN0ZW5pbmcgZm9yIHRob3NlIGdlc3R1cmVzXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmdbal0pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnID0gdGhpcy5nZXN0dXJlc1tqXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbiA9IGdbZS50eXBlXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm4uY2FsbChnLCBlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0aGlzLmdlc3R1cmVRdWV1ZS5sZW5ndGggPSAwO1xuICAgICAgICB9LFxuICAgICAgICBmaWxsR2VzdHVyZVF1ZXVlOiBmdW5jdGlvbihldikge1xuICAgICAgICAgICAgLy8gb25seSB0cmlnZ2VyIHRoZSBnZXN0dXJlIHF1ZXVlIG9uY2VcbiAgICAgICAgICAgIGlmICghdGhpcy5nZXN0dXJlUXVldWUubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgcmVxdWVzdEFuaW1hdGlvbkZyYW1lKHRoaXMuYm91bmRHZXN0dXJlVHJpZ2dlcik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBldi5fcmVxdWlyZWRHZXN0dXJlcyA9IHRoaXMucmVxdWlyZWRHZXN0dXJlcy5nZXQoZXYucG9pbnRlcklkKTtcbiAgICAgICAgICAgIHRoaXMuZ2VzdHVyZVF1ZXVlLnB1c2goZXYpO1xuICAgICAgICB9XG4gICAgfTtcbiAgICBkaXNwYXRjaGVyLmJvdW5kSGFuZGxlciA9IGRpc3BhdGNoZXIuZXZlbnRIYW5kbGVyLmJpbmQoZGlzcG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gICAgICAgICAgLy8gVE9ETyhkZnJlZWRtKTogcmUtZXZhbHVhdGUgYm9va2tlZXBpbmcgdG8gYXZvaWQgdXNpbmcgYXR0cmlidXRlc1xuICAgICAgICAgICAgaWYgKHJlY29nbml6ZXIpIHtcbiAgICAgICAgICAgICAgICB2YXIgdG91Y2hBY3Rpb24gPSByZWNvZ25pemVyLmRlZmF1bHRBY3Rpb25zICYmIHJlY29nbml6ZXIuZGVmYXVsdEFjdGlvbnNbZ107XG4gICAgICAgICAgICAgICAgdmFyIGFjdGlvbk5vZGU7XG4gICAgICAgICAgICAgICAgc3dpdGNoIChub2RlLm5vZGVUeXBlKSB7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgTm9kZS5FTEVNRU5UX05PREU6XG4gICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb25Ob2RlID0gbm9kZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICBjYXNlIE5vZGUuRE9DVU1FTlRfRlJBR01FTlRfTk9ERTpcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbk5vZGUgPSBub2RlLmhvc3Q7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbk5vZGUgPSBudWxsO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICh0b3VjaEFjdGlvbiAmJiBhY3Rpb25Ob2RlICYmICFhY3Rpb25Ob2RlLmhhc0F0dHJpYnV0ZSgndG91Y2gtYWN0aW9uJykpIHtcbiAgICAgICAgICAgICAgICAgICAgYWN0aW9uTm9kZS5zZXRBdHRyaWJ1dGUoJ3RvdWNoLWFjdGlvbicsIHRvdWNoQWN0aW9uKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4g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gLCB0aGUgdW5kZXJseWluZyBnZXN0dXJlIHJlY29nbml6ZXIgaXMgZGlzYWJsZWQuXG4gICAgICpcbiAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IG5vZGVcbiAgICAgKiBAcGFyYW0ge3N0cmluZ30gZ2VzdHVyZVxuICAgICAqIEByZXR1cm4gQm9vbGVhbiBgZ2VzdHVyZWAgaXMgYSB2YWxpZCBnZXN0dXJlXG4gICAgICovXG4gICAgc2NvcGUuZGVhY3RpdmF0ZUdlc3R1cmUgPSBmdW5jdGlvbihub2RlLCBnZXN0dXJlKSB7XG4gICAgICAgIHZhciBnID0gZ2VzdHVyZS50b0xvd2VyQ2FzZSgpO1xuICAgICAgICB2YXIgZGVwID0gZGlzcGF0Y2hlci5kZXBlbmRlbmN5TWFwW2ddO1xuICAgICAgICBpZiAoZGVwKSB7XG4gICAgICAgICAgICBpZiAobm9kZS5fcGdMaXN0ZW5lcnMgPiAwKSB7XG4gICAgICAgICAgICAgICAgbm9kZS5fcGdMaXN0ZW5lcnMtLTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChub2RlLl9wZ0xpc3RlbmVycyA9PT0gMCkge1xuICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIudW5yZWdpc3Rlcihub2RlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChub2RlLl9wZ0V2ZW50cykge1xuICAgICAgICAgICAgICAgIGlmIChub2RlLl9wZ0V2ZW50c1tnXSA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgbm9kZS5fcGdFdmVudHNbZ10tLTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBub2RlLl9wZ0V2ZW50c1tnXSA9IDA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBCb29sZWFuKGRlcCk7XG4gICAgfTtcblxuICAgIC8qKlxuICAgICAqIFN0b3Ag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gICAgICAgIC8vIGZpcmVmb3ggb24gbGludXggcmV0dXJucyBzcGVjLWluY29ycmVjdCB2YWx1ZXMgZm9yIG1vdXNldXAuYnV0dG9uc1xuICAgICAgICAvLyBodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZy9lbi1VUy9kb2NzL1dlYi9BUEkvTW91c2VFdmVudC5idXR0b25zI1NlZV9hbHNvXG4gICAgICAgIC8vIGh0dHBzOi8vY29kZXJldmlldy5jaHJvbWl1bS5vcmcvNzI3NTkzMDAzLyNtc2cxNlxuICAgICAgICBpZiAoRklSRUZPWF9MSU5VWC50ZXN0KG5hdmlnYXRvci51c2VyQWdlbnQpKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgIHJldHVybiBuZXcgTW91c2VFdmVudCgndGVzdCcsIHtcbiAgICAgICAgICAgICAgICBidXR0b25zOiAxXG4gICAgICAgICAgICB9KS5idXR0b25zID09PSAxO1xuICAgICAgICB9IGNhdGNoIChlKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICB9KSgpO1xuXG4gICAgLy8gaGFuZGxlciBibG9jayBmb3IgbmF0aXZlIG1vdXNlIGV2ZW50c1xuICAgIHZhciBtb3VzZUV2ZW50cyA9IHtcbiAgICAgICAgUE9JTlRFUl9JRDogMSxcbiAgICAgICAgUE9JTlRFUl9UWVBFOiAnbW91c2UnLFxuICAgICAgICBldmVudHM6IFtcbiAgICAgICAgICAgICdtb3VzZWRvd24nLFxuICAgICAgICAgICAgJ21vdXNlbW92ZScsXG4gICAgICAgICAgICAnbW91c2V1cCdcbiAgICAgICAgXSxcbiAgICAgICAgZXhwb3NlczogW1xuICAgICAgICAgICAgJ2Rvd24nLFxuICAgICAgICAgICAgJ3VwJyxcbiAgICAgICAgICAgICdtb3ZlJ1xuICAgICAgICBdLFxuICAgICAgICByZWdpc3RlcjogZnVuY3R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RElTVCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHByZXBhcmVFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSBkaXNwYXRjaGVyLmNsb25lRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnBvaW50ZXJJZCA9IHRoaXMuUE9JTlRFUl9JRDtcbiAgICAgICAgICAgIGUuaXNQcmltYXJ5ID0gdHJ1ZTtcbiAgICAgICAgICAgIGUucG9pbnRlclR5cGUgPSB0aGlzLlBPSU5URVJfVFlQRTtcbiAgICAgICAgICAgIGUuX3NvdXJjZSA9ICdtb3VzZSc7XG4gICAgICAgICAgICBpZiAoIUhBU19CVVRUT05TKSB7XG4gICAgICAgICAgICAgICAgdmFyIHR5cGUgPSBpbkV2ZW50LnR5cGU7XG4gICAgICAgICAgICAgICAgdmFyIGJpdCA9IFdISUNIX1RPX0JVVFRPTlNbaW5FdmVudC53aGljaF0gfHwgMDtcbiAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gJ21vdXNlZG93bicpIHtcbiAgICAgICAgICAgICAgICAgICAgY3VycmVudEJ1dHRvbnMgfD0gYml0O1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZSA9PT0gJ21vdXNldXAnKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnRCdXR0b25zICY9IH5iaXQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGUuYnV0dG9ucyA9IGN1cnJlbnRCdXR0b25zO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGU7XG4gICAgICAgIH0sXG4gICAgICAgIG1vdXNlZG93bjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKCF0aGlzLmlzRXZlbnRTaW11bGF0ZWRGcm9tVG91Y2goaW5FdmVudCkpIHtcbiAgICAgICAgICAgICAgICB2YXIgcCA9IHBvaW50ZXJtYXAuaGFzKHRoaXMuUE9JTlRFUl9JRCk7XG4gICAgICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBlLnRhcmdldCA9IHNjb3BlLmZpbmRUYXJnZXQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQodGhpcy5QT0lOVEVSX0lELCBlLnRhcmdldCk7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci5kb3duKGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBtb3VzZW1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5pc0V2ZW50U2ltdWxhdGVkRnJvbVRvdWNoKGluRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgdmFyIHRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KHRoaXMuUE9JTlRFUl9JRCk7XG4gICAgICAgICAgICAgICAgaWYgKHRhcmdldCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgICAgICBlLnRhcmdldCA9IHRhcmdldDtcbiAgICAgICAgICAgICAgICAgICAgLy8gaGFuZGxlIGNhc2Ugd2hlcmUgd2UgbWlzc2VkIGEgbW91c2V1cFxuICAgICAgICAgICAgICAgICAgICBpZiAoKEhBU19CVVRUT05TID8gZS5idXR0b25zIDogZS53aGljaCkgPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghSEFTX0JVVFRPTlMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50QnV0dG9ucyA9IGUuYnV0dG9ucyA9IDA7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLmNhbmNlbChlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xlYW51cE1vdXNlKGUuYnV0dG9ucyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLm1vdmUoZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdXNldXA6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICghdGhpcy5pc0V2ZW50U2ltdWxhdGVkRnJvbVRvdWNoKGluRXZlbnQpKSB7XG4gICAgICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICBlLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQodGhpcy5QT0lOVEVSX0lEKTtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLnVwKGUpO1xuICAgICAgICAgICAgICAgIHRoaXMuY2xlYW51cE1vdXNlKGUuYnV0dG9ucyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNsZWFudXBNb3VzZTogZnVuY3Rpb24oYnV0dG9ucykge1xuICAgICAgICAgICAgaWYgKGJ1dHRvbnMgPT09IDApIHtcbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLmRlbGV0ZSh0aGlzLlBPSU5URVJfSUQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfTtcblxuICAgIHNjb3BlLm1vdXNlRXZlbnRzID0gbW91c2VFdmVudHM7XG59KShleHBvcnRzKTtcblxuKGZ1bmN0aW9uKHNjb3B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ICAgJ3RvdWNoZW5kJyxcbiAgICAgICAgICAgICd0b3VjaGNhbmNlbCdcbiAgICAgICAgXSxcbiAgICAgICAgZXhwb3NlczogW1xuICAgICAgICAgICAgJ2Rvd24nLFxuICAgICAgICAgICAgJ3VwJyxcbiAgICAgICAgICAgICdtb3ZlJ1xuICAgICAgICBdLFxuICAgICAgICByZWdpc3RlcjogZnVuY3Rpb24odGFyZ2V0LCBpbml0aWFsKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5JU19JT1MgPyBpbml0aWFsIDogIWluaXRpYWwpIHtcbiAgICAgICAgICAgICAgICBkaXNwYXRjaGVyLmxpc3Rlbih0YXJnZXQsIHRoaXMuZXZlbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdW5yZWdpc3RlcjogZnVuY3Rpb24odGFyZ2V0KSB7XG4gICAgICAgICAgICBpZiAoIXRoaXMuSVNfSU9TKSB7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci51bmxpc3Rlbih0YXJnZXQsIHRoaXMuZXZlbnRzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgc2Nyb2xsVHlwZXM6IHtcbiAgICAgICAgICAgIEVNSVRURVI6ICdub25lJyxcbiAgICAgICAgICAgIFhTQ1JPTExFUjogJ3Bhbi14JyxcbiAgICAgICAgICAgIFlTQ1JPTExFUjogJ3Bhbi15JyxcbiAgICAgICAgfSxcbiAgICAgICAgdG91Y2hBY3Rpb25Ub1Njcm9sbFR5cGU6IGZ1bmN0aW9uKHRvdWNoQWN0aW9uKSB7XG4gICAgICAgICAgICB2YXIgdCA9IHRvdWNoQWN0aW9uO1xuICAgICAgICAgICAgdmFyIHN0ID0gdGhpcy5zY3JvbGxUeXBlcztcbiAgICAgICAgICAgIGlmICh0ID09PSBzdC5FTUlUVEVSKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuICdub25lJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodCA9PT0gc3QuWFNDUk9MTEVSKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuICdYJztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodCA9PT0gc3QuWVNDUk9MTEVSKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuICdZJztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuICdYWSc7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIFBPSU5URVJfVFlQRTogJ3RvdWNoJyxcbiAgICAgICAgZmlyc3RUb3VjaDogbnVsbCxcbiAgICAgICAgaXNQcmltYXJ5VG91Y2g6IGZ1bmN0aW9uKGluVG91Y2gpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmZpcnN0VG91Y2ggPT09IGluVG91Y2guaWRlbnRpZmllcjtcbiAgICAgICAgfSxcbiAgICAgICAgc2V0UHJpbWFyeVRvdWNoOiBmdW5jdGlvbihpblRvdWNoKSB7XG4gICAgICAgICAgICAvLyBzZXQgcHJpbWFyeSB0b3VjaCBpZiB0aGVyZSBubyBwb2ludGVycywgb3IgdGhlIG9ubHkgcG9pbnRlciBpcyB0aGUgbW91c2VcbiAgICAgICAgICAgIGlmIChwb2ludGVybWFwLnBvaW50ZXJzKCkgPT09IDAgfHwgKHBvaW50ZXJtYXAucG9pbnRlcnMoKSA9PT0gMSAmJiBwb2ludGVybWFwLmhhcygxKSkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcnN0VG91Y2ggPSBpblRvdWNoLmlkZW50aWZpZXI7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJzdFhZID0ge1xuICAgICAgICAgICAgICAgICAgICBYOiBpblRvdWNoLmNsaWVudFgsXG4gICAgICAgICAgICAgICAgICAgIFk6IGluVG91Y2guY2xpZW50WVxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgdGhpcy5maXJzdFRhcmdldCA9IGluVG91Y2gudGFyZ2V0O1xuICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsaW5nID0gbnVsbDtcbiAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbFJlc2V0Q2xpY2tDb3VudCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICByZW1vdmVQcmltYXJ5UG9pbnRlcjogZnVuY3Rpb24oaW5Qb2ludGVyKSB7XG4gICAgICAgICAgICBpZiAoaW5Qb2ludGVyLmlzUHJpbWFyeSkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyc3RUb3VjaCA9IG51bGw7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJzdFhZID0gbnVsbDtcbiAgICAgICAgICAgICAgICB0aGlzLnJlc2V0Q2xpY2tDb3VudCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBjbGlja0NvdW50OiAwLFxuICAgICAgICByZXNldElkOiBudWxsLFxuICAgICAgICByZXNldENsaWNrQ291bnQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdmFyIGZuID0gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlja0NvdW50ID0gMDtcbiAgICAgICAgICAgICAgICB0aGlzLnJlc2V0SWQgPSBudWxsO1xuICAgICAgICAgICAgfS5iaW5kKHRoaXMpO1xuICAgICAgICAgICAgdGhpcy5yZXNldElkID0gc2V0VGltZW91dChmbiwgQ0xJQ0tfQ09VTlRfVElNRU9VVCk7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbFJlc2V0Q2xpY2tDb3VudDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5yZXNldElkKSB7XG4gICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHRoaXMucmVzZXRJZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIHR5cGVUb0J1dHRvbnM6IGZ1bmN0aW9uKHR5cGUpIHtcbiAgICAgICAgICAgIHZhciByZXQgPSAwO1xuICAgICAgICAgICAgaWYgKHR5cGUgPT09ICd0b3VjaHN0YXJ0JyB8fCB0eXBlID09PSAndG91Y2htb3ZlJykge1xuICAgICAgICAgICAgICAgIHJldCA9IDE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gcmV0O1xuICAgICAgICB9LFxuICAgICAgICBmaW5kVGFyZ2V0OiBmdW5jdGlvbih0b3VjaCwgaWQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRUb3VjaEV2ZW50LnR5cGUgPT09ICd0b3VjaHN0YXJ0Jykge1xuICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzUHJpbWFyeVRvdWNoKHRvdWNoKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZmFzdFBhdGggPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRYOiB0b3VjaC5jbGllbnRYLFxuICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50WTogdG91Y2guY2xpZW50WSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGg6IHRoaXMuY3VycmVudFRvdWNoRXZlbnQucGF0aCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogdGhpcy5jdXJyZW50VG91Y2hFdmVudC50YXJnZXRcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNjb3BlLmZpbmRUYXJnZXQoZmFzdFBhdGgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBzY29wZS5maW5kVGFyZ2V0KHRvdWNoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyByZXVzZSB0YXJnZXQgd2UgZm91bmQgaW4gdG91Y2hzdGFydFxuICAgICAgICAgICAgcmV0dXJuIHBvaW50ZXJtYXAuZ2V0KGlkKTtcbiAgICAgICAgfSxcbiAgICAgICAgdG91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LmlzUHJpbWFyeVRvdWNoKGluVG91Y2gpO1xuICAgICAgICAgICAgZS5wb2ludGVyVHlwZSA9IHRoaXMuUE9JTlRFUl9UWVBFO1xuICAgICAgICAgICAgZS5fc291cmNlID0gJ3RvdWNoJztcbiAgICAgICAgICAgIC8vIGZvcndhcmQgdG91Y2ggcHJldmVudERlZmF1bHRzXG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG4gICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0ID0gZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zY3JvbGxpbmcgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICBzZWxmLmZpcnN0WFkgPSBudWxsO1xuICAgICAgICAgICAgICAgIGN0ZS5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHJldHVybiBlO1xuICAgICAgICB9LFxuICAgICAgICBwcm9jZXNzVG91Y2hlczogZnVuY3Rpb24oaW5FdmVudCwgaW5GdW5jdGlvbikge1xuICAgICAgICAgICAgdmFyIHRsID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlcztcbiAgICAgICAgICAgIHRoaXMuY3VycmVudFRvdWNoRXZlbnQgPSBpbkV2ZW50O1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIHQsIHA7IGkgPCB0bC5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgIHQgPSB0bFtpXTtcbiAgICAgICAgICAgICAgICBwID0gdGhpcy50b3VjaFRvUG9pbnRlcih0KTtcbiAgICAgICAgICAgICAgICBpZiAoaW5FdmVudC50eXBlID09PSAndG91Y2hzdGFydCcpIHtcbiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQocC5wb2ludGVySWQsIHAudGFyZ2V0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAuaGFzKHAucG9pbnRlcklkKSkge1xuICAgICAgICAgICAgICAgICAgICBpbkZ1bmN0aW9uLmNhbGwodGhpcywgcCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChpbkV2ZW50LnR5cGUgPT09ICd0b3VjaGVuZCcgfHwgaW5FdmVudC5fY2FuY2VsKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY2xlYW5VcFBvaW50ZXIocCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICAvLyBGb3Igc2luZ2xlIGF4aXMgc2Nyb2xsZXJzLCBkZXRlcm1pbmVzIHdoZXRoZXIgdGhlIGVsZW1lbnQgc2hvdWxkIGVtaXRcbiAgICAgICAgLy8gcG9pbnRlciBldmVudHMgb3IgYmVoYXZlIGFzIGEgc2Nyb2xsZXJcbiAgICAgICAgc2hvdWxkU2Nyb2xsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAodGhpcy5maXJzdFhZKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJldDtcbiAgICAgICAgICAgICAgICB2YXIgdG91Y2hBY3Rpb24gPSBzY29wZS50YXJnZXRGaW5kaW5nLmZpbmRUb3VjaEFjdGlvbihpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICB2YXIgc2Nyb2xsQXhpcyA9IHRoaXMudG91Y2hBY3Rpb25Ub1Njcm9sbFR5cGUodG91Y2hBY3Rpb24pO1xuICAgICAgICAgICAgICAgIGlmIChzY3JvbGxBeGlzID09PSAnbm9uZScpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gdGhpcyBlbGVtZW50IGlzIGEgdG91Y2gtYWN0aW9uOiBub25lLCBzaG91bGQgbmV2ZXIgc2Nyb2xsXG4gICAgICAgICAgICAgICAgICAgIHJldCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc2Nyb2xsQXhpcyA9PT0gJ1hZJykge1xuICAgICAgICAgICAgICAgICAgICAvLyB0aGlzIGVsZW1lbnQgc2hvdWxkIGFsd2F5cyBzY3JvbGxcbiAgICAgICAgICAgICAgICAgICAgcmV0ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdCA9IGluRXZlbnQuY2hhbmdlZFRvdWNoZXNbMF07XG4gICAgICAgICAgICAgICAgICAgIC8vIGNoZWNrIHRoZSBpbnRlbmRlZCBzY3JvbGwgYXhpcywgYW5kIG90aGVyIGF4aXNcbiAgICAgICAgICAgICAgICAgICAgdmFyIGEgPSBzY3JvbGxBeGlzO1xuICAgICAgICAgICAgICAgICAgICB2YXIgb2EgPSBzY3JvbGxBeGlzID09PSAnWScgPyAnWCcgOiAnWSc7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkYSA9IE1hdGguYWJzKHRbJ2NsaWVudCcgKyBhXSAtIHRoaXMuZmlyc3RYWVthXSk7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkb2EgPSBNYXRoLmFicyh0WydjbGllbnQnICsgb2FdIC0gdGhpcy5maXJzdFhZW29hXSk7XG4gICAgICAgICAgICAgICAgICAgIC8vIGlmIGRlbHRhIGluIHRoZSBzY3JvbGwgYXhpcyA+IGRlbHRhIG90aGVyIGF4aXMsIHNjcm9sbCBpbnN0ZWFkIG9mXG4gICAgICAgICAgICAgICAgICAgIC8vIG1ha2luZyBldmVudHNcbiAgICAgICAgICAgICAgICAgICAgcmV0ID0gZGEgPj0gZG9hO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gcmV0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBmaW5kVG91Y2g6IGZ1bmN0aW9uKGluVEwsIGluSWQpIHtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBsID0gaW5UTC5sZW5ndGgsIHQ7IGkgPCBsICYmICh0ID0gaW5UTFtpXSk7IGkrKykge1xuICAgICAgICAgICA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ICAgICAgICAgICAgICAgICAgIC8vIE5ldmVyIHJlbW92ZSBwb2ludGVySWQgPT0gMSwgd2hpY2ggaXMgbW91c2UuXG4gICAgICAgICAgICAgICAgICAgIC8vIFRvdWNoIGlkZW50aWZpZXJzIGFyZSAyIHNtYWxsZXIgdGhhbiB0aGVpciBwb2ludGVySWQsIHdoaWNoIGlzIHRoZVxuICAgICAgICAgICAgICAgICAgICAvLyBpbmRleCBpbiBwb2ludGVybWFwLlxuICAgICAgICAgICAgICAgICAgICBpZiAoa2V5ICE9PSAxICYmICF0aGlzLmZpbmRUb3VjaCh0bCwga2V5IC0gMikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2gocCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9LCB0aGlzKTtcbiAgICAgICAgICAgICAgICBkLmZvckVhY2goZnVuY3Rpb24ocCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbChwKTtcbiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcm1hcC5kZWxldGUocC5wb2ludGVySWQpO1xuICAgICAgICAgICAgICAgIH0sIHRoaXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB0b3VjaHN0YXJ0OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB0aGlzLnZhY3V1bVRvdWNoZXMoaW5FdmVudCk7XG4gICAgICAgICAgICB0aGlzLnNldFByaW1hcnlUb3VjaChpbkV2ZW50LmNoYW5nZWRUb3VjaGVzWzBdKTtcbiAgICAgICAgICAgIHRoaXMuZGVkdXBTeW50aE1vdXNlKGluRXZlbnQpO1xuICAgICAgICAgICAgaWYgKCF0aGlzLnNjcm9sbGluZykge1xuICAgICAgICAgICAgICAgIHRoaXMuY2xpY2tDb3VudCsrO1xuICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc1Rvd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AgICAgICAgICAgICAgICAgICAgICAgIGluRXZlbnQucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc1RvdWNoZXMoaW5FdmVudCwgdGhpcy5tb3ZlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5maXJzdFhZKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0ID0gaW5FdmVudC5jaGFuZ2VkVG91Y2hlc1swXTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGR4ID0gdC5jbGllbnRYIC0gdGhpcy5maXJzdFhZLlg7XG4gICAgICAgICAgICAgICAgICAgIHZhciBkeSA9IHQuY2xpZW50WSAtIHRoaXMuZmlyc3RYWS5ZO1xuICAgICAgICAgICAgICAgICAgICB2YXIgZGQgPSBNYXRoLnNxcnQoZHggKiBkeCArIGR5ICogZHkpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoZGQgPj0gSFlTVEVSRVNJUykge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50b3VjaGNhbmNlbChpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2Nyb2xsaW5nID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyc3RYWSA9IG51bGw7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdmU6IGZ1bmN0aW9uKGluUG9pbnRlcikge1xuICAgICAgICAgICAgZGlzcGF0Y2hlci5tb3ZlKGluUG9pbnRlcik7XG4gICAgICAgIH0sXG4gICAgICAgIHRvdWNoZW5kOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB0aGlzLmRlZHVwU3ludGhNb3VzZShpbkV2ZW50KTtcbiAgICAgICAgICAgIHRoaXMucHJvY2V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mltYXJ5IGZpbmdlciB3aWxsIHN5bnRoIG1vdXNlIGV2ZW50c1xuICAgICAgICAgICAgaWYgKHRoaXMuaXNQcmltYXJ5VG91Y2godCkpIHtcbiAgICAgICAgICAgICAgICAvLyByZW1lbWJlciB4L3kgb2YgbGFzdCB0b3VjaFxuICAgICAgICAgICAgICAgIHZhciBsdCA9IHtcbiAgICAgICAgICAgICAgICAgICAgeDogdC5jbGllbnRYLFxuICAgICAgICAgICAgICAgICAgICB5OiB0LmNsaWVudFlcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGx0cy5wdXNoKGx0KTtcbiAgICAgICAgICAgICAgICB2YXIgZm4gPSAoZnVuY3Rpb24obHRzLCBsdCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgaSA9IGx0cy5pbmRleE9mKGx0KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGkgPiAtMSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbHRzLnNwbGljZShpLCAxKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pLmJpbmQobnVsbCwgbHRzLCBsdCk7XG4gICAgICAgICAgICAgICAgc2V0VGltZW91dChmbiwgREVEVVBfVElNRU9VVCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgLy8gcHJldmVudCBcImdob3N0IGNsaWNrc1wiIHRoYXQgY29tZSBmcm9tIGVsZW1lbnRzIHRoYXQgd2VyZSByZW1vdmVkIGluIGEgdG91Y2ggaGFuZGxlclxuICAgIHZhciBTVE9QX1BST1BfRk4gPSBFdmVudC5wcm90b3R5cGUuc3RvcEltbWVkaWF0ZVByb3BhZ2F0aW9uIHx8IEV2ZW50LnByb3RvdHlwZS5zdG9wUHJvcGFnYXRpb247XG4gICAgZG9jdW1lbnQuYWRkRXZlbnRMaXN0ZW5lcignY2xpY2snLCBmdW5jdGlvbihldikge1xuICAgICAgICB2YXIgeCA9IGV2LmNsaWV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ICAgICAgICAgICAgIGlmIChwYXRoW2ldID09PSB0b3VjaEV2ZW50cy5maXJzdFRhcmdldCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZXYucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgIFNUT1BfUFJPUF9GTi5jYWxsKGV2KTtcbiAgICAgICAgfVxuICAgIH0sIHRydWUpO1xuXG4gICAgc2NvcGUudG91Y2hFdmVudHMgPSB0b3VjaEV2ZW50cztcbn0pKGV4cG9ydHMpO1xuXG4oZnVuY3Rpb24oc2NvcGUpIHtcbiAgICB2YXIgZGlzcGF0Y2hlciA9IHNjb3BlLmRpc3BhdGNoZXI7XG4gICAgdmFyIHBvaW50ZXJtYXAgPSBkaXNwYXRjaGVyLnBvaW50ZXJtYXA7XG4gICAgdmFyIEhBU19CSVRNQVBfVFlQRSA9IHdpbmRvdy5NU1BvaW50ZXJFdmVudCAmJiB0eXBlb2Ygd2luZG93Lk1TUG9pbnRlckV2ZW50Lk1TUE9JTlRFUl9UWVBFX01PVVNFID09PSAnbnVtYmVyJztcbiAgICB2YXIgbXNFdmVudHMgPSB7XG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ01TUG9pbnRlckRvd24nLFxuICAgICAgICAgICAgJ01TUG9pbnRlck1vdmUnLFxuICAgICAgICAgICAgJ01TUG9pbnRlclVwJyxcbiAgICAgICAgICAgICdNU1BvaW50ZXJDYW5jZWwnLFxuICAgICAgICBdLFxuICAgICAgICByZWdpc3RlcjogZnVuY3Rpb24odGFyZ2V0KSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLmxpc3Rlbih0YXJnZXQsIHRoaXMuZXZlbnRzKTtcbiAgICAgICAgfSxcbiAgICAgICAgdW5yZWdpc3RlcjogZnVuY3Rpb24odGFyZ2V0KSB7XG4gICAgICAgICAgICBpZiAodGFyZ2V0Lm5vZGVUeXBlID09PSBOb2RlLkRPQ1VNRU5UX05PREUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkaXNwYXRjaGVyLnVubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICBQT0lOVEVSX1RZUEVTOiBbXG4gICAgICAgICAgICAnJyxcbiAgICAgICAgICAgICd1bmF2YWlsYWJsZScsXG4gICAgICAgICAgICAndG91Y2gnLFxuICAgICAgICAgICAgJ3BlbicsXG4gICAgICAgICAgICAnbW91c2UnXG4gICAgICAgIF0sXG4gICAgICAgIHByZXBhcmVFdmVudDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSBpbkV2ZW50O1xuICAgICAgICAgICAgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGlmIChIQVNfQklUTUFQX1RZUEUpIHtcbiAgICAgICAgICAgICAgICBlLnBvaW50ZXJUeXBlID0gdGhpcy5QT0lOVEVSX1RZUEVTW2luRXZlbnQucG9pbnRlclR5cGVdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZS5fc291cmNlID0gJ21zJztcbiAgICAgICAgICAgIHJldHVybiBlO1xuICAgICAgICB9LFxuICAgICAgICBjbGVhbnVwOiBmdW5jdGlvbihpZCkge1xuICAgICAgICAgICAgcG9pbnRlcm1hcFsnZGVsZXRlJ10oaWQpO1xuICAgICAgICB9LFxuICAgICAgICBNU1BvaW50ZXJEb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgcG9pbnRlcm1hcC5zZXQoaW5FdmVudC5wb2ludGVySWQsIGUudGFyZ2V0KTtcbiAgICAgICAgICAgIGRpc3BhdGNoZXIuZG93bihlKTtcbiAgICAgICAgfSxcbiAgICAgICAgTVNQb2ludGVyTW92ZTogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHRhcmdldCA9IHBvaW50ZXJtYXAuZ2V0KGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgICAgIGlmICh0YXJnZXQpIHtcbiAgICAgICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgICAgIGUudGFyZ2V0ID0gdGFyZ2V0O1xuICAgICAgICAgICAgICAgIGRpc3BhdGNoZXIubW92ZShlKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgTVNQb2ludGVyVXA6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBwb2ludGVybWFwLmdldChlLnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLnVwKGUpO1xuICAgICAgICAgICAgdGhpcy5jbGVhbnVwKGluRXZlbnQucG9pbnRlcklkKTtcbiAgICAgICAgfSxcbiAgICAgICAgTVNQb2ludGVyQ2FuY2VsOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IHRoaXMucHJlcGFyZUV2ZW50KGluRXZlbnQpO1xuICAgICAgICAgICAgZS5yZWxhdGVkVGFyZ2V0ID0gc2NvcGUuZmluZFRhcmdldChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUudGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQoZS5wb2ludGVySWQpO1xuICAgICAgICAgICAgZGlzcGF0Y2hlci5jYW5jZWwoZSk7XG4gICAgICAgICAgICB0aGlzLmNsZWFudXAoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIHNjb3BlLm1zRXZlbnRzID0gbXNFdmVudHM7XG59KShleHBvcnRzKTtcblxuKGZ1bmN0aW9uKHNjb3BlKSB7XG4gICAgdmFyIGRpc3BhdGNoZXIgPSBzY29wZS5kaXNwYXRjaGVyO1xuICAgIHZhciBwb2ludGVybWFwID0gZGlzcGF0Y2hlci5wb2ludGVybWFwO1xuICAgIHZhciBwb2ludGVyRXZlbnRzID0ge1xuICAgICAgICBldmVudHM6IFtcbiAgICAgICAgICAgICdwb2ludGVyZG93bicsXG4gICAgICAgICAgICAncG9pbnRlcm1vdmUnLFxuICAgICAgICAgICAgJ3BvaW50ZXJ1cCcsXG4gICAgICAgICAgICAncG9pbnRlcmNhbmNlbCdcbiAgICAgICAgXSxcbiAgICAgICAgcHJlcGFyZUV2ZW50OiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgZSA9IGRpc3BhdGNoZXIuY2xvbmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUuX3NvdXJjZSA9ICdwb2ludGVyJztcbiAgICAgICAgICAgIHJldHVybiBlO1xuICAgICAgICB9LFxuICAgICAgICByZWdpc3RlcjogZnVuY3Rpb24odGFyZ2V0KSB7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLmxpc3Rlbih0YXJnZXQsIHRoaXMuZXZlbnRzKTtcbiAgICAgICAgfSxcbiAgICAgICAgdW5yZWdpc3RlcjogZnVuY3Rpb24odGFyZ2V0KSB7XG4gICAgICAgICAgICBpZiAodGFyZ2V0Lm5vZGVUeXBlID09PSBOb2RlLkRPQ1VNRU5UX05PREUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkaXNwYXRjaGVyLnVubGlzdGVuKHRhcmdldCwgdGhpcy5ldmVudHMpO1xuICAgICAgICB9LFxuICAgICAgICBjbGVhbnVwOiBmdW5jdGlvbihpZCkge1xuICAgICAgICAgICAgcG9pbnRlcm1hcFsnZGVsZXRlJ10oaWQpO1xuICAgICAgICB9LFxuICAgICAgICBwb2ludGVyZG93bjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIGUgPSB0aGlzLnByZXBhcmVFdmVudChpbkV2ZW50KTtcbiAgICAgICAgICAgIGUudGFyZ2V0ID0gc2NvcGUuZmluZFRhcmdldChpbkV2ZW50KTtcbiAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGUucG9pbnRlcklkLCBlLnRhcmdldCk7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLmRvd24oZSk7XG4gICAgICAgIH0sXG4gICAgICAgIHBvaW50ZXJtb3ZlOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICB2YXIgdGFyZ2V0ID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHRhcmdldCkge1xuICAgICAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgZS50YXJnZXQgPSB0YXJnZXQ7XG4gICAgICAgICAgICAgICAgZGlzcGF0Y2hlci5tb3ZlKGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBwb2ludGVydXA6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBlID0gdGhpcy5wcmVwYXJlRXZlbnQoaW5FdmVudCk7XG4gICAgICAgICAgICBlLnJlbGF0ZWRUYXJnZXQgPSBzY29wZS5maW5kVGFyZ2V0KGluRXZlbnQpO1xuICAgICAgICAgICAgZS50YXJnZXQgPSBwb2ludGVybWFwLmdldChlLnBvaW50ZXJJZCk7XG4gICAgICAgICAgICBkaXNwYXRjaGVyLnV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QGNsYXNzIHRyYWNrXG4gKiBAZXh0ZW5kcyB0cmFja3N0YXJ0XG4gKi9cbi8qKlxuICogVGhpcyBldmVudCBmaXJlcyB3aGVuIHRoZSBwb2ludGVyIGlzIG5vIGxvbmdlciBiZWluZyB0cmFja2VkLlxuICpcbiAqIEBjbGFzcyB0cmFja2VuZFxuICogQGV4dGVuZHMgdHJhY2tzdGFydFxuICovXG5cbihmdW5jdGlvbihzY29wZSkge1xuICAgIHZhciBkaXNwYXRjaGVyID0gc2NvcGUuZGlzcGF0Y2hlcjtcbiAgICB2YXIgZXZlbnRGYWN0b3J5ID0gc2NvcGUuZXZlbnRGYWN0b3J5O1xuICAgIHZhciBwb2ludGVybWFwID0gbmV3IHNjb3BlLlBvaW50ZXJNYXAoKTtcbiAgICB2YXIgdHJhY2sgPSB7XG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ2Rvd24nLFxuICAgICAgICAgICAgJ21vdmUnLFxuICAgICAgICAgICAgJ3VwJyxcbiAgICAgICAgXSxcbiAgICAgICAgZXhwb3NlczogW1xuICAgICAgICAgICAgJ3RyYWNrc3RhcnQnLFxuICAgICAgICAgICAgJ3RyYWNrJyxcbiAgICAgICAgICAgICd0cmFja3gnLFxuICAgICAgICAgICAgJ3RyYWNreScsXG4gICAgICAgICAgICAndHJhY2tlbmQnXG4gICAgICAgIF0sXG4gICAgICAgIGRlZmF1bHRBY3Rpb25zOiB7XG4gICAgICAgICAgICAndHJhY2snOiAnbm9uZScsXG4gICAgICAgICAgICAndHJhY2t4JzogJ3Bhbi15JyxcbiAgICAgICAgICAgICd0cmFja3knOiAncGFuLXgnXG4gICAgICAgIH0sXG4gICAgICAgIFdJR0dMRV9USFJFU0hPTEQ6IDQsXG4gICAgICAgIGNsYW1wRGlyOiBmdW5jdGlvbihpbkRlbHRhKSB7XG4gICAgICAgICAgICByZXR1cm4gaW5EZWx0YSA+IDAgPyAxIDogLTE7XG4gICAgICAgIH0sXG4gICAgICAgIGNhbGNQb3NpdGlvbkRlbHRhOiBmdW5jdGlvbihpbkEsIGluQikge1xuICAgICAgICAgICAgdmFyIHggPSAwLFxuICAgICAgICAgICAgICAgIHkgPSAwO1xuICAgICAgICAgICAgaWYgKGluQSAmJiBpbkIpIHtcbiAgICAgICAgICAgICAgICB4ID0gaW5CLnBhZ2VYIC0gaW5BLnBhZ2VYO1xuICAgICAgICAgICAgICAgIHkgPSBpbkIucGFnZVkgLSBpbkEucGFnZVk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgIHg6IHgsXG4gICAgICAgICAgICAgICAgeTogeVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfSxcbiAgICAgICAgZmlyZVRyYWNrOiBmdW5jdGlvbihpblR5cGUsIGluRXZlbnQsIGluVHJhY2tpbmdEYXRhKSB7XG4gICAgICAgICAgICB2YXIgdCA9IGluVHJhY2tpbmdEYXRhO1xuICAgICAgICAgICAgdmFyIGQgPSB0aGlzLmNhbGNQb3NpdGlvbkRlbHRhKHQuZG93bkV2ZW50LCBpbkV2ZW50KTtcbiAgICAgICAgICAgIHZhciBkZCA9IHRoaXMuY2FsY1Bvc2l0aW9uRGVsdGEodC5sYXN0TW92ZUV2ZW50LCBpbkV2ZW50KTtcbiAgICAgICAgICAgIGlmIChkZC54KSB7XG4gICAgICAgICAgICAgICAgdC54RGlyZWN0aW9uID0gdGhpcy5jbGFtcERpcihkZC54KTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5UeXBlID09PSAndHJhY2t4Jykge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChkZC55KSB7XG4gICAgICAgICAgICAgICAgdC55RGlyZWN0aW9uID0gdGhpcy5jbGFtcERpcihkZC55KTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoaW5UeXBlID09PSAndHJhY2t5Jykge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBnZXN0dXJlUHJvdG8gPSB7XG4gICAgICAgICAgICAgICAgYnViYmxlczogdHJ1ZSxcbiAgICAgICAgICAgICAgICBjYW5jZWxhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIHRyYWNrSW5mbzogdC50cmFja0luZm8sXG4gICAgICAgICAgICAgICAgcmVsYXRlZFRhcmdldDogaW5FdmVudC5yZWxhdGVkVGFyZ2V0LFxuICAgICAgICAgICAgICAgIHBvaW50ZXJUeXBlOiBpbkV2ZW50LnBvaW50ZXJUeXBlLFxuICAgICAgICAgICAgICAgIHBvaW50ZXJJZDogaW5FdmVudC5wb2ludGVySWQsXG4gICAgICAgICAgICAgICAgX3NvdXJjZTogJ3RyYWNrJ1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIGlmIChpblR5cGUgIT09ICd0cmFja3knKSB7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnggPSBpbkV2ZW50Lng7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLmR4ID0gZC54O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5kZHggPSBkZC54O1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5jbGllbnRYID0gaW5FdmVudC5jbGllbnRYO1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5wYWdlWCA9IGluRXZlbnQucGFnZVg7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnNjcmVlblggPSBpbkV2ZW50LnNjcmVlblg7XG4gICAgICAgICAgICAgICAgZ2VzdHVyZVByb3RvLnhEaXJlY3Rpb24gPSB0LnhEaXJlY3Rpb247XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoaW5UeXBlICE9PSAndHJhY2t4Jykge1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5keSA9IGQueTtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uZGR5ID0gZGQueTtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ueSA9IGluRXZlbnQueTtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8uY2xpZW50WSA9IGluRXZlbnQuY2xpZW50WTtcbiAgICAgICAgICAgICAgICBnZXN0dXJlUHJvdG8ucGFnZVkgPSBpbkV2ZW50LnBhZ2VZO1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by5zY3JlZW5ZID0gaW5FdmVudC5zY3JlZW5ZO1xuICAgICAgICAgICAgICAgIGdlc3R1cmVQcm90by55RGlyZWN0aW9uID0gdC55RGlyZWN0aW9uO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIGUgPSBldmVudEZhY3RvcnkubWFrZUdlc3R1cmVFdmVudChpblR5cGUsIGdlc3R1cmVQcm90byk7XG4gICAgICAgICAgICB0LmRvd25UYXJnZXQuZGlzcGF0Y2hFdmVudChlKTtcbiAgICAgICAgfSxcbiAgICAgICAgZG93bjogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgaWYgKGluRXZlbnQuaXNQcmltYXJ5ICYmIChpbkV2ZW50LnBvaW50ZXJUeXBlID09PSAnbW91c2UnID8gaW5FdmVudC5idXR0b25zID09PSAxIDogdHJ1ZSkpIHtcbiAgICAgICAgICAgICAgICB2YXIgcCA9IHtcbiAgICAgICAgICAgICAgICAgICAgZG93bkV2ZW50OiBpbkV2ZW50LFxuICAgICAgICAgICAgICAgICAgICBkb3duVGFyZ2V0OiBpbkV2ZW50LnRhcmdldCxcbiAgICAgICAgICAgICAgICAgICAgdHJhY2tJbmZvOiB7fSxcbiAgICAgICAgICAgICAgICAgICAgbGFzdE1vdmVFdmVudDogbnVsbCxcbiAgICAgICAgICAgICAgICAgICAgeERpcmVjdGlvbjogMCxcbiAgICAgICAgICAgICAgICAgICAgeURpcmVjdGlvbjogMCxcbiAgICAgICAgICAgICAgICAgICAgdHJhY2tpbmc6IGZhbHNlXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldChpbkV2ZW50LnBvaW50ZXJJZCwgcCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIHZhciBwID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICAgICAgICBpZiAoIXAudHJhY2tpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSB0aGlzLmNhbGNQb3NpdGlvbkRlbHRhKHAuZG93bkV2ZW50LCBpbkV2ZW50KTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIG1vdmUgPSBkLnggKiBkLnggKyBkLnkgKiBkLnk7XG4gICAgICAgICAgICAgICAgICAgIC8vIHN0YXJ0IHRyYWNraW5nIG9ubHkgaWYgZmluZ2VyIG1vdmVzIG1vcmUgdGhhbiBXSUdHTEVfVEhSRVNIT0xEXG4gICAgICAgICAgICAgICAgICAgIGlmIChtb3ZlID4gdGhpcy5XSUdHTEVfVEhSRVNIT0xEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwLnRyYWNraW5nID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHAubGFzdE1vdmVFdmVudCA9IHAuZG93bkV2ZW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maXJlVHJhY2soJ3RyYWNrc3RhcnQnLCBpbkV2ZW50LCBwKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAocC50cmFja2luZykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVUcmFjaygndHJhY2snLCBpbkV2ZW50LCBwKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maXJlVHJhY2soJ3RyYWNreCcsI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1RIUkVTSE9MRCBwaXhlbHMgYmVmb3JlIG5vdCBjb3VudGluZyBhcyBhIGhvbGRcbiAgICAgICAgV0lHR0xFX1RIUkVTSE9MRDogMTYsXG4gICAgICAgIGV2ZW50czogW1xuICAgICAgICAgICAgJ2Rvd24nLFxuICAgICAgICAgICAgJ21vdmUnLFxuICAgICAgICAgICAgJ3VwJyxcbiAgICAgICAgXSxcbiAgICAgICAgZXhwb3NlczogW1xuICAgICAgICAgICAgJ2hvbGQnLFxuICAgICAgICAgICAgJ2hvbGRwdWxzZScsXG4gICAgICAgICAgICAncmVsZWFzZSdcbiAgICAgICAgXSxcbiAgICAgICAgaGVsZFBvaW50ZXI6IG51bGwsXG4gICAgICAgIGhvbGRKb2I6IG51bGwsXG4gICAgICAgIHB1bHNlOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciBob2xkID0gRGF0ZS5ub3coKSAtIHRoaXMuaGVsZFBvaW50ZXIudGltZVN0YW1wO1xuICAgICAgICAgICAgdmFyIHR5cGUgPSB0aGlzLmhlbGQgPyAnaG9sZHB1bHNlJyA6ICdob2xkJztcbiAgICAgICAgICAgIHRoaXMuZmlyZUhvbGQodHlwZSwgaG9sZCk7XG4gICAgICAgICAgICB0aGlzLmhlbGQgPSB0cnVlO1xuICAgICAgICB9LFxuICAgICAgICBjYW5jZWw6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgY2xlYXJJbnRlcnZhbCh0aGlzLmhvbGRKb2IpO1xuICAgICAgICAgICAgaWYgKHRoaXMuaGVsZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZUhvbGQoJ3JlbGVhc2UnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMuaGVsZCA9IGZhbHNlO1xuICAgICAgICAgICAgdGhpcy5oZWxkUG9pbnRlciA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLnRhcmdldCA9IG51bGw7XG4gICAgICAgICAgICB0aGlzLmhvbGRKb2IgPSBudWxsO1xuICAgICAgICB9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBpZiAoaW5FdmVudC5pc1ByaW1hcnkgJiYgIXRoaXMuaGVsZFBvaW50ZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmhlbGRQb2ludGVyID0gaW5FdmVudDtcbiAgICAgICAgICAgICAgICB0aGlzLnRhcmdldCA9IGluRXZlbnQudGFyZ2V0O1xuICAgICAgICAgICAgICAgIHRoaXMuaG9sZEpvYiA9IHNldEludGVydmFsKHRoaXMucHVsc2UuYmluZCh0aGlzKSwgdGhpcy5IT0xEX0RFTEFZKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgdXA6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmhlbGRQb2ludGVyICYmIHRoaXMuaGVsZFBvaW50ZXIucG9pbnRlcklkID09PSBpbkV2ZW50LnBvaW50ZXJJZCkge1xuICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmhlbGRQb2ludGVyICYmIHRoaXMuaGVsZFBvaW50ZXIucG9pbnRlcklkID09PSBpbkV2ZW50LnBvaW50ZXJJZCkge1xuICAgICAgICAgICAgICAgIHZhciB4ID0gaW5FdmVudC5jbGllbnRYIC0gdGhpcy5oZWxkUG9pbnRlci5jbGllbnRYO1xuICAgICAgICAgICAgICAgIHZhciB5ID0gaW5FdmVudC5jbGllbnRZIC0gdGhpcy5oZWxkUG9pbnRlci5jbGllbnRZO1xuICAgICAgICAgICAgICAgIGlmICgoeCAqIHggKyB5ICogeSkgPiB0aGlzLldJR0dMRV9USFJFU0hPTEQpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWwoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGZpcmVIb2xkOiBmdW5jdGlvbihpblR5cGUsIGluSG9sZFRpbWUpIHtcbiAgICAgICAgICAgIHZhciBwID0ge1xuICAgICAgICAgICAgICAgIGJ1YmJsZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBwb2ludGVyVHlwZTogdGhpcy5oZWxkUG9pbnRlci5wb2ludGVyVHlwZSxcbiAgICAgICAgICAgICAgICBwb2ludGVySWQ6IHRoaXMuaGVsZFBvaW50ZXIucG9pbnRlcklkLFxuICAgICAgICAgICAgICAgIHg6IHRoaXMuaGVsZFBvaW50ZXIuY2xpZW50WCxcbiAgICAgICAgICAgICAgICB5OiB0aGlzLmhlbGRQb2ludGVyLmNsaWVudFksXG4gICAgICAgICAgICAgICAgX3NvdXJjZTogJ2hvbGQnXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKGluSG9sZFRpbWUpIHtcbiAgICAgICAgICAgICAgICBwLmhvbGRUaW1lID0gaW5Ib2xkVGltZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQoaW5UeXBlLCBwKTtcbiAgICAgICAgICAgIHRoaXMudGFyZ2V0LmRpc3BhdGNoRXZlbnQoZSk7XG4gICAgICAgIH1cbiAgICB9O1xuICAgIGRpc3BhdGNoZXIucmVnaXN0ZXJHZXN0dXJlKCdob2xkJywgaG9sZCk7XG59KShleHBvcnRzKTtcblxuLyoqXG4gKiBUaGlzIGV2ZW50IGlzIGZpcmVkIHdoZW4gYSBwb2ludGVyIHF1aWNrbHkgZ29lcyBkb3duIGFuZCB1cCwgYW5kIGlzIHVzZWQgdG9cbiAqIGRlbm90ZSBhY3RpdmF0aW9uLlxuICpcbiAqIEFueSBnZXN0dXJ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W5FdmVudCkge1xuICAgICAgICAgICAgaWYgKGluRXZlbnQuaXNQcmltYXJ5ICYmICFpbkV2ZW50LnRhcFByZXZlbnRlZCkge1xuICAgICAgICAgICAgICAgIHBvaW50ZXJtYXAuc2V0KGluRXZlbnQucG9pbnRlcklkLCB7XG4gICAgICAgICAgICAgICAgICAgIHRhcmdldDogaW5FdmVudC50YXJnZXQsXG4gICAgICAgICAgICAgICAgICAgIGJ1dHRvbnM6IGluRXZlbnQuYnV0dG9ucyxcbiAgICAgICAgICAgICAgICAgICAgeDogaW5FdmVudC5jbGllbnRYLFxuICAgICAgICAgICAgICAgICAgICB5OiBpbkV2ZW50LmNsaWVudFlcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICAgICAgc2hvdWxkVGFwOiBmdW5jdGlvbihlLCBkb3duU3RhdGUpIHtcbiAgICAgICAgICAgIHZhciB0YXAgPSB0cnVlO1xuICAgICAgICAgICAgaWYgKGUucG9pbnRlclR5cGUgPT09ICdtb3VzZScpIHtcbiAgICAgICAgICAgICAgICAvLyBvbmx5IGFsbG93IGxlZnQgY2xpY2sgdG8gdGFwIGZvciBtb3VzZVxuICAgICAgICAgICAgICAgIHRhcCA9IChlLmJ1dHRvbnMgXiAxKSAmJiAoZG93blN0YXRlLmJ1dHRvbnMgJiAxKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0YXAgJiYgIWUudGFwUHJldmVudGVkO1xuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHN0YXJ0ID0gcG9pbnRlcm1hcC5nZXQoaW5FdmVudC5wb2ludGVySWQpO1xuICAgICAgICAgICAgaWYgKHN0YXJ0ICYmIHRoaXMuc2hvdWxkVGFwKGluRXZlbnQsIHN0YXJ0KSkge1xuICAgICAgICAgICAgICAgIC8vIHVwLnJlbGF0ZWRUYXJnZXQgaXMgdGFyZ2V0IGN1cnJlbnRseSB1bmRlciBmaW5nZXJcbiAgICAgICAgICAgICAgICB2YXIgdCA9IHNjb3BlLnRhcmdldEZpbmRpbmcuTENBKHN0YXJ0LnRhcmdldCwgaW5FdmVudC5yZWxhdGVkVGFyZ2V0KTtcbiAgICAgICAgICAgICAgICBpZiAodCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgZSA9IGV2ZW50RmFjdG9yeS5tYWtlR2VzdHVyZUV2ZW50KCd0YXAnLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBidWJibGVzOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGluRXZlbnQuY2xpZW50WCxcbiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGluRXZlbnQuY2xpZW50WSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogaW5FdmVudC5kZXRhaWwsXG4gICAgICAgICAgICAgICAgICAgICAgICBwb2ludGVyVHlwZTogaW5FdmVudC5wb2ludGVyVHlwZSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ZXJJZDogaW5FdmVudC5wb2ludGVySWQsXG4gICAgICAgICAgICAgICAgICAgICAgICBhbHRLZXk6IGluRXZlbnQuYWx0S2V5LFxuICAgICAgICAgICAgICAgICAgICAgICAgY3RybEtleTogaW5FdmVudC5jdHJsS2V5LFxuICAgICAgICAgICAgICAgICAgICAgICAgbWV0YUtleTogaW5FdmVudC5tZXRhS2V5LFxuICAgICAgICAgICAgICAgICAgICAgICAgc2hpZnRLZXk6IGluRXZlbnQuc2hpZnRLZXksXG4gICAgICAgICAgICAgICAgICAgICAgICBfc291cmNlOiAndGFwJ1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgdC5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAg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ICAgICAgJ3BpbmNoc3RhcnQnLFxuICAgICAgICAgICAgJ3BpbmNoJyxcbiAgICAgICAgICAgICdwaW5jaGVuZCcsXG4gICAgICAgICAgICAncm90YXRlJ1xuICAgICAgICBdLFxuICAgICAgICBkZWZhdWx0QWN0aW9uczoge1xuICAgICAgICAgICAgJ3BpbmNoJzogJ25vbmUnLFxuICAgICAgICAgICAgJ3JvdGF0ZSc6ICdub25lJ1xuICAgICAgICB9LFxuICAgICAgICByZWZlcmVuY2U6IHt9LFxuICAgICAgICBkb3duOiBmdW5jdGlvbihpbkV2ZW50KSB7XG4gICAgICAgICAgICBwb2ludGVybWFwLnNldChpbkV2ZW50LnBvaW50ZXJJZCwgaW5FdmVudCk7XG4gICAgICAgICAgICBpZiAocG9pbnRlcm1hcC5wb2ludGVycygpID09IDIpIHtcbiAgICAgICAgICAgICAgICB2YXIgcG9pbnRzID0gdGhpcy5jYWxjQ2hvcmQoKTtcbiAgICAgICAgICAgICAgICB2YXIgYW5nbGUgPSB0aGlzLmNhbGNBbmdsZShwb2ludHMpO1xuICAgICAgICAgICAgICAgIHRoaXMucmVmZXJlbmNlID0ge1xuICAgICAgICAgICAgICAgICAgICBhbmdsZTogYW5nbGUsXG4gICAgICAgICAgICAgICAgICAgIGRpYW1ldGVyOiBwb2ludHMuZGlhbWV0ZXIsXG4gICAgICAgICAgICAgICAgICAgIHRhcmdldDogc2NvcGUudGFyZ2V0RmluZGluZy5MQ0EocG9pbnRzLmEudGFyZ2V0LCBwb2ludHMuYi50YXJnZXQpXG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgIHRoaXMuZmlyZVBpbmNoKCdwaW5jaHN0YXJ0JywgcG9pbnRzLmRpYW1ldGVyLCBwb2ludHMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICB1cDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdmFyIHAgPSBwb2ludGVybWFwLmdldChpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICB2YXIgbnVtID0gcG9pbnRlcm1hcC5wb2ludGVycygpO1xuICAgICAgICAgICAgaWYgKHApIHtcbiAgICAgICAgICAgICAgICBpZiAobnVtID09PSAyKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGZpcmUgJ3BpbmNoZW5kJyBiZWZvcmUgZGVsZXRpbmcgcG9pbnRlclxuICAgICAgICAgICAgICAgICAgICB2YXIgcG9pbnRzID0gdGhpcy5jYWxjQ2hvcmQoKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maXJlUGluY2goJ3BpbmNoZW5kJywgcG9pbnRzLmRpYW1ldGVyLCBwb2ludHMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLmRlbGV0ZShpbkV2ZW50LnBvaW50ZXJJZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIG1vdmU6IGZ1bmN0aW9uKGluRXZlbnQpIHtcbiAgICAgICAgICAgIGlmIChwb2ludGVybWFwLmhhcyhpbkV2ZW50LnBvaW50ZXJJZCkpIHtcbiAgICAgICAgICAgICAgICBwb2ludGVybWFwLnNldChpbkV2ZW50LnBvaW50ZXJJZCwgaW5FdmVudCk7XG4gICAgICAgICAgICAgICAgaWYgKHBvaW50ZXJtYXAucG9pbnRlcnMoKSA+IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxjUGluY2hSb3RhdGUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNhbmNlbDogZnVuY3Rpb24oaW5FdmVudCkge1xuICAgICAgICAgICAgdGhpcy51cChpbkV2ZW50KTtcbiAgICAgICAgfSxcbiAgICAgICAgZmlyZVBpbmNoOiBmdW5jdGlvbih0eXBlLCBkaWFtZXRlciwgcG9pbnRzKSB7XG4gICAgICAgICAgICB2YXIgem9vbSA9IGRpYW1ldGVyIC8gdGhpcy5yZWZlcmVuY2UuZGlhbWV0ZXI7XG4gICAgICAgICAgICB2YXIgZSA9IGV2ZW50RmFjdG9yeS5tYWtlR2VzdHVyZUV2ZW50KHR5cGUsIHtcbiAgICAgICAgICAgICAgICBidWJibGVzOiB0cnVlLFxuICAgICAgICAgICAgICAgIGNhbmNlbGFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgc2NhbGU6IHpvb20sXG4gICAgICAgICAgICAgICAgY2VudGVyWDogcG9pbnRzLmNlbnRlci54LFxuICAgICAgICAgICAgICAgIGNlbnRlclk6IHBvaW50cy5jZW50ZXIueSxcbiAgICAgICAgICAgICAgICBfc291cmNlOiAncGluY2gnXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMucmVmZXJlbmNlLnRhcmdldC5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICB9LFxuICAgICAgICBmaXJlUm90YXRlOiBmdW5jdGlvbihhbmdsZSwgcG9pbnRzKSB7XG4gICAgICAgICAgICB2YXIgZGlmZiA9IE1hdGgucm91bmQoKGFuZ2xlIC0gdGhpcy5yZWZlcmVuY2UuYW5nbGUpICUgMzYwKTtcbiAgICAgICAgICAgIHZhciBlID0gZXZlbnRGYWN0b3J5Lm1ha2VHZXN0dXJlRXZlbnQoJ3JvdGF0ZScsIHtcbiAgICAgICAgICAgICAgICBidWJibGVzOiB0cnVlLFxuICAgICAgICAgICAgICAgIGNhbmNlbGFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgYW5nbGU6IGRpZmYsXG4gICAgICAgICAgICAgICAgY2VudGVyWDogcG9pbnRzLmNlbnRlci54LFxuICAgICAgICAgICAgICAgIGNlbnRlclk6IHBvaW50cy5jZW50ZXIueSxcbiAgICAgICAgICAgICAgICBfc291cmNlOiAncGluY2gnXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMucmVmZXJlbmNlLnRhcmdldC5kaXNwYXRjaEV2ZW50KGUpO1xuICAgICAgICB9LFxuICAgICAgICBjYWxjUGluY2hSb3RhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgdmFyIHBvaW50cyA9IHRoaXMuY2FsY0Nob3JkKCk7XG4gICAgICAgICAgICB2YXIgZGlhbWV0ZXIgPSBwb2ludHMuZGlhbWV0ZXI7XG4gICAgICAgICAgICB2YXIgYW5nbGUgPSB0aGlzLmNhbGNBbmdsZShwb2ludHMpO1xuICAgICAgICAgICAgaWYgKGRpYW1ldGVyICE9IHRoaXMucmVmZXJlbmNlLmRpYW1ldGVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlUGluY2goJ3BpbmNoJywgZGlhbWV0ZXIsIHBvaW50cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoYW5nbGUgIT0gdGhpcy5yZWZlcmVuY2UuYW5nbGUpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmZpcmVSb3RhdGUoYW5nbGUsIHBvaW50cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGNhbGNDaG9yZDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICB2YXIgcG9pbnRlcnMgPSBbXTtcbiAgICAgICAgICAgIHBvaW50ZXJtYXAuZm9yRWFjaChmdW5jdGlvbihwKSB7XG4gICAgICAgICAgICAgICAgcG9pbnRlcnMucHVzaChwKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdmFyIGRpc3QgPSAwO1xuICAgICAgICAgICAgLy8gc3RhcnQgd2l0aCBhdCBsZWFzdCB0d28gcG9pbnRlcnNcbiAgICAgICAgICAgIHZhciBwb2ludHMgPSB7XG4gICAgICAgICAgICAgICAgYTogcG9pbnRlcnNbMF0sXG4gICAgICAgICAgICAgICAgYjogcG9pbnRlcnNbMV1cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICB2YXIgeCwgeSwgZDtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcG9pbnRlcnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICB2YXIgYSA9IHBvaW50ZXJzW2ldO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIGogPSBpICsgMTsgaiA8IHBvaW50ZXJzLmxlbmd0aDsgaisrKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBiID0gcG9pbnRlcnNbal07XG4gICAgICAgICAgICAgICAgICAgIHggPSBNYXRoLmFicyhhLmNsaWVudFggLSBiLmNsaWVudFgpO1xuICAgICAgICAgICAgICAgICAgICB5ID0gTWF0aC5hYnMoYS5jbGllbnRZIC0gYi5jbGllbnRZKTtcbiAgICAgICAgICAgICAgICAgICAgZCA9IHggKyB5O1xuICAgICAgICAgICAgICAgICAgICBpZiAoZCA+IGRpc3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBkO1xuICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGEsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogYlxuICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHggPSBNYXRoLmFicyhwb2ludHMuYS5jbGllbnRYICsgcG9pbnRzLmIuY2xpZW50WCkgLyAyO1xuICAgICAgICAgICAgeSA9IE1hdGguYWJzKHBvaW50cy5hLmNsaWVudFkgKyBwb2ludHMuYi5jbGllbnRZKSAvIDI7XG4gICAgICAgICAgICBwb2ludHMuY2VudGVyID0ge1xuICAgICAgICAgICAgICAgIHg6IHgsXG4gICAgICAgICAgICAgICAgeTogeVxuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHBvaW50cy5kaWFtZXRlciA9IGRpc3Q7XG4gICAgICAgICAgICByZXR1cm4gcG9pbnRzO1xuICAgICAgICB9LFxuICAgICAgICBjYWxjQW5nbGU6IGZ1bmN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3Qud2lkdGgsXG4gICAgICAgICAgICAgICAgaGVpZ2h0OiByZWN0LmhlaWdodFxuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgbW9kZWxMaXN0LnJlY3QgPSByZWN0O1xuXG4gICAgICAgICAgICBpZiAocG9pbnRJblJlY3QocG9pbnQsIHJlY3QpKSB7XG4gICAgICAgICAgICAgICAgbW9kZWxMaXN0LnJlY3QgPSByZWN0O1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOyAvLyBmb3VuZFxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICBwb2ludEluSXRlbVJlY3RzOiBmdW5jdGlvbiAocG9pbnQsIGV4Y2VwdDEsIGV4Y2VwdDIpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuaXRlbXMuZmluZChmdW5jdGlvbiAoaXRlbSkge1xuICAgICAgICAgICAgdmFyIGVsZW1lbnQgPSBpdGVtLmVsZW1lbnQ7XG4gICAgICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgICAgIGVsZW1lbnQgIT09IGV4Y2VwdDEgJiZcbiAgICAgICAgICAgICAgICBlbGVtZW50ICE9PSBleGNlcHQyICYmXG4gICAgICAgICAgICAgICAgcG9pbnRJblJlY3QocG9pbnQsIGl0ZW0ucmVjdClcbiAgICAgICAgICAgICk7XG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICAvLyBnZXQgcG9zaXRpb25zIG9mIGFsbCBsaXN0IGl0ZW1zIGluIHBhZ2UgY29vcmRzIChub3JtYWxpemVkIGZvciB3aW5kb3cgYW5kIGxpc3Qgc2Nyb2xsaW5nKVxuICAgIGdldEFsbEl0ZW1Cb3VuZGluZ1JlY3RzOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBtb2RlbExpc3RzID0gdGhpcy5tb2RlbExpc3RzLCBoZWlnaH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m91bmRpbmdDbGllbnRSZWN0KCkuYm90dG9tO1xuICAgICAgICAgICAgICAgICAgICBpZiAoYm90dG9tIDwgcmVjdC50b3ApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJvdHRvbSA9IHJlY3QudG9wICsgKGhlaWdodCB8fCA1MCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBoZWlnaHQgPSByZWN0LmhlaWdodDtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZWN0ID0ge1xuICAgICAgICAgICAgICAgICAgICBsZWZ0OiAgIHdpbmRvdy5zY3JvbGxYICsgcmVjdC5sZWZ0LFxuICAgICAgICAgICAgICAgICAgICByaWdodDogIHdpbmRvdy5zY3JvbGxYICsgcmVjdC5yaWdodCxcbiAgICAgICAgICAgICAgICAgICAgdG9wOiAgICB3aW5kb3cuc2Nyb2xsWSArIHJlY3QudG9wICAgICsgbGlzdEVsZW1lbnQuc2Nyb2xsVG9wLFxuICAgICAgICAgICAgICAgICAgICBib3R0b206IHdpbmRvdy5zY3JvbGxZICsgYm90dG9tICsgbGlzdEVsZW1lbnQuc2Nyb2xsVG9wXG4gICAgICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgICAgIGl0ZW0ucmVjdCA9IHJlY3Q7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICByZWluc2VydDogZnVuY3Rpb24gKHRhcmdldCkge1xuICAgICAgICB2YXIgc3R5bGUgPSB0YXJnZXQuc3R5bGU7XG4gICAgICAgIHN0eWxlLndpZHRoID0gc3R5bGVbdHJhbnNmb3JtXSA9IHN0eWxlLnRyYW5zaXRpb24gPSBSRVZFUlRfVE9fU1RZTEVTSEVFVF9WQUxVRTtcblxuICAgICAgICB0YXJnZXQuY2xhc3NMaXN0LnJlbW92ZSgnZHJhZ29uLXBvcCcpO1xuXG4gICAgICAgIH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AgICAgICAgICAgICAgICAgLy8gbW91c2UgbmVhciBvciBiZWxvdyBib3R0b20gYW5kIGxpc3Qgbm90IHNjcm9sbGVkIHRvIGJvdHRvbSB5ZXRcbiAgICAgICAgICAgICAgICAgICAgcmVzZXRBdXRvU2Nyb2xsVGltZXIobWFnbml0dWRlLCBtYXhTY3JvbGxZLCBob3Zlckxpc3QuZWxlbWVudCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gbW91c2UgaW5zaWRlXG4gICAgICAgICAgICAgICAgICAgIHJlc2V0QXV0b1Njcm9sbFRpbWVyKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgb3RoZXIgPSBkcmFnb24ucG9pbnRJbkl0ZW1SZWN0cyh7XG4gICAgICAgICAgICAgICAgeDogZXZ0LmNsaWVudFgsXG4gICAgICAgICAgICAgICAgeTogZHJhZ29uLnJlY3QuYm90dG9tICsgd2luZG93LnNjcm9sbFkgKyBkeSArIGhvdmVyTGlzdC5lbGVtZW50LnNjcm9sbFRvcFxuICAgICAgICAgICAgfSwgdGhpcywgZHJhZ29uLmRyb3ApO1xuXG4gICAgICAgICAgICB0aGlzLnN0eWxlW3RyYW5zZm9ybV0gPSB0cmFuc2xhdGUoXG4gICAgICAgICAgICAgICAgZHJhZ29uLnJlY3QubGVmdCAtIHdpbmRvdy5zY3JvbGxYICsgZHgsXG4gICAgICAgICAgICAgICAgZHJhZ29uLnJlY3QudG9wIC0gd2luZG93LnNjcm9sbFkgKyBkeVxuICAgICAgICAgICAgKTtcblxuICAgICAgICAgICAgaWYgKG90aGVyKSB7XG4gICAgICAgICAgICAgICAgdmFyIGVsZW1lbnQgPSBvdGhlci5lbGVtZW50O1xuICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUudHJhbnNpdGlvbiA9IFJFVkVSVF9UT19TVFlMRVNIRUVUX1ZBTFVFO1xuICAgICAgICAg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Njcm9sbFZlbG9jaXR5ID4gMCAmJiBzY3JvbGxUb3AgPiBsaW1pdCkge1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNjcm9sbFRvcCA9IGxpbWl0O1xuICAgICAgICAgICAgICAgICAgICBjbGVhckludGVydmFsKHRpbWVyKTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNjcm9sbFRvcCA9IHNjcm9sbFRvcDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCAxMjUpO1xuICAgICAgICB9XG4gICAgfVxufVxuXG5mdW5jdGlvbiB0b0FycmF5KGFycmF5TGlrZU9iamVjdCkge1xuICAgIHJldHVybiBBcnJheS5wcm90b3R5cGUuc2xpY2UuY2FsbChhcnJheUxpa2VPYmplY3QpO1xufVxuXG5mdW5jdGlvbiBwb2ludEluUmVjdChwb2ludCwgcmVjdCkge1xuICAgIHJldHVybiByZWN0LnRvcCA8PSBwb2ludC55ICYmIHBvaW50LnkgPD0gcmVjdC5ib3R0b21cbiAgICAgICAgJiYgcmVjdC5sZWZ0IDw9IHBvaW50LnggJiYgcG9pbnQueCA8PSByZWN0LnJpZ2h0O1xufVxuXG5mdW5jdGlvbiB0cmFuc2xhdGUobGVmdCwgdG9wKSB7XG4gICAgcmV0dXJuICd0cmFuc2xhdGUoJ1xuICAgICAgICArIE1hdGguZmxvb3IobGVmdCArIHdpbmRvdy5zY3JvbGxYKSArICdweCwnXG4gICAgICAgICsgTWF0aC5mbG9vcih0b3AgKyB3aW5kb3cuc2Nyb2xsWSkgKyAncHgpJztcbn1cblxuZnVuY3Rpb24gaHRtbEVuY29kZShzdHJpbmcpIHtcbiAgICB2YXIgdGV4dE5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShzdHJpbmcpO1xuXG4gICAgcmV0dXJuIGRvY3VtZW50XG4gICAgICAgIC5jcmVhdGVFbGVtZW50KCdhJylcbiAgICAgICAgLm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AuXG4gICAgICogQHBhcmFtIHtQb2ludH0gcG9pbnQgLSBBIHBvaW50IHRvIGNvbXBhcmUgdG8gdGhpcyBwb2ludC5cbiAgICAgKiBAbWVtYmVyT2YgUG9pbnQucHJvdG90eXBlXG4gICAgICovXG4gICAgbWF4OiBmdW5jdGlvbihwb2ludCkge1xuICAgICAgICByZXR1cm4gbmV3IFBvaW50KFxuICAgICAgICAgICAgTWF0aC5tYXgodGhpcy54LCBwb2ludC54KSxcbiAgICAgICAgICAgIE1hdGgubWF4KHRoaXMueSwgcG9pbnQueSlcbiAgICAgICAgKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQHJldHVybnMge251bWJlcn0gRGlzdGFuY2UgYmV0d2VlbiBnaXZlbiBgcG9pbnRgIGFuZCB0aGlzIHBvaW50IHVzaW5nIFB5dGhhZ29yZWFuIFRoZW9yZW0gZm9ybXVsYS5cbiAgICAgKiBAcGFyYW0ge1BvaW50fSBwb2ludCAtIEEgcG9pbnQgZnJvbSB3aGljaCB0byBjb21wdXRlIHRoZSBkaXN0YW5jZSB0byB0aGlzIHBvaW50LlxuICAgICAqIEBtZW1iZXJPZiBQb2ludC5wcm90b3R5cGVcbiAgICAgKi9cbiAgICBkaXN0YW5jZTogZnVuY3Rpb24ocG9pbnQpIHtcbiAgICAgICAgdmFyIGRlbHRhWCA9IHBvaW50LnggLSB0aGlzLngsXG4gICAgICAgICAgICBkZWx0YVkgPSBwb2ludC55IC0gdGhpcy55O1xuXG4gICAgICAgIHJldHVybiBNYXRoLnNxcnQoXG4gICAgICAgICAgICBkZWx0YVggKiBkZWx0YVggK1xuICAgICAgICAgICAgZGVsdGFZICogZGVsdGFZXG4gICAgICAgICk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIF8oRm9ybWVybHk6IGBlcXVhbGAuKV9cbiAgICAgKiBAcmV0dXJucyB7Ym9vbGVhbn0gYHRydWVgIGlmZiBfYm90aF8gY29vcmRpbmF0ZXMgb2YgdGhpcyBwb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GhhbiBvciBlcXVhbCB0byB0aG9zZSBvZiBnaXZlbiBgcG9pbnRgLlxuICAgICAqIEBwYXJhbSB7UG9pbnR9IHBvaW50IC0gQSBwb2ludCB0byBjb21wYXJlIHRvIHRoaXMgcG9pbnQuXG4gICAgICogQG1lbWJlck9mIFBvaW50LnByb3RvdHlwZVxuICAgICAqL1xuICAgIGxlc3NUaGFuT3JFcXVhbFRvOiBmdW5jdGlvbihwb2ludCkge1xuICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgdGhpcy54IDw9IHBvaW50LnggJiZcbiAgICAgICAgICAgIHRoaXMueSA8PSBwb2ludC55XG4gICAgICAgICk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIF8oRm9ybWVybHkgYGlzQ29udGFpbmVkV2l0aGluUmVjdGFuZ2xlYC4pX1xuICAgICAqIEBwYXJhbSByZWN0IHtSZWN0YW5nbGV9IC0gUmVjdGFuZ2xlIHRvIHRlc3QgdGhpcyBwb2ludCBhZ2FpbnN0LlxuICAgICAqIEByZXR1cm5zIHtib29sZWFufSBgdHJ1ZWAgaWZmIHRoaXMgcG9pbnQgaXMgd2l0aGluIGdpdmVuIGByZWN0YC5cbiAgICAgKiBAbWVtYmVyT2YgUG9pbnQucHJvdG90eXBlXG4gICAgICovXG4gICAgd2l0aGluOiBmdW5jdGlvbihyZWN0KSB7XG4gICAgICAgIHZhciBtaW5YID0gcmVjdC5vcmlnaW4ueCxcbiAgICAgICAgICAgIG1heFggPSBtaW5YICsgcmVjdC5leHRlbnQueDtcbiAgICAgICAgdmFyIG1pblkgPSByZWN0Lm9yaWdpbi55LFxuICAgICAgICAgICAgbWF4WSA9IG1pblkgKyByZWN0LmV4dGVudC55O1xuXG4gICAgICAgIGlmIChyZWN0LmV4dGVudC54IDwgMCkge1xuICAgICAgICAgICAgbWluWCA9IG1heFg7XG4gICAgICAgICAgICBtYXhYID0gcmVjdC5vcmlnaW4ueDtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh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b3IgKGkgPSAwOyBpIDwgYWdlczsgKytpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS53aGVuIDwgYWdlW2ldLml0ZW0ud2hlbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGFnZS5zcGxpY2UoaSwgMCwgeyBrZXk6IGtleSwgaXRlbTogaXRlbSB9KTtcbiAgICAgICAgICAgICAgICAgICAgYWdlcysrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICghYWdlLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgIHJldHVybiByZWdFeHBMSUtFKHBhdHRlcm4sIGlnbm9yZUNhc2UpOyAvLyBjYWNoZSBpcyBmdWxsIVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaSA9IE1hdGguY2VpbChhZ2UubGVuZ3RoIC8gMTApOyAvLyB3aWxsIGFsd2F5cyBiZSBhdCBsZWFzdCAxXG4gICAgICAgICAgICBzaXplIC09IGk7XG4gICAgICAgICAgICB3aGlsZSAoaS0tKSB7XG4gICAgICAgICAgICAgICAgZGVsZXRlIGNhY2hlW2FnZVtpXS5rZXldO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGl0ZW0gPSBjYWNoZVtwYXR0ZXJuQW5kQ2FzZV0gPSB7XG4gICAgICAgICAgICByZWdleDogcmVnRXhwTElLRShwYXR0ZXJuLCBpZ25vcmVDYXNlKSxcbiAgICAgICAgICAgIGtlZXA6IGtlZXAsXG4gICAgICAgICAgICB3aGVuOiBuZXcgRGF0ZSgpLmdldFRpbWUoKVxuICAgICAgICB9O1xuICAgICAgICBzaXplKys7XG4gICAgfVxuICAgIHJldHVybiBpdGVtLnJlZ2V4O1xufTtcblxubW9kdWxlLmV4cG9ydHMgPSByZWdFeHBM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uZmlyZVN5bnRoZXRpY01vdXNlRG93bkV2ZW50KG1vdXNlRXZlbnQpO1xuICAgICAgICAgICAgc2VsZi5yZXBhaW50KCk7XG4gICAgICAgIH0pO1xuXG5cbiAgICAgICAgLy8gdGhpcy5hZGRFdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLWNsaWNrJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAvLyAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgIC8vICAgICAgICAgcmV0dXJuO1xuICAgICAgICAvLyAgICAgfVxuICAgICAgICAvLyAgICAgLy9zZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgIC8vICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgLy8gICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgLy8gICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAvLyAgICAgc2VsZi5maXJlU3ludGhldGljQ2xpY2tFdmVudChtb3VzZUV2ZW50KTtcbiAgICAgICAgLy8gfSk7XG5cbiAgICAgICAgdGhpcy5hZGRFdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLW1vdXNldXAnLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBzZWxmLmRyYWdnaW5nID0gZmFsc2U7XG4gICAgICAgICAgICBpZiAoc2VsZi5pc1Njcm9sbGluZ05vdygpKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5zZXRTY3JvbGxpbmdOb3coZmFsc2UpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHNlbGYuY29sdW1uRHJhZ0F1dG9TY3JvbGxpbmcpIHtcbiAgICAgICAgICAgICAgICBzZWxmLmNvbHVtbkRyYWdBdXRvU2Nyb2xsaW5nID0gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvL3NlbGYuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAgICAgdmFyIG1vdXNlRXZlbnQgPSBzZWxmLmdldEdyaWRDZWxsRnJvbU1vdXNlUG9pbnQobW91c2UpO1xuICAgICAgICAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlTW91c2VVcChtb3VzZUV2ZW50KTtcbiAgICAgICAgICAgIGlmIChzZWxmLm1vdXNlRG93blN0YXRlKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljQnV0dG9uUHJlc3NlZEV2ZW50KHNlbGYubW91c2VEb3duU3RhdGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5tb3VzZURvd25TdGF0ZSA9IG51bGw7XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNNb3VzZVVwRXZlbnQobW91c2VFdmVudCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1kYmxjbGljaycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBtb3VzZSA9IGUuZGV0YWlsLm1vdXNlO1xuICAgICAgICAgICAgdmFyIG1vdXNlRXZlbnQgPSBzZWxmLmdldEdyaWRDZWxsRnJvbU1vdXNlUG9pbnQobW91c2UpO1xuICAgICAgICAgICAgbW91c2VFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICBzZWxmLmZpcmVTeW50aGV0aWNEb3VibGVDbGlja0V2ZW50KG1vdXNlRXZlbnQsIGUpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZURvdWJsZUNsaWNrKG1vdXNlRXZlbnQpO1xuICAgICAgICB9KTtcblxuICAgICAgICB0aGlzLmFkZEV2ZW50TGlzdGVuZXIoJ2Zpbi1jYW52YXMtdGFwJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy9zZWxmLnN0b3BFZGl0aW5nKCk7XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciB0YXBFdmVudCA9IHNlbGYuZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludChtb3VzZSk7XG4gICAgICAgICAgICB0YXBFdmVudC5wcmltaXRpdmVFdmVudCA9IGU7XG4gICAgICAgICAgICB0YXBFdmVudC5rZXlzID0gZS5kZXRhaWwua2V5cztcbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0NsaWNrRXZlbnQodGFwRXZlbnQpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZVRhcCh0YXBFdmVudCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1kcmFnJywgZnVuY3Rpb24oZSkge1xuICAgICAgICAgICAgaWYgKHNlbGYucmVzb2x2ZVByb3BlcnR5KCdyZWFkT25seScpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5kcmFnZ2luZyA9IHRydWU7XG4gICAgICAgICAgICB2YXIgbW91c2UgPSBlLmRldGFpbC5tb3VzZTtcbiAgICAgICAgICAgIHZhciBtb3VzZUV2ZW50ID0gc2VsZi5nZXRHcmlkQ2VsbEZyb21Nb3VzZVBvaW50KG1vdXNlKTtcbiAgICAgICAgICAgIG1vdXNlRXZlbnQucHJpbWl0aXZlRXZlbnQgPSBlO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZU1vdXNlRHJhZyhtb3VzZUV2ZW50KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5hZGRFdmVudExpc3RlbmVyKCdmaW4tY2FudmFzLWtleWRvd24nLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ3JlYWRPbmx5JykpIHtcbiAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoc2VsZi5yZXNvbHZlUHJvcGVydHkoJ2VkaXRPbktleWRvd24nKSkge1xuICAgICAgICAgICAgICAgIHZhciBjaGFyID0gZS5kZXRhaWwuY2hhcixcbiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlQ2hhciwgaXNEZWxldGVDaGFyLCBjdXJyZW50Q2VsbCwgZWRpdG9yO1xuXG4gICAgICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgICAgICAhc2VsZi5pc0VkaXRpbmcoKSAmJlxuICAgICAgICAgICAgICAgICAgICAoXG4gICAgICAgICAgICAgICAgICAgICAgICBjaGFyID09PSAnRjInIHx8XG4gICAgICAgICAgICAgICAgICAgICAgICAoaXNWaXNpYmxlQ2hhciA9IGNoYXIubGVuZ3RoID09PSAxKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgKGlzRGVsZXRlQ2hhciA9IGNoYXIgPT09ICdERUxFVEUnIHx8IGNoYXIgPT09ICdCQUNLU1BBQ0UnKVxuICAgICAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDZWxsID0gc2VsZi5zZWxlY3Rpb25Nb2RlbC5nZXRMYXN0U2VsZWN0aW9uKCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50Q2VsbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yID0gc2VsZi5hY3RpdmF0ZUVkaXRvcihjdXJyZW50Q2VsbC5vcmlnaW4ueCwgY3VycmVudENlbGwub3JpZ2luLnkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvciBpbnN0YW5jZW9mIEh5cGVyZ3JpZC5jZWxsRWRpdG9ycy5TaW1wbGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNWaXNpYmxlQ2hhcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaW5wdXQudmFsdWUgPSBjaGFyO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXNEZWxldGVDaGFyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pbnB1dC52YWx1ZSA9ICcnO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlLmRldGFpbC5wcmltaXRpdmVFdmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5maXJlU3ludGhldGljS2V5ZG93bkV2ZW50KGUpO1xuICAgICAgICAgICAgc2VsZi5kZWxlZ2F0ZUtleURvd24oZSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy1rZXl1cCcsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHNlbGYuZmlyZVN5bnRoZXRpY0tleXVwRXZlbnQoZSk7XG4gICAgICAgICAgICBzZWxmLmRlbGVnYXRlS2V5VXAoZSk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWRkRXZlbnRMaXN0ZW5lcignZmluLWNhbnZhcy10cmFjaycsIGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgIGlmIChzZWxmLnJlc29sdmVQcm9wZXJ0eSgncmVhZE9ubHknKSkge1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzZWxmLmRyYWdnaW5nKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdmFyIHByaW1FdmVudCA9IGUuZGV0YWlsLnByaW1pdGl2ZUV2ZW50O1xuICAgICAgICAgICAgaWYgKE1hdGguYWJzKHByaW1FdmVudC5keSkgPiBNYXRoLmFicyhwcmltRXZlbnQuZHgpKSB7XG4gICAgICAgICAgICAgICAgaWYgKHByaW1FdmVudC55RGlyZWN0aW9uID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbFZCeSgtMik7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwcmltRXZlbnQueURpcmVjdGlvbiA8IC0wKSB7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuc2Nyb2xsVkJ5KDIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHByaW1FdmVudC54RGlyZWN0aW9uID4gMCkge1xuICAgICAgICAgICAgICAgICAgICBzZWxmLnNjcm9sbE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AgYW5kL29yIGAnYm90dG9tJ2BcbiAgICAgKi9cbiAgICBmaXJlU3ludGhldGljU2V0VG90YWxzVmFsdWU6IGZ1bmN0aW9uKHgsIHksIHZhbHVlLCBhcmVhcykge1xuICAgICAgICB2YXIgY2xpY2tFdmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLXNldC10b3RhbHMtdmFsdWUnLCB7XG4gICAgICAgICAgICBkZXRhaWw6IHtcbiAgICAgICAgICAgICAgICB4OiB4LFxuICAgICAgICAgICAgICAgIHk6IHksXG4gICAgICAgICAgICAgICAgdmFsdWU6IHZhbHVlLFxuICAgICAgICAgICAgICAgIGFyZWFzOiBhcmVhc1xuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChjbGlja0V2ZW50KTtcbiAgICB9LFxuXG4gICAgZmlyZVN5bnRoZXRpY0VkaXRvcktleVVwRXZlbnQ6IGZ1bmN0aW9uKGlucHV0Q29udHJvbCwga2V5RXZlbnQpIHtcbiAgICAgICAgdmFyIGNsaWNrRXZlbnQgPSBuZXcgQ3VzdG9tRXZlbnQoJ2Zpbi1lZGl0b3Ita2V5dXAnLCB7XG4gICAgICAgICAgICBkZXRhaWw6IHtcbiAgICAgICAgICAgICAgICBpbnB1dDogaW5wdXRDb250cm9sLFxuICAgICAgICAgICAgICAgIGtleUV2ZW50OiBrZXlFdmVudFxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdGhpcy5jYW52YXMuZGlzcGF0Y2hFdmVudChjbGlja0V2ZW50KTtcbiAgICB9LFxuXG4gICAgZmlyZVN5bnRoZXRpY0VkaXRvcktleURvd25FdmVudDogZnVuY3Rpb24oaW5wdXRDb250cm9sLCBrZXlFdmVudCkge1xuICAgICAgICB2YXIgY2xpY2tFdmVudCA9IG5ldyBDdXN0b21FdmVudCgnZmluLWVkaXRvci1rZXlkb3duJywge1xuICAgICAgICAgICAgZGV0YWlsOiB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aW9ucy5sZW5ndGgpO1xuICAgICAgICBzZWxlY3Rpb25zLmZvckVhY2goZnVuY3Rpb24oc2VsZWN0aW9uUmVjdCwgaSkge1xuICAgICAgICAgICAgcmVzdWx0W2ldID0gc2VsZi5fZ2V0U2VsZWN0aW9uTWF0cml4KHNlbGVjdGlvblJlY3QpO1xuICAgICAgICB9KTtcbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9LFxuXG4gICAgX2dldFNlbGVjdGlvbk1hdHJpeDogZnVuY3Rpb24ocmVjdCkge1xuICAgICAgICByZWN0ID0gbm9ybWFsaXplUmVjdChyZWN0KTtcbiAgICAgICAgdmFyIGNvbENvdW50ID0gcmVjdC5leHRlbnQueCArIDE7XG4gICAgICAgIHZhciByb3dDb3VudCA9IHJlY3QuZXh0ZW50LnkgKyAxO1xuICAgICAgICB2YXIgb3ggPSByZWN0Lm9yaWdpbi54O1xuICAgICAgICB2YXIgb3kgPSByZWN0Lm9yaWdpbi55O1xuICAgICAgICB2YXIgcmVzdWx0ID0gW107XG4gICAgICAgIGZvciAodmFyIGMgPSAwOyBjIDwgY29sQ291bnQ7IGMrKykge1xuICAgICAgICAgICAgdmFyIGNvbHVtbiA9IG5ldyBBcnJheShyb3dDb3VudCk7XG4gICAgICAgICAgICByZXN1bHRbY10gPSBjb2x1bW47XG4gICAgICAgICAgICBmb3IgKHZhciByID0gMDsgciA8IHJvd0NvdW50OyByKyspIHtcbiAgICAgICAgICAgICAgICBjb2x1bW5bcl0gPSB2YWx1ZU9yRnVuY3Rpb25FeGVjdXRlKHRoaXMuZ2V0VmFsdWUob3ggKyBjLCBveSArIHIpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgIH0sXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEh5cGVyZ3JpZC5wcm90b3R5cGVcbiAgICAgKiBAZGVzYyBTeW50aGVzaXplIGFuZCBmaXJlIGEgYGZpbi1jb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ZENlbGw6IGUuZ3JpZENlbGwsXG4gICAgICAgICAgICAgICAgbW91c2VQb2ludDogZS5tb3VzZVBvaW50LFxuICAgICAgICAgICAgICAgIHZpZXdQb2ludDogZS52aWV3UG9pbnQsXG4gICAgICAgICAgICAgICAgcHJpbWl0aXZlRXZlbnQ6IGUucHJpbWl0aXZlRXZlbnQsXG4gICAgICAgICAgICAgICAgcm93czogdGhpcy5nZXRTZWxlY3RlZFJvd3MoKSxcbiAgICAgICAgICAgICAgICBjb2x1bW5zOiB0aGlzLmdldFNlbGVjdGVkQ29sdW1ucygpLFxuICAgICAgICAgICAgICAgIHNlbGVjdGlvbnM6IHRoaXMuc2VsZWN0aW9uTW9kZWwuZ2V0U2VsZWN0aW9ucygpXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgICB0aGlzLmNhbnZhcy5kaXNwYXRjaEV2ZW50KGV2ZW50KTtcbiAgICB9LFxuXG4gICAgZmlyZVN5bnRoZXRpY01vdXNlRG93bkV2ZW50OiBmdW5jdGlvbihlKSB7XG4gICAgICAgIHRoaXMuc3RvcEVkaXRpbmcoKTtcbiAgICAgICAgdmFyIGV2ZW50ID0gbmV3IEN1c3RvbUV2ZW50KCdmaW4tbW91c2Vkb3duJywge1xuICAgICAgICAgICAgZGV0YWlsOiB7XG4gICAgICAgICAgICAgICAgZ3JpZENlbGw6IGUuZ3JpZENlbGwsXG4gICAgICAgICAgICAgICAgbW91c2VQb2ludDogZS5tb3VzZVBvaW50LFxuICAgICAgICAgICAgICAgIHZpZXdQb2ludDogZS52aWV3UG9pbnQsXG4gICAgICAgICAgICAgICAgcHJpbWl0aXZlRXZlbnQ6IGUucHJpbWl0aXZlRXZlbnQsXG4gICAgICAgICAgICAgICAgcm93czogdGhpcy5nZXRTZWxlY3RlZFJvd3MoKSxcbiAgICAgICAgICAgICAgICBjb2x1bW5zOiB0aGlzLmdldFNlbGVjdGVkQ29sdW1ucygpLFxuICAgICAgICAgICAgICAgIHNlbGVjdGl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XG4gICAgICogQHJldHVybnMge0NlbGxFZGl0b3J9IChvciBvYmplY3RlZCBleHRlbmRlZCBmcm9tIHNhbWUpIFRoZSBlZGl0b3Igb2JqZWN0LlxuICAgICAqL1xuICAgIGFjdGl2YXRlRWRpdG9yOiBmdW5jdGlvbih4LCB5KSB7XG4gICAgICAgIHZhciBlZGl0b3I7XG5cbiAgICAgICAgaWYgKHRoaXMuaXNFZGl0YWJsZSgpIHx8IHRoaXMuaXNGaWx0ZXJSb3coeSkpIHtcbiAgICAgICAgICAgIGVkaXRvciA9IHRoaXMuZ2V0Q2VsbEVkaXRvckF0KHgsIHkpO1xuXG4gICAgICAgICAgICBpZiAoZWRpdG9yKSB7XG4gICAgICAgICAgICAgICAgdmFyIHBvaW50ID0gZWRpdG9yLmdldEVkaXRvclBvaW50KCk7XG4gICAgICAgICAgICAgICAgaWYgKGVkaXRvcikge1xuICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnQueCA9PT0geCAmJiBwb2ludC55ID09PSB5ICYmIGVkaXRvci5pc0VkaXRpbmcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsgLy93ZSdyZSBhbHJlYWR5IG9wZW4gYXQgdGhpcyBsb2NhdGlvblxuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFZGl0aW5nKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RvcEVkaXRpbmcoKTsgLy9vdGhlciBlZGl0b3IgaXMgb3BlbiwgY2xvc2UgaXQgZmlyc3RcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBldmVudC5ncmlkQ2VsbCA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHg6IHgsXG4gICAgICAgICAgICAgICAgICAgICAgICB5OiB5XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdEF0KGVkaXRvci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ih4KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGlmIChoYXNDVFJMKSB7XG4gICAgICAgICAgICAgICAgaWYgKGFscmVhZHlTZWxlY3RlZCkge1xuICAgICAgICAgICAgICAgICAgICBtb2RlbC5kZXNlbGVjdENvbHVtbih4KTtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBtb2RlbC5zZWxlY3RDb2x1bW4oeCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGhhc1NISUZUKSB7XG4gICAgICAgICAgICAgICAgbW9kZWwuY2xlYXIoKTtcbiAgICAgICAgICAgICAgICBtb2RlbC5zZWxlY3RDb2x1bW4odGhpcy5sYXN0RWRnZVNlbGVjdGlvblswXSwgeCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFhbHJlYWR5U2VsZWN0ZWQgJiYgIWhhc1NISUZUKSB7XG4gICAgICAgICAgICB0aGlzLmxhc3RFZGdlU2VsZWN0aW9uWzBdID0geDtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnJlcGFpbnQoKTtcbiAgICAgICAgdGhpcy5maXJlU3ludGhldGljQ29sdW1uU2VsZWN0aW9uQ2hhbmdlZEV2ZW50KCk7XG4gICAgfSxcblxuICAgIHRvZ2dsZVNlbGVjdFJvdzogZnVuY3Rpb24oeSwga2V5cykge1xuICAgICAgICAvL3dlIGNhbiBzZWxlY3QgdGhlIHRvdGFscyByb3dzIGlmIHRoZXkgZXhpc3QsIGJ1dCBub3Qgcm93cyBhYm92ZSB0aGF0XG4gICAgICAgIGlmICh5ID4gdGhpcy5nZXRGaWx0ZXJSb3dJbmRleCgpKSB7XG4gICAgICAgICAgICBrZXlzID0ga2V5cyB8fCBbXTtcblxuICAgICAgICAgICAgdmFyIHNtID0gdGhpcy5zZWxlY3Rpb25Nb2RlbDtcbiAgICAgICAgICAgIHZhciBhbHJlYWR5U2VsZWN0ZWQgPSBzbS5pc1Jvd1NlbGVjdGVkKHkpO1xuICAgICAgICAgICAgdmFyIGhhc1NISUZUID0ga2V5cy5pbmRleE9mKCdTSElGVCcpID49IDA7XG5cbiAgICAgICAgICAgIGlmIChhbHJlYWR5U2VsZWN0ZWQpIHtcbiAgICAgICAgICAgICAgICBzbS5kZXNlbGVjdFJvdyh5KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zaW5nbGVTZWxlY3QoKTtcbiAgICAgICAgICAgICAgICBzbS5zZWxlY3RSb3coeSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChoYXNTSElGVCkge1xuICAgICAgICAgICAgICAgIHNtLmNsZWFyKCk7XG4gICAgICAgICAgICAgICAgc20uc2VsZWN0Um93KHRoaXMubGFzdEVkZ2VTZWxlY3Rpb25bMV0sIHkpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoIWFscmVhZHlTZWxlY3RlZCAmJiAhaGFzU0hJRlQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmxhc3RFZGdlU2VsZWN0aW9uWzFdID0geTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRoaXMucmVwYWludCgpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIHNpbmdsZVNlbGVjdDogZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBpc0NoZWNrYm94T25seVJvd1NlbGVjdGlvbnMgPSB0aGlzLmlzQ2hlY2tib3hPbmx5Um93U2VsZWN0aW9ucygpLFxuICAgICAgICAgICAgaXNTaW5nbGVSb3dTZWxlY3Rpb25Nb2RlID0gdGhpcy5pc1NpbmdsZVJvd1NlbGVjdGlvbk1vZGUoKSxcbiAgICAgICAgICAgIGhhc0NUUkwgPSB0aGlzLm1vdXNlRG93blN0YXRlLnByaW1pdGl2ZUV2ZW50LmRldGFpbC5wcmltaXRpd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xcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICBwcm9wZXJ0aWVzLnJvd0hlYWRlciA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yb3dIZWFkZXJGb250O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJvd0hlYWRlckZvbnQgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMucm93SGVhZGVyQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucm93SGVhZGVyQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMuY29sdW1uSGVhZGVyID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLCB7XG4gICAgICAgICAgICBmb3JtYXQ6IHtcbiAgICAgICAgICAgICAgICB2YWx1ZTogJ2RlZmF1bHQnXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb2x1bW5IZWFkZXJGb250O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbHVtbkhlYWRlckZvbnQgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29sdW1uSGVhZGVyQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuY29sdW1uSGVhZGVyQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMuY29sdW1uSGVhZGVyQ29sdW1uU2VsZWN0aW9uID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLmNvbHVtbkhlYWRlciwge1xuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckZvcmVncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJGb3JlZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbHVtbkhlYWRlckJhY2tncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2x1bW5IZWFkZXJCYWNrZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMucm93SGVhZGVyUm93U2VsZWN0aW9uID0gT2JqZWN0LmNyZWF0ZShwcm9wZXJ0aWVzLnJvd0hlYWRlciwge1xuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckZvcmVncm91bmRSb3dTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJGb3JlZ3JvdW5kUm93U2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJvd0hlYWRlckJhY2tncm91bmRSb3dTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yb3dIZWFkZXJCYWNrZ3JvdW5kUm93U2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMuZmlsdGVyUHJvcGVydGllcyA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9udDoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJGb250O1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZvbnQgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZmlsdGVyQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZENvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJCYWNrZ3JvdW5kQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJGb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckJhY2tncm91bmRTZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJCYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY2VsbEJvcmRlclN0eWxlOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmZpbHRlckNlbGxCb3JkZXJTdHlsZTtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJDZWxsQm9yZGVyU3R5bGUgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY2VsbEJvcmRlclRoaWNrbmVzczoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXJDZWxsQm9yZGVyVGhpY2tuZXNzO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckNlbGxCb3JkZXJUaGlja25lc3MgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHByb3BlcnRpZXMudHJlZUNvbHVtblByb3BlcnRpZXMgPSBPYmplY3QuY3JlYXRlKHByb3BlcnRpZXMsIHtcbiAgICAgICAgICAgIGZvbnQ6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkZvbnQ7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkZvbnQgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgY29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRDb2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZENvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGZvcmVncm91bmRTZWxlY3Rpb25Db2xvcjoge1xuICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSxcbiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50cmVlQ29sdW1uRm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yO1xuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgc2V0OiBmdW5jdGlvbih2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnRyZWVDb2x1bW5Gb3JlZ3JvdW5kU2VsZWN0aW9uQ29sb3IgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYmFja2dyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5CYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRTZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG5cbiAgICAgICAgcHJvcGVydGllcy50cmVlQ29sdW1uUHJvcGVydGllc0NvbHVtblNlbGVjdGlvbiA9IE9iamVjdC5jcmVhdGUocHJvcGVydGllcy50cmVlQ29sdW1uUHJvcGVydGllcywge1xuICAgICAgICAgICAgZm9yZWdyb3VuZFNlbGVjdGlvbkNvbG9yOiB7XG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLFxuICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnRyZWVDb2x1bW5Gb3JlZ3JvdW5kQ29sdW1uU2VsZWN0aW9uQ29sb3I7XG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICBzZXQ6IGZ1bmN0aW9uKHZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudHJlZUNvbHVtbkZvcmVncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvciA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBiYWNrZ3JvdW5kU2VsZWN0aW9uQ29sb3I6IHtcbiAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsXG4gICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMudHJlZUNvbHVtbkJhY2tncm91bmRDb2x1bW5TZWxlY3Rpb25Db2xvcjtcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmVlQ29sdW1uQmFja2dyb3VuZENvbHVtblNlbGVjdGlvbkNvbG9yID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcblxuICAgICAgICByZXR1cm4gcHJvcGVydGllcztcbiAgICB9LFxuXG4gICAgZ2V0Q29sdW1uV2lkdGg6IGZ1bmN0aW9uKHgpIHtcbiAgICAgICAgdmFyIGNvbCA9IHRoaXMuZ2V0Q29sdW1uKHgpO1xuICAgICAgICBpZiA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YgKFxuICAgICAgICAgICAgICAgICAgICBleHBvcnRQcm9wcyA9PT0gdW5kZWZpbmVkIHx8XG4gICAgICAgICAgICAgICAgICAgICFleHBvcnRQcm9wcyAmJiBub0V4cG9ydFByb3BlcnRpZXMuaW5kZXhPZihrZXkpID49IDAgfHxcbiAgICAgICAgICAgICAgICAgICAgZXhwb3J0UHJvcHMgJiYgbm9FeHBvcnRQcm9wZXJ0aWVzLmluZGV4T2Yoa2V5KSA8IDBcbiAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICBkZWxldGUgb2JqW2tleV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEJlaGF2aW9yLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIGdldHRlciBmb3IgYSBbTWVtZW50b10oaHR0cDovL2MyLmNvbS9jZ2kvd2lraT9NZW1lbnRvUGF0dGVybikgT2JqZWN0XG4gICAgICogQHJldHVybnMge29iamVjdH1cbiAgICAgKi9cbiAgICBnZXRQcml2YXRlU3RhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAoIXRoaXMudGFibGVTdGF0ZSkge1xuICAgICAgICAgICAgdGhpcy50YWJsZVN0YXRlID0gdGhpcy5nZXREZWZhdWx0U3RhdGUoKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy50YWJsZVN0YXRlO1xuICAgIH0sXG5cbiAgICAvL3RoaXMgaXMgZWZmZWN0aXZlbHkgYSBjbG9uZSwgd2l0aCBjZXJ0YWluIHRoaW5ncyByZW1vdmVkLi4uLlxuICAgIGdldFN0YXRlOiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIGNvcHkgPSBKU09OLnBhcnNlKEpTT04uc3RyaW5naWZ5KHRoaXMuZ2V0UHJpdmF0ZVN0YXRlKCkpKTtcbiAgICAgICAgdGhpcy5jbGVhck9iamVjdFByb3BlcnRp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ZW50b1BhdHRlcm4pLlxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBtZW1lbnRvIC0gYW4gZW5jYXBzdWxhdGVkIHJlcHJlc2VudGF0aW9uIG9mIHRhYmxlIHN0YXRlXG4gICAgICovXG4gICAgc2V0U3RhdGU6IGZ1bmN0aW9uKG1lbWVudG8pIHtcblxuICAgICAgICAvL3dlIGRvbid0IHdhbnQgdG8gY2xvYmJlciB0aGUgY29sdW1uIHByb3BlcnRpZXMgY29tcGxldGVseVxuICAgICAgICBpZiAoIW1lbWVudG8uY29sdW1uSW5kZXhlcykge1xuICAgICAgICAgICAgdmFyIGZpZWxkcyA9IHRoaXMuZ2V0RmllbGRzKCk7XG4gICAgICAgICAgICBtZW1lbnRvLmNvbHVtbkluZGV4ZXMgPSBbXTtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgZmllbGRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgbWVtZW50by5jb2x1bW5JbmRleGVzW2ldID0gaTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB2YXIgY29sUHJvcGVydGllcyA9IG1lbWVudG8uY29sdW1uUHJvcGVydGllcztcbiAgICAgICAgZGVsZXRlIG1lbWVudG8uY29sdW1uUHJvcGVydGllcztcbiAgICAgICAgdGhpcy50YWJsZVN0YXRlID0gbnVsbDtcbiAgICAgICAgdmFyIHN0YXRlID0gdGhpcy5nZXRQcml2YXRlU3RhdGUoKTtcbiAgICAgICAgdGhpcy5jcmVhdGVDb2x1bW5zKCk7XG4gICAgICAgIHRoaXMuc2V0Q29sdW1uT3JkZXIobWVtZW50by5jb2x1bW5JbmRleGVzKTtcbiAgICAgICAgXyhzdGF0ZSkuZXh0ZW5kT3duKG1lbWVudG8pO1xuICAgICAgICB0aGlzLnNldEFsbENvbHVtblByb3BlcnRpZXMoY29sUHJvcGVydGllcyk7XG4gICAgICAgIG1lbWVudG8uY29sdW1uUHJvcGVydGllcyA9IG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KTtcbiAgICAgICAgfVxuICAgICAgICB0YWJsZVN0YXRlLmNvbHVtbkluZGV4ZXMgPSBpbmRleGVzO1xuICAgICAgICB0aGlzLmNoYW5nZWQoKTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIEJlaGF2aW9yLnByb3RvdHlwZVxuICAgICAqIEByZXR1cm4ge3N0cmluZ1tdfSBBbGwgdGhlIGN1cnJlbnRseSBoaWRkZW4gY29sdW1uIGhlYWRlciBsYWJlbHMuXG4gICAgICovXG4gICAgZ2V0SGlkZGVuQ29sdW1uRGVzY3JpcHRvcnM6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgdGFibGVTdGF0ZSA9IHRoaXMuZ2V0UHJpdmF0ZVN0YXRlKCk7XG4gICAgICAgIHZhciBpbmRleGVzID0gdGFibGVTdGF0ZS5jb2x1bW5JbmRleGVzO1xuICAgICAgICB2YXIgbGFiZWxzID0gW107XG4gICAgICAgIHZhciBjb2x1bW5Db3VudCA9IHRoaXMuZ2V0Q29sdW1uQ291bnQoKTtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjb2x1bW5Db3VudDsgaSsrKSB7XG4gICAgICAgICAgICBpZiAoaW5kZXhlcy5pbmRleE9mKGkpID09PSAtMSkge1xuICAgICAgICAgICAgICAgIGxhYmVscy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgaWQ6IGksXG4gICAgICAgICAgICAgICAgICAgIGxhYmVsOiB0aGlzLmdldEhlYWRlcihpKSxcbiAgICAgICAgICAgICAgICAgICAgZmllbGQ6IHRoaXMuZ2V0RmllbGQoaSlcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbGFiZWxzO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgQmVoYXZpb3IucHJvdG90eXBlXG4gICAgICogQGRlc2MgaGlkZSBjb2x1bW5zIHR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gICAgcHJvcGVydGllcy53aWR0aCA9ICFkID8gYiA6IE1hdGgubWF4KGEsIGIpO1xuICAgICAgICAgICAgICAgIHByb3BlcnRpZXMuY29sdW1uQXV0b3NpemVkID0gIWlzTmFOKHByb3BlcnRpZXMud2lkdGgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfSxcblxuICAgIGdldENlbGxUeXBlOiBmdW5jdGlvbih5KSB7XG4gICAgICAgIHZhciB2YWx1ZSA9IHRoaXMuZ2V0VmFsdWUoeSk7XG4gICAgICAgIHZhciB0eXBlID0gdGhpcy50eXBlT2YodmFsdWUpO1xuICAgICAgICByZXR1cm4gdHlwZTtcbiAgICB9LFxuXG4gICAgZ2V0RmlsdGVyVHlwZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIC8vIHZhciBwcm9wcyA9IHRoaXMuZ2V0UHJvcGVydGllcygpO1xuICAgICAgICAvLyB2YXIgdHlwZSA9IHByb3BzLmZpbHRlclR5cGU7XG4gICAgICAgIC8vIGlmICghdHlwZSkge1xuICAgICAgICAvLyAgICAgdHlwZSA9IHRoaXMuZ2V0VHlwZSgpO1xuICAgICAgICAvLyAgICAgaWYgKHR5cGUgIT09ICd1bmtrbm93bicpIHtcbiAgICAgICAgLy8gICAgICAgICBwcm9wcy50eXBlID0gdHlwZTtcbiAgICAgICAgLy8gICAgIH1cbiAgICAgICAgLy8gfVxuICAgICAgICAvLyByZXR1cm4gdHlwZTtcbiAgICAgICAgcmV0dXJuICdmaWx0ZXInO1xuICAgIH0sXG5cbiAgICBnZXRUeXBlOiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIHByb3BzID0gdGhpcy5nZXRQcm9wZXJ0aWVzKCk7XG4gICAgICAgIHZhciB0eXBlID0gcHJvcHMudHlwZTtcbiAgICAgICAgaWYgKCF0eXBlKSB7XG4gICAgICAgICAgICB0eXBlID0gdGhpcy5jb21wdXRlQ29sdW1uVHlwZSgpO1xuICAgICAgICAgICAgaWYgKHR5cGUgIT09ICd1bmtrbm93bicpIHtcbiAgICAgICAgICAgICAgICBwcm9wcy50eXBlID0gdHlwZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdHlwZTtcbiAgICB9LFxuXG4gICAgY29tcHV0ZUNvbHVtblR5cGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgaGVhZGVyUm93Q291bnQgPSB0aGlzLmJlaGF2aW9yLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIHZhciBoZWlnaHQgPSB0aGlzLmJlaGF2aW9yLmdldFJvd0NvdW50KCk7XG4gICAgICAgIHZhciB2YWx1ZSA9IHRoaXMuZ2V0VmFsdWUoaGVhZGVyUm93Q291bnQpO1xuICAgICAgICB2YXIgZWFjaFR5cGUgPSB0aGlzLnR5cGVPZih2YWx1ZSk7XG4gICAgICAgIGlmICghZWFjaFR5cGUpIHtcbiAgICAgICAgICAgIHJldHVybiAndW5rbm93bic7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHR5cGUgPSB0aGlzLnR5cGVPZih2YWx1ZSk7XG4gICAgICAgIHZhciBpc051bWJlciA9ICgodHlwZW9mIHZhbHVlKSA9PT0gJ251bWJlcicpO1xuICAgICAgICBmb3IgKHZhciB5ID0gaGVhZGVyUm93Q291bnQ7IHkgPCBoZWlnaHQ7IHkrKykge1xuICAgICAgICAgICAgdmFsdWUgPSB0aGlzLmdldFZhbHVlKHkpO1xuICAgICAgICAgICAgZWFjaFR5cGUgPSB0aGlzLnR5cGVPZih2YWx1ZSk7XG4gICAgICAgICAgICBpZiAodHlwZSAhPT0gZWFjaFR5cGUpIHtcbiAgICAgICAgICAgICAgICBpZiAoaXNOdW1iZXIgJiYgKHR5cGVvZiB2YWx1ZSA9PT0gJ251bWJlcicpKSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGUgPSAnZmxvYXQnO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIH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0aW9uPlxuICAgICAgICAgICAgICAgICAgICB7ey9pdGVtc319XG4gICAgICAgICAgICAgICAgPC9zZWxlY3Q+XG4gICAgICAgICAgICAqL1xuICAgIH0sXG5cbiAgICBhdXRvcG9wdWxhdGU6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgYmVoYXZpb3IgPSB0aGlzLmdyaWQuYmVoYXZpb3I7XG4gICAgICAgIHZhciBwb2ludCA9IHRoaXMuZ2V0RWRpdG9yUG9pbnQoKTtcbiAgICAgICAgdmFyIGNvbFByb3BzID0gdGhpcy5ncmlkLmdldENvbHVtblByb3BlcnRpZXMocG9pbnQueCk7XG4gICAgICAgIGlmICghY29sUHJvcHMuYXV0b3BvcHVsYXRlRWRpdG9yKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGhlYWRlckNvdW50ID0gdGhpcy5ncmlkLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIHZhciByb3dDb3VudCA9IHRoaXMuZ3JpZC5nZXRVbmZpbHRlcmVkUm93Q291bnQoKSAtIGhlYWRlckNvdW50O1xuICAgICAgICB2YXIgY29sdW1uID0gcG9pbnQueDtcbiAgICAgICAgdmFyIG1hcCA9IG5ldyBNYXAoKTtcbiAgICAgICAgZm9yICh2YXIgciA9IDA7IHIgPCByb3dDb3VudDsgcisrKSB7XG4gICAgICAgICAgICB2YXIgZWFjaCA9IGJlaGF2aW9yLmdldFVuZmlsdGVyZWRWYWx1ZShjb2x1bW4sIHIpO1xuICAgICAgICAgICAgbWFwLnNldChlYWNoLCBlYWNoKTtcbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWVzID0gbWFwLnZhbHVlcztcbiAgICAgICAgdmFsdWVzLnNvcnQoKTtcblxuICAgICAgICBpZiAodmFsdWVzLmxlbmd0aCA+IDAgJiYgdmFsdWVzWzBdLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHZhbHVlcy51bnNoaWZ0KCcnKT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dyaWQuZGlhbG9nO1xuXG4gICAgICAgIHZhciBjb2x1bW5JbmRleCA9IGVkaXRvclBvaW50LngsXG4gICAgICAgICAgICB0aXRsZSA9IGJlaGF2aW9yLmdldENvbHVtbklkKGNvbHVtbkluZGV4KSxcbiAgICAgICAgICAgIGZpZWxkID0gYmVoYXZpb3IuZ2V0RmllbGQoY29sdW1uSW5kZXgpLFxuICAgICAgICAgICAgdHlwZSA9IGJlaGF2aW9yLmdldENvbHVtbihjb2x1bW5JbmRleCkuZ2V0VHlwZSgpO1xuXG4gICAgICAgIHZhciBmaWVsZHNQcm92aWRlciA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgcmV0dXJuIFt7XG4gICAgICAgICAgICAgICAgbmFtZTogZmllbGQsXG4gICAgICAgICAgICAgICAgYWxpYXM6IHRpdGxlLFxuICAgICAgICAgICAgICAgIHR5cGU6IHR5cGVcbiAgICAgICAgICAgIH1dO1xuICAgICAgICB9O1xuICAgICAgICB0aGlzLnRpdGxlLmlubmVySFRNTCA9ICdNYW5hZ2UgRmlsdGVycyc7XG4gICAgICAgIHZhciBmaWx0ZXIgPSB0aGlzLmdyaWQuZmlsdGVyO1xuICAgICAgICAvL3ZhciBzZWxmID0gdGhpcztcbiAgICAgICAgaWYgKGRpYWxvZy5pc09wZW4oKSkge1xuICAgICAgICAgICAgZGlhbG9nLmNsb3NlKCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2YXIgc2VsZiA9IHRoaXM7XG5cbiAgICAgICAgICAgIGRpYWxvZy5jbGVhcigpO1xuICAgICAgICAgICAgZGlhbG9nLm92ZXJsYXkuYXBwZW5kQ2hpbGQodGhpcy5kaWFsb2cpO1xuXG4gICAgICAgICAgICBmaWx0ZXIuaW5pdGlhbGl6ZShmaWVsZHNQcm92aWRlcik7XG5cbiAgICAgICAgICAgIGRpYWxvZy5vbk9rUHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25PayAmJiBmaWx0ZXIub25PaygpKSB7IC8vIG9uT0soKSB0cnV0aHkgcmVzdWx0IG1lYW5zIGFib3J0OyBmYWxzeSBtZWFucyBwcm9jZWVkXG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2VsZi50ZWFyRG93bigpO1xuICAgICAgICAgICAgICAgIGJlaGF2aW9yLnNldENvbXBsZXhGaWx0ZXIoY29sdW1uSW5kZXgsIHtcbiAgICAgICAgICAgICAgICAgICAgLy90eXBlOiBmaWx0ZXIuYWxpYXMsXG4gICAgICAgICAgICAgICAgICAgIHN0YXRlOiBmaWx0ZXIuZ2V0U3RhdGUoKVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIGRpYWxvZy5jbG9zZSgpO1xuICAgICAgICAgICAgICAgIGJlaGF2aW9yLmFwcGx5QW5hbHl0aWNzKCk7XG4gICAgICAgICAgICAgICAgYmVoYXZpb3IuY2hhbmdlZCgpO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGlhbG9nLm9uQ2FuY2VsUHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25DYW5jZWwgJiYgZmlsdGVyLm9uQ2FuY2VsKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzZWxmLnRlYXJEb3duKCk7XG4gICAgICAgICAgICAgICAgZGlhbG9nLmNsb3NlKCk7XG4gICAgICAgICAgICAgICAgZmlsdGVyID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgZGlhbG9nLm9uRGVsZXRlUHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25EZWxldGUgJiYgZmlsdGVyLm9uRGVsZXRlKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzZWxmLnRlYXJEb3duKCk7XG4gICAgICAgICAgICAgICAgYmVoYXZpb3Iuc2V0Q29tcGxleEZpbHRlcihjb2x1bW5JbmRleCwgdW5kZWZpbmVkKTtcbiAgICAgICAgICAgICAgICBkaWFsb2cuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICBiZWhhdmlvci5hcHBseUFuYWx5dGljcygpO1xuICAgICAgICAgICAgICAgIGJlaGF2aW9yLmNoYW5nZWQoKTtcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIGRpYWxvZy5vblJlc2V0UHJlc3NlZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIGlmIChmaWx0ZXIub25SZXNldCAmJiBmaWx0ZXIub25SZXNldCgpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgc2VsZi50ZWFyRG93bigpO1xuICAgICAgICAgICAgICAgIGZpbHRlci5pbml0aWFsaXplKGRpYWxvZyk7XG4gICAgICAgICAgICAgICAgaWYgKGZpbHRlci5vblNob3cpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlsdGVyLm9uU2hvdyhzZWxmLmNvbnRlbnQpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIHZhciBjZWxsQm91bmRzID0gdGhpcy5ncmlkLl9nZXRCb3VuZHNPZkNlbGwoY29sdW1uSW5kZXgsIGVkaXRvclBvaW50LnkpO1xuXG4gICAgICAgICAgICAvL2hhY2sgdG8gYWNjb21vZGF0ZSBib290c3RyYXAgbWFyZ2luIGlzc3Vlcy4uLlxuICAgICAgICAgICAgdmFyIHhPZmZzZXQgPVxuICAgICAgICAgICAgICAgIHRoaXMuZ3JpZC5kaXYuZ2V0Qm91bmRpbmdDbGllbnR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WZhdWx0IG51bGxcbiAgICAgKiBAbWVtYmVyT2YgQ2VsbEVkaXRvci5wcm90b3R5cGVcbiAgICAgKi9cbiAgICBpbnB1dDogbnVsbCxcblxuICAgIC8qKlxuICAgICAqIG15IGxvb2t1cCBhbGlhc1xuICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICogQG1lbWJlck9mIFNpbXBsZS5wcm90b3R5cGVcbiAgICAgKi9cbiAgICBhbGlhczogJ3NpbXBsZScsXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgU2ltcGxlLnByb3RvdHlwZVxuICAgICAqL1xuICAgIGluaXRpYWxpemU6IGZ1bmN0aW9uKCkge1xuICAgICAgICB0aGlzLmVkaXRvclBvaW50ID0ge1xuICAgICAgICAgICAgeDogMCxcbiAgICAgICAgICAgIHk6IDBcbiAgICAgICAgfTtcbiAgICB9LFxuXG4gICAgc3BlY2lhbEtleXVwczoge1xuICAgICAgICAvLzB4MDg6ICdjbGVhclN0b3BFZGl0aW5nJywgLy8gYmFja3NwYWNlXG4gICAgICAgIDB4MDk6ICdzdG9wRWRpdGluZycsIC8vIHRhYlxuICAgICAgICAweDBkOiAnc3RvcEVkaXRpbmcnLCAvLyByZXR1cm4vZW50ZXJcbiAgICAgICAgMHgxYjogJ2NhbmNlbEVkaXRpbmcnIC8vIGVzY2FwZVxuICAgIH0sXG5cbiAgICBrZXl1cDogZnVuY3Rpb24oZSkge1xuICAgICAgICBpZiAoZSkge1xuICAgICAgICAgICAgdmFyIHNwZWNpYWxLZXl1cCA9IHRoaXMuc3BlY2lhbEtleXVwc1tlLmtleUNvZGVdO1xuXG4gICAgICAgICAgICBpZiAoc3BlY2lhbEtleXVwKSB7XG4gICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgIHRoaXNbc3BlY2lhbEtleXVwXSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuZ3JpZC5yZXBhaW50KCk7XG4gICAgICAgICA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ZTsgfVxuICAgICAgICAgICAgfSBlbHNlIHsgLy8gbXVzdCBiZSBmaWx0ZXIgcm93XG4gICAgICAgICAgICAgICAgdmFsdWUgPSB0aGlzLmdldEZpbHRlcih4KTtcbiAgICAgICAgICAgICAgICB2YXIgaWNvbiA9IGltYWdlcy5maWx0ZXIodmFsdWUubGVuZ3RoKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gW251bGwsIHZhbHVlLCBpY29uXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHhcbiAgICAgKiBAcGFyYW0ge251bWJlcn0geVxuICAgICAqIEBwYXJhbSB2YWx1ZVxuICAgICAqL1xuICAgIHNldFZhbHVlOiBmdW5jdGlvbih4LCB5LCB2YWx1ZSkge1xuICAgICAgICB2YXIgaGFzSGllcmFyY2h5Q29sdW1uID0gdGhpcy5oYXNIaWVyYXJjaHlDb2x1bW4oKTtcbiAgICAgICAgdmFyIGhlYWRlclJvd0NvdW50ID0gdGhpcy5ncmlkLmdldEhlYWRlclJvd0NvdW50KCk7XG4gICAgICAgIGlmIChoYXNIaWVyYXJjaHlDb2x1bW4pIHtcbiAgICAgICAgICAgIGlmICh4ID09PSAtMikge1xuICAgICAgICAgICAgICAgIHggPSAwO1xuICAgICAgICAgICAgfVxuICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaGFzQWdncmVnYXRlcygpKSB7XG4gICAgICAgICAgICB4ICs9IDE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHkgPCBoZWFkZXJSb3dDb3VudCkge1xuICAgICAgICAgICAgdGhpcy5zZXRIZWFkZXJSb3dWYWx1ZSh4LCB5LCB2YWx1ZSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLm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xuICAgICAgICB2YXIgZ3JvdXBzID0gW107XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgaGVhZGVycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgaWYgKGdyb3VwQnlzLmluZGV4T2YoaSkgPT09IC0xKSB7XG4gICAgICAgICAgICAgICAgdmFyIGZpZWxkID0gaGVhZGVyc1tpXTtcbiAgICAgICAgICAgICAgICBncm91cHMucHVzaCh7XG4gICAgICAgICAgICAgICAgICAgIGlkOiBpLFxuICAgICAgICAgICAgICAgICAgICBsYWJlbDogZmllbGQsXG4gICAgICAgICAgICAgICAgICAgIGZpZWxkOiBmaWVsZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBncm91cHM7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge29iamVjdFtdfVxuICAgICAqL1xuICAgIGdldFZpc2libGVDb2x1bW5zOiBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIGl0ZW1zID0gdGhpcy5ncmlkLmJlaGF2aW9yLmNvbHVtbnM7XG4gICAgICAgIGl0ZW1zID0gaXRlbXMuZmlsdGVyKGZ1bmN0aW9uKGVhY2gpIHtcbiAgICAgICAgICAgIHJldHVybiBlYWNoLmxhYmVsICE9PSAnVHJlZSc7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gaXRlbXM7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBkYXRhTW9kZWxzLkpTT04ucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge29iamVjdFtdfVxuICAgICAqL1xuICAgIGdldEhpZGRlbkNvbHVtbnM6IGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgdmlzaWJsZSA9IHRoaXMuZ3JpZC5iZWhhdmlvci5jb2x1bW5zO1xu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F0ZVN0YXRlKCkuc29ydHM7XG4gICAgICAgIGlmICghc29ydHMpIHtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHZhciBwb3NpdGlvbiA9IHNvcnRzLmluZGV4T2YoaW5kZXgpO1xuICAgICAgICBpZiAocG9zaXRpb24gPCAwKSB7XG4gICAgICAgICAgICBwb3NpdGlvbiA9IHNvcnRzLmluZGV4T2YoLTEgKiBpbmRleCk7XG4gICAgICAgICAgICB1cCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmIChwb3NpdGlvbiA8IDApIHtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgICAgIHZhciByYW5rID0gc29ydHMubGVuZ3RoIC0gcG9zaXRpb247XG4gICAgICAgIHZhciBhcnJvdyA9IHVwID8gVVBXQVJEU19CTEFDS19BUlJPVyA6IERPV05XQVJEU19CTEFDS19BUlJPVztcbiAgICAgICAgcmV0dXJuIHJhbmsgKyBhcnJvdyArICcgJztcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIGRhdGFNb2RlbHMuSlNPTi5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gY2VsbFxuICAgICAqIEBwYXJhbSBldmVudFxuICAgICAqL1xuICAgIGNlbGxDbGlja2VkOiBmdW5jdGlvbihjZWxsLCBldmVudCkge1xuICAgICAgICBpZiAoIXRoaXMuaGFzQWdncmVnYXRlcygpKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGV2ZW50LmdyaWRDZWxsLnggIT09IDApIHtcbiAgICAgICAgICAgIHJldHVybjsgLy8gdGhpcyB3YXNuJ3QgYSBjbGljayBvbiB0aGUgaGllcmFyY2h5IGNvbHVtblxuICAgICAgICB9XG4gICAgICAgIHZhciBoZWFkZXJSb3dDb3VudCA9IHRoaXMuZ3JpZC5nZXRIZWFkZXJSb3dDb3VudCgpO1xu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2YXIgaXNIZWFkZXIgPSBkeSA8IGhlYWRlclJvd0NvdW50IHx8IGR4IDwgaGVhZGVyQ29sdW1uQ291bnQ7XG5cbiAgICAgICAgaWYgKCFncmlkLmlzQ2VsbFNlbGVjdGlvbigpIHx8IGlzUmlnaHRDbGljayB8fCBpc0hlYWRlciB8fCBpc091dHNpZGUpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLm5leHQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLm5leHQuaGFuZGxlTW91c2VEb3duKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgICAgIHZhciBudW1GaXhlZFJvd3MgPSBncmlkLmdldEZpeGVkUm93Q291bnQoKTtcblxuICAgICAgICAgICAgLy9pZiB3ZSBhcmUgaW4gdGhlIGZpeGVkIGFyZWEgZG8gbm90IGFwcGx5IHRoZSBzY3JvbGwgdmFsdWVzXG4gICAgICAgICAgICAvL2NoZWNrIGJvdGggeCBhbmQgeSB2YWx1ZXMgaW5kZXBlbmRlbnRseVxuICAgICAgICAgICAgaWYgKHZpZXdDZWxsLnggPCBudW1GaXhlZENvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICBkeCA9IHZpZXdDZWxsLng7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh2aWV3Q2VsbC55IDwgbnVtRml4ZWRSb3dzKSB7XG4gICAgICAgICAgICAgICAgZHkgPSB2aWV3Q2VsbC55O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB2YXIgZENlbGwgPSBncmlkLm5ld1BvaW50KGR4LCBkeSk7XG5cbiAgICAgICAgICAgIHZhciBwcmltRXZlbnQgPSBldmVudC5wcmltaXRpdmVFdmVudDtcbiAgICAgICAgICAgIHZhciBrZXlzID0gcHJpbUV2ZW50LmRldGFpbC5rZXlzO1xuICAgICAgICAgICAgdGhpcy5kcmFnZ2luZyA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmV4dGVuZFNlbGVjdGlvbihncmlkLCBkQ2VsbCwga2V5cyk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIENlbGxTZWxlY3Rpb24ucHJvdG90eXBlXG4gICAgICogQGRlc2MgSGFuZGxlIHRoaXMgZXZlbnQgZG93biB0aGUgZmVhdHVyZSBjaGFpbiBvZiByZXNwb25zaWJpbGl0eS5cbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VEcmFnOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICB2YXIgaXNSaWdodENsaWNrID0gZXZlbnQucHJpbWl0aXZlRXZlbnQuZGV0YWlsLmlzUmlnaHRDbGljaztcblxuICAgICAgICBpZiAoIWdyaWQuaXNDZWxsU2VsZWN0aW9uKCkgfHwgaXNSaWdodENsaWNrIHx8ICF0aGlzLmRyYWdnaW5nKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRHJhZyhncmlkLCBldmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG5cbiAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgICAgIHZhciBudW1GaXhlZFJvd3MgPSBncmlkLmdldEZpeGVkUm93Q291bnQoKTtcblxuICAgICAgICAgICAgdmFyIGNlbGwgPSBldmVudC5ncmlkQ2VsbDtcbiAgICAgICAgICAgIHZhciB2aWV3Q2VsbCA9IGV2ZW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uICAgICAqL1xuICAgIHNjcm9sbERyYWc6IGZ1bmN0aW9uKGdyaWQpIHtcblxuICAgICAgICBpZiAoIWdyaWQuaXNTY3JvbGxpbmdOb3coKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGRyYWdTdGFydGVkSW5IZWFkZXJBcmVhID0gZ3JpZC5pc01vdXNlRG93bkluSGVhZGVyQXJlYSgpO1xuICAgICAgICB2YXIgbGFzdERyYWdDZWxsID0gdGhpcy5sYXN0RHJhZ0NlbGw7XG4gICAgICAgIHZhciBiID0gZ3JpZC5nZXREYXRhQm91bmRzKCk7XG4gICAgICAgIHZhciB4T2Zmc2V0ID0gMDtcbiAgICAgICAgdmFyIHlPZmZzZXQgPSAwO1xuXG4gICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcbiAgICAgICAgdmFyIG51bUZpeGVkUm93cyA9IGdyaWQuZ2V0Rml4ZWRSb3dDb3VudCgpO1xuXG4gICAgICAgIHZhciBkcmFnRW5kSW5GaXhlZEFyZWFYID0gbGFzdERyYWdDZWxsLnggPCBudW1GaXhlZENvbHVtbnM7XG4gICAgICAgIHZhciBkcmFnRW5kSW5GaXhlZEFyZWFZID0gbGFzdERyYWdDZWxsLnkgPCBudW1GaXhlZFJvd3M7XG5cbiAgICAgICAgaWYgKCFkcmFnU3RhcnRlZEluSGVhZGVyQXJlYSkge1xuICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudERyYWcueCA8IGIub3JpZ2luLngpIHtcbiAgICAgICAgICAgICAgICB4T2Zmc2V0ID0gLTE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50RHJhZy55IDwgYi5vcmlnaW4ueSkge1xuICAgICAgICAgICAgICAgIHlPZmZzZXQgPSAtMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5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bmdcbiAgICAgICAgaWYgKHggPCAwIHx8IHkgPCAwKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICAvL3dlIGhhdmUgcmVwZWF0ZWQgYSBjbGljayBpbiB0aGUgc2FtZSBzcG90IGRlc2xlY3QgdGhlIHZhbHVlIGZyb20gbGFzdCB0aW1lXG4gICAgICAgIGlmIChcbiAgICAgICAgICAgIGhhc0NUUkwgJiZcbiAgICAgICAgICAgIHggPT09IG1vdXNlUG9pbnQueCAmJlxuICAgICAgICAgICAgeSA9PT0gbW91c2VQb2ludC55XG4gICAgICAgICkge1xuICAgICAgICAgICAgZ3JpZC5jbGVhck1vc3RSZWNlbnRTZWxlY3Rpb24oKTtcbiAgICAgICAgICAgIGdyaWQucG9wTW91c2VEb3duKCk7XG4gICAgICAgICAgICBncmlkLnJlcGFpbnQoKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICghaGFzQ1RSTCAmJiAhaGFzU0hJRlQpIHtcbiAgICAgICAgICAgIGdyaWQuY2xlYXJTZWxlY3Rpb25zKCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoaGFzU0hJRlQpIHtcbiAgICAgICAgICAgIGdyaWQuY2xlYXJNb3N0UmVjZW50U2VsZWN0aW9uKCk7XG4gICAgICAgICAgICBncmlkLnNlbGVjdChtb3VzZVBvaW50LngsIG1vdXNlUG9pbnQueSwgeCAtIG1vdXNlUG9pbnQueCArIDEsIHkgLSBtb3VzZVBvaW50LnkgKyAxKTtcbiAgICAgICAgICAgIGdyaWQuc2V0RHJhZ0V4dGVudChncmlkLm5ld1BvaW50KHggLSBtb3VzZVBvaW50LnggKyAxLCB5IC0gbW91c2VQb2ludC55KSk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBncmlkLnNlbGVjdCh4LCB5LCAwLCAwKTtcbiAgICAgICAgICAgIGdyaWQuc2V0TW91c2VEb3duKGdyaWQubmV3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VsZi5zZXRDcm9zc0Jyb3dzZXJQcm9wZXJ0eShkLCAndHJhbnNpdGlvbicsICcnKTtcbiAgICAgICAgICAgICAgICBncmlkLnJlbmRlck92ZXJyaWRlc0NhY2hlLmZsb2F0ZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIGdyaWQucmVwYWludCgpO1xuICAgICAgICAgICAgICAgIHNlbGYuZG9GbG9hdGVyQW5pbWF0aW9uKGdyaWQpO1xuICAgICAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgZC5zdHlsZS5kaXNwbGF5ID0gJ25vbmUnO1xuICAgICAgICAgICAgICAgICAgICBzZWxmLmlzRmxvYXRpbmdOb3cgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0sIGNvbHVtbkFuaW1hdGlvblRpbWUgKyA1MCk7XG4gICAgICAgIH07XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBDZWxsTW92aW5nLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIG1hbmlmZXN0IHRoZSBmbG9hdGVyIGFuaW1hdGlvblxuICAgICAqIEBwYXJhbSB7SHlwZXJncmlkfSBncmlkXG4gICAgICovXG4gICAgZG9GbG9hdGVyQW5pbWF0aW9uOiBmdW5jdGlvbihncmlkKSB7XG4gICAgICAgIGlmICh0aGlzLmZsb2F0ZXJBbmltYXRpb25RdWV1ZS5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIHRoaXMuZmxvYXRpbmdOb3cgPSBmYWxzZTtcbiAgICAgICAgICAgIGdyaWQucmVwYWludCgpO1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHZhciBhbmltYXRpb24gPSB0aGlzLmZsb2F0ZXJBbmltYXRpb25RdWV1ZS5wb3AoKTtcbiAgICAgICAgYW5pbWF0aW9uKCk7XG4gICAgfSxcblxuIC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gIH1cbiAgICAgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlVXAoZ3JpZCwgZXZlbnQpO1xuICAgICAgICB9XG4gICAgfSxcblxuICAgIGhhbmRsZURvdWJsZUNsaWNrOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICBpZiAodGhpcy5kb3VibGVDbGlja1RpbWVyKSB7XG4gICAgICAgICAgICBjbGVhclRpbWVvdXQodGhpcy5kb3VibGVDbGlja1RpbWVyKTsgLy8gcHJldmVudCBtb3VzZURvd24gZnJvbSBjb250aW51aW5nXG4gICAgICAgICAgICB0aGlzLmRvdWJsZUNsaWNrVGltZXIgPSB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMubmV4dCkge1xuICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZURvdWJsZUNsaWNrKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgfVxuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgQ29sdW1uU2VsZWN0aW9uLnByb3RvdHlwZVxuICAgICAqIEBkZXNjICogQGRlc2MgSGFuZGxlIHRoaXMgZXZlbnQgZG93biB0aGUgZmVhdHVyZSBjaGFpbiBvZiByZXNwb25zaWJpbGl0eS5cbiAgICAgKiBAcGFyYW0ge0h5cGVyZ3JpZH0gZ3JpZFxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBldmVudCAtIHRoZSBldmVudCBkZXRhaWxzXG4gICAgICovXG4gICAgaGFuZGxlTW91c2VEb3duOiBmdW5jdGlvbihncmlkLCBldmVudCkge1xuICAgICAgICBpZiAodGhpcy5kb3VibGVDbGlja1RpbWVyKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoKCFncmlkLmlzQ29sdW1uU2VsZWN0aW9uKCkgfHwgZXZlbnQubW91c2VQb2ludC55IDwgNSkgJiYgdGhpcy5uZXh0KSB7XG4gICAgICAgICAgICB0aGlzLm5leHQuaGFuZGxlTW91c2VEb3duKGdyaWQsIGV2ZW50KTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBpc1JpZ2h0Q2xpY2sgPSBldmVudC5wcmltaXRpdmVFdmVudC5kZXRhaWwuaXNSaWdodENsaWNrO1xuICAgICAgICB2YXIgY2VsbCA9IGV2ZW50LmdyaWRDZWxsO1xuICAgICAgICB2YXIgdmlld0NlbGwgPSBldmVudC52aWV3UG9pbnQ7XG4gICAgICAgIHZhciBkeCA9IGNlbGwueDtcbiAgICAgICAgdmFyIGR5ID0gY2VsbC55O1xuXG4gICAgICAgIHZhciBpc0hlYWRlciA9IGdyaWQuaXNTaG93SGVhZGVyUm93KCkgJiYgZHkgPT09IDAgJiYgZHggIT09IC0xO1xuXG4gICAgICAgIGlmIChpc1JpZ2h0Q2xpY2sgfHwgIWlzSGVhZGVyKSB7XG4gICAgICAgICAgICBpZiAodGhpcy5uZXh0KSB7XG4gICAgICAgICAgICAgICAgdGhpcy5uZXh0LmhhbmRsZU1vdXNlRG93bihncmlkLCBldmVudCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBIT0xEIE9GRiBXSElMRSBXQUlUSU5HIEZPUiBET1VCTEUtQ0xJQ0tcbiAgICAgICAgICAgIHRoaXMuZG91YmxlQ2xpY2tUaW1lciA9IHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5kb3VibGVDbGlja1RpbWVyID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgIHZhciBudW1GaXhlZENvbHVtbnMgPSBncmlkLmdldEZpeGVkQ29sdW1uQ291bnQoKTtcblxuICAgICAgICAgICAgICAgIC8vaWYgd2UgYXJlIGluIHRoZSBmaXhlZCBhcmVhIGRvIG5vdCBhcHBseSB0aGUgc2Nyb2xs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m5vZGVOYW1lICE9PSAnSU1HJykge1xuICAgICAgICAgICAgICAgIGxlZnRJY29uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChyaWdodEljb24gJiYgcmlnaHRJY29uLm5vZGVOYW1lICE9PSAnSU1HJykge1xuICAgICAgICAgICAgICAgIHJpZ2h0SWNvbiA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY2VudGVySWNvbiAmJiBjZW50ZXJJY29uLm5vZGVOYW1lICE9PSAnSU1HJykge1xuICAgICAgICAgICAgICAgIGNlbnRlckljb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdmFsID0gdmFsdWVPckZ1bmN0aW9uRXhlY3V0ZShjb25maWcsIHZhbCk7XG5cbiAgICAgICAgdmFsID0gY29uZmlnLmZvcm1hdHRlcih2YWwpO1xuXG4gICAgICAgIGlmIChnYy5mb250ICE9PSBjb25maWcuZm9udCkge1xuICAgICAgICAgICAgZ2MuZm9udCA9IGNvbmZpZy5mb250O1xuICAgICAgICB9XG4gICAgICAgIGlmIChnYy50ZXh0QWxpZ24gIT09ICdsZWZ0Jykge1xuICAgICAgICAgICAgZ2MudGV4dEFsaWduID0gJ2xlZnQnO1xuICAgICAgICB9XG4gICAgICAgIGlmIChnYy50ZXh0QmFzZWxpbmUgIT09ICdtaWRkbGUnKSB7XG4gICAgICAgICAgICBnYy50ZXh0QmFzZWxpbmUgPSAnbWlkZGxlJztcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIGZpbGwgYmFja2dyb3VuZCBvbmx5IGlmIG91ciBiZ0NvbG9yIGlzIHBvcHVsYXRlZCBvciB3ZSBhcmUgYSBzZWxlY3RlZCBjZWxsXG4gICAgICAgIHZhciBiYWNrZ3JvdW5kQ29sb3IsIGhvdmVyLCBob3ZlckNvbG9yLCBzZWxlY3RDb2xvcjtcbiAgICAgICAgaWYgKGNvbmZpZy5pc0NlbGxIb3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ZmlsbFN0eWxlID0gdGhlQ29sb3I7XG4gICAgICAgICAgICBnYy5zdHJva2VTdHlsZSA9IHRoZUNvbG9yO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGlzSGVhZGVyICYmIHdyYXBIZWFkZXJzKSB7XG4gICAgICAgICAgICB0aGlzLnJlbmRlck11bHRpTGluZVRleHQoZ2MsIHgsIHksIGhlaWdodCwgd2lkdGgsIGNvbmZpZywgdmFsKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMucmVuZGVyU2luZ2xlTGluZVRleHQoZ2MsIHgsIHksIGhlaWdodCwgd2lkdGgsIGNvbmZpZywgdmFsKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBpY29uV2lkdGggPSAwO1xuICAgICAgICBpZiAobGVmdEljb24pIHtcbiAgICAgICAgICAgIGl5b2Zmc2V0ID0gTWF0aC5yb3VuZCgoaGVpZ2h0IC0gbGVmdEljb24uaGVpZ2h0KSAvIDIpO1xuICAgICAgICAgICAgZ2MuZHJhd0ltYWdlKGxlZnRJY29uLCB4ICsgbGVmdFBhZGRpbmcsIHkgKyBpeW9mZnNldCk7XG4gICAgICAgICAgICBpY29uV2lkdGggPSBNYXRoLm1heChsZWZ0SWNvbi53aWR0aCArIDIpO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyaWdodEljb24gJiYgd2lkdGggPiAxLjc1ICogaGVpZ2h0KSB7XG4gICAgICAgICAgICBpeW9mZnNldCA9IE1hdGgucm91bmQoKGhlaWdodCAtIHJpZ2h0SWNvbi5oZWlnaHQpIC8gMik7XG4gICAgICAgICAgICB2YXIgcmlnaHRYID0geCArIHdpZHRoIC0gcmlnaHRJY29uLndpZHRoO1xuICAgICAgICAgICAgaWYgKGJhY2tncm91bmRDb2xvciAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgZ2MuZmlsbFN0eWxlID0gYmFja2dyb3VuZENvbG9yO1xuICAgICAgICAgICAgICAgIGdjLmZpbGxSZWN0KHJpZ2h0WCwgeSwgcmlnaHRJY29uLndpZHRoLCBoZWlnaHQpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBnYy5jbGVhclJlY3QocmlnaHRYLCB5LCByaWdodEljb24ud2lkdGgsIGhlaWdodCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBnYy5kcmF3SW1hZ2UocmlnaHRJY29uLCByaWdodFgsIHkgKyBpeW9mZnNldCk7XG4gICAgICAgICAgICBpY29uV2lkdGggPSBNYXRoLm1heChyaWdodEljb24ud2lkdGggKyAyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY2VudGVySWNvbikge1xuICAgICAgICAgICAgaXlvZmZzZXQgPSBNYXRoLnJvdW5kKChoZWlnaHQgLSBjZW50ZXJJY29uLmhlaWdodCkgLyAyKTtcbiAgICAgICAgICAgIGl4b2Zmc2V0ID0gTWF0aC5yb3VuZCgod2lkdGggLSBjZW50ZXJJY29uLndpZHRoKSAvIDIpO1xuICAgICAgICAgICAgZ2MuZHJhd0ltYWdlKGNlbnRlckljb24sIHggKyB3aWR0aCAtIGl4b2Zmc2V0IC0gY2VudGVySWNvbi53aWR0aCwgeSArIGl5b2Zmc2V0KTtcbiAgICAgICAgICAgIGljb25XaWR0aCA9IE1hdGgubWF4KGNlbnRlckljb24ud2lkdGggKyAyKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoY29uZmlnLmNlbGxCb3JkZXJUaGlja25lc3MpIHtcbiAgICAgICAgICAgIGdjLmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgZ2MucmVjdCh4LCB5LCB3aWR0aCwgaGVpZ2h0KTtcbiAgICAgICAgICAgIGdjLmxpbmVXaWR0aCA9IGNvbmZpZy5jZWxsQm9yZGVyVGhpY2tuZXNzO1xuICAgICAgICAgICAgZ2Muc3Ryb2tlU3R5bGUgPSBjb25maWcuY2VsbEJvcmRlclN0eWxlO1xuXG4gICAgICAgICAgICAvLyBhbmltYXRlIHRoZSBkYXNoZWQgbGluZSBhIGJpdCBoZXJlIGZvciBmdW5cblxuICAgICAgICAgICAgZ2Muc3Ryb2tlKCk7XG4gICAgICAgICAgICBnYy5jbG9zZVBhdGgoKTtcbiAgICAgICAgfVxuICAgICAgICBjb25maWcubWluV2lkdGggPSBjb25maWcubWluV2lkdGggKyAyICogKGljb25XaWR0aCk7XG4gICAgfSxcblxuICAgIHJlbmRlck11bHRpTGluZVRleHQ6IGZ1bmN0aW9uKGdjLCB4LCB5LCBoZWlnaHQsIHdpZHRoLCBjb25maWcsIHZhbCkge1xuICAgICAgICB2YXIgbGluZXMgPSBmaXRUZXh0KGdjLCBjb25maWcsIHZhbCwgd2lkdGgpO1xuICAgICAgICBpZiAobGluZXMubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5yZW5kZXJTaW5nbGVMaW5lVGV4dChnYywgeCwgeSwgaGVpZ2h0LCB3aWR0aCwgY29uZmlnLCBzcXVlZXplKHZhbCkpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGNvbEhFZGdlT2Zmc2V0ID0gY29uZmlnLmNlbGxQYWRkaW5nLFxuICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gMCxcbiAgICAgICAgICAgIHZhbGlnbk9mZnNldCA9IGNvbmZpZy52b2Zmc2V0LFxuICAgICAgICAgICAgaGFsaWduID0gY29uZmlnLmhhbGlnbixcbiAgICAgICAgICAgIHRleHRIZWlnaHQgPSBjb25maWcuZ2V0VGV4dEhlaWdodChjb25maWcuZm9udCkuaGVpZ2h0O1xuXG4gICAgICAgIHN3aXRjaCAoaGFsaWduKSB7XG4gICAgICAgICAgICBjYXNlICdyaWdodCc6XG4gICAgICAgICAgICAgICAgaGFsaWduT2Zmc2V0ID0gd2lkdGggLSBjb2xIRWRnZU9mZnNldDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ2NlbnRlcic6XG4gICAgICA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cmluZyB3aGVuIGludmFsaWQpXG4gICAgICAgICAgICAgICAgdGhpcy5maWx0ZXIgPSBmdW5jdGlvbihkYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgIGRhdGFSb3dbZmllbGROYW1lXSA9IGRhdGE7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmaWx0ZXJUcmVlLnRlc3QoZGF0YVJvdyk7XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5maWx0ZXI7XG4gICAgfTtcblxuICAgIHRoaXMuc2V0U3RhdGUgPSBmdW5jdGlvbihzdGF0ZU9iamVjdE9ySnNvblN0cmluZykge1xuICAgICAgICB2YXIgb3B0aW9ucyA9IHtcbiAgICAgICAgICAgIGZpZWxkczogdGhpcy5maWVsZHNQcm92aWRlcigpXG4gICAgICAgIH07XG5cbiAgICAgICAgaWYgKHR5cGVvZiBzdGF0ZU9iamVjdE9ySnNvblN0cmluZyA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgIG9wdGlvbnMuc3RhdGUgPSBzdGF0ZU9iamVjdE9ySnNvblN0cmluZztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG9wdGlvbnMuanNvbiA9IHN0YXRlT2JqZWN0T3JKc29uU3RyaW5nO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuICh0aGlzLmZpbHRlclRyZWUgPSBuZXcgRmlsdGVyVHJlZShvcHRpb25zKSk7XG4gICAgfTtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBDdXN0b21GaWx0ZXI7XG4iLCIndXNlIHN0cmljdCc7XG5cbmZ1bmN0aW9uIG5uKG51bWJlcikge1xuICAgIHJldHVybiAobnVtYmVyIDwgMTAgPyAnLTAnIDogJy0nKSArIG51bWJlcjtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSB7XG4gICAgZGF0ZTogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIHZhbHVlIGluc3RhbmNlb2YgRGF0ZVxuICAgICAgICAgICAgPyB2YWx1ZS5nZXRGdWxsWWVhcigpICsgbm4odmFsdWUuZ2V0TW9udGgoKSArIDEpICsgbm4odmFsdWUuZ2V0RGF0ZSgpKVxuICAgICAgICAgICAgOiB2YWx1ZSArICcnO1xuICAgIH0sXG4gICAgZGVmYXVsdDogZnVuY3Rpb24odmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIHZhbHVlICsgJyc7XG4gICAgfVxufTtcbiIsIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSAoZnVuY3Rpb24oKSB7XG5cbiAgICB2YXIgb2lkUHJlZml4ID0gJy5+LiMlXyc7IC8vdGhpcyBzaG91bGQgYmUgc29tZXRoaW5nIHdlIG5ldmVyIHdpbGwgc2VlIGF0IHRoZSBiZWdpbmluZyBvZiBhIHN0cmluZ1xuICAgIHZhciBjb3VudGVyID0gMDtcblxuICAgIHZhciBoYXNoID0gZnVuY3Rpb24oa2V5KSB7XG4gICAgICAgIHZhciB0eXBlT2YgPSB0eXBlb2Yga2V5O1xuICAgICAgICBzd2l0Y2ggKHR5cGVPZikge1xuICAgICAgICAgICAgY2FzZSAnbnVtYmVyJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gb2lkUHJlZml4ICsgdHlwZU9mICsgJ18nICsga2V5O1xuICAgICAgICAgICAgY2FzZSAnc3RyaW5nJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gb2lkUHJlZml4ICsgdHlwZU9mICsgJ18nICsga2V5O1xuICAgICAgICAgICAgY2FzZSAnYm9vbGVhbic6XG4gICAgICAgICAgICAgICAgcmV0dXJuIG9pZFByZWZpeCArIHR5cGVPZiArICdfJyArIGtleTtcbiAgICAgICAgICAgIGNhc2UgJ3N5bWJvbCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIG9pZFByZWZpeCArIHR5cGVPZiArICdfJyArIGtleTtcbiAgICAgICAgICAgIGNhc2UgJ3VuZGVmaW5lZCc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIG9pZFByZWZpeCArICd1bmRlZmluZWQnO1xuICAgICAgICAgICAgY2FzZSAnb2JqZWN0JzpcbiAgICAgICAgICAgIGNhc2UgJ2Z1bmN0aW9uJzpcbiAgICAgICAgICAgICAgICAvKmVzbGludC1kaXNhYmxlICovXG4gICAgICAgICAgICAgICAgaWYgKCFrZXkuX19fZmluaGFzaCkge1xuICAgICAgICAgICAgICAgICAgICBrZXkuX19fZmluaGFzaCA9IG9pZFByZWZpeCArIGNvdW50ZXIrKztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIGtleS5fX19maW5oYXNoO1xuICAgICAgICAgICAgICAgIC8qZXNsaW50LWVuYWJsZSAqL1xuICAgICAgICB9XG4gICAgfTtcblxuICAgIC8vIE9iamVjdC5pcyBwb2x5ZmlsbCwgY291cnRlc3kgb2YgQFdlYlJlZmxlY3Rpb25cbiAgICB2YXIgaXMgPSBPYmplY3QuaXMgfHxcbiAgICAgICAgZnVuY3Rpb24oYSwgYikge1xuICAgICAgICAgICAgcmV0dXJuIGEgPT09IGIgPyBhICE9PSAwIHx8IDEgLyBhID09IDEgLyBiIDogYSAhPSBhICYmIGIgIT0gYjsgLy8gZXNsaW50LWRpc2FibGUtbGluZVxuICAgICAgICB9O1xuXG4gICAgLy8gTW9yZSByZWxpYWJsZSBpbmRleE9mLCBjb3VydGVzeSBvZiBAV2ViUmVmbGVjdGlvblxuICAgIHZhciBiZXR0ZXJJbmRleE9mID0gZnVuY3Rpb24oYXJyLCB2YWx1ZSkge1xuICAgICAgICBpZiAodmFsdWUgIT0gdmFsdWUgfHwgdmFsdWUgPT09IDApIHsgLy8gZXNsaW50LWRpc2FibGUtbGluZVxuICAgICAgICAgICAgZm9yICh2YXIgaSA9IGFyci5sZW5ndGg7IGktLSAmJiAhaXMoYXJyW2ldLCB2YWx1ZSk7KSB7IC8vIGVzbGludC1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vd1Jvd051bWJlcnMoKSkge1xuICAgICAgICAgICAgc3RhcnQtLTtcbiAgICAgICAgICAgIHRoaXMuY29sdW1uRWRnZXNbLTFdID0gLTE7XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGMgPSBzdGFydDsgYyA8IG51bUNvbHVtbnM7IGMrKykge1xuICAgICAgICAgICAgdnggPSBjO1xuICAgICAgICAgICAgaWYgKGMgPj0gbnVtRml4ZWRDb2x1bW5zKSB7XG4gICAgICAgICAgICAgICAgdnggPSB2eCArIHNjcm9sbExlZnQ7XG4gICAgICAgICAgICAgICAgaWYgKGZpcnN0VlggPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdFZYID0gdng7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGxhc3RWWCA9IHZ4O1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHggPiB2aWV3V2lkdGggfHwgbnVtQ29sdW1ucyA8PSB2eCkge1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgd2lkdGggPSBncmlkLmdldENvbHVtbldpZHRoKHZ4KTtcbiAgICAgICAgICAgIHggPSB4ICsgd2lkdGg7XG4gICAgICAgICAgICB0aGlzLmNvbHVtbkVkZ2VzW2MgKyAxXSA9IE1hdGgucm91bmQoeCk7XG4gICAgICAgICAgICB0aGlzLnZpc2libGVDb2x1bW5zW2NdID0gdng7XG4gICAgICAgICAgICB0aGlzLmNvbHVtbkVkZ2VzSW5kZXhNYXBbdnhdID0gYztcblxuICAgICAgICAgICAgaW5zZXJ0aW9uQm91bmRzQ3Vyc29yID0gaW5zZXJ0aW9uQm91bmRzQ3Vyc29yICsgTWF0aC5yb3VuZCh3aWR0aCAvIDIpICsgcHJldmlvdXNJbnNlcnRpb25Cb3VuZHNDdXJzb3JWYWx1ZTtcbiAgICAgICAgICAgIHRoaXMuaW5zZXJ0aW9uQm91bmRzLnB1c2goaW5zZXJ0aW9uQm91bmRzQ3Vyc29yKTtcbiAgICAgICAgICAgIHByZXZpb3VzSW5zZXJ0aW9uQm91bmRzQ3Vyc29yVmFsdWUgPSBNYXRoLnJvdW5kKHdpZHRoIC8gMik7XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKHIgPSAwOyByIDwgbnVtUm93czsgcisrKSB7XG4gICAgICAgICAgICB2eSA9IHI7XG4gICAgICAgICAgICBpZiAociA+PSBudW1GaXhlZFJvd3MpIHtcbiAgICAgICAgICAgICAgICB2eSA9IHZ5ICsgc2Nyb2xsVG9wO1xuICAgICAgICAgICAgICAgIGlmIChmaXJzdFZZID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgZmlyc3RWWSA9IHZ5O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBsYXN0VlkgPSB2eTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmICh5ID4gdmlld0hlaWdodCB8fCBudW1Sb3dzIDw9IHZ5KSB7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBoZWlnaHQgPSBncmlkLmdldFJvd0hlaWdodCh2eSk7XG4gICAgICAgICAgICB5ID0geSArIGhlaWdodDtcbiAgICAgICAgICAgIHRoaXMucm93RWRnZXNbciArIDFdID0gTWF0aC5yb3VuZCh5KTtcbiAgICAgICAgICAgIHRoaXMudmlzaWJsZVJvd3Nbcl0gPSB2eTtcbiAgICAgICAgICAgIHRoaXMucm93RWRnZXNJbmRleE1hcFt2eV0gPSByO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMudmlld0hlaWdodCA9IHZpZXdIZWlnaHQ7XG4gICAgICAgIHRoaXMuZGF0YVdpbmRvdyA9IHRoaXMuZ3JpZC5uZXdSZWN0YW5nbGUoZmlyc3RWWCwgZmlyc3RWWSwgbGFzdFZYIC0gZmlyc3RWWCwgbGFzdFZZIC0gZmlyc3RWWSk7XG4gICA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XJlZC5cbiAgICAgKi9cbiAgICBnZXRWaXNpYmxlQ29sdW1uczogZnVuY3Rpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnZpc2libGVDb2x1bW5zO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQHJldHVybnMge251bWJlcn0gVGhlIGNvbHVtbiBpbmRleCB3aG5lIHRoZSBtb3VzZUV2ZW50IGNvb3JkaW5hdGVzIGFyZSBvdmVyIGEgY29sdW1uIGRpdmlkZXIuXG4gICAgICovXG4gICAgb3ZlckNvbHVtbkRpdmlkZXI6IGZ1bmN0aW9uKHgpIHtcbiAgICAgICAgeCA9IE1hdGgucm91bmQoeCk7XG4gICAgICAgIHZhciBlZGdlcyA9IHRoaXMuZ2V0Q29sdW1uRWRnZXMoKTtcbiAgICAgICAgdmFyIHdoaWNoQ29sID0gZWRnZXMuaW5kZXhPZih4IC0gMSk7XG4gICAgICAgIGlmICh3aGljaENvbCA8IDApIHtcbiAgICAgICAgICAgIHdoaWNoQ29sID0gZWRnZXMuaW5kZXhPZih4KTtcbiAgICAgICAgfVxuICAgICAgICBpZiAod2hpY2hDb2wgPCAwKSB7XG4gICAgICAgICAgICB3aGljaENvbCA9IGVkZ2VzLmluZGV4T2YoeCAtIDIpO1xuICAgICAgICB9XG4gICAgICAgIGlmICh3aGljaENvbCA8IDApIHtcbiAgICAgICAgICAgIHdoaWNoQ29sID0gZWRnZXMuaW5kZXhPZih4ICsgMSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHdoaWNoQ29sIDwgMCkge1xuICAgICAgICAgICAgd2hpY2hDb2wgPSBlZGdlcy5pbmRleE9mKHggLSAzKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB3aGljaENvbDtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFJlbmRlcmVyLnByb3RvdHlwZVxuICAgICAqIEByZX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leTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHkgPSB0aGlzLnJvd0VkZ2VzSW5kZXhNYXBbcl07XG4gICAgICAgICAgICBpZiAoeSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgeSA9IHRoaXMucm93RWRnZXNJbmRleE1hcFtyIC0gMV07XG4gICAgICAgICAgICAgICAgeU91dHNpZGUgPSB0cnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBveSA9IHRoaXMucm93RWRnZXNbeV07XG4gICAgICAgICAgICBjeSA9IHRoaXMucm93RWRnZXNbeSArIDFdO1xuICAgICAgICAgICAgZXkgPSBjeSAtIG95O1xuICAgICAgICB9XG5cbiAgICAgICAgY2VsbC55ID0geU91dHNpZGUgPyBjeSA6IG95O1xuICAgICAgICBjZWxsLmhlaWdodCA9IHlPdXRzaWRlID8gMCA6IGV5O1xuXG4gICAgICAgIHJldHVybiBjZWxsO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJvdG90eXBlXG4gICAgICogQGRlc2MgYW5zd2VyIHRoZSBjb2x1bW4gaW5kZXggdW5kZXIgdGhlIGNvb3JkaW5hdGUgYXQgcGl4ZWxYXG4gICAgICogQHBhcmFtIHtudW1iZXJ9IHBpeGVsWCAtIFRoZSBob3Jpem9udGFsIGNvb3JkaW5hdGUuXG4gICAgICogQHJldHVybnMge251bWJlcn0gVGhlIGNvbHVtbiBpbmRleCB1bmRlciB0aGUgY29vcmRpbmF0ZSBhdCBwaXhlbFguXG4gICAgICovXG4gICAgZ2V0Q29sdW1uRnJvbVBpeGVsWDogZnVuY3Rpb24ocGl4ZWxYKSB7XG4gICAgICAgIHZhciB3aWR0aCA9IDAsXG4gICAgICAgICAgICBmaXhlZENvbHVtbkNvdW50ID0gdGhpcy5nZXRGaXhlZENvbHVtbkNvdW50KCksXG4gICAgICAgICAgICBzY3JvbGxMZWZ0ID0gdGhpcy5ncmlkLmdldEhTY3JvbGxWYWx1ZSgpLFxuICAgICAgICAgICAgZWRnZXMgPSB0aGlzLmdldENvbHVtbkVkZ2VzKCk7XG5cbiAgICAgICAgZm9yICh2YXIgYyA9IDE7IGMgPCBlZGdlcy5sZW5ndGggLSAxOyBjKyspIHtcbiAgICAgICAgICAgIHdpZHRoID0gZWRnZXNbY10gLSAoZWRnZXNbY10gLSBlZGdlc1tjIC0gMV0pIC8gMjtcbiAgICAgICAgICAgIGlmIChwaXhlbFggPCB3aWR0aCkge1xuICAgICAgICAgICAgICAgIGlmIChjID4gZml4ZWRDb2x1bW5Db3VudCkge1xuICAgICAgICAgICAgICAgICAgICBjID0gYyArIHNjcm9sbExlZnQ7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBjIC0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoYyA+IGZpeGVkQ29sdW1uQ291bnQpIHtcbiAgICAgICAgICAgIGMgPSBjICsgc2Nyb2xsTGVmdDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYyAtIDE7XG4gICAgfSxcblxuXG4gICAgLyoqXG4gICAgICogQG1lbWJlck9mIFJlbmRlcmVyLnByb3RvdHlwZVxuICAgICAqIEBkZXNjIEFuc3dlciBzcGVjaWZpYyBkYXRhIGNlbGwgY29vcmRpbmF0ZXMgZ2l2ZW4gbW91c2UgY29vcmRpbmF0ZXMgaW4gcGl4ZWxzLlxuICAgICAqIEBwYXJhbSB7UG9pbnR9IHBvaW50XG4gICAgICogQHJldHVybnMge1BvaW50fSBDZWxsIGNvb3JkaW5hdGVzXG4gICAgICovXG4gICAgZ2V0R3JpZENlbGxGcm9tTW91c2VQb2ludDogZnVuY3Rpb24ocG9pbnQpIHtcblxuICAgICAgICB2YXIgYmVoYXZpb3IgPSB0aGlzLmdyaWQuYmVoYXZpb3I7XG4gICAgICAgIHZhciB3aWR0aCA9IDA7XG4gICAgICAgIHZhciBoZWlnaHQgPSAwO1xuICAgICAgICB2YXIgeCwgeSwgYywgcjtcbiAgICAgICAgdmFyIHByZXZpb3VzID0gMDtcbiAgICAgICAgdmFyIGNvbHVtbkVkZ2VzID0gdGhpcy5nZXRDb2x1bW5FZGdlcygpO1xuICAgICAgICB2YXIgZml4ZWRDb2x1bW5Db3VudCA9IHRoaXMuZ2V0Rml4ZWRDb2x1bW5Db3VudCgpOyAvLyArIGdyaWRTaXplO1xuICAgICAgICB2YXIgZml4ZWRSb3dDb3VudCA9IHRoaXMuZ2V0Rml4ZWRSb3dDb3VudCgpO1xuXG4gICAgICAgIC8vIHZhciBmaXhlZENvbHVtbkNvdW50ID0gdGhpcy5nZXRGaXhlZENvbHVtbkNvdW50KCk7XG4gICAgICAgIC8vIHZhciBmaXhlZFJvd0NvdW50ID0gdGhpcy5nZXRGaXhlZFJvd0NvdW50KCk7XG4gICAgICAgIHZhciBzY3JvbGxYID0gdGhpcy5nZXRTY3JvbGxMZWZ0KCk7XG4gICAgICAgIHZhciBzY3JvbGxZID0gdGhpcy5nZXRTY3JvbGxUb3AoKTtcblxuICAgICAgICBmb3IgKGMgPSAwOyBjIDwgY29sdW1uRWRnZXMubGVuZ3RoOyBjKyspIHtcbiAgICAgICAgICAgIHdpZHRoID0gY29sdW1uRWRnZXNbY107XG4gICAgICAgICAgICBpZiAocG9pbnQueCA8IHdpZHRoKSB7XG4gICAgICAgICAgICAgICAgeCA9IE1hdGgubWF4KDAsIHBvaW50LnggLSBwcmV2aW91cyAtIDIpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcHJldmlvdXMgPSB3aWR0aDtcbiAgICAgICAgfVxuICAgICAgICBjLS07XG4gICAgICAgIHByZXZpb3VzID0gMDtcbiAgICAgICAgZm9yIChyID0gMDsgciA8IHRoaXMucm93RWRnZXMubGVuZ3RoOyByKyspIHtcbiAgICAgICAgICAgIGhlaWdodCA9IHRoaXMucm93RWRnZXNbcl07XG4gICAgICAgICAgICBpZiAocG9pbnQueSA8IGhlaWdodCkge1xuICAgICAgICAgICAgICAgIHkgPSBNYXRoLm1heCgwLCBwb2ludC55IC0gcHJldmlvdXMgLSAyKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHByZXZpb3VzID0gaGVpZ2h0O1xuICAgICAgICB9XG4gICAgICAgIHItLTtcbiAgICAgICAgaWYgKHBvaW50LnggPCAwKSB7XG4gICAgICAgICAgICBjID0gLTE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHBvaW50LnkgPCAwKSB7XG4gICAgICAgICAgICByID0gLTE7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgdmlld1BvaW50ID0gdGhpcy5ncmlkLm5ld1BvaW50KGMsIHIpO1xuXG4gICAgICAgIC8vY29tcGVuc2F0ZSBpZiB3ZSBhcmUgc2Nyb2xsZWRcbiAgICAgICAgaWYgKGMgPj0gZml4ZWRDb2x1bW5Db3VudCkge1xuICAgICAgICAgICAgYyA9IGMgKyBzY3JvbGxYO1xuICAgICAgICB9XG4gICAgICAgIGlmIChyID49IGZpeGVkUm93Q291bnQpIHtcbiAgICAgICAgICAgIHIgPSByICsgc2Nyb2xsWTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciB0cmFuc2xhdGVkSW5kZXggPSAtMTtcblxuICAgICAgICB2YXIgY29sdW1uID0gYmVoYXZpb3IuZ2V0Q29sdW1uKGMpO1xuICAgICAgICBpZiAoY29sdW1uKSB7XG4gICAgICAgICAgICB0cmFuc2xhdGVkSW5kZXggPSBjb2x1bW4uaW5kZXg7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgZ3JpZENlbGw6IHRoaXMuZ3JpZC5uZXdQb2ludChjLCByKSxcbiAgICAgICAgICAgIG1vdXNlUG9pbnQ6IHRoaXMuZ3JpZC5uZXdQb2ludCh4LCB5KSxcbiAgICAgICAgICAgIHZ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AgICAgICAgICAgICBnYy5jbGlwKCk7XG5cbiAgICAgICAgICAgICAgICAvLyBGb3IgZWFjaCByb3cgKG9mIGVhY2ggY29sdW1uKS4uLlxuICAgICAgICAgICAgICAgIGZvciAoeSA9IDA7IHkgPCB2aXNpYmxlUm93cy5sZW5ndGg7IHkrKykge1xuXG4gICAgICAgICAgICAgICAgICAgIHIgPSB2aXNpYmxlUm93c1t5XTtcblxuICAgICAgICAgICAgICAgICAgICB0cnkge1xuXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYWludENlbGwoZ2MsIGMsIHIpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAvL2lmIChyID09PSA5ICYmIGMgPT09IDIpIHsgdGhyb3cgRXJyb3IoJ1NoZSBzZWxscyBzZWEgc2hlbGxzIGJ5IHRoZSBzZWEgc2hvcmUuJyk7IH1cblxuICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UgPSBlICYmIChlLm1lc3NhZ2UgfHwgZSkgfHwgJ1Vua25vd24gZXJyb3IuJztcblxuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihtZXNzYWdlKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlckNlbGxFcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByYXdHYyA9IGdjLmdjIHx8IGdjLCAvLyBEb24ndCBsb2cgdGhlc2UgY2FudmFzIGNhbGxzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyclkgPSByb3dFZGdlc1t5XSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJySGVpZ2h0ID0gcm93RWRnZXNbeSArIDFdIC0gZXJyWTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhd0djLnNhdmUoKTsgLy8gZGVmaW5lIGNsaXBwaW5nIHJlZ2lvblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhd0djLmJlZ2luUGF0aCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhd0djLnJlY3QoY2xpcFgsIGVyclksIGNsaXBXaWR0aCwgZXJySGVpZ2h0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdHYy5jbGlwKCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJDZWxsRXJyb3IocmF3R2MsIG1lc3NhZ2UsIGNsaXBYLCBlcnJZLCBjbGlwV2lkdGgsIGVyckhlaWdodCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdHYy5yZXN0b3JlKCk7IC8vIGRpc2NhcmQgY2xpcHBpbmcgcmVnaW9uXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIC8vIEJvdHRvbSB0b3RhbHMgcm93cy4uLlxuICAgICAgICAgICAgICAgIGZvciAoeSA9IC1iZWhhdmlvci5nZXREYXRhTW9kZWwoKS5nZXRCb3R0b21Ub3RhbHMoKS5sZW5ndGg7IHk7IHkrKykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYWludENlbGwoZ2MsIGMsIHkpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGdjLnJlc3RvcmUoKTsgLy8gUmVtb3ZlIGNvbHVtbidzIGNsaXAgcmVnaW9uIChhbmQgYW55dGhpbmcgZWxzZSByZW5kZXJDZWxsRXJyb3IoKSBtaWdodCBoYXZlIHNldClcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHNldE51bWJlckNvbHVtbldpZHRoKGdjLCBiZWhhdmlvciwgdGhpcy5ncmlkLmdldFJvd0NvdW50KCkpO1xuICAgIH0sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgUmVuZGVyZXIucHJv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ocy5sZW5ndGggKyAxOyBjKyspIHtcbiAgICAgICAgICAgICAgICB4ID0gY29sV2lkdGhzW2NdICsgMC41O1xuICAgICAgICAgICAgICAgIGdjLm1vdmVUbyh4LCAwKTtcbiAgICAgICAgICAgICAgICBnYy5saW5lVG8oeCwgdmlld0hlaWdodCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoZHJhd1RoZW1IKSB7XG4gICAgICAgICAgICBmb3IgKHIgPSAwOyByIDwgcm93SGVpZ2h0cy5sZW5ndGggLSAxOyByKyspIHtcbiAgICAgICAgICAgICAgICB5ID0gcm93SGVpZ2h0c1tyXSArIDAuNTtcbiAgICAgICAgICAgICAgICBnYy5tb3ZlVG8oMCwgeSk7XG4gICAgICAgICAgICAgICAgZ2MubGluZVRvKHZpZXdXaWR0aCwgeSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIC8vIEJvdHRvbSB0b3RhbHMgcm93cy4uLlxuICAgICAgICAgICAgdmFyIGJlaGF2aW9yID0gdGhpcy5ncmlkLmJlaGF2aW9yLFxuICAgICAgICAgICAgICAgIHJvd0hlaWdodCA9IGJlaGF2aW9yLmdldERlZmF1bHRSb3dIZWlnaHQoKTtcbiAgICAgICAgICAgIGZvciAociA9IC1iZWhhdmlvci5nZXREYXRhTW9kZWwoKS5nZXRCb3R0b21Ub3RhbHMoKS5sZW5ndGgsIHkgPSB0aGlzLmdldEJvdW5kcygpLmhlaWdodDsgcjsgcisrKSB7XG4gICAgICAgICAgICAgICAgeSAtPSByb3dIZWlnaHQ7XG4gICAgICAgICAgICAgICAgZ2MubW92ZVRvKDAsIHkpO1xuICAgICAgICAgICAgICAgIGdjLmxpbmVUbyh2aWV3V2lkdGgsIHkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZ2MuY2xvc2VQYXRoKCk7XG5cbiAgICAgICAgZ2Muc3Ryb2tlU3R5bGUgPSBsaW5lQ29sb3I7XG4gICAgICA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1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQucHVzaCh0aSk7XG4gICAgICAgICAgICAgICAgICAgIHNldFt0aV0gPSB0cnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHJlc3VsdC5zb3J0KGZ1bmN0aW9uKHgsIHkpIHtcbiAgICAgICAgICAgIHJldHVybiB4IC0geTtcbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBTZWxlY3Rpb25Nb2RlbC5wcm90b3R5cGVcbiAgICAgKiBAcGFyYW0gb2Zmc2V0XG4gICAgICovXG4gICAgc2VsZWN0Um93c0Zyb21DZWxsczogZnVuY3Rpb24ob2Zmc2V0LCBkb250Q2xlYXJSb3dTZWxlY3Rpb25zKSB7XG4gICAgICAgIG9mZnNldCA9IG9mZnNldCB8fCAwO1xuICAgICAgICBkb250Q2xlYXJSb3dTZWxlY3Rpb25zID0gZG9udENsZWFyUm93U2VsZWN0aW9ucyA9PT0gdHJ1ZTtcblxuICAgICAgICB2YXIgc20gPSB0aGlzLnJvd1NlbGVjdGlvbk1vZGVsO1xuXG4gICAgICAgIGlmICghZG9udENsZWFyUm93U2VsZWN0aW9ucykge1xuICAgICAgICAgICAgdGhpcy5zZXRBbGxSb3dzU2VsZWN0ZWQoZmFsc2UpO1xuICAgICAgICAgICAgc20uY2xlYXIoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRoaXMuc2VsZWN0aW9ucy5mb3JFYWNoKGZ1bmN0aW9uKHNlbGVjdGlvbikge1xuICAgICAgICAgICAgdmFyIHRvcCA9IHNlbGVjdGlvbi5vcmlnaW4ueSxcbiAgICAgICAgICAgICAgICBleHRlbnQgPSBzZWxlY3Rpb24uZXh0ZW50Lnk7XG4gICAgICAgICAgICB0b3AgKz0gb2Zmc2V0O1xuICAgICAgICAgICAgc20uc2VsZW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sXG5cbiAgICAvKipcbiAgICAgKiBAbWVtYmVyT2YgU2VsZWN0aW9uTW9kZWwucHJvdG90eXBlXG4gICAgICogQHBhcmFtIHJlY3RcbiAgICAgKiBAcGFyYW0geFxuICAgICAqIEBwYXJhbSB5XG4gICAgICogQHJldHVybnMge2Jvb2xlYW59XG4gICAgICovXG4gICAgcmVjdGFuZ2xlQ29udGFpbnM6IGZ1bmN0aW9uKHJlY3QsIHgsIHkpIHsgLy9UT0RPOiBleHBsb3JlIHdoeSB0aGlzIHdvcmtzIGFuZCBjb250YWlucyBvbiByZWN0YW5nbHVsYXIgZG9lcyBub3RcbiAgICAgICAgdmFyIG1pblggPSByZWN0Lm9yaWdpbi54O1xuICAgICAgICB2YXIgbWluWSA9IHJlY3Qub3JpZ2luLnk7XG4gICAgICAgIHZhciBtYXhYID0gbWluWCArIHJlY3QuZXh0ZW50Lng7XG4gICAgICAgIHZhciBtYXhZID0gbWluWSArIHJlY3QuZXh0ZW50Lnk7XG5cbiAgICAgICAgaWYgKHJlY3QuZXh0ZW50LnggPCAwKSB7XG4gICAgICAgICAgICBtaW5YID0gbWF4WDtcbiAgICAgICAgICAgIG1heFggPSByZWN0Lm9yaWdpbi54O1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHJlY3QuZXh0ZW50LnkgPCAwKSB7XG4gICAgICAgICAgICBtaW5ZID0gbWF4WTtcbiAgICAgICAgICAgIG1heFkgPSByZWN0Lm9yaWdpbi55O1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIHJlc3VsdCA9XG4gICAgICAgICAgICB4ID49IG1pblggJiZcbiAgICAgICAgICAgIHkgPj0gbWluWSAmJlxuICAgICAgICAgICAgeCA8PSBtYXhYICYmXG4gICAgICAgICAgICB5IDw9IG1heFk7XG5cbiAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG59O1xuXG5tb2R1bGUuZXhwb3J0cyA9IFNlbGVjdGlvbk1vZGVsO1xuIiwiLyogZXNsaW50LWVudiB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Y3Rpb24ocmVjdCkge1xuICAgICAgICBpZiAodGhpcy5pc09wZW4oKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMub3Blbk5vdyA9IHRydWU7XG4gICAgICAgIHZhciBzZWxmID0gdGhpcztcbiAgICAgICAgdmFyIHN0eWxlID0gdGhpcy5vdmVybGF5LnN0eWxlO1xuICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSB0aGlzLmdyaWQucmVzb2x2ZVByb3BlcnR5KCdiYWNrZ3JvdW5kQ29sb3InKTtcblxuICAgICAgICB2YXIgYm91bmRzID0gdGhpcy5ncmlkLmRpdi5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKSxcbiAgICAgICAgICAgIG1hcmdpbnMgPSByZWN0LnkgKyAncHggJyArXG4gICAgICAgICAgICAgICAgKGJvdW5kcy53aWR0aCAtIChyZWN0LnggKyByZWN0LndpZHRoKSkgKyAncHggJyArXG4gICAgICAgICAgICAgICAgKGJvdW5kcy5oZWlnaHQgLSAocmVjdC55ICsgcmVjdC5oZWlnaHQpKSArICdweCAnICtcbiAgICAgICAgICAgICAgICByZWN0LnggKyAncHgnO1xuXG4gICAgICAgIHN0eWxlLndlYmtpdFRyYW5zaXRpb24gPSAnJztcblxuICAgICAgICBzdHlsZS50b3AgPSBzdHlsZS5yaWdodCA9IHN0eWxlLmJvdHRvbSA9IHN0eWxlLmxlZnQgPSAwO1xuXG4gICAgICAgIHN0eWxlLm1hcmdpbiA9IG1hcmdpbnM7XG4gICAgICAgIHN0eWxlLnpJbmRleCA9IDEwMDtcbiAgICAgICAgc3R5bGUub3BhY2l0eSA9IDE7XG5cbiAgICAgICAgdGhpcy5jbG9zZVRyYW5zaXRpb24gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHN0eWxlLm1hcmdpbiA9IG1hcmdpbnM7XG4gICAgICAgIH07XG5cbiAgICAgICAgaWYgKCF0aGlzLl9jbG9zZXIpIHtcbiAgICAgICAgICAgIHRoaXMuX2Nsb3NlciA9IGZ1bmN0aW9uKGUpIHtcbiAgICAgICAgICAgICAgICB2YXIga2V5ID0gc2VsZi5nZXRDaGFyRm9yKGUua2V5Q29kZSkudG9Mb3dlckNhc2UoKTtcbiAgICAgICAgICAgICAgICB2YXIga2V5cyA9IHNlbGYuZ3JpZC5yZXNvbHZlUHJvcGVydHkoJ2VkaXRvckFjdGl2YXRpb25LZXlzJyk7XG4gICAgICAgICAgICAgICAgaWYgKGtleXMuaW5kZXhPZihrZXkpID4gLTEgfHwgZS5rZXlDb2RlID09PSAyNykge1xuICAgICAgICAgICAgICAgICAgICBlLnByZXZlbnREZWZhdWx0KCk7XG4gICAgICAgICAgICAgICAgICAgIHNlbGYuY2xvc2UoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgLy9ncmlkLnNldEZvY3VzYWJsZShmYWxzZSk7XG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoJ2tleWRvd24nLCBzZWxmLl9jbG9zZXIsIGZhbHNlKTtcbiAgICAgICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlLndlYmtpdFRyYW5zaXRpb24gPSAnbWFyZ2luLXRvcCAnICsgVFJBTlNJVElPTiArICcsIG1hcmdpbi1yaWdodCAnICsgVFJBTlNJVElPTiArICcsIG1hcmdpbi1ib3R0b20gJyArIFRSQU5TSVRJT04gKyAnLCBtYXJnaW4tbGVmdCAnICsgVFJBTlNJVElPTjtcbiAgICAgICAgICAgICAgICAgICAgc3R5bGUubWFyZ2luID0gJzE1cHggMzVweCAzNXB4IDE1cHgnO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgc2VsZi5vdmVybGF5LmZvY3VzKCk7XG4gICAgICAgIH0sIDEwMCk7XG4gICAgfSxcblxuICAgIC8qKlxuICAgICAqIEBtZW1iZXJPZiBPdmVybGF5LnByb3RvdHlwZVxuICAgICAqIEBkZXNjIGNsb3NlIHRoZSBvdmVybGF5XG4gICAgICogQHBhcmFtIHtIeXBlcmdyaWR9IGdyaWRcbiAgICAgKi9cbiAgICBjbG9zZTogZnVuY3Rpb24oKSB7XG4gICAgICAgIC8vZ3JpZC5zZXRGb2N1c2FibGUodHJ1ZSk7XG4gICAgICAgIHRoaXMub3Blbk5vdyA9IGZhbHNlO1xuICAgICAgICBkb2N1bWVudC5yZW1vdmVFdmVudExpc3RlbmVyKCdrZXlkb3duJywgdGhpcy5fY2xvc2VyLCBmYWxzZSk7XG5cbiAgICAgICAgdmFyIHNlbGYgPSB0aGlzO1xuXG4gICAgICAgIHJlcXVlc3RBbmltYXRpb25GcmFtZShmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHNlbGYuY2xvc2VUcmFuc2l0aW9uKCk7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICBzZWxmLmNsZWFyKCk7XG4gICAgICAgICAgICBzZWxmLm92ZXJsYXkuc3R5bGUuekluZGV4ID0gLTEwMDA7XG4gICAgICAgICAgICBpZiAoc2VsZi5vbkNsb3NlKSB7XG4gICAgICAgICAgICAgICAgc2VsZi5vbkNsb3NlKCk7XG4gICAgICAgICAgICAgICAgc2VsZi5vbkNsb3NlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc2VsZi5ncmlkLnRha2VGb2N1cygpO1xuICAgICAgICB9L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AgICAgaWYgKHRoaXMuZmlsdGVyKSB7XG4gICAgICAgICAgICByZXR1cm4gMDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5kYXRhU291cmNlLmdldFJvd0NvdW50KCk7XG4gICAgfTtcblxuICAgIERhdGFTb3VyY2VHbG9iYWxGaWx0ZXIucHJvdG90eXBlLmFwcGx5ID0gZnVuY3Rpb24odmlzaWJsZUNvbHVtbnMpIHtcbiAgICAgICAgaWYgKCF0aGlzLmZpbHRlcikge1xuICAgICAgICAgICAgdGhpcy5pbmRleGVzLmxlbmd0aCA9IDA7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHZpc2libGVDb2x1bW5NYXAgPSB0aGlzLnZpc2libGVDb2x1bW5NYXAgPSBbXTtcbiAgICAgICAgdmlzaWJsZUNvbHVtbnMuZm9yRWFjaChmdW5jdGlvbihjb2x1bW4pIHtcbiAgICAgICAgICAgIHZpc2libGVDb2x1bW5NYXAucHVzaChjb2x1bW4uaW5kZXgpO1xuICAgICAgICB9KTtcbiAgICAgICAgdmFyIGluZGV4ZXMgPSB0aGlzLmluZGV4ZXM7XG4gICAgICAgIGluZGV4ZXMubGVuZ3RoID0gMDtcbiAgICAgICAgdmFyIGNvdW50ID0gdGhpcy5kYXRhU291cmNlLmdldFJvd0NvdW50KCk7XG4gICAgICAgIGZvciAodmFyIHIgPSAwOyByIDwgY291bnQ7IHIrKykge1xuICAgICAgICAgICAgaWYgKHRoaXMuYXBwbHlGaWx0ZXJUbyhyKSkge1xuICAgICAgICAgICAgICAgIGluZGV4ZXMucHVzaChyKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH07XG5cbiAgICBEYXRhU291cmNlR2xvYmFsRmlsdGVyLnByb3RvdHlwZS5hcHBseUZpbHRlclRvID0gZnVuY3Rpb24ocikge1xuICAgICAgICB2YXIgaXNGaWx0ZXJlZCA9IGZhbHNlO1xuICAgICAgICB2YXIgZmlsd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ByZXR1cm4gcy5jaGFyQXQoMCkudG9VcHBlckNhc2UoKSArIHMuc2xpY2UoMSk7XG4gICAgICAgIH0pO1xuICAgICAgICByZXR1cm4gcGllY2VzLmpvaW4oJyAnKTtcbiAgICB9O1xuXG4gICAgdmFyIGNvbXB1dGVGaWVsZE5hbWVzID0gZnVuY3Rpb24ob2JqZWN0KSB7XG4gICAgICAgIGlmICghb2JqZWN0KSB7XG4gICAgICAgICAgICByZXR1cm4gW107XG4gICAgICAgIH1cbiAgICAgICAgdmFyIGZpZWxkcyA9IFtdLmNvbmNhdChPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhvYmplY3QpLmZpbHRlcihmdW5jdGlvbihlKSB7XG4gICAgICAgICAgICByZXR1cm4gZS5zdWJzdHIoMCwgMikgIT09ICdfXyc7XG4gICAgICAgIH0pKTtcbiAgICAgICAgcmV0dXJuIGZpZWxkcztcbiAgICB9O1xuXG4gICAgZnVuY3Rpb24gSlNEYXRhU291cmNlKGRhdGEsIGZpZWxkcykge1xuICAgICAgICB0aGlzLmZpZWxkcyA9IGZpZWxkcyB8fCBjb21wdXRlRmllbGROYW1lcyhkYXRhWzBdKTtcbiAgICAgICAgdGhpcy5oZWFkZXJzID0gW107XG4gICAgICAgIHRoaXMuZGF0YSA9IGRhdGE7XG4gICAgfVxuXG4gICAgSlNEYXRhU291cmNlLnByb3RvdHlwZS5pc051bGxPYmplY3QgPSBmYWxzZTtcblxuICAgIEpTRGF0YVNvdXJjZS5wcm90b3R5cGUuZ2V0VmFsdWUgPSBmdW5jdGlvbih4LCB5KSB7XG4gICAgICAgIHZhciByb3cgPSB0aGlzLmRhdGFbeV07XG4gICAgICAgIGlmICghcm93KSB7XG4gICAgICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgICAgfVxuICAgICAgICB2YXIgdmFsdWUgPSByb3dbdGhpcy5maWVsZHNbeF1dO1xuICAgICAgICByZXR1cm4gdmFsdWU7XG4gICAgfTtcblxuICAgIEpTRGF0YVNv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iAgICByZXR1cm4ge1xuXG4gICAgICAgIGNvdW50OiBmdW5jdGlvbigpIHsgLyogY29sdW1JbmRleCAqL1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIHJldHVybiByb3dzO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSxcblxuICAgICAgICBzdW06IGZ1bmN0aW9uKGNvbHVtSW5kZXgpIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbihncm91cCkge1xuICAgICAgICAgICAgICAgIHZhciBzdW0gPSAwO1xuICAgICAgICAgICAgICAgIHZhciByb3dzID0gZ3JvdXAuZ2V0Um93Q291bnQoKTtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciByID0gMDsgciA8IHJvd3M7IHIrKykge1xuICAgICAgICAgICAgICAgICAgICBzdW0gPSBzdW0gKyBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHN1bTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0sXG5cbiAgICAgICAgbWluOiBmdW5jdGlvbihjb2x1bUluZGV4KSB7XG4gICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24oZ3JvdXApIHtcbiAgICAgICAgICAgICAgICB2YXIgbWluID0gSW5maW5pdHk7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIHIgPSAwOyByIDwgcm93czsgcisrKSB7XG4gICAgICAgICAgICAgICAgICAgIG1pbiA9IE1hdGgubWluKG1pbiwgZ3JvdXAuZ2V0VmFsdWUoY29sdW1JbmRleCwgcikpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gbWluO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSxcblxuXG4gICAgICAgIG1heDogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIG1heCA9IC1JbmZpbml0eTtcbiAgICAgICAgICAgICAgICB2YXIgcm93cyA9IGdyb3VwLmdldFJvd0NvdW50KCk7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgciA9IDA7IHIgPCByb3dzOyByKyspIHtcbiAgICAgICAgICAgICAgICAgICAgbWF4ID0gTWF0aC5tYXgobWF4LCBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBtYXg7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuXG4gICAgICAgIGF2ZzogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHN1bSA9IDA7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIGZvciAodmFyIHIgPSAwOyByIDwgcm93czsgcisrKSB7XG4gICAgICAgICAgICAgICAgICAgIHN1bSA9IHN1bSArIGdyb3VwLmdldFZhbHVlKGNvbHVtSW5kZXgsIHIpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gc3VtIC8gcm93cztcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0sXG5cbiAgICAgICAgZmlyc3Q6IGZ1bmN0aW9uKGNvbHVtSW5kZXgpIHtcbiAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbihncm91cCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCAwKTtcbiAgICAgICAgICAgIH07XG4gICAgICAgIH0sXG5cbiAgICAgICAgbGFzdDogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIHJldHVybiBncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByb3dzIC0gMSk7XG4gICAgICAgICAgICB9O1xuICAgICAgICB9LFxuXG4gICAgICAgIHN0ZGRldjogZnVuY3Rpb24oY29sdW1JbmRleCkge1xuICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHI7XG4gICAgICAgICAgICAgICAgdmFyIHN1bSA9IDA7XG4gICAgICAgICAgICAgICAgdmFyIHJvd3MgPSBncm91cC5nZXRSb3dDb3VudCgpO1xuICAgICAgICAgICAgICAgIGZvciAociA9IDA7IHIgPCByb3dzOyByKyspIHtcbiAgICAgICAgICAgICAgICAgICAgc3VtID0gc3VtICsgZ3JvdXAuZ2V0VmFsdWUoY29sdW1JbmRleCwgcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBtZWFuID0gc3VtIC8gcm93cztcbiAgICAgICAgICAgICAgICB2YXIgdmFyaWFuY2UgPSAwO1xuICAgICAgICAgICAgICAgIGZvciAociA9IDA7IHIgPCByb3dzOyByKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGRldiA9IChncm91cC5nZXRWYWx1ZShjb2x1bUluZGV4LCByKSAtIG1lYW4pO1xuICAgICAgICAgICAgICAgICAgICB2YXJpYW5jZSA9IHZhcmlhbmNlICsgKGRldiAqIGRldik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHZhciBzdGRkZXYgPSBNYXRoLnNxcnQodmFyaWFuY2UgLyByb3dzKTtcbi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NvdXJjZUFnZ3JlZ2F0b3IsXG4gICAgICAgIGFnZ3JlZ2F0aW9uczogYWdncmVnYXRpb25zXG4gICAgfTtcblxufSkoKTtcbiIsIid1c2Ugc3RyaWN0JztcblxudmFyIHN0YWJpbGl6ZSA9IGZ1bmN0aW9uKGNvbXBhcmF0b3IsIGRlc2NlbmRpbmcpIHtcbiAgICByZXR1cm4gZnVuY3Rpb24oYXJyMSwgYXJyMikge1xuICAgICAgICB2YXIgeCA9IGFycjFbMF07XG4gICAgICAgIHZhciB5ID0gYXJyMlswXTtcbiAgICAgICAgaWYgKHggPT09IHkpIHtcbiAgICAgICAgICAgIHggPSBkZXNjZW5kaW5nID8gYXJyMlsxXSA6IGFycjFbMV07XG4gICAgICAgICAgICB5ID0gZGVzY2VuZGluZyA/IGFycjFbMV0gOiBhcnIyWzFdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHkgPT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gLTE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoeCA9PT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIHJldHVybiAxO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiBjb21wYXJhdG9yKHgsIHkpO1xuICAgIH07XG59O1xuXG5cbnZhciBhc2NlbmRpbmdOdW1iZXJzID0gZnVuY3Rpb24oeCwgeSkge1xuICAgIHJldHVybiB4IC0geTtcbn07XG5cbnZhciBkZXNjZW5kaW5nTnVtYmVycyA9IGZ1bmN0aW9uKHgsIHkpIHtcbiAgICByZXR1cm4geSAtIHg7XG59O1xuXG52YXIgYXNjZW5kaW5nQWxsT3RoZXJzID0gZnVuY3Rpb24oeCwgeSkge1xuICAgIHJldHVybiB4IDwgeSA/IC0xIDogMTtcbn07XG5cbnZhciBkZXNjZW5kaW5nQWxsT3RoZXJzID0gZnVuY3Rpb24oeCwgeSkge1xuICAgIHJldHVybiB5IDwgeCA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tcGFyZSA9IChzb3J0VHlwZSA9PT0gMSkgPyBhc2NlbmRpbmcodHlwZU9mRGF0YSkgOiBkZXNjZW5kaW5nKHR5cGVPZkRhdGEpO1xuXG4gICAgICAgIC8vc3RhcnQgdGhlIGFjdHVhbGx5IHNvcnRpbmcuLi4uLlxuICAgICAgICB2YXIgdG1wID0gbmV3IEFycmF5KGluZGV4VmVjdG9yLmxlbmd0aCk7XG5cbiAgICAgICAgLy9sZXRzIGFkZCB0aGUgaW5kZXggZm9yIHN0YWJpbGl0eVxuICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaW5kZXhWZWN0b3IubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHRtcFtpXSA9IFtkYXRhU291cmNlKGkpLCBpXTtcbiAgICAgICAgfVxuXG4gICAgICAgIHRtcC5zb3J0KGNvbXBhcmUpO1xuXG4gICAgICAgIC8vY29weSB0aGUgc29ydGVkIHZhbHVlcyBpbnRvIG91ciBpbmRleCB2ZWN0b3JcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGluZGV4VmVjdG9yLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBpbmRleFZlY3RvcltpXSA9IHRtcFtpXVsxXTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiBzb3J0O1xufSkoKTtcbiJdfQ== diff --git a/examples/v0.2/index.min.js b/examples/v0.2/index.min.js index fb96018c5..36165c5e6 100644 --- a/examples/v0.2/index.min.js +++ b/examples/v0.2/index.min.js @@ -1,9 +1,9 @@ !function t(e,i,n){function o(s,l){if(!i[s]){if(!e[s]){var a="function"==typeof require&&require;if(!l&&a)return a(s,!0);if(r)return r(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=i[s]={exports:{}};e[s][0].call(u.exports,function(t){var i=e[s][1][t];return o(i?i:t)},u,u.exports,t,e,i,n)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s div, div.dragon-list > ul > li, li.dragon-pop { line-height: 46px; }","div.dragon-list > ul { top: 46px; }","div.dragon-list > ul > li:not(:last-child)::before, li.dragon-pop::before {"," content: '\\2b24';"," color: #b6b6b6;"," font-size: 30px;"," margin: 8px 14px 8px 8px; }","li.dragon-pop { opacity:.8; }"]};e.exports=n},{"css-injector":4}],2:[function(t,e,i){e.exports={calendar:{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAc0lEQVR4nIXQwQkCMRSE4U9ZLMCT9Xjaq2AfNhfYU5oQLMAOtoN48EWei5iBIRPe/yYQ3qrhf1lFG7iKcEaJxSfukUvMWgdHavt0uWHtg2QwxXnAnJZ2uOLyVZtybzzhgWNmfoFl0/YB87NbzR1cjP9xeQHSDC6mcL1xFQAAAABJRU5ErkJggg=="},checked:{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAYJJREFUOE+NkstLglEQxf0fahG0iFrUxm2ElFDYLohCqCDaCAkWPaxIRbFFEJEaGEKLDCoMETRFUAMLyaIHBUG6sSKIMtKFqEhLT818ZUgmDhzu3DPn9z0uV1RrmUwmyGQyqNVqfFvViwBxu5RFPZuLSyGMKhz/qlEsRV19K8xm6y+w7bpBPFnAferjj3bdQX6DpHcAUwavAHUN2RGIZxBJZHH2mC/TUeydwwTZvBegLENNgw7sX6Wh1FswNmPEmjPCDyGRRwCtW9E3tMgdAtQw7GZjYcNX+gza2wJ3ZXsSZUuQ0vWCOV8SHfJJ/uluhbHUj1v8PKNMszIoQNRMHCShD6Wh8zyhrbOPwz8w+STKlCCJ7oRNUzQH63kBs5thBghePXxlj2aUoSxDPcuXPNiLAc5EEZ6HIkbmV2DYiXBPHs0o079+K0DTVj/s11mE00A0L+g4VcDp10qKZMAzytBhMaTRaPmYg885DlcSzSij0eoEiIouoUqlqqqaL2rlEok+Ad4vlfzPoVDsAAAAAElFTkSuQmCC"},"down-rectangle":{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAAkAAAAECAYAAABcDxXOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAABpJREFUGFdjgIL/eDAKIKgABggqgAE0BQwMAPTlD/Fpi0JfAAAAAElFTkSuQmCC"},"filter-off":{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAChSURBVChTzZHBCoUgFET9TqEiskgyWoutQvRLRIr+cR7XQAjiJW/1BgZmMUevXsY5xy9OoDEGMcYiUzeB67qibVuwQjVNA6311V+WBeM4vsLDMEApde/1fY9pmtI453neHEKAlBJd1z0fXtc16PbjODK07zvmeUZVVd8nooc75zJIOX3Gm6i0bVsGKf8xKIRIuyJTLgJJ3nvQzsjW2geIsQ/pr9hMVrSncAAAAABJRU5ErkJggg=="},"filter-on":{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAACoSURBVChTY3BqfP2fHAzWmDbj7f8p294RhVOBasEa02e+/e/VBmQQCTxaX/9PnvYGoj5ywpv/Qd2ENft3vv4f1gfVBAP+nW/+h/a+ATtn1q73KHjytvdgg3070DTBgHvL6/8g22fsQGiaDmSHA21xaybgIpDHixa8hWssnA8NDEIApCh3LkIjiD2INYJCL2X6W3B8gdhEaQQBUOCA4gyE8+e9xaKJgQEA/74BNE3cElkAAAAASUVORK5CYII="},unchecked:{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAARBJREFUOE+9krtug1AQRPldSio7FQ1tZImOkoKOBomGT0EURC5ino54yTw90WywQhTkIkVWGoF2zuxdrlD+t0zThKZpT0Vmxb8CQRCg6zr0fb8rer7vfwcPxxdcrx+YpgnzPGNZlh9ibxxHlGUJshLSdV0at9tNpg7DIBrX5+OkPM9BVkKGYSBJEtR1jbZrBdiqbVtUVYU0TUFWQq+nE+I4xvvlImGaW7FHjwxZCVmWhbfzGVmWoSgKWXUr9uiRISshx3FkEldomubXauzRI0NWQp7nyUR+NG/rfr/jUXxnjx5vmKyEbNuWox9Xvid6ZMhK6HA4wnVdhGGIKIp2RY8MWQmx+JuoqvpUZFb8L6UonyYL3uOtrFH+AAAAAElFTkSuQmCC"},"up-down-spin":{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAA4AAAAPCAYAAADUFP50AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAGJJREFUOE+lkwEKACEIBH2Zb/PnHsoGeaVJDUjGOgRRpKpkiIj+y4MME3eDR7kaKOVNsJyMNjIHzGy9YnW6J7qIcrriQimeCqORNABd0fpRTkt8uVUj7EsxC6vs/q3e/Q6iD2bwnByjPXHNAAAAAElFTkSuQmCC"},"up-down":{type:"image/png",data:"iVBORw0KGgoAAAANSUhEUgAAAA4AAAAPCAYAAADUFP50AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC41ZYUyZQAAAGFJREFUOE+lkkEKQCEIRD2ZJ3Ph3iN4WD9GflpYhj0YYowpGgJmbikd3gjMDFokwbuT1iAiurG5nomgqo5QaPo9ERQRI6Jf7sfGjudy2je23+i0Wl2oQ85TOdlfrJQOazF8br+rqTXQKn0AAAAASUVORK5CYII="}}},{}],3:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("./images");n(o).each(function(t,e){var i=new Image;i. src="data:"+t.type+";base64,"+t.data,o[e]=i}),o.checkbox=function(t){return o[t?"checked":"unchecked"]},o.filter=function(t){return o[t?"filter-on":"filter-off"]},e.exports=o},{"./images":2,"object-iterators":21}],4:[function(t,e,i){"use strict";function n(t,e,i){if("string"==typeof i){if(i=document.querySelector(i),!i)throw"Cannot find reference element for CSS injection."}else if(i&&!(i instanceof Element))throw"Given value not a reference element.";var o=i&&i.parentNode||document.head||document.getElementsByTagName("head")[0];if(!e||(e=n.idPrefix+e,!o.querySelector("#"+e))){var r=document.createElement("style");return r.type="text/css",e&&(r.id=e),t instanceof Array&&(t=t.join("\n")),t="\n"+t+"\n",r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t)),void 0===i&&(i=o.firstChild),o.insertBefore(r,i),r}}n.idPrefix="injected-stylesheet-",e.exports=n},{}],5:[function(t,e,i){"use strict";function n(t,e){function i(){e.preInitialize&&e.preInitialize.apply(this,arguments),o.apply(this,arguments),e.postInitialize&&e.postInitialize.apply(this,arguments)}function r(t,i){s[i]=e[t]}switch(arguments.length){case 0:e={};break;case 1:if(e=t,"object"!=typeof e)throw"Single parameter overload must be object.";t=void 0;break;case 2:if("string"!=typeof t||"object"!=typeof e)throw"Two parameter overload must be string, object.";break;default:throw"Too many parameters"}i.extend=n;var s=i.prototype=Object.create(this.prototype);s.constructor=i,t&&n.debug&&(s.$$CLASS_NAME=t);for(var l in e)if(e.hasOwnProperty(l)){var a=e[l];switch(l){case"initializeOwn":break;case"aliases":for(var u in a)a.hasOwnProperty(u)&&r(a[u],u);break;default:"string"==typeof a&&"#"===a[0]?r(a,l.substr(1)):s[l]=a}}return i}function o(){function t(n){var o=Object.getPrototypeOf(n);o.constructor!==Object&&(t(o),o.hasOwnProperty("initialize")&&o.initialize.apply(e,i))}var e=this,i=arguments;t(e)}n.Base=function(){},n.Base.extend=n,e.exports=n},{}],6:[function(t,e,i){"use strict";function n(t){if("object"!=typeof t){var e="Expected `state` parameter to be an object.";throw"string"==typeof t&&(e+=" See `JSON.parse()`."),c.Error(e)}}function o(t){var e=t.target,i=this[e.className]||this[e.parentNode.className];i&&(this.detachChooser&&this.detachChooser(),i.call(this,t),t.stopPropagation()),this.eventHandler&&this.eventHandler(t)}function r(t){if(this instanceof v&&!this.children.length)throw new c.Error("Empty subexpression (no filters).");this.children.forEach(function(e){e instanceof h?e.validate(t):e.children.length&&r.call(e,t)})}function s(t){var e=this,i=t.target.getBoundingClientRect();if(!i.width)return void setTimeout(function(){s.call(e,t)},50);var n=Object.keys(v.prototype.editors),o=this.chooser=document.createElement("select");o.className="filter-tree-chooser",o.size=n.length,n.forEach(function(t){var i=e.editors[t].prototype.name||t;i=i.replace("?","≟"),o.add(new Option(i,t))}),o.onmouseover=function(t){t.target.selected=!0},o.style.left=i.left+19+"px",o.style.top=i.bottom+"px",this.detachChooser=l.bind(this),window.addEventListener("click",this.detachChooser),o.onclick=function(){e.children.push(new e.editors[o.value]({parent:e}))},o.onmouseout=function(){o.selectedIndex=-1},this.el.appendChild(o),this.chooserTarget=t.target,this.chooserTarget.classList.add("as-menu-header")}function l(){var t=this.chooser;t&&(this.el.removeChild(t),this.chooserTarget.classList.remove("as-menu-header"),t.onclick=t.onmouseout=null,window.removeEventListener("click",this.detachChooser),delete this.detachChooser,delete this.chooser)}var a=t("unstrungify"),u=t("./js/css"),c=t("./js/FilterNode"),h=t("./js/FilterLeaf"),d=t("./js/template"),g=t("./js/tree-operators"),f=0,p=/^filter-tree: /,v=c.extend("FilterTree",{preInitialize:function(t){u("filter-tree-base",t&&t.cssStylesheetReferenceElement),t.editors&&(this.editors=t.editors)},destroy:function(){l.call(this)},editors:{Default:h},addEditor:function(t,e){e?this.editors[t]=h.extend(e):delete this.editors[t]},newView:function(){this.el=d("tree",++f),this.el.addEventListener("click",o.bind(this))},getState:a,getJSON:function(){var t=JSON.stringify(this,null,this.JSONspace);return t?t:""},setJSON:function(t){this.setState(JSON.parse(t))},load:function(t){if(t){if(n(t),!(g[t.operator]||void 0===t.operator&&1===t.children.length))throw c.Error("Expected `operator` property to be one of: "+Object.keys(g));if(this.operator=t.operator,!(t.children instanceof Array&&t.children.length))throw c.Error("Expected `children` property to be a non-empty array.");this.children=[];var e=this;t.children.forEach(function(t){var i;if("object"!=typeof t)throw e.Error("Expected child to be an object containing either `children`, `editor`, or neither.");i=t.children?v:e.editors[t.editor||"Default"],e.children.push(new i({state:t,parent:e}))})}else{var i=Object.keys(this.editors),o=1===i.length;this.children=o?[new this.editors[i[0]]({parent:this})]:[],this.operator="op-and"}},render:function(){var t=this.el.querySelector("input[value="+this.operator+"]");if(t.checked=!0,this["filter-tree-op-choice"]({target:t}),!this.children.length&&Object.keys(this.editors).length>1){var e=this.el.querySelector(".filter-tree-add-filter");this["filter-tree-add-filter"]({target:e})}c.prototype.render.call(this)},"filter-tree-op-choice":function(t){var e=t.target;this.operator=e.value;var i=this.el.querySelectorAll("label>input.filter-tree-op-choice[name="+e.name+"]");Array.prototype.slice.call(i).forEach(function(t){t.parentElement.style.textDecoration=t.checked?"none":"line-through"});for(var n in g)this.el.classList.remove(n);this.el.classList.add(this.operator)},"filter-tree-add-filter":function(t){var e=Object.keys(this.editors);1===e.length?this.children.push(new this.editors[e[0]]({parent:this})):s.call(this,t)},"filter-tree-add":function(){this.children.push(new v({parent:this}))},"filter-tree-remove":function(t){var e=t.target,i=e.parentElement,n=this.children,o=e.nextElementSibling;n.forEach(function(t,e){t.el===o&&(delete n[e],i.remove())})},validate:function(t){t=t||{};var e,i=void 0===t.focus||t.focus,n=void 0===t.alert||t.alert,o=t.rethrow===!0;try{r.call(this,i)}catch(s){if(e=s.message,o||!p.test(e))throw s;n&&(e=e.replace(p,""),window.alert(e))}return e},test:function m(t){var e=g[this.operator],i=e.seed,n=!0;return this.children.find(function(o){return o?(n=!1,o instanceof h?i=e.reduce(i,o.test(t)):o.children.length&&(i=e.reduce(i,m.call(o,t))),i===e.abort):!1}),n||(e.negate?!i:i)},toJSON:function C(){var t={operator:this.operator,children:[]};this.children.forEach(function(e){if(e)if(e instanceof h)t.children.push(e);else if(e.children.length){var i=C.call(e);i&&t.children.push(i)}});var e=c.prototype.toJSON.call(this);return Object.keys(e).forEach(function(i){t[i]=e[i]}),t.children.length?t:void 0},getSqlWhereClause:function w(){var t=g[this.operator].SQL,e="";return this.children.forEach(function(i,n){var o=n?" "+t.op+" ":"";i&&(i instanceof h?e+=o+i.getSqlWhereClause():i.children.length&&(e+=o+w.call(i)))}),e||(e="NULL IS NULL"),t.beg+e+t.end}});e.exports=v},{"./js/FilterLeaf":7,"./js/FilterNode":8,"./js/css":9,"./js/template":11,"./js/tree-operators":12,unstrungify:26}],7:[function(t,e,i){"use strict";function n(t,e){var i,o;return o=t.find(function(t){return(t.options||t)instanceof Array?i=n(t.options||t,e):t.name===e}),i||o}function o(t){var e=t.target;if(e.classList.remove("filter-tree-error"),u.setWarningClass(e),!e.multiple&&e.value)for(;(e=e.nextElementSibling)&&(!("name"in e)||""!==e.value.trim()););e&&""===e.value.trim()&&(e.value="",u.clickIn(e)),this.eventHandler&&this.eventHandler(t)}function r(t){setTimeout(function(){t.classList.add("filter-tree-error"),u.clickIn(t)},0)}function s(t){var e,i;switch(t.type){case"checkbox":case"radio":for(t=document.querySelectorAll("input[name='"+t.name+"']:enabled:checked"),e=[],i=0;it?-1:t>e?1:0}var u=t("./FilterNode"),c=t("./template"),h=t("./leaf-operators"),d={to:Number,not:isNaN},g={to:function(t){return new Date(t)},not:isNaN},f=u.extend("FilterLeaf",{name:"column : value",preInitialize:function(){this.onChange=o.bind(this)},operators:h,operatorsOptions:h.options,destroy:function(){if(this.controls)for(var t in this.controls)this.controls[t].removeEventListener("change",this.onChange)},newView:function(){var t=this.parent.nodeFields||this.fields;if(!t)throw u.Error("Terminal node requires a fields list.");var e=this.el=document.createElement("span");e.className="filter-tree-default",this.controls={column:this.makeElement(e,t,"column",!0),operator:this.makeElement(e,this.operatorsOptions,"operator"),value:this.makeElement(e)},e.appendChild(document.createElement("br"))},makeElement:function(t,e,i,n){var o,r,s,a=e?"select":"input";return e&&1===e.length?(r=e[0],o=document.createElement("input"),o.type="hidden",o.value=r.name||r.alias||r,s=document.createElement("span"),s.innerHTML=r.alias||r.name||r,s.appendChild(o),t.appendChild(s)):(o=l(a,e,i,n),"text"===o.type&&this.eventHandler&&this.el.addEventListener("keyup",this.eventHandler),this.el.addEventListener("change",this.onChange),u.setWarningClass(o),t.appendChild(o)),o},load:function(t){if(t){var e,i,n,o,r,s=[];for(var l in t)if("fields"!==l&&"editor"!==l)switch(e=t[l],i=this.controls[l],i.type){case"checkbox":case"radio":for(i=document.querySelectorAll("input[name='"+i.name+"']"),n=0;n=0;break;case"select-multiple":for(i=i.options,n=0,o=!1;n=0,i[n].selected=r;u.setWarningClass(i,o);break;default:i.value=e,u.setWarningClass(i)||i.value===e||s.push({key:l,value:e})}if(s.length){var a=s.length>1,h=c(a?"notes":"note"),d=h.lastElementChild;s.forEach(function(t){var e=a?document.createElement("li"):d;for(t=c("optionMissing",t.key,t.value);t.length;)e.appendChild(t[0]);a&&d.appendChild(e)}),i.parentNode.replaceChild(h,i.parentNode.lastElementChild)}}},converters:{number:d,"int":d,"float":d,date:g},validate:function(t){var e,i,o;for(e in this.controls){var l=this.controls[e],a=s(l).trim();if(""===a)throw t&&r(l),new u.Error("Blank "+e+" control.\nComplete the filter or delete it.");this[e]=a}if(this.op=this.operators[this.operator],this.converter=void 0,this.op.type)this.converter=this.converters[this.op.type];else for(e in this.controls)/^column/.test(e)&&(i=this.parent.nodeFields||this.fields,o=n(i,this[e]),o&&o.type&&(this.converter=this.converters[o.type]))},p:function(t){return t[this.column]},q:function(){return this.value},test:function(t){var e,i,n,o,r;return void 0===(e=this.p(t))||void 0===(i=this.q(t))?!1:!(r=this.converter)||r.not(n=r.to(e))||r.not(o=r.to(i))?this.op.test(e,i):this.op.test(n,o)},toJSON:function(t){var e={};this.editor&&(e.editor=this.editor);for(var i in this.controls)e[i]=this[i];return this.parent.nodeFields||this.fields===this.parent.fields||(e.fields=this.fields),e},getSqlWhereClause:function(){return this.SQL_QUOTED_IDENTIFIER+this.column+this.SQL_QUOTED_IDENTIFIER+" "+("function"==typeof this.op.sql?this.op.sql(this.value):(this.op.sql||this.operator)+h.sq(this.value))}});e.exports=f},{"./FilterNode":8,"./leaf-operators":10,"./template":11}],8:[function(t,e,i){"use strict";function n(t,e,i,n){return e&&e[t]||i&&i[t]||n&&n[t]}var o=t("extend-me"),r=o.Base,s=t("./template");o.debug=!0;var l="OL",a="LI",u=r.extend({initialize:function(t){var e=t&&t.parent,i=t&&(t.state||t.json&&JSON.parse(t.json));this.parent=e,this.nodeFields=n("nodeFields",t,i),this.fields=n("fields",t,i,e),this.editor=n("editor",t,i,e),this.eventHandler=n("eventHandler",t,i,e),this.setState(i)},render:function(){if(this.parent){var t=document.createElement(a);t.appendChild(s("removeButton")),t.appendChild(this.el),this.parent.el.querySelector(l).appendChild(t)}},setState:function(t){var e=this.el;this.newView(),this.load(t),this.render(),e&&!this.parent&&e.parentNode.replaceChild(this.el,e)},toJSON:function(){var t={};if(this.toJsonOptions){var e=this,i=[];this.toJsonOptions.fields&&(i.push("fields"),i.push("nodeFields")),this.toJsonOptions.editor&&i.push("editor"),i.forEach(function(i){(!e.parent||e[i]&&e[i]!==e.parent[i])&&(t[i]=e[i])})}return t},SQL_QUOTED_IDENTIFIER:'"'});u.setWarningClass=function(t,e){return arguments.length<2&&(e=t.value),t.classList[e?"remove":"add"]("filter-tree-warning"),e},u.Error=function(t){return new Error("filter-tree: "+t)},u.clickIn=function(t){t&&("SELECT"===t.tagName?setTimeout(function(){t.dispatchEvent(new MouseEvent("mousedown"))},0):t.focus())},e.exports=u},{"./template":11,"extend-me":5}],9:[function(t,e,i){"use strict";var n,o=t("css-injector");n=".filter-tree{font-family:sans-serif;font-size:10pt;line-height:1.5em}.filter-tree label{font-weight:400}.filter-tree input[type=checkbox],.filter-tree input[type=radio]{left:3px;margin-right:3px}.filter-tree ol{margin-top:0}.filter-tree-add,.filter-tree-add-filter,.filter-tree-remove{cursor:pointer}.filter-tree-add,.filter-tree-add-filter{font-style:italic;color:#444;font-size:90%}.filter-tree-add-filter{margin:3px 0 3px 3em;width:120px;display:inline-block}.filter-tree-add-filter:hover,.filter-tree-add:hover{text-decoration:underline}.filter-tree-add-filter.as-menu-header,.filter-tree-add.as-menu-header{background-color:#fff;font-weight:700;font-style:normal}.filter-tree-add-filter.as-menu-header:hover{text-decoration:inherit}.filter-tree-add-filter>div,.filter-tree-add>div,.filter-tree-remove{display:inline-block;width:15px;height:15px;border-radius:8px;background-color:#8c8;font-size:11.5px;font-weight:700;color:#fff;text-align:center;line-height:normal;font-style:normal;font-family:sans-serif;text-shadow:0 0 1.5px grey;margin-right:4px}.filter-tree-add-filter>div:before,.filter-tree-add>div:before{content:'\\ff0b'}.filter-tree-remove{background-color:#e88;border:0}.filter-tree-remove:before{content:'\\2212'}.filter-tree li::after{font-size:70%;font-style:italic;font-weight:700;color:#080}.filter-tree>ol>li:last-child::after{display:none}.op-or>ol>li::after{margin-left:2.5em;content:'— OR —'}.op-and>ol>li::after{margin-left:2.5em;content:'— AND —'}.op-nor>ol>li::after{margin-left:2.5em;content:'— NOR —'}.filter-tree-default>:enabled{margin:0 .4em;background-color:#ddd;border:0}.filter-tree-default>input[type=text]{width:8em;padding:0 5px}.filter-tree-default>select{border:0}.filter-tree-default>.filter-tree-warning{background-color:#ffc}.filter-tree-default>.filter-tree-error{background-color:#Fcc}.filter-tree .footnotes{font-size:6pt;margin:2px 0 0;line-height:normal;white-space:normal;color:#999}.filter-tree .footnotes>ol{margin:0;padding-left:2em}.filter-tree .footnotes>ol>li{margin:2px 0}.filter-tree .footnotes .field-name,.filter-tree .footnotes .field-value{font-weight:700;color:#777}.filter-tree .footnotes .field-value:after,.filter-tree .footnotes .field-value:before{content:'\"'}.filter-tree .footnotes .field-value{font-family:monospace}.filter-tree-chooser{position:absolute;font-size:9pt;outline:0;box-shadow:5px 5px 10px grey}",e.exports=o.bind(this,n)},{"css-injector":4}],10:[function(t,e,i){"use strict";function n(t,e){return e.trim().replace(/\s*,\s*/g,",").split(",").indexOf(t.toString())}function o(t,e){return t.toString().toLowerCase().indexOf(e.toString().toLowerCase())}function r(t,e){return t.toString().toLowerCase().substr(0,e)}function s(t,e){return t.toString().toLowerCase().substr(-e,e)}function l(t,e,i,n){var o=n.replace(/([\[_%\]])/g,"[$1]");return i+h(t+o+e)}function a(t){return"IN ('"+c(t).replace(/\s*,\s*/g,"', '")+"')"}function u(t){return"NOT "+a(t)}function c(t){return t.replace(/'/g,"''")}function h(t){return" '"+c(t)+"'"}var d,g,f,p,v,m=t("regexp-like"),C="LIKE ",w="NOT "+C,y="%",b={"<":{test:function(t,e){return e>t}},"≤":{test:function(t,e){return e>=t},sql:"<="},"=":{test:function(t,e){return t===e}},"≥":{test:function(t,e){return t>=e},sql:">="},">":{test:function(t,e){return t>e}},"≠":{test:function(t,e){return t!==e},sql:"<>"},LIKE:{test:function(t,e){return m.cached(e,!0).test(t)},type:"string"},"NOT LIKE":{test:function(t,e){return!m.cached(e,!0).test(t)},type:"string"},IN:{test:function(t,e){return n(t,e)>=0},sql:a,type:"string"},"NOT IN":{test:function(t,e){return n(t,e)<0},sql:u,type:"string"},CONTAINS:{test:function(t,e){return o(t,e)>=0},sql:l.bind(this,y,y,C),type:"string"},"NOT CONTAINS":{test:function(t,e){return o(t,e)<0},sql:l.bind(this,y,y,w),type:"string"},BEGINS:{test:function(t,e){return e=e.toString().toLowerCase(),r(t,e.length)===e},sql:l.bind(this,"",y,C),type:"string"},"NOT BEGINS":{test:function(t,e){return e=e.toString().toLowerCase(),r(t,e.length)!==e},sql:l.bind(this,"",y,w),type:"string"},ENDS:{test:function(t,e){return e=e.toString().toLowerCase(),s(t,e.length)===e},sql:l.bind(this,y,"",C),type:"string"},"NOT ENDS":{test:function(t,e){return e=e.toString().toLowerCase(),s(t,e.length)!==e},sql:l.bind(this,y,"",w),type:"string"}};d=["="],d.label="Equality",g=["<","≤","≠","≥",">"],g.label="Inquality",f=["IN","NOT IN"],f.label="Set scan",p=["CONTAINS","NOT CONTAINS","BEGINS","NOT BEGINS","ENDS","NOT ENDS"],p.label="String scan",v={options:["LIKE","NOT LIKE"],label:"Pattern matching"},b.options=[d,g,f,p,v],b.sq=h,e.exports=b},{"regexp-like":23}],11:[function(t,e,i){"use strict";function n(t){var e,i=document.createElement("div"),n=r[t].toString().match(s)[1],a=[n].concat(Array.prototype.slice.call(arguments,1)),u={};for(l.lastIndex=0;e=l.exec(n);)u[e[1]]=!0;return e=Object.keys(u),e.length&&(e.forEach(function(t){i.textContent=a[t],a[t]=i.innerHTML}),a[0]=n.replace(l,"{$1}")),i.innerHTML=o.apply(this,a),1===i.children.length&&1===i.childNodes.length?i.firstChild:i.childNodes}var o=t("templex"),r={tree:function(){},removeButton:function(){},note:function(){},notes:function(){},optionMissing:function(){}},s=/\/\*\s*([^]+?)\s+\*\//,l=/\{(\d+)\:encode\}/g;e.exports=n},{templex:25}],12:[function(t,e,i){"use strict";function n(t,e){return t&&e}function o(t,e){return t||e}var r={"op-and":{reduce:n,seed:!0,abort:!1,negate:!1,SQL:{op:"AND",beg:"(",end:")"}},"op-or":{reduce:o,seed:!1,abort:!0,negate:!1,SQL:{op:"OR",beg:"(",end:")"}},"op-nor":{reduce:o,seed:!1,abort:!0,negate:!0,SQL:{op:"OR",beg:"NOT (",end:")"}}};e.exports=r},{}],13:[function(t,e,i){"use strict";function n(t){var e=this._bound={};for(s in u)e[s]=u[s].bind(this);var i=document.createElement("div");i.classList.add("thumb"),i.onclick=e.shortStop,i.onmouseover=e.onmouseover,this.thumb=i;var o=document.createElement("div");o.classList.add("finbar-vertical"),o.appendChild(i),this.paging&&(o.onclick=e.onclick),this.bar=o,t=t||{},this.orientation="vertical",this._min=this._index=0,this._max=100;for(var s in t)if(t.hasOwnProperty(s)){var c=t[s];switch(s){case"index":this._index=c;break;case"range":r(c),this._min=c.min,this._max=c.max,this.contentSize=c.max-c.min+1;break;default:"_"!==s.charAt(0)&&"function"!=typeof n.prototype[s]&&(this[s]=c)}}l(a,"finbar-base",t.cssStylesheetReferenceElement)}function o(t){for(var e=1;e'+t.replace("mouse","")+""}),e.appendChild(n),t={},i.forEach(function(e){t[e]=n.getElementsByClassName(e)[0]})}return t},_addEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.add("listening"),window.addEventListener(t,this._bound["on"+t])},_removeEvt:function(t){var e=this.testPanelItem&&this.testPanelItem[t];e&&e.classList.remove("listening"),window.removeEventListener(t,this._bound["on"+t])}};var a,u={shortStop:function(t){t.stopPropagation()},onwheel:function(t){this.index+=t[this.deltaProp],t.stopPropagation(),t.preventDefault()},onclick:function(t){var e=this.thumb.getBoundingClientRect(),i=t[this.oh.coordinate].thumb,div.finbar-vertical>.thumb{position:absolute;background-color:#d3d3d3;-webkit-box-shadow:0 0 1px #000;-moz-box-shadow:0 0 1px #000;box-shadow:0 0 1px #000;border-radius:4px;margin:2px;opacity:.4;transition:opacity .5s}div.finbar-horizontal>.thumb.hover,div.finbar-vertical>.thumb.hover{opacity:1;transition:opacity .5s}div.finbar-vertical{top:0;bottom:0;right:0;width:11px}div.finbar-vertical>.thumb{top:0;right:0;width:7px}div.finbar-horizontal{left:0;right:0;bottom:0;height:11px}div.finbar-horizontal>.thumb{left:0;bottom:0;height:7px}",e.exports=n},{"css-injector":4}],14:[function(t,e,i){"use strict";function n(t,e,i){var n=this;this.div=t,this.component=e,i=i||{},this.doubleClickDelay=i.doubleClickDelay||325,this.dragEndtime=Date.now(),this.canvas=document.createElement("canvas"),this.div.appendChild(this.canvas),this.canvas.style.outline="none",this.canvasCTX=this.canvas.getContext("2d"),this.gc=new u(this.canvasCTX),this.buffer=document.createElement("canvas"),this.bufferCTX=this.buffer.getContext("2d"),this.bufferGC=new u(this.bufferCTX),this.mouseLocation=new l.Point(-1,-1),this.dragstart=new l.Point(-1,-1),this.bounds=new l.Rectangle(0,0,0,0),this.hasMouse=!1,document.addEventListener("mousemove",function(t){(n.hasMouse||n.isDragging())&&n.finmousemove(t)}),document.addEventListener("mouseup",function(t){n.finmouseup(t)}),document.addEventListener("wheel",function(t){n.finwheelmoved(t)}),document.addEventListener("keydown",function(t){n.finkeydown(t)}),document.addEventListener("keyup",function(t){n.finkeyup(t)}),this.canvas.onmouseover=function(){n.hasMouse=!0},this.canvas.addEventListener("focus",function(t){n.finfocusgained(t)}),this.canvas.addEventListener("blur",function(t){n.finfocuslost(t)}),this.canvas.addEventListener("mousedown",function(t){n.finmousedown(t)}),this.canvas.addEventListener("mouseout",function(t){n.hasMouse=!1,n.finmouseout(t)}),this.canvas.addEventListener("click",function(t){n.finclick(t)}),this.canvas.addEventListener("contextmenu",function(t){return n.fincontextmenu(t),t.preventDefault(),!1}),a.addEventListener(this.canvas,"tap",function(t){n.fintap(t)}),a.addEventListener(this.canvas,"holdpulse",function(t){n.finholdpulse(t)}),a.addEventListener(this.canvas,"flick",function(t){n.finflick(t)}),a.addEventListener(this.canvas,"release",function(t){n.finrelease(t)}),a.addEventListener(this.canvas,"trackstart",function(t){n.fintrackstart(t)}),a.addEventListener(this.canvas,"track",function(t){n.fintrack(t)}),a.addEventListener(this.canvas,"trackend",function(t){n.fintrackend(t)}),this.canvas.setAttribute("tabindex",0),this.canvas.contentEditable=!0,this.resize(),this.beginResizing(),this.beginPainting()}function o(t){if(g){for(var e=0;ei;i++)t[i]=e;return t[27]=["ESC","ESCSHIFT"],t[192]=["`","~"],t[49]=["1","!"],t[50]=["2","@"],t[51]=["3","#"],t[52]=["4","$"],t[53]=["5","%"],t[54]=["6","^"],t[55]=["7","&"],t[56]=["8","*"],t[57]=["9","("],t[48]=["0",")"],t[189]=["-","_"],t[187]=["=","+"],t[8]=["BACKSPACE","BACKSPACESHIFT"],t[46]=["DELETE","DELETESHIFT"],t[9]=["TAB","TABSHIFT"],t[81]=["q","Q"],t[87]=["w","W"],t[69]=["e","E"],t[82]=["r","R"],t[84]=["t","T"],t[89]=["y","Y"],t[85]=["u","U"],t[73]=["i","I"],t[79]=["o","O"],t[80]=["p","P"],t[219]=["[","{"],t[221]=["]","}"],t[220]=["\\","|"],t[220]=["CAPSLOCK","CAPSLOCKSHIFT"],t[65]=["a","A"],t[83]=["s","S"],t[68]=["d","D"],t[70]=["f","F"],t[71]=["g","G"],t[72]=["h","H"],t[74]=["j","J"],t[75]=["k","K"],t[76]=["l","L"],t[186]=[";",":"],t[222]=["'","|"],t[13]=["RETURN","RETURNSHIFT"],t[16]=["SHIFT","SHIFT"],t[90]=["z","Z"],t[88]=["x","X"],t[67]=["c","C"],t[86]=["v","V"],t[66]=["b","B"],t[78]=["n","N"],t[77]=["m","M"],t[188]=[",","<"],t[190]=[".",">"],t[191]=["/","?"],t[16]=["SHIFT","SHIFT"],t[17]=["CTRL","CTRLSHIFT"],t[18]=["ALT","ALTSHIFT"],t[91]=["COMMANDLEFT","COMMANDLEFTSHIFT"],t[32]=["SPACE","SPACESHIFT"],t[93]=["COMMANDRIGHT","COMMANDRIGHTSHIFT"],t[18]=["ALT","ALTSHIFT"],t[38]=["UP","UPSHIFT"],t[37]=["LEFT","LEFTSHIFT"],t[40]=["DOWN","DOWNSHIFT"],t[39]=["RIGHT","RIGHTSHIFT"],t[33]=["PAGEUP","PAGEUPSHIFT"],t[34]=["PAGEDOWN","PAGEDOWNSHIFT"],t[35]=["PAGERIGHT","PAGERIGHTSHIFT"],t[36]=["PAGELEFT","PAGELEFTSHIFT"],t[112]=["F1","F1SHIFT"],t[113]=["F2","F2SHIFT"],t[114]=["F3","F3SHIFT"],t[115]=["F4","F4SHIFT"],t[116]=["F5","F5SHIFT"],t[117]=["F6","F6SHIFT"],t[118]=["F7","F7SHIFT"],t[119]=["F8","F8SHIFT"],t[120]=["F9","F9SHIFT"],t[121]=["F10","F10SHIFT"],t[122]=["F11","F1S1HIFT"],t[123]=["F12","F121HIFT"],t}var l=t("rectangular"),a=t("./js/polymergestures.dev.js"),u=t("./js/GraphicsContext.js"),c=200,h=[],d=[],g=!0,f=!0,p=s();n.prototype={constructor:n.prototype.constructor,div:null,component:null,gestures:a,canvas:null,canvasCTX:null,focuser:null,buffer:null,ctx:null,mouseLocation:null,holdPulseCount:-1,dragstart:null,origin:null,bounds:null,dirty:!1,size:null,mousedown:!1,dragging:!1,repeatKeyCount:0,repeatKey:null,repeatKeyStartTime:0,currentKeys:[],hasMouse:!1,lastDoubleClickTime:0,dragEndTime:0,lastRepaintTime:0,addEventListener:function(t,e){this.canvas.addEventListener(t,e)},stopPaintLoop:function(){g=!1},restartPaintLoop:function(){g||(g=!0,requestAnimationFrame(o))},stopResizeLoop:function(){f=!1},restartResizeLoop:function(){f||(f=!0,setInterval(r,200))},detached:function(){this.stopPainting(),this.stopResizing()},useHiDPI:function(){return this.component.resolveProperty("useHiDPI")},useBitBlit:function(){return this.component.resolveProperty("useBitBlit")},getFPS:function(){var t=this.component.resolveProperty("repaintIntervalRate");return t?parseInt(t):0},tickPaint:function(t){var e=this.getFPS();if(0!==e){var i=1e3/e,n=t-this.lastRepaintTime;n>i&&this.dirty&&(this.lastRepaintTime=t-n%i,this.paintNow())}},beginPainting:function(){var t=this;this.dirty=!0,this.tickPainter=function(e){t.tickPaint(e)},h.push(this)},stopPainting:function(){h.splice(h.indexOf(this),1)},beginResizing:function(){var t=this;this.tickResizer=function(){t.checksize()},d.push(this)},stopResizing:function(){d.splice(d.indexOf(this),1)},start:function(){this.beginPainting(),this.beginResizing()},stop:function(){this.stopPainting(),this.stopResizing()},checksize:function(){var t=this.div.getBoundingClientRect();(t.width!==this.size.width||t.height!==this.size.height)&&this.sizeChangedNotification()},sizeChangedNotification:function(){this.resize()},resize:function(){var t=this.size=this.div.getBoundingClientRect();this.canvas.width=this.buffer.width=t.width,this.canvas.height=this.buffer.height=t.height;var e=1,i=this.useBitBlit(),n=window.devicePixelRatio&&this.useHiDPI();if(n){var o=window.devicePixelRatio||1,r=this.canvasCTX.webkitBackingStorePixelRatio||this.canvasCTX.mozBackingStorePixelRatio||this.canvasCTX.msBackingStorePixelRatio||this.canvasCTX.oBackingStorePixelRatio||this.canvasCTX.backingStorePixelRatio||1;e=o/r}var s=this.canvas.getAttribute("width"),a=this.canvas.getAttribute("height");this.canvas.width=s*e,this.canvas.height=a*e,this.buffer.width=s*e,this.buffer.height=a*e,this.canvas.style.width=s+"px",this.canvas.style.height=a+"px",this.buffer.style.width=s+"px",this.buffer.style.height=a+"px",this.bufferCTX.scale(e,e),n&&!i&&this.canvasCTX.scale(e,e),this.bounds=new l.Rectangle(0,0,t.width,t.height);var u=this.component;u&&u.setBounds(this.bounds),this.resizeNotification(),this.paintNow()},resizeNotification:function(){},getBounds:function(){return this.bounds},paintNow:function(){var t=this;this.safePaintImmediately(function(e){e.clearRect(0,0,t.canvas.width,t.canvas.height);var i=t.component;i&&i._paint(e),t.dirty=!1})},safePaintImmediately:function(t){var e=this.useBitBlit(),i=e?this.bufferGC:this.gc;try{i.save(),t(i)}catch(n){console.error(n)}finally{i.restore()}e&&this.flushBuffer()},flushBuffer:function(){this.buffer.width>0&&this.buffer.height>0&&this.canvasCTX.drawImage(this.buffer,0,0)},dispatchNewEvent:function(t,e,i){return i={detail:i||{}},i.detail.primitiveEvent=t,this.canvas.dispatchEvent(new CustomEvent(e,i))},dispatchNewMouseKeysEvent:function(t,e,i){return i=i||{},i.mouse=this.mouseLocation,i.keys=this.currentKeys,this.dispatchNewEvent(t,e,i)},finmousemove:function(t){!this.isDragging()&&this.mousedown&&(this.beDragging(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragstart",{isRightClick:this.isRightClick(t)}),this.dragstart=new l.Point(this.mouseLocation.x,this.mouseLocation.y)),this.mouseLocation=this.getLocal(t),this.isDragging()&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-drag",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.bounds.contains(this.mouseLocation)&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousemove")},finmousedown:function(t){this.mouseLocation=this.mouseDownLocation=this.getLocal(t),this.mousedown=!0,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousedown",{isRightClick:this.isRightClick(t)}),this.takeFocus()},finmouseup:function(t){this.isDragging()&&(this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragend",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.beNotDragging(),this.dragEndtime=Date.now()),this.mousedown=!1,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseup",{isRightClick:this.isRightClick(t)})},finmouseout:function(t){this.mousedown||(this.mouseLocation=new l.Point(-1,-1)),this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseout")},finwheelmoved:function(t){!this.isDragging()&&this.hasFocus()&&(t.preventDefault(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-wheelmoved",{isRightClick:this.isRightClick(t)}))},finclick:function(t){this.doubleClickTimer&&Date.now()-this.lastClickTimen||i-this.dragEndtime<100||setTimeout(function(){e._fintap(t)},180)},_fintap:function(t){var e=Date.now(),i=e-this.lastDoubleClickTime;300>i||(this.mouseDownLocation&&(this.mouseLocation=this.mouseDownLocation,this.mouseDownLocation=void 0),this.dispatchNewMouseKeysEvent(t,"fin-canvas-tap",{isRightClick:this.isRightClick(t)}))},findblclick:function(t){this.mouseLocation=this.getLocal(t),this.lastDoubleClickTime=Date.now(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dblclick",{isRightClick:this.isRightClick(t)})},getCharMap:function(){return p},finkeydown:function(t){if(this.hasFocus()){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];t.repeat?this.repeatKey===e?this.repeatKeyCount++:(this.repeatKey=e,this.repeatKeyStartTime=Date.now()):(this.repeatKey=null,this.repeatKeyCount=0,this.repeatKeyStartTime=0),-1===this.currentKeys.indexOf(e)&&this.currentKeys.push(e),this.dispatchNewEvent(t,"fin-canvas-keydown",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeatCount:this.repeatKeyCount,repeatStartTime:this.repeatKeyStartTime,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)})}},finkeyup:function(t){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];this.currentKeys.splice(this.currentKeys.indexOf(e),1),this.hasFocus()&&(this.repeatKeyCount=0,this.repeatKey=null,this.repeatKeyStartTime=0,this.dispatchNewEvent(t,"fin-canvas-keyup",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeat:t.repeat,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)}))},finfocusgained:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-gained")},finfocuslost:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-lost")},fincontextmenu:function(t){t.ctrlKey&&-1===this.currentKeys.indexOf("CTRL")&&this.currentKeys.push("CTRL"),this.doubleRightClickTimer&&Date.now()-this.lastClickTime=0?t=this.walk(t,o):e=this.walk(e,-o);t&&e&&t!==e;)t=t.parentNode||t.host,e=e.parentNode||e.host;return t},walk:function(t,e){for(var i=0;t&&e>i;i++)t=t.parentNode||t.host;return t},depth:function(t){for(var e=0;t;)e++,t=t.parentNode||t.host;return e},deepContains:function(t,e){var i=this.LCA(t,e);return i===t},insideNode:function(t,e,i){var n=t.getBoundingClientRect();return n.left<=e&&e<=n.right&&n.top<=i&&i<=n.bottom},path:function(t){var i;if(e&&t.path&&t.path.length)i=t.path;else{i=[];for(var n=this.findTarget(t);n;)i.push(n),n=n.parentNode||n.host}return i}};t.targetFinding=s,t.findTarget=s.findTarget.bind(s),t.deepContains=s.deepContains.bind(s),t.insideNode=s.insideNode}(i),function(){function t(t){return"html /deep/ "+e(t)}function e(t){return'[touch-action="'+t+'"]'}function i(t){return"{ -ms-touch-action: "+t+"; touch-action: "+t+";}"}var n=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"],o="",r="string"==typeof document.head.style.touchAction,s=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(r){n.forEach(function(n){String(n)===n?(o+=e(n)+i(n)+"\n",s&&(o+=t(n)+i(n)+"\n")):(o+=n.selectors.map(e)+i(n.rule)+"\n",s&&(o+=n.selectors.map(t)+i(n.rule)+"\n"))});var l=document.createElement("style");l.textContent=o,document.head.appendChild(l)}}(),function(t){var e=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],i=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0],n=function(){return function(){}},o={preventTap:n,makeBaseEvent:function(t,e){var i=document.createEvent("Event");return i.initEvent(t,e.bubbles||!1,e.cancelable||!1),i.preventTap=o.preventTap(i),i},makeGestureEvent:function(t,e){e=e||Object.create(null);for(var i,n=this.makeBaseEvent(t,e),o=0,r=Object.keys(e);o-1?this.values[i]=e:(this.keys.push(t),this.values.push(e))},has:function(t){return this.keys.indexOf(t)>-1},"delete":function(t){var e=this.keys.indexOf(t);e>-1&&(this.keys.splice(e,1),this.values.splice(e,1))},get:function(t){var e=this.keys.indexOf(t);return this.values[e]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(t,e){this.values.forEach(function(i,n){t.call(e,i,this.keys[n],this)},this)},pointers:function(){return this.keys.length}},t.PointerMap=e}(i),function(t){var e,i=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"],n=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0,function(){},!1],o="undefined"!=typeof SVGElementInstance,r=t.eventFactory,s={IS_IOS:!1,pointermap:new t.PointerMap,requiredGestures:new t.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(t,e){var i=e,n=i.events;n&&(n.forEach(function(t){i[t]&&(this.eventMap[t]=i[t].bind(i))},this),this.eventSources[t]=i,this.eventSourceList.push(i))},registerGesture:function(t,e){var i=Object.create(null);i.listeners=0,i.index=this.gestures.length;for(var n,o=0;oo&&(i=this.eventSourceList[o]);o++)i.register.call(i,t,e)},unregister:function(t){for(var e,i=this.eventSourceList.length,n=0;i>n&&(e=this.eventSourceList[n]);n++)e.unregister.call(e,t)},down:function(t){this.requiredGestures.set(t.pointerId,e),this.fireEvent("down",t)},move:function(t){t.type="move",this.fillGestureQueue(t)},up:function(t){this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},cancel:function(t){t.tapPrevented=!0,this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},addGestureDependency:function(t,e){var i=t._pgEvents;if(i&&e)for(var n,o,r,s=Object.keys(i),l=0;l0&&(n=this.dependencyMap[r],o=n?n.index:-1,e[o]=!0)},eventHandler:function(i){var n=i.type;if("touchstart"===n||"mousedown"===n||"pointerdown"===n||"MSPointerDown"===n)if(i._handledByPG||(e={}),this.IS_IOS){var o=i;if("touchstart"===n){var r=i.changedTouches[0];o={target:i.target,clientX:r.clientX,clientY:r.clientY,path:i.path}}for(var s,l=i.path||t.targetFinding.path(o),a=0;an&&(i=e[n]);n++)this.addEvent(t,i)},unlisten:function(t,e){for(var i,n=0,o=e.length;o>n&&(i=e[n]);n++)this.removeEvent(t,i)},addEvent:function(t,e){t.addEventListener(e,this.boundHandler)},removeEvent:function(t,e){t.removeEventListener(e,this.boundHandler)},makeEvent:function(t,e){var i=r.makePointerEvent(t,e);return i.preventDefault=e.preventDefault,i.tapPrevented=e.tapPrevented,i._target=i._target||e.target,i},fireEvent:function(t,e){var i=this.makeEvent(t,e);return this.dispatchEvent(i)},cloneEvent:function(t){for(var e,r=Object.create(null),s=0;s0&&t._pgListeners--,0===t._pgListeners&&s.unregister(t),t._pgEvents&&(t._pgEvents[i]>0?t._pgEvents[i]--:t._pgEvents[i]=0)),Boolean(n)},t.removeEventListener=function(e,i,n,o){n&&(t.deactivateGesture(e,i),e.removeEventListener(i,n,o))}}(i),function(t){var e=t.dispatcher,i=e.pointermap,n=25,o=[0,1,4,2],r=0,s=/Linux.*Firefox\//i,l=function(){if(s.test(navigator.userAgent))return!1;try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}(),a={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(t){for(var e,i=this.lastTouches,o=t.clientX,r=t.clientY,s=0,l=i.length;l>s&&(e=i[s]);s++){var a=Math.abs(o-e.x),u=Math.abs(r-e.y);if(n>=a&&n>=u)return!0}},prepareEvent:function(t){var i=e.cloneEvent(t);if(i.pointerId=this.POINTER_ID,i.isPrimary=!0,i.pointerType=this.POINTER_TYPE,i._source="mouse",!l){var n=t.type,s=o[t.which]||0;"mousedown"===n?r|=s:"mouseup"===n&&(r&=~s),i.buttons=r}return i},mousedown:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=(i.has(this.POINTER_ID),this.prepareEvent(n));o.target=t.findTarget(n),i.set(this.POINTER_ID,o.target),e.down(o)}},mousemove:function(t){if(!this.isEventSimulatedFromTouch(t)){var n=i.get(this.POINTER_ID);if(n){var o=this.prepareEvent(t);o.target=n,0===(l?o.buttons:o.which)?(l||(r=o.buttons=0),e.cancel(o),this.cleanupMouse(o.buttons)):e.move(o)}}},mouseup:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(this.POINTER_ID),e.up(o),this.cleanupMouse(o.buttons)}},cleanupMouse:function(t){0===t&&i["delete"](this.POINTER_ID)}};t.mouseEvents=a}(i),function(t){var e=t.dispatcher,i=(t.targetFinding.allShadows.bind(t.targetFinding),e.pointermap),n=(Array.prototype.map.call.bind(Array.prototype.map),2500),o=25,r=200,s=20,l=!1,a={IS_IOS:!1,events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(t,i){(this.IS_IOS?i:!i)&&e.listen(t,this.events)},unregister:function(t){this.IS_IOS||e.unlisten(t,this.events)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(t){var e=t,i=this.scrollTypes;return e===i.EMITTER?"none":e===i.XSCROLLER?"X":e===i.YSCROLLER?"Y":"XY"},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(t){return this.firstTouch===t.identifier},setPrimaryTouch:function(t){(0===i.pointers()||1===i.pointers()&&i.has(1))&&(this.firstTouch=t.identifier,this.firstXY={X:t.clientX,Y:t.clientY},this.firstTarget=t.target,this.scrolling=null,this.cancelResetClickCount())},removePrimaryPointer:function(t){t.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var t=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(t,r)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(t){var e=0;return("touchstart"===t||"touchmove"===t)&&(e=1),e},findTarget:function(e,n){if("touchstart"===this.currentTouchEvent.type){if(this.isPrimaryTouch(e)){var o={clientX:e.clientX,clientY:e.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return t.findTarget(o)}return t.findTarget(e)}return i.get(n)},touchToPointer:function(t){var i=this.currentTouchEvent,n=e.cloneEvent(t),o=n.pointerId=t.identifier+2;n.target=this.findTarget(t,o),n.bubbles=!0,n.cancelable=!0,n.detail=this.clickCount,n.buttons=this.typeToButtons(i.type),n.width=t.webkitRadiusX||t.radiusX||0,n.height=t.webkitRadiusY||t.radiusY||0,n.pressure=t.webkitForce||t.force||.5,n.isPrimary=this.isPrimaryTouch(t),n.pointerType=this.POINTER_TYPE,n._source="touch";var r=this;return n.preventDefault=function(){r.scrolling=!1,r.firstXY=null,i.preventDefault()},n},processTouches:function(t,e){var n=t.changedTouches;this.currentTouchEvent=t;for(var o,r,s=0;s=u}return i}},findTouch:function(t,e){for(var i,n=0,o=t.length;o>n&&(i=t[n]);n++)if(i.identifier===e)return!0},vacuumTouches:function(t){var e=t.touches;if(i.pointers()>=e.length){var n=[];i.forEach(function(t,i){if(1!==i&&!this.findTouch(e,i-2)){var o=t;n.push(o)}},this),n.forEach(function(t){this.cancel(t),i["delete"](t.pointerId)},this)}},touchstart:function(t){this.vacuumTouches(t),this.setPrimaryTouch(t.changedTouches[0]),this.dedupSynthMouse(t),this.scrolling||(this.clickCount++,this.processTouches(t,this.down))},down:function(t){e.down(t)},touchmove:function(t){if(l)t.cancelable&&this.processTouches(t,this.move);else if(this.scrolling){if(this.firstXY){var e=t.changedTouches[0],i=e.clientX-this.firstXY.X,n=e.clientY-this.firstXY.Y,o=Math.sqrt(i*i+n*n);o>=s&&(this.touchcancel(t),this.scrolling=!0,this.firstXY=null)}}else null===this.scrolling&&this.shouldScroll(t)?this.scrolling=!0:(this.scrolling=!1,t.preventDefault(),this.processTouches(t,this.move))},move:function(t){e.move(t)},touchend:function(t){this.dedupSynthMouse(t),this.processTouches(t,this.up)},up:function(i){i.relatedTarget=t.findTarget(i),e.up(i)},cancel:function(t){e.cancel(t)},touchcancel:function(t){t._cancel=!0,this.processTouches(t,this.cancel)},cleanUpPointer:function(t){i["delete"](t.pointerId),this.removePrimaryPointer(t)},dedupSynthMouse:function(e){var i=t.mouseEvents.lastTouches,o=e.changedTouches[0];if(this.isPrimaryTouch(o)){var r={x:o.clientX,y:o.clientY};i.push(r);var s=function(t,e){var i=t.indexOf(e); -i>-1&&t.splice(i,1)}.bind(null,i,r);setTimeout(s,n)}}},u=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(e){var i=e.clientX,n=e.clientY,r=function(t){var e=Math.abs(i-t.x),r=Math.abs(n-t.y);return o>=e&&o>=r},s=t.mouseEvents.lastTouches.some(r),l=t.targetFinding.path(e);if(s){for(var c=0;c0?1:-1},calcPositionDelta:function(t,e){var i=0,n=0;return t&&e&&(i=e.pageX-t.pageX,n=e.pageY-t.pageY),{x:i,y:n}},fireTrack:function(t,e,n){var o=n,r=this.calcPositionDelta(o.downEvent,e),s=this.calcPositionDelta(o.lastMoveEvent,e);if(s.x)o.xDirection=this.clampDir(s.x);else if("trackx"===t)return;if(s.y)o.yDirection=this.clampDir(s.y);else if("tracky"===t)return;var l={bubbles:!0,cancelable:!0,trackInfo:o.trackInfo,relatedTarget:e.relatedTarget,pointerType:e.pointerType,pointerId:e.pointerId,_source:"track"};"tracky"!==t&&(l.x=e.x,l.dx=r.x,l.ddx=s.x,l.clientX=e.clientX,l.pageX=e.pageX,l.screenX=e.screenX,l.xDirection=o.xDirection),"trackx"!==t&&(l.dy=r.y,l.ddy=s.y,l.y=e.y,l.clientY=e.clientY,l.pageY=e.pageY,l.screenY=e.screenY,l.yDirection=o.yDirection);var a=i.makeGestureEvent(t,l);o.downTarget.dispatchEvent(a)},down:function(t){if(t.isPrimary&&("mouse"===t.pointerType?1===t.buttons:!0)){var e={downEvent:t,downTarget:t.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};n.set(t.pointerId,e)}},move:function(t){var e=n.get(t.pointerId);if(e){if(!e.tracking){var i=this.calcPositionDelta(e.downEvent,t),o=i.x*i.x+i.y*i.y;o>this.WIGGLE_THRESHOLD&&(e.tracking=!0,e.lastMoveEvent=e.downEvent,this.fireTrack("trackstart",t,e))}e.tracking&&(this.fireTrack("track",t,e),this.fireTrack("trackx",t,e),this.fireTrack("tracky",t,e)),e.lastMoveEvent=t}},up:function(t){var e=n.get(t.pointerId);e&&(e.tracking&&this.fireTrack("trackend",t,e),n["delete"](t.pointerId))}};e.registerGesture("track",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var t=Date.now()-this.heldPointer.timeStamp,e=this.held?"holdpulse":"hold";this.fireHold(e,t),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(t){t.isPrimary&&!this.heldPointer&&(this.heldPointer=t,this.target=t.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(t){this.heldPointer&&this.heldPointer.pointerId===t.pointerId&&this.cancel()},move:function(t){if(this.heldPointer&&this.heldPointer.pointerId===t.pointerId){var e=t.clientX-this.heldPointer.clientX,i=t.clientY-this.heldPointer.clientY;e*e+i*i>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(t,e){var n={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};e&&(n.holdTime=e);var o=i.makeGestureEvent(t,n);this.target.dispatchEvent(o)}};e.registerGesture("hold",n)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","up"],exposes:["tap"],down:function(t){t.isPrimary&&!t.tapPrevented&&n.set(t.pointerId,{target:t.target,buttons:t.buttons,x:t.clientX,y:t.clientY})},shouldTap:function(t,e){var i=!0;return"mouse"===t.pointerType&&(i=1^t.buttons&&1&e.buttons),i&&!t.tapPrevented},up:function(e){var o=n.get(e.pointerId);if(o&&this.shouldTap(e,o)){var r=t.targetFinding.LCA(o.target,e.relatedTarget);if(r){var s=i.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:e.clientX,y:e.clientY,detail:e.detail,pointerType:e.pointerType,pointerId:e.pointerId,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,_source:"tap"});r.dispatchEvent(s)}}n["delete"](e.pointerId)}};i.preventTap=function(t){return function(){t.tapPrevented=!0,n["delete"](t.pointerId)}},e.registerGesture("tap",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o=180/Math.PI,r={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(e){if(n.set(e.pointerId,e),2==n.pointers()){var i=this.calcChord(),o=this.calcAngle(i);this.reference={angle:o,diameter:i.diameter,target:t.targetFinding.LCA(i.a.target,i.b.target)},this.firePinch("pinchstart",i.diameter,i)}},up:function(t){var e=n.get(t.pointerId),i=n.pointers();if(e){if(2===i){var o=this.calcChord();this.firePinch("pinchend",o.diameter,o)}n["delete"](t.pointerId)}},move:function(t){n.has(t.pointerId)&&(n.set(t.pointerId,t),n.pointers()>1&&this.calcPinchRotate())},cancel:function(t){this.up(t)},firePinch:function(t,e,n){var o=e/this.reference.diameter,r=i.makeGestureEvent(t,{bubbles:!0,cancelable:!0,scale:o,centerX:n.center.x,centerY:n.center.y,_source:"pinch"});this.reference.target.dispatchEvent(r)},fireRotate:function(t,e){var n=Math.round((t-this.reference.angle)%360),o=i.makeGestureEvent("rotate",{bubbles:!0,cancelable:!0,angle:n,centerX:e.center.x,centerY:e.center.y,_source:"pinch"});this.reference.target.dispatchEvent(o)},calcPinchRotate:function(){var t=this.calcChord(),e=t.diameter,i=this.calcAngle(t);e!=this.reference.diameter&&this.firePinch("pinch",e,t),i!=this.reference.angle&&this.fireRotate(i,t)},calcChord:function(){var t=[];n.forEach(function(e){t.push(e)});for(var e,i,o,r=0,s={a:t[0],b:t[1]},l=0;lr&&(r=o,s={a:a,b:c})}return e=Math.abs(s.a.clientX+s.b.clientX)/2,i=Math.abs(s.a.clientY+s.b.clientY)/2,s.center={x:e,y:i},s.diameter=r,s},calcAngle:function(t){var e=t.a.clientX-t.b.clientX,i=t.a.clientY-t.b.clientY;return(360+Math.atan2(i,e)*o)%360}};e.registerGesture("pinch",r)}(i)},{}],18:[function(t,e,i){"use strict";function n(t,e){if(!(this instanceof n))throw d('Not called with "new" keyword.');var i,o,s=this;e=e||{},"string"==typeof t?(o=r(document.querySelectorAll(t)),i=c(o)):t[0]instanceof Element?(o=r(t),i=c(o)):(o=[],i=u(t,e),i.forEach(function(t){o=o.concat(r(t.element.querySelectorAll("li")))})),i.forEach(function(t){t.element.addEventListener("wheel",h)}),o.forEach(function(t,e){var i=t!==t.parentElement.lastElementChild?s.addEvt(t,"mousedown",t,!0):{element:t};o[e]=i}),g="transform"in o[0].element.style?"transform":"-webkit-transform",this.modelLists=i,this.items=o,this.bindings={},this.callback={},m(v,"list-dragon-base",e.cssStylesheetReferenceElement)}function o(t,e,i){if(t){var n=0>p&&t>=0||0===p&&0!==t||p>0&&0>=t;p=t>0?Math.min(50,t):Math.max(-50,t),n&&(clearInterval(f),f=setInterval(function(t){var e=i.scrollTop+p;0>p&&t>e||p>0&&e>t?(i.scrollTop=t,clearInterval(f)):i.scrollTop=e},125))}else clearInterval(f),p=0}function r(t){return Array.prototype.slice.call(t)}function s(t,e){return e.top<=t.y&&t.y<=e.bottom&&e.left<=t.x&&t.x<=e.right}function l(t,e){return"translate("+Math.floor(t+window.scrollX)+"px,"+Math.floor(e+window.scrollY)+"px)"}function a(t){var e=document.createTextNode(t);return document.createElement("a").appendChild(e).parentNode.innerHTML}function u(t,e){var i=e.label||"{label}";return t.forEach(function(n,o){var r=n.label||i,s=void 0!==n.htmlEncode&&n.htmlEncode||e.htmlEncode,l=document.createElement("div"),u=document.createElement("ul");if(n.models)Object.keys(n).forEach(function(t){"models"!==t&&(n.models[t]=n[t])}),t[o]=n=n.models;else{if(!(n instanceof Array))throw d("List [{1}] not an array of models (with or without additional properties) OR an object (with a `models` property containing an array of models).",o);n.models=n}n.forEach(function(t){var i=t.label||r,o=void 0!==t.htmlEncode&&t.htmlEncode||s,l="object"==typeof t?t:{label:t},c=C.call([l,n,e],i),h=document.createElement("li");h.innerHTML=o?a(c):c,u.appendChild(h)});var c=document.createElement("li");if(c.innerHTML=" ",u.appendChild(c),n.title){var h=document.createElement("div");h.innerHTML=s?a(n.title):n.title,l.appendChild(h)}l.appendChild(u),l.className=n.cssClassNames||e.cssClassNames||"dragon-list",n.element=u,n.container=l}),t}function c(t){var e=[];return t.forEach(function(t){var i=t.parentElement,n=i.parentElement,o=[];e.find(function(t){return t.element===i})||(r(i.querySelectorAll("li")).forEach(function(t){t!==i.lastElementChild&&o.push(t.innerHTML)}),o.element=i,o.container=n,e.push(o))}),e}function h(t){t.stopPropagation()}function d(){return"list-dragon: "+C.apply(this,Array.prototype.slice.call(arguments))}var g,f,p,v,m=t("css-injector"),C=t("templex"),w=null;v="div.dragon-list{position:relative;background-color:#fff}div.dragon-list>div,div.dragon-list>ul{position:absolute;left:0;right:0}div.dragon-list>div{text-align:center;background-color:#00796b;color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden;white-space:nowrap}div.dragon-list>ul{overflow-y:auto;bottom:0;margin:0;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}div.dragon-list>ul>li,li.dragon-pop{white-space:nowrap;list-style-type:none;border:0 solid #f4f4f4;border-bottom:1px solid #e0e0e0;cursor:move;transition:border-top-width .2s}div.dragon-list>ul>li:last-child{height:0;border-bottom:none}li.dragon-pop{position:fixed;background-color:#fff;border:1px solid #e0e0e0;left:0;top:0;overflow-x:hidden;box-shadow:rgba(0,0,0,.188235) 0 10px 20px,rgba(0,0,0,.227451) 0 6px 6px}",n.prototype={addEvt:function(t,e,i,n){var o={handler:y[e].bind(t,this),element:i||window};return n||(this.bindings[e]=o),o.element.addEventListener(e,o.handler),o},removeEvt:function(t){var e=this.bindings[t];delete this.bindings[t],e.element.removeEventListener(t,e.handler)},removeAllEventListeners:function(){for(var t in this.bindings){var e=this.bindings[t];e.element.removeEventListener(t,e.handler)}this.items.forEach(function(t){t.handler&&t.element.removeEventListener("mousedown",t.handler)}),this.modelLists.forEach(function(t){t.element.removeEventListener("wheel",h)})},pointInListRects:function(t){return this.modelLists.find(function(e){var i=e.element.getBoundingClientRect();return i={left:window.scrollX+i.left,top:window.scrollY+i.top,right:window.scrollX+i.right,bottom:window.scrollY+i.bottom,width:i.width,height:i.height},e.rect=i,s(t,i)?(e.rect=i,!0):!1})},pointInItemRects:function(t,e,i){return this.items.find(function(n){var o=n.element;return o!==e&&o!==i&&s(t,n.rect)})},getAllItemBoundingRects:function(){var t,e=this.modelLists;this.items.forEach(function(i){var n=i.element,o=n.parentElement,r=e.find(function(t){return t.element===o});if(void 0===r.isDropTarget||"function"==typeof r.isDropTarget&&r.isDropTarget()||r.isDropTarget){var s=n.getBoundingClientRect(),l=s.bottom;n===o.lastElementChild?(l=o.getBoundingClientRect().bottom,l0&&(i.element.scrollTop>0&&(s=u-(i.rect.top+5))<0?o(s,0,i.element):i.element.scrollTop0?o(s,a,i.element):o());var c=t.pointInItemRects({x:e.clientX,y:t.rect.bottom+window.scrollY+r+i.element.scrollTop},this,t.drop);if(this.style[g]=l(t.rect.left-window.scrollX+n,t.rect.top-window.scrollY+r),c){var h=c.element;h.style.transition=w,h.style.borderTopWidth=t.drop.style.borderTopWidth,t.drop.style.borderTopWidth=null,t.drop=h}}},mouseup:function(t,e){o(),t.removeEvt("mousemove"),t.removeEvt("mouseup"),e.stopPropagation();var i=this.getBoundingClientRect();if(window.scrollX+i.left===t.rect.left&&window.scrollY+i.top===t.rect.top)t.reinsert(this);else{var n=t.drop.getBoundingClientRect();t.addEvt(this,"transitionend",this),this.style.transitionDuration=w,this.style.transitionProperty=g,this.style[g]=l(n.left-window.scrollX,n.top-window.scrollY)}},transitionend:function(t,e){if(e.propertyName===g){t.removeEvt("transitionend"),t.reinsert(this),this.style.transitionProperty=w;var i=t.modelLists[t.origin.list].splice(t.origin.item,1)[0],n=t.itemCoordinates(this);t.modelLists[n.list].splice(n.item,0,i),t.callback.dropped&&t.callback.dropped.call(this,t)}}};e.exports=n},{"css-injector":4,templex:25}],19:[function(t,e,i){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(){return 1}function n(t){d||"string"==typeof t||"number"==typeof t||(d=!0,console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! "+typeof t).stack))}function o(t){return this instanceof o?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||i,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=i),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new o(t)}function r(t,e,i){n(e);var o=t._cache[e];return o&&(s(t,o)?(c(t,o),t._allowStale||(o=void 0)):i&&l(t,o),o&&(o=o.value)),o}function s(t,e){if(!e||!e.maxAge&&!t._maxAge)return!1;var i=!1,n=Date.now()-e.now;return i=e.maxAge?n>e.maxAge:t._maxAge&&n>t._maxAge}function l(t,e){u(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)c(t,t._lruList[t._lru])}function u(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],20:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return C[t]})}function a(e,i){function o(){if(m&&!C)for(;v.length;)delete f[v.pop()];else v=[];m=!1,C=!1}function r(t){if("string"==typeof t&&(t=t.split(y,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,C=!1;r(i||t.tags);for(var E,A,R,D,T,P,M=new h(e);!M.eos();){if(E=M.pos,R=M.scanUntil(l))for(var k=0,F=R.length;F>k;++k)D=R.charAt(k),s(D)?v.push(f.length):C=!0,f.push(["text",D,E,E+1]),E+=1,"\n"===D&&o();if(!M.scan(l))break;if(m=!0,A=M.scan(S)||"name",M.scan(w),"="===A?(R=M.scanUntil(b),M.scan(b),M.scanUntil(a)):"{"===A?(R=M.scanUntil(d),M.scan(x),M.scanUntil(a),A="&"):R=M.scanUntil(a),!M.scan(a))throw new Error("Unclosed tag at "+M.pos);if(T=[A,R,E,M.pos],f.push(T),"#"===A||"^"===A)g.push(T);else if("/"===A){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+E);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+E)}else"name"===A||"{"===A||"&"===A?C=!0:"="===A&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+M.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,C={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},w=/\s*/,y=/\s+/,b=/\s*=/,x=/\s*\}/,S=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var E=new g;t.clearCache=function(){return E.clearCache()},t.parse=function(t,e){return E.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return E.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],21:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],22:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x\|\:\[\]])/g,r=".*",s=".",l="("+r+")",a="_",u="%",c=new RegExp("("+[a,u,"\\[\\^?[^-\\]]+]","\\[\\^?[^-\\]]\\-[^\\]]]"].join("|")+")","g"); -n.reserve=function(t){return t.replace(o,"\\$1")};var h,d;(n.clearCache=function(t){return t?h[t]&&(delete h[t],d--):(h={},d=0),d})(),n.getCacheSize=function(){return d},n.cached=function(t,e,i){"string"==typeof t&&(i=e,e=t,t=!1);var o=e+(i?"i":"c"),r=h[o];if(r)r.when=(new Date).getTime(),void 0!==t&&(r.keep=t);else{if(d===n.cacheMax){var s,l,a=[],u=0;for(s in h)if(r=h[s],!r.keep){for(l=0;u>l&&!(r.when=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],25:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i-1,this.selectionModel=new C(this),this.localCellEditors={},this.cellEditors=Object.create(this.localCellEditors),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new g(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(n)}),i=i||{},i.top=i.top||0,i.right=i.right||"-200px",i.bottom=i.bottom||0,i.left=i.left||0,S||(S=!0,s()),this.initRenderer(),this.initCanvas(i),this.initScrollbars(),this.initLocalCellEditors(),document.body.addEventListener("copy",function(t){n.checkClipboardCopy(t)}),this.getCanvas().resize(),this.dialog=new y(this),this.filter=new x}function o(t,e){return p(e).each(function(e,i){"object"==typeof t[i]&&"object"==typeof e?o(t[i],e):void 0===e?delete t[i]:t[i]=e}),t}function r(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new f(n,o,r-n,s-o);return l}function s(){l(E);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);E.columnHeaderBackgroundColor=e.color,E.rowHeaderBackgroundColor=e.color,E.topLeftBackgroundColor=e.color,E.lineColor=e.backgroundColor,E.backgroundColor2=o.backgroundColor,E.color=n.color,E.fontFamily=n.fontFamily,E.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),E.columnHeaderColor=e.color,E.rowHeaderColor=e.color,E.topLeftColor=e.color,E.backgroundSelectionColor=e.backgroundColor,E.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),E.columnHeaderForegroundSelectionColor=e.color,E.columnHeaderBackgroundSelectionColor=e.backgroundColor,E.rowHeaderForegroundSelectionColor=e.color,E.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===E.columnHeaderBackgroundSelectionColor||"transparent"===E.lineColor)&&l(E),document.body.removeChild(t),document.body.removeChild(i)}function l(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function a(t){var e="function"==typeof t?t():t;return e||0===e?e:""}var u=t("extend-me"),c=t("./lib/deprecated");u.debug=!0;var h=t("finbars"),d=t("fincanvas"),g=t("rectangular").Point,f=t("rectangular").Rectangle,p=t("object-iterators"),v=t("./defaults"),m=t("./lib/Renderer"),C=t("./lib/SelectionModel"),w=t("../css/stylesheets"),y=t("./lib/TableDialog"),b=t("./lib/Formatters"),x=t("./lib/CustomFilter"),S=!1,E=Object.create(v),A=Object.create(E);n.prototype={constructor:n.prototype.constructor,deprecated:c,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(A),this.selectionModel=new C(this),this.cellEditors=Object.create(this.localCellEditors),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new g(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.behavior.reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){this.localCellEditors[t.alias]=t,t.grid=this},initLocalCellEditors:function(){var t=["Textfield","Choice","Color","Date","Slider","Spinner","Filter"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])}),this.localCellEditors["int"]=this.localCellEditors.spinner,this.localCellEditors["float"]=this.localCellEditors.spinner,this.localCellEditors.date=this.localCellEditors.date,this.localCellEditors.string=this.localCellEditors.extfield},toggleColumnPicker:function(){this.behavior.toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i&&i.x===t&&i.y===e},registerFormatter:function(t,e){b[t]=e},getFormatter:function(t){var e=b[t];return e?e:b["default"]},formatValue:function(t,e){var i=this.getFormatter(t);return i(e)},isColumnHovered:function(t){var e=this.getHoverCell();return e&&e.x===t},isRowResizeable:function(){return this.resolveProperty("rowResize")},isCheckboxOnlyRowSelections:function(){return this.resolveProperty("checkboxOnlyRowSelections")},isRowHovered:function(t){var e=this.getHoverCell();return e&&e.y===t},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new g(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(A)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){p(t).each(function(t,e){A[e]=t})},refreshProperties:function(){this.checkScrollbarVisibility(),this.behavior.defaultRowHeight=null,this.isColumnAutosizing()&&this.behavior.autosizeAllColumns()},addProperties:function(t){var e=this.getProperties();o(e,t),this.refreshProperties()},getPrivateState:function(){return this.behavior.getPrivateState()},setState:function(t){var e=this;this.behavior.setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.behavior.getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new g(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.behavior.getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(),this.checkColumnAutosizing(),this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.behavior;t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){this.behavior.setRenderedColumnCount(this.getVisibleColumns()+1),this.behavior.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.selectionModel.hasSelections():void 0},getSelectionAsTSV:function(){var t=this.selectionModel;if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){if(t.length){var e=t.length,i=t[0].length,n=e*i,o=[];if(n>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var r=0;i>r;r++){for(var s=0;e>s;s++)o.push(t[s][r]),e>s&&o.push(" ");i>r&&o.push("\n")}var l=o.join("");return l}return""},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){var t=this.isCheckboxOnlyRowSelections();this.selectionModel.clear(t),this.clearMouseDown()},clearMostRecentSelection:function(){var t=this.isCheckboxOnlyRowSelections();this.selectionModel.clearMostRecentSelection(t)},clearMostRecentColumnSelection:function(){this.selectionModel.clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){},clearRowSelection:function(){this.selectionModel.clearRowSelection(),this.behavior.getDataModel().getComponent().clearSelectedData()},select:function(t,e,i,n){0>t||0>e||this.selectionModel.select(t,e,i,n)},isSelected:function(t,e){return this.selectionModel.isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.selectionModel,i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.selectionModel,i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.deprecated("selectionModel",{since:"0.2"})},getBehavior:function(){return this.deprecated("behavior",{since:"0.2"})},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();return t&&t.getBounds()},resolveProperty:function(t){for(var e=t.split("."),i=this.getProperties();e.length;)i=i[e.shift()];return i},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(t){var e=this,i=this.divCanvas=document.createElement("div");this.div.appendChild(i),this.canvas=new d(i,this.renderer);var o=i.style;o.position="absolute",o.top=t.top,o.right=t.right,o.bottom=t.bottom,o.left=t.left,this.canvas.resizeNotification=function(){e.resized()},this.addFinEventListener("fin-canvas-mousemove",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.delegateMouseMove(n)}}),this.addFinEventListener("fin-canvas-mousedown",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.keys=t.detail.keys,n.primitiveEvent=t,e.mouseDownState=n,e.delegateMouseDown(n),e.fireSyntheticMouseDownEvent(n),e.repaint()}}),this.addFinEventListener("fin-canvas-mouseup",function(t){if(!e.resolveProperty("readOnly")){e.dragging=!1,e.isScrollingNow()&&e.setScrollingNow(!1),e.columnDragAutoScrolling&&(e.columnDragAutoScrolling=!1);var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.delegateMouseUp(n),e.mouseDownState&&e.fireSyntheticButtonPressedEvent(e.mouseDownState),e.mouseDownState=null,e.fireSyntheticMouseUpEvent(n)}}),this.addFinEventListener("fin-canvas-dblclick",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.fireSyntheticDoubleClickEvent(n,t),e.delegateDoubleClick(n)}}),this.addFinEventListener("fin-canvas-tap",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,n.keys=t.detail.keys,e.fireSyntheticClickEvent(n),e.delegateTap(n)}}),this.addFinEventListener("fin-canvas-drag",function(t){if(!e.resolveProperty("readOnly")){e.dragging=!0;var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.delegateMouseDrag(n)}}),this.addFinEventListener("fin-canvas-keydown",function(t){if(!e.resolveProperty("readOnly")){if(e.resolveProperty("editOnKeydown")){var i,o,r,s,l=t.detail["char"];e.isEditing()||"F2"!==l&&!(i=1===l.length)&&!(o="DELETE"===l||"BACKSPACE"===l)||(r=e.selectionModel.getLastSelection(),r&&(s=e.activateEditor(r.origin.x,r.origin.y),s instanceof n.cellEditors.Simple&&(i?s.input.value=l:o&&(s.input.value=""),t.detail.primitiveEvent.preventDefault())))}e.fireSyntheticKeydownEvent(t),e.delegateKeyDown(t)}}),this.addFinEventListener("fin-canvas-keyup",function(t){e.resolveProperty("readOnly")||(e.fireSyntheticKeyupEvent(t),e.delegateKeyUp(t))}),this.addFinEventListener("fin-canvas-track",function(t){if(!e.resolveProperty("readOnly")&&!e.dragging){var i=t.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?e.scrollVBy(-2):i.yDirection<-0&&e.scrollVBy(2):i.xDirection>0?e.scrollHBy(-1):i.xDirection<-0&&e.scrollHBy(1)}}),this.addFinEventListener("fin-canvas-wheelmoved",function(t){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t.detail.primitiveEvent,e.delegateWheelMoved(n)}),this.addFinEventListener("fin-canvas-mouseout",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t.detail.primitiveEvent,e.delegateMouseExit(n)}}),this.addFinEventListener("fin-canvas-context-menu",function(t){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t.detail.primitiveEvent,e.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.behavior.convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.behavior.convertDataPointToViewPoint(t)},addFinEventListener:function(t,e){this.canvas.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){this.behavior.onWheelMoved(this,t)},delegateMouseExit:function(t){this.behavior.handleMouseExit(this,t)},delegateContextMenu:function(t){this.behavior.onContextMenu(this,t)},delegateMouseMove:function(t){this.behavior.onMouseMove(this,t)},delegateMouseDown:function(t){this.behavior.handleMouseDown(this,t)},delegateMouseUp:function(t){this.behavior.onMouseUp(this,t)},delegateTap:function(t){this.behavior.onTap(this,t)},delegateMouseDrag:function(t){this.behavior.onMouseDrag(this,t)},delegateDoubleClick:function(t){this.behavior.onDoubleClick(this,t)},delegateHoldPulse:function(t){this.behavior.onHoldPulse(this,t)},delegateKeyDown:function(t){this.behavior.onKeyDown(this,t)},delegateKeyUp:function(t){this.behavior.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&this.isEditing()&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new f(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(n>=0&&o>=0){var r=new g(n,o);this.setMouseDown(r),this.setDragExtent(new g(0,0)),t.beginEditAt(r)}},isColumnVisible:function(t){return this.getRenderer().isColumnVisible(t)},isDataRowVisible:function(t){return this.getRenderer().isRowVisible(t)},isDataVisible:function(t,e){return this.isDataRowVisible(e)&&this.isColumnVisible(t)},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t+(e>0),o=!this.isColumnVisible(n)||t===i;return o&&this.scrollBy(e,0),o},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t+(e>0),o=!this.isDataRowVisible(n)||t===i;return o&&this.scrollBy(0,e),o},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new f(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell;if(e.x<=this.getColumnCount()&&e.y<=this.getRowCount()){var i=this.getHoverCell(),n=i.x,o=i.y;o>=0&&(o+=this.getVScrollValue()),this.behavior.cellClicked(new g(n,o),t)}},setTotalsValueNotification:function(t,e,i,n){this.fireSyntheticSetTotalsValue(t,e,i,n)},fireSyntheticSetTotalsValue:function(t,e,i,n){var o=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i,area:n?"bottom":"top"}});this.canvas.dispatchEvent(o)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-keyup",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-keydown",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-keypress",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=a(n.getValue(e,t))}var e,i,n=this,o=this.selectionModel.getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=a(i.getValue(e,t))}var e,i=this,n=this.selectionModel.getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=a(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=a(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=r(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,s=t.origin.y,l={},u=0;i>u;u++){var c=new Array(n);for(l[this.getField(u+o)]=c,e=0;n>e;e++)c[e]=a(this.getValue(o+u,s+e))}return l},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=r(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,s=[],l=0;e>l;l++){var u=new Array(i);s[l]=u;for(var c=0;i>c;c++)u[c]=a(this.getValue(n+l,o+c))}return s},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){this.stopEditing();var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticFilterAppliedEvent:function(t){var e=new CustomEvent("fin-filter-applied",{detail:t});this.canvas&&this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.behavior.enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){this.stopEditing();var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};this.behavior.enhanceDoubleClickEvent(t);var n=new CustomEvent("fin-double-click",{detail:i});this.behavior.cellDoubleClicked(e,t),this.canvas.dispatchEvent(n)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.behavior._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.behavior._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor&&this.cellEditor.isEditing},initScrollbars:function(){var t=this,e=new h({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new h({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.behavior.getValue(t,e)},setValue:function(t,e,i){this.behavior.setValue(t,e,i)},getColumnAlignment:function(t){return this.behavior.getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getFixedColumnCount(),e=this.getFixedRowCount(),i=this.getColumnCount(),n=this.getRowCount(),o=this.getBounds();if(o){for(var r=o.height-this.behavior.getFixedRowsMaxHeight()-15,s=o.width-200-this.behavior.getFixedColumnsMaxWidth()-15,l=0,a=0;i>l;l++){var u=this.getColumnWidth(i-l-1);if(a+=u,a>s)break}for(var c=0,h=0;n>c;c++){var d=this.getRowHeight(n-c-1);if(h+=d,h>r)break}var g=Math.max(0,i-t-l);this.setHScrollbarValues(g);var f=1+Math.max(0,n-e-c);this.setVScrollbarValues(f),this.setHScrollValue(Math.min(this.getHScrollValue(),g)),this.setVScrollValue(Math.min(this.getVScrollValue(),f)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new m(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.behavior.getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.behavior.setColumnWidth(t,e)},getColumnEdge:function(t){return this.behavior.getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.behavior.getFixedColumnsWidth()},getRowHeight:function(t){return this.behavior.getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.behavior.setRowHeight(t,e)},getFixedRowsHeight:function(){return this.behavior.getFixedRowsHeight()},getColumnCount:function(){return this.behavior.getColumnCount()},getRowCount:function(){return this.behavior.getRowCount()},getUnfilteredRowCount:function(){return this.behavior.getUnfilteredRowCount()},getFixedColumnCount:function(){return this.behavior.getFixedColumnCount()},getFixedRowCount:function(){return this.behavior.getFixedRowCount()},topLeftClicked:function(t){this.behavior.topLeftClicked(this,t)},rowHeaderClicked:function(t){this.behavior.rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.behavior.columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){var i;if((this.isEditable()||this.isFilterRow(e))&&(i=this.getCellEditorAt(t,e))){var n=i.getEditorPoint();if(i){if(n.x===t&&n.y===e&&i.isEditing)return;this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}return i; -},getCellEditorAt:function(t,e){return this.behavior._getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.behavior.getCursorAt(-1,-1),e=this.getHoverCell();if(e&&e.x>-1&&e.y>-1){var i=e.x+this.getHScrollValue();t=this.behavior.getCursorAt(i,e.y+this.getVScrollValue())}this.beCursor(t)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.behavior,i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.selectionModel.getSelections();if(t.length){for(var e=this.behavior,i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n,row:this.getRow(t.y)}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n,row:this.getRow(t.y)}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.behavior.getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.behavior.swapColumns(t,e)},endDragColumnNotification:function(){this.behavior.endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.behavior.getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){if(t>this.getFilterRowIndex()){e=e||[];var i=this.selectionModel,n=i.isRowSelected(t),o=e.indexOf("SHIFT")>=0;n?i.deselectRow(t):(this.singleSelect(),i.selectRow(t)),o&&(i.clear(),i.selectRow(this.lastEdgeSelection[1],t)),n||o||(this.lastEdgeSelection[1]=t),this.repaint()}},singleSelect:function(){var t=this.isCheckboxOnlyRowSelections(),e=this.isSingleRowSelectionMode(),i=this.mouseDownState.primitiveEvent.detail.primitiveEvent.ctrlKey,n=t&&e||!t&&(!i||e);return n&&this.selectionModel.clearRowSelection(),n},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.behavior.getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.behavior.setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.behavior.hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()&&0===t},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.selectionModel.isColumnOrRowSelected()},selectColumn:function(t,e){this.selectionModel.selectColumn(t,e)},selectRow:function(t,e){var i=this.selectionModel,n=this.getFilterRowIndex()+1;this.singleSelect()?t=e:e=e||t;var o=Math.min(t,e);if(o>=n){var r=Math.max(t,e);i.selectRow(o,r)}},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.selectionModel.isRowSelected(t)},isColumnSelected:function(t){return this.selectionModel.isColumnSelected(t)},lookupFeature:function(t){return this.behavior.lookupFeature(t)},getRow:function(t){return this.behavior.getRow(t)},getFieldName:function(t){return this.behavior.getFieldName(t)},getColumnIndex:function(t){return this.behavior.getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.behavior.getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.behavior.setGlobalFilter(t)},selectRowsFromCells:function(){if(!this.isCheckboxOnlyRowSelections()){var t,e=this.mouseDownState.primitiveEvent.detail.primitiveEvent.ctrlKey;e&&!this.isSingleRowSelectionMode()?this.selectionModel.selectRowsFromCells(0,e):(t=this.selectionModel.getLastSelection())?this.selectRow(null,t.corner.y):this.clearRowSelection()}},selectColumnsFromCells:function(){this.selectionModel.selectColumnsFromCells()},getSelectedRows:function(){return this.behavior.getSelectedRows()},getSelectedColumns:function(){return this.behavior.getSelectedColumns()},getSelections:function(){return this.behavior.getSelections()},getLastSelectionType:function(){return this.selectionModel.getLastSelectionType()},isCellSelected:function(t,e){return this.selectionModel.isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.selectionModel.isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.selectionModel.selectAllRows()},areAllRowsSelected:function(){return this.selectionModel.areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.selectionModel.clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.behavior.getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new g(t,e)},newRectangle:function(t,e,i,n){return new f(t,e,i,n)},getFormattedValue:function(t,e){e+=this.getHeaderRowCount();var i=this.getColumnProperties(t).format,n=this.getValue(t,e),o=this.getFormatter(i),r=o(n);return r}},e.exports=n},{"../css/stylesheets":1,"./defaults":47,"./lib/CustomFilter":68,"./lib/Formatters":69,"./lib/Renderer":71,"./lib/SelectionModel":72,"./lib/TableDialog":73,"./lib/deprecated":74,"extend-me":5,finbars:13,fincanvas:14,"object-iterators":21,rectangular:22}],28:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("../lib/Base"),r=t("./Column"),s=t("../lib/CellProvider"),l=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],a={isNull:!0},u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{format:{value:"default"},font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},setComplexFilter:function(t,e){var i=this.getColumn(t);i&&i.setComplexFilter(e)},getComplexFilter:function(t){var e=this.getColumn(t);return e&&e.getComplexFilter()},applyAnalytics:function(){},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&l.indexOf(i)>=0||e&&l.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!1),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.grid._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState().rowHeights;return e&&e[t]||this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.grid.isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){return this.getFixedColumnsWidth()},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){var t=this.grid.dialog,e=this;t.isOpen()?t.close():(this.buildColumnPicker(t.overlay),t.onClose=function(){e.updateFromColumnPicker(t.overlay)},t.open())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return a;var i=e.getProperties();return i?i:a},setColumnProperties:function(t,e){var i=this.allColumns[t].getProperties();n(i).extendOwn(e),this.changed()},getField:function(t){return-1===t?"tree":this.getColumn(t).getField()},getHeader:function(t){return-1===t?"Tree":this.getColumn(t).getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;ns;s++)if(i=this.getValue(s),n=this.typeOf(i),o!==n){if(!r||"number"!=typeof i)return"mixed";o="float"}return o},typeOf:function(t){var e=typeof t;switch(e){case"object":return t.constructor.name.toLowerCase();case"number":return parseInt(t)===t?"int":"float";default:return e}},getProperties:function(){return this.behavior.getPrivateState().columnProperties[this.index]},setProperties:function(t){var e=this.behavior.getPrivateState().columnProperties[this.index];this.clearObjectProperties(e,!1),o(e).extendOwn(t)},toggleSort:function(t){this.dataModel.toggleSort(this.index,t)},getCellEditorAt:function(t,e){return this.dataModel.getCellEditorAt(this.index,e)},getHeader:function(){return this.label},getField:function(){ -return this.dataModel.getFields()[this.index]}},e.exports=n},{"object-iterators":21}],30:[function(t,e,i){"use strict";function n(t,e){this.setComponent(e),this.setGrid(t)}var o=t("../lib/deprecated");n.prototype={constructor:n.prototype.constructor,deprecated:o,component:null,grid:null,getGrid:function(){return this.deprecated("grid",{since:"0.2"})},setGrid:function(t){this.grid=t,this.getComponent().setGrid(t)},getBehavior:function(){return this.deprecated("grid.behavior",{since:"0.2"})},changed:function(){this.grid.behavior.changed()},getPrivateState:function(){return this.grid.getPrivateState()},applyState:function(){},setComponent:function(t){this.component=t},getComponent:function(){return this.component},setGlobalFilter:function(t){return this.getComponent().setGlobalFilter(t)},getData:function(){return this.getComponent().getData()},getFilteredData:function(){return this.getComponent().getFilteredData()},getValue:function(t,e){return this.getComponent().getValue(t,e)},getUnfilteredValue:function(t,e){return this.getComponent().getUnfilteredValue(t,e)},setValue:function(t,e,i){this.getComponent().setValue(t,e,i)},getColumnCount:function(){return this.getComponent().getColumnCount()},applyAnalytics:function(){return this.getComponent().applyAnalytics()},getRowCount:function(){return this.getComponent().getRowCount()},getCellRenderer:function(t,e,i,n,o){return this.getComponent().getCellRenderer(t,e,i,n,o)},getRowHeight:function(t){return this.getComponent().getRowHeight(t)},getColumnEdge:function(t,e){return this.getComponent().getColumnEdge(t,e)},getColumnWidth:function(t){return this.getComponent().getColumnWidth(t)},setColumnWidth:function(t,e){this.getComponent().setColumnWidth(t,e)},toggleSort:function(t,e){this.getComponent().toggleSort(t,e)},getColumnProperties:function(t){return this.getComponent().getColumnProperties(t)},setColumnProperties:function(t,e){this.getComponent().setColumnProperties(t,e)},getHeaders:function(){return this.getComponent().getHeaders()},getFields:function(){return this.getComponent().getFields()},setFields:function(t){this.getComponent().setFields(t)},getCellProperties:function(t,e){return this.getComponent().getCellProperties(t,e)},setCellProperties:function(t,e,i){this.getComponent().setCellProperties(t,e,i)},getRow:function(t){return this.getComponent().getRow(t)},getTopTotals:function(){return this.getComponent().getTopTotals()},setTopTotals:function(t){this.getComponent().setTopTotals(t)},getBottomTotals:function(){return this.getComponent().getBottomTotals()},setBottomTotals:function(t){this.getComponent().setBottomTotals(t)},setData:function(t){return this.getComponent().setData(t)},hasHierarchyColumn:function(){return this.getComponent().hasHierarchyColumn()},setHeaders:function(t){return this.getComponent().setHeaders(t)},cellClicked:function(t,e){return this.getComponent().cellClicked(t,e)},getAvailableGroups:function(){return this.getComponent().getAvailableGroups()},getGroups:function(){return this.getComponent().getGroups()},setGroups:function(t){this.getComponent().setGroups(t)},getHiddenColumns:function(){return this.getComponent().getHiddenColumns()},getVisibleColumns:function(){return this.getComponent().getVisibleColumns()},setAggregates:function(t){return this.getComponent().setAggregates(t)},reset:function(){this.getComponent().reset()},getCellEditorAt:function(t,e){return this.getComponent().getCellEditorAt(t,e)},getUnfilteredRowCount:function(){return this.getComponent().getUnfilteredRowCount()}},e.exports=n},{"../lib/deprecated":74}],31:[function(t,e,i){"use strict";var n=t("list-dragon"),o=t("./Local"),r=t("./DataModelDecorator"),s=t("../dataModels/JSON"),l=t("../features/index"),a=t("../../css/stylesheets"),u=t("../local_node_modules/finanalytics").aggregations,c=o.extend("behaviors.JSON",{initialize:function(t,e){this.setData(e)},features:[l.CellSelection,l.KeyPaging,l.ColumnPicker,l.ColumnResizing,l.RowResizing,l.Filters,l.RowSelection,l.ColumnSelection,l.ColumnMoving,l.ColumnSorting,l.CellEditing,l.CellClick,l.OnHover],aggregations:u,createColumns:function(){var t=this.getDataModel(),e=t.getColumnCount(),i=t.getHeaders(),n=t.getFields();this.clearColumns();for(var o=0;e>o;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r,l.complexFilter=null}},getDefaultDataModel:function(){var t=new s,e=new r(this.grid,t);return e.setComponent(t),e},applyAnalytics:function(){this.dataModel.applyAnalytics()},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.grid.isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setBottomTotals:function(t){this.getDataModel().setBottomTotals(t)},getBottomTotals:function(){return this.getDataModel().getBottomTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},buildColumnPicker:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;ia;a++){var u=t.getUnfilteredValue(s,a);l.set(u,u)}var c=l.values;c.sort(),c.length>0&&c[0].length>0&&c.unshift(""),this.setItems(c)}},showEditor:function(){var t=this;this.input.style.display="inline",setTimeout(function(){t.showDropdown(t.input)},50)},preShowEditorNotification:function(){this.autopopulate(),this.setEditorValue(this.initialValue)},setItems:function(t){this.items=t,this.updateView()},initializeInput:function(t){var e=this;n.prototype.initializeInput.apply(this,[t]),t.onchange=function(){e.stopEditing()}}});e.exports=r},{"../lib/Mappy":70,"./Simple":40}],37:[function(t,e,i){"use strict";var n=t("./Simple"),o=n.extend("Color",{alias:"color",template:function(){}});e.exports=o},{"./Simple":40}],38:[function(t,e,i){"use strict";function n(t){var e=t.match(/(\d+)/g);return new window.Date(e[0],e[1]-1,e[2])}var o=t("./Simple"),r=t("../lib/Formatters"),s=o.extend("Date",{alias:"date",template:function(){},setEditorValue:function(t){null!=t&&"Date"===t.constructor.name&&(t=r.date(t)),this.getInput().value=t+""},getEditorValue:function(){var t=this.getInput().value;return t=n(t)}});e.exports=s},{"../lib/Formatters":69,"./Simple":40}],39:[function(t,e,i){"use strict";var n=t("./CellEditor"),o=n.extend("Filter",{alias:"filter",initialize:function(){var t=document.createElement("div"),e=t.style;e.position="absolute",e.top=e.bottom="44px",e.right=e.left="1em",e.overflowY="scroll";var i=document.createElement("table");t.appendChild(i),e=i.style,e.width=e.height="100%";var n=document.createElement("tr"),o=document.createElement("td");i.appendChild(n),n.appendChild(o),this.title=document.createElement("div"),this.title.innerHTML="Filter Editor",this.dialog=document.createElement("div"),this.content=o,this.buttons=document.createElement("div"),e=this.dialog.style,e.position="absolute",e.top=e.left=e.right=e.bottom=0,e.whiteSpace="nowrap",e=this.title.style,e.position="absolute",e.top=e.left=e.right=0,e.height="44px",e.whiteSpace="nowrap",e.textAlign="center",e.padding="11px",e=this.buttons.style,e.position="absolute",e.left=e.right=e.bottom=0,e.height="44px",e.whiteSpace="nowrap",e.textAlign="center",e.padding="8px",this.dialog.appendChild(this.title),this.dialog.appendChild(t),this.dialog.appendChild(this.buttons),this.ok=document.createElement("button"),this.ok.style.borderRadius="8px",this.ok.style.width="5.5em",this.cancel=document.createElement("button"),this.cancel.style.marginLeft="2em",this.cancel.style.borderRadius="8px",this.cancel.style.width="5.5em",this["delete"]=document.createElement("button"),this["delete"].style.marginLeft="2em",this["delete"].style.borderRadius="8px",this["delete"].style.width="5.5em",this.reset=document.createElement("button"),this.reset.style.marginLeft="2em",this.reset.style.borderRadius="8px",this.reset.style.width="5.5em",this.ok.innerHTML="ok",this.cancel.innerHTML="cancel",this["delete"].innerHTML="delete",this.reset.innerHTML="reset",this.buttons.appendChild(this.ok),this.buttons.appendChild(this.reset),this.buttons.appendChild(this["delete"]),this.buttons.appendChild(this.cancel);var r=this;this.ok.onclick=function(){r.okPressed()},this.cancel.onclick=function(){r.cancelPressed()},this["delete"].onclick=function(){r.deletePressed()},this.reset.onclick=function(){r.resetPressed()}},tearDown:function(){this.content.innerHTML=""},okPressed:function(){var t=this.grid.dialog;t.onOkPressed()},cancelPressed:function(){var t=this.grid.dialog;t.onCancelPressed()},deletePressed:function(){var t=this.grid.dialog;t.onDeletePressed()},resetPressed:function(){var t=this.grid.dialog;t.onResetPressed()},beginEditAt:function(t){var e=this.grid.behavior,i=this.grid.dialog,n=t.x,o=e.getColumnId(n),r=e.getField(n),s=e.getColumn(n).getType(),l=function(){return[{name:r,alias:o,type:s}]};this.title.innerHTML="Manage Filters";var a=this.grid.filter;if(i.isOpen())i.close();else{var u=this;i.clear(),i.overlay.appendChild(this.dialog),a.initialize(l),i.onOkPressed=function(){a.onOk&&a.onOk()||(u.tearDown(),e.setComplexFilter(n,{state:a.getState()}),i.close(),e.applyAnalytics(),e.changed())},i.onCancelPressed=function(){a.onCancel&&a.onCancel()||(u.tearDown(),i.close(),a=void 0)},i.onDeletePressed=function(){a.onDelete&&a.onDelete()||(u.tearDown(),e.setComplexFilter(n,void 0),i.close(),e.applyAnalytics(),e.changed())},i.onResetPressed=function(){a.onReset&&a.onReset()||(u.tearDown(),a.initialize(i),a.onShow&&a.onShow(u.content))};var c=this.grid._getBoundsOfCell(n,t.y),h=this.grid.div.getBoundingClientRect().left-this.grid.divCanvas.getBoundingClientRect().left;c.x=c.x-h,i.openFrom(c);var d=e.getComplexFilter(n);d&&a.setState(d.state),setTimeout(function(){a.onShow&&a.onShow(u.content)},i.getAnimationTime()+10)}}});e.exports=o},{"./CellEditor":35}],40:[function(t,e,i){"use strict";var n=t("./CellEditor.js"),o=n.extend("Simple",{input:null,alias:"simple",initialize:function(){this.editorPoint={x:0,y:0}},specialKeyups:{9:"stopEditing",13:"stopEditing",27:"cancelEditing"},keyup:function(t){if(t){var e=this.specialKeyups[t.keyCode];e&&(t.preventDefault(),this[e](),this.grid.repaint(),this.grid.takeFocus()),this.grid.fireSyntheticEditorKeyUpEvent(this,t)}},initializeInput:function(t){var e=this;t.addEventListener("keyup",this.keyup.bind(this)),t.addEventListener("keydown",function(t){e.grid.fireSyntheticEditorKeyDownEvent(e,t)}),t.addEventListener("keypress",function(t){e.grid.fireSyntheticEditorKeyPressEvent(e,t)}),t.onblur=function(t){e.cancelEditing()},t.style.position="absolute",t.style.display="none",t.style.border="solid 2px black",t.style.outline=0,t.style.padding=0,t.style.boxShadow="white 0px 0px 1px 1px"},getEditorValue:function(){var t=this.getInput().value;return t},setEditorValue:function(t){this.getInput().value=t},clearStopEditing:function(){this.setEditorValue(""),this.stopEditing()},cancelEditing:function(){this.isEditing&&(this.getInput().value=null,this.isEditing=!1,this.hideEditor())},showEditor:function(){this.getInput().style.display="inline"},hideEditor:function(){this.getInput().style.display="none"},takeFocus:function(){var t=this;setTimeout(function(){var e=t.input.style.transform;t.input.style.transform="translate(0,0)",t.input.focus(),t.selectAll(),t.input.style.transform=e})},selectAll:function(){},originOffset:function(){return[0,0]},setBounds:function(t){var e=this.originOffset(),i="translate("+(t.x-1+e[0])+"px,"+(t.y-1+e[1])+"px)",n=this.getInput();n.style.boxSizing="border-box",n.style.webkitTransform=i,n.style.MozTransform=i,n.style.msTransform=i,n.style.OTransform=i,n.style.width=t.width+2+"px",n.style.height=t.height+2+"px"},saveEditorValue:function(){var t=this.getEditorPoint(),e=this.getEditorValue();if(e!==this.initialValue){parseFloat(this.initialValue)===this.initialValue&&(e=parseFloat(e));var i=this.grid.fireBeforeCellEdit(t,this.initialValue,e,this);i&&(this.grid.behavior.setValue(t.x,t.y,e),this.grid.fireAfterCellEdit(t,this.initialValue,e,this))}},_moveEditor:function(){var t=this.getEditorPoint(),e=this.grid._getBoundsOfCell(t.x,t.y),i=this.grid.div.getBoundingClientRect().left-this.grid.divCanvas.getBoundingClientRect().left;e.x=e.x-i,this.setBounds(e)},moveEditor:function(){this._moveEditor(),this.takeFocus()},beginEditAt:function(t){this.isAdded||(this.isAdded=!0,this.attachEditor()),this.setEditorPoint(t);var e=this.grid.behavior.getValue(t.x,t.y);"Array"===e.constructor.name&&(e=e[1]);var i=this.grid.fireRequestCellEdit(t,e);i&&(this.initialValue=e,this.isEditing=!0,this.setCheckEditorPositionFlag(),this.checkEditor())},checkEditor:function(){if(this.checkEditorPositionFlag&&(this.checkEditorPositionFlag=!1,this.isEditing)){var t=this.getEditorPoint();this.grid.isDataVisible(t.x,t.y)?(this.preShowEditorNotification(),this.attachEditor(),this.moveEditor(),this.showEditor()):this.hideEditor()}},attachEditor:function(){var t=this.getInput(),e=this.grid.div,i=e.querySelectorAll(".finbar-horizontal, .finbar-vertical");e.insertBefore(t,i.length?i[0]:null)},preShowEditorNotification:function(){this.setEditorValue(this.initialValue)},getInput:function(){return this.input||(this.input=this.getDefaultInput()),this.input},getDefaultInput:function(){var t=document.createElement("DIV");t.innerHTML=this.getHTML();var e=t.firstChild;return this.initializeInput(e),e},updateView:function(){var t=this.getInput(),e=t.parentNode,i=this.getDefaultInput();this.input=i,e.replaceChild(i,t)},showDropdown:function(t){var e;e=document.createEvent("MouseEvents"),e.initMouseEvent("mousedown",!0,!0,window),t.dispatchEvent(e)}});e.exports=o},{"./CellEditor.js":35}],41:[function(t,e,i){"use strict";var n=t("./Simple"),o=n.extend("Slider",{alias:"slider",template:function(){}});e.exports=o},{"./Simple":40}],42:[function(t,e,i){"use strict";var n=t("./Simple"),o=n.extend("Spinner",{alias:"spinner",template:function(){}});e.exports=o},{"./Simple":40}],43:[function(t,e,i){"use strict";function n(){this.saveEditorValue(),this._moveEditor()}var o=t("./Simple"),r=o.extend("Textfield",{alias:"textfield",template:function(){},selectAll:function(){this.input.setSelectionRange(0,this.input.value.length)},specialKeyups:{9:"stopEditing",13:"stopEditing",27:"cancelEditing"},keyup:function(t){t&&(o.prototype.keyup.call(this,t),this.grid.isFilterRow(this.getEditorPoint().y)&&setTimeout(n.bind(this)))}});e.exports=r},{"./Simple":40}],44:[function(t,e,i){"use strict";e.exports={CellEditor:t("./CellEditor"),Textfield:t("./Textfield"),Choice:t("./Choice"),Color:t("./Color"),Date:t("./Date"),Simple:t("./Simple"),Slider:t("./Slider"),Spinner:t("./Spinner"),Filter:t("./Filter")}},{"./CellEditor":35,"./Choice":36,"./Color":37,"./Date":38,"./Filter":39,"./Simple":40,"./Slider":41,"./Spinner":42,"./Textfield":43}],45:[function(t,e,i){"use strict";var n=t("../lib/Base"),o="A".charCodeAt(0),r=n.extend("DataModel",{next:null,grid:null,setGrid:function(t){this.grid=t},getGrid:function(){return this.deprecated("grid",{since:"0.2"})},getBehavior:function(){return this.deprecated("grid.behavior",{since:"0.2"})},changed:function(){this.grid.behavior.changed()},getPrivateState:function(){return this.grid.getPrivateState()},applyState:function(){},alphaFor:function(t){var e=Math.floor(t/26),i=t%26,n="";return e>0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)},getCellEditorAt:function(t,e){}});e.exports=r},{"../lib/Base":66}],46:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return t=t.toLowerCase(),function(e){return e=n(e),(e+"").toLowerCase().indexOf(t)>-1}}function r(){var t=this.selectedData,e=this.grid.selectionModel.hasRowSelections(),i=t.length||e;if(i)var n=this.getFilteredData();t.forEach(function(e,i){n.indexOf(e)>=0&&delete t[i]}),e&&this.grid.getSelectedRows().forEach(function(e){var i=n[e];t.indexOf(i)<0&&t.push(i)})}function s(){if(this.selectedData.length){var t=this.grid.selectionModel,e=this.grid.getHeaderRowCount(),i=this.getFilteredData();t.clearRowSelection(),this.selectedData.forEach(function(n){var o=i.indexOf(n);o>=0&&t.selectRow(e+o)})}}function l(){0===this.analytics.aggregates.length&&this.quietlySetAggregates({}),this.analytics.apply()}function a(){var t=this.getVisibleColumns();this.getGlobalFilterSource().apply(t);var e=[],i=this.getFilterSource(),n=0;i.clearAll(),t.forEach(function(t){var r=t.index,s=this.getFilter(r),l=t.getProperties().format,a=this.grid.getFormatter(l),u=this.getComplexFilter(r),c=u||s.length>0&&o(s);c&&(i.add(r-n,this.createFormattedFilter(a,c)),e.push({column:t.label,format:u?"complex":l}))}.bind(this)),i.applyAll(),this.grid.fireSyntheticFilterAppliedEvent({details:e})}function u(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;nn;n++)i[n]=t.getRow(n);return i},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.grid.getHeaderRowCount();return n?-2===t&&(t=0):this.hasAggregates()&&(t+=1),i=o>e?this.getHeaderRowValue(t,e):this.getDataSource().getValue(t,e-o)},getHeaderRowValue:function(t,e){var i;if(void 0===e)i=this.getHeaders()[Math.max(t,0)];else if(0>e){var n=this.getBottomTotals();i=n[n.length+e][t]}else{var o=this.grid.isShowFilterRow(),r=this.grid.isShowHeaderRow(),s=(o?1:0)+(r?1:0);if(e>=s)i=this.getTopTotals()[e-s][t];else{if(!r||0!==e){i=this.getFilter(t);var l=d.filter(i.length);return[null,i,l]}i=this.getHeaders()[t];var a=this.getSortImageForColumn(t);a&&(i=a+i)}}return i},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.grid.getHeaderRowCount();n?-2===t&&(t=0):this.hasAggregates()&&(t+=1),o>e?this.setHeaderRowValue(t,e,i):this.getDataSource().setValue(t,e-o,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.grid.isShowFilterRow(),o=this.grid.isShowHeaderRow(),r=n&&o,s=(n?1:0)+(o?1:0);if(e>=s)this.getTopTotals()[e-s][t]=i;else{if(-1===t)return;if(r){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!n)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.grid.behavior.allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e,i;return(i=this.getColumnProperties(t))&&(e=i.filter),e||""},getComplexFilter:function(t){var e,i,o,r,s;return(i=this.getColumnProperties(t))&&(o=i.complexFilter)&&(r=this.grid.filter)&&(s=r.create(o.state))&&(e=function(t){var e=n(t);return s(e)}),e},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){var t=this.grid.resolveProperty("showTreeColumn")===!0,e=this.hasAggregates(),i=e&&!t?-1:0;return this.analytics.getColumnCount()+i},getRowCount:function(){var t=this.getDataSource().getRowCount();return t+=this.grid.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},setData:function(t){this.source=new c.JSDataSource(t),this.analytics=new c.DataSourceAggregator(this.source),this.postglobalfilter=new c.DataSourceGlobalFilter(this.analytics),this.postfilter=new c.DataSourceFilter(this.postglobalfilter),this.postsorter=new c.DataSourceSorterComposite(this.postfilter),this.applyAnalytics()},setTopTotals:function(t){this.topTotals=t},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setBottomTotals:function(t){this.bottomTotals=t},getBottomTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.bottomTotals},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.grid.fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;o-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},getSortImageForColumn:function(t){t++;var e=!0,i=this.getPrivateState().sorts;if(!i)return null;var n=i.indexOf(t);if(0>n&&(n=i.indexOf(-1*t),e=!1),0>n)return null;var o=i.length-n,r=e?g:f;return o+r+" "},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.grid.getHeaderRowCount(),n=e.gridCell.y-i;this.getDataSource().click(n),this.applyAnalytics(!0),this.changed()}},getRow:function(t){var e=this.grid.getHeaderRowCount();if(e>t&&!this.hasAggregates()){var i=this.getTopTotals();return i[t-(e-i.length)]}return this.getDataSource().getRow(t-e)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=t.behavior.getHeaderRowCount()&&e.gridCell.x>=t.behavior.getHeaderColumnCount()?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":58}],50:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.resolveProperty("editOnDoubleClick");this.checkActivateEditor(t,e,i)?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleTap:function(t,e){var i=t.resolveProperty("editOnDoubleClick");this.checkActivateEditor(t,e,!i)?t._activateEditor(e):this.next&&this.next.handleTap(t,e)},handleHoldPulse:function(t,e){var i=t.resolveProperty("editOnDoubleClick");this.checkActivateEditor(t,e,!i)?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)},checkActivateEditor:function(t,e,i){var n=t.behavior.getHeaderRowCount(),o=t.behavior.getHeaderColumnCount(),r=e.gridCell,s=t.isFilterRow(r.y),l=i&&r.x>=o&&(s||r.y>=n);return l}});e.exports=o},{"./Feature.js":58}],51:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.behavior.getHeaderRowCount(),a=t.behavior.getHeaderColumnCount(),u=t.behavior.getColumnCount(),c=o.x>=u,h=l>s||a>r;if(!t.isCellSelection()||i||h||c)this.next&&this.next.handleMouseDown(t,e);else{var d=t.getFixedColumnCount(),g=t.getFixedRowCount();o.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=i.indexOf("CTRL")>=0,o=i.indexOf("SHIFT")>=0,r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(n&&s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":58}],52:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":58}],53:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.behavior.isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundary()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":58}],54:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnPicker",{alias:"ColumnPicker",handleKeyUp:function(t,e){var i=e.detail["char"].toLowerCase(),n=t.resolveProperty("editorActivationKeys");n.indexOf(i)>-1&&t.toggleColumnPicker()}});e.exports=o},{"./Feature.js":58}],55:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":58}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=50,r=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleDoubleClick:function(t,e){this.doubleClickTimer&&(clearTimeout(this.doubleClickTimer),this.doubleClickTimer=void 0),this.next&&this.next.handleDoubleClick(t,e)},handleMouseDown:function(t,e){if(!this.doubleClickTimer){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,r=e.viewPoint,s=n.x,l=n.y,a=t.isShowHeaderRow()&&0===l&&-1!==s;i||!a?this.next&&this.next.handleMouseDown(t,e):this.doubleClickTimer=setTimeout(function(){this.doubleClickTimer=void 0;var i=t.getFixedColumnCount();r.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=r},{"./Feature.js":58}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":58}],58:[function(t,e,i){"use strict";var n=t("../lib/Base"),o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.yr;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now(); -},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":58}],64:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":58}],65:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),ColumnPicker:t("./ColumnPicker"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":49,"./CellEditing":50,"./CellSelection":51,"./ColumnAutosizing":52,"./ColumnMoving":53,"./ColumnPicker":54,"./ColumnResizing":55,"./ColumnSelection":56,"./ColumnSorting":57,"./Feature":58,"./Filters":59,"./KeyPaging":60,"./OnHover":61,"./RowResizing":62,"./RowSelection":63,"./ThumbwheelScrolling":64}],66:[function(t,e,i){"use strict";var n=t("./deprecated"),o=t("extend-me").Base;o.prototype.deprecated=n,e.exports=o},{"./deprecated":74,"extend-me":5}],67:[function(t,e,i){"use strict";function n(t,e){var i="f"===(typeof e)[0],n=i?e(t):e;return n||0===n?n:""}function o(t,e,i,n,o,r){var s=t.getTextWidth(e,i);switch(e.textAlign){case"center":n-=s/2;break;case"right":n-=s}e.lineWidth=r,e.moveTo(n+.5,o+.5),e.lineTo(n+s+.5,o+.5)}function r(t,e,i,n,o,r){var s=t.getTextHeight(t.font),l=t.getTextWidth(e,i);switch(o-=.4*s.height,e.textAlign){case"center":n-=l/2;break;case"right":n-=l}e.lineWidth=r,e.moveTo(n+.5,o+.5),e.lineTo(n+l+.5,o+.5)}function s(t,e,i,n){if(1===i.length)return i;for(var o,r=[i.shift()];(o=e.getTextWidth(t,r.join(" "))1&&i.unshift(r.pop()),r=[r.join(" ")],i.length&&(r=r.concat(s(t,e,i,n))),r}function l(t,e,i,n){return s(t,e,a(i).split(" "),n)}function a(t){return t.toString().trim().replace(/\s\s+/g," ")}function u(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}function c(t){if(void 0===t)return 0;var e=t.match(c.regex);if(null===e)return 1;var i=e[4];return void 0===i?0:Number(i)}var h=t("./Base"),d=h.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,a=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",u(t,s,l,a,c,h,d,!0);var g=(a-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,h=e.bounds.y,d=e.bounds.width,g=e.bounds.height,f=e.headerTextWrapping,p=2,v=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],a&&"object"==typeof a&&"HTMLImageElement"===a.constructor.name&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),a=e.formatter(a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle");var m,C,w,y;e.isCellHovered&&e.hoverCellHighlight.enabled?w=e.hoverCellHighlight.backgroundColor:e.isRowHovered&&(C=e.hoverRowHighlight).enabled?w=e.isGridColumn||!C.header||void 0===C.header.backgroundColor?C.backgroundColor:C.header.backgroundColor:e.isColumnHovered&&(C=e.hoverColumnHighlight).enabled&&(w=e.isGridRow||!C.header||void 0===C.header.backgroundColor?C.backgroundColor:C.header.backgroundColor),c(w)<1&&(e.isSelected&&(y=n(e,e.backgroundSelectionColor)),c(y)<1&&(m=n(e,e.backgroundColor),c(m)>0&&(t.fillStyle=m,t.fillRect(u,h,d,g))),void 0!==y&&(t.fillStyle=y,t.fillRect(u,h,d,g))),void 0!==w&&(t.fillStyle=w,t.fillRect(u,h,d,g));var b=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==b&&(t.fillStyle=b,t.strokeStyle=b),v&&f?this.renderMultiLineText(t,u,h,g,d,e,a):this.renderSingleLineText(t,u,h,g,d,e,a);var x=0;if(i&&(l=Math.round((g-i.height)/2),t.drawImage(i,u+p,h+l),x=Math.max(i.width+2)),o&&d>1.75*g){l=Math.round((g-o.height)/2);var S=u+d-o.width;void 0!==m?(t.fillStyle=m,t.fillRect(S,h,o.width,g)):t.clearRect(S,h,o.width,g),t.drawImage(o,S,h+l),x=Math.max(o.width+2)}r&&(l=Math.round((g-r.height)/2),s=Math.round((d-r.width)/2),t.drawImage(r,u+d-s-r.width,h+l),x=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,h,d,g),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*x},renderMultiLineText:function(t,e,i,n,o,r,s){var u=l(t,r,s,o);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,a(s));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=o-c;break;case"center":h=o/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((n-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),t.save(),t.rect(e,i,o,n),t.clip(),t.textAlign=g;for(var m=0;mt?"-0":"-")+t}e.exports={date:function(t){return t instanceof Date?t.getFullYear()+n(t.getMonth()+1)+n(t.getDate()):t+""},"default":function(t){return t+""}}},{}],70:[function(t,e,i){"use strict";e.exports=function(){function t(){this.keys=[],this.data={},this.values=[]}var e=".~.#%_",i=0,n=function(t){var n=typeof t;switch(n){case"number":return e+n+"_"+t;case"string":return e+n+"_"+t;case"boolean":return e+n+"_"+t;case"symbol":return e+n+"_"+t;case"undefined":return e+"undefined";case"object":case"function":return t.___finhash||(t.___finhash=e+i++),t.___finhash}},o=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},r=function(t,e){if(e!=e||0===e)for(var i=t.length;i--&&!o(t[i],e););else i=[].indexOf.call(t,e);return i};return t.prototype.set=function(t,e){var i=n(t);void 0===this.data[i]&&(this.keys.push(t),this.values.push(e)),this.data[i]=e},t.prototype.get=function(t){var e=n(t);return this.data[e]},t.prototype.getIfAbsent=function(t,e){var i=this.get(t);return void 0===i&&(i=e(t,this)),i},t.prototype.size=function(){return this.keys.length},t.prototype.clear=function(){this.keys.length=0,this.data={}},t.prototype["delete"]=function(t){var e=n(t);if(void 0!==this.data[e]){var i=r(this.keys,t);this.keys.splice(i,1),this.values.splice(i,1),delete this.data[e]}},t.prototype.forEach=function(t){for(var e=this.keys,i=0;it&&(i=t,t>=g&&(i+=h,void 0===s&&(s=i),l=i),!(E>w||i>=d));t++)o=m.getColumnWidth(i),E+=o,this.columnEdges[t+1]=Math.round(E),this.visibleColumns[t]=i,this.columnEdgesIndexMap[i]=t,b=b+Math.round(o/2)+x,this.insertionBounds.push(b),x=Math.round(o/2);for(e=0;f>e&&(n=e,e>=p&&(n+=c,void 0===a&&(a=n),u=n),!(A>y||n>=f));e++)r=m.getRowHeight(n),A+=r,this.rowEdges[e+1]=Math.round(A),this.visibleRows[e]=n,this.rowEdgesIndexMap[n]=e;this.viewHeight=y,this.dataWindow=this.grid.newRectangle(s,a,l-s,u-a)},resolveProperty:function(t){return this.grid.resolveProperty(t)},getGrid:function(){return this.deprecated("grid",{since:"0.2"})},_paint:function(t){this.grid&&(this.renderGrid(t),this.grid.gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){return this.viewHeight-this.grid.getFixedRowsHeight()},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i,n=!1,o=!1,r=this.cell,s=this.columnEdgesIndexMap[t];void 0===s&&(s=this.columnEdgesIndexMap[t-1],n=!0);var l,a,u,c=this.columnEdges[s],h=this.columnEdges[s+1],d=h-c;if(r.x=n?h:c,r.width=n?0:d,0>e){var g=this.grid.behavior,f=this.getBounds();u=g.getDefaultRowHeight(),l=f.height+e*u,a=l+u}else i=this.rowEdgesIndexMap[e],void 0===i&&(i=this.rowEdgesIndexMap[e-1],o=!0),l=this.rowEdges[i],a=this.rowEdges[i+1],u=a-l;return r.y=o?a:l,r.height=o?0:u,r},getColumnFromPixelX:function(t){for(var e=0,i=this.getFixedColumnCount(),n=this.grid.getHScrollValue(),o=this.getColumnEdges(),r=1;rt)return r>i&&(r+=n),r-1;return r>i&&(r+=n),r-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.grid.behavior,s=0,l=0,a=0,u=this.getColumnEdges(),c=this.getFixedColumnCount(),h=this.getFixedRowCount(),d=this.getScrollLeft(),g=this.getScrollTop();for(n=0;n=c&&(n+=d),o>=h&&(o+=g);var p=-1,v=r.getColumn(n);return v&&(p=v.index),{gridCell:this.grid.newPoint(n,o),mousePoint:this.grid.newPoint(e,i),viewPoint:f,dataCell:this.grid.newPoint(p,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundary:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.grid.isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.grid.selectionModel.getSelections();if(e&&0!==e.length){var i=e[e.length-1],n=i.origin;if(-1!==n.x){var o=this.getVisibleColumns(),r=this.getVisibleRows(),s=o[o.length-1],l=r[r.length-1],a=i.extent,u=Math.min(n.x,n.x+a.x),c=Math.min(n.y,n.y+a.y);if(!(u>s||c>l)){var h=Math.max(n.x,n.x+a.x)+1;h=Math.min(h,1+s);var d=Math.max(n.y,n.y+a.y)+1;d=Math.min(d,1+l);var g=this._getBoundsOfCell(u,c),f=Math.round(void 0===g.x?this.grid.getFixedColumnsWidth():g.x),p=Math.round(void 0===g.y?this.grid.getFixedRowsHeight():g.y),v=this._getBoundsOfCell(h,d),m=Math.round(void 0===v.x?this.grid.getFixedColumnsWidth():v.x),C=Math.round(void 0===v.y?this.grid.getFixedRowsHeight():v.y),w=Math.min(f,m),y=Math.min(p,C),b=1+m-f,x=1+C-p;w===m&&(b=f-m),y===C&&(x=p-C),1>b*x||(t.rect(w,y,b,x),t.fillStyle=this.resolveProperty("selectionRegionOverlayColor"),t.fill(),t.lineWidth=1,t.strokeStyle=this.resolveProperty("selectionRegionOutlineColor"),t.stroke())}}}},renderOverrides:function(t){var e=this.grid.renderOverridesCache;for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];n&&this.renderOverride(t,n)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},getScrollTop:function(){return this.grid.getVScrollValue()},getScrollLeft:function(){return this.grid.getHScrollValue()},getBehavior:function(){return this.deprecated("grid.behavior",{since:"0.2"})},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},isLastColumnVisible:function(){var t=this.getColumnCount()-1;return-1!==this.visibleColumns.indexOf(t)},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.grid.getCanvas()},isDraggingColumn:function(){return this.grid.isDraggingColumn()},getPageUpRow:function(){for(var t=this.grid,e=this.getVisibleScrollHeight(),i=this.grid.getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.grid.getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.grid.getColumnCount()},getRowCount:function(){return this.grid.getRowCount()},getFixedColumnCount:function(){return this.grid.getFixedColumnCount()},getFixedRowCount:function(){return this.grid.getFixedRowCount()},getHeaderRowCount:function(){return this.grid.getHeaderRowCount()},getHeaderColumnCount:function(){return this.grid.getHeaderColumnCount()},paintCells:function(t){var e,i,o,r,s,l,a,u=this.getColumnEdges(),c=this.rowEdges,h=this.getVisibleColumns(),d=this.getVisibleRows(),g=this.grid.behavior,f=0,p=0,v=this.getBounds().height,m=this.grid.isShowRowNumbers()?-1:0,C=h.length;if(this.buttonCells={},C)for(o=m;C>o;o++,f+=a){for(s=h[o],this.renderedColumnMinWidths[s]=0,e=g.getColumnProperties(s).renderCellError,t.save(),a=u[o-m]-f,t.beginPath(),t.rect(f,p,a,v),t.clip(),r=0;r=c,d=0>i,g=!h&&!d,f=n.isFilterRow(i),p=r.getHeaderColumnCount(),v=e>=p,m=n.isShowRowNumbers(),C=n.isHierarchyColumn(e),w=n.isRowSelected(i),y=n.isColumnSelected(e),b=n.isCellSelected(e,i),x=n.isCellSelectedInColumn(e),S=n.isCellSelectedInRow(i),E=n.areAllRowsSelected();m&&-1===e||C?(w?(a=Object.create(l.rowHeaderRowSelection),a.isSelected=!0):(a=Object.create(l.rowHeader),a.isSelected=S),a.isUserDataArea=!1):g||d?(f?(a=Object.create(l.filterProperties),a.isSelected=!1):y?(a=Object.create(l.columnHeaderColumnSelection),a.isSelected=!0):(a=Object.create(l.columnHeader),a.isSelected=x),a.isUserDataArea=!1):C?(a=Object.create(l.rowHeader),a.isSelected=S):(a=Object.create(l),a.isSelected=b||w||y,a.isUserDataArea=!0);var A=i-c+1;if(-1===e?(0===i?a.value=[s.checkbox(E),"",null]:f?a.value=[s.filter(!1),"",null]:g||d?a.value="":a.value=[s.checkbox(w),A,null],a.halign="right"):(a.value=n.getValue(e,i),a.halign=n.getColumnAlignment(e)),a.isGridColumn=v,a.isGridRow=h,a.isColumnHovered=n.isColumnHovered(e)&&v,a.isRowHovered=n.isRowHovered(i)&&h,a.isCellHovered=n.isHovered(e,i)&&v&&h,a.bounds=this._getBoundsOfCell(e,i),a.isCellSelected=b,a.isRowSelected=w,a.isColumnSelected=y,a.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i),n.mouseDownState){var R=n.mouseDownState.gridCell;a.mouseDown=R.x===e&&R.y===i}a.x=e,a.y=i,r.cellPropertiesPrePaintNotification(a);var D=r.getCellRenderer(a,e,i),T=r.getCellProperties(e,i);o(a).extendOwn(T),a.buttonCells=this.buttonCells;var P=a.isUserDataArea?a.format:"default";a.formatter=n.getFormatter(P),D.paint(t,a),this.renderedColumnMinWidths[e]=Math.max(a.minWidth||0,this.renderedColumnMinWidths[e]),u.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t,e=this;t=function(){e.animate(),requestAnimationFrame(t)},requestAnimationFrame(t)},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=l},{"../../images/index":3,"./Base":66,"object-iterators":21}],72:[function(t,e,i){"use strict";function n(t){this.grid=t,this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={constructor:n.prototype.constructor,allRowsSelected:!1,getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.grid.newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.grid.selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.grid.selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(t){t=t===!0,t||this.setAllRowsSelected(!1),this.selections.length&&--this.selections.length,this.flattenedX.length&&--this.flattenedX.length,this.flattenedY.length&&--this.flattenedY.length},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(t){t=t===!0,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.columnSelectionModel.clear(),t||(this.setAllRowsSelected(!1),this.rowSelectionModel.clear())},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.setAllRowsSelected(!0)},setAllRowsSelected:function(t){this.allRowsSelected=t},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.grid.getHeaderRowCount(),e=this.grid.getRowCount()-t,i=new Array(e),n=0;e>n;n++)i[n]=n+t;return i}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t,e){t=t||0,e=e===!0;var i=this.rowSelectionModel;e||(this.setAllRowsSelected(!1),i.clear()),this.selections.forEach(function(e){var n=e.origin.y,o=e.extent.y;n+=t,i.select(n,n+o)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;n+=t,e.select(n,n+o)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":24}],73:[function(t,e,i){"use strict";var n=t("./Base"),o=500,r=o+"ms ease-in",s=n.extend("TableDialog",{initialize:function(t){this.grid=t,this.initializeOverlaySurface(),this.openNow=!1},isOpen:function(){return this.openNow},open:function(){if(!this.isOpen()){this.openNow=!0;var t=this;this.overlay.style.backgroundColor=this.grid.resolveProperty("backgroundColor"),this.overlay.style.top=this.overlay.style.bottom=this.overlay.style.right=this.overlay.style.left=0,t.overlay.style.webkitTransition="",this.overlay.style.margin="15px 35px 35px 15px",this.overlay.style.opacity=0,this.overlay.style.zIndex=100,this.closeTransition=function(){this.overlay.style.opacity=0},this._closer||(this._closer=function(e){var i=t.getCharFor(e.keyCode).toLowerCase(),n=t.grid.resolveProperty("editorActivationKeys");(n.indexOf(i)>-1||27===e.keyCode)&&(e.preventDefault(),t.close())}),requestAnimationFrame(function(){t.overlay.style.webkitTransition="opacity "+o+"ms ease-in",requestAnimationFrame(function(){document.addEventListener("keydown",t._closer,!1),t.overlay.style.opacity=.95})}),setTimeout(function(){t.overlay.focus()},100)}},openFrom:function(t){if(!this.isOpen()){this.openNow=!0;var e=this,i=this.overlay.style;i.backgroundColor=this.grid.resolveProperty("backgroundColor");var n=this.grid.div.getBoundingClientRect(),o=t.y+"px "+(n.width-(t.x+t.width))+"px "+(n.height-(t.y+t.height))+"px "+t.x+"px";i.webkitTransition="",i.top=i.right=i.bottom=i.left=0,i.margin=o,i.zIndex=100,i.opacity=1,this.closeTransition=function(){i.margin=o},this._closer||(this._closer=function(t){var i=e.getCharFor(t.keyCode).toLowerCase(),n=e.grid.resolveProperty("editorActivationKeys");(n.indexOf(i)>-1||27===t.keyCode)&&(t.preventDefault(),e.close())}),requestAnimationFrame(function(){document.addEventListener("keydown",e._closer,!1),requestAnimationFrame(function(){requestAnimationFrame(function(){i.webkitTransition="margin-top "+r+", margin-right "+r+", margin-bottom "+r+", margin-left "+r,i.margin="15px 35px 35px 15px"})})}),setTimeout(function(){e.overlay.focus()},100)}},close:function(){this.openNow=!1,document.removeEventListener("keydown",this._closer,!1);var t=this;requestAnimationFrame(function(){t.closeTransition()}),setTimeout(function(){t.clear(),t.overlay.style.zIndex=-1e3,t.onClose&&(t.onClose(),t.onClose=void 0),t.grid.takeFocus()},o)},initializeOverlaySurface:function(){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.addEventListener("wheel",function(t){t.stopPropagation()});var t=this.overlay.style;t.outline="none",t.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",t.position="absolute",t.margin=0,t.overflow="hidden",t.opacity=0,t.zIndex=10,this.grid.div.appendChild(this.overlay)},getCharFor:function(t){var e=this.grid.getCanvas().getCharMap();return e[t][0]},clear:function(){this.overlay.innerHTML=""},querySelector:function(t){var e=this.overlay.querySelector(t); -return e},getAnimationTime:function(){return o}});e.exports=s},{"./Base":66}],74:[function(t,e,i){"use strict";console.warn||(console.warn=function(){console.log.apply(console,["WARNING:"].concat(Array.prototype.slice.call(arguments)))});var n=function(t,e){var i,n=t.split("."),o=n[n.length-1],r=e&&e.asOfVersion,s=this;return o="get"+o[0].toUpperCase()+o.substr(1),i="."+o+"() method is deprecated",r&&(i+=" as of v"+e.asOfVersion),i+=". Use ."+t,")"!==t[t.length-1]&&(i+=" property"),i+=" instead. (Will be removed in a future release.)",console.warn(i),n.forEach(function(t){s=s[t]}),s};e.exports=n},{}],75:[function(t,e,i){"use strict";function n(t,e,i,n,r,s){t.fillStyle="#FFD500",t.fill(),t.strokeStyle=t.createPattern(o.caution,"repeat"),t.lineWidth=5,t.beginPath(),t.moveTo(i,n),t.lineTo(i+r,n),t.lineTo(i+r,n+s),t.lineTo(i,n+s),t.lineTo(i,n),t.stroke(),t.beginPath(),t.rect(i,n,r-2,s),t.clip(),t.fillStyle="#A00",t.textAlign="start",t.textBaseline="middle",t.font='bold 6pt "arial narrow", verdana, geneva',t.fillText(e,i+4,n+s/2+.5)}var o=t("../../images/index");e.exports=n},{"../../images/index":3}],76:[function(t,e,i){"use strict";e.exports=function(){function t(t){this.label=t,this.data=[""],this.rowIndexes=[],this.hasChildren=!1,this.depth=0,this.height=1,this.expanded=!1}var e=" ";return t.prototype.isNullObject=!1,t.prototype.getValue=function(t){return this.data[t]},t.prototype.prune=function(t){this.depth=t,this.data[0]=this.computeDepthString()},t.prototype.computeDepthString=function(){var t=e.substring(0,2+3*this.depth)+this.label;return t},t.prototype.computeHeight=function(){return 1},t.prototype.getAllRowIndexes=function(){return this.rowIndexes},t.prototype.computeAggregates=function(t){this.applyAggregates(t)},t.prototype.applyAggregates=function(t){var e=t.hasGroups()?1:0,i=this.getAllRowIndexes();if(0!==i.length){var n=t.aggregates,o=this.data;o.length=n.length+e;var r=t.sorterInstance;r.indexes=i;for(var s=0;s0},t.prototype.hasAggregates=function(){return this.aggregates.length>0},t.prototype.apply=function(){this.buildGroupTree()},t.prototype.clearGroups=function(){this.groupBys.length=0},t.prototype.clearAggregations=function(){this.aggregates.length=0,this.headers.length=0},t.prototype.buildGroupTree=function(){var t,e,i,l,a,u=function(t,e){return l=new r(t),e.set(t,l),l},c=function(t,e){return l=new s(t),e.set(t,l),l},h=this.groupBys,d=this.dataSource,g=d.getRowCount();if(this.presortGroups)for(t=0;te;e++){for(t=0;ti;i++)e[i]=i;this.indexes=e},t.prototype.setData=function(t){this.dataSource.setData(t)},t}()},{}],82:[function(t,e,i){"use strict";var n=t("./DataSourceDecorator");e.exports=function(){function t(t){n.call(this,t,!1),this.filters=[]}return t.prototype=Object.create(n.prototype),t.prototype.add=function(t,e){e.columnIndex=t,this.filters.push(e)},t.prototype.set=function(t,e){e.columnIndex=t,this.filters.push(e)},t.prototype.clearAll=function(){this.filters.length=0,this.indexes.length=0},t.prototype.applyAll=function(){if(0===this.filters.length)return void(this.indexes.length=0);var t=this.indexes;t.length=0;for(var e=this.dataSource.getRowCount(),i=0;e>i;i++)this.applyFiltersTo(i)&&t.push(i)},t.prototype.applyFiltersTo=function(t){for(var e=this.filters,i=!0,n=0;no;o++)this.applyFilterTo(o)&&i.push(o)},t.prototype.applyFilterTo=function(t){for(var e=!1,i=this.filter,n=this.visibleColumnMap.length,o=this.dataSource.getRow(t),r=0;n>r;r++){var s=this.visibleColumnMap[r];if(e=e||i(this.dataSource.getValue(s,t),o,t))return!0}return!1},t}()},{"./DataSourceDecorator":81}],84:[function(t,e,i){"use strict";var n=t("./Utils.js"),o=t("./DataSourceDecorator"),r=function(t){var e="f"===(typeof t)[0],i=e?t():t;return i};e.exports=function(){function t(t){o.call(this,t),this.descendingSort=!1}return t.prototype=Object.create(o.prototype),t.prototype.sortOn=function(t,e){if(0===e)return void(this.indexes.length=0);this.initializeIndexVector();var i=this;n.stableSort(this.indexes,function(e){var n=i.dataSource.getValue(t,e);return n=r(n)},e)},t}()},{"./DataSourceDecorator":81,"./Utils.js":88}],85:[function(t,e,i){"use strict";var n=t("./DataSourceDecorator"),o=t("./DataSourceSorter");e.exports=function(){function t(t){n.call(this,t),this.sorts=[],this.last=this.dataSource}return t.prototype=Object.create(n.prototype),t.prototype.getRow=function(t){return this.last.getRow(t)},t.prototype.sortOn=function(t,e){this.sorts.push([t,e])},t.prototype.applySorts=function(){for(var t=this.sorts,e=this.dataSource,i=0;io;o++)i+=e.getValue(t,o);return i}},min:function(t){return function(e){for(var i=1/0,n=e.getRowCount(),o=0;n>o;o++)i=Math.min(i,e.getValue(t,o));return i}},max:function(t){return function(e){for(var i=-(1/0),n=e.getRowCount(),o=0;n>o;o++)i=Math.max(i,e.getValue(t,o));return i}},avg:function(t){return function(e){for(var i=0,n=e.getRowCount(),o=0;n>o;o++)i+=e.getValue(t,o);return i/n}},first:function(t){return function(e){return e.getValue(t,0)}},last:function(t){return function(e){var i=e.getRowCount();return e.getValue(t,i-1)}},stddev:function(t){return function(e){var i,n=0,o=e.getRowCount();for(i=0;o>i;i++)n+=e.getValue(t,i);var r=n/o,s=0;for(i=0;o>i;i++){var l=e.getValue(t,i)-r;s+=l*l}var a=Math.sqrt(s/o);return a}}}}()},{}],90:[function(t,e,i){"use strict";var n=t("./JSDataSource"),o=t("./DataSourceSorter"),r=t("./DataSourceSorterComposite"),s=t("./DataSourceFilter"),l=t("./DataSourceGlobalFilter"),a=t("./DataSourceAggregator"),u=t("./aggregations");e.exports=function(){return{JSDataSource:n,DataSourceSorter:o,DataSourceSorterComposite:r,DataSourceFilter:s,DataSourceGlobalFilter:l,DataSourceAggregator:a,aggregations:u}}()},{"./DataSourceAggregator":80,"./DataSourceFilter":82,"./DataSourceGlobalFilter":83,"./DataSourceSorter":84,"./DataSourceSorterComposite":85,"./JSDataSource":86,"./aggregations":89}],91:[function(t,e,i){"use strict";var n=function(t,e){return function(i,n){var o=i[0],r=n[0];if(o===r)o=e?n[1]:i[1],r=e?i[1]:n[1];else{if(null===r)return-1;if(null===o)return 1}return t(o,r)}},o=function(t,e){return t-e},r=function(t,e){return e-t},s=function(t,e){return e>t?-1:1},l=function(t,e){return t>e?-1:1},a=function(t){return"number"===t?n(o,!1):n(s,!1)},u=function(t){return"number"===t?n(r,!0):n(l,!0)};e.exports=function(){function t(t,e,i){var n,o;if(0!==t.length&&(void 0===i&&(i=1),0!==i)){var r=typeof e(0);n=1===i?a(r):u(r);var s=new Array(t.length);for(o=0;o.thumb,div.finbar-vertical>.thumb{position:absolute;background-color:#d3d3d3;-webkit-box-shadow:0 0 1px #000;-moz-box-shadow:0 0 1px #000;box-shadow:0 0 1px #000;border-radius:4px;margin:2px;opacity:.4;transition:opacity .5s}div.finbar-horizontal>.thumb.hover,div.finbar-vertical>.thumb.hover{opacity:1;transition:opacity .5s}div.finbar-vertical{top:0;bottom:0;right:0;width:11px}div.finbar-vertical>.thumb{top:0;right:0;width:7px}div.finbar-horizontal{left:0;right:0;bottom:0;height:11px}div.finbar-horizontal>.thumb{left:0;bottom:0;height:7px}",e.exports=n},{"css-injector":4}],14:[function(t,e,i){"use strict";function n(t,e,i){var n=this;this.div=t,this.component=e,i=i||{},this.doubleClickDelay=i.doubleClickDelay||325,this.dragEndtime=Date.now(),this.canvas=document.createElement("canvas"),this.div.appendChild(this.canvas),this.canvas.style.outline="none",this.canvasCTX=this.canvas.getContext("2d"),this.gc=new u(this.canvasCTX),this.buffer=document.createElement("canvas"),this.bufferCTX=this.buffer.getContext("2d"),this.bufferGC=new u(this.bufferCTX),this.mouseLocation=new l.Point(-1,-1),this.dragstart=new l.Point(-1,-1),this.bounds=new l.Rectangle(0,0,0,0),this.hasMouse=!1,document.addEventListener("mousemove",function(t){(n.hasMouse||n.isDragging())&&n.finmousemove(t)}),document.addEventListener("mouseup",function(t){n.finmouseup(t)}),document.addEventListener("wheel",function(t){n.finwheelmoved(t)}),document.addEventListener("keydown",function(t){n.finkeydown(t)}),document.addEventListener("keyup",function(t){n.finkeyup(t)}),this.canvas.onmouseover=function(){n.hasMouse=!0},this.canvas.addEventListener("focus",function(t){n.finfocusgained(t)}),this.canvas.addEventListener("blur",function(t){n.finfocuslost(t)}),this.canvas.addEventListener("mousedown",function(t){n.finmousedown(t)}),this.canvas.addEventListener("mouseout",function(t){n.hasMouse=!1,n.finmouseout(t)}),this.canvas.addEventListener("click",function(t){n.finclick(t)}),this.canvas.addEventListener("contextmenu",function(t){return n.fincontextmenu(t),t.preventDefault(),!1}),a.addEventListener(this.canvas,"tap",function(t){n.fintap(t)}),a.addEventListener(this.canvas,"holdpulse",function(t){n.finholdpulse(t)}),a.addEventListener(this.canvas,"flick",function(t){n.finflick(t)}),a.addEventListener(this.canvas,"release",function(t){n.finrelease(t)}),a.addEventListener(this.canvas,"trackstart",function(t){n.fintrackstart(t)}),a.addEventListener(this.canvas,"track",function(t){n.fintrack(t)}),a.addEventListener(this.canvas,"trackend",function(t){n.fintrackend(t)}),this.canvas.setAttribute("tabindex",0),this.canvas.contentEditable=!0,this.resize(),this.beginResizing(),this.beginPainting()}function o(t){if(g){for(var e=0;ei;i++)t[i]=e;return t[27]=["ESC","ESCSHIFT"],t[192]=["`","~"],t[49]=["1","!"],t[50]=["2","@"],t[51]=["3","#"],t[52]=["4","$"],t[53]=["5","%"],t[54]=["6","^"],t[55]=["7","&"],t[56]=["8","*"],t[57]=["9","("],t[48]=["0",")"],t[189]=["-","_"],t[187]=["=","+"],t[8]=["BACKSPACE","BACKSPACESHIFT"],t[46]=["DELETE","DELETESHIFT"],t[9]=["TAB","TABSHIFT"],t[81]=["q","Q"],t[87]=["w","W"],t[69]=["e","E"],t[82]=["r","R"],t[84]=["t","T"],t[89]=["y","Y"],t[85]=["u","U"],t[73]=["i","I"],t[79]=["o","O"],t[80]=["p","P"],t[219]=["[","{"],t[221]=["]","}"],t[220]=["\\","|"],t[220]=["CAPSLOCK","CAPSLOCKSHIFT"],t[65]=["a","A"],t[83]=["s","S"],t[68]=["d","D"],t[70]=["f","F"],t[71]=["g","G"],t[72]=["h","H"],t[74]=["j","J"],t[75]=["k","K"],t[76]=["l","L"],t[186]=[";",":"],t[222]=["'","|"],t[13]=["RETURN","RETURNSHIFT"],t[16]=["SHIFT","SHIFT"],t[90]=["z","Z"],t[88]=["x","X"],t[67]=["c","C"],t[86]=["v","V"],t[66]=["b","B"],t[78]=["n","N"],t[77]=["m","M"],t[188]=[",","<"],t[190]=[".",">"],t[191]=["/","?"],t[16]=["SHIFT","SHIFT"],t[17]=["CTRL","CTRLSHIFT"],t[18]=["ALT","ALTSHIFT"],t[91]=["COMMANDLEFT","COMMANDLEFTSHIFT"],t[32]=["SPACE","SPACESHIFT"],t[93]=["COMMANDRIGHT","COMMANDRIGHTSHIFT"],t[18]=["ALT","ALTSHIFT"],t[38]=["UP","UPSHIFT"],t[37]=["LEFT","LEFTSHIFT"],t[40]=["DOWN","DOWNSHIFT"],t[39]=["RIGHT","RIGHTSHIFT"],t[33]=["PAGEUP","PAGEUPSHIFT"],t[34]=["PAGEDOWN","PAGEDOWNSHIFT"],t[35]=["PAGERIGHT","PAGERIGHTSHIFT"],t[36]=["PAGELEFT","PAGELEFTSHIFT"],t[112]=["F1","F1SHIFT"],t[113]=["F2","F2SHIFT"],t[114]=["F3","F3SHIFT"],t[115]=["F4","F4SHIFT"],t[116]=["F5","F5SHIFT"],t[117]=["F6","F6SHIFT"],t[118]=["F7","F7SHIFT"],t[119]=["F8","F8SHIFT"],t[120]=["F9","F9SHIFT"],t[121]=["F10","F10SHIFT"],t[122]=["F11","F1S1HIFT"],t[123]=["F12","F121HIFT"],t}var l=t("rectangular"),a=t("./js/polymergestures.dev.js"),u=t("./js/GraphicsContext.js"),c=200,h=[],d=[],g=!0,f=!0,p=s();n.prototype={constructor:n.prototype.constructor,div:null,component:null,gestures:a,canvas:null,canvasCTX:null,focuser:null,buffer:null,ctx:null,mouseLocation:null,holdPulseCount:-1,dragstart:null,origin:null,bounds:null,dirty:!1,size:null,mousedown:!1,dragging:!1,repeatKeyCount:0,repeatKey:null,repeatKeyStartTime:0,currentKeys:[],hasMouse:!1,lastDoubleClickTime:0,dragEndTime:0,lastRepaintTime:0,addEventListener:function(t,e){this.canvas.addEventListener(t,e)},stopPaintLoop:function(){g=!1},restartPaintLoop:function(){g||(g=!0,requestAnimationFrame(o))},stopResizeLoop:function(){f=!1},restartResizeLoop:function(){f||(f=!0,setInterval(r,200))},detached:function(){this.stopPainting(),this.stopResizing()},useHiDPI:function(){return this.component.resolveProperty("useHiDPI")},useBitBlit:function(){return this.component.resolveProperty("useBitBlit")},getFPS:function(){var t=this.component.resolveProperty("repaintIntervalRate");return t?parseInt(t):0},tickPaint:function(t){var e=this.getFPS();if(0!==e){var i=1e3/e,n=t-this.lastRepaintTime;n>i&&this.dirty&&(this.lastRepaintTime=t-n%i,this.paintNow())}},beginPainting:function(){var t=this;this.dirty=!0,this.tickPainter=function(e){t.tickPaint(e)},h.push(this)},stopPainting:function(){h.splice(h.indexOf(this),1)},beginResizing:function(){var t=this;this.tickResizer=function(){t.checksize()},d.push(this)},stopResizing:function(){d.splice(d.indexOf(this),1)},start:function(){this.beginPainting(),this.beginResizing()},stop:function(){this.stopPainting(),this.stopResizing()},checksize:function(){var t=this.div.getBoundingClientRect();(t.width!==this.size.width||t.height!==this.size.height)&&this.sizeChangedNotification()},sizeChangedNotification:function(){this.resize()},resize:function(){var t=this.size=this.div.getBoundingClientRect();this.canvas.width=this.buffer.width=t.width,this.canvas.height=this.buffer.height=t.height;var e=1,i=this.useBitBlit(),n=window.devicePixelRatio&&this.useHiDPI();if(n){var o=window.devicePixelRatio||1,r=this.canvasCTX.webkitBackingStorePixelRatio||this.canvasCTX.mozBackingStorePixelRatio||this.canvasCTX.msBackingStorePixelRatio||this.canvasCTX.oBackingStorePixelRatio||this.canvasCTX.backingStorePixelRatio||1;e=o/r}var s=this.canvas.getAttribute("width"),a=this.canvas.getAttribute("height");this.canvas.width=this.buffer.width=s*e,this.canvas.height=this.buffer.height=a*e,this.canvas.style.width=this.buffer.style.width=s+"px",this.canvas.style.height=this.buffer.style.height=a+"px",this.bufferCTX.scale(e,e),n&&!i&&this.canvasCTX.scale(e,e),this.bounds=new l.Rectangle(0,0,t.width,t.height);var u=this.component;u&&u.setBounds(this.bounds),this.resizeNotification(),this.paintNow()},resizeNotification:function(){},getBounds:function(){return this.bounds},paintNow:function(){var t=this;this.safePaintImmediately(function(e){e.clearRect(0,0,t.canvas.width,t.canvas.height);var i=t.component;i&&i.paint(e),t.dirty=!1})},safePaintImmediately:function(t){var e=this.useBitBlit(),i=e?this.bufferGC:this.gc;try{i.save(),t(i)}catch(n){console.error(n)}finally{i.restore()}e&&this.flushBuffer()},flushBuffer:function(){this.buffer.width>0&&this.buffer.height>0&&this.canvasCTX.drawImage(this.buffer,0,0)},dispatchNewEvent:function(t,e,i){return i={detail:i||{}},i.detail.primitiveEvent=t,this.canvas.dispatchEvent(new CustomEvent(e,i))},dispatchNewMouseKeysEvent:function(t,e,i){return i=i||{},i.mouse=this.mouseLocation,i.keys=this.currentKeys,this.dispatchNewEvent(t,e,i)},finmousemove:function(t){!this.isDragging()&&this.mousedown&&(this.beDragging(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragstart",{isRightClick:this.isRightClick(t)}),this.dragstart=new l.Point(this.mouseLocation.x,this.mouseLocation.y)),this.mouseLocation=this.getLocal(t),this.isDragging()&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-drag",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.bounds.contains(this.mouseLocation)&&this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousemove")},finmousedown:function(t){this.mouseLocation=this.mouseDownLocation=this.getLocal(t),this.mousedown=!0,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mousedown",{isRightClick:this.isRightClick(t)}),this.takeFocus()},finmouseup:function(t){this.isDragging()&&(this.dispatchNewMouseKeysEvent(t,"fin-canvas-dragend",{dragstart:this.dragstart,isRightClick:this.isRightClick(t)}),this.beNotDragging(),this.dragEndtime=Date.now()),this.mousedown=!1,this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseup",{isRightClick:this.isRightClick(t)})},finmouseout:function(t){this.mousedown||(this.mouseLocation=new l.Point(-1,-1)),this.dispatchNewMouseKeysEvent(t,"fin-canvas-mouseout")},finwheelmoved:function(t){!this.isDragging()&&this.hasFocus()&&(t.preventDefault(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-wheelmoved",{isRightClick:this.isRightClick(t)}))},finclick:function(t){this.doubleClickTimer&&Date.now()-this.lastClickTimen||i-this.dragEndtime<100||setTimeout(function(){e._fintap(t)},180)},_fintap:function(t){var e=Date.now(),i=e-this.lastDoubleClickTime;300>i||(this.mouseDownLocation&&(this.mouseLocation=this.mouseDownLocation,this.mouseDownLocation=void 0),this.dispatchNewMouseKeysEvent(t,"fin-canvas-tap",{isRightClick:this.isRightClick(t)}))},findblclick:function(t){this.mouseLocation=this.getLocal(t),this.lastDoubleClickTime=Date.now(),this.dispatchNewMouseKeysEvent(t,"fin-canvas-dblclick",{isRightClick:this.isRightClick(t)})},getCharMap:function(){return p},finkeydown:function(t){if(this.hasFocus()){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];t.repeat?this.repeatKey===e?this.repeatKeyCount++:(this.repeatKey=e,this.repeatKeyStartTime=Date.now()):(this.repeatKey=null,this.repeatKeyCount=0,this.repeatKeyStartTime=0),-1===this.currentKeys.indexOf(e)&&this.currentKeys.push(e),this.dispatchNewEvent(t,"fin-canvas-keydown",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeatCount:this.repeatKeyCount,repeatStartTime:this.repeatKeyStartTime,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)})}},finkeyup:function(t){var e=t.shiftKey?p[t.keyCode][1]:p[t.keyCode][0];this.currentKeys.splice(this.currentKeys.indexOf(e),1),this.hasFocus()&&(this.repeatKeyCount=0,this.repeatKey=null,this.repeatKeyStartTime=0,this.dispatchNewEvent(t,"fin-canvas-keyup",{alt:t.altKey,ctrl:t.ctrlKey,"char":e,code:t.charCode,key:t.keyCode,meta:t.metaKey,repeat:t.repeat,shift:t.shiftKey,identifier:t.keyIdentifier,currentKeys:this.currentKeys.slice(0)}))},finfocusgained:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-gained")},finfocuslost:function(t){this.dispatchNewEvent(t,"fin-canvas-focus-lost")},fincontextmenu:function(t){t.ctrlKey&&-1===this.currentKeys.indexOf("CTRL")&&this.currentKeys.push("CTRL"),this.doubleRightClickTimer&&Date.now()-this.lastClickTime=0?t=this.walk(t,o):e=this.walk(e,-o);t&&e&&t!==e;)t=t.parentNode||t.host,e=e.parentNode||e.host;return t},walk:function(t,e){for(var i=0;t&&e>i;i++)t=t.parentNode||t.host;return t},depth:function(t){for(var e=0;t;)e++,t=t.parentNode||t.host;return e},deepContains:function(t,e){var i=this.LCA(t,e);return i===t},insideNode:function(t,e,i){var n=t.getBoundingClientRect();return n.left<=e&&e<=n.right&&n.top<=i&&i<=n.bottom},path:function(t){var i;if(e&&t.path&&t.path.length)i=t.path;else{i=[];for(var n=this.findTarget(t);n;)i.push(n),n=n.parentNode||n.host}return i}};t.targetFinding=s,t.findTarget=s.findTarget.bind(s),t.deepContains=s.deepContains.bind(s),t.insideNode=s.insideNode}(i),function(){function t(t){return"html /deep/ "+e(t)}function e(t){return'[touch-action="'+t+'"]'}function i(t){return"{ -ms-touch-action: "+t+"; touch-action: "+t+";}"}var n=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]},"manipulation"],o="",r="string"==typeof document.head.style.touchAction,s=!window.ShadowDOMPolyfill&&document.head.createShadowRoot;if(r){n.forEach(function(n){String(n)===n?(o+=e(n)+i(n)+"\n",s&&(o+=t(n)+i(n)+"\n")):(o+=n.selectors.map(e)+i(n.rule)+"\n",s&&(o+=n.selectors.map(t)+i(n.rule)+"\n"))});var l=document.createElement("style");l.textContent=o,document.head.appendChild(l)}}(),function(t){var e=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],i=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0],n=function(){return function(){}},o={preventTap:n,makeBaseEvent:function(t,e){var i=document.createEvent("Event");return i.initEvent(t,e.bubbles||!1,e.cancelable||!1),i.preventTap=o.preventTap(i),i},makeGestureEvent:function(t,e){e=e||Object.create(null);for(var i,n=this.makeBaseEvent(t,e),o=0,r=Object.keys(e);o-1?this.values[i]=e:(this.keys.push(t),this.values.push(e))},has:function(t){return this.keys.indexOf(t)>-1},"delete":function(t){var e=this.keys.indexOf(t);e>-1&&(this.keys.splice(e,1),this.values.splice(e,1))},get:function(t){var e=this.keys.indexOf(t);return this.values[e]},clear:function(){this.keys.length=0,this.values.length=0},forEach:function(t,e){this.values.forEach(function(i,n){t.call(e,i,this.keys[n],this)},this)},pointers:function(){return this.keys.length}},t.PointerMap=e}(i),function(t){var e,i=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp","preventTap","tapPrevented","_source"],n=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0,function(){},!1],o="undefined"!=typeof SVGElementInstance,r=t.eventFactory,s={IS_IOS:!1,pointermap:new t.PointerMap,requiredGestures:new t.PointerMap,eventMap:Object.create(null),eventSources:Object.create(null),eventSourceList:[],gestures:[],dependencyMap:{down:{listeners:0,index:-1},up:{listeners:0,index:-1}},gestureQueue:[],registerSource:function(t,e){var i=e,n=i.events;n&&(n.forEach(function(t){i[t]&&(this.eventMap[t]=i[t].bind(i))},this),this.eventSources[t]=i,this.eventSourceList.push(i))},registerGesture:function(t,e){var i=Object.create(null);i.listeners=0,i.index=this.gestures.length;for(var n,o=0;oo&&(i=this.eventSourceList[o]);o++)i.register.call(i,t,e)},unregister:function(t){for(var e,i=this.eventSourceList.length,n=0;i>n&&(e=this.eventSourceList[n]);n++)e.unregister.call(e,t)},down:function(t){this.requiredGestures.set(t.pointerId,e),this.fireEvent("down",t)},move:function(t){t.type="move",this.fillGestureQueue(t)},up:function(t){this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},cancel:function(t){t.tapPrevented=!0,this.fireEvent("up",t),this.requiredGestures["delete"](t.pointerId)},addGestureDependency:function(t,e){var i=t._pgEvents;if(i&&e)for(var n,o,r,s=Object.keys(i),l=0;l0&&(n=this.dependencyMap[r],o=n?n.index:-1,e[o]=!0)},eventHandler:function(i){var n=i.type;if("touchstart"===n||"mousedown"===n||"pointerdown"===n||"MSPointerDown"===n)if(i._handledByPG||(e={}),this.IS_IOS){var o=i;if("touchstart"===n){var r=i.changedTouches[0];o={target:i.target,clientX:r.clientX,clientY:r.clientY,path:i.path}}for(var s,l=i.path||t.targetFinding.path(o),a=0;an&&(i=e[n]);n++)this.addEvent(t,i)},unlisten:function(t,e){for(var i,n=0,o=e.length;o>n&&(i=e[n]);n++)this.removeEvent(t,i)},addEvent:function(t,e){t.addEventListener(e,this.boundHandler)},removeEvent:function(t,e){t.removeEventListener(e,this.boundHandler)},makeEvent:function(t,e){var i=r.makePointerEvent(t,e);return i.preventDefault=e.preventDefault,i.tapPrevented=e.tapPrevented,i._target=i._target||e.target,i},fireEvent:function(t,e){var i=this.makeEvent(t,e);return this.dispatchEvent(i)},cloneEvent:function(t){for(var e,r=Object.create(null),s=0;s0&&t._pgListeners--,0===t._pgListeners&&s.unregister(t),t._pgEvents&&(t._pgEvents[i]>0?t._pgEvents[i]--:t._pgEvents[i]=0)),Boolean(n)},t.removeEventListener=function(e,i,n,o){n&&(t.deactivateGesture(e,i),e.removeEventListener(i,n,o))}}(i),function(t){var e=t.dispatcher,i=e.pointermap,n=25,o=[0,1,4,2],r=0,s=/Linux.*Firefox\//i,l=function(){if(s.test(navigator.userAgent))return!1;try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}(),a={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup"],exposes:["down","up","move"],register:function(t){e.listen(t,this.events)},unregister:function(t){t.nodeType!==Node.DOCUMENT_NODE&&e.unlisten(t,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(t){for(var e,i=this.lastTouches,o=t.clientX,r=t.clientY,s=0,l=i.length;l>s&&(e=i[s]);s++){var a=Math.abs(o-e.x),u=Math.abs(r-e.y);if(n>=a&&n>=u)return!0}},prepareEvent:function(t){var i=e.cloneEvent(t);if(i.pointerId=this.POINTER_ID,i.isPrimary=!0,i.pointerType=this.POINTER_TYPE,i._source="mouse",!l){var n=t.type,s=o[t.which]||0;"mousedown"===n?r|=s:"mouseup"===n&&(r&=~s),i.buttons=r}return i},mousedown:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=(i.has(this.POINTER_ID),this.prepareEvent(n));o.target=t.findTarget(n),i.set(this.POINTER_ID,o.target),e.down(o)}},mousemove:function(t){if(!this.isEventSimulatedFromTouch(t)){var n=i.get(this.POINTER_ID);if(n){var o=this.prepareEvent(t);o.target=n,0===(l?o.buttons:o.which)?(l||(r=o.buttons=0),e.cancel(o),this.cleanupMouse(o.buttons)):e.move(o)}}},mouseup:function(n){if(!this.isEventSimulatedFromTouch(n)){var o=this.prepareEvent(n);o.relatedTarget=t.findTarget(n),o.target=i.get(this.POINTER_ID),e.up(o),this.cleanupMouse(o.buttons)}},cleanupMouse:function(t){0===t&&i["delete"](this.POINTER_ID)}};t.mouseEvents=a}(i),function(t){var e=t.dispatcher,i=(t.targetFinding.allShadows.bind(t.targetFinding),e.pointermap),n=(Array.prototype.map.call.bind(Array.prototype.map),2500),o=25,r=200,s=20,l=!1,a={IS_IOS:!1,events:["touchstart","touchmove","touchend","touchcancel"],exposes:["down","up","move"],register:function(t,i){(this.IS_IOS?i:!i)&&e.listen(t,this.events)},unregister:function(t){this.IS_IOS||e.unlisten(t,this.events)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y"},touchActionToScrollType:function(t){var e=t,i=this.scrollTypes;return e===i.EMITTER?"none":e===i.XSCROLLER?"X":e===i.YSCROLLER?"Y":"XY"},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(t){return this.firstTouch===t.identifier},setPrimaryTouch:function(t){(0===i.pointers()||1===i.pointers()&&i.has(1))&&(this.firstTouch=t.identifier,this.firstXY={X:t.clientX,Y:t.clientY},this.firstTarget=t.target,this.scrolling=null,this.cancelResetClickCount())},removePrimaryPointer:function(t){t.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var t=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(t,r)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(t){var e=0;return("touchstart"===t||"touchmove"===t)&&(e=1),e},findTarget:function(e,n){if("touchstart"===this.currentTouchEvent.type){if(this.isPrimaryTouch(e)){var o={clientX:e.clientX,clientY:e.clientY,path:this.currentTouchEvent.path,target:this.currentTouchEvent.target};return t.findTarget(o)}return t.findTarget(e)}return i.get(n)},touchToPointer:function(t){var i=this.currentTouchEvent,n=e.cloneEvent(t),o=n.pointerId=t.identifier+2;n.target=this.findTarget(t,o),n.bubbles=!0,n.cancelable=!0,n.detail=this.clickCount,n.buttons=this.typeToButtons(i.type),n.width=t.webkitRadiusX||t.radiusX||0,n.height=t.webkitRadiusY||t.radiusY||0,n.pressure=t.webkitForce||t.force||.5,n.isPrimary=this.isPrimaryTouch(t),n.pointerType=this.POINTER_TYPE,n._source="touch";var r=this;return n.preventDefault=function(){r.scrolling=!1,r.firstXY=null,i.preventDefault()},n},processTouches:function(t,e){var n=t.changedTouches;this.currentTouchEvent=t;for(var o,r,s=0;s=u}return i}},findTouch:function(t,e){for(var i,n=0,o=t.length;o>n&&(i=t[n]);n++)if(i.identifier===e)return!0},vacuumTouches:function(t){var e=t.touches;if(i.pointers()>=e.length){var n=[];i.forEach(function(t,i){if(1!==i&&!this.findTouch(e,i-2)){var o=t;n.push(o)}},this),n.forEach(function(t){this.cancel(t),i["delete"](t.pointerId)},this)}},touchstart:function(t){this.vacuumTouches(t),this.setPrimaryTouch(t.changedTouches[0]),this.dedupSynthMouse(t),this.scrolling||(this.clickCount++,this.processTouches(t,this.down))},down:function(t){e.down(t)},touchmove:function(t){if(l)t.cancelable&&this.processTouches(t,this.move);else if(this.scrolling){if(this.firstXY){var e=t.changedTouches[0],i=e.clientX-this.firstXY.X,n=e.clientY-this.firstXY.Y,o=Math.sqrt(i*i+n*n);o>=s&&(this.touchcancel(t),this.scrolling=!0,this.firstXY=null)}}else null===this.scrolling&&this.shouldScroll(t)?this.scrolling=!0:(this.scrolling=!1,t.preventDefault(),this.processTouches(t,this.move))},move:function(t){e.move(t)},touchend:function(t){this.dedupSynthMouse(t),this.processTouches(t,this.up)},up:function(i){i.relatedTarget=t.findTarget(i),e.up(i)},cancel:function(t){e.cancel(t)},touchcancel:function(t){t._cancel=!0,this.processTouches(t,this.cancel)},cleanUpPointer:function(t){i["delete"](t.pointerId),this.removePrimaryPointer(t)},dedupSynthMouse:function(e){var i=t.mouseEvents.lastTouches,o=e.changedTouches[0];if(this.isPrimaryTouch(o)){var r={x:o.clientX,y:o.clientY};i.push(r);var s=function(t,e){var i=t.indexOf(e);i>-1&&t.splice(i,1); +}.bind(null,i,r);setTimeout(s,n)}}},u=Event.prototype.stopImmediatePropagation||Event.prototype.stopPropagation;document.addEventListener("click",function(e){var i=e.clientX,n=e.clientY,r=function(t){var e=Math.abs(i-t.x),r=Math.abs(n-t.y);return o>=e&&o>=r},s=t.mouseEvents.lastTouches.some(r),l=t.targetFinding.path(e);if(s){for(var c=0;c0?1:-1},calcPositionDelta:function(t,e){var i=0,n=0;return t&&e&&(i=e.pageX-t.pageX,n=e.pageY-t.pageY),{x:i,y:n}},fireTrack:function(t,e,n){var o=n,r=this.calcPositionDelta(o.downEvent,e),s=this.calcPositionDelta(o.lastMoveEvent,e);if(s.x)o.xDirection=this.clampDir(s.x);else if("trackx"===t)return;if(s.y)o.yDirection=this.clampDir(s.y);else if("tracky"===t)return;var l={bubbles:!0,cancelable:!0,trackInfo:o.trackInfo,relatedTarget:e.relatedTarget,pointerType:e.pointerType,pointerId:e.pointerId,_source:"track"};"tracky"!==t&&(l.x=e.x,l.dx=r.x,l.ddx=s.x,l.clientX=e.clientX,l.pageX=e.pageX,l.screenX=e.screenX,l.xDirection=o.xDirection),"trackx"!==t&&(l.dy=r.y,l.ddy=s.y,l.y=e.y,l.clientY=e.clientY,l.pageY=e.pageY,l.screenY=e.screenY,l.yDirection=o.yDirection);var a=i.makeGestureEvent(t,l);o.downTarget.dispatchEvent(a)},down:function(t){if(t.isPrimary&&("mouse"===t.pointerType?1===t.buttons:!0)){var e={downEvent:t,downTarget:t.target,trackInfo:{},lastMoveEvent:null,xDirection:0,yDirection:0,tracking:!1};n.set(t.pointerId,e)}},move:function(t){var e=n.get(t.pointerId);if(e){if(!e.tracking){var i=this.calcPositionDelta(e.downEvent,t),o=i.x*i.x+i.y*i.y;o>this.WIGGLE_THRESHOLD&&(e.tracking=!0,e.lastMoveEvent=e.downEvent,this.fireTrack("trackstart",t,e))}e.tracking&&(this.fireTrack("track",t,e),this.fireTrack("trackx",t,e),this.fireTrack("tracky",t,e)),e.lastMoveEvent=t}},up:function(t){var e=n.get(t.pointerId);e&&(e.tracking&&this.fireTrack("trackend",t,e),n["delete"](t.pointerId))}};e.registerGesture("track",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n={HOLD_DELAY:200,WIGGLE_THRESHOLD:16,events:["down","move","up"],exposes:["hold","holdpulse","release"],heldPointer:null,holdJob:null,pulse:function(){var t=Date.now()-this.heldPointer.timeStamp,e=this.held?"holdpulse":"hold";this.fireHold(e,t),this.held=!0},cancel:function(){clearInterval(this.holdJob),this.held&&this.fireHold("release"),this.held=!1,this.heldPointer=null,this.target=null,this.holdJob=null},down:function(t){t.isPrimary&&!this.heldPointer&&(this.heldPointer=t,this.target=t.target,this.holdJob=setInterval(this.pulse.bind(this),this.HOLD_DELAY))},up:function(t){this.heldPointer&&this.heldPointer.pointerId===t.pointerId&&this.cancel()},move:function(t){if(this.heldPointer&&this.heldPointer.pointerId===t.pointerId){var e=t.clientX-this.heldPointer.clientX,i=t.clientY-this.heldPointer.clientY;e*e+i*i>this.WIGGLE_THRESHOLD&&this.cancel()}},fireHold:function(t,e){var n={bubbles:!0,cancelable:!0,pointerType:this.heldPointer.pointerType,pointerId:this.heldPointer.pointerId,x:this.heldPointer.clientX,y:this.heldPointer.clientY,_source:"hold"};e&&(n.holdTime=e);var o=i.makeGestureEvent(t,n);this.target.dispatchEvent(o)}};e.registerGesture("hold",n)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o={events:["down","up"],exposes:["tap"],down:function(t){t.isPrimary&&!t.tapPrevented&&n.set(t.pointerId,{target:t.target,buttons:t.buttons,x:t.clientX,y:t.clientY})},shouldTap:function(t,e){var i=!0;return"mouse"===t.pointerType&&(i=1^t.buttons&&1&e.buttons),i&&!t.tapPrevented},up:function(e){var o=n.get(e.pointerId);if(o&&this.shouldTap(e,o)){var r=t.targetFinding.LCA(o.target,e.relatedTarget);if(r){var s=i.makeGestureEvent("tap",{bubbles:!0,cancelable:!0,x:e.clientX,y:e.clientY,detail:e.detail,pointerType:e.pointerType,pointerId:e.pointerId,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,_source:"tap"});r.dispatchEvent(s)}}n["delete"](e.pointerId)}};i.preventTap=function(t){return function(){t.tapPrevented=!0,n["delete"](t.pointerId)}},e.registerGesture("tap",o)}(i),function(t){var e=t.dispatcher,i=t.eventFactory,n=new t.PointerMap,o=180/Math.PI,r={events:["down","up","move","cancel"],exposes:["pinchstart","pinch","pinchend","rotate"],defaultActions:{pinch:"none",rotate:"none"},reference:{},down:function(e){if(n.set(e.pointerId,e),2==n.pointers()){var i=this.calcChord(),o=this.calcAngle(i);this.reference={angle:o,diameter:i.diameter,target:t.targetFinding.LCA(i.a.target,i.b.target)},this.firePinch("pinchstart",i.diameter,i)}},up:function(t){var e=n.get(t.pointerId),i=n.pointers();if(e){if(2===i){var o=this.calcChord();this.firePinch("pinchend",o.diameter,o)}n["delete"](t.pointerId)}},move:function(t){n.has(t.pointerId)&&(n.set(t.pointerId,t),n.pointers()>1&&this.calcPinchRotate())},cancel:function(t){this.up(t)},firePinch:function(t,e,n){var o=e/this.reference.diameter,r=i.makeGestureEvent(t,{bubbles:!0,cancelable:!0,scale:o,centerX:n.center.x,centerY:n.center.y,_source:"pinch"});this.reference.target.dispatchEvent(r)},fireRotate:function(t,e){var n=Math.round((t-this.reference.angle)%360),o=i.makeGestureEvent("rotate",{bubbles:!0,cancelable:!0,angle:n,centerX:e.center.x,centerY:e.center.y,_source:"pinch"});this.reference.target.dispatchEvent(o)},calcPinchRotate:function(){var t=this.calcChord(),e=t.diameter,i=this.calcAngle(t);e!=this.reference.diameter&&this.firePinch("pinch",e,t),i!=this.reference.angle&&this.fireRotate(i,t)},calcChord:function(){var t=[];n.forEach(function(e){t.push(e)});for(var e,i,o,r=0,s={a:t[0],b:t[1]},l=0;lr&&(r=o,s={a:a,b:c})}return e=Math.abs(s.a.clientX+s.b.clientX)/2,i=Math.abs(s.a.clientY+s.b.clientY)/2,s.center={x:e,y:i},s.diameter=r,s},calcAngle:function(t){var e=t.a.clientX-t.b.clientX,i=t.a.clientY-t.b.clientY;return(360+Math.atan2(i,e)*o)%360}};e.registerGesture("pinch",r)}(i)},{}],18:[function(t,e,i){"use strict";function n(t,e){if(!(this instanceof n))throw d('Not called with "new" keyword.');var i,o,s=this;e=e||{},"string"==typeof t?(o=r(document.querySelectorAll(t)),i=c(o)):t[0]instanceof Element?(o=r(t),i=c(o)):(o=[],i=u(t,e),i.forEach(function(t){o=o.concat(r(t.element.querySelectorAll("li")))})),i.forEach(function(t){t.element.addEventListener("wheel",h)}),o.forEach(function(t,e){var i=t!==t.parentElement.lastElementChild?s.addEvt(t,"mousedown",t,!0):{element:t};o[e]=i}),g="transform"in o[0].element.style?"transform":"-webkit-transform",this.modelLists=i,this.items=o,this.bindings={},this.callback={},m(v,"list-dragon-base",e.cssStylesheetReferenceElement)}function o(t,e,i){if(t){var n=0>p&&t>=0||0===p&&0!==t||p>0&&0>=t;p=t>0?Math.min(50,t):Math.max(-50,t),n&&(clearInterval(f),f=setInterval(function(t){var e=i.scrollTop+p;0>p&&t>e||p>0&&e>t?(i.scrollTop=t,clearInterval(f)):i.scrollTop=e},125))}else clearInterval(f),p=0}function r(t){return Array.prototype.slice.call(t)}function s(t,e){return e.top<=t.y&&t.y<=e.bottom&&e.left<=t.x&&t.x<=e.right}function l(t,e){return"translate("+Math.floor(t+window.scrollX)+"px,"+Math.floor(e+window.scrollY)+"px)"}function a(t){var e=document.createTextNode(t);return document.createElement("a").appendChild(e).parentNode.innerHTML}function u(t,e){var i=e.label||"{label}";return t.forEach(function(n,o){var r=n.label||i,s=void 0!==n.htmlEncode&&n.htmlEncode||e.htmlEncode,l=document.createElement("div"),u=document.createElement("ul");if(n.models)Object.keys(n).forEach(function(t){"models"!==t&&(n.models[t]=n[t])}),t[o]=n=n.models;else{if(!(n instanceof Array))throw d("List [{1}] not an array of models (with or without additional properties) OR an object (with a `models` property containing an array of models).",o);n.models=n}n.forEach(function(t){var i=t.label||r,o=void 0!==t.htmlEncode&&t.htmlEncode||s,l="object"==typeof t?t:{label:t},c=C.call([l,n,e],i),h=document.createElement("li");h.innerHTML=o?a(c):c,u.appendChild(h)});var c=document.createElement("li");if(c.innerHTML=" ",u.appendChild(c),n.title){var h=document.createElement("div");h.innerHTML=s?a(n.title):n.title,l.appendChild(h)}l.appendChild(u),l.className=n.cssClassNames||e.cssClassNames||"dragon-list",n.element=u,n.container=l}),t}function c(t){var e=[];return t.forEach(function(t){var i=t.parentElement,n=i.parentElement,o=[];e.find(function(t){return t.element===i})||(r(i.querySelectorAll("li")).forEach(function(t){t!==i.lastElementChild&&o.push(t.innerHTML)}),o.element=i,o.container=n,e.push(o))}),e}function h(t){t.stopPropagation()}function d(){return"list-dragon: "+C.apply(this,Array.prototype.slice.call(arguments))}var g,f,p,v,m=t("css-injector"),C=t("templex"),w=null;v="div.dragon-list{position:relative;background-color:#fff}div.dragon-list>div,div.dragon-list>ul{position:absolute;left:0;right:0}div.dragon-list>div{text-align:center;background-color:#00796b;color:#fff;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);overflow:hidden;white-space:nowrap}div.dragon-list>ul{overflow-y:auto;bottom:0;margin:0;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}div.dragon-list>ul>li,li.dragon-pop{white-space:nowrap;list-style-type:none;border:0 solid #f4f4f4;border-bottom:1px solid #e0e0e0;cursor:move;transition:border-top-width .2s}div.dragon-list>ul>li:last-child{height:0;border-bottom:none}li.dragon-pop{position:fixed;background-color:#fff;border:1px solid #e0e0e0;left:0;top:0;overflow-x:hidden;box-shadow:rgba(0,0,0,.188235) 0 10px 20px,rgba(0,0,0,.227451) 0 6px 6px}",n.prototype={addEvt:function(t,e,i,n){var o={handler:y[e].bind(t,this),element:i||window};return n||(this.bindings[e]=o),o.element.addEventListener(e,o.handler),o},removeEvt:function(t){var e=this.bindings[t];delete this.bindings[t],e.element.removeEventListener(t,e.handler)},removeAllEventListeners:function(){for(var t in this.bindings){var e=this.bindings[t];e.element.removeEventListener(t,e.handler)}this.items.forEach(function(t){t.handler&&t.element.removeEventListener("mousedown",t.handler)}),this.modelLists.forEach(function(t){t.element.removeEventListener("wheel",h)})},pointInListRects:function(t){return this.modelLists.find(function(e){var i=e.element.getBoundingClientRect();return i={left:window.scrollX+i.left,top:window.scrollY+i.top,right:window.scrollX+i.right,bottom:window.scrollY+i.bottom,width:i.width,height:i.height},e.rect=i,s(t,i)?(e.rect=i,!0):!1})},pointInItemRects:function(t,e,i){return this.items.find(function(n){var o=n.element;return o!==e&&o!==i&&s(t,n.rect)})},getAllItemBoundingRects:function(){var t,e=this.modelLists;this.items.forEach(function(i){var n=i.element,o=n.parentElement,r=e.find(function(t){return t.element===o});if(void 0===r.isDropTarget||"function"==typeof r.isDropTarget&&r.isDropTarget()||r.isDropTarget){var s=n.getBoundingClientRect(),l=s.bottom;n===o.lastElementChild?(l=o.getBoundingClientRect().bottom,l0&&(i.element.scrollTop>0&&(s=u-(i.rect.top+5))<0?o(s,0,i.element):i.element.scrollTop0?o(s,a,i.element):o());var c=t.pointInItemRects({x:e.clientX,y:t.rect.bottom+window.scrollY+r+i.element.scrollTop},this,t.drop);if(this.style[g]=l(t.rect.left-window.scrollX+n,t.rect.top-window.scrollY+r),c){var h=c.element;h.style.transition=w,h.style.borderTopWidth=t.drop.style.borderTopWidth,t.drop.style.borderTopWidth=null,t.drop=h}}},mouseup:function(t,e){o(),t.removeEvt("mousemove"),t.removeEvt("mouseup"),e.stopPropagation();var i=this.getBoundingClientRect();if(window.scrollX+i.left===t.rect.left&&window.scrollY+i.top===t.rect.top)t.reinsert(this);else{var n=t.drop.getBoundingClientRect();t.addEvt(this,"transitionend",this),this.style.transitionDuration=w,this.style.transitionProperty=g,this.style[g]=l(n.left-window.scrollX,n.top-window.scrollY)}},transitionend:function(t,e){if(e.propertyName===g){t.removeEvt("transitionend"),t.reinsert(this),this.style.transitionProperty=w;var i=t.modelLists[t.origin.list].splice(t.origin.item,1)[0],n=t.itemCoordinates(this);t.modelLists[n.list].splice(n.item,0,i),t.callback.dropped&&t.callback.dropped.call(this,t)}}};e.exports=n},{"css-injector":4,templex:25}],19:[function(t,e,i){!function(){function t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(){return 1}function n(t){d||"string"==typeof t||"number"==typeof t||(d=!0,console.error(new TypeError("LRU: key must be a string or number. Almost certainly a bug! "+typeof t).stack))}function o(t){return this instanceof o?("number"==typeof t&&(t={max:t}),t||(t={}),this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||i,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=i),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,void this.reset()):new o(t)}function r(t,e,i){n(e);var o=t._cache[e];return o&&(s(t,o)?(c(t,o),t._allowStale||(o=void 0)):i&&l(t,o),o&&(o=o.value)),o}function s(t,e){if(!e||!e.maxAge&&!t._maxAge)return!1;var i=!1,n=Date.now()-e.now;return i=e.maxAge?n>e.maxAge:t._maxAge&&n>t._maxAge}function l(t,e){u(t,e),e.lu=t._mru++,t._lruList[e.lu]=e}function a(t){for(;t._lrut._max;)c(t,t._lruList[t._lru])}function u(t,e){for(delete t._lruList[e.lu];t._lru=t)&&(t=1/0),this._max=t,this._length>this._max&&a(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t){this._lengthCalculator=i,this._length=this._itemCount;for(var e in this._cache)this._cache[e].length=1}else{this._lengthCalculator=t,this._length=0;for(var e in this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length}this._length>this._max&&a(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,e){e=e||this;for(var i=0,n=this._itemCount,o=this._mru-1;o>=0&&n>i;o--)if(this._lruList[o]){i++;var r=this._lruList[o];s(this,r)&&(c(this,r),this._allowStale||(r=void 0)),r&&t.call(e,r.value,r.key,this)}},o.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,i=this._mru-1;i>=0&&e=0&&e=0&&ethis._max?(c(this,this._cache[e]),!1):(this._dispose&&this._dispose(e,this._cache[e].value),this._cache[e].now=r,this._cache[e].maxAge=o,this._cache[e].value=i,this._length+=s-this._cache[e].length,this._cache[e].length=s,this.get(e),this._length>this._max&&a(this),!0);var l=new h(e,i,this._mru++,s,r,o);return l.length>this._max?(this._dispose&&this._dispose(e,i),!1):(this._length+=l.length,this._lruList[l.lu]=this._cache[e]=l,this._itemCount++,this._length>this._max&&a(this),!0)},o.prototype.has=function(e){if(n(e),!t(this._cache,e))return!1;var i=this._cache[e];return s(this,i)?!1:!0},o.prototype.get=function(t){return n(t),r(this,t,!0)},o.prototype.peek=function(t){return n(t),r(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return c(this,t),t||null},o.prototype.del=function(t){n(t),c(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var e=Date.now(),i=t.length-1;i>=0;i--){var o=t[i];n(o.k);var r=o.e||0;if(0===r)this.set(o.k,o.v);else{var s=r-e;s>0&&this.set(o.k,o.v,s)}}}}()},{}],20:[function(t,e,i){!function(t,e){"object"==typeof i&&i&&"string"!=typeof i.nodeName?e(i):"function"==typeof define&&define.amd?define(["exports"],e):(t.Mustache={},e(t.Mustache))}(this,function(t){function e(t){return"function"==typeof t}function i(t){return p(t)?"array":typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function o(t,e){return null!=t&&"object"==typeof t&&e in t}function r(t,e){return v.call(t,e)}function s(t){return!r(m,t)}function l(t){return String(t).replace(/[&<>"'`=\/]/g,function(t){return C[t]})}function a(e,i){function o(){if(m&&!C)for(;v.length;)delete f[v.pop()];else v=[];m=!1,C=!1}function r(t){if("string"==typeof t&&(t=t.split(y,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);l=new RegExp(n(t[0])+"\\s*"),a=new RegExp("\\s*"+n(t[1])),d=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var l,a,d,g=[],f=[],v=[],m=!1,C=!1;r(i||t.tags);for(var E,A,R,D,T,P,M=new h(e);!M.eos();){if(E=M.pos,R=M.scanUntil(l))for(var k=0,F=R.length;F>k;++k)D=R.charAt(k),s(D)?v.push(f.length):C=!0,f.push(["text",D,E,E+1]),E+=1,"\n"===D&&o();if(!M.scan(l))break;if(m=!0,A=M.scan(x)||"name",M.scan(w),"="===A?(R=M.scanUntil(b),M.scan(b),M.scanUntil(a)):"{"===A?(R=M.scanUntil(d),M.scan(S),M.scanUntil(a),A="&"):R=M.scanUntil(a),!M.scan(a))throw new Error("Unclosed tag at "+M.pos);if(T=[A,R,E,M.pos],f.push(T),"#"===A||"^"===A)g.push(T);else if("/"===A){if(P=g.pop(),!P)throw new Error('Unopened section "'+R+'" at '+E);if(P[1]!==R)throw new Error('Unclosed section "'+P[1]+'" at '+E)}else"name"===A||"{"===A||"&"===A?C=!0:"="===A&&r(R)}if(P=g.pop())throw new Error('Unclosed section "'+P[1]+'" at '+M.pos);return c(u(f))}function u(t){for(var e,i,n=[],o=0,r=t.length;r>o;++o)e=t[o],e&&("text"===e[0]&&i&&"text"===i[0]?(i[1]+=e[1],i[3]=e[3]):(n.push(e),i=e));return n}function c(t){for(var e,i,n=[],o=n,r=[],s=0,l=t.length;l>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),r.push(e),o=e[4]=[];break;case"/":i=r.pop(),i[5]=e[2],o=r.length>0?r[r.length-1][4]:n;break;default:o.push(e)}return n}function h(t){this.string=t,this.tail=t,this.pos=0}function d(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function g(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},v=RegExp.prototype.test,m=/\S/,C={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},w=/\s*/,y=/\s+/,b=/\s*=/,S=/\s*\}/,x=/#|\^|\/|>|\{|&|=|!/;h.prototype.eos=function(){return""===this.tail},h.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var i=e[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i},h.prototype.scanUntil=function(t){var e,i=this.tail.search(t);switch(i){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,i),this.tail=this.tail.substring(i)}return this.pos+=e.length,e},d.prototype.push=function(t){return new d(t,this)},d.prototype.lookup=function(t){var i,n=this.cache;if(n.hasOwnProperty(t))i=n[t];else{for(var r,s,l=this,a=!1;l;){if(t.indexOf(".")>0)for(i=l.view,r=t.split("."),s=0;null!=i&&sa;++a)s=void 0,o=t[a],r=o[0],"#"===r?s=this.renderSection(o,e,i,n):"^"===r?s=this.renderInverted(o,e,i,n):">"===r?s=this.renderPartial(o,e,i,n):"&"===r?s=this.unescapedValue(o,e):"name"===r?s=this.escapedValue(o,e):"text"===r&&(s=this.rawValue(o)),void 0!==s&&(l+=s);return l},g.prototype.renderSection=function(t,i,n,o){function r(t){return s.render(t,i,n)}var s=this,l="",a=i.lookup(t[1]);if(a){if(p(a))for(var u=0,c=a.length;c>u;++u)l+=this.renderTokens(t[4],i.push(a[u]),n,o);else if("object"==typeof a||"string"==typeof a||"number"==typeof a)l+=this.renderTokens(t[4],i.push(a),n,o);else if(e(a)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");a=a.call(i.view,o.slice(t[3],t[5]),r),null!=a&&(l+=a)}else l+=this.renderTokens(t[4],i,n,o);return l}},g.prototype.renderInverted=function(t,e,i,n){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,i,n):void 0},g.prototype.renderPartial=function(t,i,n){if(n){var o=e(n)?n(t[1]):n[t[1]];return null!=o?this.renderTokens(this.parse(o),i,n,o):void 0}},g.prototype.unescapedValue=function(t,e){var i=e.lookup(t[1]);return null!=i?i:void 0},g.prototype.escapedValue=function(e,i){var n=i.lookup(e[1]);return null!=n?t.escape(n):void 0},g.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.2.1",t.tags=["{{","}}"];var E=new g;t.clearCache=function(){return E.clearCache()},t.parse=function(t,e){return E.parse(t,e)},t.render=function(t,e,n){if("string"!=typeof t)throw new TypeError('Invalid template! Template should be a "string" but "'+i(t)+'" was given as the first argument for mustache#render(template, view, partials)');return E.render(t,e,n)},t.to_html=function(i,n,o,r){var s=t.render(i,n,o);return e(r)?void r(s):s},t.escape=l,t.Scanner=h,t.Context=d,t.Writer=g})},{}],21:[function(t,e,i){"use strict";function n(t){return t instanceof n?t:this instanceof n?(this.originalValue=t,void(this.o=t||{})):new n(t)}n.chain=function(t){var e=n(t);return e.chaining=!0,e},n.prototype={value:function(){return this.originalValue},each:function(t,e){var i=this.o;return Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)},e||i),this},find:function(t,e){var i,n=this.o;return n&&(i=Object.keys(n).find(function(e){return t.call(this,n[e],e,n)},e||n),void 0!==i&&(i=n[i])),i},filter:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){t.call(this,i[e],e,i)&&n.push(i[e])},e||i),n},map:function(t,e){var i=this.o,n=[];return i&&Object.keys(i).forEach(function(e){n.push(t.call(this,i[e],e,i))},e||i),n},reduce:function(t,e,i){var n=this.o;return n&&Object.keys(n).forEach(function(i,o){e=o||void 0!==e?t(e,n[i],i,n):n[i]},i||n),e},extend:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){if(t)for(var i in t)e[i]=t[i]}),this.chaining?this:e},extendOwn:function(t){var e=this.o;return Array.prototype.slice.call(arguments).forEach(function(t){n(t).each(function(t,i){e[i]=t})}),this.chaining?this:e}},Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,i=Object(this),n=i.length>>>0,o=arguments[1],r=0;n>r;r++)if(e=i[r],t.call(o,e,r,i))return e}),e.exports=n},{}],22:[function(t,e,i){"use strict";function n(t,e){Object.defineProperty(this,t,{value:e,writable:!1,enumerable:!0,configurable:!1})}function o(t,e){n.call(this,"x",Number(t)||0),n.call(this,"y",Number(e)||0)}function r(t,e,i,r){t=Number(t)||0,e=Number(e)||0,i=Number(i)||0,r=Number(r)||0,0>i&&(t+=i,i=-i),0>r&&(e+=r,r=-r),n.call(this,"origin",new o(t,e)),n.call(this,"extent",new o(i,r)),n.call(this,"corner",new o(t+i,e+r)),n.call(this,"center",new o(t+i/2,e+r/2))}o.prototype={plus:function(t){return new o(this.x+t.x,this.y+t.y)},plusXY:function(t,e){return new o(this.x+(t||0),this.y+(e||0))},minus:function(t){return new o(this.x-t.x,this.y-t.y)},min:function(t){return new o(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new o(Math.max(this.x,t.x),Math.max(this.y,t.y))},distance:function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){var e=!1;return t&&(e=this.x===t.x&&this.y===t.y),e},greaterThan:function(t){return this.x>t.x&&this.y>t.y},lessThan:function(t){return this.x=t.x&&this.y>=t.y},lessThanOrEqualTo:function(t){return this.x<=t.x&&this.y<=t.y},within:function(t){var e=t.origin.x,i=e+t.extent.x,n=t.origin.y,o=n+t.extent.y;return t.extent.x<0&&(e=i,i=t.origin.x),t.extent.y<0&&(n=o,o=t.origin.y),e<=this.x&&this.xi;i++)for(var o=this.origin.y,r=this.corner.y;r>o;o++)t.call(e,i,o)},intersect:function(t,e,i){var n=null,o=this.origin.max(t.origin),s=this.corner.min(t.corner),l=s.minus(o);return l.x>0&&l.y>0?n=new r(o.x,o.y,l.x,l.y):"function"==typeof e&&(n=e.call(i||this,t)),n},intersects:function(t){return t.corner.x>this.origin.x&&t.corner.y>this.origin.y&&t.origin.x\|\:\[\]])/g,r=".*",s=".",l="("+r+")",a="_",u="%",c=new RegExp("("+[a,u,"\\[\\^?[^-\\]]+]","\\[\\^?[^-\\]]\\-[^\\]]]"].join("|")+")","g"); +n.reserve=function(t){return t.replace(o,"\\$1")};var h,d;(n.clearCache=function(t){return t?h[t]&&(delete h[t],d--):(h={},d=0),d})(),n.getCacheSize=function(){return d},n.cached=function(t,e,i){"string"==typeof t&&(i=e,e=t,t=!1);var o=e+(i?"i":"c"),r=h[o];if(r)r.when=(new Date).getTime(),void 0!==t&&(r.keep=t);else{if(d===n.cacheMax){var s,l,a=[],u=0;for(s in h)if(r=h[s],!r.keep){for(l=0;u>l&&!(r.when=t?[t,e]:[e,t]}function n(t,e){return t[0]<=e[0]&&e[0]<=t[1]||t[0]<=e[1]&&e[1]<=t[1]||e[0]=o&&n>r?s.push([r+1,n]):o>i&&r>=n?s.push([i,o-1]):o>i&&n>r?(s.push([i,o-1]),s.push([r+1,n])):(i>r||o>n)&&s.push(t),s}function s(t,e){var i=Math.min(Math.min.apply(Math,t),Math.min.apply(Math,e)),n=Math.max(Math.max.apply(Math,t),Math.max.apply(Math,e));return[i,n]}e.prototype={select:function(t,e){this.storeState();var r=i(t,e),l=[0,1];return this.selection.forEach(function(t){n(t,r)||o(t,r)?r=s(t,r):l.push(t)}),l.push(r),l[1]=this.selection.length,this.selection.splice.apply(this.selection,l),this},deselect:function(t,e){var o=i(t,e),s=[0,0];return this.selection.forEach(function(t){if(n(t,o)){var e=r(t,o);s=s.concat(e)}else s.push(t)}),s[1]=this.selection.length,this.selection.splice.apply(this.selection,s),this},clear:function(){return this.states.length=0,this.selection.length=0,this},clearMostRecentSelection:function(){0!==this.states.length&&(this.selection=this.states.pop())},isSelected:function(t){return this.selection.some(function(e){return e[0]<=t&&t<=e[1]})},isEmpty:function(){return 0===this.selection.length},getSelections:function(){var t=[];return this.selection.forEach(function(e){for(var i=e[0];i<=e[1];i++)t.push(i)}),t.sort(function(t,e){return t-e}),t}},t.exports=e})("object"==typeof e&&e||(window.RangeSelectionModel={}),"object"==typeof e&&e.exports||(window.RangeSelectionModel.exports={}))||"object"==typeof e||(window.RangeSelectionModel=window.RangeSelectionModel.exports)},{}],25:[function(require,module,exports){function templex(t){var e=this instanceof Array?this:[this];return arguments.length>1&&e.unshift(arguments),t.replace(templex.regexp,templex.merger.bind(e))}templex.regexp=/\{(.*?)\}/g,templex["with"]=function(t,e){return"with(this["+t+"]){"+e+"}"},templex.cache=[],templex.deref=function(key){if(!(this.length in templex.cache)){for(var code="return eval(expr)",i=0;i-1,this.selectionModel=new C(this),this.localCellEditors={},this.cellEditors=Object.create(this.localCellEditors),this.renderOverridesCache={},this.behavior=e(this),this.div.oncontextmenu=function(t){return t.preventDefault(),!1},this.clearMouseDown(),this.dragExtent=new g(0,0),this.numRows=0,this.numColumns=0,this.pluginsDo(function(t){t.installOn&&t.installOn(n)}),i=i||{},i.top=i.top||0,i.right=i.right||"-200px",i.bottom=i.bottom||0,i.left=i.left||0,x||(x=!0,s()),this.initRenderer(),this.initCanvas(i),this.initScrollbars(),this.initLocalCellEditors(),document.body.addEventListener("copy",function(t){n.checkClipboardCopy(t)}),this.getCanvas().resize(),this.dialog=new y(this),this.filter=new S}function o(t,e){return p(e).each(function(e,i){"object"==typeof t[i]&&"object"==typeof e?o(t[i],e):void 0===e?delete t[i]:t[i]=e}),t}function r(t){var e=t.origin,i=t.corner,n=Math.min(e.x,i.x),o=Math.min(e.y,i.y),r=Math.max(e.x,i.x),s=Math.max(e.y,i.y),l=new f(n,o,r-n,s-o);return l}function s(){l(E);var t=document.createElement("paper-button");t.style.display="none",t.setAttribute("disabled",!0),document.body.appendChild(t);var e=window.getComputedStyle(t),i=document.createElement("section");i.style.display="none",i.setAttribute("hero",!0),document.body.appendChild(i);var n=window.getComputedStyle(document.querySelector("html")),o=window.getComputedStyle(document.querySelector("html, body")),r=window.getComputedStyle(i);E.columnHeaderBackgroundColor=e.color,E.rowHeaderBackgroundColor=e.color,E.topLeftBackgroundColor=e.color,E.lineColor=e.backgroundColor,E.backgroundColor2=o.backgroundColor,E.color=n.color,E.fontFamily=n.fontFamily,E.backgroundColor=r.backgroundColor,t.setAttribute("disabled",!1),t.setAttribute("secondary",!0),t.setAttribute("raised",!0),e=window.getComputedStyle(t),E.columnHeaderColor=e.color,E.rowHeaderColor=e.color,E.topLeftColor=e.color,E.backgroundSelectionColor=e.backgroundColor,E.foregroundSelectionColor=e.color,t.setAttribute("secondary",!1),t.setAttribute("warning",!0),E.columnHeaderForegroundSelectionColor=e.color,E.columnHeaderBackgroundSelectionColor=e.backgroundColor,E.rowHeaderForegroundSelectionColor=e.color,E.fixedColumnBackgroundSelectionColor=e.backgroundColor,("rgba(0, 0, 0, 0)"===E.columnHeaderBackgroundSelectionColor||"transparent"===E.lineColor)&&l(E),document.body.removeChild(t),document.body.removeChild(i)}function l(t){for(var e in t)t.hasOwnProperty(e)&&delete t[e]}function a(t){var e="function"==typeof t?t():t;return e||0===e?e:""}var u=t("extend-me"),c=t("./lib/deprecated");u.debug=!0;var h=t("finbars"),d=t("fincanvas"),g=t("rectangular").Point,f=t("rectangular").Rectangle,p=t("object-iterators"),v=t("./defaults"),m=t("./lib/Renderer"),C=t("./lib/SelectionModel"),w=t("../css/stylesheets"),y=t("./lib/TableDialog"),b=t("./lib/Formatters"),S=t("./lib/CustomFilter"),x=!1,E=Object.create(v),A=Object.create(E);n.prototype={constructor:n.prototype.constructor,deprecated:c,behavior:null,isWebkit:!0,mouseDown:[],dragExtent:null,vScrollValue:0,hScrollValue:0,rectangular:null,selectionModel:null,cellEditor:null,sbHScroller:null,sbVScroller:null,sbPrevVScrollValue:null,sbPrevHScrollValue:null,cellEditors:null,renderOverridesCache:{},hoverCell:null,scrollingNow:!1,lastEdgeSelection:null,setAttribute:function(t,e){this.div.setAttribute(t,e)},reset:function(){this.lastEdgeSelection=[0,0],this.lnfProperties=Object.create(A),this.selectionModel=new C(this),this.cellEditors=Object.create(this.localCellEditors),this.renderOverridesCache={},this.clearMouseDown(),this.dragExtent=new g(0,0),this.numRows=0,this.numColumns=0,this.vScrollValue=0,this.hScrollValue=0,this.cellEditor=null,this.sbPrevVScrollValue=null,this.sbPrevHScrollValue=null,this.hoverCell=null,this.scrollingNow=!1,this.lastEdgeSelection=[0,0],this.behavior.reset(),this.getRenderer().reset(),this.getCanvas().resize(),this.behaviorChanged()},getProperties:function(){return this.getPrivateState()},_getProperties:function(){return this.lnfProperties},computeCellsBounds:function(){var t=this.getRenderer();t&&t.computeCellsBounds()},initCellEditor:function(t){this.localCellEditors[t.alias]=t,t.grid=this},initLocalCellEditors:function(){var t=["Textfield","Choice","Color","Date","Slider","Spinner","Filter"],e=this;t.forEach(function(t){e.initCellEditor(new n.cellEditors[t])}),this.localCellEditors["int"]=this.localCellEditors.spinner,this.localCellEditors["float"]=this.localCellEditors.spinner,this.localCellEditors.date=this.localCellEditors.date,this.localCellEditors.string=this.localCellEditors.extfield},toggleColumnPicker:function(){this.behavior.toggleColumnPicker()},isHovered:function(t,e){var i=this.getHoverCell();return i&&i.x===t&&i.y===e},registerFormatter:function(t,e){b[t]=e},getFormatter:function(t){var e=b[t];return e?e:b["default"]},formatValue:function(t,e){var i=this.getFormatter(t);return i(e)},isColumnHovered:function(t){var e=this.getHoverCell();return e&&e.x===t},isRowResizeable:function(){return this.resolveProperty("rowResize")},isCheckboxOnlyRowSelections:function(){return this.resolveProperty("checkboxOnlyRowSelections")},isRowHovered:function(t){var e=this.getHoverCell();return e&&e.y===t},getHoverCell:function(){return this.hoverCell},setHoverCell:function(t){var e=this.hoverCell,i=new g(t.x,t.y);e&&e.equals(i)||(this.hoverCell=i,this.fireSyntheticOnCellEnterEvent(i),this.repaint())},addGlobalProperties:function(t){if(A)this._addGlobalProperties(t);else{var e=this;setTimeout(function(){e.addGlobalProperties(t)},10)}},_addGlobalProperties:function(t){p(t).each(function(t,e){A[e]=t})},refreshProperties:function(){this.checkScrollbarVisibility(),this.behavior.defaultRowHeight=null,this.isColumnAutosizing()&&this.behavior.autosizeAllColumns()},addProperties:function(t){var e=this.getProperties();o(e,t),this.refreshProperties()},getPrivateState:function(){return this.behavior.getPrivateState()},setState:function(t){var e=this;this.behavior.setState(t),setTimeout(function(){e.behaviorChanged(),e.synchronizeScrollingBoundries()},100)},getState:function(){return this.behavior.getState()},getMouseDown:function(){var t=this.mouseDown.length-1;return 0>t?null:this.mouseDown[t]},popMouseDown:function(){0!==this.mouseDown.length&&(this.mouseDown.length=this.mouseDown.length-1)},clearMouseDown:function(){this.mouseDown=[new g(-1,-1)],this.dragExtent=null},setMouseDown:function(t){this.mouseDown.push(t)},getDragExtent:function(){return this.dragExtent},setDragExtent:function(t){this.dragExtent=t},pluginsDo:function(t){},getCellProvider:function(){var t=this.behavior.getCellProvider();return t},gridRenderedNotification:function(){this.updateRenderedSizes(),this.cellEditor&&this.cellEditor.gridRenderedNotification(),this.checkColumnAutosizing(),this.fireSyntheticGridRenderedEvent()},checkColumnAutosizing:function(){var t=this.behavior;t.autoSizeRowNumberColumn(),this.isColumnAutosizing()&&t.checkColumnAutosizing(!1)},updateRenderedSizes:function(){this.behavior.setRenderedColumnCount(this.getVisibleColumns()+1),this.behavior.setRenderedRowCount(this.getVisibleRows()+1)},checkClipboardCopy:function(t){if(this.hasFocus()){t.preventDefault();var e=this.getSelectionAsTSV();t.clipboardData.setData("text/plain",e)}},hasSelections:function(){return this.getSelectionModel?this.selectionModel.hasSelections():void 0},getSelectionAsTSV:function(){var t=this.selectionModel;if(t.hasSelections()){var e=this.getSelectionMatrix();return e=e[e.length-1],this.getMatrixSelectionAsTSV(e)}return t.hasRowSelections()?this.getMatrixSelectionAsTSV(this.getRowSelectionMatrix()):t.hasColumnSelections()?this.getMatrixSelectionAsTSV(this.getColumnSelectionMatrix()):void 0},getMatrixSelectionAsTSV:function(t){var e="";if(t.length){var i=t.length,n=t[0].length,o=i*n,r=i-1;if(o>2e4)return alert("selection size is too big to copy to the paste buffer"),"";for(var s=0;n>s;s++)for(var l=0;i>l;l++)e+=t[l][s]+(r>l?" ":"\n")}return e},hasFocus:function(){return this.getCanvas().hasFocus()},clearSelections:function(){var t=this.isCheckboxOnlyRowSelections();this.selectionModel.clear(t),this.clearMouseDown()},clearMostRecentSelection:function(){var t=this.isCheckboxOnlyRowSelections();this.selectionModel.clearMostRecentSelection(t)},clearMostRecentColumnSelection:function(){this.selectionModel.clearMostRecentColumnSelection()},clearMostRecentRowSelection:function(){},clearRowSelection:function(){this.selectionModel.clearRowSelection(),this.behavior.getDataModel().getComponent().clearSelectedData()},select:function(t,e,i,n){0>t||0>e||this.selectionModel.select(t,e,i,n)},isSelected:function(t,e){return this.selectionModel.isSelected(t,e)},isCellSelectedInRow:function(t){var e=this.selectionModel,i=e.isCellSelectedInRow(t);return i},isCellSelectedInColumn:function(t){var e=this.selectionModel,i=e.isCellSelectedInColumn(t);return i},getSelectionModel:function(){return this.deprecated("selectionModel",{since:"0.2"})},getBehavior:function(){return this.deprecated("behavior",{since:"0.2"})},setBehavior:function(t){this.behavior=t,this.behavior.setGrid(this),this.behavior.changed=this.behaviorChanged.bind(this),this.behavior.shapeChanged=this.behaviorShapeChanged.bind(this),this.behavior.stateChanged=this.behaviorStateChanged.bind(this)},behaviorChanged:function(){(this.numColumns!==this.getColumnCount()||this.numRows!==this.getRowCount())&&(this.numColumns=this.getColumnCount(),this.numRows=this.getRowCount(),this.behaviorShapeChanged()),this.computeCellsBounds(),this.repaint()},getBounds:function(){var t=this.getRenderer();return t&&t.getBounds()},resolveProperty:function(t){for(var e=t.split("."),i=this.getProperties();e.length;)i=i[e.shift()];return i},behaviorShapeChanged:function(){this.synchronizeScrollingBoundries()},behaviorStateChanged:function(){this.getRenderer().computeCellsBounds(),this.repaint()},repaint:function(){var t=this.resolveProperty("repaintImmediately"),e=this.getCanvas();e&&(t===!0?e.paintNow():e.repaint())},paintNow:function(){var t=this.getCanvas();t.paintNow()},useHiDPI:function(){return this.resolveProperty("useHiDPI")!==!1},initCanvas:function(t){var e=this,i=this.divCanvas=document.createElement("div");this.div.appendChild(i),this.canvas=new d(i,this.renderer);var o=i.style;o.position="absolute",o.top=t.top,o.right=t.right,o.bottom=t.bottom,o.left=t.left,this.canvas.resizeNotification=function(){e.resized()},this.addEventListener("fin-canvas-mousemove",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.delegateMouseMove(n)}}),this.addEventListener("fin-canvas-mousedown",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.keys=t.detail.keys,n.primitiveEvent=t,e.mouseDownState=n,e.delegateMouseDown(n),e.fireSyntheticMouseDownEvent(n),e.repaint()}}),this.addEventListener("fin-canvas-mouseup",function(t){if(!e.resolveProperty("readOnly")){e.dragging=!1,e.isScrollingNow()&&e.setScrollingNow(!1),e.columnDragAutoScrolling&&(e.columnDragAutoScrolling=!1);var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.delegateMouseUp(n),e.mouseDownState&&e.fireSyntheticButtonPressedEvent(e.mouseDownState),e.mouseDownState=null,e.fireSyntheticMouseUpEvent(n)}}),this.addEventListener("fin-canvas-dblclick",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.fireSyntheticDoubleClickEvent(n,t),e.delegateDoubleClick(n)}}),this.addEventListener("fin-canvas-tap",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,n.keys=t.detail.keys,e.fireSyntheticClickEvent(n),e.delegateTap(n)}}),this.addEventListener("fin-canvas-drag",function(t){if(!e.resolveProperty("readOnly")){e.dragging=!0;var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t,e.delegateMouseDrag(n)}}),this.addEventListener("fin-canvas-keydown",function(t){if(!e.resolveProperty("readOnly")){if(e.resolveProperty("editOnKeydown")){var i,o,r,s,l=t.detail["char"];e.isEditing()||"F2"!==l&&!(i=1===l.length)&&!(o="DELETE"===l||"BACKSPACE"===l)||(r=e.selectionModel.getLastSelection(),r&&(s=e.activateEditor(r.origin.x,r.origin.y),s instanceof n.cellEditors.Simple&&(i?s.input.value=l:o&&(s.input.value=""),t.detail.primitiveEvent.preventDefault())))}e.fireSyntheticKeydownEvent(t),e.delegateKeyDown(t)}}),this.addEventListener("fin-canvas-keyup",function(t){e.resolveProperty("readOnly")||(e.fireSyntheticKeyupEvent(t),e.delegateKeyUp(t))}),this.addEventListener("fin-canvas-track",function(t){if(!e.resolveProperty("readOnly")&&!e.dragging){var i=t.detail.primitiveEvent;Math.abs(i.dy)>Math.abs(i.dx)?i.yDirection>0?e.scrollVBy(-2):i.yDirection<-0&&e.scrollVBy(2):i.xDirection>0?e.scrollHBy(-1):i.xDirection<-0&&e.scrollHBy(1)}}),this.addEventListener("fin-canvas-wheelmoved",function(t){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t.detail.primitiveEvent,e.delegateWheelMoved(n)}),this.addEventListener("fin-canvas-mouseout",function(t){if(!e.resolveProperty("readOnly")){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t.detail.primitiveEvent,e.delegateMouseExit(n)}}),this.addEventListener("fin-canvas-context-menu",function(t){var i=t.detail.mouse,n=e.getGridCellFromMousePoint(i);n.primitiveEvent=t.detail.primitiveEvent,e.delegateContextMenu(n)}),this.div.removeAttribute("tabindex")},convertViewPointToDataPoint:function(t){return this.behavior.convertViewPointToDataPoint(t)},convertDataPointToViewPoint:function(t){return this.behavior.convertDataPointToViewPoint(t)},addEventListener:function(t,e){this.canvas.addEventListener(t,e)},addFinEventListener:function(t,e){console.warn(".addEventListener() method is deprecated as of v0.2. Use .addEventListener() instead. (Will be removed in a future release.)"),this.addEventListener(t,e)},setScrollingNow:function(t){this.scrollingNow=t},isScrollingNow:function(){return this.scrollingNow},overColumnDivider:function(t){var e=t.primitiveEvent.detail.mouse.x,i=this.getRenderer().overColumnDivider(e);return i},overRowDivider:function(t){var e=t.primitiveEvent.detail.mouse.y,i=this.getRenderer().overRowDivider(e);return i},beCursor:function(t){t||(t="default"),this.div.style.cursor=t},delegateWheelMoved:function(t){this.behavior.onWheelMoved(this,t)},delegateMouseExit:function(t){this.behavior.handleMouseExit(this,t)},delegateContextMenu:function(t){this.behavior.onContextMenu(this,t)},delegateMouseMove:function(t){this.behavior.onMouseMove(this,t)},delegateMouseDown:function(t){this.behavior.handleMouseDown(this,t)},delegateMouseUp:function(t){this.behavior.onMouseUp(this,t)},delegateTap:function(t){this.behavior.onTap(this,t)},delegateMouseDrag:function(t){this.behavior.onMouseDrag(this,t)},delegateDoubleClick:function(t){this.behavior.onDoubleClick(this,t)},delegateHoldPulse:function(t){this.behavior.onHoldPulse(this,t)},delegateKeyDown:function(t){this.behavior.onKeyDown(this,t)},delegateKeyUp:function(t){this.behavior.onKeyUp(this,t)},stopEditing:function(){this.cellEditor&&this.isEditing()&&(this.cellEditor.stopEditing&&this.cellEditor.stopEditing(),this.cellEditor=null)},registerCellEditor:function(t,e){this.cellEditors[t]=e},getDataBounds:function(){var t=200,e=this.canvas.bounds,i=new f(0,0,e.origin.x+e.extent.x-t,e.origin.y+e.extent.y);return i},getRowNumbersWidth:function(){return this.isShowRowNumbers()?this.getRenderer().getRowNumbersWidth():0},getCanvas:function(){return this.canvas},editAt:function(t,e){this.cellEditor=t;var i=e.gridCell,n=i.x,o=i.y;if(n>=0&&o>=0){var r=new g(n,o);this.setMouseDown(r),this.setDragExtent(new g(0,0)),t.beginEditAt(r)}},isColumnVisible:function(t){return this.getRenderer().isColumnVisible(t)},isDataRowVisible:function(t){return this.getRenderer().isRowVisible(t)},isDataVisible:function(t,e){return this.isDataRowVisible(e)&&this.isColumnVisible(t)},insureModelColIsVisible:function(t,e){var i=this.getColumnCount()-1,n=t+(e>0),o=!this.isColumnVisible(n)||t===i;return o&&this.scrollBy(e,0),o},insureModelRowIsVisible:function(t,e){var i=this.getRowCount()-1,n=t+(e>0),o=!this.isDataRowVisible(n)||t===i;return o&&this.scrollBy(0,e),o},scrollBy:function(t,e){this.scrollHBy(t),this.scrollVBy(e)},scrollVBy:function(t){var e=this.sbVScroller.range.max,i=this.getVScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setVScrollValue(n)},scrollHBy:function(t){var e=this.sbHScroller.range.max,i=this.getHScrollValue(),n=Math.min(e,Math.max(0,i+t));n!==i&&this.setHScrollValue(n)},getGridCellFromMousePoint:function(t){var e=this.getRenderer().getGridCellFromMousePoint(t);return e},getBoundsOfCell:function(t){var e=this.getRenderer().getBoundsOfCell(t),i=new f(e.x,e.y,e.width,e.height);return i},resized:function(){this.synchronizeScrollingBoundries()},cellClicked:function(t){var e=t.gridCell;if(e.x<=this.getColumnCount()&&e.y<=this.getRowCount()){var i=this.getHoverCell(),n=i.x,o=i.y;o>=0&&(o+=this.getVScrollValue()),this.behavior.cellClicked(new g(n,o),t)}},setTotalsValueNotification:function(t,e,i,n){this.fireSyntheticSetTotalsValue(t,e,i,n)},fireSyntheticSetTotalsValue:function(t,e,i,n){var o=new CustomEvent("fin-set-totals-value",{detail:{x:t,y:e,value:i,areas:n}});this.canvas.dispatchEvent(o)},fireSyntheticEditorKeyUpEvent:function(t,e){var i=new CustomEvent("fin-editor-keyup",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyDownEvent:function(t,e){var i=new CustomEvent("fin-editor-keydown",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorKeyPressEvent:function(t,e){var i=new CustomEvent("fin-editor-keypress",{detail:{input:t,keyEvent:e}});this.canvas.dispatchEvent(i)},fireSyntheticEditorDataChangeEvent:function(t,e,i){var n=new CustomEvent("fin-editor-data-change",{detail:{input:t,oldValue:e,newValue:i},cancelable:!0});return this.canvas.dispatchEvent(n)},fireSyntheticRowSelectionChangedEvent:function(){var t=new CustomEvent("fin-row-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(t)},fireSyntheticColumnSelectionChangedEvent:function(){var t=new CustomEvent("fin-column-selection-changed",{detail:{rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(t)},selectionChanged:function(){var t=this.getSelectedRows(),e=new CustomEvent("fin-selection-changed",{detail:{rows:t,columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},getRowSelection:function(){function t(t,o){i[o]=a(n.getValue(e,t))}var e,i,n=this,o=this.selectionModel.getSelectedRows(),r=this.getColumnCount(),s={};for(e=0;r>e;e++)i=new Array(o.length),s[this.getField(e)]=i,o.forEach(t);return s},getRowSelectionMatrix:function(){function t(t,n){r[e][n]=a(i.getValue(e,t))}var e,i=this,n=this.selectionModel.getSelectedRows(),o=this.getColumnCount(),r=new Array(o);for(e=0;o>e;e++)r[e]=new Array(n.length),n.forEach(t);return r},getColumnSelectionMatrix:function(){var t=this.getSelectedColumns(),e=this.getRowCount(),i=new Array(t.length),n=this;return t.forEach(function(t,o){i[o]=new Array(e);for(var r=0;e>r;r++)i[o][r]=a(n.getValue(t,r))}),i},getColumnSelection:function(){var t=this.getSelectedColumns(),e={},i=this.getRowCount(),n=this;return t.forEach(function(t){var o=new Array(i);e[n.getField(t)]=o;for(var r=0;i>r;r++)o[r]=a(n.getValue(t,r))}),e},getSelection:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelection(e)}),i},_getSelection:function(t){t=r(t);for(var e,i=t.extent.x+1,n=t.extent.y+1,o=t.origin.x,s=t.origin.y,l={},u=0;i>u;u++){var c=new Array(n);for(l[this.getField(u+o)]=c,e=0;n>e;e++)c[e]=a(this.getValue(o+u,s+e))}return l},getSelectionMatrix:function(){var t=this,e=this.getSelections(),i=new Array(e.length);return e.forEach(function(e,n){i[n]=t._getSelectionMatrix(e)}),i},_getSelectionMatrix:function(t){t=r(t);for(var e=t.extent.x+1,i=t.extent.y+1,n=t.origin.x,o=t.origin.y,s=[],l=0;e>l;l++){var u=new Array(i);s[l]=u;for(var c=0;i>c;c++)u[c]=a(this.getValue(n+l,o+c))}return s},fireSyntheticContextMenuEvent:function(t){t.gridCell=this.convertViewPointToDataPoint(t.gridCell);var e=new CustomEvent("fin-context-menu",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseUpEvent:function(t){var e=new CustomEvent("fin-mouseup",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},fireSyntheticMouseDownEvent:function(t){this.stopEditing();var e=new CustomEvent("fin-mousedown",{detail:{gridCell:t.gridCell,mousePoint:t.mousePoint,viewPoint:t.viewPoint,primitiveEvent:t.primitiveEvent,rows:this.getSelectedRows(),columns:this.getSelectedColumns(),selections:this.selectionModel.getSelections()}});this.canvas.dispatchEvent(e)},isViewableButton:function(t,e){return this.getRenderer().isViewableButton(t,e)},fireSyntheticButtonPressedEvent:function(t){var e=t.dataCell,i=t.gridCell;if(this.isViewableButton(e.x,e.y)){var n=new CustomEvent("fin-button-pressed",{detail:{gridCell:i}});this.canvas.dispatchEvent(n)}},fireSyntheticKeydownEvent:function(t){var e=new CustomEvent("fin-keydown",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticKeyupEvent:function(t){var e=new CustomEvent("fin-keyup",{detail:t.detail});this.canvas.dispatchEvent(e)},fireSyntheticFilterAppliedEvent:function(t){var e=new CustomEvent("fin-filter-applied",{detail:t});this.canvas&&this.canvas.dispatchEvent(e)},fireSyntheticOnCellEnterEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-enter",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticGroupsChangedEvent:function(t){var e={groups:t,time:Date.now(),grid:this},i=new CustomEvent("fin-groups-changed",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticOnCellExitEvent:function(t){var e={gridCell:t,time:Date.now(),grid:this},i=new CustomEvent("fin-cell-exit",{detail:e});this.canvas.dispatchEvent(i)},fireSyntheticClickEvent:function(t){var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,keys:t.keys,primitiveEvent:t,time:Date.now(),grid:this};this.behavior.enhanceDoubleClickEvent(i);var n=new CustomEvent("fin-click",{detail:i});this.canvas.dispatchEvent(n)},fireSyntheticDoubleClickEvent:function(t){this.stopEditing();var e=t.gridCell,i={gridCell:e,mousePoint:t.mousePoint,time:Date.now(),grid:this};this.behavior.enhanceDoubleClickEvent(t);var n=new CustomEvent("fin-double-click",{detail:i});this.behavior.cellDoubleClicked(e,t),this.canvas.dispatchEvent(n)},fireSyntheticGridRenderedEvent:function(){var t=new CustomEvent("fin-grid-rendered",{detail:{source:this,time:Date.now()}});this.canvas&&this.canvas.dispatchEvent(t)},fireScrollEvent:function(t,e,i){var n=new CustomEvent(t,{detail:{oldValue:e,value:i,time:Date.now()}});this.canvas.dispatchEvent(n)},setVScrollValue:function(t){t=Math.round(t);var e=this.sbVScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.vScrollValue){this.behavior._setScrollPositionY(t);var n=this.vScrollValue;this.vScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-y",n,t)})}},getVScrollValue:function(){return this.vScrollValue},setHScrollValue:function(t){t=Math.round(t);var e=this.sbHScroller.range.max;t=Math.min(e,Math.max(0,t));var i=this;if(t!==this.hScrollValue){this.behavior._setScrollPositionX(t);var n=this.hScrollValue;this.hScrollValue=t,this.scrollValueChangedNotification(),setTimeout(function(){i.fireScrollEvent("fin-scroll-x",n,t),i.synchronizeScrollingBoundries()})}},getHScrollValue:function(){return this.hScrollValue},takeFocus:function(){this.isEditing()?this.stopEditing():this.getCanvas().takeFocus()},editorTakeFocus:function(){return this.cellEditor?this.cellEditor.takeFocus():void 0},isEditing:function(){return this.cellEditor&&this.cellEditor.isEditing},initScrollbars:function(){var t=this,e=new h({orientation:"horizontal",onchange:t.setHScrollValue.bind(t),cssStylesheetReferenceElement:this.div}),i=new h({orientation:"vertical",onchange:t.setVScrollValue.bind(t),paging:{up:t.pageUp.bind(t),down:t.pageDown.bind(t)}});this.sbHScroller=e,this.sbVScroller=i;var n=this.resolveProperty("hScrollbarClassPrefix"),o=this.resolveProperty("vScrollbarClassPrefix");n&&""!==n&&(this.sbHScroller.classPrefix=n),o&&""!==o&&(this.sbVScroller.classPrefix=o),this.div.appendChild(e.bar),this.div.appendChild(i.bar),this.resizeScrollbars()},resizeScrollbars:function(){this.sbHScroller.shortenBy(this.sbVScroller).resize(),this.sbVScroller.resize()},setVScrollbarValues:function(t){this.sbVScroller.range={min:0,max:t}},setHScrollbarValues:function(t){this.sbHScroller.range={min:0,max:t}},scrollValueChangedNotification:function(){(this.hScrollValue!==this.sbPrevHScrollValue||this.vScrollValue!==this.sbPrevVScrollValue)&&(this.sbPrevHScrollValue=this.hScrollValue,this.sbPrevVScrollValue=this.vScrollValue,this.cellEditor&&this.cellEditor.scrollValueChangedNotification(),this.computeCellsBounds())},getValue:function(t,e){return this.behavior.getValue(t,e)},setValue:function(t,e,i){this.behavior.setValue(t,e,i)},getColumnAlignment:function(t){return this.behavior.getColumnAlignment(t)},synchronizeScrollingBoundries:function(){var t=this.getFixedColumnCount(),e=this.getFixedRowCount(),i=this.getColumnCount(),n=this.getRowCount(),o=this.getBounds();if(o){for(var r=o.height-this.behavior.getFixedRowsMaxHeight()-15,s=o.width-200-this.behavior.getFixedColumnsMaxWidth()-15,l=0,a=0;i>l;l++){var u=this.getColumnWidth(i-l-1);if(a+=u,a>s)break}for(var c=0,h=0;n>c;c++){var d=this.getRowHeight(n-c-1);if(h+=d,h>r)break}var g=Math.max(0,i-t-l);this.setHScrollbarValues(g);var f=1+Math.max(0,n-e-c);this.setVScrollbarValues(f),this.setHScrollValue(Math.min(this.getHScrollValue(),g)),this.setVScrollValue(Math.min(this.getVScrollValue(),f)),this.computeCellsBounds(),this.repaint(),this.resizeScrollbars()}},getVisibleRows:function(){return this.getRenderer().getVisibleRows()},getVisibleColumns:function(){return this.getRenderer().getVisibleColumns()},initRenderer:function(){this.renderer=new m(this)},getRenderer:function(){return this.renderer},getColumnWidth:function(t){return this.behavior.getColumnWidth(t)},setColumnWidth:function(t,e){this.stopEditing(),this.behavior.setColumnWidth(t,e)},getColumnEdge:function(t){return this.behavior.getColumnEdge(t,this.getRenderer())},getFixedColumnsWidth:function(){return this.behavior.getFixedColumnsWidth()},getRowHeight:function(t){return this.behavior.getRowHeight(t)},setRowHeight:function(t,e){this.stopEditing(),this.behavior.setRowHeight(t,e)},getFixedRowsHeight:function(){return this.behavior.getFixedRowsHeight()},getColumnCount:function(){return this.behavior.getColumnCount()},getRowCount:function(){return this.behavior.getRowCount()},getUnfilteredRowCount:function(){return this.behavior.getUnfilteredRowCount()},getFixedColumnCount:function(){return this.behavior.getFixedColumnCount()},getFixedRowCount:function(){return this.behavior.getFixedRowCount()},topLeftClicked:function(t){this.behavior.topLeftClicked(this,t)},rowHeaderClicked:function(t){this.behavior.rowHeaderClicked(this,t)},columnHeaderClicked:function(t){this.behavior.columnHeaderClicked(this,t)},_activateEditor:function(t){var e=t.gridCell;this.activateEditor(e.x,e.y)},activateEditor:function(t,e){var i;if((this.isEditable()||this.isFilterRow(e))&&(i=this.getCellEditorAt(t,e))){var n=i.getEditorPoint();if(i){if(n.x===t&&n.y===e&&i.isEditing)return; +this.isEditing()&&this.stopEditing(),event.gridCell={x:t,y:e},this.editAt(i,event)}}return i},getCellEditorAt:function(t,e){return this.behavior._getCellEditorAt(t,e)},toggleHiDPI:function(){this.useHiDPI()?this.removeAttribute("hidpi"):this.setAttribute("hidpi",null),this.canvas.resize()},getHiDPI:function(t){if(window.devicePixelRatio&&this.useHiDPI()){var e=window.devicePixelRatio||1,i=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1,n=e/i;return n}return 1},getRenderedWidth:function(t){return this.renderer.getRenderedWidth(t)},getRenderedHeight:function(t){return this.renderer.getRenderedHeight(t)},resolveCellEditor:function(t){return this.cellEditors[t]},updateCursor:function(){var t=this.behavior.getCursorAt(-1,-1),e=this.getHoverCell();if(e&&e.x>-1&&e.y>-1){var i=e.x+this.getHScrollValue();t=this.behavior.getCursorAt(i,e.y+this.getVScrollValue())}this.beCursor(t)},repaintCell:function(t,e){this.getRenderer().repaintCell(t,e)},isDraggingColumn:function(){return!!this.renderOverridesCache.dragger},pageUp:function(){var t=this.getRenderer().getPageUpRow();return this.setVScrollValue(t),t},pageDown:function(){var t=this.getRenderer().getPageDownRow();return this.setVScrollValue(t),t},pageLeft:function(){console.log("page left")},pageRight:function(){console.log("page right")},getRenderedData:function(){var t,e=this.behavior,i=this.getRenderer(),n=this.getColumnCount(),o=i.getVisibleRows(),r=new Array(n),s=new Array(o);return r.forEach(function(t,i){r[i]=e.getColumnId(i,0)}),s.forEach(function(i,n){t=s[n]={hierarchy:e.getFixedColumnValue(0,n)},r.forEach(function(i,o){t[i]=e.getValue(o,n)})}),s},getSelectedRow:function(){var t=this.selectionModel.getSelections();if(t.length){for(var e=this.behavior,i=this.getColumnCount(),n=t[0].origin.y,o={},r=0;i>r;r++)o[e.getColumnId(r,0)]=e.getValue(r,n);return o}},fireRequestCellEdit:function(t,e){var i=new CustomEvent("fin-request-cell-edit",{cancelable:!0,detail:{value:e,gridCell:t,time:Date.now()}});return this.canvas.dispatchEvent(i)},fireBeforeCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-before-cell-edit",{cancelable:!0,detail:{oldValue:e,newValue:i,gridCell:t,time:Date.now(),input:n,row:this.getRow(t.y)}}),r=this.canvas.dispatchEvent(o);return r},fireAfterCellEdit:function(t,e,i,n){var o=new CustomEvent("fin-after-cell-edit",{detail:{newValue:i,oldValue:e,gridCell:t,time:Date.now(),input:n,row:this.getRow(t.y)}});this.canvas.dispatchEvent(o)},autosizeColumn:function(t){var e=this.behavior.getColumn(t);e.checkColumnAutosizing(!0),this.computeCellsBounds()},setFocusable:function(t){this.getCanvas().setFocusable(t)},getVisibleColumnsCount:function(){return this.getRenderer().getVisibleColumnsCount()},getVisibleRowsCount:function(){return this.getRenderer().getVisibleRowsCount()},updateSize:function(){this.canvas.checksize()},stopPaintThread:function(){this.canvas.stopPaintThread()},stopResizeThread:function(){this.canvas.stopResizeThread()},restartResizeThread:function(){this.canvas.restartResizeThread()},restartPaintThread:function(){this.canvas.restartPaintThread()},swapColumns:function(t,e){this.behavior.swapColumns(t,e)},endDragColumnNotification:function(){this.behavior.endDragColumnNotification()},getFixedColumnsMaxWidth:function(){return this.behavior.getFixedColumnsMaxWidth()},isMouseDownInHeaderArea:function(){var t=this.getHeaderColumnCount(),e=this.getHeaderRowCount(),i=this.getMouseDown();return i.x-1,r=e.indexOf("SHIFT")>-1;o||r?(o&&(n?i.deselectColumn(t):i.selectColumn(t)),r&&(i.clear(),i.selectColumn(this.lastEdgeSelection[0],t))):(i.clear(),n||i.selectColumn(t)),n||r||(this.lastEdgeSelection[0]=t),this.repaint(),this.fireSyntheticColumnSelectionChangedEvent()},toggleSelectRow:function(t,e){if(t>this.getFilterRowIndex()){e=e||[];var i=this.selectionModel,n=i.isRowSelected(t),o=e.indexOf("SHIFT")>=0;n?i.deselectRow(t):(this.singleSelect(),i.selectRow(t)),o&&(i.clear(),i.selectRow(this.lastEdgeSelection[1],t)),n||o||(this.lastEdgeSelection[1]=t),this.repaint()}},singleSelect:function(){var t=this.isCheckboxOnlyRowSelections(),e=this.isSingleRowSelectionMode(),i=this.mouseDownState.primitiveEvent.detail.primitiveEvent.ctrlKey,n=t&&e||!t&&(!i||e);return n&&this.selectionModel.clearRowSelection(),n},selectViewportCell:function(t,e){var i=this.getHeaderRowCount(),n=this.getRenderer(),o=n.getVisibleColumns()[t],r=n.getVisibleRows()[e];this.clearSelections(),this.select(o,r+i,0,0),this.setMouseDown(this.newPoint(o,r+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToViewportCell:function(t,e){var i=this.getSelections();if(i&&i.length){var n=this.getHeaderRowCount(),o=this.getRenderer(),r=o.getVisibleColumns()[t],s=o.getVisibleRows()[e]+n,l=i[0],a=l.origin;this.setDragExtent(this.newPoint(r-a.x,s-a.y)),this.select(a.x,a.y,r-a.x,s-a.y),this.repaint()}},selectFinalCellOfCurrentRow:function(){var t=this.getColumnCount()-1,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.scrollBy(this.getColumnCount(),0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFinalCellOfCurrentRow:function(){var t=this.getSelections();if(t&&t.length){var e=t[0],i=e.origin,n=e.extent,o=this.getColumnCount();this.scrollBy(o,0),this.clearSelections(),this.select(i.x,i.y,o-i.x-1,n.y),this.repaint()}},selectFirstCellOfCurrentRow:function(){var t=0,e=this.getSelectedRows()[0],i=this.getHeaderRowCount();this.clearSelections(),this.setHScrollValue(0),this.select(t,e+i,0,0),this.setMouseDown(this.newPoint(t,e+i)),this.setDragExtent(this.newPoint(0,0)),this.repaint()},selectToFirstCellOfCurrentRow:function(){var t=this.getSelections();if(t&&t.length){var e=t[0],i=e.origin,n=e.extent;this.clearSelections(),this.select(i.x,i.y,-i.x,n.y),this.setHScrollValue(0),this.repaint()}},selectFinalCell:function(){this.selectCell(this.getColumnCount()-1,this.getRowCount()-1),this.scrollBy(this.getColumnCount(),this.getRowCount()),this.repaint()},selectToFinalCell:function(){var t=this.getSelections();if(t&&t.length){var e=t[0],i=e.origin,n=this.getColumnCount(),o=this.getRowCount();this.clearSelections(),this.select(i.x,i.y,n-i.x-1,o-i.y-1),this.scrollBy(n,o),this.repaint()}},isShowRowNumbers:function(){return this.resolveProperty("showRowNumbers")},isEditable:function(){return this.resolveProperty("editable")===!0},isShowFilterRow:function(){return this.resolveProperty("showFilterRow")},isShowHeaderRow:function(){return this.resolveProperty("showHeaderRow")},getHeaderRowCount:function(){return this.behavior.getHeaderRowCount()},isFilterRow:function(t){return t===this.getFilterRowIndex()},getFilterRowIndex:function(){return this.isShowFilterRow()?this.isShowHeaderRow()?1:0:-1},setGroups:function(t){this.behavior.setGroups(t)},filterClicked:function(t){this.activateEditor(t.gridCell.x,t.gridCell.y)},hasHierarchyColumn:function(){return this.behavior.hasHierarchyColumn()},isHierarchyColumn:function(t){return this.hasHierarchyColumn()&&0===t},checkScrollbarVisibility:function(){},isColumnOrRowSelected:function(){return this.selectionModel.isColumnOrRowSelected()},selectColumn:function(t,e){this.selectionModel.selectColumn(t,e)},selectRow:function(t,e){var i=this.selectionModel,n=this.getFilterRowIndex()+1;this.singleSelect()?t=e:e=e||t;var o=Math.min(t,e);if(o>=n){var r=Math.max(t,e);i.selectRow(o,r)}},isRowNumberAutosizing:function(){return this.resolveProperty("rowNumberAutosizing")},isRowSelected:function(t){return this.selectionModel.isRowSelected(t)},isColumnSelected:function(t){return this.selectionModel.isColumnSelected(t)},lookupFeature:function(t){return this.behavior.lookupFeature(t)},getRow:function(t){return this.behavior.getRow(t)},getFieldName:function(t){return this.behavior.getFieldName(t)},getColumnIndex:function(t){return this.behavior.getColumnIndex(t)},isCellSelection:function(){return this.resolveProperty("cellSelection")===!0},isRowSelection:function(){return this.resolveProperty("rowSelection")===!0},isColumnSelection:function(){return this.resolveProperty("columnSelection")===!0},getComputedRow:function(t){return this.behavior.getComputedRow(t)},isColumnAutosizing:function(){return this.resolveProperty("columnAutosizing")===!0},setGlobalFilter:function(t){this.behavior.setGlobalFilter(t)},selectRowsFromCells:function(){if(!this.isCheckboxOnlyRowSelections()){var t,e=this.mouseDownState.primitiveEvent.detail.primitiveEvent.ctrlKey;e&&!this.isSingleRowSelectionMode()?this.selectionModel.selectRowsFromCells(0,e):(t=this.selectionModel.getLastSelection())?this.selectRow(null,t.corner.y):this.clearRowSelection()}},selectColumnsFromCells:function(){this.selectionModel.selectColumnsFromCells()},getSelectedRows:function(){return this.behavior.getSelectedRows()},getSelectedColumns:function(){return this.behavior.getSelectedColumns()},getSelections:function(){return this.behavior.getSelections()},getLastSelectionType:function(){return this.selectionModel.getLastSelectionType()},isCellSelected:function(t,e){return this.selectionModel.isCellSelected(t,e)},isInCurrentSelectionRectangle:function(t,e){return this.selectionModel.isInCurrentSelectionRectangle(t,e)},selectAllRows:function(){this.selectionModel.selectAllRows()},areAllRowsSelected:function(){return this.selectionModel.areAllRowsSelected()},toggleSelectAllRows:function(){this.areAllRowsSelected()?this.selectionModel.clear():this.selectAllRows(),this.repaint()},getField:function(t){return this.behavior.getField(t)},isSingleRowSelectionMode:function(){return this.resolveProperty("singleRowSelectionMode")},newPoint:function(t,e){return new g(t,e)},newRectangle:function(t,e,i,n){return new f(t,e,i,n)},getFormattedValue:function(t,e){e+=this.getHeaderRowCount();var i=this.getColumnProperties(t).format,n=this.getValue(t,e),o=this.getFormatter(i),r=o(n);return r}},e.exports=n},{"../css/stylesheets":1,"./defaults":47,"./lib/CustomFilter":68,"./lib/Formatters":69,"./lib/Renderer":71,"./lib/SelectionModel":72,"./lib/TableDialog":73,"./lib/deprecated":74,"extend-me":5,finbars:13,fincanvas:14,"object-iterators":21,rectangular:22}],28:[function(t,e,i){"use strict";var n=t("object-iterators"),o=t("../lib/Base"),r=t("./Column"),s=t("../lib/CellProvider"),l=["columnHeader","columnHeaderColumnSelection","filterProperties","rowHeader","rowHeaderRowSelection","rowNumbersProperties","treeColumnProperties","treeColumnPropertiesColumnSelection"],a={isNull:!0},u=o.extend("Behavior",{initialize:function(t){t.setBehavior(this),this.initializeFeatureChain(t),this.getDataModel(),this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={}},initializeFeatureChain:function(t){var e=this;this.features.forEach(function(t){e.setNextFeature(new t)}),this.featureChain.initializeOn(t)},features:[],tableState:null,grid:null,editorTypes:["choice","textfield","color","slider","spinner","date"],featureChain:null,dataModel:null,baseModel:null,scrollPositionX:0,scrollPositionY:0,featureMap:{},allColumns:[],columns:[],reset:function(){this.cellProvider=this.createCellProvider(),this.renderedColumnCount=30,this.renderedRowCount=60,this.dataUpdates={},this.clearColumns(),this.clearState(),this.getDataModel().reset(),this.createColumns()},clearColumns:function(){this.columns=[],this.allColumns=[],this.columns[-1]=this.newColumn(-1,""),this.columns[-2]=this.newColumn(-2,"Tree"),this.allColumns[-1]=this.columns[-1],this.allColumns[-2]=this.columns[-2]},getColumn:function(t){return this.columns[t]},getColumnId:function(t){return this.getColumn(t).label},newColumn:function(t,e){var i=this.createColumnProperties();return this.getPrivateState().columnProperties[t]=i,new r(this,t,e)},addColumn:function(t,e){var i=this.newColumn(t,e);return this.columns.push(i),this.allColumns.push(i),i},createColumns:function(){},createColumnProperties:function(){var t=this.getPrivateState(),e=Object.create(t);return e.rowNumbersProperties=Object.create(e,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.rowHeader=Object.create(e,{font:{configurable:!0,get:function(){return this.rowHeaderFont},set:function(t){this.rowHeaderFont=t}},color:{configurable:!0,get:function(){return this.rowHeaderColor},set:function(t){this.rowHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundColor},set:function(t){this.rowHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundSelectionColor},set:function(t){this.rowHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundSelectionColor},set:function(t){this.rowHeaderBackgroundSelectionColor=t}}}),e.columnHeader=Object.create(e,{format:{value:"default"},font:{configurable:!0,get:function(){return this.columnHeaderFont},set:function(t){this.columnHeaderFont=t}},color:{configurable:!0,get:function(){return this.columnHeaderColor},set:function(t){this.columnHeaderColor=t}},backgroundColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColor},set:function(t){this.columnHeaderBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundSelectionColor},set:function(t){this.columnHeaderForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundSelectionColor},set:function(t){this.columnHeaderBackgroundSelectionColor=t}}}),e.columnHeaderColumnSelection=Object.create(e.columnHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderForegroundColumnSelectionColor},set:function(t){this.columnHeaderForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.columnHeaderBackgroundColumnSelectionColor},set:function(t){this.columnHeaderBackgroundColumnSelectionColor=t}}}),e.rowHeaderRowSelection=Object.create(e.rowHeader,{foregroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderForegroundRowSelectionColor},set:function(t){this.rowHeaderForegroundRowSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.rowHeaderBackgroundRowSelectionColor},set:function(t){this.rowHeaderBackgroundRowSelectionColor=t}}}),e.filterProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.filterFont},set:function(t){this.filterFont=t}},color:{configurable:!0,get:function(){return this.filterColor},set:function(t){this.filterColor=t}},backgroundColor:{configurable:!0,get:function(){return this.filterBackgroundColor},set:function(t){this.filterBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.filterForegroundSelectionColor},set:function(t){this.filterForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.filterBackgroundSelectionColor},set:function(t){this.filterBackgroundSelectionColor=t}},cellBorderStyle:{configurable:!0,get:function(){return this.filterCellBorderStyle},set:function(t){this.filterCellBorderStyle=t}},cellBorderThickness:{configurable:!0,get:function(){return this.filterCellBorderThickness},set:function(t){this.filterCellBorderThickness=t}}}),e.treeColumnProperties=Object.create(e,{font:{configurable:!0,get:function(){return this.treeColumnFont},set:function(t){this.treeColumnFont=t}},color:{configurable:!0,get:function(){return this.treeColumnColor},set:function(t){this.treeColumnColor=t}},backgroundColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColor},set:function(t){this.treeColumnBackgroundColor=t}},foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundSelectionColor},set:function(t){this.treeColumnForegroundSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundSelectionColor},set:function(t){this.treeColumnBackgroundSelectionColor=t}}}),e.treeColumnPropertiesColumnSelection=Object.create(e.treeColumnProperties,{foregroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnForegroundColumnSelectionColor},set:function(t){this.treeColumnForegroundColumnSelectionColor=t}},backgroundSelectionColor:{configurable:!0,get:function(){return this.treeColumnBackgroundColumnSelectionColor},set:function(t){this.treeColumnBackgroundColumnSelectionColor=t}}}),e},getColumnWidth:function(t){var e=this.getColumn(t);if(!e)return this.resolveProperty("defaultColumnWidth");var i=e.getWidth();return i},setColumnWidth:function(t,e){this.getColumn(t).setWidth(e),this.stateChanged()},getDataModel:function(){if(null===this.dataModel){var t=this.getDefaultDataModel();this.setDataModel(t)}return this.dataModel},getCellRenderer:function(t,e,i){return this.getColumn(e).getCellRenderer(t,i)},setDataModel:function(t){this.dataModel=t},setComplexFilter:function(t,e){var i=this.getColumn(t);i&&i.setComplexFilter(e)},getComplexFilter:function(t){var e=this.getColumn(t);return e&&e.getComplexFilter()},applyAnalytics:function(){},clearObjectProperties:function(t,e){for(var i in t)t.hasOwnProperty(i)&&(void 0===e||!e&&l.indexOf(i)>=0||e&&l.indexOf(i)<0)&&delete t[i]},getPrivateState:function(){return this.tableState||(this.tableState=this.getDefaultState()),this.tableState},getState:function(){var t=JSON.parse(JSON.stringify(this.getPrivateState()));return this.clearObjectProperties(t.columnProperties,!1),t},clearState:function(){this.tableState=null},getDefaultState:function(){var t=this.grid._getProperties(),e=Object.create(t);return n(e).extendOwn({rowHeights:{},cellProperties:{},columnProperties:[]}),e},setState:function(t){if(!t.columnIndexes){var e=this.getFields();t.columnIndexes=[];for(var i=0;ii;i++)e+=this.getRowHeight(i);return e},getRowHeight:function(t){var e=this.getPrivateState().rowHeights;return e&&e[t]||this.getDefaultRowHeight()},getDefaultRowHeight:function(){return this.defaultRowHeight||(this.defaultRowHeight=this.resolveProperty("defaultRowHeight")),this.defaultRowHeight},setRowHeight:function(t,e){var i=this.getPrivateState();i.rowHeights[t]=Math.max(5,e),this.stateChanged()},getFixedRowsMaxHeight:function(){return this.getFixedRowsHeight()},getFixedColumnsWidth:function(){var t=this.getFixedColumnCount(),e=0;this.grid.isShowRowNumbers()&&(e=this.getColumnWidth(-1));for(var i=0;t>i;i++)e+=this.getColumnWidth(i);return e},getFixedColumnsMaxWidth:function(){return this.getFixedColumnsWidth()},_setScrollPositionY:function(t){this.setScrollPositionY(t),this.changed()},_setScrollPositionX:function(t){this.setScrollPositionX(t),this.changed()},setRenderedColumnCount:function(t){this.renderedColumnCount=t},setRenderedRowCount:function(t){this.renderedRowCount=t},_fixedRowClicked:function(t,e){var i=this.translateColumnIndex(this.getScrollPositionX()+e.gridCell.x-this.getFixedColumnCount()),n=this.grid.newPoint(i,e.gridCell.y);e.gridCell=n,this.fixedRowClicked(t,e)},_fixedColumnClicked:function(t,e){var i=this.grid.newPoint(e.gridCell.x,this.getScrollPositionY()+e.gridCell.y-this.getFixedRowCount());e.gridCell=i,this.fixedColumnClicked(t,e)},moveSingleSelect:function(t,e,i){this.featureChain&&(this.featureChain.moveSingleSelect(t,e,i),this.setCursor(t))},setCursor:function(t){t.updateCursor(),this.featureChain.setCursor(t)},onMouseMove:function(t,e){this.featureChain&&(this.featureChain.handleMouseMove(t,e),this.setCursor(t))},onTap:function(t,e){this.featureChain&&(this.featureChain.handleTap(t,e),this.setCursor(t))},onContextMenu:function(t,e){var i=t.fireSyntheticContextMenuEvent(e);i&&this.featureChain&&(this.featureChain.handleContextMenu(t,e),this.setCursor(t))},onWheelMoved:function(t,e){this.featureChain&&(this.featureChain.handleWheelMoved(t,e),this.setCursor(t))},onMouseUp:function(t,e){this.featureChain&&(this.featureChain.handleMouseUp(t,e),this.setCursor(t))},onMouseDrag:function(t,e){this.featureChain&&(this.featureChain.handleMouseDrag(t,e),this.setCursor(t))},onKeyDown:function(t,e){this.featureChain&&(this.featureChain.handleKeyDown(t,e),this.setCursor(t))},onKeyUp:function(t,e){this.featureChain&&(this.featureChain.handleKeyUp(t,e),this.setCursor(t))},onDoubleClick:function(t,e){this.featureChain&&(this.featureChain.handleDoubleClick(t,e),this.setCursor(t))},onHoldPulse:function(t,e){this.featureChain&&(this.featureChain.handleHoldPulse(t,e),this.setCursor(t))},toggleColumnPicker:function(){var t=this.grid.dialog,e=this;t.isOpen()?t.close():(this.buildColumnPicker(t.overlay),t.onClose=function(){e.updateFromColumnPicker(t.overlay)},t.open())},handleMouseDown:function(t,e){this.featureChain&&(this.featureChain.handleMouseDown(t,e),this.setCursor(t))},handleMouseExit:function(t,e){this.featureChain&&(this.featureChain.handleMouseExit(t,e),this.setCursor(t))},changed:function(){},shapeChanged:function(){},isColumnReorderable:function(){return!0},getColumnProperties:function(t){var e=this.columns[t];if(!e)return a;var i=e.getProperties();return i?i:a},setColumnProperties:function(t,e){var i=this.allColumns[t].getProperties();n(i).extendOwn(e),this.changed()},getField:function(t){return-1===t?"tree":this.getColumn(t).getField()},getHeader:function(t){return-1===t?"Tree":this.getColumn(t).getHeader()},setColumnDescriptors:function(t){var e,i=t.visible,n=this.getPrivateState(),o=i.length,r=[];for(e=0;o>e;e++)r.push(i[e].id);n.columnIndexes=r,this.changed()},getHiddenColumnDescriptors:function(){for(var t=this.getPrivateState(),e=t.columnIndexes,i=[],n=this.getColumnCount(),o=0;n>o;o++)-1===e.indexOf(o)&&i.push({id:o,label:this.getHeader(o),field:this.getField(o)});return i},hideColumns:function(t){for(var e=this.getPrivateState(),i=e.columnIndexes,n=0;ns;s++)if(i=this.getValue(s),n=this.typeOf(i),o!==n){if(!r||"number"!=typeof i)return"mixed";o="float"}return o},typeOf:function(t){var e=typeof t;switch(e){case"object":return t.constructor.name.toLowerCase();case"number":return parseInt(t)===t?"int":"float";default:return e}},getProperties:function(){return this.behavior.getPrivateState().columnProperties[this.index]},setProperties:function(t){var e=this.behavior.getPrivateState().columnProperties[this.index];this.clearObjectProperties(e,!1),o(e).extendOwn(t)},toggleSort:function(t){this.dataModel.toggleSort(this.index,t)},getCellEditorAt:function(t,e){return this.dataModel.getCellEditorAt(this.index,e); +},getHeader:function(){return this.label},getField:function(){return this.dataModel.getFields()[this.index]}},e.exports=n},{"object-iterators":21}],30:[function(t,e,i){"use strict";function n(t,e){this.setComponent(e),this.setGrid(t)}var o=t("../lib/deprecated");n.prototype={constructor:n.prototype.constructor,deprecated:o,component:null,grid:null,getGrid:function(){return this.deprecated("grid",{since:"0.2"})},setGrid:function(t){this.grid=t,this.getComponent().setGrid(t)},getBehavior:function(){return this.deprecated("grid.behavior",{since:"0.2"})},changed:function(){this.grid.behavior.changed()},getPrivateState:function(){return this.grid.getPrivateState()},applyState:function(){},setComponent:function(t){this.component=t},getComponent:function(){return this.component},setGlobalFilter:function(t){return this.getComponent().setGlobalFilter(t)},getData:function(){return this.getComponent().getData()},getFilteredData:function(){return this.getComponent().getFilteredData()},getValue:function(t,e){return this.getComponent().getValue(t,e)},getUnfilteredValue:function(t,e){return this.getComponent().getUnfilteredValue(t,e)},setValue:function(t,e,i){this.getComponent().setValue(t,e,i)},getColumnCount:function(){return this.getComponent().getColumnCount()},applyAnalytics:function(){return this.getComponent().applyAnalytics()},getRowCount:function(){return this.getComponent().getRowCount()},getCellRenderer:function(t,e,i,n,o){return this.getComponent().getCellRenderer(t,e,i,n,o)},getRowHeight:function(t){return this.getComponent().getRowHeight(t)},getColumnEdge:function(t,e){return this.getComponent().getColumnEdge(t,e)},getColumnWidth:function(t){return this.getComponent().getColumnWidth(t)},setColumnWidth:function(t,e){this.getComponent().setColumnWidth(t,e)},toggleSort:function(t,e){this.getComponent().toggleSort(t,e)},getColumnProperties:function(t){return this.getComponent().getColumnProperties(t)},setColumnProperties:function(t,e){this.getComponent().setColumnProperties(t,e)},getHeaders:function(){return this.getComponent().getHeaders()},getFields:function(){return this.getComponent().getFields()},setFields:function(t){this.getComponent().setFields(t)},getCellProperties:function(t,e){return this.getComponent().getCellProperties(t,e)},setCellProperties:function(t,e,i){this.getComponent().setCellProperties(t,e,i)},getRow:function(t){return this.getComponent().getRow(t)},getTopTotals:function(){return this.getComponent().getTopTotals()},setTopTotals:function(t){this.getComponent().setTopTotals(t)},getBottomTotals:function(){return this.getComponent().getBottomTotals()},setBottomTotals:function(t){this.getComponent().setBottomTotals(t)},setData:function(t){return this.getComponent().setData(t)},hasHierarchyColumn:function(){return this.getComponent().hasHierarchyColumn()},setHeaders:function(t){return this.getComponent().setHeaders(t)},cellClicked:function(t,e){return this.getComponent().cellClicked(t,e)},getAvailableGroups:function(){return this.getComponent().getAvailableGroups()},getGroups:function(){return this.getComponent().getGroups()},setGroups:function(t){this.getComponent().setGroups(t)},getHiddenColumns:function(){return this.getComponent().getHiddenColumns()},getVisibleColumns:function(){return this.getComponent().getVisibleColumns()},setAggregates:function(t){return this.getComponent().setAggregates(t)},reset:function(){this.getComponent().reset()},getCellEditorAt:function(t,e){return this.getComponent().getCellEditorAt(t,e)},getUnfilteredRowCount:function(){return this.getComponent().getUnfilteredRowCount()}},e.exports=n},{"../lib/deprecated":74}],31:[function(t,e,i){"use strict";var n=t("list-dragon"),o=t("./Local"),r=t("./DataModelDecorator"),s=t("../dataModels/JSON"),l=t("../features"),a=t("../../css/stylesheets"),u=t("../local_node_modules/finanalytics").aggregations,c=o.extend("behaviors.JSON",{initialize:function(t,e){this.setData(e)},features:[l.CellSelection,l.KeyPaging,l.ColumnPicker,l.ColumnResizing,l.RowResizing,l.Filters,l.RowSelection,l.ColumnSelection,l.ColumnMoving,l.ColumnSorting,l.CellEditing,l.CellClick,l.OnHover],aggregations:u,createColumns:function(){var t=this.getDataModel(),e=t.getColumnCount(),i=t.getHeaders(),n=t.getFields();this.clearColumns();for(var o=0;e>o;o++){var r=i[o],s=this.addColumn(o,r),l=s.getProperties();l.field=n[o],l.header=r,l.complexFilter=null}},getDefaultDataModel:function(){return new r(this.grid,new s)},applyAnalytics:function(){this.dataModel.applyAnalytics()},setHeaders:function(t){this.getDataModel().setHeaders(t)},getHeaders:function(){return this.getDataModel().getHeaders()},setFields:function(t){this.getDataModel().setFields(t),this.createColumns()},getFields:function(){return this.getDataModel().getFields()},setData:function(t){this.getDataModel().setData(t),this.createColumns();var e=this;this.grid.isColumnAutosizing()?(setTimeout(function(){e.autosizeAllColumns()},100),e.changed()):setTimeout(function(){e.allColumns[-1].checkColumnAutosizing(!0),e.changed()})},setTopTotals:function(t){this.getDataModel().setTopTotals(t)},getTopTotals:function(){return this.getDataModel().getTopTotals()},setBottomTotals:function(t){this.getDataModel().setBottomTotals(t)},getBottomTotals:function(){return this.getDataModel().getBottomTotals()},setColumns:function(t){this.getDataModel().setColumns(t)},enhanceDoubleClickEvent:function(t){t.row=this.getRow(t.gridCell.y)},setDataProvider:function(t){this.getDataModel().setDataProvider(t)},hasHierarchyColumn:function(){return this.getDataModel().hasHierarchyColumn()},getColumnAlignment:function(t){return 0===t&&this.hasHierarchyColumn()?"left":"center"},getRowSelectionMatrix:function(t){return this.getDataModel().getRowSelectionMatrix(t)},getColumnSelectionMatrix:function(t){return this.getDataModel().getColumnSelectionMatrix(t)},getSelectionMatrix:function(t){return this.getDataModel().getSelectionMatrix(t)},getRowSelection:function(){var t=this.getSelectedRows();return this.getDataModel().getRowSelection(t)},getColumnSelection:function(){var t=this.getSelectedColumns();return this.getDataModel().getColumnSelection(t)},getSelection:function(){var t=this.getSelections();return this.getDataModel().getSelection(t)},buildColumnPicker:function(t){if(!this.isColumnReorderable())return!1;var e={cssStylesheetReferenceElement:t},i={models:this.getGroups(),title:"Groups"},o={models:this.getAvailableGroups(),title:"Available Groups"},r={models:this.getHiddenColumns(),title:"Hidden Columns"},s={models:this.getVisibleColumns(),title:"Visible Columns"},l=new n([i,o],e),u=new n([r,s],e),c=[l,u];return a("list-dragon",t),c.forEach(function(e){e.modelLists.forEach(function(e){t.appendChild(e.container)})}),t.lists={group:i.models,availableGroups:o.models,hidden:r.models,visible:s.models},!0},getGroups:function(){return this.getDataModel().getGroups()},getAvailableGroups:function(){return this.getDataModel().getAvailableGroups()},getHiddenColumns:function(){return this.getDataModel().getHiddenColumns()},getVisibleColumns:function(){return this.getDataModel().getVisibleColumns()},setColumnDescriptors:function(t){var e=this.columns[0];this.columns.length=0,e&&"Tree"===e.label&&this.columns.push(e);for(var i=0;ia;a++){var u=t.getUnfilteredValue(s,a);l.set(u,u)}var c=l.values;c.sort(),c.length>0&&c[0].length>0&&c.unshift(""),this.setItems(c)}},showEditor:function(){var t=this;this.input.style.display="inline",setTimeout(function(){t.showDropdown(t.input)},50)},preShowEditorNotification:function(){this.autopopulate(),this.setEditorValue(this.initialValue)},setItems:function(t){this.items=t,this.updateView()},initializeInput:function(t){var e=this;n.prototype.initializeInput.apply(this,[t]),t.onchange=function(){e.stopEditing()}}});e.exports=r},{"../lib/Mappy":70,"./Simple":40}],37:[function(t,e,i){"use strict";var n=t("./Simple"),o=n.extend("Color",{alias:"color",template:function(){}});e.exports=o},{"./Simple":40}],38:[function(t,e,i){"use strict";function n(t){var e=t.match(/(\d+)/g);return new window.Date(e[0],e[1]-1,e[2])}var o=t("./Simple"),r=t("../lib/Formatters"),s=o.extend("Date",{alias:"date",template:function(){},setEditorValue:function(t){null!=t&&"Date"===t.constructor.name&&(t=r.date(t)),this.getInput().value=t+""},getEditorValue:function(){var t=this.getInput().value;return t=n(t)}});e.exports=s},{"../lib/Formatters":69,"./Simple":40}],39:[function(t,e,i){"use strict";var n=t("./CellEditor"),o=n.extend("Filter",{alias:"filter",initialize:function(){var t=document.createElement("div"),e=t.style;e.position="absolute",e.top=e.bottom="44px",e.right=e.left="1em",e.overflowY="scroll";var i=document.createElement("table");t.appendChild(i),e=i.style,e.width=e.height="100%";var n=document.createElement("tr"),o=document.createElement("td");i.appendChild(n),n.appendChild(o),this.title=document.createElement("div"),this.title.innerHTML="Filter Editor",this.dialog=document.createElement("div"),this.content=o,this.buttons=document.createElement("div"),e=this.dialog.style,e.position="absolute",e.top=e.left=e.right=e.bottom=0,e.whiteSpace="nowrap",e=this.title.style,e.position="absolute",e.top=e.left=e.right=0,e.height="44px",e.whiteSpace="nowrap",e.textAlign="center",e.padding="11px",e=this.buttons.style,e.position="absolute",e.left=e.right=e.bottom=0,e.height="44px",e.whiteSpace="nowrap",e.textAlign="center",e.padding="8px",this.dialog.appendChild(this.title),this.dialog.appendChild(t),this.dialog.appendChild(this.buttons),this.ok=document.createElement("button"),this.ok.style.borderRadius="8px",this.ok.style.width="5.5em",this.cancel=document.createElement("button"),this.cancel.style.marginLeft="2em",this.cancel.style.borderRadius="8px",this.cancel.style.width="5.5em",this["delete"]=document.createElement("button"),this["delete"].style.marginLeft="2em",this["delete"].style.borderRadius="8px",this["delete"].style.width="5.5em",this.reset=document.createElement("button"),this.reset.style.marginLeft="2em",this.reset.style.borderRadius="8px",this.reset.style.width="5.5em",this.ok.innerHTML="ok",this.cancel.innerHTML="cancel",this["delete"].innerHTML="delete",this.reset.innerHTML="reset",this.buttons.appendChild(this.ok),this.buttons.appendChild(this.reset),this.buttons.appendChild(this["delete"]),this.buttons.appendChild(this.cancel);var r=this;this.ok.onclick=function(){r.okPressed()},this.cancel.onclick=function(){r.cancelPressed()},this["delete"].onclick=function(){r.deletePressed()},this.reset.onclick=function(){r.resetPressed()}},tearDown:function(){this.content.innerHTML=""},okPressed:function(){var t=this.grid.dialog;t.onOkPressed()},cancelPressed:function(){var t=this.grid.dialog;t.onCancelPressed()},deletePressed:function(){var t=this.grid.dialog;t.onDeletePressed()},resetPressed:function(){var t=this.grid.dialog;t.onResetPressed()},beginEditAt:function(t){var e=this.grid.behavior,i=this.grid.dialog,n=t.x,o=e.getColumnId(n),r=e.getField(n),s=e.getColumn(n).getType(),l=function(){return[{name:r,alias:o,type:s}]};this.title.innerHTML="Manage Filters";var a=this.grid.filter;if(i.isOpen())i.close();else{var u=this;i.clear(),i.overlay.appendChild(this.dialog),a.initialize(l),i.onOkPressed=function(){a.onOk&&a.onOk()||(u.tearDown(),e.setComplexFilter(n,{state:a.getState()}),i.close(),e.applyAnalytics(),e.changed())},i.onCancelPressed=function(){a.onCancel&&a.onCancel()||(u.tearDown(),i.close(),a=void 0)},i.onDeletePressed=function(){a.onDelete&&a.onDelete()||(u.tearDown(),e.setComplexFilter(n,void 0),i.close(),e.applyAnalytics(),e.changed())},i.onResetPressed=function(){a.onReset&&a.onReset()||(u.tearDown(),a.initialize(i),a.onShow&&a.onShow(u.content))};var c=this.grid._getBoundsOfCell(n,t.y),h=this.grid.div.getBoundingClientRect().left-this.grid.divCanvas.getBoundingClientRect().left;c.x=c.x-h,i.openFrom(c);var d=e.getComplexFilter(n);d&&a.setState(d.state),setTimeout(function(){a.onShow&&a.onShow(u.content)},i.getAnimationTime()+10)}}});e.exports=o},{"./CellEditor":35}],40:[function(t,e,i){"use strict";var n=t("./CellEditor.js"),o=n.extend("Simple",{input:null,alias:"simple",initialize:function(){this.editorPoint={x:0,y:0}},specialKeyups:{9:"stopEditing",13:"stopEditing",27:"cancelEditing"},keyup:function(t){if(t){var e=this.specialKeyups[t.keyCode];e&&(t.preventDefault(),this[e](),this.grid.repaint(),this.grid.takeFocus()),this.grid.fireSyntheticEditorKeyUpEvent(this,t)}},initializeInput:function(t){var e=this;t.addEventListener("keyup",this.keyup.bind(this)),t.addEventListener("keydown",function(t){e.grid.fireSyntheticEditorKeyDownEvent(e,t)}),t.addEventListener("keypress",function(t){e.grid.fireSyntheticEditorKeyPressEvent(e,t)}),t.onblur=function(t){e.cancelEditing()},t.style.position="absolute",t.style.display="none",t.style.border="solid 2px black",t.style.outline=0,t.style.padding=0,t.style.boxShadow="white 0px 0px 1px 1px"},getEditorValue:function(){var t=this.getInput().value;return t},setEditorValue:function(t){this.getInput().value=t},clearStopEditing:function(){this.setEditorValue(""),this.stopEditing()},cancelEditing:function(){this.isEditing&&(this.getInput().value=null,this.isEditing=!1,this.hideEditor())},showEditor:function(){this.getInput().style.display="inline"},hideEditor:function(){this.getInput().style.display="none"},takeFocus:function(){var t=this;setTimeout(function(){var e=t.input.style.transform;t.input.style.transform="translate(0,0)",t.input.focus(),t.selectAll(),t.input.style.transform=e})},selectAll:function(){},originOffset:function(){return[0,0]},setBounds:function(t){var e=this.originOffset(),i="translate("+(t.x-1+e[0])+"px,"+(t.y-1+e[1])+"px)",n=this.getInput();n.style.boxSizing="border-box",n.style.webkitTransform=i,n.style.MozTransform=i,n.style.msTransform=i,n.style.OTransform=i,n.style.width=t.width+2+"px",n.style.height=t.height+2+"px"},saveEditorValue:function(){var t=this.getEditorPoint(),e=this.getEditorValue();if(e!==this.initialValue){parseFloat(this.initialValue)===this.initialValue&&(e=parseFloat(e));var i=this.grid.fireBeforeCellEdit(t,this.initialValue,e,this);i&&(this.grid.behavior.setValue(t.x,t.y,e),this.grid.fireAfterCellEdit(t,this.initialValue,e,this))}},_moveEditor:function(){var t=this.getEditorPoint(),e=this.grid._getBoundsOfCell(t.x,t.y),i=this.grid.div.getBoundingClientRect().left-this.grid.divCanvas.getBoundingClientRect().left;e.x=e.x-i,this.setBounds(e)},moveEditor:function(){this._moveEditor(),this.takeFocus()},beginEditAt:function(t){this.isAdded||(this.isAdded=!0,this.attachEditor()),this.setEditorPoint(t);var e=this.grid.behavior.getValue(t.x,t.y);"Array"===e.constructor.name&&(e=e[1]);var i=this.grid.fireRequestCellEdit(t,e);i&&(this.initialValue=e,this.isEditing=!0,this.setCheckEditorPositionFlag(),this.checkEditor())},checkEditor:function(){if(this.checkEditorPositionFlag&&(this.checkEditorPositionFlag=!1,this.isEditing)){var t=this.getEditorPoint();this.grid.isDataVisible(t.x,t.y)?(this.preShowEditorNotification(),this.attachEditor(),this.moveEditor(),this.showEditor()):this.hideEditor()}},attachEditor:function(){var t=this.getInput(),e=this.grid.div,i=e.querySelectorAll(".finbar-horizontal, .finbar-vertical");e.insertBefore(t,i.length?i[0]:null)},preShowEditorNotification:function(){this.setEditorValue(this.initialValue)},getInput:function(){return this.input||(this.input=this.getDefaultInput()),this.input},getDefaultInput:function(){var t=document.createElement("DIV");t.innerHTML=this.getHTML();var e=t.firstChild;return this.initializeInput(e),e},updateView:function(){var t=this.getInput(),e=t.parentNode,i=this.getDefaultInput();this.input=i,e.replaceChild(i,t)},showDropdown:function(t){var e;e=document.createEvent("MouseEvents"),e.initMouseEvent("mousedown",!0,!0,window),t.dispatchEvent(e)}});e.exports=o},{"./CellEditor.js":35}],41:[function(t,e,i){"use strict";var n=t("./Simple"),o=n.extend("Slider",{alias:"slider",template:function(){}});e.exports=o},{"./Simple":40}],42:[function(t,e,i){"use strict";var n=t("./Simple"),o=n.extend("Spinner",{alias:"spinner",template:function(){}});e.exports=o},{"./Simple":40}],43:[function(t,e,i){"use strict";function n(){this.saveEditorValue(),this._moveEditor()}var o=t("./Simple"),r=o.extend("Textfield",{alias:"textfield",template:function(){},selectAll:function(){this.input.setSelectionRange(0,this.input.value.length)},specialKeyups:{9:"stopEditing",13:"stopEditing",27:"cancelEditing"},keyup:function(t){t&&(o.prototype.keyup.call(this,t),this.grid.isFilterRow(this.getEditorPoint().y)&&setTimeout(n.bind(this)))}});e.exports=r},{"./Simple":40}],44:[function(t,e,i){"use strict";e.exports={CellEditor:t("./CellEditor"),Textfield:t("./Textfield"),Choice:t("./Choice"),Color:t("./Color"),Date:t("./Date"),Simple:t("./Simple"),Slider:t("./Slider"),Spinner:t("./Spinner"),Filter:t("./Filter")}},{"./CellEditor":35,"./Choice":36,"./Color":37,"./Date":38,"./Filter":39,"./Simple":40,"./Slider":41,"./Spinner":42,"./Textfield":43}],45:[function(t,e,i){"use strict";var n=t("../lib/Base"),o="A".charCodeAt(0),r=n.extend("DataModel",{next:null,grid:null,setGrid:function(t){this.grid=t},getGrid:function(){return this.deprecated("grid",{since:"0.2"})},getBehavior:function(){return this.deprecated("grid.behavior",{since:"0.2"})},changed:function(){this.grid.behavior.changed()},getPrivateState:function(){return this.grid.getPrivateState()},applyState:function(){},alphaFor:function(t){var e=Math.floor(t/26),i=t%26,n="";return e>0&&(n+=this.alpha(e-1)),n+=this.alpha(i)},alpha:function(t){return String.fromCharCode(o+t)},getCellEditorAt:function(t,e){}});e.exports=r},{"../lib/Base":66}],46:[function(t,e,i){"use strict";function n(t){return"function"==typeof t?t():t}function o(t){return t=t.toLowerCase(),function(e){return e=n(e),(e+"").toLowerCase().indexOf(t)>-1}}function r(){var t=this.selectedData,e=this.grid.selectionModel.hasRowSelections(),i=t.length||e;if(i)var n=this.getFilteredData();t.forEach(function(e,i){n.indexOf(e)>=0&&delete t[i]}),e&&this.grid.getSelectedRows().forEach(function(e){var i=n[e];t.indexOf(i)<0&&t.push(i)})}function s(){if(this.selectedData.length){var t=this.grid.selectionModel,e=this.grid.getHeaderRowCount(),i=this.getFilteredData();t.clearRowSelection(),this.selectedData.forEach(function(n){var o=i.indexOf(n);o>=0&&t.selectRow(e+o)})}}function l(){0===this.analytics.aggregates.length&&this.quietlySetAggregates({}),this.analytics.apply()}function a(){var t=this.getVisibleColumns();this.getGlobalFilterSource().apply(t);var e=[],i=this.getFilterSource(),n=0;i.clearAll(),t.forEach(function(t){var r=t.index,s=this.getFilter(r),l=t.getProperties().format,a=this.grid.getFormatter(l),u=this.getComplexFilter(r),c=u||s.length>0&&o(s);c&&(i.add(r-n,this.createFormattedFilter(a,c)),e.push({column:t.label,format:u?"complex":l}))}.bind(this)),i.applyAll(),this.grid.fireSyntheticFilterAppliedEvent({details:e})}function u(){var t=this.getSortingSource(),e=this.getPrivateState().sorts,i=this.hasAggregates()?1:0;if(e&&0!==e.length)for(var n=0;nn;n++)i[n]=t.getRow(n);return i},getValue:function(t,e){var i,n=this.hasHierarchyColumn(),o=this.grid.getHeaderRowCount();return n?-2===t&&(t=0):this.hasAggregates()&&(t+=1),i=o>e?this.getHeaderRowValue(t,e):this.getDataSource().getValue(t,e-o)},getHeaderRowValue:function(t,e){var i;if(void 0===e)i=this.getHeaders()[Math.max(t,0)];else if(0>e){var n=this.getBottomTotals();i=n[n.length+e][t]}else{var o=this.grid.isShowFilterRow(),r=this.grid.isShowHeaderRow(),s=(o?1:0)+(r?1:0);if(e>=s)i=this.getTopTotals()[e-s][t];else{if(!r||0!==e){i=this.getFilter(t);var l=d.filter(i.length);return[null,i,l]}i=this.getHeaders()[t];var a=this.getSortImageForColumn(t);a&&(i=a+i)}}return i},setValue:function(t,e,i){var n=this.hasHierarchyColumn(),o=this.grid.getHeaderRowCount();n?-2===t&&(t=0):this.hasAggregates()&&(t+=1),o>e?this.setHeaderRowValue(t,e,i):this.getDataSource().setValue(t,e-o,i),this.changed()},setHeaderRowValue:function(t,e,i){if(void 0===i)return this._setHeader(t,e);var n=this.grid.isShowFilterRow(),o=this.grid.isShowHeaderRow(),r=n&&o,s=(n?1:0)+(o?1:0);if(e>=s)this.getTopTotals()[e-s][t]=i;else{if(-1===t)return;if(r){if(0===e)return this._setHeader(t,i);this.setFilter(t,i)}else{if(!n)return this._setHeader(t,i);this.setFilter(t,i)}}return""},getColumnProperties:function(t){var e=this.grid.behavior.allColumns[t];return e?e.getProperties():void 0},getFilter:function(t){var e,i;return(i=this.getColumnProperties(t))&&(e=i.filter),e||""},getComplexFilter:function(t){var e,i,o,r,s;return(i=this.getColumnProperties(t))&&(o=i.complexFilter)&&(r=this.grid.filter)&&(s=r.create(o.state))&&(e=function(t){var e=n(t);return s(e)}),e},setFilter:function(t,e){var i=this.getColumnProperties(t);i.filter=e,this.applyAnalytics()},getColumnCount:function(){var t=this.grid.resolveProperty("showTreeColumn")===!0,e=this.hasAggregates(),i=e&&!t?-1:0;return this.analytics.getColumnCount()+i},getRowCount:function(){var t=this.getDataSource().getRowCount();return t+=this.grid.getHeaderRowCount()},getHeaders:function(){return this.analytics.getHeaders()},setHeaders:function(t){this.getDataSource().setHeaders(t)},setFields:function(t){this.getDataSource().setFields(t)},getFields:function(){return this.getDataSource().getFields()},setData:function(t){this.source=new c.JSDataSource(t),this.analytics=new c.DataSourceAggregator(this.source),this.postglobalfilter=new c.DataSourceGlobalFilter(this.analytics),this.postfilter=new c.DataSourceFilter(this.postglobalfilter),this.postsorter=new c.DataSourceSorterComposite(this.postfilter),this.applyAnalytics()},setTopTotals:function(t){this.topTotals=t},getTopTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.topTotals},setBottomTotals:function(t){this.bottomTotals=t},getBottomTotals:function(){return this.hasAggregates()?this.getDataSource().getGrandTotals():this.bottomTotals},setGroups:function(t){this.analytics.setGroupBys(t),this.applyAnalytics(),this.grid.fireSyntheticGroupsChangedEvent(this.getGroups())},getGroups:function(){for(var t=this.getHeaders().slice(0),e=this.getFields().slice(0),i=this.analytics.groupBys,n=[],o=0;o-1;i.sorts=i.sorts||[];var o=i.sorts.indexOf(t);-1===o&&(o=i.sorts.indexOf(-1*t)),o>-1?i.sorts[o]>0?i.sorts[o]=-1*i.sorts[o]:i.sorts.splice(o,1):n||0===i.sorts.length?i.sorts.unshift(t):(i.sorts.length=0,i.sorts.unshift(t)),i.sorts.length>3&&(i.sorts.length=3)},getSortImageForColumn:function(t){t++;var e=!0,i=this.getPrivateState().sorts;if(!i)return null;var n=i.indexOf(t);if(0>n&&(n=i.indexOf(-1*t),e=!1),0>n)return null;var o=i.length-n,r=e?g:f;return o+r+" "},cellClicked:function(t,e){if(this.hasAggregates()&&0===e.gridCell.x){var i=this.grid.getHeaderRowCount(),n=e.gridCell.y-i;this.getDataSource().click(n),this.applyAnalytics(!0),this.changed()}},getRow:function(t){var e=this.grid.getHeaderRowCount();if(e>t&&!this.hasAggregates()){var i=this.getTopTotals();return i[t-(e-i.length)]}return this.getDataSource().getRow(t-e)},buildRow:function(t){var e=this.getColumnCount(),i=[].concat(this.getFields()),n={};this.hasAggregates()&&(n.tree=this.getValue(-2,t),i.shift());for(var o=0;e>o;o++)n[i[o]]=this.getValue(o,t);return n},getComputedRow:function(t){for(var e=this.getRowContextFunction([t]),i=this.getFields(),n={},o=0;o=t.behavior.getHeaderRowCount()&&e.gridCell.x>=t.behavior.getHeaderColumnCount()?t.cellClicked(e):this.next&&this.next.handleTap(t,e)}});e.exports=o},{"./Feature.js":58}],50:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellEditing",{alias:"CellEditing",handleDoubleClick:function(t,e){var i=t.resolveProperty("editOnDoubleClick");this.checkActivateEditor(t,e,i)?t._activateEditor(e):this.next&&this.next.handleDoubleClick(t,e)},handleTap:function(t,e){var i=t.resolveProperty("editOnDoubleClick");this.checkActivateEditor(t,e,!i)?t._activateEditor(e):this.next&&this.next.handleTap(t,e)},handleHoldPulse:function(t,e){var i=t.resolveProperty("editOnDoubleClick");this.checkActivateEditor(t,e,!i)?t._activateEditor(e):this.next&&this.next.handleHoldPulse(t,e)},checkActivateEditor:function(t,e,i){var n=t.behavior.getHeaderRowCount(),o=t.behavior.getHeaderColumnCount(),r=e.gridCell,s=t.isFilterRow(r.y),l=i&&r.x>=o&&(s||r.y>=n);return l}});e.exports=o},{"./Feature.js":58}],51:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("CellSelection",{alias:"CellSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleMouseDown:function(t,e){var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,o=e.viewPoint,r=n.x,s=n.y,l=t.behavior.getHeaderRowCount(),a=t.behavior.getHeaderColumnCount(),u=t.behavior.getColumnCount(),c=o.x>=u,h=l>s||a>r;if(!t.isCellSelection()||i||h||c)this.next&&this.next.handleMouseDown(t,e);else{var d=t.getFixedColumnCount(),g=t.getFixedRowCount();o.xn.origin.x+n.extent.x&&(o=1),this.currentDrag.y>n.origin.y+n.extent.y&&(r=1);var c=o,h=r;a&&(c=0),u&&(h=0),this.lastDragCell=i.plusXY(c,h),t.scrollBy(o,r),this.handleMouseDragCellSelection(t,i,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){var n=i.indexOf("CTRL")>=0,o=i.indexOf("SHIFT")>=0,r=t.getMouseDown(),s=e.x,l=e.y;if(!(0>s||0>l)){if(n&&s===r.x&&l===r.y)return t.clearMostRecentSelection(),t.popMouseDown(),void t.repaint();n||o||t.clearSelections(),o?(t.clearMostRecentSelection(),t.select(r.x,r.y,s-r.x+1,l-r.y+1),t.setDragExtent(t.newPoint(s-r.x+1,l-r.y))):(t.select(s,l,0,0),t.setMouseDown(t.newPoint(s,l)),t.setDragExtent(t.newPoint(0,0))),t.repaint()}},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,0,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,0,-1)},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1,0)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1,0)},handleDOWN:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,i)},handleUP:function(t,e){e.primitiveEvent.preventDefault();var i=this.getAutoScrollAcceleration();this.moveSingleSelect(t,0,-i)},handleLEFT:function(t){this.moveSingleSelect(t,-1,0)},handleRIGHT:function(t){this.moveSingleSelect(t,1,0)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumns()-1,s=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var l=t.getMouseDown(),a=t.getDragExtent(),u=a.x+e,c=a.y+i;u=Math.min(n-l.x,Math.max(-l.x,u)),c=Math.min(o-l.y,Math.max(-l.y,c)),t.clearMostRecentSelection(),t.select(l.x,l.y,u,c),t.setDragExtent(t.newPoint(u,c)),t.insureModelColIsVisible(u+l.x,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(c+l.y,i)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e,i){var n=t.getColumnCount()-1,o=t.getRowCount()-1,r=t.getVisibleColumnsCount()-1,s=t.getVisibleRowsCount()-1,l=t.getHeaderRowCount(),a=t.getHeaderColumnCount();t.resolveProperty("scrollingEnabled")||(n=Math.min(n,r),o=Math.min(o,s));var u=t.getMouseDown().plus(t.getDragExtent()),c=u.x+e,h=u.y+i;c=Math.min(n,Math.max(a,c)),h=Math.min(o,Math.max(l,h)),t.clearSelections(),t.select(c,h,0,0),t.setMouseDown(t.newPoint(c,h)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(c,e)&&this.pingAutoScroll(),t.insureModelRowIsVisible(h,i)&&this.pingAutoScroll(),t.repaint()}});e.exports=o},{"./Feature.js":58}],52:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnAutosizing",{alias:"ColumnAutosizing",handleDoubleClick:function(t,e){var i=t.getHeaderRowCount(),n=e.gridCell;n.y<=i?t.autosizeColumn(n.x):this.next&&this.next.handleDoubleClick(t,e)}});e.exports=o},{"./Feature.js":58}],53:[function(t,e,i){"use strict";var n,o,r,s,l=t("./Feature.js"),a=150,u=l.extend("ColumnMoving",{alias:"ColumnMoving",floaterAnimationQueue:[],columnDragAutoScrollingRight:!1,columnDragAutoScrollingLeft:!1,dragArmed:!1,dragging:!1,dragCol:-1,dragOffset:0,initializeOn:function(t){this.isFloatingNow=!1,this.initializeAnimationSupport(t),this.next&&this.next.initializeOn(t)},initializeAnimationSupport:function(t){n||(n=document.createElement("canvas"),n.setAttribute("width","0px"),n.setAttribute("height","0px"),document.body.appendChild(n),o=n.getContext("2d")),r||(r=document.createElement("canvas"),r.setAttribute("width","0px"),r.setAttribute("height","0px"),document.body.appendChild(r),s=r.getContext("2d"))},getCanDragCursorName:function(){return"-webkit-grab"},getDraggingCursorName:function(){return"-webkit-grabbing"},handleMouseDrag:function(t,e){var i,n=e.gridCell,o=Math.abs(e.primitiveEvent.detail.dragstart.x-e.primitiveEvent.detail.mouse.x);return 10>o?void(this.next&&this.next.handleMouseDrag(t,e)):(this.isHeaderRow(t,e)&&this.dragArmed&&!this.dragging?(this.dragging=!0,this.dragCol=n.x,this.dragOffset=e.mousePoint.x,this.detachChain(),i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.createDragColumn(t,i,this.dragCol)):this.next&&this.next.handleMouseDrag(t,e),void(this.dragging&&(i=e.primitiveEvent.detail.mouse.x-this.dragOffset,this.dragColumn(t,i))))},handleMouseDown:function(t,e){t.behavior.isColumnReorderable()&&this.isHeaderRow(t,e)&&-1!==e.gridCell.x&&(this.dragArmed=!0,this.cursor=this.getDraggingCursorName(),t.clearSelections()),this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){if(this.dragging){this.cursor=null;var i=this;this.endDragColumn(t),setTimeout(function(){i.attachChain()},200)}this.dragCol=-1,this.dragging=!1,this.dragArmed=!1,this.cursor=null,t.repaint(),this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){!this.dragging&&e.mousePoint.y<5&&0===e.viewPoint.y?this.cursor=this.getCanDragCursorName():this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.isHeaderRow(t,e)&&this.dragging&&(this.cursor=this.getDraggingCursorName())},floatColumnTo:function(t,e){this.floatingNow=!0;var i,n,o=t.getRenderer(),r=o.getColumnEdges(),s=t.getHScrollValue(),l=t.renderOverridesCache.floater.columnIndex,a=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.hdpiratio,c=t.getFixedColumnCount(),h=t.getColumnWidth(a),d=t.getColumnWidth(l),g=t.getVisibleColumnsCount(),f=0,p=0;a>=c&&(f=s),l>=c&&(p=s),e?(i=r[Math.min(g,a-f)],n=r[Math.min(g,l-p)],t.renderOverridesCache.dragger.startX=(i+d)*u,t.renderOverridesCache.floater.startX=i*u):(n=r[Math.min(g,l-p)],i=n+h,t.renderOverridesCache.dragger.startX=n*u,t.renderOverridesCache.floater.startX=i*u),t.swapColumns(a,l),t.renderOverridesCache.dragger.columnIndex=l,t.renderOverridesCache.floater.columnIndex=a,this.floaterAnimationQueue.unshift(this.doColumnMoveAnimation(t,n,i)),this.doFloaterAnimation(t)},doColumnMoveAnimation:function(t,e,i){var n=this;return function(){var o=r;o.style.display="inline",n.setCrossBrowserProperty(o,"transform","translate("+e+"px, 0px)"),requestAnimationFrame(function(){n.setCrossBrowserProperty(o,"transition",(n.isWebkit?"-webkit-":"")+"transform "+a+"ms ease"),n.setCrossBrowserProperty(o,"transform","translate("+i+"px, -2px)")}),t.repaint(),setTimeout(function(){n.setCrossBrowserProperty(o,"transition",""),t.renderOverridesCache.floater=null,t.repaint(),n.doFloaterAnimation(t),requestAnimationFrame(function(){o.style.display="none",n.isFloatingNow=!1})},a+50)}},doFloaterAnimation:function(t){if(0===this.floaterAnimationQueue.length)return this.floatingNow=!1,void t.repaint();var e=this.floaterAnimationQueue.pop();e()},createFloatColumn:function(t,e){var i=t.getFixedColumnCount(),n=t.getHScrollValue();i>e&&(n=0);var o=t.getRenderer(),l=o.getColumnEdges(),a=t.getColumnWidth(e),u=t.div.clientHeight,c=r,h=c.style,d=t.div.getBoundingClientRect();h.top=d.top-2+"px",h.left=d.left+"px",h.position="fixed";var g=t.getHiDPI(s);c.setAttribute("width",Math.round(a*g)+"px"),c.setAttribute("height",Math.round(u*g)+"px"),h.boxShadow="0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)",h.width=a+"px",h.height=u+"px",h.borderTop="1px solid "+o.resolveProperty("lineColor"),h.backgroundColor=o.resolveProperty("backgroundColor");var f=l[e-n];f*=g,s.scale(g,g),t.renderOverridesCache.floater={columnIndex:e,ctx:s,startX:f,width:a,height:u,hdpiratio:g},h.zIndex="4",this.setCrossBrowserProperty(c,"transform","translate("+f+"px, -2px)"),h.cursor=this.getDraggingCursorName(),t.repaint()},setCrossBrowserProperty:function(t,e,i){var n=e[0].toUpperCase()+e.substr(1);this.setProp(t,"webkit"+n,i),this.setProp(t,"Moz"+n,i),this.setProp(t,"ms"+n,i),this.setProp(t,"O"+n,i),this.setProp(t,e,i)},setProp:function(t,e,i){e in t.style&&(t.style[e]=i)},createDragColumn:function(t,e,i){var r=t.getFixedColumnCount(),s=t.getHScrollValue();r>i&&(s=0);var l=t.getRenderer(),a=l.getColumnEdges(),u=t.getHiDPI(o),c=t.getColumnWidth(i),h=t.div.clientHeight,d=n,g=t.div.getBoundingClientRect(),f=d.style;f.top=g.top+"px",f.left=g.left+"px",f.position="fixed",f.opacity=.85,f.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",f.borderTop="1px solid "+l.resolveProperty("lineColor"),f.backgroundColor=t.renderer.resolveProperty("backgroundColor"),d.setAttribute("width",Math.round(c*u)+"px"),d.setAttribute("height",Math.round(h*u)+"px"),f.width=c+"px",f.height=h+"px";var p=a[i-s];p*=u,o.scale(u,u),t.renderOverridesCache.dragger={columnIndex:i,ctx:o,startX:p,width:c,height:h,hdpiratio:u},this.setCrossBrowserProperty(d,"transform","translate("+e+"px, -5px)"),f.zIndex="5",f.cursor=this.getDraggingCursorName(),t.repaint()},dragColumn:function(t,e){var i=this,r=this.columnDragAutoScrollingRight||this.columnDragAutoScrollingLeft,s=t.getHiDPI(o),l=t.renderOverridesCache.dragger.columnIndex,u=t.renderOverridesCache.dragger.width,c=0,h=t.renderer.getFinalVisableColumnBoundary()-u;e=Math.min(e,h+15),e=Math.max(c-15,e);var d=c>e&&0!==l,g=e>h,f=n;this.setCrossBrowserProperty(f,"transition",(i.isWebkit?"-webkit-":"")+"transform 0ms ease, box-shadow "+a+"ms ease"),this.setCrossBrowserProperty(f,"transform","translate("+e+"px, -10px)"),requestAnimationFrame(function(){f.style.display="inline"});var p=t.renderer.getColumnFromPixelX(e+f.width/2/s);d&&(p=0),g&&(p=t.getColumnCount()-1);var v=l>p;if(v=v||p-l>=1,!v||g||r){if(c-10>e&&this.checkAutoScrollToLeft(t,e),e>c-10&&(this.columnDragAutoScrollingLeft=!1),g||e>h+10)return void this.checkAutoScrollToRight(t,e);h+10>e&&(this.columnDragAutoScrollingRight=!1)}else{var m=p>l;if(this.isFloatingNow)return;this.isFloatingNow=!0,this.createFloatColumn(t,p),this.floatColumnTo(t,m)}},checkAutoScrollToRight:function(t,e){this.columnDragAutoScrollingRight||(this.columnDragAutoScrollingRight=!0,this._checkAutoScrollToRight(t,e))},_checkAutoScrollToRight:function(t,e){if(this.columnDragAutoScrollingRight){var i=t.getHScrollValue();if(t.dragging&&!(i>t.sbHScrollConfig.rangeStop-2)){var n=t.renderOverridesCache.dragger.columnIndex;t.scrollBy(1,0);var o=n+1;console.log(o,n),t.swapColumns(o,n),t.renderOverridesCache.dragger.columnIndex=o,setTimeout(this._checkAutoScrollToRight.bind(this,t,e),250)}}},checkAutoScrollToLeft:function(t,e){this.columnDragAutoScrollingLeft||(this.columnDragAutoScrollingLeft=!0,this._checkAutoScrollToLeft(t,e))},_checkAutoScrollToLeft:function(t,e){if(this.columnDragAutoScrollingLeft){var i=t.getHScrollValue();if(t.dragging&&!(1>i)){var n=t.renderOverridesCache.dragger.columnIndex;t.swapColumns(n+i,n+i-1),t.scrollBy(-1,0),setTimeout(this._checkAutoScrollToLeft.bind(this,t,e),250)}}},endDragColumn:function(t){var e=t.getFixedColumnCount(),i=t.getHScrollValue(),o=t.renderOverridesCache.dragger.columnIndex;e>o&&(i=0);var r=t.getRenderer(),s=r.getColumnEdges(),l=this,u=s[o-i],c=n;l.setCrossBrowserProperty(c,"transition",(l.isWebkit?"-webkit-":"")+"transform "+a+"ms ease, box-shadow "+a+"ms ease"),l.setCrossBrowserProperty(c,"transform","translate("+u+"px, -1px)"),c.style.boxShadow="0px 0px 0px #888888",setTimeout(function(){t.renderOverridesCache.dragger=null,t.repaint(),requestAnimationFrame(function(){c.style.display="none",t.endDragColumnNotification()})},a+50)},isHeaderRow:function(t,e){var i=e.viewPoint,n=0===i.y;return n}});e.exports=u},{"./Feature.js":58}],54:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnPicker",{alias:"ColumnPicker",handleKeyUp:function(t,e){var i=e.detail["char"].toLowerCase(),n=t.resolveProperty("editorActivationKeys");n.indexOf(i)>-1&&t.toggleColumnPicker()}});e.exports=o},{"./Feature.js":58}],55:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnResizing",{alias:"ColumnResizing",dragIndex:-2,dragStart:-1,dragIndexStartingSize:-1,getMouseValue:function(t){return t.primitiveEvent.detail.mouse.x},getGridCellValue:function(t){return t.y},getScrollValue:function(t){return t.getHScrollValue()},getAreaSize:function(t,e){return t.getColumnWidth(e)},setAreaSize:function(t,e,i){t.setColumnWidth(e,i)},getPreviousAbsoluteSize:function(t,e){return t.getRenderedWidth(e)},overAreaDivider:function(t,e){return t.overColumnDivider(e)},isFirstFixedOtherArea:function(t,e){return this.isFirstFixedRow(t,e)},getCursorName:function(){return"col-resize"},handleMouseDrag:function(t,e){if(this.dragIndex>-2){var i=this.getMouseValue(e),n=this.getScrollValue(t);this.dragIndex-1&&this.isFirstFixedOtherArea(t,e)){var o=this.getScrollValue(t);n-2){this.cursor=null,this.dragIndex=-2,e.primitiveEvent.stopPropagation();var n=this;t.synchronizeScrollingBoundries(),setTimeout(function(){n.attachChain()},200)}else this.next&&this.next.handleMouseUp(t,e)},handleMouseMove:function(t,e){this.dragIndex>-2||(this.cursor=null,this.next&&this.next.handleMouseMove(t,e),this.checkForAreaResizeCursorChange(t,e))},checkForAreaResizeCursorChange:function(t,e){var i=this.isEnabled(t);i&&this.overAreaDivider(t,e)>-1&&this.isFirstFixedOtherArea(t,e)?this.cursor=this.getCursorName():this.cursor=null},getFixedAreaCount:function(t){var e=t.getFixedColumnCount()+(t.isShowRowNumbers()?1:0)+(t.hasHierarchyColumn()?1:0);return e},handleDoubleClick:function(t,e){var i=this.isEnabled(t),n=this.overAreaDivider(t,e)>-1,o=t.getHeaderRowCount(),r=e.gridCell;i&&n&&r.y<=o?t.autosizeColumn(r.x-1):this.next&&this.next.handleDoubleClick(t,e)},isEnabled:function(t){return!0}});e.exports=o},{"./Feature.js":58}],56:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=50,r=n.extend("ColumnSelection",{alias:"ColumnSelection",currentDrag:null,lastDragCell:null,sbLastAuto:0,sbAutoStart:0,handleMouseUp:function(t,e){this.dragging&&(this.dragging=!1),this.next&&this.next.handleMouseUp(t,e)},handleDoubleClick:function(t,e){this.doubleClickTimer&&(clearTimeout(this.doubleClickTimer),this.doubleClickTimer=void 0),this.next&&this.next.handleDoubleClick(t,e)},handleMouseDown:function(t,e){if(!this.doubleClickTimer){if((!t.isColumnSelection()||e.mousePoint.y<5)&&this.next)return void this.next.handleMouseDown(t,e);var i=e.primitiveEvent.detail.isRightClick,n=e.gridCell,r=e.viewPoint,s=n.x,l=n.y,a=t.isShowHeaderRow()&&0===l&&-1!==s;i||!a?this.next&&this.next.handleMouseDown(t,e):this.doubleClickTimer=setTimeout(function(){this.doubleClickTimer=void 0;var i=t.getFixedColumnCount();r.xi.origin.x+i.extent.x&&(n=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentColumnSelection(),t.selectColumn(r,o.x),t.setDragExtent(t.newPoint(r-o.x,0))):(t.toggleSelectColumn(r,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){},handleUPSHIFT:function(t){},handleLEFTSHIFT:function(t){this.moveShiftSelect(t,-1)},handleRIGHTSHIFT:function(t){this.moveShiftSelect(t,1)},handleDOWN:function(t){},handleUP:function(t){},handleLEFT:function(t){this.moveSingleSelect(t,-1)},handleRIGHT:function(t){this.moveSingleSelect(t,1)},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now()},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumns()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.x+e;s=Math.min(i-o.x,Math.max(-o.x,s)),t.clearMostRecentColumnSelection(),t.selectColumn(o.x,o.x+s),t.setDragExtent(t.newPoint(s,0)),t.insureModelColIsVisible(s+o.x,e)&&this.pingAutoScroll(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getColumnCount()-1,n=t.getVisibleColumnsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.x+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectColumn(r),t.setMouseDown(t.newPoint(r,0)),t.setDragExtent(t.newPoint(0,0)),t.insureModelColIsVisible(r,e)&&this.pingAutoScroll(),t.repaint()},isColumnDragging:function(t){var e=t.lookupFeature("ColumnMoving");if(!e)return!1;var i=e.dragging&&!this.dragging;return i}});e.exports=r},{"./Feature.js":58}],57:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ColumnSorting",{alias:"ColumnSorting",handleDoubleClick:function(t,e){var i=e.gridCell;if(t.isShowHeaderRow()&&0===i.y&&-1!==i.x){var n=e.primitiveEvent.detail.keys;t.toggleSort(i.x,n)}else this.next&&this.next.handleDoubleClick(t,e)},handleMouseMove:function(t,e){var i=e.gridCell.y;this.isFixedRow(t,e)&&1>i?this.cursor="pointer":this.cursor=null,this.next&&this.next.handleMouseMove(t,e)}});e.exports=o},{"./Feature.js":58}],58:[function(t,e,i){"use strict";var n=t("../lib/Base"),o=n.extend("Feature",{next:null,detached:null,cursor:null,currentHoverCell:null,setNext:function(t){this.next?this.next.setNext(t):(this.next=t,this.detached=t)},detachChain:function(){this.next=null},attachChain:function(){this.next=this.detached},handleMouseMove:function(t,e){this.next&&this.next.handleMouseMove(t,e)},handleMouseExit:function(t,e){this.next&&this.next.handleMouseExit(t,e)},handleMouseEnter:function(t,e){this.next&&this.next.handleMouseEnter(t,e)},handleMouseDown:function(t,e){this.next&&this.next.handleMouseDown(t,e)},handleMouseUp:function(t,e){this.next&&this.next.handleMouseUp(t,e)},handleKeyDown:function(t,e){this.next&&this.next.handleKeyDown(t,e)},handleKeyUp:function(t,e){this.next&&this.next.handleKeyUp(t,e)},handleWheelMoved:function(t,e){this.next&&this.next.handleWheelMoved(t,e)},handleDoubleClick:function(t,e){this.next&&this.next.handleDoubleClick(t,e)},handleHoldPulse:function(t,e){this.next&&this.next.handleHoldPulse(t,e)},handleTap:function(t,e){this.next&&this.next.handleTap(t,e)},handleMouseDrag:function(t,e){this.next&&this.next.handleMouseDrag(t,e)},handleContextMenu:function(t,e){this.next&&this.next.handleContextMenu(t,e)},moveSingleSelect:function(t,e,i){this.next&&this.next.moveSingleSelect(t,e,i)},isFixedRow:function(t,e){var i=e.viewPoint,n=i.yr;if(t.isRowSelection()&&!i&&l){var a=t.getFixedRowCount();o.yi.origin.y+i.extent.y&&(o=1);var u=n,c=o;l&&(u=0),a&&(c=0),this.lastDragCell=e.plusXY(u,c),t.scrollBy(n,o),this.handleMouseDragCellSelection(t,e,[]),t.repaint(),setTimeout(this.scrollDrag.bind(this,t),25)}},extendSelection:function(t,e,i){t.stopEditing();var n=-1!==i.indexOf("SHIFT"),o=t.getMouseDown(),r=e.x,s=e.y;0>r||0>s||(n?(t.clearMostRecentRowSelection(),t.selectRow(s,o.y),t.setDragExtent(t.newPoint(0,s-o.y))):(t.toggleSelectRow(s,i),t.setMouseDown(t.newPoint(r,s)),t.setDragExtent(t.newPoint(0,0))),t.repaint())},handleDOWNSHIFT:function(t){this.moveShiftSelect(t,1)},handleUPSHIFT:function(t){this.moveShiftSelect(t,-1)},handleLEFTSHIFT:function(t){},handleRIGHTSHIFT:function(t){},handleDOWN:function(t){this.moveSingleSelect(t,1)},handleUP:function(t){this.moveSingleSelect(t,-1)},handleLEFT:function(t){},handleRIGHT:function(t){var e=t.getMouseDown().plus(t.getDragExtent()),i=t.getColumnCount()-1,n=t.getHeaderColumnCount()+t.getHScrollValue(),o=e.y;n=Math.min(i,n),t.clearSelections(),t.select(n,o,0,0),t.setMouseDown(t.newPoint(n,o)),t.setDragExtent(t.newPoint(0,0)),t.repaint()},getAutoScrollAcceleration:function(){var t=1,e=this.getAutoScrollDuration()/2e3;return t=Math.max(1,Math.floor(e*e*e*e))},setAutoScrollStartTime:function(){this.sbAutoStart=Date.now(); +},pingAutoScroll:function(){var t=Date.now();t-this.sbLastAuto>500&&this.setAutoScrollStartTime(),this.sbLastAuto=Date.now()},getAutoScrollDuration:function(){return Date.now()-this.sbLastAuto>500?0:Date.now()-this.sbAutoStart},moveShiftSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRows()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown(),r=t.getDragExtent(),s=r.y+e;s=Math.min(i-o.y,Math.max(-o.y,s)),t.clearMostRecentRowSelection(),t.selectRow(o.y,o.y+s),t.setDragExtent(t.newPoint(0,s)),t.insureModelRowIsVisible(s+o.y,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},moveSingleSelect:function(t,e){var i=t.getRowCount()-1,n=t.getVisibleRowsCount()-1;t.resolveProperty("scrollingEnabled")||(i=Math.min(i,n));var o=t.getMouseDown().plus(t.getDragExtent()),r=o.y+e;r=Math.min(i,Math.max(0,r)),t.clearSelections(),t.selectRow(r),t.setMouseDown(t.newPoint(0,r)),t.setDragExtent(t.newPoint(0,0)),t.insureModelRowIsVisible(r,e)&&this.pingAutoScroll(),t.fireSyntheticRowSelectionChangedEvent(),t.repaint()},isSingleRowSelection:function(){return!0}});e.exports=o},{"./Feature.js":58}],64:[function(t,e,i){"use strict";var n=t("./Feature.js"),o=n.extend("ThumbwheelScrolling",{alias:"ThumbwheelScrolling",handleWheelMoved:function(t,e){if(t.resolveProperty("scrollingEnabled")){var i=e.primitiveEvent,n=i.wheelDeltaY||-i.deltaY,o=i.wheelDeltaX||-i.deltaX;n>0?t.scrollBy(0,-1):-0>n?t.scrollBy(0,1):o>0?t.scrollBy(-1,0):-0>o&&t.scrollBy(1,0)}}});e.exports=o},{"./Feature.js":58}],65:[function(t,e,i){"use strict";e.exports={Feature:t("./Feature"),CellClick:t("./CellClick"),CellEditing:t("./CellEditing"),CellSelection:t("./CellSelection"),ColumnAutosizing:t("./ColumnAutosizing"),ColumnMoving:t("./ColumnMoving"),ColumnResizing:t("./ColumnResizing"),ColumnSelection:t("./ColumnSelection"),ColumnSorting:t("./ColumnSorting"),Filters:t("./Filters"),KeyPaging:t("./KeyPaging"),OnHover:t("./OnHover"),ColumnPicker:t("./ColumnPicker"),RowResizing:t("./RowResizing"),RowSelection:t("./RowSelection"),ThumbwheelScrolling:t("./ThumbwheelScrolling")}},{"./CellClick":49,"./CellEditing":50,"./CellSelection":51,"./ColumnAutosizing":52,"./ColumnMoving":53,"./ColumnPicker":54,"./ColumnResizing":55,"./ColumnSelection":56,"./ColumnSorting":57,"./Feature":58,"./Filters":59,"./KeyPaging":60,"./OnHover":61,"./RowResizing":62,"./RowSelection":63,"./ThumbwheelScrolling":64}],66:[function(t,e,i){"use strict";var n=t("./deprecated"),o=t("extend-me").Base;o.prototype.deprecated=n,e.exports=o},{"./deprecated":74,"extend-me":5}],67:[function(t,e,i){"use strict";function n(t,e){var i="f"===(typeof e)[0],n=i?e(t):e;return n||0===n?n:""}function o(t,e,i,n,o,r){var s=t.getTextWidth(e,i);switch(e.textAlign){case"center":n-=s/2;break;case"right":n-=s}e.lineWidth=r,e.moveTo(n+.5,o+.5),e.lineTo(n+s+.5,o+.5)}function r(t,e,i,n,o,r){var s=t.getTextHeight(t.font),l=t.getTextWidth(e,i);switch(o-=.4*s.height,e.textAlign){case"center":n-=l/2;break;case"right":n-=l}e.lineWidth=r,e.moveTo(n+.5,o+.5),e.lineTo(n+l+.5,o+.5)}function s(t,e,i,n){if(1===i.length)return i;for(var o,r=[i.shift()];(o=e.getTextWidth(t,r.join(" "))1&&i.unshift(r.pop()),r=[r.join(" ")],i.length&&(r=r.concat(s(t,e,i,n))),r}function l(t,e,i,n){return s(t,e,a(i).split(" "),n)}function a(t){return t.toString().trim().replace(/\s\s+/g," ")}function u(t,e,i,n,o,r,s,l){l||(l=!0),r||(r=5),t.beginPath(),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+r),t.lineTo(e+n,i+o-r),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-r),t.lineTo(e,i+r),t.quadraticCurveTo(e,i,e+r,i),t.closePath(),l&&t.stroke(),s&&t.fill(),t.closePath()}function c(t){if(void 0===t)return 0;var e=t.match(c.regex);if(null===e)return 1;var i=e[4];return void 0===i?0:Number(i)}var h=t("./Base"),d=h.extend("CellProvider",{initialize:function(){this.cellCache={},this.initializeCells()},getCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getColumnHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},getRowHeaderCell:function(t){var e=this.cellCache.simpleCellRenderer;return e.config=t,e},paintButton:function(t,e){var i=e.value,n=e.x,o=e.y,r=e.bounds,s=r.x+2,l=r.y+2,a=r.width-3,c=r.height-3,h=c/2,d=t.createLinearGradient(s,l,s,l+c);e.mouseDown?(d.addColorStop(0,"#B5CBED"),d.addColorStop(1,"#4d74ea")):(d.addColorStop(0,"#ffffff"),d.addColorStop(1,"#aaaaaa")),t.fillStyle=d,t.strokeStyle="#000000",u(t,s,l,a,c,h,d,!0);var g=(a-e.getTextWidth(t,i))/2,f=(c-e.getTextHeight(t.font).descent)/2;"middle"!==t.textBaseline&&(t.textBaseline="middle"),t.fillStyle="#000000",e.backgroundColor="rgba(0,0,0,0)",t.fillText(i,s+g,l+f),e.buttonCells[n+","+o]=!0},defaultCellPaint:function(t,e){var i,o,r,s,l,a=e.value,u=e.bounds.x,h=e.bounds.y,d=e.bounds.width,g=e.bounds.height,f=e.headerTextWrapping,p=2,v=0===e.y;a&&a.constructor===Array&&(i=a[0],o=a[2],a=a[1],a&&"object"==typeof a&&"HTMLImageElement"===a.constructor.name&&(r=a,a=null),i&&"IMG"!==i.nodeName&&(i=null),o&&"IMG"!==o.nodeName&&(o=null),r&&"IMG"!==r.nodeName&&(r=null)),a=n(e,a),a=e.formatter(a),t.font!==e.font&&(t.font=e.font),"left"!==t.textAlign&&(t.textAlign="left"),"middle"!==t.textBaseline&&(t.textBaseline="middle");var m,C,w,y;e.isCellHovered&&e.hoverCellHighlight.enabled?w=e.hoverCellHighlight.backgroundColor:e.isRowHovered&&(C=e.hoverRowHighlight).enabled?w=e.isGridColumn||!C.header||void 0===C.header.backgroundColor?C.backgroundColor:C.header.backgroundColor:e.isColumnHovered&&(C=e.hoverColumnHighlight).enabled&&(w=e.isGridRow||!C.header||void 0===C.header.backgroundColor?C.backgroundColor:C.header.backgroundColor),c(w)<1&&(e.isSelected&&(y=n(e,e.backgroundSelectionColor)),c(y)<1&&(m=n(e,e.backgroundColor),c(m)>0&&(t.fillStyle=m,t.fillRect(u,h,d,g))),void 0!==y&&(t.fillStyle=y,t.fillRect(u,h,d,g))),void 0!==w&&(t.fillStyle=w,t.fillRect(u,h,d,g));var b=n(e,e.isSelected?e.foregroundSelectionColor:e.color);t.fillStyle!==b&&(t.fillStyle=b,t.strokeStyle=b),v&&f?this.renderMultiLineText(t,u,h,g,d,e,a):this.renderSingleLineText(t,u,h,g,d,e,a);var S=0;if(i&&(l=Math.round((g-i.height)/2),t.drawImage(i,u+p,h+l),S=Math.max(i.width+2)),o&&d>1.75*g){l=Math.round((g-o.height)/2);var x=u+d-o.width;void 0!==m?(t.fillStyle=m,t.fillRect(x,h,o.width,g)):t.clearRect(x,h,o.width,g),t.drawImage(o,x,h+l),S=Math.max(o.width+2)}r&&(l=Math.round((g-r.height)/2),s=Math.round((d-r.width)/2),t.drawImage(r,u+d-s-r.width,h+l),S=Math.max(r.width+2)),e.cellBorderThickness&&(t.beginPath(),t.rect(u,h,d,g),t.lineWidth=e.cellBorderThickness,t.strokeStyle=e.cellBorderStyle,t.stroke(),t.closePath()),e.minWidth=e.minWidth+2*S},renderMultiLineText:function(t,e,i,n,o,r,s){var u=l(t,r,s,o);if(1===u.length)return this.renderSingleLineText(t,e,i,n,o,r,a(s));var c=r.cellPadding,h=0,d=r.voffset,g=r.halign,f=r.getTextHeight(r.font).height;switch(g){case"right":h=o-c;break;case"center":h=o/2;break;case"left":h=c}var p=0,v=Math.ceil(f/2);d+=Math.ceil((n-(u.length-1)*f)/2),h=Math.max(p,h),d=Math.max(v,d),t.save(),t.rect(e,i,o,n),t.clip(),t.textAlign=g;for(var m=0;mt?"-0":"-")+t}e.exports={date:function(t){return t instanceof Date?t.getFullYear()+n(t.getMonth()+1)+n(t.getDate()):t+""},"default":function(t){return t+""}}},{}],70:[function(t,e,i){"use strict";e.exports=function(){function t(){this.keys=[],this.data={},this.values=[]}var e=".~.#%_",i=0,n=function(t){var n=typeof t;switch(n){case"number":return e+n+"_"+t;case"string":return e+n+"_"+t;case"boolean":return e+n+"_"+t;case"symbol":return e+n+"_"+t;case"undefined":return e+"undefined";case"object":case"function":return t.___finhash||(t.___finhash=e+i++),t.___finhash}},o=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},r=function(t,e){if(e!=e||0===e)for(var i=t.length;i--&&!o(t[i],e););else i=[].indexOf.call(t,e);return i};return t.prototype.set=function(t,e){var i=n(t);void 0===this.data[i]&&(this.keys.push(t),this.values.push(e)),this.data[i]=e},t.prototype.get=function(t){var e=n(t);return this.data[e]},t.prototype.getIfAbsent=function(t,e){var i=this.get(t);return void 0===i&&(i=e(t,this)),i},t.prototype.size=function(){return this.keys.length},t.prototype.clear=function(){this.keys.length=0,this.data={}},t.prototype["delete"]=function(t){var e=n(t);if(void 0!==this.data[e]){var i=r(this.keys,t);this.keys.splice(i,1),this.values.splice(i,1),delete this.data[e]}},t.prototype.forEach=function(t){for(var e=this.keys,i=0;it&&(i=t,t>=g&&(i+=h,void 0===s&&(s=i),l=i),!(E>w||i>=d));t++)o=m.getColumnWidth(i),E+=o,this.columnEdges[t+1]=Math.round(E),this.visibleColumns[t]=i,this.columnEdgesIndexMap[i]=t,b=b+Math.round(o/2)+S,this.insertionBounds.push(b),S=Math.round(o/2);for(e=0;f>e&&(n=e,e>=p&&(n+=c,void 0===a&&(a=n),u=n),!(A>y||n>=f));e++)r=m.getRowHeight(n),A+=r,this.rowEdges[e+1]=Math.round(A),this.visibleRows[e]=n,this.rowEdgesIndexMap[n]=e;this.viewHeight=y,this.dataWindow=this.grid.newRectangle(s,a,l-s,u-a)},resolveProperty:function(t){return this.grid.resolveProperty(t)},getGrid:function(){return this.deprecated("grid",{since:"0.2"})},paint:function(t){this.grid&&(this.renderGrid(t),this.grid.gridRenderedNotification())},getVisibleRowsCount:function(){return this.visibleRows.length-1},getVisibleScrollHeight:function(){return this.viewHeight-this.grid.getFixedRowsHeight()},getVisibleRows:function(){return this.visibleRows},getVisibleColumnsCount:function(){return this.visibleColumns.length-1},getVisibleColumns:function(){return this.visibleColumns},overColumnDivider:function(t){t=Math.round(t);var e=this.getColumnEdges(),i=e.indexOf(t-1);return 0>i&&(i=e.indexOf(t)),0>i&&(i=e.indexOf(t-2)),0>i&&(i=e.indexOf(t+1)),0>i&&(i=e.indexOf(t-3)),i},overRowDivider:function(t){t=Math.round(t);var e=this.rowEdges.indexOf(t+1);return 0>e&&(e=this.rowEdges.indexOf(t)),0>e&&(e=this.rowEdges.indexOf(t-1)),e},getBoundsOfCell:function(t){return this._getBoundsOfCell(t.x,t.y)},_getBoundsOfCell:function(t,e){var i,n=!1,o=!1,r=this.cell,s=this.columnEdgesIndexMap[t];void 0===s&&(s=this.columnEdgesIndexMap[t-1],n=!0);var l,a,u,c=this.columnEdges[s],h=this.columnEdges[s+1],d=h-c;if(r.x=n?h:c,r.width=n?0:d,0>e){var g=this.grid.behavior,f=this.getBounds();u=g.getDefaultRowHeight(),l=f.height+e*u,a=l+u}else i=this.rowEdgesIndexMap[e],void 0===i&&(i=this.rowEdgesIndexMap[e-1],o=!0),l=this.rowEdges[i],a=this.rowEdges[i+1],u=a-l;return r.y=o?a:l,r.height=o?0:u,r},getColumnFromPixelX:function(t){for(var e=0,i=this.getFixedColumnCount(),n=this.grid.getHScrollValue(),o=this.getColumnEdges(),r=1;rt)return r>i&&(r+=n),r-1;return r>i&&(r+=n),r-1},getGridCellFromMousePoint:function(t){var e,i,n,o,r=this.grid.behavior,s=0,l=0,a=0,u=this.getColumnEdges(),c=this.getFixedColumnCount(),h=this.getFixedRowCount(),d=this.getScrollLeft(),g=this.getScrollTop();for(n=0;n=c&&(n+=d),o>=h&&(o+=g);var p=-1,v=r.getColumn(n);return v&&(p=v.index),{gridCell:this.grid.newPoint(n,o),mousePoint:this.grid.newPoint(e,i),viewPoint:f,dataCell:this.grid.newPoint(p,o)}},isColumnVisible:function(t){var e=-1!==this.visibleColumns.indexOf(t);return e},getFinalVisableColumnBoundary:function(){var t=this.isLastColumnVisible(),e=t?2:1,i=this.getColumnEdges()[this.getColumnEdges().length-e],n=Math.min(i,this.getBounds().width-200);return n},isRowVisible:function(t){var e=-1!==this.visibleRows.indexOf(t);return e},isSelected:function(t,e){return this.grid.isSelected(t,e)},renderGrid:function(t){t.beginPath(),this.paintCells(t),this.paintGridlines(t),this.renderOverrides(t),this.renderFocusCell(t),t.closePath()},focusLineStep:[[5,5],[0,1,5,4],[0,2,5,3],[0,3,5,2],[0,4,5,1],[0,5,5,0],[1,5,4,0],[2,5,3,0],[3,5,2,0],[4,5,1,0]],renderFocusCell:function(t){t.beginPath(),this._renderFocusCell(t),t.closePath()},_renderFocusCell:function(t){var e=this.grid.selectionModel.getSelections();if(e&&0!==e.length){var i=e[e.length-1],n=i.origin;if(-1!==n.x){var o=this.getVisibleColumns(),r=this.getVisibleRows(),s=o[o.length-1],l=r[r.length-1],a=i.extent,u=Math.min(n.x,n.x+a.x),c=Math.min(n.y,n.y+a.y);if(!(u>s||c>l)){var h=Math.max(n.x,n.x+a.x)+1;h=Math.min(h,1+s);var d=Math.max(n.y,n.y+a.y)+1;d=Math.min(d,1+l);var g=this._getBoundsOfCell(u,c),f=Math.round(void 0===g.x?this.grid.getFixedColumnsWidth():g.x),p=Math.round(void 0===g.y?this.grid.getFixedRowsHeight():g.y),v=this._getBoundsOfCell(h,d),m=Math.round(void 0===v.x?this.grid.getFixedColumnsWidth():v.x),C=Math.round(void 0===v.y?this.grid.getFixedRowsHeight():v.y),w=Math.min(f,m),y=Math.min(p,C),b=1+m-f,S=1+C-p;w===m&&(b=f-m),y===C&&(S=p-C),1>b*S||(t.rect(w,y,b,S),t.fillStyle=this.resolveProperty("selectionRegionOverlayColor"),t.fill(),t.lineWidth=1,t.strokeStyle=this.resolveProperty("selectionRegionOutlineColor"),t.stroke())}}}},renderOverrides:function(t){var e=this.grid.renderOverridesCache;for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];n&&this.renderOverride(t,n)}},renderOverride:function(t,e){var i=e.hdpiratio,n=e.startX,o=e.width+1,r=e.height,s=e.ctx,l=t.getImageData(n,0,Math.round(o*i),Math.round(r*i));s.putImageData(l,0,0),t.fillStyle=this.resolveProperty("backgroundColor2"),t.fillRect(Math.round(n/i),0,o,r)},getScrollTop:function(){return this.grid.getVScrollValue()},getScrollLeft:function(){return this.grid.getHScrollValue()},getBehavior:function(){return this.deprecated("grid.behavior",{since:"0.2"})},getColumnEdges:function(){return this.columnEdges},getRowEdges:function(){return this.rowEdges},isLastColumnVisible:function(){var t=this.getColumnCount()-1;return-1!==this.visibleColumns.indexOf(t)},getRenderedWidth:function(t){return this.getColumnEdges()[t]},getRenderedHeight:function(t){return this.rowEdges[t]},getCanvas:function(){return this.grid.getCanvas()},isDraggingColumn:function(){return this.grid.isDraggingColumn()},getPageUpRow:function(){for(var t=this.grid,e=this.getVisibleScrollHeight(),i=this.grid.getFixedRowCount(),n=this.dataWindow.origin.y-i,o=0;e>o&&n>-1;)o+=t.getRowHeight(n),n--;return n+1},getPageDownRow:function(){var t=this.grid.getFixedRowCount(),e=this.dataWindow.corner.y-t-1;return e},getColumnCount:function(){return this.grid.getColumnCount()},getRowCount:function(){return this.grid.getRowCount()},getFixedColumnCount:function(){return this.grid.getFixedColumnCount()},getFixedRowCount:function(){return this.grid.getFixedRowCount()},getHeaderRowCount:function(){return this.grid.getHeaderRowCount()},getHeaderColumnCount:function(){return this.grid.getHeaderColumnCount()},paintCells:function(t){var e,i,o,r,s,l,a,u=this.getColumnEdges(),c=this.rowEdges,h=this.getVisibleColumns(),d=this.getVisibleRows(),g=this.grid.behavior,f=0,p=0,v=this.getBounds().height,m=this.grid.isShowRowNumbers()?-1:0,C=h.length;if(this.buttonCells={},C)for(o=m;C>o;o++,f+=a){for(s=h[o],this.renderedColumnMinWidths[s]=0,e=g.getColumnProperties(s).renderCellError,t.save(),a=u[o-m]-f,t.beginPath(),t.rect(f,p,a,v),t.clip(),r=0;r=c,d=0>i,g=!h&&!d,f=n.isFilterRow(i),p=r.getHeaderColumnCount(),v=e>=p,m=n.isShowRowNumbers(),C=n.isHierarchyColumn(e),w=n.isRowSelected(i),y=n.isColumnSelected(e),b=n.isCellSelected(e,i),S=n.isCellSelectedInColumn(e),x=n.isCellSelectedInRow(i),E=n.areAllRowsSelected();m&&-1===e||C?(w?(a=Object.create(l.rowHeaderRowSelection),a.isSelected=!0):(a=Object.create(l.rowHeader),a.isSelected=x),a.isUserDataArea=!1):g||d?(f?(a=Object.create(l.filterProperties),a.isSelected=!1):y?(a=Object.create(l.columnHeaderColumnSelection),a.isSelected=!0):(a=Object.create(l.columnHeader),a.isSelected=S),a.isUserDataArea=!1):C?(a=Object.create(l.rowHeader),a.isSelected=x):(a=Object.create(l),a.isSelected=b||w||y,a.isUserDataArea=!0);var A=i-c+1;if(-1===e?(0===i?a.value=[s.checkbox(E),"",null]:f?a.value=[s.filter(!1),"",null]:g||d?a.value="":a.value=[s.checkbox(w),A,null],a.halign="right"):(a.value=n.getValue(e,i),a.halign=n.getColumnAlignment(e)),a.isGridColumn=v,a.isGridRow=h,a.isColumnHovered=n.isColumnHovered(e)&&v,a.isRowHovered=n.isRowHovered(i)&&h,a.isCellHovered=n.isHovered(e,i)&&v&&h,a.bounds=this._getBoundsOfCell(e,i),a.isCellSelected=b,a.isRowSelected=w,a.isColumnSelected=y,a.isInCurrentSelectionRectangle=n.isInCurrentSelectionRectangle(e,i),n.mouseDownState){var R=n.mouseDownState.gridCell;a.mouseDown=R.x===e&&R.y===i}a.x=e,a.y=i,r.cellPropertiesPrePaintNotification(a);var D=r.getCellRenderer(a,e,i),T=r.getCellProperties(e,i);o(a).extendOwn(T),a.buttonCells=this.buttonCells;var P=a.isUserDataArea?a.format:"default";a.formatter=n.getFormatter(P),D.paint(t,a),this.renderedColumnMinWidths[e]=Math.max(a.minWidth||0,this.renderedColumnMinWidths[e]),u.preferredWidth=this.renderedColumnMinWidths[e]}},isViewableButton:function(t,e){var i=t+","+e;return this.buttonCells[i]===!0},getRowNumbersWidth:function(){var t=this.getColumnEdges();return 0===t.length?0:t[0]},startAnimator:function(){var t=this;requestAnimationFrame(function e(){t.animate(),requestAnimationFrame(e)})},animate:function(){var t=this.getCanvas().canvasCTX;t.beginPath(),t.save(),this.renderFocusCell(t),t.restore(),t.closePath()},getBounds:function(){return this.bounds},setBounds:function(t){return this.bounds=t}});e.exports=l},{"../../images":3,"./Base":66,"object-iterators":21}],72:[function(t,e,i){"use strict";function n(t){this.grid=t,this.selections=[],this.flattenedX=[],this.flattenedY=[],this.rowSelectionModel=new o,this.columnSelectionModel=new o,this.setLastSelectionType("")}var o=t("sparse-boolean-array");n.prototype={constructor:n.prototype.constructor,allRowsSelected:!1,getLastSelection:function(){var t=this.selections,e=t[t.length-1];return e},getLastSelectionType:function(){return this.lastSelectionType},setLastSelectionType:function(t){this.lastSelectionType=t},select:function(t,e,i,n){var o=this.grid.newRectangle(t,e,i,n);this.selections.push(o),this.flattenedX.push(o.flattenXAt(0)),this.flattenedY.push(o.flattenYAt(0)),this.setLastSelectionType("cell"),this.grid.selectionChanged()},toggleSelect:function(t,e,i,n){var o,r;o=this.selections.find(function(o,s){return r=s,o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n}),o?(this.selections.splice(r,1),this.flattenedX.splice(r,1),this.flattenedY.splice(r,1),this.grid.selectionChanged()):this.select(t,e,i,n)},clearMostRecentSelection:function(t){t=t===!0,t||this.setAllRowsSelected(!1),this.selections.length&&--this.selections.length,this.flattenedX.length&&--this.flattenedX.length,this.flattenedY.length&&--this.flattenedY.length},clearMostRecentColumnSelection:function(){this.columnSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("column")},clearMostRecentRowSelection:function(){this.rowSelectionModel.clearMostRecentSelection(),this.setLastSelectionType("row")},clearRowSelection:function(){this.rowSelectionModel.clear(),this.setLastSelectionType("row")},getSelections:function(){return this.selections},hasSelections:function(){return 0!==this.selections.length},hasRowSelections:function(){return!this.rowSelectionModel.isEmpty()},hasColumnSelections:function(){return!this.columnSelectionModel.isEmpty()},isCellSelectedInRow:function(t){return this._isCellSelected(this.flattenedX,0,t)},isCellSelectedInColumn:function(t){return this._isCellSelected(this.flattenedY,t,0)},isSelected:function(t,e){return this.isColumnSelected(t)||this.isRowSelected(e)||this._isCellSelected(this.selections,t,e)},isCellSelected:function(t,e){return this._isCellSelected(this.selections,t,e)},_isCellSelected:function(t,e,i){var n=this;return!!t.find(function(t){return n.rectangleContains(t,e,i)})},clear:function(t){t=t===!0,this.selections.length=0,this.flattenedX.length=0,this.flattenedY.length=0,this.columnSelectionModel.clear(),t||(this.setAllRowsSelected(!1),this.rowSelectionModel.clear())},isRectangleSelected:function(t,e,i,n){return!!this.selections.find(function(o){return o.origin.x===t&&o.origin.y===e&&o.extent.x===i&&o.extent.y===n})},isColumnSelected:function(t){return this.columnSelectionModel.isSelected(t)},isRowSelected:function(t){return this.allRowsSelected||this.rowSelectionModel.isSelected(t)},selectColumn:function(t,e){this.columnSelectionModel.select(t,e),this.setLastSelectionType("column")},selectAllRows:function(){this.clear(),this.setAllRowsSelected(!0)},setAllRowsSelected:function(t){this.allRowsSelected=t},areAllRowsSelected:function(){return this.allRowsSelected},selectRow:function(t,e){this.rowSelectionModel.select(t,e),this.setLastSelectionType("row")},deselectColumn:function(t,e){this.columnSelectionModel.deselect(t,e),this.setLastSelectionType("column")},deselectRow:function(t,e){this.rowSelectionModel.deselect(t,e),this.setLastSelectionType("row")},getSelectedRows:function(){if(this.areAllRowsSelected()){for(var t=this.grid.getHeaderRowCount(),e=this.grid.getRowCount()-t,i=new Array(e),n=0;e>n;n++)i[n]=n+t;return i}return this.rowSelectionModel.getSelections()},getSelectedColumns:function(){return this.columnSelectionModel.getSelections()},isColumnOrRowSelected:function(){return!this.columnSelectionModel.isEmpty()||!this.rowSelectionModel.isEmpty()},getFlattenedYs:function(){var t=[],e={};return this.selections.forEach(function(i){for(var n=i.origin.y,o=i.extent.y+1,r=0;o>r;r++){var s=r+n;e[s]||(t.push(s),e[s]=!0)}}),t.sort(function(t,e){return t-e}),t},selectRowsFromCells:function(t,e){t=t||0,e=e===!0;var i=this.rowSelectionModel;e||(this.setAllRowsSelected(!1),i.clear()),this.selections.forEach(function(e){var n=e.origin.y,o=e.extent.y;n+=t,i.select(n,n+o)})},selectColumnsFromCells:function(t){t=t||0;var e=this.columnSelectionModel;e.clear(),this.selections.forEach(function(i){var n=i.origin.x,o=i.extent.x;n+=t,e.select(n,n+o)})},isInCurrentSelectionRectangle:function(t,e){var i=this.selections[this.selections.length-1];return i&&this.rectangleContains(i,t,e)},rectangleContains:function(t,e,i){var n=t.origin.x,o=t.origin.y,r=n+t.extent.x,s=o+t.extent.y;t.extent.x<0&&(n=r,r=t.origin.x),t.extent.y<0&&(o=s,s=t.origin.y);var l=e>=n&&i>=o&&r>=e&&s>=i;return l}},e.exports=n},{"sparse-boolean-array":24}],73:[function(t,e,i){"use strict";var n=t("./Base"),o=500,r=o+"ms ease-in",s=n.extend("TableDialog",{initialize:function(t){this.grid=t,this.initializeOverlaySurface(),this.openNow=!1},isOpen:function(){return this.openNow},open:function(){if(!this.isOpen()){this.openNow=!0;var t=this;this.overlay.style.backgroundColor=this.grid.resolveProperty("backgroundColor"),this.overlay.style.top=this.overlay.style.bottom=this.overlay.style.right=this.overlay.style.left=0,t.overlay.style.webkitTransition="",this.overlay.style.margin="15px 35px 35px 15px",this.overlay.style.opacity=0,this.overlay.style.zIndex=100,this.closeTransition=function(){this.overlay.style.opacity=0},this._closer||(this._closer=function(e){var i=t.getCharFor(e.keyCode).toLowerCase(),n=t.grid.resolveProperty("editorActivationKeys");(n.indexOf(i)>-1||27===e.keyCode)&&(e.preventDefault(),t.close())}),requestAnimationFrame(function(){t.overlay.style.webkitTransition="opacity "+o+"ms ease-in",requestAnimationFrame(function(){document.addEventListener("keydown",t._closer,!1),t.overlay.style.opacity=.95})}),setTimeout(function(){t.overlay.focus()},100)}},openFrom:function(t){if(!this.isOpen()){this.openNow=!0;var e=this,i=this.overlay.style;i.backgroundColor=this.grid.resolveProperty("backgroundColor");var n=this.grid.div.getBoundingClientRect(),o=t.y+"px "+(n.width-(t.x+t.width))+"px "+(n.height-(t.y+t.height))+"px "+t.x+"px";i.webkitTransition="",i.top=i.right=i.bottom=i.left=0,i.margin=o,i.zIndex=100,i.opacity=1,this.closeTransition=function(){i.margin=o},this._closer||(this._closer=function(t){var i=e.getCharFor(t.keyCode).toLowerCase(),n=e.grid.resolveProperty("editorActivationKeys");(n.indexOf(i)>-1||27===t.keyCode)&&(t.preventDefault(),e.close())}),requestAnimationFrame(function(){document.addEventListener("keydown",e._closer,!1),requestAnimationFrame(function(){requestAnimationFrame(function(){i.webkitTransition="margin-top "+r+", margin-right "+r+", margin-bottom "+r+", margin-left "+r,i.margin="15px 35px 35px 15px"})})}),setTimeout(function(){e.overlay.focus()},100)}},close:function(){this.openNow=!1,document.removeEventListener("keydown",this._closer,!1);var t=this;requestAnimationFrame(function(){t.closeTransition()}),setTimeout(function(){t.clear(),t.overlay.style.zIndex=-1e3,t.onClose&&(t.onClose(),t.onClose=void 0),t.grid.takeFocus()},o)},initializeOverlaySurface:function(){this.overlay=document.createElement("div"),this.overlay.setAttribute("tabindex",0),this.overlay.addEventListener("wheel",function(t){t.stopPropagation()});var t=this.overlay.style;t.outline="none",t.boxShadow="0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)",t.position="absolute",t.margin=0,t.overflow="hidden",t.opacity=0,t.zIndex=10,this.grid.div.appendChild(this.overlay)},getCharFor:function(t){var e=this.grid.getCanvas().getCharMap();return e[t][0]},clear:function(){this.overlay.innerHTML=""},querySelector:function(t){ +var e=this.overlay.querySelector(t);return e},getAnimationTime:function(){return o}});e.exports=s},{"./Base":66}],74:[function(t,e,i){"use strict";console.warn||(console.warn=function(){console.log.apply(console,["WARNING:"].concat(Array.prototype.slice.call(arguments)))});var n=function(t,e){var i,n=t.split("."),o=n[n.length-1],r=e&&e.asOfVersion,s=this;return o="get"+o[0].toUpperCase()+o.substr(1),i="."+o+"() method is deprecated",r&&(i+=" as of v"+e.asOfVersion),i+=". Use ."+t,")"!==t[t.length-1]&&(i+=" property"),i+=" instead. (Will be removed in a future release.)",console.warn(i),n.forEach(function(t){s=s[t]}),s};e.exports=n},{}],75:[function(t,e,i){"use strict";function n(t,e,i,n,r,s){t.fillStyle="#FFD500",t.fill(),t.strokeStyle=t.createPattern(o.caution,"repeat"),t.lineWidth=5,t.beginPath(),t.moveTo(i,n),t.lineTo(i+r,n),t.lineTo(i+r,n+s),t.lineTo(i,n+s),t.lineTo(i,n),t.stroke(),t.beginPath(),t.rect(i,n,r-2,s),t.clip(),t.fillStyle="#A00",t.textAlign="start",t.textBaseline="middle",t.font='bold 6pt "arial narrow", verdana, geneva',t.fillText(e,i+4,n+s/2+.5)}var o=t("../../images");e.exports=n},{"../../images":3}],76:[function(t,e,i){"use strict";e.exports=function(){function t(t){this.label=t,this.data=[""],this.rowIndexes=[],this.hasChildren=!1,this.depth=0,this.height=1,this.expanded=!1}var e=" ";return t.prototype.isNullObject=!1,t.prototype.getValue=function(t){return this.data[t]},t.prototype.prune=function(t){this.depth=t,this.data[0]=this.computeDepthString()},t.prototype.computeDepthString=function(){var t=e.substring(0,2+3*this.depth)+this.label;return t},t.prototype.computeHeight=function(){return 1},t.prototype.getAllRowIndexes=function(){return this.rowIndexes},t.prototype.computeAggregates=function(t){this.applyAggregates(t)},t.prototype.applyAggregates=function(t){var e=t.hasGroups()?1:0,i=this.getAllRowIndexes();if(0!==i.length){var n=t.aggregates,o=this.data;o.length=n.length+e;var r=t.sorterInstance;r.indexes=i;for(var s=0;s0},t.prototype.hasAggregates=function(){return this.aggregates.length>0},t.prototype.apply=function(){this.buildGroupTree()},t.prototype.clearGroups=function(){this.groupBys.length=0},t.prototype.clearAggregations=function(){this.aggregates.length=0,this.headers.length=0},t.prototype.buildGroupTree=function(){var t,e,i,l,a,u=function(t,e){return l=new r(t),e.set(t,l),l},c=function(t,e){return l=new s(t),e.set(t,l),l},h=this.groupBys,d=this.dataSource,g=d.getRowCount();if(this.presortGroups)for(t=0;te;e++){for(t=0;ti;i++)e[i]=i;this.indexes=e},t.prototype.setData=function(t){this.dataSource.setData(t)},t}()},{}],82:[function(t,e,i){"use strict";var n=t("./DataSourceDecorator");e.exports=function(){function t(t){n.call(this,t,!1),this.filters=[]}return t.prototype=Object.create(n.prototype),t.prototype.add=function(t,e){e.columnIndex=t,this.filters.push(e)},t.prototype.set=function(t,e){e.columnIndex=t,this.filters.push(e)},t.prototype.clearAll=function(){this.filters.length=0,this.indexes.length=0},t.prototype.applyAll=function(){if(0===this.filters.length)return void(this.indexes.length=0);var t=this.indexes;t.length=0;for(var e=this.dataSource.getRowCount(),i=0;e>i;i++)this.applyFiltersTo(i)&&t.push(i)},t.prototype.applyFiltersTo=function(t){for(var e=this.filters,i=!0,n=0;no;o++)this.applyFilterTo(o)&&i.push(o)},t.prototype.applyFilterTo=function(t){for(var e=!1,i=this.filter,n=this.visibleColumnMap.length,o=this.dataSource.getRow(t),r=0;n>r;r++){var s=this.visibleColumnMap[r];if(e=e||i(this.dataSource.getValue(s,t),o,t))return!0}return!1},t}()},{"./DataSourceDecorator":81}],84:[function(t,e,i){"use strict";var n=t("./Utils.js"),o=t("./DataSourceDecorator"),r=function(t){var e="f"===(typeof t)[0],i=e?t():t;return i};e.exports=function(){function t(t){o.call(this,t),this.descendingSort=!1}return t.prototype=Object.create(o.prototype),t.prototype.sortOn=function(t,e){if(0===e)return void(this.indexes.length=0);this.initializeIndexVector();var i=this;n.stableSort(this.indexes,function(e){var n=i.dataSource.getValue(t,e);return n=r(n)},e)},t}()},{"./DataSourceDecorator":81,"./Utils.js":88}],85:[function(t,e,i){"use strict";var n=t("./DataSourceDecorator"),o=t("./DataSourceSorter");e.exports=function(){function t(t){n.call(this,t),this.sorts=[],this.last=this.dataSource}return t.prototype=Object.create(n.prototype),t.prototype.getRow=function(t){return this.last.getRow(t)},t.prototype.sortOn=function(t,e){this.sorts.push([t,e])},t.prototype.applySorts=function(){for(var t=this.sorts,e=this.dataSource,i=0;io;o++)i+=e.getValue(t,o);return i}},min:function(t){return function(e){for(var i=1/0,n=e.getRowCount(),o=0;n>o;o++)i=Math.min(i,e.getValue(t,o));return i}},max:function(t){return function(e){for(var i=-(1/0),n=e.getRowCount(),o=0;n>o;o++)i=Math.max(i,e.getValue(t,o));return i}},avg:function(t){return function(e){for(var i=0,n=e.getRowCount(),o=0;n>o;o++)i+=e.getValue(t,o);return i/n}},first:function(t){return function(e){return e.getValue(t,0)}},last:function(t){return function(e){var i=e.getRowCount();return e.getValue(t,i-1)}},stddev:function(t){return function(e){var i,n=0,o=e.getRowCount();for(i=0;o>i;i++)n+=e.getValue(t,i);var r=n/o,s=0;for(i=0;o>i;i++){var l=e.getValue(t,i)-r;s+=l*l}var a=Math.sqrt(s/o);return a}}}}()},{}],90:[function(t,e,i){"use strict";var n=t("./JSDataSource"),o=t("./DataSourceSorter"),r=t("./DataSourceSorterComposite"),s=t("./DataSourceFilter"),l=t("./DataSourceGlobalFilter"),a=t("./DataSourceAggregator"),u=t("./aggregations");e.exports=function(){return{JSDataSource:n,DataSourceSorter:o,DataSourceSorterComposite:r,DataSourceFilter:s,DataSourceGlobalFilter:l,DataSourceAggregator:a,aggregations:u}}()},{"./DataSourceAggregator":80,"./DataSourceFilter":82,"./DataSourceGlobalFilter":83,"./DataSourceSorter":84,"./DataSourceSorterComposite":85,"./JSDataSource":86,"./aggregations":89}],91:[function(t,e,i){"use strict";var n=function(t,e){return function(i,n){var o=i[0],r=n[0];if(o===r)o=e?n[1]:i[1],r=e?i[1]:n[1];else{if(null===r)return-1;if(null===o)return 1}return t(o,r)}},o=function(t,e){return t-e},r=function(t,e){return e-t},s=function(t,e){return e>t?-1:1},l=function(t,e){return t>e?-1:1},a=function(t){return"number"===t?n(o,!1):n(s,!1)},u=function(t){return"number"===t?n(r,!0):n(l,!0)};e.exports=function(){function t(t,e,i){var n,o;if(0!==t.length&&(void 0===i&&(i=1),0!==i)){var r=typeof e(0);n=1===i?a(r):u(r);var s=new Array(t.length);for(o=0;o