mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
3775 lines
292 KiB
JavaScript
3775 lines
292 KiB
JavaScript
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||
var ActionTypes = {
|
||
// Connection
|
||
CONNECTION_OPEN: "connection_open",
|
||
CONNECTION_CLOSE: "connection_close",
|
||
CONNECTION_ERROR: "connection_error",
|
||
|
||
// Stores
|
||
SETTINGS_STORE: "settings",
|
||
EVENT_STORE: "events",
|
||
FLOW_STORE: "flows",
|
||
};
|
||
|
||
var StoreCmds = {
|
||
ADD: "add",
|
||
UPDATE: "update",
|
||
REMOVE: "remove",
|
||
RESET: "reset"
|
||
};
|
||
|
||
var ConnectionActions = {
|
||
open: function () {
|
||
AppDispatcher.dispatchViewAction({
|
||
type: ActionTypes.CONNECTION_OPEN
|
||
});
|
||
},
|
||
close: function () {
|
||
AppDispatcher.dispatchViewAction({
|
||
type: ActionTypes.CONNECTION_CLOSE
|
||
});
|
||
},
|
||
error: function () {
|
||
AppDispatcher.dispatchViewAction({
|
||
type: ActionTypes.CONNECTION_ERROR
|
||
});
|
||
}
|
||
};
|
||
|
||
var SettingsActions = {
|
||
update: function (settings) {
|
||
|
||
jQuery.ajax({
|
||
type: "PUT",
|
||
url: "/settings",
|
||
data: settings
|
||
});
|
||
|
||
/*
|
||
//Facebook Flux: We do an optimistic update on the client already.
|
||
AppDispatcher.dispatchViewAction({
|
||
type: ActionTypes.SETTINGS_STORE,
|
||
cmd: StoreCmds.UPDATE,
|
||
data: settings
|
||
});
|
||
*/
|
||
}
|
||
};
|
||
|
||
var EventLogActions_event_id = 0;
|
||
var EventLogActions = {
|
||
add_event: function (message) {
|
||
AppDispatcher.dispatchViewAction({
|
||
type: ActionTypes.EVENT_STORE,
|
||
cmd: StoreCmds.ADD,
|
||
data: {
|
||
message: message,
|
||
level: "web",
|
||
id: "viewAction-" + EventLogActions_event_id++
|
||
}
|
||
});
|
||
}
|
||
};
|
||
|
||
var FlowActions = {
|
||
accept: function (flow) {
|
||
jQuery.post("/flows/" + flow.id + "/accept");
|
||
},
|
||
accept_all: function(){
|
||
jQuery.post("/flows/accept");
|
||
},
|
||
"delete": function(flow){
|
||
jQuery.ajax({
|
||
type:"DELETE",
|
||
url: "/flows/" + flow.id
|
||
});
|
||
},
|
||
duplicate: function(flow){
|
||
jQuery.post("/flows/" + flow.id + "/duplicate");
|
||
},
|
||
replay: function(flow){
|
||
jQuery.post("/flows/" + flow.id + "/replay");
|
||
},
|
||
revert: function(flow){
|
||
jQuery.post("/flows/" + flow.id + "/revert");
|
||
},
|
||
update: function (flow) {
|
||
AppDispatcher.dispatchViewAction({
|
||
type: ActionTypes.FLOW_STORE,
|
||
cmd: StoreCmds.UPDATE,
|
||
data: flow
|
||
});
|
||
},
|
||
clear: function(){
|
||
jQuery.post("/clear");
|
||
}
|
||
};
|
||
|
||
Query = {
|
||
FILTER: "f",
|
||
HIGHLIGHT: "h",
|
||
SHOW_EVENTLOG: "e"
|
||
};
|
||
|
||
module.exports = {
|
||
ActionTypes: ActionTypes,
|
||
ConnectionActions: ConnectionActions
|
||
|
||
};
|
||
},{}],2:[function(require,module,exports){
|
||
|
||
var React = require("react");
|
||
var ReactRouter = require("react-router");
|
||
var $ = require("jquery");
|
||
|
||
var Connection = require("./connection");
|
||
var proxyapp = require("./components/proxyapp.jsx.js");
|
||
|
||
$(function () {
|
||
window.ws = new Connection("/updates");
|
||
|
||
ReactRouter.run(proxyapp.routes, function (Handler) {
|
||
React.render(React.createElement(Handler, null), document.body);
|
||
});
|
||
});
|
||
},{"./components/proxyapp.jsx.js":8,"./connection":11,"jquery":"jquery","react":"react","react-router":"react-router"}],3:[function(require,module,exports){
|
||
var React = require("react");
|
||
var flowutils = require("../flow/utils.js");
|
||
var utils = require("../utils.js");
|
||
|
||
var TLSColumn = React.createClass({displayName: "TLSColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "tls", className: "col-tls"});
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
var ssl = (flow.request.scheme == "https");
|
||
var classes;
|
||
if (ssl) {
|
||
classes = "col-tls col-tls-https";
|
||
} else {
|
||
classes = "col-tls col-tls-http";
|
||
}
|
||
return React.createElement("td", {className: classes});
|
||
}
|
||
});
|
||
|
||
|
||
var IconColumn = React.createClass({displayName: "IconColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "icon", className: "col-icon"});
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
|
||
var icon;
|
||
if (flow.response) {
|
||
var contentType = flowutils.ResponseUtils.getContentType(flow.response);
|
||
|
||
//TODO: We should assign a type to the flow somewhere else.
|
||
if (flow.response.code == 304) {
|
||
icon = "resource-icon-not-modified";
|
||
} else if (300 <= flow.response.code && flow.response.code < 400) {
|
||
icon = "resource-icon-redirect";
|
||
} else if (contentType && contentType.indexOf("image") >= 0) {
|
||
icon = "resource-icon-image";
|
||
} else if (contentType && contentType.indexOf("javascript") >= 0) {
|
||
icon = "resource-icon-js";
|
||
} else if (contentType && contentType.indexOf("css") >= 0) {
|
||
icon = "resource-icon-css";
|
||
} else if (contentType && contentType.indexOf("html") >= 0) {
|
||
icon = "resource-icon-document";
|
||
}
|
||
}
|
||
if (!icon) {
|
||
icon = "resource-icon-plain";
|
||
}
|
||
|
||
|
||
icon += " resource-icon";
|
||
return React.createElement("td", {className: "col-icon"},
|
||
React.createElement("div", {className: icon})
|
||
);
|
||
}
|
||
});
|
||
|
||
var PathColumn = React.createClass({displayName: "PathColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "path", className: "col-path"}, "Path");
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
return React.createElement("td", {className: "col-path"},
|
||
flow.request.is_replay ? React.createElement("i", {className: "fa fa-fw fa-repeat pull-right"}) : null,
|
||
flow.intercepted ? React.createElement("i", {className: "fa fa-fw fa-pause pull-right"}) : null,
|
||
flow.request.scheme + "://" + flow.request.host + flow.request.path
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
var MethodColumn = React.createClass({displayName: "MethodColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "method", className: "col-method"}, "Method");
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
return React.createElement("td", {className: "col-method"}, flow.request.method);
|
||
}
|
||
});
|
||
|
||
|
||
var StatusColumn = React.createClass({displayName: "StatusColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "status", className: "col-status"}, "Status");
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
var status;
|
||
if (flow.response) {
|
||
status = flow.response.code;
|
||
} else {
|
||
status = null;
|
||
}
|
||
return React.createElement("td", {className: "col-status"}, status);
|
||
}
|
||
});
|
||
|
||
|
||
var SizeColumn = React.createClass({displayName: "SizeColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "size", className: "col-size"}, "Size");
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
|
||
var total = flow.request.contentLength;
|
||
if (flow.response) {
|
||
total += flow.response.contentLength || 0;
|
||
}
|
||
var size = utils.formatSize(total);
|
||
return React.createElement("td", {className: "col-size"}, size);
|
||
}
|
||
});
|
||
|
||
|
||
var TimeColumn = React.createClass({displayName: "TimeColumn",
|
||
statics: {
|
||
renderTitle: function () {
|
||
return React.createElement("th", {key: "time", className: "col-time"}, "Time");
|
||
}
|
||
},
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
var time;
|
||
if (flow.response) {
|
||
time = utils.formatTimeDelta(1000 * (flow.response.timestamp_end - flow.request.timestamp_start));
|
||
} else {
|
||
time = "...";
|
||
}
|
||
return React.createElement("td", {className: "col-time"}, time);
|
||
}
|
||
});
|
||
|
||
|
||
var all_columns = [
|
||
TLSColumn,
|
||
IconColumn,
|
||
PathColumn,
|
||
MethodColumn,
|
||
StatusColumn,
|
||
SizeColumn,
|
||
TimeColumn];
|
||
|
||
|
||
module.exports = all_columns;
|
||
|
||
|
||
|
||
},{"../flow/utils.js":14,"../utils.js":17,"react":"react"}],4:[function(require,module,exports){
|
||
var React = require("react");
|
||
var utils = require("./utils.jsx.js");
|
||
var VirtualScrollMixin = require("./virtualscroll.jsx.js");
|
||
var flowtable_columns = require("./flowtable-columns.jsx.js");
|
||
|
||
var FlowRow = React.createClass({displayName: "FlowRow",
|
||
render: function () {
|
||
var flow = this.props.flow;
|
||
var columns = this.props.columns.map(function (Column) {
|
||
return React.createElement(Column, {key: Column.displayName, flow: flow});
|
||
}.bind(this));
|
||
var className = "";
|
||
if (this.props.selected) {
|
||
className += " selected";
|
||
}
|
||
if (this.props.highlighted) {
|
||
className += " highlighted";
|
||
}
|
||
if (flow.intercepted) {
|
||
className += " intercepted";
|
||
}
|
||
if (flow.request) {
|
||
className += " has-request";
|
||
}
|
||
if (flow.response) {
|
||
className += " has-response";
|
||
}
|
||
|
||
return (
|
||
React.createElement("tr", {className: className, onClick: this.props.selectFlow.bind(null, flow)},
|
||
columns
|
||
));
|
||
},
|
||
shouldComponentUpdate: function (nextProps) {
|
||
return true;
|
||
// Further optimization could be done here
|
||
// by calling forceUpdate on flow updates, selection changes and column changes.
|
||
//return (
|
||
//(this.props.columns.length !== nextProps.columns.length) ||
|
||
//(this.props.selected !== nextProps.selected)
|
||
//);
|
||
}
|
||
});
|
||
|
||
var FlowTableHead = React.createClass({displayName: "FlowTableHead",
|
||
render: function () {
|
||
var columns = this.props.columns.map(function (column) {
|
||
return column.renderTitle();
|
||
}.bind(this));
|
||
return React.createElement("thead", null,
|
||
React.createElement("tr", null, columns)
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
var ROW_HEIGHT = 32;
|
||
|
||
var FlowTable = React.createClass({displayName: "FlowTable",
|
||
mixins: [utils.StickyHeadMixin, utils.AutoScrollMixin, VirtualScrollMixin],
|
||
getInitialState: function () {
|
||
return {
|
||
columns: flowtable_columns
|
||
};
|
||
},
|
||
componentWillMount: function () {
|
||
if (this.props.view) {
|
||
this.props.view.addListener("add update remove recalculate", this.onChange);
|
||
}
|
||
},
|
||
componentWillReceiveProps: function (nextProps) {
|
||
if (nextProps.view !== this.props.view) {
|
||
if (this.props.view) {
|
||
this.props.view.removeListener("add update remove recalculate");
|
||
}
|
||
nextProps.view.addListener("add update remove recalculate", this.onChange);
|
||
}
|
||
},
|
||
getDefaultProps: function () {
|
||
return {
|
||
rowHeight: ROW_HEIGHT
|
||
};
|
||
},
|
||
onScrollFlowTable: function () {
|
||
this.adjustHead();
|
||
this.onScroll();
|
||
},
|
||
onChange: function () {
|
||
this.forceUpdate();
|
||
},
|
||
scrollIntoView: function (flow) {
|
||
this.scrollRowIntoView(
|
||
this.props.view.index(flow),
|
||
this.refs.body.getDOMNode().offsetTop
|
||
);
|
||
},
|
||
renderRow: function (flow) {
|
||
var selected = (flow === this.props.selected);
|
||
var highlighted =
|
||
(
|
||
this.props.view._highlight &&
|
||
this.props.view._highlight[flow.id]
|
||
);
|
||
|
||
return React.createElement(FlowRow, {key: flow.id,
|
||
ref: flow.id,
|
||
flow: flow,
|
||
columns: this.state.columns,
|
||
selected: selected,
|
||
highlighted: highlighted,
|
||
selectFlow: this.props.selectFlow}
|
||
);
|
||
},
|
||
render: function () {
|
||
//console.log("render flowtable", this.state.start, this.state.stop, this.props.selected);
|
||
var flows = this.props.view ? this.props.view.list : [];
|
||
|
||
var rows = this.renderRows(flows);
|
||
|
||
return (
|
||
React.createElement("div", {className: "flow-table", onScroll: this.onScrollFlowTable},
|
||
React.createElement("table", null,
|
||
React.createElement(FlowTableHead, {ref: "head",
|
||
columns: this.state.columns}),
|
||
React.createElement("tbody", {ref: "body"},
|
||
this.getPlaceholderTop(flows.length),
|
||
rows,
|
||
this.getPlaceholderBottom(flows.length)
|
||
)
|
||
)
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
module.exports = FlowTable;
|
||
|
||
},{"./flowtable-columns.jsx.js":3,"./utils.jsx.js":9,"./virtualscroll.jsx.js":10,"react":"react"}],5:[function(require,module,exports){
|
||
var React = require("react");
|
||
|
||
var Footer = React.createClass({displayName: "Footer",
|
||
render: function () {
|
||
var mode = this.props.settings.mode;
|
||
var intercept = this.props.settings.intercept;
|
||
return (
|
||
React.createElement("footer", null,
|
||
mode != "regular" ? React.createElement("span", {className: "label label-success"}, mode, " mode") : null,
|
||
" ",
|
||
intercept ? React.createElement("span", {className: "label label-success"}, "Intercept: ", intercept) : null
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
module.exports = Footer;
|
||
},{"react":"react"}],6:[function(require,module,exports){
|
||
var React = require("react");
|
||
var $ = require("jquery");
|
||
|
||
var utils = require("./utils.jsx.js");
|
||
|
||
var FilterDocs = React.createClass({displayName: "FilterDocs",
|
||
statics: {
|
||
xhr: false,
|
||
doc: false
|
||
},
|
||
componentWillMount: function () {
|
||
if (!FilterDocs.doc) {
|
||
FilterDocs.xhr = $.getJSON("/filter-help").done(function (doc) {
|
||
FilterDocs.doc = doc;
|
||
FilterDocs.xhr = false;
|
||
});
|
||
}
|
||
if (FilterDocs.xhr) {
|
||
FilterDocs.xhr.done(function () {
|
||
this.forceUpdate();
|
||
}.bind(this));
|
||
}
|
||
},
|
||
render: function () {
|
||
if (!FilterDocs.doc) {
|
||
return React.createElement("i", {className: "fa fa-spinner fa-spin"});
|
||
} else {
|
||
var commands = FilterDocs.doc.commands.map(function (c) {
|
||
return React.createElement("tr", null,
|
||
React.createElement("td", null, c[0].replace(" ", '\u00a0')),
|
||
React.createElement("td", null, c[1])
|
||
);
|
||
});
|
||
commands.push(React.createElement("tr", null,
|
||
React.createElement("td", {colSpan: "2"},
|
||
React.createElement("a", {href: "https://mitmproxy.org/doc/features/filters.html",
|
||
target: "_blank"},
|
||
React.createElement("i", {className: "fa fa-external-link"}),
|
||
" mitmproxy docs")
|
||
)
|
||
));
|
||
return React.createElement("table", {className: "table table-condensed"},
|
||
React.createElement("tbody", null, commands)
|
||
);
|
||
}
|
||
}
|
||
});
|
||
var FilterInput = React.createClass({displayName: "FilterInput",
|
||
getInitialState: function () {
|
||
// Consider both focus and mouseover for showing/hiding the tooltip,
|
||
// because onBlur of the input is triggered before the click on the tooltip
|
||
// finalized, hiding the tooltip just as the user clicks on it.
|
||
return {
|
||
value: this.props.value,
|
||
focus: false,
|
||
mousefocus: false
|
||
};
|
||
},
|
||
componentWillReceiveProps: function (nextProps) {
|
||
this.setState({value: nextProps.value});
|
||
},
|
||
onChange: function (e) {
|
||
var nextValue = e.target.value;
|
||
this.setState({
|
||
value: nextValue
|
||
});
|
||
// Only propagate valid filters upwards.
|
||
if (this.isValid(nextValue)) {
|
||
this.props.onChange(nextValue);
|
||
}
|
||
},
|
||
isValid: function (filt) {
|
||
try {
|
||
Filt.parse(filt || this.state.value);
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
},
|
||
getDesc: function () {
|
||
var desc;
|
||
try {
|
||
desc = Filt.parse(this.state.value).desc;
|
||
} catch (e) {
|
||
desc = "" + e;
|
||
}
|
||
if (desc !== "true") {
|
||
return desc;
|
||
} else {
|
||
return (
|
||
React.createElement(FilterDocs, null)
|
||
);
|
||
}
|
||
},
|
||
onFocus: function () {
|
||
this.setState({focus: true});
|
||
},
|
||
onBlur: function () {
|
||
this.setState({focus: false});
|
||
},
|
||
onMouseEnter: function () {
|
||
this.setState({mousefocus: true});
|
||
},
|
||
onMouseLeave: function () {
|
||
this.setState({mousefocus: false});
|
||
},
|
||
onKeyDown: function (e) {
|
||
if (e.keyCode === Key.ESC || e.keyCode === Key.ENTER) {
|
||
this.blur();
|
||
// If closed using ESC/ENTER, hide the tooltip.
|
||
this.setState({mousefocus: false});
|
||
}
|
||
},
|
||
blur: function () {
|
||
this.refs.input.getDOMNode().blur();
|
||
},
|
||
focus: function () {
|
||
this.refs.input.getDOMNode().select();
|
||
},
|
||
render: function () {
|
||
var isValid = this.isValid();
|
||
var icon = "fa fa-fw fa-" + this.props.type;
|
||
var groupClassName = "filter-input input-group" + (isValid ? "" : " has-error");
|
||
|
||
var popover;
|
||
if (this.state.focus || this.state.mousefocus) {
|
||
popover = (
|
||
React.createElement("div", {className: "popover bottom", onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave},
|
||
React.createElement("div", {className: "arrow"}),
|
||
React.createElement("div", {className: "popover-content"},
|
||
this.getDesc()
|
||
)
|
||
)
|
||
);
|
||
}
|
||
|
||
return (
|
||
React.createElement("div", {className: groupClassName},
|
||
React.createElement("span", {className: "input-group-addon"},
|
||
React.createElement("i", {className: icon, style: {color: this.props.color}})
|
||
),
|
||
React.createElement("input", {type: "text", placeholder: this.props.placeholder, className: "form-control",
|
||
ref: "input",
|
||
onChange: this.onChange,
|
||
onFocus: this.onFocus,
|
||
onBlur: this.onBlur,
|
||
onKeyDown: this.onKeyDown,
|
||
value: this.state.value}),
|
||
popover
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
var MainMenu = React.createClass({displayName: "MainMenu",
|
||
mixins: [utils.Navigation, utils.State],
|
||
statics: {
|
||
title: "Start",
|
||
route: "flows"
|
||
},
|
||
onFilterChange: function (val) {
|
||
var d = {};
|
||
d[Query.FILTER] = val;
|
||
this.setQuery(d);
|
||
},
|
||
onHighlightChange: function (val) {
|
||
var d = {};
|
||
d[Query.HIGHLIGHT] = val;
|
||
this.setQuery(d);
|
||
},
|
||
onInterceptChange: function (val) {
|
||
SettingsActions.update({intercept: val});
|
||
},
|
||
render: function () {
|
||
var filter = this.getQuery()[Query.FILTER] || "";
|
||
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
|
||
var intercept = this.props.settings.intercept || "";
|
||
|
||
return (
|
||
React.createElement("div", null,
|
||
React.createElement("div", {className: "menu-row"},
|
||
React.createElement(FilterInput, {
|
||
placeholder: "Filter",
|
||
type: "filter",
|
||
color: "black",
|
||
value: filter,
|
||
onChange: this.onFilterChange}),
|
||
React.createElement(FilterInput, {
|
||
placeholder: "Highlight",
|
||
type: "tag",
|
||
color: "hsl(48, 100%, 50%)",
|
||
value: highlight,
|
||
onChange: this.onHighlightChange}),
|
||
React.createElement(FilterInput, {
|
||
placeholder: "Intercept",
|
||
type: "pause",
|
||
color: "hsl(208, 56%, 53%)",
|
||
value: intercept,
|
||
onChange: this.onInterceptChange})
|
||
),
|
||
React.createElement("div", {className: "clearfix"})
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
var ViewMenu = React.createClass({displayName: "ViewMenu",
|
||
statics: {
|
||
title: "View",
|
||
route: "flows"
|
||
},
|
||
mixins: [utils.Navigation, utils.State],
|
||
toggleEventLog: function () {
|
||
var d = {};
|
||
|
||
if (this.getQuery()[Query.SHOW_EVENTLOG]) {
|
||
d[Query.SHOW_EVENTLOG] = undefined;
|
||
} else {
|
||
d[Query.SHOW_EVENTLOG] = "t"; // any non-false value will do it, keep it short
|
||
}
|
||
|
||
this.setQuery(d);
|
||
},
|
||
render: function () {
|
||
var showEventLog = this.getQuery()[Query.SHOW_EVENTLOG];
|
||
return (
|
||
React.createElement("div", null,
|
||
React.createElement("button", {
|
||
className: "btn " + (showEventLog ? "btn-primary" : "btn-default"),
|
||
onClick: this.toggleEventLog},
|
||
React.createElement("i", {className: "fa fa-database"}),
|
||
" Show Eventlog"
|
||
),
|
||
React.createElement("span", null, " ")
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
var ReportsMenu = React.createClass({displayName: "ReportsMenu",
|
||
statics: {
|
||
title: "Visualization",
|
||
route: "reports"
|
||
},
|
||
render: function () {
|
||
return React.createElement("div", null, "Reports Menu");
|
||
}
|
||
});
|
||
|
||
var FileMenu = React.createClass({displayName: "FileMenu",
|
||
getInitialState: function () {
|
||
return {
|
||
showFileMenu: false
|
||
};
|
||
},
|
||
handleFileClick: function (e) {
|
||
e.preventDefault();
|
||
if (!this.state.showFileMenu) {
|
||
var close = function () {
|
||
this.setState({showFileMenu: false});
|
||
document.removeEventListener("click", close);
|
||
}.bind(this);
|
||
document.addEventListener("click", close);
|
||
|
||
this.setState({
|
||
showFileMenu: true
|
||
});
|
||
}
|
||
},
|
||
handleNewClick: function (e) {
|
||
e.preventDefault();
|
||
if (confirm("Delete all flows?")) {
|
||
FlowActions.clear();
|
||
}
|
||
},
|
||
handleOpenClick: function (e) {
|
||
e.preventDefault();
|
||
console.error("unimplemented: handleOpenClick");
|
||
},
|
||
handleSaveClick: function (e) {
|
||
e.preventDefault();
|
||
console.error("unimplemented: handleSaveClick");
|
||
},
|
||
handleShutdownClick: function (e) {
|
||
e.preventDefault();
|
||
console.error("unimplemented: handleShutdownClick");
|
||
},
|
||
render: function () {
|
||
var fileMenuClass = "dropdown pull-left" + (this.state.showFileMenu ? " open" : "");
|
||
|
||
return (
|
||
React.createElement("div", {className: fileMenuClass},
|
||
React.createElement("a", {href: "#", className: "special", onClick: this.handleFileClick}, " File "),
|
||
React.createElement("ul", {className: "dropdown-menu", role: "menu"},
|
||
React.createElement("li", null,
|
||
React.createElement("a", {href: "#", onClick: this.handleNewClick},
|
||
React.createElement("i", {className: "fa fa-fw fa-file"}),
|
||
"New"
|
||
)
|
||
),
|
||
React.createElement("li", {role: "presentation", className: "divider"}),
|
||
React.createElement("li", null,
|
||
React.createElement("a", {href: "http://mitm.it/", target: "_blank"},
|
||
React.createElement("i", {className: "fa fa-fw fa-external-link"}),
|
||
"Install Certificates..."
|
||
)
|
||
)
|
||
/*
|
||
<li>
|
||
<a href="#" onClick={this.handleOpenClick}>
|
||
<i className="fa fa-fw fa-folder-open"></i>
|
||
Open
|
||
</a>
|
||
</li>
|
||
<li>
|
||
<a href="#" onClick={this.handleSaveClick}>
|
||
<i className="fa fa-fw fa-save"></i>
|
||
Save
|
||
</a>
|
||
</li>
|
||
<li role="presentation" className="divider"></li>
|
||
<li>
|
||
<a href="#" onClick={this.handleShutdownClick}>
|
||
<i className="fa fa-fw fa-plug"></i>
|
||
Shutdown
|
||
</a>
|
||
</li>
|
||
*/
|
||
)
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
var header_entries = [MainMenu, ViewMenu /*, ReportsMenu */];
|
||
|
||
|
||
var Header = React.createClass({displayName: "Header",
|
||
mixins: [utils.Navigation],
|
||
getInitialState: function () {
|
||
return {
|
||
active: header_entries[0]
|
||
};
|
||
},
|
||
handleClick: function (active, e) {
|
||
e.preventDefault();
|
||
this.replaceWith(active.route);
|
||
this.setState({active: active});
|
||
},
|
||
render: function () {
|
||
var header = header_entries.map(function (entry, i) {
|
||
var classes = React.addons.classSet({
|
||
active: entry == this.state.active
|
||
});
|
||
return (
|
||
React.createElement("a", {key: i,
|
||
href: "#",
|
||
className: classes,
|
||
onClick: this.handleClick.bind(this, entry)
|
||
},
|
||
entry.title
|
||
)
|
||
);
|
||
}.bind(this));
|
||
|
||
return (
|
||
React.createElement("header", null,
|
||
React.createElement("div", {className: "title-bar"},
|
||
"mitmproxy ", this.props.settings.version
|
||
),
|
||
React.createElement("nav", {className: "nav-tabs nav-tabs-lg"},
|
||
React.createElement(FileMenu, null),
|
||
header
|
||
),
|
||
React.createElement("div", {className: "menu"},
|
||
React.createElement(this.state.active, {settings: this.props.settings})
|
||
)
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
module.exports = {
|
||
Header: Header
|
||
}
|
||
},{"./utils.jsx.js":9,"jquery":"jquery","react":"react"}],7:[function(require,module,exports){
|
||
var React = require("react");
|
||
|
||
var utils = require("./utils.jsx.js");
|
||
var views = require("../store/view.js");
|
||
var Filt = require("../filt/filt.js");
|
||
FlowTable = require("./flowtable.jsx.js");
|
||
|
||
|
||
var MainView = React.createClass({displayName: "MainView",
|
||
mixins: [utils.Navigation, utils.State],
|
||
getInitialState: function () {
|
||
this.onQueryChange(Query.FILTER, function () {
|
||
this.state.view.recalculate(this.getViewFilt(), this.getViewSort());
|
||
}.bind(this));
|
||
this.onQueryChange(Query.HIGHLIGHT, function () {
|
||
this.state.view.recalculate(this.getViewFilt(), this.getViewSort());
|
||
}.bind(this));
|
||
return {
|
||
flows: []
|
||
};
|
||
},
|
||
getViewFilt: function () {
|
||
try {
|
||
var filt = Filt.parse(this.getQuery()[Query.FILTER] || "");
|
||
var highlightStr = this.getQuery()[Query.HIGHLIGHT];
|
||
var highlight = highlightStr ? Filt.parse(highlightStr) : false;
|
||
} catch (e) {
|
||
console.error("Error when processing filter: " + e);
|
||
}
|
||
|
||
return function filter_and_highlight(flow) {
|
||
if (!this._highlight) {
|
||
this._highlight = {};
|
||
}
|
||
this._highlight[flow.id] = highlight && highlight(flow);
|
||
return filt(flow);
|
||
};
|
||
},
|
||
getViewSort: function () {
|
||
},
|
||
componentWillReceiveProps: function (nextProps) {
|
||
if (nextProps.flowStore !== this.props.flowStore) {
|
||
this.closeView();
|
||
this.openView(nextProps.flowStore);
|
||
}
|
||
},
|
||
openView: function (store) {
|
||
var view = new views.StoreView(store, this.getViewFilt(), this.getViewSort());
|
||
this.setState({
|
||
view: view
|
||
});
|
||
|
||
view.addListener("recalculate", this.onRecalculate);
|
||
view.addListener("add update remove", this.onUpdate);
|
||
view.addListener("remove", this.onRemove);
|
||
},
|
||
onRecalculate: function () {
|
||
this.forceUpdate();
|
||
var selected = this.getSelected();
|
||
if (selected) {
|
||
this.refs.flowTable.scrollIntoView(selected);
|
||
}
|
||
},
|
||
onUpdate: function (flow) {
|
||
if (flow.id === this.getParams().flowId) {
|
||
this.forceUpdate();
|
||
}
|
||
},
|
||
onRemove: function (flow_id, index) {
|
||
if (flow_id === this.getParams().flowId) {
|
||
var flow_to_select = this.state.view.list[Math.min(index, this.state.view.list.length -1)];
|
||
this.selectFlow(flow_to_select);
|
||
}
|
||
},
|
||
closeView: function () {
|
||
this.state.view.close();
|
||
},
|
||
componentWillMount: function () {
|
||
this.openView(this.props.flowStore);
|
||
},
|
||
componentWillUnmount: function () {
|
||
this.closeView();
|
||
},
|
||
selectFlow: function (flow) {
|
||
if (flow) {
|
||
this.replaceWith(
|
||
"flow",
|
||
{
|
||
flowId: flow.id,
|
||
detailTab: this.getParams().detailTab || "request"
|
||
}
|
||
);
|
||
this.refs.flowTable.scrollIntoView(flow);
|
||
} else {
|
||
this.replaceWith("flows", {});
|
||
}
|
||
},
|
||
selectFlowRelative: function (shift) {
|
||
var flows = this.state.view.list;
|
||
var index;
|
||
if (!this.getParams().flowId) {
|
||
if (shift > 0) {
|
||
index = flows.length - 1;
|
||
} else {
|
||
index = 0;
|
||
}
|
||
} else {
|
||
var currFlowId = this.getParams().flowId;
|
||
var i = flows.length;
|
||
while (i--) {
|
||
if (flows[i].id === currFlowId) {
|
||
index = i;
|
||
break;
|
||
}
|
||
}
|
||
index = Math.min(
|
||
Math.max(0, index + shift),
|
||
flows.length - 1);
|
||
}
|
||
this.selectFlow(flows[index]);
|
||
},
|
||
onKeyDown: function (e) {
|
||
var flow = this.getSelected();
|
||
if (e.ctrlKey) {
|
||
return;
|
||
}
|
||
switch (e.keyCode) {
|
||
case Key.K:
|
||
case Key.UP:
|
||
this.selectFlowRelative(-1);
|
||
break;
|
||
case Key.J:
|
||
case Key.DOWN:
|
||
this.selectFlowRelative(+1);
|
||
break;
|
||
case Key.SPACE:
|
||
case Key.PAGE_DOWN:
|
||
this.selectFlowRelative(+10);
|
||
break;
|
||
case Key.PAGE_UP:
|
||
this.selectFlowRelative(-10);
|
||
break;
|
||
case Key.END:
|
||
this.selectFlowRelative(+1e10);
|
||
break;
|
||
case Key.HOME:
|
||
this.selectFlowRelative(-1e10);
|
||
break;
|
||
case Key.ESC:
|
||
this.selectFlow(null);
|
||
break;
|
||
case Key.H:
|
||
case Key.LEFT:
|
||
if (this.refs.flowDetails) {
|
||
this.refs.flowDetails.nextTab(-1);
|
||
}
|
||
break;
|
||
case Key.L:
|
||
case Key.TAB:
|
||
case Key.RIGHT:
|
||
if (this.refs.flowDetails) {
|
||
this.refs.flowDetails.nextTab(+1);
|
||
}
|
||
break;
|
||
case Key.C:
|
||
if (e.shiftKey) {
|
||
FlowActions.clear();
|
||
}
|
||
break;
|
||
case Key.D:
|
||
if (flow) {
|
||
if (e.shiftKey) {
|
||
FlowActions.duplicate(flow);
|
||
} else {
|
||
FlowActions.delete(flow);
|
||
}
|
||
}
|
||
break;
|
||
case Key.A:
|
||
if (e.shiftKey) {
|
||
FlowActions.accept_all();
|
||
} else if (flow && flow.intercepted) {
|
||
FlowActions.accept(flow);
|
||
}
|
||
break;
|
||
case Key.R:
|
||
if (!e.shiftKey && flow) {
|
||
FlowActions.replay(flow);
|
||
}
|
||
break;
|
||
case Key.V:
|
||
if(e.shiftKey && flow && flow.modified) {
|
||
FlowActions.revert(flow);
|
||
}
|
||
break;
|
||
default:
|
||
console.debug("keydown", e.keyCode);
|
||
return;
|
||
}
|
||
e.preventDefault();
|
||
},
|
||
getSelected: function () {
|
||
return this.props.flowStore.get(this.getParams().flowId);
|
||
},
|
||
render: function () {
|
||
var selected = this.getSelected();
|
||
|
||
var details;
|
||
if (selected) {
|
||
details = [
|
||
React.createElement(Splitter, {key: "splitter"}),
|
||
React.createElement(FlowDetail, {key: "flowDetails", ref: "flowDetails", flow: selected})
|
||
];
|
||
} else {
|
||
details = null;
|
||
}
|
||
|
||
return (
|
||
React.createElement("div", {className: "main-view", onKeyDown: this.onKeyDown, tabIndex: "0"},
|
||
React.createElement(FlowTable, {ref: "flowTable",
|
||
view: this.state.view,
|
||
selectFlow: this.selectFlow,
|
||
selected: selected}),
|
||
details
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
module.exports = MainView;
|
||
|
||
},{"../filt/filt.js":13,"../store/view.js":16,"./flowtable.jsx.js":4,"./utils.jsx.js":9,"react":"react"}],8:[function(require,module,exports){
|
||
var React = require("react");
|
||
var ReactRouter = require("react-router");
|
||
var _ = require("lodash");
|
||
|
||
var utils = require("./utils.jsx.js");
|
||
var MainView = require("./mainview.jsx.js");
|
||
var Footer = require("./footer.jsx.js");
|
||
var header = require("./header.jsx.js");
|
||
var store = require("../store/store.js");
|
||
|
||
|
||
//TODO: Move out of here, just a stub.
|
||
var Reports = React.createClass({displayName: "Reports",
|
||
render: function () {
|
||
return React.createElement("div", null, "ReportEditor");
|
||
}
|
||
});
|
||
|
||
|
||
var ProxyAppMain = React.createClass({displayName: "ProxyAppMain",
|
||
mixins: [utils.State],
|
||
getInitialState: function () {
|
||
var eventStore = new store.EventLogStore();
|
||
var flowStore = new store.FlowStore();
|
||
var settings = new store.SettingsStore();
|
||
|
||
// Default Settings before fetch
|
||
_.extend(settings.dict,{
|
||
});
|
||
return {
|
||
settings: settings,
|
||
flowStore: flowStore,
|
||
eventStore: eventStore
|
||
};
|
||
},
|
||
componentDidMount: function () {
|
||
this.state.settings.addListener("recalculate", this.onSettingsChange);
|
||
window.app = this;
|
||
},
|
||
componentWillUnmount: function () {
|
||
this.state.settings.removeListener("recalculate", this.onSettingsChange);
|
||
},
|
||
onSettingsChange: function(){
|
||
this.setState({
|
||
settings: this.state.settings
|
||
});
|
||
},
|
||
render: function () {
|
||
|
||
var eventlog;
|
||
if (this.getQuery()[Query.SHOW_EVENTLOG]) {
|
||
eventlog = [
|
||
React.createElement(Splitter, {key: "splitter", axis: "y"}),
|
||
React.createElement(EventLog, {key: "eventlog", eventStore: this.state.eventStore})
|
||
];
|
||
} else {
|
||
eventlog = null;
|
||
}
|
||
|
||
return (
|
||
React.createElement("div", {id: "container"},
|
||
React.createElement(header.Header, {settings: this.state.settings.dict}),
|
||
React.createElement(RouteHandler, {settings: this.state.settings.dict, flowStore: this.state.flowStore}),
|
||
eventlog,
|
||
React.createElement(Footer, {settings: this.state.settings.dict})
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
|
||
var Route = ReactRouter.Route;
|
||
var RouteHandler = ReactRouter.RouteHandler;
|
||
var Redirect = ReactRouter.Redirect;
|
||
var DefaultRoute = ReactRouter.DefaultRoute;
|
||
var NotFoundRoute = ReactRouter.NotFoundRoute;
|
||
|
||
|
||
var routes = (
|
||
React.createElement(Route, {path: "/", handler: ProxyAppMain},
|
||
React.createElement(Route, {name: "flows", path: "flows", handler: MainView}),
|
||
React.createElement(Route, {name: "flow", path: "flows/:flowId/:detailTab", handler: MainView}),
|
||
React.createElement(Route, {name: "reports", handler: Reports}),
|
||
React.createElement(Redirect, {path: "/", to: "flows"})
|
||
)
|
||
);
|
||
|
||
module.exports = {
|
||
routes: routes
|
||
};
|
||
|
||
|
||
},{"../store/store.js":15,"./footer.jsx.js":5,"./header.jsx.js":6,"./mainview.jsx.js":7,"./utils.jsx.js":9,"lodash":"lodash","react":"react","react-router":"react-router"}],9:[function(require,module,exports){
|
||
var React = require("react");
|
||
var ReactRouter = require("react-router");
|
||
var _ = require("lodash");
|
||
|
||
//React utils. For other utilities, see ../utils.js
|
||
|
||
// http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html (also contains inverse example)
|
||
var AutoScrollMixin = {
|
||
componentWillUpdate: function () {
|
||
var node = this.getDOMNode();
|
||
this._shouldScrollBottom = (
|
||
node.scrollTop !== 0 &&
|
||
node.scrollTop + node.clientHeight === node.scrollHeight
|
||
);
|
||
},
|
||
componentDidUpdate: function () {
|
||
if (this._shouldScrollBottom) {
|
||
var node = this.getDOMNode();
|
||
node.scrollTop = node.scrollHeight;
|
||
}
|
||
},
|
||
};
|
||
|
||
|
||
var StickyHeadMixin = {
|
||
adjustHead: function () {
|
||
// Abusing CSS transforms to set the element
|
||
// referenced as head into some kind of position:sticky.
|
||
var head = this.refs.head.getDOMNode();
|
||
head.style.transform = "translate(0," + this.getDOMNode().scrollTop + "px)";
|
||
}
|
||
};
|
||
|
||
|
||
var Navigation = _.extend({}, ReactRouter.Navigation, {
|
||
setQuery: function (dict) {
|
||
var q = this.context.getCurrentQuery();
|
||
for(var i in dict){
|
||
if(dict.hasOwnProperty(i)){
|
||
q[i] = dict[i] || undefined; //falsey values shall be removed.
|
||
}
|
||
}
|
||
q._ = "_"; // workaround for https://github.com/rackt/react-router/pull/599
|
||
this.replaceWith(this.context.getCurrentPath(), this.context.getCurrentParams(), q);
|
||
},
|
||
replaceWith: function(routeNameOrPath, params, query) {
|
||
if(routeNameOrPath === undefined){
|
||
routeNameOrPath = this.context.getCurrentPath();
|
||
}
|
||
if(params === undefined){
|
||
params = this.context.getCurrentParams();
|
||
}
|
||
if(query === undefined){
|
||
query = this.context.getCurrentQuery();
|
||
}
|
||
ReactRouter.Navigation.replaceWith.call(this, routeNameOrPath, params, query);
|
||
}
|
||
});
|
||
_.extend(Navigation.contextTypes, ReactRouter.State.contextTypes);
|
||
|
||
var State = _.extend({}, ReactRouter.State, {
|
||
getInitialState: function () {
|
||
this._query = this.context.getCurrentQuery();
|
||
this._queryWatches = [];
|
||
return null;
|
||
},
|
||
onQueryChange: function (key, callback) {
|
||
this._queryWatches.push({
|
||
key: key,
|
||
callback: callback
|
||
});
|
||
},
|
||
componentWillReceiveProps: function (nextProps, nextState) {
|
||
var q = this.context.getCurrentQuery();
|
||
for (var i = 0; i < this._queryWatches.length; i++) {
|
||
var watch = this._queryWatches[i];
|
||
if (this._query[watch.key] !== q[watch.key]) {
|
||
watch.callback(this._query[watch.key], q[watch.key], watch.key);
|
||
}
|
||
}
|
||
this._query = q;
|
||
}
|
||
});
|
||
|
||
var Splitter = React.createClass({displayName: "Splitter",
|
||
getDefaultProps: function () {
|
||
return {
|
||
axis: "x"
|
||
};
|
||
},
|
||
getInitialState: function () {
|
||
return {
|
||
applied: false,
|
||
startX: false,
|
||
startY: false
|
||
};
|
||
},
|
||
onMouseDown: function (e) {
|
||
this.setState({
|
||
startX: e.pageX,
|
||
startY: e.pageY
|
||
});
|
||
window.addEventListener("mousemove", this.onMouseMove);
|
||
window.addEventListener("mouseup", this.onMouseUp);
|
||
// Occasionally, only a dragEnd event is triggered, but no mouseUp.
|
||
window.addEventListener("dragend", this.onDragEnd);
|
||
},
|
||
onDragEnd: function () {
|
||
this.getDOMNode().style.transform = "";
|
||
window.removeEventListener("dragend", this.onDragEnd);
|
||
window.removeEventListener("mouseup", this.onMouseUp);
|
||
window.removeEventListener("mousemove", this.onMouseMove);
|
||
},
|
||
onMouseUp: function (e) {
|
||
this.onDragEnd();
|
||
|
||
var node = this.getDOMNode();
|
||
var prev = node.previousElementSibling;
|
||
var next = node.nextElementSibling;
|
||
|
||
var dX = e.pageX - this.state.startX;
|
||
var dY = e.pageY - this.state.startY;
|
||
var flexBasis;
|
||
if (this.props.axis === "x") {
|
||
flexBasis = prev.offsetWidth + dX;
|
||
} else {
|
||
flexBasis = prev.offsetHeight + dY;
|
||
}
|
||
|
||
prev.style.flex = "0 0 " + Math.max(0, flexBasis) + "px";
|
||
next.style.flex = "1 1 auto";
|
||
|
||
this.setState({
|
||
applied: true
|
||
});
|
||
this.onResize();
|
||
},
|
||
onMouseMove: function (e) {
|
||
var dX = 0, dY = 0;
|
||
if (this.props.axis === "x") {
|
||
dX = e.pageX - this.state.startX;
|
||
} else {
|
||
dY = e.pageY - this.state.startY;
|
||
}
|
||
this.getDOMNode().style.transform = "translate(" + dX + "px," + dY + "px)";
|
||
},
|
||
onResize: function () {
|
||
// Trigger a global resize event. This notifies components that employ virtual scrolling
|
||
// that their viewport may have changed.
|
||
window.setTimeout(function () {
|
||
window.dispatchEvent(new CustomEvent("resize"));
|
||
}, 1);
|
||
},
|
||
reset: function (willUnmount) {
|
||
if (!this.state.applied) {
|
||
return;
|
||
}
|
||
var node = this.getDOMNode();
|
||
var prev = node.previousElementSibling;
|
||
var next = node.nextElementSibling;
|
||
|
||
prev.style.flex = "";
|
||
next.style.flex = "";
|
||
|
||
if (!willUnmount) {
|
||
this.setState({
|
||
applied: false
|
||
});
|
||
}
|
||
this.onResize();
|
||
},
|
||
componentWillUnmount: function () {
|
||
this.reset(true);
|
||
},
|
||
render: function () {
|
||
var className = "splitter";
|
||
if (this.props.axis === "x") {
|
||
className += " splitter-x";
|
||
} else {
|
||
className += " splitter-y";
|
||
}
|
||
return (
|
||
React.createElement("div", {className: className},
|
||
React.createElement("div", {onMouseDown: this.onMouseDown, draggable: "true"})
|
||
)
|
||
);
|
||
}
|
||
});
|
||
|
||
module.exports = {
|
||
State: State,
|
||
Navigation: Navigation,
|
||
StickyHeadMixin: StickyHeadMixin,
|
||
AutoScrollMixin: AutoScrollMixin,
|
||
Splitter: Splitter
|
||
}
|
||
},{"lodash":"lodash","react":"react","react-router":"react-router"}],10:[function(require,module,exports){
|
||
var React = require("react");
|
||
|
||
var VirtualScrollMixin = {
|
||
getInitialState: function () {
|
||
return {
|
||
start: 0,
|
||
stop: 0
|
||
};
|
||
},
|
||
componentWillMount: function () {
|
||
if (!this.props.rowHeight) {
|
||
console.warn("VirtualScrollMixin: No rowHeight specified", this);
|
||
}
|
||
},
|
||
getPlaceholderTop: function (total) {
|
||
var Tag = this.props.placeholderTagName || "tr";
|
||
// When a large trunk of elements is removed from the button, start may be far off the viewport.
|
||
// To make this issue less severe, limit the top placeholder to the total number of rows.
|
||
var style = {
|
||
height: Math.min(this.state.start, total) * this.props.rowHeight
|
||
};
|
||
var spacer = React.createElement(Tag, {key: "placeholder-top", style: style});
|
||
|
||
if (this.state.start % 2 === 1) {
|
||
// fix even/odd rows
|
||
return [spacer, React.createElement(Tag, {key: "placeholder-top-2"})];
|
||
} else {
|
||
return spacer;
|
||
}
|
||
},
|
||
getPlaceholderBottom: function (total) {
|
||
var Tag = this.props.placeholderTagName || "tr";
|
||
var style = {
|
||
height: Math.max(0, total - this.state.stop) * this.props.rowHeight
|
||
};
|
||
return React.createElement(Tag, {key: "placeholder-bottom", style: style});
|
||
},
|
||
componentDidMount: function () {
|
||
this.onScroll();
|
||
window.addEventListener('resize', this.onScroll);
|
||
},
|
||
componentWillUnmount: function(){
|
||
window.removeEventListener('resize', this.onScroll);
|
||
},
|
||
onScroll: function () {
|
||
var viewport = this.getDOMNode();
|
||
var top = viewport.scrollTop;
|
||
var height = viewport.offsetHeight;
|
||
var start = Math.floor(top / this.props.rowHeight);
|
||
var stop = start + Math.ceil(height / (this.props.rowHeightMin || this.props.rowHeight));
|
||
|
||
this.setState({
|
||
start: start,
|
||
stop: stop
|
||
});
|
||
},
|
||
renderRows: function (elems) {
|
||
var rows = [];
|
||
var max = Math.min(elems.length, this.state.stop);
|
||
|
||
for (var i = this.state.start; i < max; i++) {
|
||
var elem = elems[i];
|
||
rows.push(this.renderRow(elem));
|
||
}
|
||
return rows;
|
||
},
|
||
scrollRowIntoView: function (index, head_height) {
|
||
|
||
var row_top = (index * this.props.rowHeight) + head_height;
|
||
var row_bottom = row_top + this.props.rowHeight;
|
||
|
||
var viewport = this.getDOMNode();
|
||
var viewport_top = viewport.scrollTop;
|
||
var viewport_bottom = viewport_top + viewport.offsetHeight;
|
||
|
||
// Account for pinned thead
|
||
if (row_top - head_height < viewport_top) {
|
||
viewport.scrollTop = row_top - head_height;
|
||
} else if (row_bottom > viewport_bottom) {
|
||
viewport.scrollTop = row_bottom - viewport.offsetHeight;
|
||
}
|
||
},
|
||
};
|
||
|
||
module.exports = VirtualScrollMixin;
|
||
},{"react":"react"}],11:[function(require,module,exports){
|
||
|
||
var actions = require("./actions.js");
|
||
|
||
function Connection(url) {
|
||
if (url[0] === "/") {
|
||
url = location.origin.replace("http", "ws") + url;
|
||
}
|
||
|
||
var ws = new WebSocket(url);
|
||
ws.onopen = function () {
|
||
actions.ConnectionActions.open();
|
||
};
|
||
ws.onmessage = function (message) {
|
||
var m = JSON.parse(message.data);
|
||
AppDispatcher.dispatchServerAction(m);
|
||
};
|
||
ws.onerror = function () {
|
||
actions.ConnectionActions.error();
|
||
EventLogActions.add_event("WebSocket connection error.");
|
||
};
|
||
ws.onclose = function () {
|
||
actions.ConnectionActions.close();
|
||
EventLogActions.add_event("WebSocket connection closed.");
|
||
};
|
||
return ws;
|
||
}
|
||
|
||
module.exports = Connection;
|
||
},{"./actions.js":1}],12:[function(require,module,exports){
|
||
const PayloadSources = {
|
||
VIEW: "view",
|
||
SERVER: "server"
|
||
};
|
||
|
||
|
||
function Dispatcher() {
|
||
this.callbacks = [];
|
||
}
|
||
Dispatcher.prototype.register = function (callback) {
|
||
this.callbacks.push(callback);
|
||
};
|
||
Dispatcher.prototype.unregister = function (callback) {
|
||
var index = this.callbacks.indexOf(callback);
|
||
if (index >= 0) {
|
||
this.callbacks.splice(index, 1);
|
||
}
|
||
};
|
||
Dispatcher.prototype.dispatch = function (payload) {
|
||
console.debug("dispatch", payload);
|
||
for (var i = 0; i < this.callbacks.length; i++) {
|
||
this.callbacks[i](payload);
|
||
}
|
||
};
|
||
|
||
|
||
AppDispatcher = new Dispatcher();
|
||
AppDispatcher.dispatchViewAction = function (action) {
|
||
action.source = PayloadSources.VIEW;
|
||
this.dispatch(action);
|
||
};
|
||
AppDispatcher.dispatchServerAction = function (action) {
|
||
action.source = PayloadSources.SERVER;
|
||
this.dispatch(action);
|
||
};
|
||
|
||
module.exports = {
|
||
AppDispatcher: AppDispatcher
|
||
};
|
||
},{}],13:[function(require,module,exports){
|
||
/* jshint ignore:start */
|
||
Filt = (function() {
|
||
/*
|
||
* Generated by PEG.js 0.8.0.
|
||
*
|
||
* http://pegjs.majda.cz/
|
||
*/
|
||
|
||
function peg$subclass(child, parent) {
|
||
function ctor() { this.constructor = child; }
|
||
ctor.prototype = parent.prototype;
|
||
child.prototype = new ctor();
|
||
}
|
||
|
||
function SyntaxError(message, expected, found, offset, line, column) {
|
||
this.message = message;
|
||
this.expected = expected;
|
||
this.found = found;
|
||
this.offset = offset;
|
||
this.line = line;
|
||
this.column = column;
|
||
|
||
this.name = "SyntaxError";
|
||
}
|
||
|
||
peg$subclass(SyntaxError, Error);
|
||
|
||
function parse(input) {
|
||
var options = arguments.length > 1 ? arguments[1] : {},
|
||
|
||
peg$FAILED = {},
|
||
|
||
peg$startRuleFunctions = { start: peg$parsestart },
|
||
peg$startRuleFunction = peg$parsestart,
|
||
|
||
peg$c0 = { type: "other", description: "filter expression" },
|
||
peg$c1 = peg$FAILED,
|
||
peg$c2 = function(orExpr) { return orExpr; },
|
||
peg$c3 = [],
|
||
peg$c4 = function() {return trueFilter; },
|
||
peg$c5 = { type: "other", description: "whitespace" },
|
||
peg$c6 = /^[ \t\n\r]/,
|
||
peg$c7 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
|
||
peg$c8 = { type: "other", description: "control character" },
|
||
peg$c9 = /^[|&!()~"]/,
|
||
peg$c10 = { type: "class", value: "[|&!()~\"]", description: "[|&!()~\"]" },
|
||
peg$c11 = { type: "other", description: "optional whitespace" },
|
||
peg$c12 = "|",
|
||
peg$c13 = { type: "literal", value: "|", description: "\"|\"" },
|
||
peg$c14 = function(first, second) { return or(first, second); },
|
||
peg$c15 = "&",
|
||
peg$c16 = { type: "literal", value: "&", description: "\"&\"" },
|
||
peg$c17 = function(first, second) { return and(first, second); },
|
||
peg$c18 = "!",
|
||
peg$c19 = { type: "literal", value: "!", description: "\"!\"" },
|
||
peg$c20 = function(expr) { return not(expr); },
|
||
peg$c21 = "(",
|
||
peg$c22 = { type: "literal", value: "(", description: "\"(\"" },
|
||
peg$c23 = ")",
|
||
peg$c24 = { type: "literal", value: ")", description: "\")\"" },
|
||
peg$c25 = function(expr) { return binding(expr); },
|
||
peg$c26 = "~a",
|
||
peg$c27 = { type: "literal", value: "~a", description: "\"~a\"" },
|
||
peg$c28 = function() { return assetFilter; },
|
||
peg$c29 = "~e",
|
||
peg$c30 = { type: "literal", value: "~e", description: "\"~e\"" },
|
||
peg$c31 = function() { return errorFilter; },
|
||
peg$c32 = "~q",
|
||
peg$c33 = { type: "literal", value: "~q", description: "\"~q\"" },
|
||
peg$c34 = function() { return noResponseFilter; },
|
||
peg$c35 = "~s",
|
||
peg$c36 = { type: "literal", value: "~s", description: "\"~s\"" },
|
||
peg$c37 = function() { return responseFilter; },
|
||
peg$c38 = "true",
|
||
peg$c39 = { type: "literal", value: "true", description: "\"true\"" },
|
||
peg$c40 = function() { return trueFilter; },
|
||
peg$c41 = "false",
|
||
peg$c42 = { type: "literal", value: "false", description: "\"false\"" },
|
||
peg$c43 = function() { return falseFilter; },
|
||
peg$c44 = "~c",
|
||
peg$c45 = { type: "literal", value: "~c", description: "\"~c\"" },
|
||
peg$c46 = function(s) { return responseCode(s); },
|
||
peg$c47 = "~d",
|
||
peg$c48 = { type: "literal", value: "~d", description: "\"~d\"" },
|
||
peg$c49 = function(s) { return domain(s); },
|
||
peg$c50 = "~h",
|
||
peg$c51 = { type: "literal", value: "~h", description: "\"~h\"" },
|
||
peg$c52 = function(s) { return header(s); },
|
||
peg$c53 = "~hq",
|
||
peg$c54 = { type: "literal", value: "~hq", description: "\"~hq\"" },
|
||
peg$c55 = function(s) { return requestHeader(s); },
|
||
peg$c56 = "~hs",
|
||
peg$c57 = { type: "literal", value: "~hs", description: "\"~hs\"" },
|
||
peg$c58 = function(s) { return responseHeader(s); },
|
||
peg$c59 = "~m",
|
||
peg$c60 = { type: "literal", value: "~m", description: "\"~m\"" },
|
||
peg$c61 = function(s) { return method(s); },
|
||
peg$c62 = "~t",
|
||
peg$c63 = { type: "literal", value: "~t", description: "\"~t\"" },
|
||
peg$c64 = function(s) { return contentType(s); },
|
||
peg$c65 = "~tq",
|
||
peg$c66 = { type: "literal", value: "~tq", description: "\"~tq\"" },
|
||
peg$c67 = function(s) { return requestContentType(s); },
|
||
peg$c68 = "~ts",
|
||
peg$c69 = { type: "literal", value: "~ts", description: "\"~ts\"" },
|
||
peg$c70 = function(s) { return responseContentType(s); },
|
||
peg$c71 = "~u",
|
||
peg$c72 = { type: "literal", value: "~u", description: "\"~u\"" },
|
||
peg$c73 = function(s) { return url(s); },
|
||
peg$c74 = { type: "other", description: "integer" },
|
||
peg$c75 = null,
|
||
peg$c76 = /^['"]/,
|
||
peg$c77 = { type: "class", value: "['\"]", description: "['\"]" },
|
||
peg$c78 = /^[0-9]/,
|
||
peg$c79 = { type: "class", value: "[0-9]", description: "[0-9]" },
|
||
peg$c80 = function(digits) { return parseInt(digits.join(""), 10); },
|
||
peg$c81 = { type: "other", description: "string" },
|
||
peg$c82 = "\"",
|
||
peg$c83 = { type: "literal", value: "\"", description: "\"\\\"\"" },
|
||
peg$c84 = function(chars) { return chars.join(""); },
|
||
peg$c85 = "'",
|
||
peg$c86 = { type: "literal", value: "'", description: "\"'\"" },
|
||
peg$c87 = void 0,
|
||
peg$c88 = /^["\\]/,
|
||
peg$c89 = { type: "class", value: "[\"\\\\]", description: "[\"\\\\]" },
|
||
peg$c90 = { type: "any", description: "any character" },
|
||
peg$c91 = function(char) { return char; },
|
||
peg$c92 = "\\",
|
||
peg$c93 = { type: "literal", value: "\\", description: "\"\\\\\"" },
|
||
peg$c94 = /^['\\]/,
|
||
peg$c95 = { type: "class", value: "['\\\\]", description: "['\\\\]" },
|
||
peg$c96 = /^['"\\]/,
|
||
peg$c97 = { type: "class", value: "['\"\\\\]", description: "['\"\\\\]" },
|
||
peg$c98 = "n",
|
||
peg$c99 = { type: "literal", value: "n", description: "\"n\"" },
|
||
peg$c100 = function() { return "\n"; },
|
||
peg$c101 = "r",
|
||
peg$c102 = { type: "literal", value: "r", description: "\"r\"" },
|
||
peg$c103 = function() { return "\r"; },
|
||
peg$c104 = "t",
|
||
peg$c105 = { type: "literal", value: "t", description: "\"t\"" },
|
||
peg$c106 = function() { return "\t"; },
|
||
|
||
peg$currPos = 0,
|
||
peg$reportedPos = 0,
|
||
peg$cachedPos = 0,
|
||
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
|
||
peg$maxFailPos = 0,
|
||
peg$maxFailExpected = [],
|
||
peg$silentFails = 0,
|
||
|
||
peg$result;
|
||
|
||
if ("startRule" in options) {
|
||
if (!(options.startRule in peg$startRuleFunctions)) {
|
||
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
||
}
|
||
|
||
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
||
}
|
||
|
||
function text() {
|
||
return input.substring(peg$reportedPos, peg$currPos);
|
||
}
|
||
|
||
function offset() {
|
||
return peg$reportedPos;
|
||
}
|
||
|
||
function line() {
|
||
return peg$computePosDetails(peg$reportedPos).line;
|
||
}
|
||
|
||
function column() {
|
||
return peg$computePosDetails(peg$reportedPos).column;
|
||
}
|
||
|
||
function expected(description) {
|
||
throw peg$buildException(
|
||
null,
|
||
[{ type: "other", description: description }],
|
||
peg$reportedPos
|
||
);
|
||
}
|
||
|
||
function error(message) {
|
||
throw peg$buildException(message, null, peg$reportedPos);
|
||
}
|
||
|
||
function peg$computePosDetails(pos) {
|
||
function advance(details, startPos, endPos) {
|
||
var p, ch;
|
||
|
||
for (p = startPos; p < endPos; p++) {
|
||
ch = input.charAt(p);
|
||
if (ch === "\n") {
|
||
if (!details.seenCR) { details.line++; }
|
||
details.column = 1;
|
||
details.seenCR = false;
|
||
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
|
||
details.line++;
|
||
details.column = 1;
|
||
details.seenCR = true;
|
||
} else {
|
||
details.column++;
|
||
details.seenCR = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (peg$cachedPos !== pos) {
|
||
if (peg$cachedPos > pos) {
|
||
peg$cachedPos = 0;
|
||
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
|
||
}
|
||
advance(peg$cachedPosDetails, peg$cachedPos, pos);
|
||
peg$cachedPos = pos;
|
||
}
|
||
|
||
return peg$cachedPosDetails;
|
||
}
|
||
|
||
function peg$fail(expected) {
|
||
if (peg$currPos < peg$maxFailPos) { return; }
|
||
|
||
if (peg$currPos > peg$maxFailPos) {
|
||
peg$maxFailPos = peg$currPos;
|
||
peg$maxFailExpected = [];
|
||
}
|
||
|
||
peg$maxFailExpected.push(expected);
|
||
}
|
||
|
||
function peg$buildException(message, expected, pos) {
|
||
function cleanupExpected(expected) {
|
||
var i = 1;
|
||
|
||
expected.sort(function(a, b) {
|
||
if (a.description < b.description) {
|
||
return -1;
|
||
} else if (a.description > b.description) {
|
||
return 1;
|
||
} else {
|
||
return 0;
|
||
}
|
||
});
|
||
|
||
while (i < expected.length) {
|
||
if (expected[i - 1] === expected[i]) {
|
||
expected.splice(i, 1);
|
||
} else {
|
||
i++;
|
||
}
|
||
}
|
||
}
|
||
|
||
function buildMessage(expected, found) {
|
||
function stringEscape(s) {
|
||
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
|
||
|
||
return s
|
||
.replace(/\\/g, '\\\\')
|
||
.replace(/"/g, '\\"')
|
||
.replace(/\x08/g, '\\b')
|
||
.replace(/\t/g, '\\t')
|
||
.replace(/\n/g, '\\n')
|
||
.replace(/\f/g, '\\f')
|
||
.replace(/\r/g, '\\r')
|
||
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
|
||
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
|
||
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
|
||
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
|
||
}
|
||
|
||
var expectedDescs = new Array(expected.length),
|
||
expectedDesc, foundDesc, i;
|
||
|
||
for (i = 0; i < expected.length; i++) {
|
||
expectedDescs[i] = expected[i].description;
|
||
}
|
||
|
||
expectedDesc = expected.length > 1
|
||
? expectedDescs.slice(0, -1).join(", ")
|
||
+ " or "
|
||
+ expectedDescs[expected.length - 1]
|
||
: expectedDescs[0];
|
||
|
||
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
|
||
|
||
return "Expected " + expectedDesc + " but " + foundDesc + " found.";
|
||
}
|
||
|
||
var posDetails = peg$computePosDetails(pos),
|
||
found = pos < input.length ? input.charAt(pos) : null;
|
||
|
||
if (expected !== null) {
|
||
cleanupExpected(expected);
|
||
}
|
||
|
||
return new SyntaxError(
|
||
message !== null ? message : buildMessage(expected, found),
|
||
expected,
|
||
found,
|
||
pos,
|
||
posDetails.line,
|
||
posDetails.column
|
||
);
|
||
}
|
||
|
||
function peg$parsestart() {
|
||
var s0, s1, s2, s3;
|
||
|
||
peg$silentFails++;
|
||
s0 = peg$currPos;
|
||
s1 = peg$parse__();
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parseOrExpr();
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parse__();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c2(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
s1 = [];
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c4();
|
||
}
|
||
s0 = s1;
|
||
}
|
||
peg$silentFails--;
|
||
if (s0 === peg$FAILED) {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c0); }
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parsews() {
|
||
var s0, s1;
|
||
|
||
peg$silentFails++;
|
||
if (peg$c6.test(input.charAt(peg$currPos))) {
|
||
s0 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s0 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c7); }
|
||
}
|
||
peg$silentFails--;
|
||
if (s0 === peg$FAILED) {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parsecc() {
|
||
var s0, s1;
|
||
|
||
peg$silentFails++;
|
||
if (peg$c9.test(input.charAt(peg$currPos))) {
|
||
s0 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s0 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c10); }
|
||
}
|
||
peg$silentFails--;
|
||
if (s0 === peg$FAILED) {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c8); }
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parse__() {
|
||
var s0, s1;
|
||
|
||
peg$silentFails++;
|
||
s0 = [];
|
||
s1 = peg$parsews();
|
||
while (s1 !== peg$FAILED) {
|
||
s0.push(s1);
|
||
s1 = peg$parsews();
|
||
}
|
||
peg$silentFails--;
|
||
if (s0 === peg$FAILED) {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c11); }
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseOrExpr() {
|
||
var s0, s1, s2, s3, s4, s5;
|
||
|
||
s0 = peg$currPos;
|
||
s1 = peg$parseAndExpr();
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parse__();
|
||
if (s2 !== peg$FAILED) {
|
||
if (input.charCodeAt(peg$currPos) === 124) {
|
||
s3 = peg$c12;
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c13); }
|
||
}
|
||
if (s3 !== peg$FAILED) {
|
||
s4 = peg$parse__();
|
||
if (s4 !== peg$FAILED) {
|
||
s5 = peg$parseOrExpr();
|
||
if (s5 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c14(s1, s5);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$parseAndExpr();
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseAndExpr() {
|
||
var s0, s1, s2, s3, s4, s5;
|
||
|
||
s0 = peg$currPos;
|
||
s1 = peg$parseNotExpr();
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parse__();
|
||
if (s2 !== peg$FAILED) {
|
||
if (input.charCodeAt(peg$currPos) === 38) {
|
||
s3 = peg$c15;
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c16); }
|
||
}
|
||
if (s3 !== peg$FAILED) {
|
||
s4 = peg$parse__();
|
||
if (s4 !== peg$FAILED) {
|
||
s5 = peg$parseAndExpr();
|
||
if (s5 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c17(s1, s5);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
s1 = peg$parseNotExpr();
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseAndExpr();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c17(s1, s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$parseNotExpr();
|
||
}
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseNotExpr() {
|
||
var s0, s1, s2, s3;
|
||
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 33) {
|
||
s1 = peg$c18;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c19); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parse__();
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseNotExpr();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c20(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$parseBindingExpr();
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseBindingExpr() {
|
||
var s0, s1, s2, s3, s4, s5;
|
||
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 40) {
|
||
s1 = peg$c21;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c22); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parse__();
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseOrExpr();
|
||
if (s3 !== peg$FAILED) {
|
||
s4 = peg$parse__();
|
||
if (s4 !== peg$FAILED) {
|
||
if (input.charCodeAt(peg$currPos) === 41) {
|
||
s5 = peg$c23;
|
||
peg$currPos++;
|
||
} else {
|
||
s5 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
||
}
|
||
if (s5 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c25(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$parseExpr();
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseExpr() {
|
||
var s0;
|
||
|
||
s0 = peg$parseNullaryExpr();
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$parseUnaryExpr();
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseNullaryExpr() {
|
||
var s0, s1;
|
||
|
||
s0 = peg$parseBooleanLiteral();
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c26) {
|
||
s1 = peg$c26;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c27); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c28();
|
||
}
|
||
s0 = s1;
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c29) {
|
||
s1 = peg$c29;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c30); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c31();
|
||
}
|
||
s0 = s1;
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c32) {
|
||
s1 = peg$c32;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c33); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c34();
|
||
}
|
||
s0 = s1;
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c35) {
|
||
s1 = peg$c35;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c36); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c37();
|
||
}
|
||
s0 = s1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseBooleanLiteral() {
|
||
var s0, s1;
|
||
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 4) === peg$c38) {
|
||
s1 = peg$c38;
|
||
peg$currPos += 4;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c39); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c40();
|
||
}
|
||
s0 = s1;
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 5) === peg$c41) {
|
||
s1 = peg$c41;
|
||
peg$currPos += 5;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c42); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c43();
|
||
}
|
||
s0 = s1;
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseUnaryExpr() {
|
||
var s0, s1, s2, s3;
|
||
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c44) {
|
||
s1 = peg$c44;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c45); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseIntegerLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c46(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c47) {
|
||
s1 = peg$c47;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c48); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c49(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c50) {
|
||
s1 = peg$c50;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c51); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c52(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 3) === peg$c53) {
|
||
s1 = peg$c53;
|
||
peg$currPos += 3;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c54); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c55(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 3) === peg$c56) {
|
||
s1 = peg$c56;
|
||
peg$currPos += 3;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c57); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c58(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c59) {
|
||
s1 = peg$c59;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c60); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c61(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c62) {
|
||
s1 = peg$c62;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c63); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c64(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 3) === peg$c65) {
|
||
s1 = peg$c65;
|
||
peg$currPos += 3;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c66); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c67(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 3) === peg$c68) {
|
||
s1 = peg$c68;
|
||
peg$currPos += 3;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c69); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c70(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.substr(peg$currPos, 2) === peg$c71) {
|
||
s1 = peg$c71;
|
||
peg$currPos += 2;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c72); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parsews();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parsews();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
s3 = peg$parseStringLiteral();
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c73(s3);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
s1 = peg$parseStringLiteral();
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c73(s1);
|
||
}
|
||
s0 = s1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseIntegerLiteral() {
|
||
var s0, s1, s2, s3;
|
||
|
||
peg$silentFails++;
|
||
s0 = peg$currPos;
|
||
if (peg$c76.test(input.charAt(peg$currPos))) {
|
||
s1 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c77); }
|
||
}
|
||
if (s1 === peg$FAILED) {
|
||
s1 = peg$c75;
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
if (peg$c78.test(input.charAt(peg$currPos))) {
|
||
s3 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c79); }
|
||
}
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
if (peg$c78.test(input.charAt(peg$currPos))) {
|
||
s3 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c79); }
|
||
}
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
if (peg$c76.test(input.charAt(peg$currPos))) {
|
||
s3 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c77); }
|
||
}
|
||
if (s3 === peg$FAILED) {
|
||
s3 = peg$c75;
|
||
}
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c80(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
peg$silentFails--;
|
||
if (s0 === peg$FAILED) {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c74); }
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseStringLiteral() {
|
||
var s0, s1, s2, s3;
|
||
|
||
peg$silentFails++;
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 34) {
|
||
s1 = peg$c82;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c83); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parseDoubleStringChar();
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parseDoubleStringChar();
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
if (input.charCodeAt(peg$currPos) === 34) {
|
||
s3 = peg$c82;
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c83); }
|
||
}
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c84(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 39) {
|
||
s1 = peg$c85;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c86); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parseSingleStringChar();
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parseSingleStringChar();
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
if (input.charCodeAt(peg$currPos) === 39) {
|
||
s3 = peg$c85;
|
||
peg$currPos++;
|
||
} else {
|
||
s3 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c86); }
|
||
}
|
||
if (s3 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c84(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
s1 = peg$currPos;
|
||
peg$silentFails++;
|
||
s2 = peg$parsecc();
|
||
peg$silentFails--;
|
||
if (s2 === peg$FAILED) {
|
||
s1 = peg$c87;
|
||
} else {
|
||
peg$currPos = s1;
|
||
s1 = peg$c1;
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = [];
|
||
s3 = peg$parseUnquotedStringChar();
|
||
if (s3 !== peg$FAILED) {
|
||
while (s3 !== peg$FAILED) {
|
||
s2.push(s3);
|
||
s3 = peg$parseUnquotedStringChar();
|
||
}
|
||
} else {
|
||
s2 = peg$c1;
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c84(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
}
|
||
}
|
||
peg$silentFails--;
|
||
if (s0 === peg$FAILED) {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c81); }
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseDoubleStringChar() {
|
||
var s0, s1, s2;
|
||
|
||
s0 = peg$currPos;
|
||
s1 = peg$currPos;
|
||
peg$silentFails++;
|
||
if (peg$c88.test(input.charAt(peg$currPos))) {
|
||
s2 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s2 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c89); }
|
||
}
|
||
peg$silentFails--;
|
||
if (s2 === peg$FAILED) {
|
||
s1 = peg$c87;
|
||
} else {
|
||
peg$currPos = s1;
|
||
s1 = peg$c1;
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
if (input.length > peg$currPos) {
|
||
s2 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s2 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c90); }
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c91(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 92) {
|
||
s1 = peg$c92;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c93); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parseEscapeSequence();
|
||
if (s2 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c91(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseSingleStringChar() {
|
||
var s0, s1, s2;
|
||
|
||
s0 = peg$currPos;
|
||
s1 = peg$currPos;
|
||
peg$silentFails++;
|
||
if (peg$c94.test(input.charAt(peg$currPos))) {
|
||
s2 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s2 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c95); }
|
||
}
|
||
peg$silentFails--;
|
||
if (s2 === peg$FAILED) {
|
||
s1 = peg$c87;
|
||
} else {
|
||
peg$currPos = s1;
|
||
s1 = peg$c1;
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
if (input.length > peg$currPos) {
|
||
s2 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s2 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c90); }
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c91(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 92) {
|
||
s1 = peg$c92;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c93); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
s2 = peg$parseEscapeSequence();
|
||
if (s2 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c91(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseUnquotedStringChar() {
|
||
var s0, s1, s2;
|
||
|
||
s0 = peg$currPos;
|
||
s1 = peg$currPos;
|
||
peg$silentFails++;
|
||
s2 = peg$parsews();
|
||
peg$silentFails--;
|
||
if (s2 === peg$FAILED) {
|
||
s1 = peg$c87;
|
||
} else {
|
||
peg$currPos = s1;
|
||
s1 = peg$c1;
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
if (input.length > peg$currPos) {
|
||
s2 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s2 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c90); }
|
||
}
|
||
if (s2 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c91(s2);
|
||
s0 = s1;
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
} else {
|
||
peg$currPos = s0;
|
||
s0 = peg$c1;
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
function peg$parseEscapeSequence() {
|
||
var s0, s1;
|
||
|
||
if (peg$c96.test(input.charAt(peg$currPos))) {
|
||
s0 = input.charAt(peg$currPos);
|
||
peg$currPos++;
|
||
} else {
|
||
s0 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c97); }
|
||
}
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 110) {
|
||
s1 = peg$c98;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c99); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c100();
|
||
}
|
||
s0 = s1;
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 114) {
|
||
s1 = peg$c101;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c102); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c103();
|
||
}
|
||
s0 = s1;
|
||
if (s0 === peg$FAILED) {
|
||
s0 = peg$currPos;
|
||
if (input.charCodeAt(peg$currPos) === 116) {
|
||
s1 = peg$c104;
|
||
peg$currPos++;
|
||
} else {
|
||
s1 = peg$FAILED;
|
||
if (peg$silentFails === 0) { peg$fail(peg$c105); }
|
||
}
|
||
if (s1 !== peg$FAILED) {
|
||
peg$reportedPos = s0;
|
||
s1 = peg$c106();
|
||
}
|
||
s0 = s1;
|
||
}
|
||
}
|
||
}
|
||
|
||
return s0;
|
||
}
|
||
|
||
|
||
function or(first, second) {
|
||
// Add explicit function names to ease debugging.
|
||
function orFilter() {
|
||
return first.apply(this, arguments) || second.apply(this, arguments);
|
||
}
|
||
orFilter.desc = first.desc + " or " + second.desc;
|
||
return orFilter;
|
||
}
|
||
function and(first, second) {
|
||
function andFilter() {
|
||
return first.apply(this, arguments) && second.apply(this, arguments);
|
||
}
|
||
andFilter.desc = first.desc + " and " + second.desc;
|
||
return andFilter;
|
||
}
|
||
function not(expr) {
|
||
function notFilter() {
|
||
return !expr.apply(this, arguments);
|
||
}
|
||
notFilter.desc = "not " + expr.desc;
|
||
return notFilter;
|
||
}
|
||
function binding(expr) {
|
||
function bindingFilter() {
|
||
return expr.apply(this, arguments);
|
||
}
|
||
bindingFilter.desc = "(" + expr.desc + ")";
|
||
return bindingFilter;
|
||
}
|
||
function trueFilter(flow) {
|
||
return true;
|
||
}
|
||
trueFilter.desc = "true";
|
||
function falseFilter(flow) {
|
||
return false;
|
||
}
|
||
falseFilter.desc = "false";
|
||
|
||
var ASSET_TYPES = [
|
||
new RegExp("text/javascript"),
|
||
new RegExp("application/x-javascript"),
|
||
new RegExp("application/javascript"),
|
||
new RegExp("text/css"),
|
||
new RegExp("image/.*"),
|
||
new RegExp("application/x-shockwave-flash")
|
||
];
|
||
function assetFilter(flow) {
|
||
if (flow.response) {
|
||
var ct = ResponseUtils.getContentType(flow.response);
|
||
var i = ASSET_TYPES.length;
|
||
while (i--) {
|
||
if (ASSET_TYPES[i].test(ct)) {
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
assetFilter.desc = "is asset";
|
||
function responseCode(code){
|
||
function responseCodeFilter(flow){
|
||
return flow.response && flow.response.code === code;
|
||
}
|
||
responseCodeFilter.desc = "resp. code is " + code;
|
||
return responseCodeFilter;
|
||
}
|
||
function domain(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function domainFilter(flow){
|
||
return flow.request && regex.test(flow.request.host);
|
||
}
|
||
domainFilter.desc = "domain matches " + regex;
|
||
return domainFilter;
|
||
}
|
||
function errorFilter(flow){
|
||
return !!flow.error;
|
||
}
|
||
errorFilter.desc = "has error";
|
||
function header(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function headerFilter(flow){
|
||
return (
|
||
(flow.request && RequestUtils.match_header(flow.request, regex))
|
||
||
|
||
(flow.response && ResponseUtils.match_header(flow.response, regex))
|
||
);
|
||
}
|
||
headerFilter.desc = "header matches " + regex;
|
||
return headerFilter;
|
||
}
|
||
function requestHeader(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function requestHeaderFilter(flow){
|
||
return (flow.request && RequestUtils.match_header(flow.request, regex));
|
||
}
|
||
requestHeaderFilter.desc = "req. header matches " + regex;
|
||
return requestHeaderFilter;
|
||
}
|
||
function responseHeader(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function responseHeaderFilter(flow){
|
||
return (flow.response && ResponseUtils.match_header(flow.response, regex));
|
||
}
|
||
responseHeaderFilter.desc = "resp. header matches " + regex;
|
||
return responseHeaderFilter;
|
||
}
|
||
function method(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function methodFilter(flow){
|
||
return flow.request && regex.test(flow.request.method);
|
||
}
|
||
methodFilter.desc = "method matches " + regex;
|
||
return methodFilter;
|
||
}
|
||
function noResponseFilter(flow){
|
||
return flow.request && !flow.response;
|
||
}
|
||
noResponseFilter.desc = "has no response";
|
||
function responseFilter(flow){
|
||
return !!flow.response;
|
||
}
|
||
responseFilter.desc = "has response";
|
||
|
||
function contentType(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function contentTypeFilter(flow){
|
||
return (
|
||
(flow.request && regex.test(RequestUtils.getContentType(flow.request)))
|
||
||
|
||
(flow.response && regex.test(ResponseUtils.getContentType(flow.response)))
|
||
);
|
||
}
|
||
contentTypeFilter.desc = "content type matches " + regex;
|
||
return contentTypeFilter;
|
||
}
|
||
function requestContentType(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function requestContentTypeFilter(flow){
|
||
return flow.request && regex.test(RequestUtils.getContentType(flow.request));
|
||
}
|
||
requestContentTypeFilter.desc = "req. content type matches " + regex;
|
||
return requestContentTypeFilter;
|
||
}
|
||
function responseContentType(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function responseContentTypeFilter(flow){
|
||
return flow.response && regex.test(ResponseUtils.getContentType(flow.response));
|
||
}
|
||
responseContentTypeFilter.desc = "resp. content type matches " + regex;
|
||
return responseContentTypeFilter;
|
||
}
|
||
function url(regex){
|
||
regex = new RegExp(regex, "i");
|
||
function urlFilter(flow){
|
||
return flow.request && regex.test(RequestUtils.pretty_url(flow.request));
|
||
}
|
||
urlFilter.desc = "url matches " + regex;
|
||
return urlFilter;
|
||
}
|
||
|
||
|
||
peg$result = peg$startRuleFunction();
|
||
|
||
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
||
return peg$result;
|
||
} else {
|
||
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
||
peg$fail({ type: "end", description: "end of input" });
|
||
}
|
||
|
||
throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
|
||
}
|
||
}
|
||
|
||
return {
|
||
SyntaxError: SyntaxError,
|
||
parse: parse
|
||
};
|
||
})();
|
||
/* jshint ignore:end */
|
||
|
||
module.exports = Filt;
|
||
|
||
},{}],14:[function(require,module,exports){
|
||
var _ = require("lodash");
|
||
|
||
var _MessageUtils = {
|
||
getContentType: function (message) {
|
||
return this.get_first_header(message, /^Content-Type$/i);
|
||
},
|
||
get_first_header: function (message, regex) {
|
||
//FIXME: Cache Invalidation.
|
||
if (!message._headerLookups)
|
||
Object.defineProperty(message, "_headerLookups", {
|
||
value: {},
|
||
configurable: false,
|
||
enumerable: false,
|
||
writable: false
|
||
});
|
||
if (!(regex in message._headerLookups)) {
|
||
var header;
|
||
for (var i = 0; i < message.headers.length; i++) {
|
||
if (!!message.headers[i][0].match(regex)) {
|
||
header = message.headers[i];
|
||
break;
|
||
}
|
||
}
|
||
message._headerLookups[regex] = header ? header[1] : undefined;
|
||
}
|
||
return message._headerLookups[regex];
|
||
},
|
||
match_header: function (message, regex) {
|
||
var headers = message.headers;
|
||
var i = headers.length;
|
||
while (i--) {
|
||
if (regex.test(headers[i].join(" "))) {
|
||
return headers[i];
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
};
|
||
|
||
var defaultPorts = {
|
||
"http": 80,
|
||
"https": 443
|
||
};
|
||
|
||
var RequestUtils = _.extend(_MessageUtils, {
|
||
pretty_host: function (request) {
|
||
//FIXME: Add hostheader
|
||
return request.host;
|
||
},
|
||
pretty_url: function (request) {
|
||
var port = "";
|
||
if (defaultPorts[request.scheme] !== request.port) {
|
||
port = ":" + request.port;
|
||
}
|
||
return request.scheme + "://" + this.pretty_host(request) + port + request.path;
|
||
}
|
||
});
|
||
|
||
var ResponseUtils = _.extend(_MessageUtils, {});
|
||
|
||
|
||
module.exports = {
|
||
ResponseUtils: ResponseUtils
|
||
}
|
||
},{"lodash":"lodash"}],15:[function(require,module,exports){
|
||
|
||
var _ = require("lodash");
|
||
var $ = require("jquery");
|
||
|
||
var utils = require("../utils.js");
|
||
var actions = require("../actions.js");
|
||
var dispatcher = require("../dispatcher.js");
|
||
|
||
|
||
function ListStore() {
|
||
utils.EventEmitter.call(this);
|
||
this.reset();
|
||
}
|
||
_.extend(ListStore.prototype, utils.EventEmitter.prototype, {
|
||
add: function (elem) {
|
||
if (elem.id in this._pos_map) {
|
||
return;
|
||
}
|
||
this._pos_map[elem.id] = this.list.length;
|
||
this.list.push(elem);
|
||
this.emit("add", elem);
|
||
},
|
||
update: function (elem) {
|
||
if (!(elem.id in this._pos_map)) {
|
||
return;
|
||
}
|
||
this.list[this._pos_map[elem.id]] = elem;
|
||
this.emit("update", elem);
|
||
},
|
||
remove: function (elem_id) {
|
||
if (!(elem_id in this._pos_map)) {
|
||
return;
|
||
}
|
||
this.list.splice(this._pos_map[elem_id], 1);
|
||
this._build_map();
|
||
this.emit("remove", elem_id);
|
||
},
|
||
reset: function (elems) {
|
||
this.list = elems || [];
|
||
this._build_map();
|
||
this.emit("recalculate");
|
||
},
|
||
_build_map: function () {
|
||
this._pos_map = {};
|
||
for (var i = 0; i < this.list.length; i++) {
|
||
var elem = this.list[i];
|
||
this._pos_map[elem.id] = i;
|
||
}
|
||
},
|
||
get: function (elem_id) {
|
||
return this.list[this._pos_map[elem_id]];
|
||
},
|
||
index: function (elem_id) {
|
||
return this._pos_map[elem_id];
|
||
}
|
||
});
|
||
|
||
|
||
function DictStore() {
|
||
utils.EventEmitter.call(this);
|
||
this.reset();
|
||
}
|
||
_.extend(DictStore.prototype, utils.EventEmitter.prototype, {
|
||
update: function (dict) {
|
||
_.merge(this.dict, dict);
|
||
this.emit("recalculate");
|
||
},
|
||
reset: function (dict) {
|
||
this.dict = dict || {};
|
||
this.emit("recalculate");
|
||
}
|
||
});
|
||
|
||
function LiveStoreMixin(type) {
|
||
this.type = type;
|
||
|
||
this._updates_before_fetch = undefined;
|
||
this._fetchxhr = false;
|
||
|
||
this.handle = this.handle.bind(this);
|
||
dispatcher.AppDispatcher.register(this.handle);
|
||
|
||
// Avoid double-fetch on startup.
|
||
if (!(window.ws && window.ws.readyState === WebSocket.CONNECTING)) {
|
||
this.fetch();
|
||
}
|
||
}
|
||
_.extend(LiveStoreMixin.prototype, {
|
||
handle: function (event) {
|
||
if (event.type === actions.ActionTypes.CONNECTION_OPEN) {
|
||
return this.fetch();
|
||
}
|
||
if (event.type === this.type) {
|
||
if (event.cmd === StoreCmds.RESET) {
|
||
this.fetch(event.data);
|
||
} else if (this._updates_before_fetch) {
|
||
console.log("defer update", event);
|
||
this._updates_before_fetch.push(event);
|
||
} else {
|
||
this[event.cmd](event.data);
|
||
}
|
||
}
|
||
},
|
||
close: function () {
|
||
dispatcher.AppDispatcher.unregister(this.handle);
|
||
},
|
||
fetch: function (data) {
|
||
console.log("fetch " + this.type);
|
||
if (this._fetchxhr) {
|
||
this._fetchxhr.abort();
|
||
}
|
||
this._updates_before_fetch = []; // (JS: empty array is true)
|
||
if (data) {
|
||
this.handle_fetch(data);
|
||
} else {
|
||
this._fetchxhr = $.getJSON("/" + this.type)
|
||
.done(function (message) {
|
||
this.handle_fetch(message.data);
|
||
}.bind(this))
|
||
.fail(function () {
|
||
EventLogActions.add_event("Could not fetch " + this.type);
|
||
}.bind(this));
|
||
}
|
||
},
|
||
handle_fetch: function (data) {
|
||
this._fetchxhr = false;
|
||
console.log(this.type + " fetched.", this._updates_before_fetch);
|
||
this.reset(data);
|
||
var updates = this._updates_before_fetch;
|
||
this._updates_before_fetch = false;
|
||
for (var i = 0; i < updates.length; i++) {
|
||
this.handle(updates[i]);
|
||
}
|
||
},
|
||
});
|
||
|
||
function LiveListStore(type) {
|
||
ListStore.call(this);
|
||
LiveStoreMixin.call(this, type);
|
||
}
|
||
_.extend(LiveListStore.prototype, ListStore.prototype, LiveStoreMixin.prototype);
|
||
|
||
function LiveDictStore(type) {
|
||
DictStore.call(this);
|
||
LiveStoreMixin.call(this, type);
|
||
}
|
||
_.extend(LiveDictStore.prototype, DictStore.prototype, LiveStoreMixin.prototype);
|
||
|
||
|
||
function FlowStore() {
|
||
return new LiveListStore(actions.ActionTypes.FLOW_STORE);
|
||
}
|
||
|
||
function SettingsStore() {
|
||
return new LiveDictStore(actions.ActionTypes.SETTINGS_STORE);
|
||
}
|
||
|
||
function EventLogStore() {
|
||
LiveListStore.call(this, actions.ActionTypes.EVENT_STORE);
|
||
}
|
||
_.extend(EventLogStore.prototype, LiveListStore.prototype, {
|
||
fetch: function(){
|
||
LiveListStore.prototype.fetch.apply(this, arguments);
|
||
|
||
// Make sure to display updates even if fetching all events failed.
|
||
// This way, we can send "fetch failed" log messages to the log.
|
||
if(this._fetchxhr){
|
||
this._fetchxhr.fail(function(){
|
||
this.handle_fetch(null);
|
||
}.bind(this));
|
||
}
|
||
}
|
||
});
|
||
|
||
|
||
module.exports = {
|
||
EventLogStore: EventLogStore,
|
||
SettingsStore: SettingsStore,
|
||
FlowStore: FlowStore
|
||
};
|
||
},{"../actions.js":1,"../dispatcher.js":12,"../utils.js":17,"jquery":"jquery","lodash":"lodash"}],16:[function(require,module,exports){
|
||
var _ = require("lodash");
|
||
|
||
var utils = require("../utils.js");
|
||
|
||
function SortByStoreOrder(elem) {
|
||
return this.store.index(elem.id);
|
||
}
|
||
|
||
var default_sort = SortByStoreOrder;
|
||
var default_filt = function(elem){
|
||
return true;
|
||
};
|
||
|
||
function StoreView(store, filt, sortfun) {
|
||
utils.EventEmitter.call(this);
|
||
filt = filt || default_filt;
|
||
sortfun = sortfun || default_sort;
|
||
|
||
this.store = store;
|
||
|
||
this.add = this.add.bind(this);
|
||
this.update = this.update.bind(this);
|
||
this.remove = this.remove.bind(this);
|
||
this.recalculate = this.recalculate.bind(this);
|
||
this.store.addListener("add", this.add);
|
||
this.store.addListener("update", this.update);
|
||
this.store.addListener("remove", this.remove);
|
||
this.store.addListener("recalculate", this.recalculate);
|
||
|
||
this.recalculate(filt, sortfun);
|
||
}
|
||
|
||
_.extend(StoreView.prototype, utils.EventEmitter.prototype, {
|
||
close: function () {
|
||
this.store.removeListener("add", this.add);
|
||
this.store.removeListener("update", this.update);
|
||
this.store.removeListener("remove", this.remove);
|
||
this.store.removeListener("recalculate", this.recalculate);
|
||
},
|
||
recalculate: function (filt, sortfun) {
|
||
if (filt) {
|
||
this.filt = filt.bind(this);
|
||
}
|
||
if (sortfun) {
|
||
this.sortfun = sortfun.bind(this);
|
||
}
|
||
|
||
this.list = this.store.list.filter(this.filt);
|
||
this.list.sort(function (a, b) {
|
||
return this.sortfun(a) - this.sortfun(b);
|
||
}.bind(this));
|
||
this.emit("recalculate");
|
||
},
|
||
index: function (elem) {
|
||
return _.sortedIndex(this.list, elem, this.sortfun);
|
||
},
|
||
add: function (elem) {
|
||
if (this.filt(elem)) {
|
||
var idx = this.index(elem);
|
||
if (idx === this.list.length) { //happens often, .push is way faster.
|
||
this.list.push(elem);
|
||
} else {
|
||
this.list.splice(idx, 0, elem);
|
||
}
|
||
this.emit("add", elem, idx);
|
||
}
|
||
},
|
||
update: function (elem) {
|
||
var idx;
|
||
var i = this.list.length;
|
||
// Search from the back, we usually update the latest entries.
|
||
while (i--) {
|
||
if (this.list[i].id === elem.id) {
|
||
idx = i;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (idx === -1) { //not contained in list
|
||
this.add(elem);
|
||
} else if (!this.filt(elem)) {
|
||
this.remove(elem.id);
|
||
} else {
|
||
if (this.sortfun(this.list[idx]) !== this.sortfun(elem)) { //sortpos has changed
|
||
this.remove(this.list[idx]);
|
||
this.add(elem);
|
||
} else {
|
||
this.list[idx] = elem;
|
||
this.emit("update", elem, idx);
|
||
}
|
||
}
|
||
},
|
||
remove: function (elem_id) {
|
||
var idx = this.list.length;
|
||
while (idx--) {
|
||
if (this.list[idx].id === elem_id) {
|
||
this.list.splice(idx, 1);
|
||
this.emit("remove", elem_id, idx);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
module.exports = {
|
||
StoreView: StoreView
|
||
};
|
||
},{"../utils.js":17,"lodash":"lodash"}],17:[function(require,module,exports){
|
||
var $ = require("jquery");
|
||
|
||
|
||
var Key = {
|
||
UP: 38,
|
||
DOWN: 40,
|
||
PAGE_UP: 33,
|
||
PAGE_DOWN: 34,
|
||
HOME: 36,
|
||
END: 35,
|
||
LEFT: 37,
|
||
RIGHT: 39,
|
||
ENTER: 13,
|
||
ESC: 27,
|
||
TAB: 9,
|
||
SPACE: 32,
|
||
BACKSPACE: 8,
|
||
};
|
||
// Add A-Z
|
||
for (var i = 65; i <= 90; i++) {
|
||
Key[String.fromCharCode(i)] = i;
|
||
}
|
||
|
||
|
||
var formatSize = function (bytes) {
|
||
var size = bytes;
|
||
var prefix = ["B", "KB", "MB", "GB", "TB"];
|
||
var i = 0;
|
||
while (Math.abs(size) >= 1024 && i < prefix.length - 1) {
|
||
i++;
|
||
size = size / 1024;
|
||
}
|
||
return (Math.floor(size * 100) / 100.0).toFixed(2) + prefix[i];
|
||
};
|
||
|
||
|
||
var formatTimeDelta = function (milliseconds) {
|
||
var time = milliseconds;
|
||
var prefix = ["ms", "s", "min", "h"];
|
||
var div = [1000, 60, 60];
|
||
var i = 0;
|
||
while (Math.abs(time) >= div[i] && i < div.length) {
|
||
time = time / div[i];
|
||
i++;
|
||
}
|
||
return Math.round(time) + prefix[i];
|
||
};
|
||
|
||
|
||
var formatTimeStamp = function (seconds) {
|
||
var ts = (new Date(seconds * 1000)).toISOString();
|
||
return ts.replace("T", " ").replace("Z", "");
|
||
};
|
||
|
||
|
||
function EventEmitter() {
|
||
this.listeners = {};
|
||
}
|
||
EventEmitter.prototype.emit = function (event) {
|
||
if (!(event in this.listeners)) {
|
||
return;
|
||
}
|
||
var args = Array.prototype.slice.call(arguments, 1);
|
||
this.listeners[event].forEach(function (listener) {
|
||
listener.apply(this, args);
|
||
}.bind(this));
|
||
};
|
||
EventEmitter.prototype.addListener = function (events, f) {
|
||
events.split(" ").forEach(function (event) {
|
||
this.listeners[event] = this.listeners[event] || [];
|
||
this.listeners[event].push(f);
|
||
}.bind(this));
|
||
};
|
||
EventEmitter.prototype.removeListener = function (events, f) {
|
||
if (!(events in this.listeners)) {
|
||
return false;
|
||
}
|
||
events.split(" ").forEach(function (event) {
|
||
var index = this.listeners[event].indexOf(f);
|
||
if (index >= 0) {
|
||
this.listeners[event].splice(index, 1);
|
||
}
|
||
}.bind(this));
|
||
};
|
||
|
||
|
||
function getCookie(name) {
|
||
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
|
||
return r ? r[1] : undefined;
|
||
}
|
||
var xsrf = $.param({_xsrf: getCookie("_xsrf")});
|
||
|
||
//Tornado XSRF Protection.
|
||
$.ajaxPrefilter(function (options) {
|
||
if (["post", "put", "delete"].indexOf(options.type.toLowerCase()) >= 0 && options.url[0] === "/") {
|
||
if (options.data) {
|
||
options.data += ("&" + xsrf);
|
||
} else {
|
||
options.data = xsrf;
|
||
}
|
||
}
|
||
});
|
||
// Log AJAX Errors
|
||
$(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
|
||
var message = jqXHR.responseText;
|
||
console.error(message, arguments);
|
||
EventLogActions.add_event(thrownError + ": " + message);
|
||
window.alert(message);
|
||
});
|
||
|
||
module.exports = {
|
||
EventEmitter: EventEmitter,
|
||
formatSize: formatSize,
|
||
formatTimeDelta: formatTimeDelta,
|
||
formatTimeStamp: formatTimeStamp
|
||
};
|
||
},{"jquery":"jquery"}]},{},[2])
|
||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvanMvYWN0aW9ucy5qcyIsInNyYy9qcy9hcHAuanMiLCJzcmMvanMvY29tcG9uZW50cy9mbG93dGFibGUtY29sdW1ucy5qc3guanMiLCJzcmMvanMvY29tcG9uZW50cy9mbG93dGFibGUuanN4LmpzIiwic3JjL2pzL2NvbXBvbmVudHMvZm9vdGVyLmpzeC5qcyIsInNyYy9qcy9jb21wb25lbnRzL2hlYWRlci5qc3guanMiLCJzcmMvanMvY29tcG9uZW50cy9tYWludmlldy5qc3guanMiLCJzcmMvanMvY29tcG9uZW50cy9wcm94eWFwcC5qc3guanMiLCJzcmMvanMvY29tcG9uZW50cy91dGlscy5qc3guanMiLCJzcmMvanMvY29tcG9uZW50cy92aXJ0dWFsc2Nyb2xsLmpzeC5qcyIsInNyYy9qcy9jb25uZWN0aW9uLmpzIiwic3JjL2pzL2Rpc3BhdGNoZXIuanMiLCJzcmMvanMvZmlsdC9maWx0LmpzIiwic3JjL2pzL2Zsb3cvdXRpbHMuanMiLCJzcmMvanMvc3RvcmUvc3RvcmUuanMiLCJzcmMvanMvc3RvcmUvdmlldy5qcyIsInN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gNDAwKSB7XG4gICAgICAgICAgICAgICAgaWNvbiA9IFwicmVzb3VyY2UtaWNvbi1yZWRpcmVjdFwiO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChjb250ZW50VHlwZSAmJiBjb250ZW50VHlwZS5pbmRleE9mKFwiaW1hZ2VcIikgPj0gMCkge1xuICAgICAgICAgICAgICAgIGljb24gPSBcInJlc291cmNlLWljb24taW1hZ2VcIjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY29udGVudFR5cGUgJiYgY29udGVudFR5cGUuaW5kZXhPZihcImphdmFzY3JpcHRcIikgPj0gMCkge1xuICAgICAgICAgICAgICAgIGljb24gPSBcInJlc291cmNlLWljb24tanNcIjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY29udGVudFR5cGUgJiYgY29udGVudFR5cGUuaW5kZXhPZihcImNzc1wiKSA+PSAwKSB7XG4gICAgICAgICAgICAgICAgaWNvbiA9IFwicmVzb3VyY2UtaWNvbi1jc3NcIjtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY29udGVudFR5cGUgJiYgY29udGVudFR5cGUuaW5kZXhPZihcImh0bWxcIikgPj0gMCkge1xuICAgICAgICAgICAgICAgIGljb24gPSBcInJlc291cmNlLWljb24tZG9jdW1lbnRcIjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoIWljb24pIHtcbiAgICAgICAgICAgIGljb24gPSBcInJlc291cmNlLWljb24tcGxhaW5cIjtcbiAgICAgICAgfVxuXG5cbiAgICAgICAgaWNvbiArPSBcIiByZXNvdXJjZS1pY29uXCI7XG4gICAgICAgIHJldHVybiBSZWFjdC5jcmVhdGVFbGVtZW50KFwidGRcIiwge2NsYXNzTmFtZTogXCJjb2wtaWNvblwifSwgXG4gICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwiZGl2XCIsIHtjbGFzc05hbWU6IGljb259KVxuICAgICAgICApO1xuICAgIH1cbn0pO1xuXG52YXIgUGF0a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gICAgICByZXR1cm4gUmVhY3QuY3JlYXRlRWxlbWVudChcImlcIiwge2NsYXNzTmFtZTogXCJmYSBmYS1zcGlubmVyIGZhLXNwaW5cIn0pO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdmFyIGNvbW1hbmRzID0gRmlsdGVyRG9jcy5kb2MuY29tbWFuZHMubWFwKGZ1bmN0aW9uIChjKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJ0clwiLCBudWxsLCBcbiAgICAgICAgICAgICAgICAgICAgUmVhY3QuY3JlYXRlRWxlbWVudChcInRkXCIsIG51bGwsIGNbMF0ucmVwbGFjZShcIiBcIiwgJ1xcdTAwYTAnKSksIFxuICAgICAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwidGRcIiwgbnVsbCwgY1sxXSlcbiAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICBjb21tYW5kcy5wdXNoKFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJ0clwiLCBudWxsLCBcbiAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwidGRcIiwge2NvbFNwYW46IFwiMlwifSwgXG4gICAgICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJhXCIsIHtocmVmOiBcImh0dHBzOi8vbWl0bXByb3h5Lm9yZy9kb2MvZmVhdHVyZXMvZmlsdGVycy5odG1sXCIsIFxuICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBcIl9ibGFua1wifSwgXG4gICAgICAgICAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwiaVwiLCB7Y2xhc3NOYW1lOiBcImZhIGZhLWV4dGVybmFsLWxpbmtcIn0pLCBcbiAgICAgICAgICAgICAgICAgICAgXCLCoCBtaXRtcHJveHkgZG9jc1wiKVxuICAgICAgICAgICAgICAg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gICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwiaVwiLCB7Y2xhc3NOYW1lOiBpY29uLCBzdHlsZToge2NvbG9yOiB0aGlzLnByb3BzLmNvbG9yfX0pXG4gICAgICAgICAgICAgICAgKSwgXG4gICAgICAgICAgICAgICAgUmVhY3QuY3JlYXRlRWxlbWVudChcImlucHV0XCIsIHt0eXBlOiBcInRleHRcIiwgcGxhY2Vob2xkZXI6IHRoaXMucHJvcHMucGxhY2Vob2xkZXIsIGNsYXNzTmFtZTogXCJmb3JtLWNvbnRyb2xcIiwgXG4gICAgICAgICAgICAgICAgICAgIHJlZjogXCJpbnB1dFwiLCBcbiAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IHRoaXMub25DaGFuZ2UsIFxuICAgICAgICAgICAgICAgICAgICBvbkZvY3VzOiB0aGlzLm9uRm9jdXMsIFxuICAgICAgICAgICAgICAgICAgICBvbkJsdXI6IHRoaXMub25CbHVyLCBcbiAgICAgICAgICAgICAgICAgICAgb25LZXlEb3duOiB0aGlzLm9uS2V5RG93biwgXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnN0YXRlLnZhbHVlfSksIFxuICAgICAgICAgICAgICAgIHBvcG92ZXJcbiAgICAgICAgICAgIClcbiAgICAgICAgKTtcbiAgICB9XG59KTtcblxudmFyIE1haW5NZW51ID0gUmVhY3QuY3JlYXRlQ2xhc3Moe2Rpc3BsYXlOYW1lOiBcIk1haW5NZW51XCIsXG4gICAgbWl4aW5zOiBbdXRpbHMuTmF2aWdhdGlvbiwgdXRpbHMuU3RhdGVdLFxuICAgIHN0YXRpY3M6IHtcbiAgICAgICAgdGl0bGU6IFwiU3RhcnRcIixcbiAgICAgICAgcm91dGU6IFwiZmxvd3NcIlxuICAgIH0sXG4gICAgb25GaWx0ZXJDaGFuZ2U6IGZ1bmN0aW9uICh2YWwpIHtcbiAgICAgICAgdmFyIGQgPSB7fTtcbiAgICAgICAgZFtRdWVyeS5GSUx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tcIiwgXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmlsdGVyLCBcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiB0aGlzLm9uRmlsdGVyQ2hhbmdlfSksIFxuICAgICAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KEZpbHRlcklucHV0LCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwbGFjZWhvbGRlcjogXCJIaWdobGlnaHRcIiwgXG4gICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBcInRhZ1wiLCBcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yOiBcImhzbCg0OCwgMTAwJSwgNTAlKVwiLCBcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBoaWdobGlnaHQsIFxuICAgICAgICAgICAgICAgICAgICAgICAgb25DaGFuZ2U6IHRoaXMub25IaWdobGlnaHRDaGFuZ2V9KSwgXG4gICAgICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoRmlsdGVySW5wdXQsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHBsYWNlaG9sZGVyOiBcIkludGVyY2VwdFwiLCBcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IFwicGF1c2VcIiwgXG4gICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogXCJoc2woMjA4LCA1NiUsIDUzJSlcIiwgXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogaW50ZXJjZXB0LCBcbiAgICAgICAgICAgICAgICAgICAgICAgIG9uQ2hhbmdlOiB0aGlzLm9uSW50ZXJjZXB0Q2hhbmdlfSlcbiAgICAgICAgICAgICAgICApLCBcbiAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwiZGl2XCIsIHtjbGFzc05hbWU6IFwiY2xlYXJmaXhcIn0pXG4gICAgICAgICAgICApXG4gICAgICAgICk7XG4gICAgfVxufSk7XG5cblxud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ICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwibGlcIiwge3JvbGU6IFwicHJlc2VudGF0aW9uXCIsIGNsYXNzTmFtZTogXCJkaXZpZGVyXCJ9KSwgXG4gICAgICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJsaVwiLCBudWxsLCBcbiAgICAgICAgICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJhXCIsIHtocmVmOiBcImh0dHA6Ly9taXRtLml0L1wiLCB0YXJnZXQ6IFwiX2JsYW5rXCJ9LCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwiaVwiLCB7Y2xhc3NOYW1lOiBcImZhIGZhLWZ3IGZhLWV4dGVybmFsLWxpbmtcIn0pLCBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIkluc3RhbGwgQ2VydGlmaWNhdGVzLi4uXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgIC8qXG4gICAgICAgICAgICAgICAgIDxsaT5cbiAgICAgICAgICAgICAgICAgPGEgaHJlZj1cIiNcIiBvbkNsaWNrPXt0aGlzLmhhbmRsZU9wZW5DbGlja30+XG4gICAgICAgICAgICAgICAgIDxpIGNsYXNzTmFtZT1cImZhIGZhLWZ3IGZhLWZvbGRlci1vcGVuXCI+PC9pPlxuICAgICAgICAgICAgICAgICBPcGVuXG4gICAgICAgICAgICAgICAgIDwvYT5cbiAgICAgICAgICAgICAgICAgPC9saT5cbiAgICAgICAgICAgICAgICAgPGxpPlxuICAgICAgICAgICAgICAgICA8YSBocmVmPVwiI1wiIG9uQ2xpY2s9e3RoaXMuaGFuZGxlU2F2ZUNsaWNrfT5cbiAgICAgICAgICAgICAgICAgPGkgY2xhc3NOYW1lPVwiZmEgZmEtZncgZmEtc2F2ZVwiPjwvaT5cbiAgICAgICAgICAgICAgICAgU2F2ZVxuICAgICAgICAgICAgICAgICA8L2E+XG4gICAgICAgICAgICAgICAgIDwvbGk+XG4gICAgICAgICAgICAgICAgIDxsaSByb2xlPVwicHJlc2VudGF0aW9uXCIgY2xhc3NOYW1lPVwiZGl2aWRlclwiPjwvbGk+XG4gICAgICAgICAgICAgICAgIDxsaT5cbiAgICAgICAgICAgICAgICAgPGEgaHJlZj1cIiNcIiBvbkNsaWNrPXt0aGlzLmhhbmRsZVNodXRkb3duQ2xpY2t9PlxuICAgICAgICAgICAgICAgICA8aSBjbGFzc05hbWU9XCJmYSBmYS1mdyBmYS1wbHVnXCI+PC9pPlxuICAgICAgICAgICAgICAgICBTaHV0ZG93blxuICAgICAgICAgICAgICAgICA8L2E+XG4gICAgICAgICAgICAgICAgIDwvbGk+XG4gICAgICAgICAgICAgICAgICovXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgKVxuICAgICAgICApO1xuICAgIH1cbn0pO1xuXG5cbnZhciBoZWFkZXJfZW50cmllcyA9IFtNYWluTWVudSwgVmlld01lbnUgLyosIFJlcG9ydHNNZW51ICovXTtcblxuXG52YXIgSGVhZGVyID0gUmVhY3QuY3JlYXRlQ2xhc3Moe2Rpc3BsYXlOYW1lOiBcIkhlYWRlclwiLFxuICAgIG1peGluczogW3V0aWxzLk5hdmlnYXRpb25dLFxuICAgIGdldEluaXRpYWxTdGF0ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgYWN0aXZlOiBoZWFkZXJfZW50cmllc1swXVxuICAgICAgICB9O1xuICAgIH0sXG4gICAgaGFuZGxlQ2xpY2s6IGZ1bmN0aW9uIChhY3RpdmUsIGUpIHtcbiAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICB0aGlzLnJlcGxhY2VXaXRoKGFjdGl2ZS5yb3V0ZSk7XG4gICAgICAgIHRoaXMuc2V0U3RhdGUoe2FjdGl2ZTogYWN0aXZlfSk7XG4gICAgfSxcbiAgICByZW5kZXI6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGhlYWRlciA9IGhlYWRlcl9lbnRyaWVzLm1hcChmdW5jdGlvbiAoZW50cnksIGkpIHtcbiAgICAgICAgICAgIHZhciBjbGFzc2VzID0gUmVhY3QuYWRkb25zLmNsYXNzU2V0KHtcbiAgICAgICAgICAgICAgICBhY3RpdmU6IGVudHJ5ID09IHRoaXMuc3RhdGUuYWN0aXZlXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICAgICAgUmVhY3QuY3JlYXRlRWxlbWVudChcImFcIiwge2tleTogaSwgXG4gICAgICAgICAgICAgICAgICAgIGhyZWY6IFwiI1wiLCBcbiAgICAgICAgICAgICAgICAgICAgY2xhc3NOYW1lOiBjbGFzc2VzLCBcbiAgICAgICAgICAgICAgICAgICAgb25DbGljazogdGhpcy5oYW5kbGVDbGljay5iaW5kKHRoaXMsIGVudHJ5KVxuICAgICAgICAgICAgICAgIH0sIFxuICAgICAgICAgICAgICAgICAgICAgZW50cnkudGl0bGVcbiAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICApO1xuICAgICAgICB9LmJpbmQodGhpcykpO1xuXG4gICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KFwiaGVhZGVyXCIsIG51bGwsIFxuICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJkaXZcIiwge2NsYXNzTmFtZTogXCJ0aXRsZS1iYXJcIn0sIFxuICAgICAgICAgICAgICAgICAgICBcIm1pdG1wcm94eSBcIiwgIHRoaXMucHJvcHMuc2V0dGluZ3MudmVyc2lvblxuICAgICAgICAgICAgICAgICksIFxuICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoXCJuYXZcIiwge2NsYXNzTmFtZTogXCJuYXYtdGFicyBuYXYtdGFicy1sZ1wifSwgX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GxhY2VXaXRoKFxuICAgICAgICAgICAgICAgIFwiZmxvd1wiLFxuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgZmxvd0lkOiBmbG93LmlkLFxuICAgICAgICAgICAgICAgICAgICBkZXRhaWxUYWI6IHRoaXMuZ2V0UGFyYW1zKCkuZGV0YWlsVGFiIHx8IFwicmVxdWVzdFwiXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIHRoaXMucmVmcy5mbG93VGFibGUuc2Nyb2xsSW50b1ZpZXcoZmxvdyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnJlcGxhY2VXaXRoKFwiZmxvd3NcIiwge30pO1xuICAgICAgICB9XG4gICAgfSxcbiAgICBzZWxlY3RGbG93UmVsYXRpdmU6IGZ1bmN0aW9uIChzaGlmdCkge1xuICAgICAgICB2YXIgZmxvd3MgPSB0aGlzLnN0YXRlLnZpZXcubGlzdDtcbiAgICAgICAgdmFyIGluZGV4O1xuICAgICAgICBpZiAoIXRoaXMuZ2V0UGFyYW1zKCkuZmxvd0lkKSB7XG4gICAgICAgICAgICBpZiAoc2hpZnQgPiAwKSB7XG4gICAgICAgICAgICAgICAgaW5kZXggPSBmbG93cy5sZW5ndGggLSAxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBpbmRleCA9IDA7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB2YXIgY3VyckZsb3dJZCA9IHRoaXMuZ2V0UGFyYW1zKCkuZmxvd0lkO1xuICAgICAgICAgICAgdmFyIGkgPSBmbG93cy5sZW5ndGg7XG4gICAgICAgICAgICB3aGlsZSAoaS0tKSB7XG4gICAgICAgICAgICAgICAgaWYgKGZsb3dzW2ldLmlkID09PSBjdXJyRmxvd0lkKSB7XG4gICAgICAgICAgICAgICAgICAgIGluZGV4ID0gaTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaW5kZXggPSBNYXRoLm1pbihcbiAgICAgICAgICAgICAgICBNYXRoLm1heCgwLCBpbmRleCArIHNoaWZ0KSxcbiAgICAgICAgICAgICAgICBmbG93cy5sZW5ndGggLSAxKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnNlbGVjdEZsb3coZmxvd3NbaW5kZXhdKTtcbiAgICB9LFxuICAgIG9uS2V5RG93bjogZnVuY3Rpb24gKGUpIHtcbiAgICAgICAgdmFyIGZsb3cgPSB0aGlzLmdldFNlbGVjdGVkKCk7XG4gICAgICAgIGlmIChlLmN0cmxLZXkpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKGUua2V5Q29kZSkge1xuICAgICAgICAgICAgY2FzZSBLZXkuSzpcbiAgICAgICAgICAgIGNhc2UgS2V5LlVQOlxuICAgICAgICAgICAgICAgIHRoaXMuc2VsZWN0Rmxvd1JlbGF0aXZlKC0xKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgS2V5Lko6XG4gICAgICAgICAgICBjYXNlIEtleS5ET1dOOlxuICAgICAgICAgICAgICAgIHRoaXMuc2VsZWN0Rmxvd1JlbGF0aXZlKCsxKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgS2V5LlNQQUNFOlxuICAgICAgICAgICAgY2FzZSBLZXkuUEFHRV9ET1dOOlxuICAgICAgICAgICAgICAgIHRoaXMuc2VsZWN0Rmxvd1JlbGF0aXZlKCsxMCk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIEtleS5QQUdFX1VQOlxuICAgICAgICAgICAgICAgIHRoaXMuc2VsZWN0Rmxvd1JlbGF0aXZlKC0xMCk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIEtleS5FTkQ6XG4gICAgICAgICAgICAgICAgdGhpcy5zZWxlY3RGbG93UmVsYXRpdmUoKzFlMTApO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBLZXkuSE9NRTpcbiAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdEZsb3dSZWxhdGl2ZSgtMWUxMCk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIEtleS5FU0M6XG4gICAgICAgICAgICAgICAgdGhpcy5zZWxlY3RGbG93KG51bGwpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBLZXkuSDpcbiAgICAgICAgICAgIGNhc2UgS2V5LkxFRlQ6XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMucmVmcy5mbG93RGV0YWlscykge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLnJlZnMuZmxvd0RldGFpbHMubmV4dFRhYigtMSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBLZXkuTDpcbiAgICAgICAgICAgIGNhc2UgS2V5LlRBQjpcbiAgICAgICAgICAgIGNhc2UgS2V5LlJJR0hUOlxuICAgICAgICAgICAgICAgIGlmICh0aGlzLnJlZnMuZmxvd0RldGFpbHMpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZWZzLmZsb3dEZXRhaWxzLm5leHRUYWIoKzEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgS2V5LkM6XG4gICAgICAgICAgICAgICAgaWYgKGUuc2hpZnRLZXkpIHtcbiAgICAgICAgICAgICAgICAgICAgRmxvd0FjdGlvbnMuY2xlYXIoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIEtleS5EOlxuICAgICAgICAgICAgICAgIGlmIChmbG93KSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlLnNoaWZ0S2V5KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBGbG93QWN0aW9ucy5kdXBsaWNhdGUoZmxvdyk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBGbG93QWN0aW9ucy5kZWxldGUoZmxvdyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIEtleS5BOlxuICAgICAgICAgICAgICAgIGlmIChlLnNoaWZ0S2V5KSB7XG4gICAgICAgICAgICAgICAgICAgIEZsb3dBY3Rpb25zLmFjY2VwdF9hbGwoKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGZsb3cgJiYgZmxvdy5pbnRlcmNlcHRlZCkge1xuICAgICAgICAgICAgICAgICAgICBGbG93QWN0aW9ucy5hY2NlcHQoZmxvdyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBLZXkuUjpcbiAgICAgICAgICAgICAgICBpZiAoIWUuc2hpZnRLZXkgJiYgZmxvdykge1xuICAgICAgICAgICAgICAgICAgICBGbG93QWN0aW9ucy5yZXBsYXkoZmxvdyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBLZXkuVjpcbiAgICAgICAgICAgICAgICBpZihlLnNoaWZ0S2V5ICYmIGZsb3cgJiYgZmxvdy5tb2RpZmllZCkge1xuICAgICAgICAgICAgICAgICAgICBGbG93QWN0aW9ucy5yZXZlcnQoZmxvdyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICA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ZSh7XG4gICAgICAgICAgICBzZXR0aW5nczogdGhpcy5zdGF0ZS5zZXR0aW5nc1xuICAgICAgICB9KTtcbiAgICB9LFxuICAgIHJlbmRlcjogZnVuY3Rpb24gKCkge1xuXG4gICAgICAgIHZhciBldmVudGxvZztcbiAgICAgICAgaWYgKHRoaXMuZ2V0UXVlcnkoKVtRdWVyeS5TSE9XX0VWRU5UTE9HXSkge1xuICAgICAgICAgICAgZXZlbnRsb2cgPSBbXG4gICAgICAgICAgICAgICAgUmVhY3QuY3JlYXRlRWxlbWVudChTcGxpdHRlciwge2tleTogXCJzcGxpdHRlclwiLCBheGlzOiBcInlcIn0pLFxuICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoRXZlbnRMb2csIHtrZXk6IFwiZXZlbnRsb2dcIiwgZXZlbnRTdG9yZTogdGhpcy5zdGF0ZS5ldmVudFN0b3JlfSlcbiAgICAgICAgICAgIF07XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBldmVudGxvZyA9IG51bGw7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gKFxuICAgICAgICAgICAgUmVhY3QuY3JlYXRlRWxlbWVudChcImRpdlwiLCB7aWQ6IFwiY29udGFpbmVyXCJ9LCBcbiAgICAgICAgICAgICAgICBSZWFjdC5jcmVhdGVFbGVtZW50KGhlYWRlci5IZWFkZXIsIHtzZXR0aW5nczogdGhpcy5zdGF0ZS5zZXR0aW5ncy5kaWN0fSksIFxuICAgICAgICAgICAgICAgIFJlYWN0LmNyZWF0ZUVsZW1lbnQoUm91dGVIYW5kbGVyLCB7c2V0dGluZ3M6IHRoaXMuc3RhdGUuc2V0dGluZ3MuZGljdCwgZmxvd1N0b3JlOiB0aGlzLnN0YXRlLmZsb3dTdG9yZX0pLCBcbiAgICAgICAgICAgICAgICBldmVudGxvZywgXG4gICAgICAgICAgICAgICAgUmVhY3QuY3JlYXRlRWxlbWVudChGb290ZXIsIHtzZXR0aW5nczogdGhp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yaWdnZXIgYSBnbG9iYWwgcmVzaXplIGV2ZW50LiBUaGlzIG5vdGlmaWVzIGNvbXBvbmVudHMgdGhhdCBlbXBsb3kgdmlydHVhbCBzY3JvbGxpbmdcbiAgICAgICAgLy8gdGhhdCB0aGVpciB2aWV3cG9ydCBtYXkgaGF2ZSBjaGFuZ2VkLlxuICAgICAgICB3aW5kb3cuc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB3aW5kb3cuZGlzcGF0Y2hFdmVudChuZXcgQ3VzdG9tRXZlbnQoXCJyZXNpemVcIikpO1xuICAgICAgICB9LCAxKTtcbiAgICB9LFxuICAgIHJlc2V0OiBmdW5jdGlvbiAod2lsbFVubW91bnQpIHtcbiAgICAgICAgaWYgKCF0aGlzLnN0YXRlLmFwcGxpZWQpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICB2YXIgbm9kZSA9IHRoaXMuZ2V0RE9NTm9kZSgpO1xuICAgICAgICB2YXIgcHJldiA9IG5vZGUucHJldmlvdXNFbGVtZW50U2libGluZztcbiAgICAgICAgdmFyIG5leHQgPSBub2RlLm5leHRFbGVtZW50U2libGluZztcblxuICAgICAgICBwcmV2LnN0eWxlLmZsZXggPSBcIlwiO1xuICAgICAgICBuZXh0LnN0eWxlLmZsZXggPSBcIlwiO1xuXG4gICAgICAgIGlmICghd2lsbFVubW91bnQpIHtcbiAgICAgICAgICAgIHRoaXMuc2V0U3RhdGUoe1xuICAgICAgICAgICAgICAgIGFwcGxpZWQ6IGZhbHNlXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm9uUmVzaXplKCk7XG4gICAgfSxcbiAgICBjb21wb25lbnRXaWxsVW5tb3VudDogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnJlc2V0KHRydWUpO1xuICAgIH0sXG4gICAgcmVuZGVyOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBjbGFzc05h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biAgICAgICAgICAgIGlmICghZGV0YWlscy5zZWVuQ1IpIHsgZGV0YWlscy5saW5lKys7IH1cbiAgICAgICAgICAgIGRldGFpbHMuY29sdW1uID0gMTtcbiAgICAgICAgICAgIGRldGFpbHMuc2VlbkNSID0gZmFsc2U7XG4gICAgICAgICAgfSBlbHNlIGlmIChjaCA9PT0gXCJcXHJcIiB8fCBjaCA9PT0gXCJcXHUyMDI4XCIgfHwgY2ggPT09IFwiXFx1MjAyOVwiKSB7XG4gICAgICAgICAgICBkZXRhaWxzLmxpbmUrKztcbiAgICAgICAgICAgIGRldGFpbHMuY29sdW1uID0gMTtcbiAgICAgICAgICAgIGRldGFpbHMuc2VlbkNSID0gdHJ1ZTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgZGV0YWlscy5jb2x1bW4rKztcbiAgICAgICAgICAgIGRldGFpbHMuc2VlbkNSID0gZmFsc2U7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIGlmIChwZWckY2FjaGVkUG9zICE9PSBwb3MpIHtcbiAgICAgICAgaWYgKHBlZyRjYWNoZWRQb3MgPiBwb3MpIHtcbiAgICAgICAgICBwZWckY2FjaGVkUG9zID0gMDtcbiAgICAgICAgICBwZWckY2FjaGVkUG9zRGV0YWlscyA9IHsgbGluZTogMSwgY29sdW1uOiAxLCBzZWVuQ1I6IGZhbHNlIH07XG4gICAgICAgIH1cbiAgICAgICAgYWR2YW5jZShwZWckY2FjaGVkUG9zRGV0YWlscywgcGVnJGNhY2hlZFBvcywgcG9zKTtcbiAgICAgICAgcGVnJGNhY2hlZFBvcyA9IHBvcztcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIHBlZyRjYWNoZWRQb3NEZXRhaWxzO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBlZyRmYWlsKGV4cGVjdGVkKSB7XG4gICAgICBpZiAocGVnJGN1cnJQb3MgPCBwZWckbWF4RmFpbFBvcykgeyByZXR1cm47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9uIHN0cmluZ0VzY2FwZShzKSB7XG4gICAgICAgICAgZnVuY3Rpb24gaGV4KGNoKSB7IHJldHVybiBjaC5jaGFyQ29kZUF0KDApLnRvU3RyaW5nKDE2KS50b1VwcGVyQ2FzZSgpOyB9XG5cbiAgICAgICAgICByZXR1cm4gc1xuICAgICAgICAgICAgLnJlcGxhY2UoL1xcXFwvZywgICAnXFxcXFxcXFwnKVxuICAgICAgICAgICAgLnJlcGxhY2UoL1wiL2csICAgICdcXFxcXCInKVxuICAgICAgICAgICAgLnJlcGxhY2UoL1xceDA4L2csICdcXFxcYicpXG4gICAgICAgICAgICAucmVwbGFjZSgvXFx0L2csICAgJ1xcXFx0JylcbiAgICAgICAgICAgIC5yZXBsYWNlKC9cXG4vZywgICAnXFxcXG4nKVxuICAgICAgICAgICAgLnJlcGxhY2UoL1xcZi9nLCAgICdcXFxcZicpXG4gICAgICAgICAgICAucmVwbGFjZSgvXFxyL2csICAgJ1xcXFxyJylcbiAgICAgICAgICAgIC5yZXBsYWNlKC9bXFx4MDAtXFx4MDdcXHgwQlxceDBFXFx4MEZdL2csIGZ1bmN0aW9uKGNoKSB7IHJldHVybiAnXFxcXHgwJyArIGhleChjaCk7IH0pXG4gICAgICAgICAgICAucmVwbGFjZSgvW1xceDEwLVxceDFGXFx4ODAtXFx4RkZdL2csICAgIGZ1bmN0aW9uKGNoKSB7IHJldHVybiAnXFxcXHgnICArIGhleChjaCk7IH0pXG4gICAgICAgICAgICAucmVwbGFjZSgvW1xcdTAxODAtXFx1MEZGRl0vZywgICAgICAgICBmdW5jdGlvbihjaCkgeyByZXR1cm4gJ1xcXFx1MCcgKyBoZXgoY2gpOyB9KVxuICAgICAgICAgICAgLnJlcGxhY2UoL1tcXHUxMDgwLVxcdUZGRkZdL2csICAgICAgICAgZnVuY3Rpb24oY2gpIHsgcmV0dXJuICdcXFxcdScgICsgaGV4KGNoKTsgfSk7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgZXhwZWN0ZWREZXN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2UgIT09IG51bGwgPyBtZXNzYWdlIDogYnVpbGRNZXNzYWdlKGV4cGVjdGVkLCBmb3VuZCksXG4gICAgICAgIGV4cGVjdGVkLFxuICAgICAgICBmb3VuZCxcbiAgICAgICAgcG9zLFxuICAgICAgICBwb3NEZXRhaWxzLmxpbmUsXG4gICAgICAgIHBvc0RldGFpbHMuY29sdW1uXG4gICAgICApO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBlZyRwYXJzZXN0YXJ0KCkge1xuICAgICAgdmFyIHMwLCBzMSwgczIsIHMzO1xuXG4gICAgICBwZWckc2lsZW50RmFpbHMrKztcbiAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICBzMSA9IHBlZyRwYXJzZV9fKCk7XG4gICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczIgPSBwZWckcGFyc2VPckV4cHIoKTtcbiAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgczMgPSBwZWckcGFyc2VfXygpO1xuICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICBzMSA9IHBlZyRjMihzMik7XG4gICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgfVxuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgIHMxID0gW107XG4gICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgIHMxID0gcGVnJGM0KCk7XG4gICAgICAgIH1cbiAgICAgICAgczAgPSBzMTtcbiAgICAgIH1cbiAgICAgIHBlZyRzaWxlbnRGYWlscy0tO1xuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzApOyB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBzMDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwZWckcGFyc2V3cygpIHtcbiAgICAgIHZhciBzMCwgczE7XG5cbiAgICAgIHBlZyRzaWxlbnRGYWlscysrO1xuICAgICAgaWYgKHBlZyRjNi50ZXN0KGlucHV0LmNoYXJBdChwZWckY3VyclBvcykpKSB7XG4gICAgICAgIHMwID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTtcbiAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHMwID0gcGVnJEZBSUxFRDtcbiAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzcpOyB9XG4gICAgICB9XG4gICAgICBwZWckc2lsZW50RmFpbHMtLTtcbiAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM1KTsgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlY2MoKSB7XG4gICAgICB2YXIgczAsIHMxO1xuXG4gICAgICBwZWckc2lsZW50RmFpbHMrKztcbiAgICAgIGlmIChwZWckYzkudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkge1xuICAgICAgICBzMCA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7XG4gICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGMxMCk7IH1cbiAgICAgIH1cbiAgICAgIHBlZyRzaWxlbnRGYWlscy0tO1xuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzgpOyB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBzMDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwZWckcGFyc2VfXygpIHtcbiAgICAgIHZhciBzMCwgczE7XG5cbiAgICAgIHBlZyRzaWxlbnRGYWlscysrO1xuICAgICAgczAgPSBbXTtcbiAgICAgIHMxID0gcGVnJHBhcnNld3MoKTtcbiAgICAgIHdoaWxlIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMC5wdXNoKHMxKTtcbiAgICAgICAgczEgPSBwZWckcGFyc2V3cygpO1xuICAgICAgfVxuICAgICAgcGVnJHNpbGVudEZhaWxzLS07XG4gICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjMTEpOyB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBzMDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwZWckcGFyc2VPckV4cHIoKSB7XG4gICAgICB2YXIgczAsIHMxLCBzMiwgczMsIHM0LCBzNTtcblxuICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgIHMxID0gcGVnJHBhcnNlQW5kRXhwcigpO1xuICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMyID0gcGVnJHBhcnNlX18oKTtcbiAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAxMjQpIHtcbiAgICAgICAgICAgIHMzID0gcGVnJGMxMjtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGMxMyk7IH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICBzNCA9IHBlZyRwYXJzZV9fKCk7XG4gICAgICAgICAgICBpZiAoczQgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgczUgPSBwZWckcGFyc2VPckV4cHIoKTtcbiAgICAgICAgICAgICAgaWYgKHM1ICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgICAgczEgPSBwZWckYzE0KHMxLCBzNSk7XG4gICAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgIH1cbiAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMCA9IHBlZyRwYXJzZUFuZEV4cHIoKTtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIHMwO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBlZyRwYXJzZUFuZEV4cHIoKSB7XG4gICAgICB2YXIgczAsIHMxLCBzMiwgczMsIHM0LCBzNTtcblxuICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgIHMxID0gcGVnJHBhcnNlTm90RXhwcigpO1xuICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMyID0gcGVnJHBhcnNlX18oKTtcbiAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAzOCkge1xuICAgICAgICAgICAgczMgPSBwZWckYzE1O1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzE2KTsgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHM0ID0gcGVnJHBhcnNlX18oKTtcbiAgICAgICAgICAgIGlmIChzNCAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICBzNSA9IHBlZyRwYXJzZUFuZEV4cHIoKTtcbiAgICAgICAgICAgICAgaWYgKHM1ICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgICAgczEgPSBwZWckYzE3KHMxLCBzNSk7XG4gICAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgIH1cbiAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgICBzMSA9IHBlZyRwYXJzZU5vdEV4cHIoKTtcbiAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgczIgPSBbXTtcbiAgICAgICAgICBzMyA9IHBlZyRwYXJzZXdzKCk7XG4gICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICB3aGlsZSAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgczIucHVzaChzMyk7XG4gICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgczIgPSBwZWckYzE7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgczMgPSBwZWckcGFyc2VBbmRFeHByKCk7XG4gICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgIHMxID0gcGVnJGMxNyhzMSwgczMpO1xuICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICBzMCA9IHBlZyRwYXJzZU5vdEV4cHIoKTtcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlTm90RXhwcigpIHtcbiAgICAgIHZhciBzMCwgczEsIHMyLCBzMztcblxuICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gMzMpIHtcbiAgICAgICAgczEgPSBwZWckYzE4O1xuICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjMTkpOyB9XG4gICAgICB9XG4gICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczIgPSBwZWckcGFyc2VfXygpO1xuICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICBzMyA9IHBlZyRwYXJzZU5vdEV4cHIoKTtcbiAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgczEgPSBwZWckYzIwKHMzKTtcbiAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICB9XG4gICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczAgPSBwZWckcGFyc2VCaW5kaW5nRXhwcigpO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlQmluZGluZ0V4cHIoKSB7XG4gICAgICB2YXIgczAsIHMxLCBzMiwgczMsIHM0LCBzNTtcblxuICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gNDApIHtcbiAgICAgICAgczEgPSBwZWckYzIxO1xuICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjMjIpOyB9XG4gICAgICB9XG4gICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczIgPSBwZWckcGFyc2VfXygpO1xuICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICBzMyA9IHBlZyRwYXJzZU9yRXhwcigpO1xuICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgczQgPSBwZWckcGFyc2VfXygpO1xuICAgICAgICAgICAgaWYgKHM0ICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gNDEpIHtcbiAgICAgICAgICAgICAgICBzNSA9IHBlZyRjMjM7XG4gICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzNSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzI0KTsgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmIChzNSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgICAgIHMxID0gcGVnJGMyNShzMyk7XG4gICAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgIH1cbiAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMCA9IHBlZyRwYXJzZUV4cHIoKTtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIHMwO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBlZyRwYXJzZUV4cHIoKSB7XG4gICAgICB2YXIgczA7XG5cbiAgICAgIHMwID0gcGVnJHBhcnNlTnVsbGFyeUV4cHIoKTtcbiAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMCA9IHBlZyRwYXJzZVVuYXJ5RXhwcigpO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlTnVsbGFyeUV4cHIoKSB7XG4gICAgICB2YXIgczAsIHMxO1xuXG4gICAgICBzMCA9IHBlZyRwYXJzZUJvb2xlYW5MaXRlcmFsKCk7XG4gICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgMikgPT09IHBlZyRjMjYpIHtcbiAgICAgICAgICBzMSA9IHBlZyRjMjY7XG4gICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzI3KTsgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgIHMxID0gcGVnJGMyOCgpO1xuICAgICAgICB9XG4gICAgICAgIHMwID0gczE7XG4gICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgMikgPT09IHBlZyRjMjkpIHtcbiAgICAgICAgICAgIHMxID0gcGVnJGMyOTtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDI7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGMzMCk7IH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgIHMxID0gcGVnJGMzMSgpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDIpID09PSBwZWckYzMyKSB7XG4gICAgICAgICAgICAgIHMxID0gcGVnJGMzMjtcbiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzMzKTsgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgICBzMSA9IHBlZyRjMzQoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgMikgPT09IHBlZyRjMzUpIHtcbiAgICAgICAgICAgICAgICBzMSA9IHBlZyRjMzU7XG4gICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzM2KTsgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgICAgIHMxID0gcGVnJGMzNygpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBzMDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwZWckcGFyc2VCb29sZWFuTGl0ZXJhbCgpIHtcbiAgICAgIHZhciBzMCwgczE7XG5cbiAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCA0KSA9PT0gcGVnJGMzOCkge1xuICAgICAgICBzMSA9IHBlZyRjMzg7XG4gICAgICAgIHBlZyRjdXJyUG9zICs9IDQ7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGMzOSk7IH1cbiAgICAgIH1cbiAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgczEgPSBwZWckYzQwKCk7XG4gICAgICB9XG4gICAgICBzMCA9IHMxO1xuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDUpID09PSBwZWckYzQxKSB7XG4gICAgICAgICAgczEgPSBwZWckYzQxO1xuICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDU7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM0Mik7IH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICBzMSA9IHBlZyRjNDMoKTtcbiAgICAgICAgfVxuICAgICAgICBzMCA9IHMxO1xuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlVW5hcnlFeHByKCkge1xuICAgICAgdmFyIHMwLCBzMSwgczIsIHMzO1xuXG4gICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgaWYgKGlucHV0LnN1YnN0cihwZWckY3VyclBvcywgMikgPT09IHBlZyRjNDQpIHtcbiAgICAgICAgczEgPSBwZWckYzQ0O1xuICAgICAgICBwZWckY3VyclBvcyArPSAyO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjNDUpOyB9XG4gICAgICB9XG4gICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczIgPSBbXTtcbiAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICB3aGlsZSAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHMyLnB1c2goczMpO1xuICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICBzMyA9IHBlZyRwYXJzZUludGVnZXJMaXRlcmFsKCk7XG4gICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgIHMxID0gcGVnJGM0NihzMyk7XG4gICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgfVxuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDIpID09PSBwZWckYzQ3KSB7XG4gICAgICAgICAgczEgPSBwZWckYzQ3O1xuICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM0OCk7IH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICBzMiA9IFtdO1xuICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVN0cmluZ0xpdGVyYWwoKTtcbiAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgczEgPSBwZWckYzQ5KHMzKTtcbiAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCAyKSA9PT0gcGVnJGM1MCkge1xuICAgICAgICAgICAgczEgPSBwZWckYzUwO1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzUxKTsgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICBzMyA9IHBlZyRwYXJzZXdzKCk7XG4gICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgczIucHVzaChzMyk7XG4gICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVN0cmluZ0xpdGVyYWwoKTtcbiAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgICAgczEgPSBwZWckYzUyKHMzKTtcbiAgICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDMpID09PSBwZWckYzUzKSB7XG4gICAgICAgICAgICAgIHMxID0gcGVnJGM1MztcbiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzU0KTsgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgczIgPSBwZWckYzE7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2VTdHJpbmdMaXRlcmFsKCk7XG4gICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGM1NShzMyk7XG4gICAgICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDMpID09PSBwZWckYzU2KSB7XG4gICAgICAgICAgICAgICAgczEgPSBwZWckYzU2O1xuICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDM7XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM1Nyk7IH1cbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICBzMiA9IFtdO1xuICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVN0cmluZ0xpdGVyYWwoKTtcbiAgICAgICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzU4KHMzKTtcbiAgICAgICAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCAyKSA9PT0gcGVnJGM1OSkge1xuICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzU5O1xuICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzYwKTsgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZXdzKCk7XG4gICAgICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgczIucHVzaChzMyk7XG4gICAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVN0cmluZ0xpdGVyYWwoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzYxKHMzKTtcbiAgICAgICAgICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDIpID09PSBwZWckYzYyKSB7XG4gICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGM2MjtcbiAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzYzKTsgfVxuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgczIgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2VTdHJpbmdMaXRlcmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGM2NChzMyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDMpID09PSBwZWckYzY1KSB7XG4gICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzY1O1xuICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zICs9IDM7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM2Nik7IH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICBzMiA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVN0cmluZ0xpdGVyYWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzY3KHMzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgICAgICAgICAgICBpZiAoaW5wdXQuc3Vic3RyKHBlZyRjdXJyUG9zLCAzKSA9PT0gcGVnJGM2OCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzY4O1xuICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMztcbiAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzY5KTsgfVxuICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZXdzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczIucHVzaChzMyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2V3cygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICBzMiA9IHBlZyRjMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVN0cmluZ0xpdGVyYWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczEgPSBwZWckYzcwKHMzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dC5zdWJzdHIocGVnJGN1cnJQb3MsIDIpID09PSBwZWckYzcxKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGM3MTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgKz0gMjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzcyKTsgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNld3MoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczIgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczMgPSBwZWckcGFyc2VTdHJpbmdMaXRlcmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJGM3MyhzMyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMxID0gcGVnJHBhcnNlU3RyaW5nTGl0ZXJhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzMSA9IHBlZyRjNzMoczEpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBzMDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwZWckcGFyc2VJbnRlZ2VyTGl0ZXJhbCgpIHtcbiAgICAgIHZhciBzMCwgczEsIHMyLCBzMztcblxuICAgICAgcGVnJHNpbGVudEZhaWxzKys7XG4gICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgaWYgKHBlZyRjNzYudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkge1xuICAgICAgICBzMSA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7XG4gICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM3Nyk7IH1cbiAgICAgIH1cbiAgICAgIGlmIChzMSA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMSA9IHBlZyRjNzU7XG4gICAgICB9XG4gICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczIgPSBbXTtcbiAgICAgICAgaWYgKHBlZyRjNzgudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkge1xuICAgICAgICAgIHMzID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTtcbiAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjNzkpOyB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICBzMi5wdXNoKHMzKTtcbiAgICAgICAgICAgIGlmIChwZWckYzc4LnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHtcbiAgICAgICAgICAgICAgczMgPSBpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpO1xuICAgICAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjNzkpOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHMyID0gcGVnJGMxO1xuICAgICAgICB9XG4gICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIGlmIChwZWckYzc2LnRlc3QoaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKSkpIHtcbiAgICAgICAgICAgIHMzID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHMzID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM3Nyk7IH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHMzID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICBzMyA9IHBlZyRjNzU7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICBzMSA9IHBlZyRjODAoczIpO1xuICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgIH1cbiAgICAgIHBlZyRzaWxlbnRGYWlscy0tO1xuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzc0KTsgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlU3RyaW5nTGl0ZXJhbCgpIHtcbiAgICAgIHZhciBzMCwgczEsIHMyLCBzMztcblxuICAgICAgcGVnJHNpbGVudEZhaWxzKys7XG4gICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAzNCkge1xuICAgICAgICBzMSA9IHBlZyRjODI7XG4gICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM4Myk7IH1cbiAgICAgIH1cbiAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMiA9IFtdO1xuICAgICAgICBzMyA9IHBlZyRwYXJzZURvdWJsZVN0cmluZ0NoYXIoKTtcbiAgICAgICAgd2hpbGUgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgczIucHVzaChzMyk7XG4gICAgICAgICAgczMgPSBwZWckcGFyc2VEb3VibGVTdHJpbmdDaGFyKCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAzNCkge1xuICAgICAgICAgICAgczMgPSBwZWckYzgyO1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgczMgPSBwZWckRkFJTEVEO1xuICAgICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzgzKTsgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgczEgPSBwZWckYzg0KHMyKTtcbiAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICB9XG4gICAgICBpZiAoczAgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAzOSkge1xuICAgICAgICAgIHMxID0gcGVnJGM4NTtcbiAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjODYpOyB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgczIgPSBbXTtcbiAgICAgICAgICBzMyA9IHBlZyRwYXJzZVNpbmdsZVN0cmluZ0NoYXIoKTtcbiAgICAgICAgICB3aGlsZSAoczMgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHMyLnB1c2goczMpO1xuICAgICAgICAgICAgczMgPSBwZWckcGFyc2VTaW5nbGVTdHJpbmdDaGFyKCk7XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAzOSkge1xuICAgICAgICAgICAgICBzMyA9IHBlZyRjODU7XG4gICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzMyA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM4Nik7IH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICBwZWckcmVwb3J0ZWRQb3MgPSBzMDtcbiAgICAgICAgICAgICAgczEgPSBwZWckYzg0KHMyKTtcbiAgICAgICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICBzMSA9IHBlZyRjdXJyUG9zO1xuICAgICAgICAgIHBlZyRzaWxlbnRGYWlscysrO1xuICAgICAgICAgIHMyID0gcGVnJHBhcnNlY2MoKTtcbiAgICAgICAgICBwZWckc2lsZW50RmFpbHMtLTtcbiAgICAgICAgICBpZiAoczIgPT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHMxID0gcGVnJGM4NztcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMTtcbiAgICAgICAgICAgIHMxID0gcGVnJGMxO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHMyID0gW107XG4gICAgICAgICAgICBzMyA9IHBlZyRwYXJzZVVucXVvdGVkU3RyaW5nQ2hhcigpO1xuICAgICAgICAgICAgaWYgKHMzICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgIHdoaWxlIChzMyAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgICAgIHMyLnB1c2goczMpO1xuICAgICAgICAgICAgICAgIHMzID0gcGVnJHBhcnNlVW5xdW90ZWRTdHJpbmdDaGFyKCk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIHMyID0gcGVnJGMxO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgICBzMSA9IHBlZyRjODQoczIpO1xuICAgICAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHBlZyRzaWxlbnRGYWlscy0tO1xuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzgxKTsgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlRG91YmxlU3RyaW5nQ2hhcigpIHtcbiAgICAgIHZhciBzMCwgczEsIHMyO1xuXG4gICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgczEgPSBwZWckY3VyclBvcztcbiAgICAgIHBlZyRzaWxlbnRGYWlscysrO1xuICAgICAgaWYgKHBlZyRjODgudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkge1xuICAgICAgICBzMiA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7XG4gICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMiA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM4OSk7IH1cbiAgICAgIH1cbiAgICAgIHBlZyRzaWxlbnRGYWlscy0tO1xuICAgICAgaWYgKHMyID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMxID0gcGVnJGM4NztcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHBlZyRjdXJyUG9zID0gczE7XG4gICAgICAgIHMxID0gcGVnJGMxO1xuICAgICAgfVxuICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIGlmIChpbnB1dC5sZW5ndGggPiBwZWckY3VyclBvcykge1xuICAgICAgICAgIHMyID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTtcbiAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHMyID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjOTApOyB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgczEgPSBwZWckYzkxKHMyKTtcbiAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgfVxuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gOTIpIHtcbiAgICAgICAgICBzMSA9IHBlZyRjOTI7XG4gICAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzkzKTsgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHMyID0gcGVnJHBhcnNlRXNjYXBlU2VxdWVuY2UoKTtcbiAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgczEgPSBwZWckYzkxKHMyKTtcbiAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlU2luZ2xlU3RyaW5nQ2hhcigpIHtcbiAgICAgIHZhciBzMCwgczEsIHMyO1xuXG4gICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgczEgPSBwZWckY3VyclBvcztcbiAgICAgIHBlZyRzaWxlbnRGYWlscysrO1xuICAgICAgaWYgKHBlZyRjOTQudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkge1xuICAgICAgICBzMiA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7XG4gICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMiA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM5NSk7IH1cbiAgICAgIH1cbiAgICAgIHBlZyRzaWxlbnRGYWlscy0tO1xuICAgICAgaWYgKHMyID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMxID0gcGVnJGM4NztcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHBlZyRjdXJyUG9zID0gczE7XG4gICAgICAgIHMxID0gcGVnJGMxO1xuICAgICAgfVxuICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIGlmIChpbnB1dC5sZW5ndGggPiBwZWckY3VyclBvcykge1xuICAgICAgICAgIHMyID0gaW5wdXQuY2hhckF0KHBlZyRjdXJyUG9zKTtcbiAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHMyID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjOTApOyB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMyICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgczEgPSBwZWckYzkxKHMyKTtcbiAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgczAgPSBwZWckYzE7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgfVxuICAgICAgaWYgKHMwID09PSBwZWckRkFJTEVEKSB7XG4gICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gOTIpIHtcbiAgICAgICAgICBzMSA9IHBlZyRjOTI7XG4gICAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzkzKTsgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHMyID0gcGVnJHBhcnNlRXNjYXBlU2VxdWVuY2UoKTtcbiAgICAgICAgICBpZiAoczIgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgczEgPSBwZWckYzkxKHMyKTtcbiAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBlZyRjdXJyUG9zID0gczA7XG4gICAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGVnJGN1cnJQb3MgPSBzMDtcbiAgICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICByZXR1cm4gczA7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcGVnJHBhcnNlVW5xdW90ZWRTdHJpbmdDaGFyKCkge1xuICAgICAgdmFyIHMwLCBzMSwgczI7XG5cbiAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICBzMSA9IHBlZyRjdXJyUG9zO1xuICAgICAgcGVnJHNpbGVudEZhaWxzKys7XG4gICAgICBzMiA9IHBlZyRwYXJzZXdzKCk7XG4gICAgICBwZWckc2lsZW50RmFpbHMtLTtcbiAgICAgIGlmIChzMiA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMSA9IHBlZyRjODc7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwZWckY3VyclBvcyA9IHMxO1xuICAgICAgICBzMSA9IHBlZyRjMTtcbiAgICAgIH1cbiAgICAgIGlmIChzMSAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBpZiAoaW5wdXQubGVuZ3RoID4gcGVnJGN1cnJQb3MpIHtcbiAgICAgICAgICBzMiA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7XG4gICAgICAgICAgcGVnJGN1cnJQb3MrKztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBzMiA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgaWYgKHBlZyRzaWxlbnRGYWlscyA9PT0gMCkgeyBwZWckZmFpbChwZWckYzkwKTsgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChzMiAhPT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgIHMxID0gcGVnJGM5MShzMik7XG4gICAgICAgICAgczAgPSBzMTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICAgIHMwID0gcGVnJGMxO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBwZWckY3VyclBvcyA9IHMwO1xuICAgICAgICBzMCA9IHBlZyRjMTtcbiAgICAgIH1cblxuICAgICAgcmV0dXJuIHMwO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHBlZyRwYXJzZUVzY2FwZVNlcXVlbmNlKCkge1xuICAgICAgdmFyIHMwLCBzMTtcblxuICAgICAgaWYgKHBlZyRjOTYudGVzdChpbnB1dC5jaGFyQXQocGVnJGN1cnJQb3MpKSkge1xuICAgICAgICBzMCA9IGlucHV0LmNoYXJBdChwZWckY3VyclBvcyk7XG4gICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBzMCA9IHBlZyRGQUlMRUQ7XG4gICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGM5Nyk7IH1cbiAgICAgIH1cbiAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICBzMCA9IHBlZyRjdXJyUG9zO1xuICAgICAgICBpZiAoaW5wdXQuY2hhckNvZGVBdChwZWckY3VyclBvcykgPT09IDExMCkge1xuICAgICAgICAgIHMxID0gcGVnJGM5ODtcbiAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHMxID0gcGVnJEZBSUxFRDtcbiAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjOTkpOyB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHMxICE9PSBwZWckRkFJTEVEKSB7XG4gICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgczEgPSBwZWckYzEwMCgpO1xuICAgICAgICB9XG4gICAgICAgIHMwID0gczE7XG4gICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgIHMwID0gcGVnJGN1cnJQb3M7XG4gICAgICAgICAgaWYgKGlucHV0LmNoYXJDb2RlQXQocGVnJGN1cnJQb3MpID09PSAxMTQpIHtcbiAgICAgICAgICAgIHMxID0gcGVnJGMxMDE7XG4gICAgICAgICAgICBwZWckY3VyclBvcysrO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgICBpZiAocGVnJHNpbGVudEZhaWxzID09PSAwKSB7IHBlZyRmYWlsKHBlZyRjMTAyKTsgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgIHBlZyRyZXBvcnRlZFBvcyA9IHMwO1xuICAgICAgICAgICAgczEgPSBwZWckYzEwMygpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBzMCA9IHMxO1xuICAgICAgICAgIGlmIChzMCA9PT0gcGVnJEZBSUxFRCkge1xuICAgICAgICAgICAgczAgPSBwZWckY3VyclBvcztcbiAgICAgICAgICAgIGlmIChpbnB1dC5jaGFyQ29kZUF0KHBlZyRjdXJyUG9zKSA9PT0gMTE2KSB7XG4gICAgICAgICAgICAgIHMxID0gcGVnJGMxMDQ7XG4gICAgICAgICAgICAgIHBlZyRjdXJyUG9zKys7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzMSA9IHBlZyRGQUlMRUQ7XG4gICAgICAgICAgICAgIGlmIChwZWckc2lsZW50RmFpbHMgPT09IDApIHsgcGVnJGZhaWwocGVnJGMxMDUpOyB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoczEgIT09IHBlZyRGQUlMRUQpIHtcbiAgICAgICAgICAgICAgcGVnJHJlcG9ydGVkUG9zID0gczA7XG4gICAgICAgICAgICAgIHMxID0gcGVnJGMxMDYoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHMwID0gczE7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBzMDtcbiAgICB9XG5cblxuICAgIGZ1bmN0aW9uIG9yKGZpcnN0LCBzZWNvbmQpIHtcbiAgICAgICAgLy8gQWRkIGV4cGxpY2l0IGZ1bmN0aW9uIG5hbWVzIHRvIGVhc2UgZGVidWdnaW5nLlxuICAgICAgICBmdW5jdGlvbiBvckZpbHRlcigpIHtcbiAgICAgICAgICAgIHJldHVybiBmaXJzdC5hcHBseSh0aGlzLCBhcmd1bWVudHMpIHx8IHNlY29uZC5hcHBseSh0aGlzLCBhcmd1bWVudHMpO1xuICAgICAgICB9XG4gICAgICAgIG9yRmlsdGVyLmRlc2MgPSBmaXJzdC5kZXNjICsgXCIgb3IgXCIgKyBzZWNvbmQuZGVzYztcbiAgICAgICAgcmV0dXJuIG9yRmlsdGVyO1xuICAgIH1cbiAgICBmdW5jdGlvbiBhbmQoZmlyc3QsIHNlY29uZCkge1xuICAgICAgICBmdW5jdGlvbiBhbmRGaWx0ZXIoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmlyc3QuYXBwbHkodGhpcywgYXJndW1lbnRzKSAmJiBzZWNvbmQuYXB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b3J0cyA9IEZpbHQ7XG4iLCJ2YXIgXyA9IHJlcXVpcmUoXCJsb2Rhc2hcIik7XG5cbnZhciBfTWVzc2FnZVV0aWxzID0ge1xuICAgIGdldENvbnRlbnRUeXBlOiBmdW5jdGlvbiAobWVzc2FnZSkge1xuICAgICAgICByZXR1cm4gdGhpcy5nZXRfZmlyc3RfaGVhZGVyKG1lc3NhZ2UsIC9eQ29udGVudC1UeXBlJC9pKTtcbiAgICB9LFxuICAgIGdldF9maXJzdF9oZWFkZXI6IGZ1bmN0aW9uIChtZXNzYWdlLCByZWdleCkge1xuICAgICAgICAvL0ZJWE1FOiBDYWNoZSBJbnZhbGlkYXRpb24uXG4gICAgICAgIGlmICghbWVzc2FnZS5faGVhZGVyTG9va3VwcylcbiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShtZXNzYWdlLCBcIl9oZWFkZXJMb29rdXBzXCIsIHtcbiAgICAgICAgICAgICAgICB2YWx1ZToge30sXG4gICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICB3cml0YWJsZTogZmFsc2VcbiAgICAgICAgICAgIH0pO1xuICAgICAgICBpZiAoIShyZWdleCBpbiBtZXNzYWdlLl9oZWFkZXJMb29rdXBzKSkge1xuICAgICAgICAgICAgdmFyIGhlYWRlcjtcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbWVzc2FnZS5oZWFkZXJzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKCEhbWVzc2FnZS5oZWFkZXJzW2ldWzBdLm1hdGNoKHJlZ2V4KSkge1xuICAgICAgICAgICAgICAgICAgICBoZWFkZXIgPSBtZXNzYWdlLmhlYWRlcnNbaV07XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1c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