diff --git a/dist/milo.bundle.js b/dist/milo.bundle.js index 6a529ce..e9239b8 100644 --- a/dist/milo.bundle.js +++ b/dist/milo.bundle.js @@ -2933,6 +2933,8 @@ function CssFacet$set(data) { } function CssFacet$del() { + var self = this; + _.eachKey(this.activeModelPaths, function(modelPaths, cssClass) { modelPaths.clear(); @@ -19456,6 +19458,5 @@ function makeFindMethod(someMethod, findWhat) { } },{}]},{},[67]) - -; -//# sourceMappingURL=milo.bundle.map \ No newline at end of file +//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9yaWNoYXJkd2FsdG9uL1dvcmsvQ0MvbWlsby9saWIvYWJzdHJhY3QvZmFjZXQuanMiLCIvVXNlcnMvcmljaGFyZHdhbHRvbi9Xb3JrL0NDL21pbG8vbGliL2Fic3RyYWN0L2ZhY2V0ZWRfb2JqZWN0LmpzIiwiL1VzZXJzL3JpY2hhcmR3YWx0b24vV29yay9DQy9taWxvL2xpYi9hYnN0cmFjdC9yZWdpc3RyeS5qcyIsIi9Vc2Vycy9yaWNoYXJkd2FsdG9uL1dvcmsvQ0MvbWlsby9saWIvYXR0cmlidXRlcy9hX2JpbmQuanMiLCIvVXNlcnMvcmljaGFyZHdhbHRvbi9Xb3JrL0NDL21pbG8vbGliL2F0dHJpYnV0ZXMvYV9jbGFzcy5qcyIsIi9Vc2Vycy9yaWNoYXJkd2FsdG9uL1dvcmsvQ0MvbWlsby9saWIvYXR0cmlidXRlcy9hX2xvYWQuanMiLCIvVXNlcnMvcmljaGFyZHdhbHRvbi9Xb3JrL0NDL21pbG8vbGliL2F0dHJpYnV0ZXMvaW5kZXguanMiLCIvVXNlcnMvcmljaGFyZHdhbHRvbi9Xb3JrL0NDL21pbG8vbGliL2JpbmRlci5qcyIsIi9Vc2Vycy9yaWNoYXJkd2FsdG9uL1dvcmsvQ0MvbWlsby9saWIvY2xhc3Nlcy5qcyIsIi9Vc2Vycy9yaWNoYXJkd2FsdG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gdGhpcy5vbihtZXNzYWdlcywgc3Vic2NyaWJlcik7XG5cbiAgICAgICAgICAgIGlmIChjb250ZXh0VHlwZSA9PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgIGlmIChzdWJzY3JpYmVyLmNvbnRleHQgPT0gdGhpcy5uYW1lIHx8IHN1YnNjcmliZXIuY29udGV4dCA9PSAnZmFjZXQnKVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlcjogc3Vic2NyaWJlci5zdWJzY3JpYmVyLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dDogdGhpc1xuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGVsc2UgaWYgKHN1YnNjcmliZXIuY29udGV4dCA9PSAnb3duZXInKVxuICAgICAgICAgICAgICAgICAgICBzdWJzY3JpYmVyID0ge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlcjogc3Vic2NyaWJlci5zdWJzY3JpYmVyLFxuICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dDogdGhpcy5vd25lclxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCd1bmtub3duIHN1YnNjcmliZXIgY29udGV4dCBpbiBjb25maWd1cmF0aW9uOiAnICsgc3Vic2NyaWJlci5jb250ZXh0KTtcblxuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm9uKG1lc3NhZ2VzLCBzdWJzY3JpYmVyKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCd1bmtub3duIHN1YnNjcmliZXIgY29udGV4dCB0eXBlIGluIGNvbmZpZ3VyYXRpb246ICcgKyBjb250ZXh0VHlwZSk7XG4gICAgICAgIH1cblxuICAgICAgICB0aHJvdyBuZXcgRXJyb3I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cbiAgICBmb3IgKHZhciBpID0gMCwgbGVuID0gcGFyc2VkUGF0aC5sZW5ndGg7IGkgPCBsZW47IGkrKykge1xuICAgICAgICB2YXIgcGF0aE5vZGUgPSBwYXJzZWRQYXRoW2ldXG4gICAgICAgICAgICAsIG5vZGVLZXkgPSBwYXRoVXRpbHMuZ2V0UGF0aE5vZGVLZXkocGF0aE5vZGUpO1xuICAgICAgICBpZiAocGF0aE5vZGUuc3ludGF4ID09ICdhcnJheScgJiYgY3VycmVudENvbXBvbmVudC5saXN0KSB7XG4gICAgICAgICAgICB2YXIgaXRlbUNvbXBvbmVudCA9IGN1cnJlbnRDb21wb25lbnQubGlzdC5pdGVtKG5vZGVLZXkpO1xuICAgICAgICAgICAgaWYgKCEgaXRlbUNvbXBvbmVudCAmJiBjcmVhdGVJdGVtICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgIGl0ZW1Db21wb25lbnQgPSBjdXJyZW50Q29tcG9uZW50Lmxpc3QuX2FkZEl0ZW0obm9kZUtleSk7XG4gICAgICAgICAgICAgICAgaXRlbUNvbXBvbmVudC5kYXRhLl9wYXRoID0gcGF0aE5vZGUucHJvcGVydHk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjdXJyZW50Q29tcG9uZW50ID0gaXRlbUNvbXBvbmVudDtcbiAgICAgICAgfSBlbHNlIGlmIChjdXJyZW50Q29tcG9uZW50LmNvbnRhaW5lcilcbiAgICAgICAgICAgIGN1cnJlbnRDb21wb25lbnQgPSBjdXJyZW50Q29tcG9uZW50LmNvbnRhaW5lci5zY29wZVtub2RlS2V5XTtcblxuICAgICAgICB2YXIgY3VycmVudERhdGFGYWNldCA9IGN1cnJlbnRDb21wb25lbnQgJiYgY3VycmVudENvbXBvbmVudC5kYXRhO1xuICAgICAgICBpZiAoISBjdXJyZW50RGF0YUZhY2V0KVxuICAgICAgICAgICAgYnJlYWs7XG4gICAgfVxuXG4gICAgcmV0dXJuIGN1cnJlbnREYXRhRmFjZXQ7XG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AnZnVuY3Rpb24nOlxuICAgICAgICAgICAgICAgIHJldHVybiBhbGxvd0NvbXBzLmNhbGwodGhpcy5vd25lciwgbWV0YSwgZHQsIG9yaWdpbmFsRHJvcENvbXBvbmVudCk7XG4gICAgICAgICAgICBjYXNlICdvYmplY3QnOlxuICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGFsbG93Q29tcHMpKVxuICAgICAgICAgICAgICAgICAgICAvLyBsaXN0IG9mIGFsbG93ZWQgY2xhc3Nlc1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gYWxsb3dDb21wcy5pbmRleE9mKG1ldGEgJiYgbWV0YS5jb21wQ2xhc3MpID49IDA7XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIG1hcCBvZiBjbGFzczogYm9vbGVhbnx0ZXN0IGZ1bmN0aW9uXG4gICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0gYWxsb3dDb21wc1ttZXRhICYmIG1ldGEuY29tcENsYXNzXTtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhIF8ucmVzdWx0KHRlc3QsIHRoaXMub3duZXIsIG1ldGEsIGR0KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW5jb3JyZWN0IGFsbG93ZWQgY29tcG9uZW50cyBpbiBjb25maWcnKTtcbiAgICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICAgIHZhciBkYXRhVHlwZXMgPSBhbGxvdyAmJiBhbGxvdy5kYXRhVHlwZXNcbiAgICAgICAgc3dpdGNoICh0eXBlb2YgZGF0YVR5cGVzKSB7XG4gICAgICAgICAgICBjYXNlICd1bmRlZmluZWQnOlxuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIGNhc2UgJ3N0cmluZyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuI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2dlci5lcnJvcignbnVtYmVyIG9mIGl0ZW1zIGFkZGVkIGlzIGRpZmZlcmVudCBmcm9tIHJlcXVlc3RlZCcpO1xuXG4gICAgaWYgKGNoaWxkcmVuICYmIGNoaWxkcmVuLmxlbmd0aCkge1xuICAgICAgICB2YXIgbGlzdExlbmd0aCA9IHRoaXMuY291bnQoKTtcbiAgICAgICAgdmFyIHNwbGljZUluZGV4ID0gaW5kZXggPCAwXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgPyAwXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgOiB0eXBlb2YgaW5kZXggPT0gJ3VuZGVmaW5lZCcgfHwgaW5kZXggPiBsaXN0TGVuZ3RoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gbGlzdExlbmd0aFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IGluZGV4O1xuXG4gICAgICAgIHZhciBwcmV2Q29tcG9uZW50ID0gc3BsaWNlSW5kZXggPT0gMFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IHRoaXMuaXRlbVNhbXBsZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IHRoaXMuX2xpc3RJdGVtc1tzcGxpY2VJbmRleCAtIDFdO1xuXG4gICAgICAgIHZhciBmcmFnID0gZG9jdW1lbnQuY3JlYXRlRG9jdW1lbnRGcmFnbWVudCgpXG4gICAgICAgICAgICAsIG5ld0NvbXBvbmVudHMgPSBbXTtcblxuICAgICAgICBjaGlsZHJlbi5mb3JFYWNoKGZ1bmN0aW9uKGVsLCBpKSB7XG4gICAgICAgICAgICB2YXIgY29tcG9uZW50ID0gQ29tcG9uZW50LmdldENvbXBvbmVudChlbCk7XG4gICAgICAgICAgICBpZiAoISBjb21wb25lbnQpXG4gICAgICAgICAgICAgICAgcmV0dXJuIGxvZ2dlci5lcnJvcignTGlzdDogZWxlbWVudCBpbiBuZXcgaXRlbXMgaXMgbm90IGEgY29tcG9uZW50Jyk7XG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cyA9IHt9O1xuXG4gICAgaWYgKEFycmF5LmlzQXJyYXkoZmFjZXRzKSlcbiAgICAgICAgZmFjZXRzLmZvckVhY2goZnVuY3Rpb24oZmN0TmFtZSkge1xuICAgICAgICAgICAgZmN0TmFtZSA9IF8uZmlyc3RVcHBlckNhc2UoZmN0TmFtZSk7XG4gICAgICAgICAgICBpZiAoQ29tcG9uZW50Q2xhc3MuaGFzRmFjZXQoZmN0TmFtZSkpXG4gICAgICAgICAgICAgICAgcmVwb3J0QmluZGVyRXJyb3IodGhyb3dPbkVycm9ycywgJ2NsYXNzICcgKyBDb21wb25lbnRDbGFzcy5uYW1lXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgJyBhbHJlYWR5IGhhcyBmYWNldCAnICsgZmN0TmFtZSk7XG4gICAgICAgICAgICBpZiAoZXh0cmFGYWNldHNDbGFzc2VzW2ZjdE5hbWVdKVxuICAgICAgICAgICAgICAgIHJlcG9ydEJpbmRlckVycm9yKHRocm93T25FcnJvcnMsICdjb21wb25lbnQgJyArIGF0dHIuY29tcE5hbWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAnIGFscmVhZHkgaGFzIGZhY2V0ICcgKyBmY3ROYW1lKTtcbiAgICAgICAgICAgIHZhciBGYWNldENsYXNzID0gZmFjZXRzUmVnaXN0cnkuZ2V0KGZjdE5hbWUpO1xuICAgICAgICAgICAgZXh0cmFGYWNldHNDbGFzc2VzW2ZjdE5hbWVdID0gRmFjZXRDbGFzcztcbiAgICAgICAgfSk7XG5cbiAgICByZXR1cm4gZXh0cmFGYWNldHNDbGFzc2VzO1xufVxuXG5cbmZ1bmN0aW9uIHJlcG9ydEJpbmRlckVycm9yKHRocm93T25FcnJvcnMsIG1lc3NhZ2UpIHtcbiAgICBpZiAodGhyb3dPbkVycm9ycyA9PT0gZmFsc2UpXG4gICAgICAgIGxvZ2dlci5lcnJvcignQ29tcG9uZW50SW5mbyBiaW5kZXIgZXJ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gOml0ZW06aW5kZXggfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7IHZhciBoYXNTdWJUcmVlID0gaXRlbS5pdGVtcyAmJiBpdGVtLml0ZW1zLmxlbmd0aDsgfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxsaSB7ez8gaGFzU3ViVHJlZSB9fWNsYXNzPVwibWwtdWktZm9sZHRyZWUtLWhhcy1tdWx0aXBsZVwie3s/fX0+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz1cIm1sLXVpLWZvbGR0cmVlLWl0ZW1cIiBkYXRhLWl0ZW0taWQ9XCJ7ez0gaXQuaXRlbUlEc1tpbmRleF0gfX1cIj5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s/IGhhc1N1YlRyZWUgfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9XCJtbC11aS1mb2xkdHJlZS1idXR0b25cIj48L2Rpdj5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s/fX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s9IGl0Lml0ZW1UZW1wbGF0ZSh7IGl0ZW06IGl0ZW0gfSkgfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8L2Rpdj5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7ez8gaGFzU3ViVHJlZSB9fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7ez0gaXQudHJlZVRlbXBsYXRlKGl0ZW0pIH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s/fX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDwvbGk+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHt7fn19XFxcbiAgICAgICAgICAgICAgICAgICAgPC91bD4nO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Gxpc3RpdGVtY2hhbmdlJztcblxudmFyIE1MTGlzdEl0ZW0gPSBDb21wb25lbnQuY3JlYXRlQ29tcG9uZW50Q2xhc3MoJ01MTGlzdEl0ZW0nLCB7XG4gICAgY29udGFpbmVyOiB1bmRlZmluZWQsXG4gICAgZG9tOiB1bmRlZmluZWQsXG4gICAgZHJhZzoge1xuICAgICAgICBtZXNzYWdlczoge1xuICAgICAgICAgICAgJ2RyYWdzdGFydCc6IHsgc3Vic2NyaWJlcjogb25EcmFnU3RhcnQsIGNvbnRleHQ6ICdvd25lcicgfVxuICAgICAgICB9LFxuICAgICAgICBtZXRhOiB7XG4gICAgICAgICAgICBwYXJhbXM6ICdnZXRNZXRhRGF0YSdcbiAgICAgICAgfVxuICAgIH0sXG4gICAgZHJvcDoge1xuICAgICAgICBtZXNzYWdlczoge1xuICAgICAgICAgICAgJ2RyYWdlbnRlcic6IHsgc3Vic2NyaWJlcjogb25EcmFnSG92ZXIsIGNvbnRleHQ6ICdvd25lcicgfSxcbiAgICAgICAgICAgICdkcmFnb3Zlcic6IHsgc3Vic2NyaWJlcjogb25EcmFnSG92ZXIsIGNvbnRleHQ6ICdvd25lcicgfSxcbiAgICAgICAgICAgICdkcmFnbGVhdmUnOiB7IHN1YnNjcmliZXI6IG9uRHJhZ091dCwgY29udGV4dDogJ293bmVyJyB9LFxuICAgICAgICAgICAgJ2Ryb3AnOiB7IHN1YnNjcmliZXI6IG9uSXRlbURyb3AsIGNvbnRleHQ6ICdvd25lcicgfVxuICAgICAgICB9LFxuICAgICAgICBhbGxvdzoge1xuICAgICAgICAgICAgY29tcG9uZW50czogaXNDb21wb25lbnRBbGxvd2VkXG4gICAgICAgIH1cbiAgICB9LFxuICAgIGRhdGE6IHtcbiAgICAgICAgZ2V0OiBNTExpc3RJdGVtX2dldCxcbiAgICAgICAgc2V0OiBNTExpc3RJdGVtX3NldCxcbiAgICAgICAgZGVsOiBNTExpc3RJdGVtX2RlbCxcbiAgICAgICAgZXZlbnQ6I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nRpbWVzOzwvYnV0dG9uPlxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAge3s/fX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxoNCBjbGFzcz1cIm1vZGFsLXRpdGxlXCI+e3s9IGl0LnRpdGxlIH19PC9oND5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+XFxcbiAgICAgICAgICAgICAgICAgICAge3s/fX1cXFxuICAgICAgICAgICAgICAgICAgICB7ez8gaXQuaHRtbCB8fCBpdC50ZXh0IH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9XCJtb2RhbC1ib2R5XCIgbWwtYmluZD1cIltjb250YWluZXJdOmRpYWxvZ0JvZHlcIj5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7PyBpdC5odG1sIH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s9IGl0Lmh0bWwgfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7Pz99fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxwPnt7PSBpdC50ZXh0IH19PC9wPlxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAge3s/fX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+XFxcbiAgICAgICAgICAgICAgICAgICAge3s/fX1cXFxuICAgICAgICAgICAgICAgICAgICB7ez8gaXQuYnV0dG9ucyAmJiBpdC5idXR0b25zLmxlbmd0aCB9fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPVwibW9kYWwtZm9vdGVyXCI+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7e34gaXQuYnV0dG9ucyA6YnRuIH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPGJ1dHRvbiB0eXBlPVwiYnV0dG9uXCJcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2x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AgIGxvYWQ6ICdtbC1sb2FkJ1xuICAgIH0sXG4gICAgY29tcG9uZW50UmVmOiAnX19fbWlsb19jb21wb25lbnQnLFxuICAgIGNvbXBvbmVudFByZWZpeDogJ21pbG9fJyxcbiAgICB0ZW1wbGF0ZToge1xuICAgICAgICBjb21waWxlOiBkb1QuY29tcGlsZVxuICAgIH0sXG4gICAgZG9tU3RvcmFnZToge1xuICAgICAgICB0eXBlU3VmZml4OiAnOl9fX21pbG9fZGF0YV90eXBlJyxcbiAgICAgICAgcHJlZml4U2VwYXJhdG9yOiAnLycsXG4gICAgICAgIHJvb3Q6ICcnLFxuICAgICAgICBtZXNzYWdlS2V5OiAnX19fbWlsb19tZXNzYWdlLycsXG4gICAgICAgIG1lc3NhZ2VUaW1lc3RhbXA6ICdfX19taWxvX3RpbWVzdGFtcCcsXG4gICAgICAgIHF1b3RhRXhjZWVkZWQ6IHtcbiAgICAgICAgICAgIHRocm93RXJyb3I6IHRydWUsXG4gICAgICAgICAgICBtZXNzYWdlOiBmYWxzZVxuICAgICAgICB9XG4gICAgfSxcbiAgICBkcmFnRHJvcDoge1xuICAgICAgICBkYXRhVHlwZXM6IHtcbiAgICAgICAgICAgIGNvbXBvbmVudDogJ3gtYXBwbGljYXRpb24vbWlsby9jb21wb25lbnQnLFxuICAgICAgICAgICAgY29tcG9uZW50TWV0YVRlbXBsYXRlOiAneC1hcHBsaWNhdGlvbi9taWxvL2NvbXBvbmVudC1tZXRhLyVjbGFzcy8lbmFtZS8lcGFyYW1zJyxcbiAgICAgICAgICAgIGNvbXBvbmVudE1ldGFSZWdleDogL154XFwtYXBwbGljYXRpb25cXC9taWxvXFwvY29tcG9uZW50XFwtbWV0YVxcLyhbYS16MC05XSspXFwvKFthLXowLTldKylcXC8oW2EtejAtOV0qKSQvLFxuICAgICAgICB9XG4gICAgfSxcbiAgICByZXF1ZXN0OiB7XG4gICAgICAgIGpzb25wVGltZW91dDogNjAwMDAsXG4gICAgICAgIGpzb25wQ2FsbGJ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ICdzdWNjZXNzJywgZXJyLCByZXN1bHQpO1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIGxvZ2dlci5lcnJvcignTm8gSlNPTlAgcmVzcG9uc2Ugb3IgdGltZW91dCcpO1xuICAgICAgICAgICAgICAgIHBvc3RNZXNzYWdlKCdlcnJvcmpzb25wdGltZW91dCcsIGVycik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjYWxsYmFjayAmJiBjYWxsYmFjayhlcnIsIHJlc3VsdCk7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2goZSkgeyB2YXIgZXJyb3IgPSBlOyB9XG4gICAgICAgIGlmIChlcnIpIHhQcm9taXNlLnJlamVjdChlcnIpO1xuICAgICAgICBlbHNlIHhQcm9taXNlLnJlc29sdmUocmVzdWx0KTtcblxuICAgICAgICBjbGVhblVwKCk7XG4gICAgICAgIGlmICghX3BlbmRpbmdSZXF1ZXN0cy5sZW5ndGgpXG4gICAgICAgICAgICBwb3N0TWVzc2FnZSgncmVxdWVzdHNjb21wbGV0ZWQnKTtcblxuICAgICAgICBpZiAoZXJyb3IpIHRocm93IGVycm9yO1xuICAgIH1cblxuXG4gICAgZnVuY3Rpb24gY2xlYW5VcCgpIHtcbiAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXQpO1xuICAgICAgICBoZWFkLnJlbW92ZUNoaWxkKHNjcmlwdCk7XG4gICAgICAgIGRlbGV0ZSB3aW5kb3dbdW5pcXVlQ2FsbGJhY2tdO1xuICAgIH1cblxuXG4gICAgZnVuY3Rpb24gcG9zdE1lc3NhZ2UobXNnLCBzdGF0dXMsIHJlc3VsdCkge1xuICAgICAgICBpZiAoX21lc3NlbmdlcikgcmVxdWVzdC5wb3N0TWVzc2FnZShtc2csXG4gICAgICAgICAgICB7IHN0YXR1czogc3RhdHVzLCByZXNwb25zZTogcmVzdWx0IH0pO1xuICAgIH1cbn1cblxuXG5mdW5jdGlvbiByZXF1ZXN0JGZpbGU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ICAgICAgICAgICBiaXRzIHw9IChieXRlID4+ICgtc2tpcCkpXG4gICAgICAgIH0gZWxzZSB7IC8vIG5vIGNhcnJ5XG4gICAgICAgICAgICBiaXRzID0gKGJ5dGUgPDwgc2tpcCkgJiAyNDhcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChza2lwID4gMykge1xuICAgICAgICAgICAgLy8gbm90IGVub3VnaCBkYXRhIHRvIHByb2R1Y2UgYSBjaGFyYWN0ZXIsIGdldCB1cyBhbm90aGVyIG9uZVxuICAgICAgICAgICAgc2tpcCAtPSA4XG4gICAgICAgICAgICByZXR1cm4gMVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHNraXAgPCA0KSB7XG4gICAgICAgICAgICAvLyBwcm9kdWNlIGEgY2hhcmFjdGVyXG4gICAgICAgICAgICB0aGlzLm91dHB1dCArPSBhbHBoYWJldFtiaXRzID4+IDNdXG4gICAgICAgICAgICBza2lwICs9IDVcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiAwXG4gICAgfVxuXG4gICAgLy8gRmx1c2ggYW55IHJlbWFpbmluZyBiaXRzIGxlZnQgaW4gdGhlIHN0cmVhbVxuICAgIHRoaXMuZmluaXNoID0gZnVuY3Rpb24oY2hlY2spIHtcbiAgICAgICAgdmFyIG91dHB1dCA9IHRoaXMub3V0cHV0ICsgKHNraXAgPCAwID8gYWxwaGFiZXRbYml0cyA+PiAzXSA6ICcnKSArIChjaGVjayA/ICckJyA6ICcnKVxuICAgICAgICB0aGlzLm91dHB1dCA9ICcnXG4gICAgICAgIHJldHVybiBvdXRwdXRcbiAgICB9XG59XG5cbi8qKlxuICogUHJvY2VzcyBhZGRpdGlvbmFsIGlucHV0XG4gKlxuICogaW5wdXQ6IHN0cmluZyBvZiBieXRlcyB0byBjb252ZXJ0XG4gKiBmbHVzaDogYm9vbGVhbiwgc2hvdWxkIHdlIGZsdXNoIGFueSB0cmFpbGluZyBiaXRzIGxlZnRcbiAqICAgICAgICBpbiB0aGUgc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nNsYXRpb24sIHBhdHRlcm5UcmFuc2xhdGlvbiwgZGF0YVRyYW5zbGF0aW9uLCBkYXRhVmFsaWRhdGlvbikge1xuICAgICAgICBmcm9tRFMub25TeW5jKCdkYXRhY2hhbmdlcycsIG9uRGF0YSk7XG4gICAgICAgIHJldHVybiBvbkRhdGE7XG5cbiAgICAgICAgZnVuY3Rpb24gb25EYXRhKG1lc3NhZ2UsIGJhdGNoKSB7XG4gICAgICAgICAgICB2YXIgc2VuZERhdGEgPSB7XG4gICAgICAgICAgICAgICAgY2hhbmdlczogW10sXG4gICAgICAgICAgICAgICAgdHJhbnNhY3Rpb246IGJhdGNoLnRyYW5zYWN0aW9uXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGJhdGNoLmNoYW5nZXMuZm9yRWFjaChmdW5jdGlvbihjaGFuZ2UpIHtcbiAgICAgICAgICAgICAgICB2YXIgc291cmNlUGF0aCA9IGNoYW5nZS5wYXRoXG4gICAgICAgICAgICAgICAgICAgICwgdGFyZ2V0UGF0aCA9IHRyYW5zbGF0ZVBhdGgoc291cmNlUGF0aCk7XG5cbiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRhcmdldFBhdGggPT0gJ3VuZGVmaW5lZCcpIHJldHVybjtcblxuICAgICAgICAgICAgICAgIHZhciBjaGFuZ2UgPSBfLmNsb25lKGNoYW5nZSk7XG4gICAgICAgICAgICAgICAgXy5leHRlbmQoY2hhbmdlLCB7XG4gICAgICAgICAgICAgICAgICAgIHNvdXJjZTogZnJvbURTLFxuICAgICAgICAgICAgICAgICAgICBwYXRoOiB0YXJnZXRQYXRoXG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICB0cmFuc2xhdGVEYXRhKHNvdXJjZVBhdGgsIGNoYW5nZSk7XG4gICAgICAgICAgICAgICAgdmFsaWRhdGVEYXRhKHNvdXJjZVBhdGgsIGNoYW5nZSk7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgaWYgKCEgY2hhbmdlc1F1ZXVlLmxlbmd0aClcbiAgICAgICAgICAgICAgICBfLmRlZmVyKHBvc3RDaGFuZ2VEYXRhKTtcblxuICAgICAgICAgICAgY2hhbmdlc1F1ZXVlLnB1c2goc2VuZERhdGEpO1xuXG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHRyYW5zbGF0ZVBhdGgoc291cmNlUGF0aCkge1xuICAgICAgICAgICAgICAgIGlmIChwYXRoVHJhbnNsYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zbGF0ZWRQYXRoID0gcGF0aFRyYW5zbGF0aW9uW3NvdXJjZVBhdGhdO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNsYXRlZFBhdGgpIHJldHVybiB0cmFuc2xhdGVkUGF0aDtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXR0ZXJuVHJhbnNsYXRpb24ubGVuZ3RoKSByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgIHZhciBwdCA9IF8uZmluZChwYXR0ZXJuVHJhbnNsYXRpb24sIGZ1bmN0aW9uKHBUcmFuc2xhdGlvbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBUcmFuc2xhdGlvbi5mcm9tUGF0dGVybi50ZXN0KHNvdXJjZVBhdGgpO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFwdCkgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB2YXIgdHJhbnNsYXRlZFBhdGggPSBzb3VyY2VQYXRoLnJlcGxhY2UocHQuZnJvbVN0YXRpY1BhdGgsIHB0LnRvU3RhdGljUGF0aCk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghICgoc3Vic2NyaXB0aW9uUGF0dGVybiBpbnN0YW5jZW9mIFJlZ0V4cFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgc3Vic2NyaXB0aW9uUGF0dGVybi50ZXN0KHNvdXJjZVBhdGgpKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgc3Vic2NyaXB0aW9uUGF0dGVybiA9PSBzb3VyY2VQYXRoKSkgcmV0dXJuO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRyYW5zbGF0ZWRQYXRoIHx8IHNvdXJjZVBhdGg7XG4gICAgICAgICAgICB9XG5cblxuICAgICAgICAgICAgZnVuY3Rpb24gdHJhbnNsYXRlRGF0YShzb3VyY2VQYXRoLCBjaGFuZ2UpIHtcbiAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zbGF0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2xhdGUgPSBkYXRhVHJhbnNsYXRpb25bc291cmNlUGF0aF07XG4gICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2xhdGUgJiYgdHlwZW9mIHRyYW5zbGF0ZSA9PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2Uub2xkVmFsdWUgPSB0cmFuc2xhdGUoY2hhbmdlLm9sZFZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5nZS5uZXdWYWx1ZSA9IHRyYW5zbGF0ZShjaGFuZ2UubmV3VmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgXG4gICAgICAgICAgICBmdW5jdGlvbiB2YWxpZGF0ZURhdGEoc291cmNlUGF0aCwgY2hhbmdlKSB7XG4gICAgICAgICAgICAgICAgcHJvcGFnYXRlRGF0YShjaGFuZ2UpO1xuXG4gICAgICAgICAgICAgICAgaWYgKGRhdGFWYWxpZGF0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0b3JzID0gZGF0YVZhbGlkYXRpb25bc291cmNlUGF0aF1cbiAgICAgICAgICAgICAgICAgICAgICAgICwgcGFzc2VkQ291bnQgPSAwXG4gICAgICAgICAgICAgICAgICAgICAgICAsIGFscmVhZHlGYWlsZWQgPSBmYWxzZTtcblxuICAgICAgICAgICAgICAgICAgICBpZiAodmFsaWRhdG9ycylcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbGlkYXRvcnMuZm9yRWFjaChjYWxsVmFsaWRhdG9yKTsgICBcbiAgICAgICAgICAgICAgICB9XG5cblxuICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNhbGxWYWxpZGF0b3IodmFsaWRhdG9yKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhbGlkYXRvcihjaGFuZ2UubmV3VmFsdWUsIGZ1bmN0aW9uKGVyciwgcmVzcG9uc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlLnBhdGggPSBzb3VyY2VQYXRoO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEgYWxyZWFkeUZhaWxlZCAmJiAoZXJyIHx8IHJlc3BvbnNlLnZhbGlkKSAmJiArK3Bhc3NlZENvdW50ID09IHZhbGlkYXRvcnMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbURTLnBvc3RNZXNzYWdlKCd2YWxpZGF0ZWQnLCByZXNwb25zZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCEgcmVzcG9uc2UudmFsaWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHJlYWR5RmFpbGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tRFMucG9zdE1lc3NhZ2UoJ3ZhbGlkYXRlZCcsIHJlc3BvbnNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHByb3BhZ2F0ZURhdGEoY2hhbmd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bcmV2ZXJzZUxpbmtdKTtcblxuICAgICAgICAgICAgICAgIHZhciBtZXNzYWdlID0gY2hhbmdlRmluaXNoZWQgPyAnY2hhbmdlY29tcGxldGVkJyA6ICdjaGFuZ2VzdGFydGVkJztcbiAgICAgICAgICAgICAgICBzZWxmLnBvc3RNZXNzYWdlKG1lc3NhZ2UsIHsgc291cmNlOiBmcm9tRFMsIHRhcmdldDogdG9EUyB9KTtcbiAgICAgICAgICAgIH1cblxuXG4gICAgICAgICAgICBmdW5jdGlvbiBtZXJnZVRyYW5zYWN0aW9ucyhiYXRjaGVzKSB7XG4gICAgICAgICAgICAgICAgdmFyIHRyYW5zYWN0aW9ucyA9IFtdXG4gICAgICAgICAgICAgICAgICAgICwgY3VycmVudFRyYW5zYWN0aW9uO1xuXG4gICAgICAgICAgICAgICAgYmF0Y2hlcy5mb3JFYWNoKGZ1bmN0aW9uKGJhdGNoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghIGJhdGNoLnRyYW5zYWN0aW9uKSBjdXJyZW50VHJhbnNhY3Rpb24gPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgICAgIGlmICghIGJhdGNoLmNoYW5nZXMubGVuZ3RoKSByZXR1cm47XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKGJhdGNoLnRyYW5zYWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudFRyYW5zYWN0aW9uKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIF8uYXBwZW5kQXJyYXkoY3VycmVudFRyYW5zYWN0aW9uLCBiYXRjaC5jaGFuZ2VzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRUcmFuc2FjdGlvbiA9IF8uY2xvbmUoYmF0Y2guY2hhbmdlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNhY3Rpb25zLnB1c2goY3VycmV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xuICAgICwgYXJyYXlJbnRlcnBvbGF0ZVN5bnRheCA9ICdcXFxcWycgKyBpbnRlcnBvbGF0aW9uU3ludGF4ICsgJ1xcXFxdJ1xuXG4gICAgLCBwcm9wZXJ0eVN0YXJTeW50YXggPSAnXFxcXC5cXFxcKidcbiAgICAsIGFycmF5U3RhclN5bnRheCA9ICdcXFxcW1xcXFwqXFxcXF0nXG4gICAgLCBzdGFyU3ludGF4ID0gJ1xcXFwqJ1xuXG4gICAgLCBwYXRoUGFyc2VTeW50YXggPSBbXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydHlQYXRoU3ludGF4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFycmF5UGF0aFN5bnRheCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eUludGVycG9sYXRlU3ludGF4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFycmF5SW50ZXJwb2xhdGVTeW50YXhcbiAgICAgICAgICAgICAgICAgICAgICAgIF0uam9pbignfCcpXG4gICAgLCBwYXRoUGFyc2VQYXR0ZXJuID0gbmV3IFJlZ0V4cChwYXRoUGFyc2VTeW50YXgsICdnJylcblxuICAgICwgcGF0dGVyblBhdGhQYXJzZVN5bnRheCA9ICBbXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoUGFyc2VTeW50YXgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0eVN0YXJTeW50YXgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJheVN0YXJTeW50YXgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFyU3ludGF4XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF0uam9pbignfCcpXG4gICAgLCBwYXR0ZXJuUGF0aFBhcnNlUGF0dGVybiA9IG5ldyBSZWdFeHAocGF0dGVyblBhdGhQYXJzZVN5bnRheCw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9vcHRpb25zLnJlYWN0aXZlICE9PSBmYWxzZSkge1xcbiAgICAgICAgICAgICAgICB7eyMgZGVmLmFkZE1zZyB9fSAnJywgdHlwZTogJ2FkZGVkJyxcXG4gICAgICAgICAgICAgICAgICAgICAgbmV3VmFsdWU6IG0gfSk7XFxuICAgICAgICAgICAgfVxcbiAgICAgICAgfVxcbiAgICB7ez8/fX1cXG4gICAgICAgIHt7PyBtZXRob2QgPT0gJ3NwbGljZScgfX1cXG4gICAgICAgICAgICBpZiAoISBtKSB7XFxuICAgICAgICB7ez99fVxcbiAgICAgICAgICAgICAgICBtID0ge3sjIGRlZi5tb2RlbEFjY2Vzc1ByZWZpeCB9fSA9IGNsb25lVHJlZSh2YWx1ZSk7XFxuICAgICAgICAgICAgICAgIHdhc0RlZiA9IHR5cGVvZiBvbGQgIT0gJ3VuZGVmaW5lZCc7XFxuICAgICAgICB7ez8gbWV0aG9kID09ICdzcGxpY2UnIH19XFxuICAgICAgICAgICAgfVxcbiAgICAgICAge3s/fX0gICAgICAgXFxuICAgIHt7P319XFxuXFxuXFxuICAgIHt7IC8qIGNyZWF0ZSBtb2RlbCB0cmVlIGlmIGl0IGRvZXNuJ3QgZXhpc3QgKi8gfX1cXG4gICAge3sgIHZhciBtb2RlbERhdGFQcm9wZXJ0eSA9ICcnO1xcbiAgICAgICAgdmFyIG5leHROb2RlID0gaXQucGFyc2VkUGF0aFswXTtcXG4gICAgICAgIHZhciBjb3VudCA9IGl0LnBhcnNlZFBhdGgubGVuZ3RoIC0gMTtcXG5cXG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgY291bnQ7IGkrKykge1xcbiAgICAgICAgICAgIHZhciBjdXJyTm9kZSA9IG5leHROb2RlO1xcbiAgICAgICAgICAgIHZhciBjdXJyUHJvcCA9IGN1cnJOb2RlLnByb3BlcnR5O1xcbiAgICAgICAgICAgIG5leHROb2RlID0gaXQucGFyc2VkUGF0aFtpICsgMV07XFxuICAgICAgICAgICAgdmFyIGVtc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GgsIG9sZFZhbHVlLCAncmVtb3ZlZCcsICdvbGRWYWx1ZScpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGFkZE1lc3NhZ2VzKG1lc3NhZ2VzLCBtZXNzYWdlc0hhc2gsIHJvb3RQYXRoLCBvYmosIG1zZ1R5cGUsIHZhbHVlUHJvcCkge1xuICAgICAgICBfYWRkTWVzc2FnZXMocm9vdFBhdGgsIG9iaik7XG5cblxuICAgICAgICBmdW5jdGlvbiBfYWRkTWVzc2FnZXMocm9vdFBhdGgsIG9iaikge1xuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkob2JqKSkge1xuICAgICAgICAgICAgICAgIHZhciBwYXRoU3ludGF4ID0gcm9vdFBhdGggKyAnWyQkXSc7XG4gICAgICAgICAgICAgICAgb2JqLmZvckVhY2goZnVuY3Rpb24odmFsdWUsIGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIGFkZE1lc3NhZ2UodmFsdWUsIGluZGV4LCBwYXRoU3ludGF4KTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFyIHBhdGhTeW50YXggPSByb290UGF0aCArICcuJCQnO1xuICAgICAgICAgICAgICAgIF8uZWFjaEtleShvYmosIGZ1bmN0aW9uKHZhbHVlLCBrZXkpIHtcbiAgICAgICAgICAgICAgICAgICAgYWRkTWVzc2FnZSh2YWx1ZSwga2V5LCBwYXRoU3ludGF4KTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIGFkZE1lc3NhZ2UodmFsdWUsIGtleSwgcGF0aFN5bnRheCkge1xuICAgICAgICAgICAgdmFyIHBhdGggPSBwYXRoU3ludGF4LnJlcGxhY2UoJyQkJywga2V5KVxuICAgICAgICAgICAgICAgICwgZXhpc3RpbmdNc2cgPSBtZXNzYWdlc0hhc2hbcGF0aF07XG5cbiAgICAgICAgICAgIGlmIChleGlzdGluZ01zZykge1xuICAgICAgICAgICAgICAgIGlmIChleGlzdGluZ01zZy50eXBlID09IG1zZ1R5cGUpXG4gICAgICAgICAgICAgICAgICAgIGxvZ2dlci5lcnJvcignc2V0dGVyIGVycm9yOiBzYW1lIG1lc3NhZ2UgdHlwZSBwb3N0ZWQgb24gdGhlIHNhbWUgcGF0aCcpO1xuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBleGlzdGluZ01zZy50eXBlID0gJ2NoYW5nZWQnO1xuICAgICAgICAgICAgICAgICAgICBleGlzdGluZ01zZ1t2YWx1ZVByb3BdID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YXIgbXNnID0geyBwYXRoOiBwYXRoLCB0eXBlOiBtc2dUeXBlIH07XG4gICAgICAgICAgICAgICAgbXNnW3ZhbHVlUHJvcF0gPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICBhZGRDaGFuZ2VNZXNzYWdlKG1lc3NhZ2VzLCBtZXNzYWdlc0hhc2gsIG1zZyk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh2YWx1ZUlzVHJlZSh2YWx1ZSkpXG4gICAgICAgICAgICAgICAgX2FkZE1lc3NhZ2VzKHBhdGgsIHZhbHVlKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNsb25lVHJlZSh2YWx1ZSkge1xuICAgICAgICByZXR1cm4gdmFsdWVJc05vcm1hbE9iamVjdCh2YWx1ZSlcbiAgICAgICAgICAgICAgICA/IF8uZGVlcENsb25lKHZhbHVlKVxuICAgICAgICAgICAgICAgIDogdmFsdWU7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gcHJvdGVjdFZhbHVlKHZhbHVlKSB7XG4gICAgICAgIHJldHVybiAhIHZhbHVlSXNOb3JtYWxPYmplY3QodmFsdWUp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FuIEFycmF5KS5cbiAgICBpZiAocGF0dGVybiBpbnN0YW5jZW9mIEFycmF5KSB7XG4gICAgICAgIGlmIChwYXR0ZXJuLmxlbmd0aCAhPT0gMSlcbiAgICAgICAgICAgIHRocm93IEVycm9yKFwiQmFkIHBhdHRlcm46IGFycmF5cyBtdXN0IGhhdmUgb25lIHR5cGUgZWxlbWVudFwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEpTT04uc3RyaW5naWZ5KHBhdHRlcm4pKTtcbiAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlKSkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IE1hdGNoLkVycm9yKFwiRXhwZWN0ZWQgYXJyYXksIGdvdCBcIiArIEpTT04uc3RyaW5naWZ5KHZhbHVlKSk7XG4gICAgICAgIH1cblxuICAgICAgICB2YWx1ZS5mb3JFYWNoKGZ1bmN0aW9uICh2YWx1ZUVsZW1lbnQsIGluZGV4KSB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGNoZWNrU3VidHJlZSh2YWx1ZUVsZW1lbnQsIHBhdHRlcm5bMF0pO1xuICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgaWYgKGVyciBpbnN0YW5jZW9mIE1hdGNoLkVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgIGVyci5wYXRoID0gX3ByZXBlbmRQYXRoKGluZGV4LCBlcnIucGF0aCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHRocm93IGVycjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICAvLyBBcmJpdHJhcnkgdmFsaWRhdGlvbiBjaGVja3MuIFRoZSBjb25kaXRpb24gY2FuIHJldHVybiBmYWxzZSBvciB0aHJvdyBhXG4gICAgLy8gTWF0Y2guRXJyb3IgKGllLCBpdCBjYW4gaW50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c3RydWN0b3IubmFtZTtcbiAgICBpZiAoY2xhc3NOYW1lICE9IG9iai5jb25zdHJ1Y3Rvci5uYW1lKSByZXR1cm4gZmFsc2U7XG4gICAgc3dpdGNoIChjbGFzc05hbWUpIHtcbiAgICAgICAgY2FzZSAnU3RyaW5nJzpcbiAgICAgICAgICAgIHJldHVybiB0aGlzID09IFN0cmluZyhvYmopO1xuICAgICAgICBjYXNlICdOdW1iZXInOlxuICAgICAgICAgICAgcmV0dXJuIHRoaXMgIT0gK3RoaXMgPyBvYmogIT0gK29iaiA6ICh0aGlzID09IDAgPyAxL3RoaXMgPT0gMS9vYmogOiB0aGlzID09ICtvYmopO1xuICAgICAgICBjYXNlICdEYXRlJzpcbiAgICAgICAgY2FzZSAnQm9vbGVhbic6XG4gICAgICAgICAgICByZXR1cm4gK3RoaXMgPT0gK29iajtcbiAgICAgICAgY2FzZSAnUmVnRXhwJzpcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnNvdXJjZSA9PSBvYmouc291cmNlXG4gICAgICAgICAgICAgICAgICAgICYmIHRoaXMuZ2xvYmFsID09IG9iai5nbG9iYWxcbiAgICAgICAgICAgICAgICAgICAgJiYgdGhpcy5tdWx0aWxpbmUgPT0gb2JqLm11bHRpbGluZVxuICAgICAgICAgICAgICAgICAgICAmJiB0aGlzLmlnbm9yZUNhc2UgPT0gb2JqLmlnbm9yZUNhc2U7XG4gICAgfVxuICAgIGlmICh0eXBlb2YgdGhpcyAhPSAnb2JqZWN0JyB8fCB0eXBlb2Ygb2JqICE9ICdvYmplY3QnKSByZXR1cm4gZmFsc2U7XG5cbiAgICBpZiAoQXJyYXkuaXNBcnJheSh0aGlzKSlcbiAgICAgICAgcmV0dXJuIHRoaXMubGVuZ3RoID09IG9iai5sZW5ndGhcbiAgICAgICAgICAgICAgICAmJiB0aGlzLmV2ZXJ5KGZ1bmN0aW9uKGl0ZW0sIGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpc0VxdWFsLm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N0ID0gY2FsbGJhY2suY2FsbCh0aGlzLCB2YWx1ZSwgaW5kZXgsIHNlbGYpO1xuICAgICAgICAgICAgaWYgKHRlc3QpIHtcbiAgICAgICAgICAgICAgICBmb3VuZFZhbHVlT3JJbmRleCA9IGFyZ3VtZW50c1thcmdJbmRleF1cbiAgICAgICAgICAgICAgICByZXR1cm4gdGVzdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn1cbiJdfQ== +; \ No newline at end of file diff --git a/lib/components/c_facets/Css.js b/lib/components/c_facets/Css.js index 0dbcfe1..6333205 100644 --- a/lib/components/c_facets/Css.js +++ b/lib/components/c_facets/Css.js @@ -77,6 +77,8 @@ function CssFacet$set(data) { } function CssFacet$del() { + var self = this; + _.eachKey(this.activeModelPaths, function(modelPaths, cssClass) { modelPaths.clear();