From 28f05f314077cbfa290c6e8e37d55866cafe84b2 Mon Sep 17 00:00:00 2001 From: mistermboy Date: Fri, 27 Mar 2020 18:28:27 +0000 Subject: [PATCH 1/3] valueSet style --- dist/yashe.bundled.min.js | 66 +- dist/yashe.css | 4 + dist/yashe.min.css | 2 +- doc/examples/wiki.js | 4006 +++++++++++++++++++ doc/main.js | 5 + index.html | 2 +- lib/grammar/tokenizer.js | 3 + package-lock.json | 107 +- package.json | 3 + src/main.js | 56 + src/scss/cssIncludes/themes/_darkTheme.scss | 1 + src/scss/cssIncludes/themes/_wikitheme.scss | 1 + 12 files changed, 4232 insertions(+), 24 deletions(-) create mode 100644 doc/examples/wiki.js diff --git a/dist/yashe.bundled.min.js b/dist/yashe.bundled.min.js index 17b0369f..01e00694 100755 --- a/dist/yashe.bundled.min.js +++ b/dist/yashe.bundled.min.js @@ -1919,6 +1919,9 @@ CodeMirror.defineMode("shex", function(config, parserConfig) { } + if(topSymbol == 'valueSetValue'){ + tokenOb.style='valueSet'; + } if (topSymbol === 'var' && tokenOb.text) state.variables[tokenOb.text] = tokenOb.text; @@ -25030,7 +25033,7 @@ module.exports = { module.exports={ "name": "yashe", "description": "Yet Another ShEx Editor", - "version": "1.2.15", + "version": "1.2.16", "main": "src/main.js", "license": "MIT", "author": "Pablo Menéndez", @@ -25102,6 +25105,8 @@ module.exports={ }, "dependencies": { "axios": "^0.19.2", + "bloodhound-js": "^1.2.3", + "bootstrap": "^4.4.1", "codemirror": "5.17.0", "file-reader": "^1.1.1", "gulp-uglify": "^3.0.2", @@ -25109,6 +25114,7 @@ module.exports={ "jquery": "^2.2.4", "prettier": "^1.4.4", "read-file": "^0.2.0", + "typeahead.js-bootstrap4-css": "^1.0.0", "yasgui-utils": "^1.6.7" }, "optionalShim": { @@ -26340,6 +26346,62 @@ root.version = { 'yasgui-utils': yutils.version, }; + +/* + +var settings = { + "async": true, + "crossDomain": true, + "url": "https://www.mediawiki.org/w/api.php?action=query&meta=tokens&format=json", + "method": "GET", + "dataType": 'jsonp', +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); + + + + + +var Bloodhound = require('bloodhound-js'); + + // Defining the local dataset + var engine = new Bloodhound({ + local: ['dog', 'pig', 'moose'], + queryTokenizer: Bloodhound.tokenizers.whitespace, + datumTokenizer: Bloodhound.tokenizers.whitespace +}); + + + + +var typeahead = document.getElementsByClassName("typeahead")[0]; +typeahead.addEventListener("keyup",function(e){ + var aux = e.target.value + + var promise = engine.initialize(); + + promise.then(function() { + + engine.search( + aux, + function(d) { + console.log(d); + }, + function(d) { + console.log(d); + } + ); + +}); + + +}) +*/ + + },{"../lib/deparam.js":1,"../lib/grammar/tokenizer.js":3,"../package.json":33,"./autocompleters/autocompleterBase.js":34,"./autocompleters/prefixDefinition.js":35,"./autocompleters/prefixesAndKeywords.js":36,"./autocompleters/wikidata.js":37,"./config/defaults.js":39,"./utils/baseUtils.js":41,"./utils/buttonsUtils.js":42,"./utils/formatUtils.js":43,"./utils/prefixFold.js":45,"./utils/prefixUtils.js":46,"./utils/syntaxUtils.js":48,"./utils/tokenUtils.js":49,"./utils/tooltipUtils.js":50,"clipboard":5,"codemirror":15,"codemirror/addon/display/fullscreen.js":6,"codemirror/addon/edit/matchbrackets.js":7,"codemirror/addon/fold/brace-fold.js":8,"codemirror/addon/fold/foldcode.js":9,"codemirror/addon/fold/foldgutter.js":10,"codemirror/addon/fold/xml-fold.js":11,"codemirror/addon/hint/show-hint.js":12,"codemirror/addon/runmode/runmode.js":13,"codemirror/addon/search/searchcursor.js":14,"jquery":16,"yasgui-utils":30}],41:[function(require,module,exports){ "use strict"; var $ = require("jquery"); @@ -27511,4 +27573,4 @@ module.exports = { },{"./rdfUtils.js":47,"jquery":16}]},{},[38])(38) }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvZGVwYXJhbS5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FTlQgKyBcIikpKlwiO1xuICAvL3ZhciBOSUwgPSBcIlxcXFwoXCIgKyBXU19PUl9DT01NRU5UX1NUQVIgKyBcIlxcXFwpXCI7XG4gIC8vdmFyIEFOT04gPSBcIlxcXFxbXCIgKyBXU19PUl9DT01NRU5UX1NUQVIgKyBcIlxcXFxdXCI7XG4gIHZhciB0ZXJtaW5hbHMgPSBbXG4gICAge1xuICAgICAgbmFtZTogXCJXU1wiLFxuICAgICAgcmVnZXg6IG5ldyBSZWdFeHAoXCJeXCIgKyBXUyArIFwiK1wiKSxcbiAgICAgIHN0eWxlOiBcIndzXCJcbiAgICB9LFxuXG4gICAge1xuICAgICAgbmFtZTogXCJDT01NRU5UXCIsXG4gICAgICByZWdleDogbmV3IFJlZ0V4cChcIl5cIiArIENPTU1FTlQpLFxuICAgICAgc3R5bGU6IFwiY29tbWVudFwiXG4gICAgfSxcblxuXG4gICAge1xuICAgICAgbmFtZTogXCJJUklfUkVGXCIsXG4gICAgICByZWdleDogbmV3IFJlZ0V4cChcIl5cIiArIElSSV9SRUYpLFxuICAgICAgc3R5bGU6IFwidmFyaWFibGUtM1wiXG4gICAgfSxcblxuICBcbiAgICB7XG4gICAgICBuYW1lOiBcIkRPVUJMRVwiLFxuICAgICAgcmVnZXg6IG5ldyBSZWdFeHAoXCJeXCIgKyBET1VCTEUpLFxuICAgICAgc3R5bGU6IFwibnVtYmVyXCJcbiAgICB9LFxuXG4gICAge1xuICAgICAgbmFtZTogXCJERUNJTUFMXCIsXG4gICAgICByZWdleDogbmV3IFJlZ0V4cChcIl5cIiArIERFQ0lNQUwpLFxuICAgICAgc3R5bGU6IFwibnVtYmVyXCJcbiAgICB9LFxuXG4gICAge1xuICAgICAgbmFtZTogXCJJTlRFR0VSXCIsXG4gICAgICByZWdleDogbmV3IFJlZ0V4cChcIl5cIiArIElOVEVHRVIpLFxuICAgICAgc3R5bGU6IFwibnVtYmVyXCJcbiAgICB9LFxuXG4gICAge1xuICAgICAgbmFtZTogXCJ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nN1bWVkKSB7XG4gICBcblxuICAgICAgICAgIGxldCBsYXN0UG9zID0gJC50cmltKHN0cmVhbS5zdHJpbmcpLmxlbmd0aC0xO1xuICAgICAgICAgIGxldCBsYXN0VG9rZW4gPSAkLnRyaW0oc3RyZWFtLnN0cmluZylbbGFzdFBvc107XG4gICAgICAgICAgbGV0IHRva2VuID0gc3RyZWFtLmN1cnJlbnQoKTtcbiAgICAgICAgICBcbiAgICAgICAgICAvL0lzIGEgc2hhcGVFeHByTGFiZWw/XG4gICAgICAgICAgLypcbiAgICAgICAgICBpZihsYXN0VG9rZW4gPT0gJ3snICAmJiAodG9rZW4uaW5jbHVkZXMoJzonKSB8fCB0b2tlbi5pbmNsdWRlcygnPCcpICkpe1xuICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgIGNhdDogdGVybWluYWxzW2ldLm5hbWUsXG4gICAgICAgICAgICAgIHN0eWxlOiAnc2hhcGUnLFxuICAgICAgICAgICAgICB0ZXh0OiBjb25zdW1lZFswXSxcbiAgICAgICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICAgICAgIH07XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgKi9cbiAgICAgICAgICBcblxuICAgICAgXG5cbiAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgY2F0OiB0ZXJtaW5hbHNbaV0ubmFtZSxcbiAgICAgICAgICAgIHN0eWxlOiB0ZXJtaW5hbHNbaV0uc3R5bGUsXG4gICAgICAgICAgICB0ZXh0OiBjb25zdW1lZFswXSxcbiAgICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgICB9O1xuXG4gICAgICAgIH1cbiAgICAgICAgXG4gICAgICBcbiAgICAgICAgXG4gICAgICB9XG5cbiAgXG4gICAgICAvLyBLZXl3b3Jkc1xuICAgICAgY29uc3VtZWQgPSBzdHJlYW0ubWF0Y2goZ3JhbW1hci5rZXl3b3JkcywgdHJ1ZSwgZmFsc2UpO1xuICAgICAgaWYgKGNvbnN1bWVkKXtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICBjYXQ6IHN0cmVhbS5jdXJyZW50KCkudG9VcHBlckNhc2UoKSxcbiAgICAgICAgICBzdHlsZTogXCJrZXl3b3JkXCIsXG4gICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICB9O1xuICAgICAgfVxuXG4gICAgICAvLyBQdW5jdHVhdGlvblxuICAgICAgY29uc3VtZWQgPSBzdHJlYW0ubWF0Y2goZ3JhbW1hci5wdW5jdCwgdHJ1ZSwgZmFsc2UpO1xuICAgICAgaWYgKGNvbnN1bWVkKXtcbiAgICAgICAgaWYoc3RyZWFtLmN1cnJlbnQoKSE9JyonIFxuICAgICAgICAgICYmIHN0cmVhbS5jdXJyZW50KCkhPScrJ1xuICAgICAgICAgICAmJiBzdHJlYW0uY3VycmVudCgpIT0nPycpe1xuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNhdDogc3RyZWFtLmN1cnJlbnQoKSxcbiAgICAgICAgICAgIHN0eWxlOiBcInB1bmNcIixcbiAgICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxuICAgICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgIGNhdDogc3RyZWFtLmN1cnJlbnQoKSxcbiAgICAgICAgICBzdHlsZTogXCJjYXJkXCIsXG4gICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICB9O1xuXG4gICAgICAgXG4gICAgICB9XG5cblxuXG4gICAgICAvLyBUb2tlbiBpcyBpbnZhbGlkXG4gICAgICAvLyBiZXR0ZXIgY29uc3VtZSBzb21ldGhpbmcgYW55d2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VuT2IudGV4dC5pbmRleE9mKFwiOlwiKTtcbiAgICAgICAgICAgICAgaWYgKGNvbG9uSW5kZXggPj0gMCkge1xuICAgICAgICAgICAgICAgIHZhciBwcmVmTnMgPSB0b2tlbk9iLnRleHQuc2xpY2UoMCwgY29sb25JbmRleCk7XG4gICAgICAgICAgICAgICAgLy9hdm9pZCB3YXJuaW5ncyBmb3IgbWlzc2luZyBiaWYgcHJlZml4ZXMgKHl1Y2ssIHZpcnR1b3NvLXNwZWNpZmljKVxuICAgICAgICAgICAgICAgIGlmICghc3RhdGUucHJlZml4ZXNbcHJlZk5zXSAmJiBbXCJiaWZcIiwgXCJ4c2RcIiwgXCJzcWxcIl0uaW5kZXhPZihwcmVmTnMpIDwgMCkge1xuICAgICAgICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgIHJlY29yZEZhaWx1cmVQb3MoKTtcbiAgICAgICAgICAgICAgICAgIHN0YXRlLmVycm9yTXNnID0gXCJQcmVmaXggJ1wiICsgcHJlZk5zICsgXCInIGlzIG5vdCBkZWZpbmVkXCI7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHN0YXRlLk9LID0gZmFsc2U7XG4gICAgICAgICAgICBzdGF0ZS5jb21wbGV0ZSA9IGZhbHNlO1xuICAgICAgICAgICAgcmVjb3JkRmFpbHVyZVBvcygpO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAvLyB0b3BTeW1ib2wgaXMgbm9udGVybWluYWxcbiAgICAgICAgICAvLyAtIHNlZSBpZiB0aGVyZSBpcyBhbiBlbnRyeSBmb3IgdG9wU3ltYm9sXG4gICAgICAgICAgLy8gYW5kIG5leHRUb2tlbiBpbiB0YWJsZVxuICAgICAgICAgIFxuICAgICAgICAgIHZhciBuZXh0U3ltYm9scyA9IGxsMV90Y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ID09IGNsb3NlQnJhY2tldCkge1xuICAgICAgICAgICAgLS1pO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICAvLyBDb25zaWRlciBudWxsYWJsZSBub24tdGVybWluYWxzIGlmIGF0IHRvcCBvZiBzdGFja1xuICAgICAgICB2YXIgZG4gPSBpbmRlbnRUb3Bbc3RhdGUuc3RhY2tbaV1dO1xuICAgICAgICBpZiAoZG4pIHtcbiAgICAgICAgICBuICs9IGRuO1xuICAgICAgICAgIC0taTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgZm9yICg7IGkgPj0gMDsgLS1pKSB7XG4gICAgICAgIHZhciBkbiA9IGluZGVudFRhYmxlW3N0YXRlLnN0YWNrW2ldXTtcbiAgICAgICAgaWYgKGRuKSB7XG4gICAgICAgICAgbiArPSBkbjtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgcmV0dXJuIG4gKiBjb25maWcuaW5kZW50VW5pdDtcbiAgICB9XG4gIH1cblxuXG4gIHJldHVybiB7XG4gICAgdG9rZW46IHRva2VuQmFzZSxcbiAgICBzdGFydFN0YXRlOiBmdW5jdGlvbihiYXNlKSB7XG4gICAgICByZXR1cm4ge1xuICAgICAgICB0b2tlbml6ZTogdG9rZW5CYXNlLFxuICAgICAgICBPSzogdHJ1ZSxcbiAgICAgICAgY29tcGxldGU6IGdyYW1tYXIuYWNjZXB0RW1wdHksXG4gICAgICAgIGVycm9yU3RhcnRQb3M6IG51bGwsXG4gICAgICAgIGVycm9yRW5kUG9zOiBudWxsLFxuICAgICAgICBxdWVyeVR5cGU6IG51bGwsXG4gICAgICAgIHBvc3NpYmxlQ3VycmVudDogZ2V0UG9zc2libGVzKGdyYW1tYXIuc3RhcnRTeW1ib2wpLFxuICAgICAgICBwb3NzaWJsZU5leHQ6IGdldFBvc3NpYmxlcyhncmFtbWFyLnN0YXJ0U3ltYm9sKSxcbiAgICAgICAgYW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vbnRhaW5lcikgPT09ICdvYmplY3QnID8gb3B0aW9ucy5jb250YWluZXIgOiBkb2N1bWVudC5ib2R5O1xuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEFkZHMgYSBjbGljayBldmVudCBsaXN0ZW5lciB0byB0aGUgcGFzc2VkIHRyaWdnZXIuXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfEhUTUxFbGVtZW50fEhUTUxDb2xsZWN0aW9ufE5vZGVMaXN0fSB0cmlnZ2VyXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdsaXN0ZW5DbGljaycsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBsaXN0ZW5DbGljayh0cmlnZ2VyKSB7XG4gICAgICAgICAgICB2YXIgX3RoaXMyID0gdGhpcztcblxuICAgICAgICAgICAgdGhpcy5saXN0ZW5lciA9ICgwLCBfZ29vZExpc3RlbmVyMi5kZWZhdWx0KSh0cmlnZ2VyLCAnY2xpY2snLCBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBfdGhpczIub25DbGljayhlKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIERlZmluZXMgYSBuZXcgYENsaXBib2FyZEFjdGlvbmAgb24gZWFjaCBjbGljayBldmVudC5cbiAgICAgICAgICogQHBhcmFtIHtFdmVudH0gZVxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnb25DbGljaycsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBvbkNsaWNrKGUpIHtcbiAgICAgICAgICAgIHZhciB0cmlnZ2VyID0gZS5kZWxlZ2F0ZVRhcmdldCB8fCBlLmN1cnJlbnRUYXJnZXQ7XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmNsaXBib2FyZEFjdGlvbikge1xuICAgICAgICAgICAgICAgIHRoaXMuY2xpcGJvYXJkQWN0aW9uID0gbnVsbDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24gPSBuZXcgX2NsaXBib2FyZEFjdGlvbjIuZGVmYXVsdCh7XG4gICAgICAgICAgICAgICAgYWN0aW9uOiB0aGlzLmFjdGlvbih0cmlnZ2VyKSxcbiAgICAgICAgICAgICAgICB0YXJnZXQ6IHRoaXMudGFyZ2V0KHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIHRleHQ6IHRoaXMudGV4dCh0cmlnZ2VyKSxcbiAgICAgICAgICAgICAgICBjb250YWluZXI6IHRoaXMuY29udGFpbmVyLFxuICAgICAgICAgICAgICAgIHRyaWdnZXI6IHRyaWdnZXIsXG4gICAgICAgICAgICAgICAgZW1pdHRlcjogdGhpc1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVmYXVsdCBgYWN0aW9uYCBsb29rdXAgZnVuY3Rpb24uXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gdHJpZ2dlclxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnZGVmYXVsdEFjdGlvbicsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkZWZhdWx0QWN0aW9uKHRyaWdnZXIpIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRBdHRyaWJ1dGVWYWx1ZSgnYWN0aW9uJywgdHJpZ2dlcik7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVmYXVsdCBgdGFyZ2V0YCBsb29rdXAgZnVuY3Rpb24uXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gdHJpZ2dlclxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnZGVmYXVsdFRhcmdldCcsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkZWZhdWx0VGFyZ2V0KHRyaWdnZ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AgfSwge1xuICAgICAgICBrZXk6ICdjbGVhclNlbGVjdGlvbicsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBjbGVhclNlbGVjdGlvbigpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRyaWdnZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnRyaWdnZXIuZm9jdXMoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgd2luZG93LmdldFNlbGVjdGlvbigpLnJlbW92ZUFsbFJhbmdlcygpO1xuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFNldHMgdGhlIGBhY3Rpb25gIHRvIGJlIHBlcmZvcm1lZCB3aGljaCBjYW4gYmUgZWl0aGVyICdjb3B5JyBvciAnY3V0Jy5cbiAgICAgICAgICogQHBhcmFtIHtTdHJpbmd9IGFjdGlvblxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnZGVzdHJveScsXG5cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVzdHJveSBsaWZlY3ljbGUuXG4gICAgICAgICAqL1xuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVzdHJveSgpIHtcbiAgICAgICAgICAgIHRoaXMucmVtb3ZlRmFrZSgpO1xuICAgICAgICB9XG4gICAgfSwge1xuICAgICAgICBrZXk6ICdhY3Rpb24nLFxuICAgICAgICBzZXQ6IGZ1bmN0aW9uIHNldCgpIHtcbiAgICAgICAgICAgIHZhciBhY3Rpb24gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6ICdjb3B5JztcblxuICAgICAgICAgICAgdGhpcy5fYWN0aW9uID0gYWN0aW9uO1xuXG4gICAgICAgICAgICBpZiAodGhpcy5fYWN0aW9uICE9PSAnY29weScgJiYgdGhpcy5fYWN0aW9uICE9PSAnY3V0Jykge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCBcImFjdGlvblwiIHZhbHVlLCB1c2UgZWl0aGVyIFwiY29weVwiIG9yIFwiY3V0XCInKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBHZXRzIHRoZSBgYWN0aW9uYCBwcm9wZXJ0eS5cbiAgICAgICAgICogQHJldHVybiB7U3RyaW5nfVxuICAgICAgICAgKi9cbiAgICAgICAgLFxuICAgICAgICBnZXQ6IGZ1bmN0aW9uIGdldCgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9hY3Rpb247XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogU2V0cyB0aGUgYHRhcmdldGAgcHJvcGVydHkgdXNpbmcgYW4gZWxlbWVudFxuICAgICAgICAgKiB0aGF0IHdpbGwgYmUgaGF2ZSBpdHMgY29udGVudCBjb3BpZWQuXG4gICAgICAgICAqIEBwYXJhbSB7RWxlbWVudH0gdGFyZ2V0XG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICd0YXJnZXQnLFxuICAgICAgICBzZXQ6IGZ1bmN0aW9uIHNldCh0YXJnZXQpIHtcbiAgICAgICAgICAgIGlmICh0YXJnZXQgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGlmICh0YXJnZXQgJiYgKHR5cGVvZiB0YXJnZXQgPT09ICd1bmRlZmluZWQnID8gJ3VuZGVmaW5lZCcgOiBfdHlwZW9mKHRhcmdldCkpID09PSAnb2JqZWN0JyAmJiB0YXJnZXQubm9kZVR5cGUgPT09IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYWN0aW9uID09PSAnY29weScgJiYgdGFyZ2V0Lmhhc0F0dHJpYnV0ZSgnZGlzYWJsZWQnKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIFwidGFyZ2V0XCIgYXR0cmlidXRlLiBQbGVhc2UgdXNlIFwicmVhZG9ubHlcIiBpbnN0ZWFkIG9mIFwiZGlzYWJsZWRcIiBhdHRyaWJ1dGUnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmFjdGlvbiA9PT0gJ2N1dCcgJiYgKHRhcmdldC5oYXNBdHRyaWJ1dGUoJ3JlYWRvbmx5JykgfHwgdGFyZ2V0Lmhhc0F0dHJpYnV0ZSgnZGlzYWJsZWQnKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCBcInRhcmdldFwiIGF0dHJpYnV0ZS4gWW91IGNhblxcJ3QgY3V0IHRleHQgZnJvbSBlbGVtZW50cyB3aXRoIFwicmVhZG9ubHlcIiBvciBcImRpc2FibGVkXCIgYXR0cmlidXRlcycpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGFyZ2V0ID0gdGFyZ2V0O1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCBcInRhcmdldFwiIHZhbHVlLCB1c2UgYSB2YWxpZCBFbGVtZW50Jyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEdldHMgdGhlIGB0YXJnZXRgIHByb3BlcnR5LlxuICAgICAgICAgKiBAcmV0dXJuIHtTdHJpbmd8SFRNTEVsZW1lbnR9XG4gICAgICAgICAqL1xuICAgICAgICAsXG4gICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RhcmdldDtcbiAgICAgICAgfVxuICAgIH1dKTtcblxuICAgIHJldHVybiBDbGlwYm9hcmRBY3Rpb247XG59KCk7XG5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IG5ld0hlYWQpO1xuICAgICAgfVxuICAgIH1cbiAgICByZXR1cm4gb3V0ID8gbm9ybWFsaXplU2VsZWN0aW9uKG91dCwgc2VsLnByaW1JbmRleCkgOiBzZWw7XG4gIH1cblxuICBmdW5jdGlvbiBza2lwQXRvbWljSW5uZXIoZG9jLCBwb3MsIG9sZFBvcywgZGlyLCBtYXlDbGVhcikge1xuICAgIHZhciBsaW5lID0gZ2V0TGluZShkb2MsIHBvcy5saW5lKTtcbiAgICBpZiAobGluZS5tYXJrZWRTcGFucykgZm9yICh2YXIgaSA9IDA7IGkgPCBsaW5lLm1hcmtlZFNwYW5zLmxlbmd0aDsgKytpKSB7XG4gICAgICB2YXIgc3AgPSBsaW5lLm1hcmtlZFNwYW5zW2ldLCBtID0gc3AubWFya2VyO1xuICAgICAgaWYgKChzcC5mcm9tID09IG51bGwgfHwgKG0uaW5jbHVzaXZlTGVmdCA/IHNwLmZyb20gPD0gcG9zLmNoIDogc3AuZnJvbSA8IHBvcy5jaCkpICYmXG4gICAgICAgICAgKHNwLnRvID09IG51bGwgfHwgKG0uaW5jbHVzaXZlUmlnaHQgPyBzcC50byA+PSBwb3MuY2ggOiBzcC50byA+IHBvcy5jaCkpKSB7XG4gICAgICAgIGlmIChtYXlDbGVhcikge1xuICAgICAgICAgIHNpZ25hbChtLCBcImJlZm9yZUN1cnNvckVudGVyXCIpO1xuICAgICAgICAgIGlmIChtLmV4cGxpY2l0bHlDbGVhcmVkKSB7XG4gICAgICAgICAgICBpZiAoIWxpbmUubWFya2VkU3BhbnMpIGJyZWFrO1xuICAgICAgICAgICAgZWxzZSB7LS1pOyBjb250aW51ZTt9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICghbS5hdG9taWMpIGNvbnRpbnVlO1xuXG4gICAgICAgIGlmIChvbGRQb3MpIHtcbiAgICAgICAgICB2YXIgbmVhciA9IG0uZmluZChkaXIgPCAwID8gMSA6IC0xKSwgZGlmZjtcbiAgICAgICAgICBp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zICYmIGZpbGVzLmxlbmd0aCAmJiB3aW5kb3cuRmlsZVJlYWRlciAmJiB3aW5kb3cuRmlsZSkge1xuICAgICAgdmFyIG4gPSBmaWxlcy5sZW5ndGgsIHRleHQgPSBBcnJheShuKSwgcmVhZCA9IDA7XG4gICAgICB2YXIgbG9hZEZpbGUgPSBmdW5jdGlvbihmaWxlLCBpKSB7XG4gICAgICAgIGlmIChjbS5vcHRpb25zLmFsbG93RHJvcEZpbGVUeXBlcyAmJlxuICAgICAgICAgICAgaW5kZXhPZihjbS5vcHRpb25zLmFsbG93RHJvcEZpbGVUeXBlcywgZmlsZS50eXBlKSA9PSAtMSlcbiAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgdmFyIHJlYWRlciA9IG5ldyBGaWxlUmVhZGVyO1xuICAgICAgICByZWFkZXIub25sb2FkID0gb3BlcmF0aW9uKGNtLCBmdW5jdGlvbigpIHtcbiAgICAgICAgICB2YXIgY29udGVudCA9IHJlYWRlci5yZXN1bHQ7XG4gICAgICAgICAgaWYgKC9bXFx4MDAtXFx4MDhcXHgwZS1cXHgxZl17Mn0vLnRlc3QoY29udGVudCkpIGNvbnRlbnQgPSBcIlwiO1xuICAgICAgICAgIHRleHRbaV0gPSBjb250ZW50O1xuICAgICAgICAgIGlmICgrK3JlYWQgPT0gbikge1xuICAgICAgICAgICAgcG9zID0gY2xpcFBvcyhjbS5kb2MsIHBvcyk7XG4gICAgICAgICAgICB2YXIgY2hhbmdlID0ge2Zyb206IHBvcywgdG86IHBvcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dDogY20uZG9jLnNwbGl0TGluZXModGV4dC5qb2luKGNtLmRvYy5saW5lU2VwYXJhdG9yKCkpKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgb3JpZ2luOiBcInBhc3RlXCJ9O1xuICAgICAgICAgICAgbWFrZUNoYW5nZShjbS5kb2MsIGNoYW5nZSk7XG4gICAgICAgICAgICBzZXRTZWxlY3Rpb25SZXBsY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gaWYgKHByZXYpXG4gICAgICAgICAgICAgICAgY20ucmVwbGFjZVJhbmdlKGxpbmUuY2hhckF0KDApICsgY20uZG9jLmxpbmVTZXBhcmF0b3IoKSArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYuY2hhckF0KHByZXYubGVuZ3RoIC0gMSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvcyhjdXIubGluZSAtIDEsIHByZXYubGVuZ3RoIC0gMSksIFBvcyhjdXIubGluZSwgMSksIFwiK3RyYW5zcG9zZVwiKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgbmV3U2VsLnB1c2gobmV3IFJhbmdlKGN1ciwgY3VyKSk7XG4gICAgICAgIH1cbiAgICAgICAgY20uc2V0U2VsZWN0aW9ucyhuZXdTZWwpO1xuICAgICAgfSk7XG4gICAgfSxcbiAgICBuZXdsaW5lQW5kSW5kZW50OiBmdW5jdGlvbihjbSkge1xuICAgICAgcnVuSW5PcChjbSwgZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciBsZW4gPSBjbS5saXN0U2VsZWN0aW9ucygpLmxlbmd0aDtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBsZW47IGkrKykge1xuICAgICAgICAgIHZhciByYW5nZSA9IGNtLmxpc3RTZWxlY3Rpb25zKClbaV07XG4gICAgICAgICAgY20ucmVwbGFjZVJhbmdlKGNtLmRvYy5saW5lU2VwYXJhdG9yKCksIHJhbmdlLmFuY2hvciwgcmFuZ2UuaGVhZCwgXCIraW5wdXRcIik7XG4gICAgICAgICAgY20uaW5kZW50TGluZShyYW5nZS5mcm9tKCkubGluZSArIDEsIG51bGwsIHRydWUpO1xuICAgICAgICB9XG4gICAgICAgIGVuc3VyZUN1cnNvclZpc2libGUoY20pO1xuICAgICAgfSk7XG4gICAgfSxcbiAgICBvcGVuTGluZTogZnVuY3Rpb24oY20pIHtjbS5yZXBsYWNlU2VsZWN0aW9uK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G4gICAgICAgICAgICAgIGNvbGxhcHNlZCA9IHNwO1xuICAgICAgICAgIH0gZWxzZSBpZiAoc3AuZnJvbSA+IHBvcyAmJiBuZXh0Q2hhbmdlID4gc3AuZnJvbSkge1xuICAgICAgICAgICAgbmV4dENoYW5nZSA9IHNwLmZyb207XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChlbmRTdHlsZXMpIGZvciAodmFyIGogPSAwOyBqIDwgZW5kU3R5bGVzLmxlbmd0aDsgaiArPSAyKVxuICAgICAgICAgIGlmIChlbmRTdHlsZXNbaiArIDFdID09IG5leHRDaGFuZ2UpIHNwYW5FbmRTdHlsZSArPSBcIiBcIiArIGVuZFN0eWxlc1tqXVxuXG4gICAgICAgIGlmICghY29sbGFwc2VkIHx8IGNvbGxhcHNlZC5mcm9tID09IHBvcykgZm9yICh2YXIgaiA9IDA7IGogPCBmb3VuZEJvb2ttYXJrcy5sZW5ndGg7ICsrailcbiAgICAgICAgICBidWlsZENvbGxhcHNlZFNwYW4oYnVpbGRlciwgMCwgZm91bmRCb29rbWFya3Nbal0pO1xuICAgICAgICBpZiAoY29sbGFwc2VkICYmIChjb2xsYXBzZWQuZnJvbSB8fCAwKSA9PSBwb3MpIHtcbiAgICAgICAgICBidWlsZENvbGxhcHNlZFNwYW4oYnVpbGRlciwgKGNvbGxhcHNlZC50byA9PSBudWxsID8gbGVuICsgMSA6IGNvbGxhcHNlZC50bykgLSBwb3MsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbGxhcHNlZC5tYXJrZXIsIGNvbGxhcHNlZC5mcm9tID09IG51bGwpO1xuICAgICAgICAgIGlmIChjb2xsYXBzZWQudG8gPT0gbnVsbCkgcmV0dXJuO1xuICAgICAgICAgIGlmIChjb2xsYXBzZWQudG8gPT0gcG9zKSBjb2xsYXBzZWQgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgICAgaWYgKHBvcyA+PSBsZW4pIGJyZWFrO1xuXG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ExMTExMTExMTExMTExMTE5OTk5OTkxMTExMTExMTExMTExMTExMTExMTExMTExMTk5OTmJiYmJiYnNiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYixOJSUlJU5OTk5MTk5OTk4lJTExTkxOTk4xTE5OTk5OTExMTExMTExMTExMTExMTExMTExMTExOTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTE5cIjtcbiAgICAvLyBDaGFyYWN0ZXIgdHlwZXMgZm9yIGNvZGVwb2ludHMgMHg2MDAgdG8gMHg2ZmZcbiAgICB2YXIgYXJhYmljVHlwZXMgPSBcInJycnJycnJycnJycixyTk5tbW1tbW1ycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycm1tbW1tbW1tbW1tbW1tcnJycnJycm5ubm5ubm5ubm4lbm5ycnJtcnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJtbW1tbW1tbW1tbW1tbW1tbW1tTm1tbW1cIjtcbiAgICBmdW5jdGlvbiBjaGFyVHlwZShjb2RlKSB7XG4gICAgICBpZiAoY29kZSA8PSAweGY3KSByZXR1cm4gbG93VHlwZXMuY2hhckF0KGNvZGUpO1xuICAgICAgZWxzZSBpZiAoMHg1OTAgPD0gY29kZSAmJiBjb2RlIDw9IDB4NWY0KSByZXR1cm4gXCJSXCI7XG4gICAgICBlbHNlIGlmICgweDYwMCA8PSBjb2RlICYmIGNvZGUgPD0gMHg2ZWQpIHJldHVybiBhcmFiaWNUeXBlcy5jaGFyQXQoY29kZSAtIDB4NjAwKTtcbiAgICAgIGVsc2UgaWYgKDB4NmVlIDw9IGNvZGUgJiYgY29kZSA8PSAweDhhYykgcmV0dXJuIFwiclwiO1xuICAgICAgZWxzZSBpZiAoMHgyMDAwIDw9IGNvZGUgJiYgY29kZSA8PSAweDIwMGIpIHJldHVybiBcIndcIjtcbi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BIHRvSlNPTiBtZXRob2QgZG9lcyBub3Qgc2VyaWFsaXplOiBpdCByZXR1cm5zIHRoZVxuLy8gICAgICAgICAgdmFsdWUgcmVwcmVzZW50ZWQgYnkgdGhlIG5hbWUvdmFsdWUgcGFpciB0aGF0IHNob3VsZCBiZSBzZXJpYWxpemVkLFxuLy8gICAgICAgICAgb3IgdW5kZWZpbmVkIGlmIG5vdGhpbmcgc2hvdWxkIGJlIHNlcmlhbGl6ZWQuIFRoZSB0b0pTT04gbWV0aG9kXG4vLyAgICAgICAgICB3aWxsIGJlIHBhc3NlZCB0aGUga2V5IGFzc29jaWF0ZWQgd2l0aCB0aGUgdmFsdWUsIGFuZCB0aGlzIHdpbGwgYmVcbi8vICAgICAgICAgIGJvdW5kIHRvIHRoZSB2YWx1ZS5cblxuLy8gICAgICAgICAgRm9yIGV4YW1wbGUsIHRoaXMgd291bGQgc2VyaWFsaXplIERhdGVzIGFzIElTTyBzdHJpbmdzLlxuXG4vLyAgICAgICAgICAgICAgRGF0ZS5wcm90b3R5cGUudG9KU09OID0gZnVuY3Rpb24gKGtleSkge1xuLy8gICAgICAgICAgICAgICAgICBmdW5jdGlvbiBmKG4pIHtcbi8vICAgICAgICAgICAgICAgICAgICAgIC8vIEZvcm1hdCBpbnRlZ2VycyB0byBoYXZlIGF0IGxlYXN0IHR3byBkaWdpdHMuXG4vLyAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKG4gPCAxMClcbi8vICAgICAgICAgICAgICAgICAgICAgICAgICA/IFwiMFwiICsgblxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgIDogbjtcbi8vICAgICAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRVVENGdWxsWWVhcigpICAgKyBcIi1cIiArXG4vLyAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ01vbnRoKCkgKyAxKSArIFwiLVwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHR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XSxcbi8vICAgICAgICAgICAgICAgICAgICAgICAgICArYVs1XSwgK2FbNl0pKTtcbi8vICAgICAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgIH1cbi8vICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4vLyAgICAgICAgICB9KTtcblxuLy8gICAgICAgICAgbXlEYXRhID0gSlNPTi5wYXJzZSgnW1wiRGF0ZSgwOS8wOS8yMDAxKVwiXScsIGZ1bmN0aW9uIChrZXksIHZhbHVlKSB7XG4vLyAgICAgICAgICAgICAgdmFyIGQ7XG4vLyAgICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSA9PT0gXCJzdHJpbmdcIiAmJlxuLy8gICAgICAgICAgICAgICAgICAgICAgdmFsdWUuc2xpY2UoMCwgNSkgPT09IFwiRGF0ZShcIiAmJlxuLy8gICAgICAgICAgICAgICAgICAgICAgdmFsdWUuc2xpY2UoLTEpID09PSBcIilcIikge1xuLy8gICAgICAgICAgICAgICAgICBkID0gbmV3IERhdGUodmFsdWUuc2xpY2UoNSwgLTEpKTtcbi8vICAgICAgICAgICAgICAgICAgaWYgKGQpIHtcbi8vICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbi8vICAgICAgICAgIH0pO1xuXG4vLyAgVGhpcyBpcyBhIHJlZmVyZW5jZSBpbXBsZW1lbnRhdGlvbi4gWW91IGFyZSBmcmVlIHRvIGNvcHksIG1vZGlmeSwgb3Jcbi8vICByZWRpc3RyaWJ1dGUuXG5cbi8qanNsaW50XG4gICAgZXZhbCwgZm9yLCB0aGlzXG4qL1xuXG4vKnByb3BlcnR5XG4gICAgSlNPTiwgYXBwbHksIGNhbGwsIGNoYXJDb2RlQXQsIGdldFVUQ0RhdGUsIGdldFVUQ0Z1bGxZZWFyLCBnZXRVVENIb3VycyxcbiAgICBnZ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3JhcCB0aGVtIGluXG4vLyBicmFja2V0cy5cblxuICAgICAgICAgICAgICAgIHYgPSBwYXJ0aWFsLmxlbmd0aCA9PT0gMFxuICAgICAgICAgICAgICAgICAgICA/IFwiW11cIlxuICAgICAgICAgICAgICAgICAgICA6IGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgPyBcIltcXG5cIiArIGdhcCArIHBhcnRpYWwuam9pbihcIixcXG5cIiArIGdhcCkgKyBcIlxcblwiICsgbWluZCArIFwiXVwiXG4gICAgICAgICAgICAgICAgICAgICAgICA6IFwiW1wiICsgcGFydGlhbC5qb2luKFwiLFwiKSArIFwiXVwiO1xuICAgICAgICAgICAgICAgIGdhcCA9IG1pbmQ7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgICAgICB9XG5cbi8vIElmIHRoZSByZXBsYWNlciBpcyBhbiBhcnJheSwgdXNlIGl0IHRvIHNlbGVjdCB0aGUgbWVtYmVycyB0byBiZSBzdHJpbmdpZmllZC5cblxuICAgICAgICAgICAgaWYgKHJlcCAmJiB0eXBlb2YgcmVwID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgbGVuZ3RoID0gcmVwLmxlbmd0aDtcbiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXBbaV0gPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGsgPSByZXBbaV07XG4gICAgICAgICAgICAgICAgICAgICAgICB2ID0gc3RyKGssIHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydGlhbC5wdXNoKHF1b3RlKGspICsgKFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnYXBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gXCI6IFwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IFwiOlwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKSArIHYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcblxuLy8gT3RoZXJ3aXNlLCBpdGVyYXRlIHRocm91Z2ggYWxsIG9mIHRoZSBrZXlzIGluIHRoZSBvYmplY3QuXG5cbiAgICAgICAgICAgICAgICBmb3IgKGsgaW4gdmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbCh2YWx1ZSwgaykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBzdHIoaywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsLnB1c2gocXVvdGUoaykgKyAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBcIjogXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogXCI6XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApICsgdik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbi8vIEpvaW4gYWxsIG9mIHRoZSBtZW1iZXIgdGV4dHMgdG9nZXRoZXIsIHNlcGFyYXRlZCB3aXRoIGNvbW1hcyxcbi8vIGFuZCB3cmFwIHRoZW0gaW4gYnJhY2VzLlxuXG4gICAgICAgICAgICB2ID0gcGFydGlhbC5sZW5ndGggPT09IDBcbiAgICAgICAgICAgICAgICA/IFw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pcyBhIHZhbGlkIEpTT04gdGV4dC5cblxuICAgICAgICAgICAgdmFyIGo7XG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHdhbGsoaG9sZGVyLCBrZXkpIHtcblxuLy8gVGhlIHdhbGsgbWV0aG9kIGlzIHVzZWQgdG8gcmVjdXJzaXZlbHkgd2FsayB0aGUgcmVzdWx0aW5nIHN0cnVjdHVyZSBzb1xuLy8gdGhhdCBtb2RpZmljYXRpb25zIGNhbiBiZSBtYWRlLlxuXG4gICAgICAgICAgICAgICAgdmFyIGs7XG4gICAgICAgICAgICAgICAgdmFyIHY7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gaG9sZGVyW2tleV07XG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlICYmIHR5cGVvZiB2YWx1ZSA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGsgaW4gdmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwodmFsdWUsIGspKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdiA9IHdhbGsodmFsdWUsIGspO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVba10gPSB2O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB2YWx1ZVtrXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJldml2ZXIuY2FsbChob2xkZXIsIGtleSwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuX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uIFxuICAgIH1cblxuICAgIHZhciBjdXIgPSB5YXNoZS5nZXRDdXJzb3IoKTtcbiAgICB2YXIgcmV0dXJuT2JqID0ge1xuICAgICAgY29tcGxldGlvblRva2VuOiB0b2tlbi5zdHJpbmcsXG4gICAgICBsaXN0OiBoaW50TGlzdCxcbiAgICAgIGZyb206IHtcbiAgICAgICAgbGluZTogY3VyLmxpbmUsXG4gICAgICAgIGNoOiBzdGFydENoYXJcbiAgICAgIH0sXG4gICAgICB0bzoge1xuICAgICAgICBsaW5lOiBjdXIubGluZSxcbiAgICAgICAgY2g6IHRva2VuLmVuZFxuICAgICAgfVxuICAgIH07XG5cbiAgICAvL2lmIHdlIGhhdmUgc29tZSBhdXRvY29tcGxldGlvbiBoYW5kbGVycyBzcGVjaWZpZWQsIGFkZCB0aGVzZSB0aGVzZSB0byB0aGUgb2JqZWN0LiBDb2RlbWlycm9yIHdpbGwgdGFrZSBjYXJlIG9mIGZpcmluZyB0aGVzZVxuICAgIGlmIChjb21wbGV0ZXIuY2FsbGJhY2tzKSB7XG4gICAgICBmb3IgKHZhciBjYWxsYmFja05hbWUgaW4gY29tcGxldGVyLmNhbGxiYWNrcykge1xuICAgICAgICBpZiAoY29tcGxldGVyLmNhbGxiYWNrc1tjYWxsYmFja05hbWVdKSB7XG4gICAgICAgICAgWUFTSEUub24ocmV0dXJuT2JqLCBjYWxsYmFja05hbWUsIGNvbXBsZXRlci5jYWxsYmFja3NbY2FsbGJhY2tOYW1lXSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHJldHVybk9iajtcbiAgfTtcblxuICByZXR1cm4ge1xuICAgIGluaXQ6IGluaXRDb21wbGV0ZXIsXG4gICAgY29tcGxldGVyczogY29tcGxldGVycyxcbiAgICBub3RpZmljYXRpb25zOiB7XG4gICAgICBnZXRFbDogZnVuY3Rpb24oY29tcGxldGVyKSB7XG4gICAgICAgIHJldHVybiAkKGNvbXBsZXRpb25Ob3RpZmljYXR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gICAgIH1cblxuXG4gICAgICAgICQuZ2V0KFxuICAgICAgICAgICAge1xuICAgICAgICAgIFxuICAgICAgICAgICAgICB1cmw6IEFQSV9FTkRQT0lOVCArICc/JyArICQucGFyYW0ocXVlcnkpLFxuICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb25wJyxcbiAgICAgICAgICBcbiAgICAgICAgICAgIH0pLmRvbmUoIGZ1bmN0aW9uKCBkYXRhICkge1xuXG4gICAgICAgICAgICAgIHZhciBsaXN0ID1bXVxuICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgLy9UaGlzIGNvbmRpdGlvbiBpcyBmb3IgYW4gZW1wdHkgc2VhcmNoXG4gICAgICAgICAgICAgIGlmKGRhdGEuZXJyb3Ipe1xuICAgICAgICAgICAgICAgIGxpc3QgPSBbIHtcbiAgICAgICAgICAgICAgICAgIHRleHQ6ICcnLFxuICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6ICdUeXBlIHRvIHNlYXJjaCBmb3IgYW4gZW50aXR5J1xuICAgICAgICAgICAgICAgIH0gXTtcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhsaXN0KVxuICAgIFxuICAgICAgICAgICAgICB9ZWxzZXtcblxuICAgICAgICAgICAgICAgIHZhciBlbnRpdGllcyA9IFtdXG4gICAgICAgICAgICAgICAgdmFyIGxhYmVsLGlkLGRlc2NyaXB0aW9uLGVudGl0aWVzXG4gICAgICAgICAgICAgICAgZm9yKHZhciBlbnRpdHkgaW4gZGF0YS5zZWFyY2gpe1xuXG4gICAgICAgICAgICAgICAgICAgIGxhYmVsID0gZGF0YS5zZWFyY2hbZW50aXR5XS5sYWJlbFxuICAgICAgICAgICAgICAgICAgICBpZCA9IGRhdGEuc2VhcmNoW2VudGl0eV0uaWRcbiAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSBkYXRhLnNlYXJjaFtlbnRpdHldLmRlc2NyaXB0aW9uXG5cbiAgICAgICAgICAgICAgICAgICAgbGlzdCA9ICB7XG4gICAgICAgICAgICAgICAgICAgICAgdGV4dDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6IGxhYmVsICsgXCIgKFwiICsgaWQgKyBcIikgXFxuIFwiICsgZGVzY3JpcHRpb25cbiAgICAgICAgICAgICAgICAgICAgfSA7XG5cbiAgICAgICAgICAgICAgICAgICAgZW50aXRpZXMucHVzaChsaXN0KVxuICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbnRpdGllcy5zb3J0KClcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhlbnRpdGllcylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIFxuICAgICAgICBcbiAgICB9LFxuICAgIGFzeW5jOiB0cnVlLFxuICAgIGJ1bGs6IGZhbHNlLFxuICAgIGF1dG9TaG93OiBmYWxzZVxuICB9O1xufTtcblxubW9kdWxlLmV4cG9ydHMuaXNWYWxpZENvbXBsZXRpb25Qb3NpdGlvbiA9IGZ1bmN0aW9uKHlhc2hlKSB7XG5cblxuICBcbiAgdmFyIHRva2VuID0geWFzaGUuZ2V0Q29tcGxldGVUb2tlbigpO1xuICB2YXIgY3VyID0geWFzaGUuZ2V0Q3Vyc29yKClcblxuICAvL1RoZSBjdXJzb3Igc2hvdWxkIHN0YXkgYXQgdGhlIGVuZCBvZiB0aGUgdG9rZW5cbiAgaWYodG9rZW4uZW5kIT1jdXIuY2gpcmV0dXJuIGZhbHNlXG5cbiAgdmFyIHByZWZpeE5hbWUgPSB0b2tlbi5zdHJpbmcuc3BsaXQoJzonKVswXVxuICB2YXIgcHJldmlvdXNUb2tlbiA9IHlhc2hlLmdldFByZXZpb3VzTm9uV3NUb2tlbihjdXIubGluZSwgdG9rZW4pO1xuXG4gIC8vVGhpcyBsaW5lIGF2b2lkIHRoZSBhdXRvY29tcGxldGUgaW4gdGhlIHByZWZpeCBkZWZpbml0aW9uXG4g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hleCcgfSk7XG4gICAgICAgICAgICB2YXIgZmlsZU5hbWVUb1NhdmVBcyA9IFwiZG9jdW1lbnQuc2hleFwiO1xuICBcbiAgICAgICAgICAgIHZhciBkb3dubG9hZExpbmsgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KFwiYVwiKTtcbiAgICAgICAgICAgIGRvd25sb2FkTGluay5kb3dubG9hZCA9IGZpbGVOYW1lVG9TYXZlQXM7XG4gICAgICAgICAgICBkb3dubG9hZExpbmsuaW5uZXJIVE1MID0gXCJEb3dubG9hZCBGaWxlXCI7XG4gICAgICAgICAgICBpZiAod2luZG93LlVSTCAhPSBudWxsKSB7XG4gICAgICAgICAgICAgIC8vIENocm9tZSBhbGxvd3MgdGhlIGxpbmsgdG8gYmUgY2xpY2tlZCB3aXRob3V0IGFjdHVhbGx5IGFkZGluZyBpdCB0byB0aGUgRE9NLlxuICAgICAgICAgICAgICBkb3dubG9hZExpbmsuaHJlZiA9IHdpbmRvdy5VUkwuY3JlYXRlT2JqZWN0VVJMKHRleHRGaWxlQXNCbG9iKTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIC8vIEZpcmVmb3ggcmVxdWlyZXMgdGhlIGxpbmsgdG8gYmUgYWRkZWQgdG8gdGhlIERPTSBiZWZvcmUgaXQgY2FuIGJlIGNsaWNrZWQuXG4gICAgICAgICAgICAgIGRvd25sb2FkTGluay5ocmVmID0gd2luZG93LlVSTC5jcmVhdGVPYmplY3RVUkwodGV4dEZpbGVBc0Jsb2IpO1xuICAgICAgICAgICAgICBkb3dubG9hZExpbmsub25jbGljayA9IGRlc3Ryb3lDbGlja2VkRWxlbWVudDtcbiAgICAgICAgICAgICAgZG93bmxvYWRMaW5rLnN0eWxlLmRpc3BsYXkgPSBcIm5vbmVcIjtcbiAgICAgICAgICAgICAgZG9jdW1lbnQuYm9keS5hcHBlbmRDaGlsZChkb3dubG9hZExpbmspO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZG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gYXJlIGNvbW1lbnRlZCwgc28gcmVtb3ZlIGNvbW1lbnRzXG4gICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShcbiAgICAgICAgICBcIlwiLFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIGxpbmU6IGksXG4gICAgICAgICAgICBjaDogMFxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgbGluZTogaSxcbiAgICAgICAgICAgIGNoOiAxXG4gICAgICAgICAgfVxuICAgICAgICApO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgLy8gTm90IGFsbCBsaW5lcyBhcmUgY29tbWVudGVkLCBzbyBhZGQgY29tbWVudHNcbiAgICAgICAgeWFzaGUucmVwbGFjZVJhbmdlKFwiI1wiLCB7XG4gICAgICAgICAgbGluZTogaSxcbiAgICAgICAgICBjaDogMFxuICAgICAgICB9KTtcbiAgICAgIH1cbiAgICB9XG4gIH07XG5cbnZhciBjb3B5TGluZVVwID0gZnVuY3Rpb24oeWFzaGUpIHtcbiAgICB2YXIgY3Vyc29yID0geWFzaGUuZ2V0Q3Vyc29yKCk7XG4gICAgdmFyIGxpbmVDb3VudCA9IHlhc2hlLmxpbmVDb3VudCgpO1xuICAgIC8vIEZpcnN0IGNyZWF0ZSBuZXcgZW1wdHkgbGluZSBhdCBlbmQgb2YgdGV4dFxuICAgIHlhc2hlLnJlcGxhY2VSYW5nZShcIlxcblwiLCB7XG4gICAgICBsaW5lOiBsaW5lQ291bnQgLSAxLFxuICAgICAgY2g6IHlhc2hlLmdldExpbmUobGluZUNvdW50IC0gMSkubGVuZ3RoXG4gICAgfSk7XG4gICAgLy8gQ29weSBhbGwgbGluZXMgdG8gdGhlaXIgbmV4dCBsaW5lXG4gICAgZm9yICh2YXIgaSA9IGxpbmVDb3VudDsgaSA+IGN1cnNvci5saW5lOyBpLS0pIHtcbiAgICAgIHZhciBsaW5lID0geWFzaGUuZ2V0TGluZShpIC0gMSk7XG4gICAgICB5YXNoZS5yZXBs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ICAgICAgY29uc3VtZWQgPSBzdHJlYW0ubWF0Y2godGVybWluYWxzW2ldLnJlZ2V4LCB0cnVlLCBmYWxzZSk7XG4gICAgICAgIGlmIChjb25zdW1lZCkge1xuICAgXG5cbiAgICAgICAgICBsZXQgbGFzdFBvcyA9ICQudHJpbShzdHJlYW0uc3RyaW5nKS5sZW5ndGgtMTtcbiAgICAgICAgICBsZXQgbGFzdFRva2VuID0gJC50cmltKHN0cmVhbS5zdHJpbmcpW2xhc3RQb3NdO1xuICAgICAgICAgIGxldCB0b2tlbiA9IHN0cmVhbS5jdXJyZW50KCk7XG4gICAgICAgICAgXG4gICAgICAgICAgLy9JcyBhIHNoYXBlRXhwckxhYmVsP1xuICAgICAgICAgIC8qXG4gICAgICAgICAgaWYobGFzdFRva2VuID09ICd7JyAgJiYgKHRva2VuLmluY2x1ZGVzKCc6JykgfHwgdG9rZW4uaW5jbHVkZXMoJzwnKSApKXtcbiAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICBjYXQ6IHRlcm1pbmFsc1tpXS5uYW1lLFxuICAgICAgICAgICAgICBzdHlsZTogJ3NoYXBlJyxcbiAgICAgICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgICAgICB9O1xuICAgICAgICAgIH1cblxuICAgICAgICAgICovXG4gICAgICAgICAgXG5cbiAgICAgIFxuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNhdDogdGVybWluYWxzW2ldLm5hbWUsXG4gICAgICAgICAgICBzdHlsZTogdGVybWluYWxzW2ldLnN0eWxlLFxuICAgICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgICBzdGFydDogc3RyZWFtLnN0YXJ0XG4gICAgICAgICAgfTtcblxuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgXG4gICAgICAgIFxuICAgICAgfVxuXG4gIFxuICAgICAgLy8gS2V5d29yZHNcbiAgICAgIGNvbnN1bWVkID0gc3RyZWFtLm1hdGNoKGdyYW1tYXIua2V5d29yZHMsIHRydWUsIGZhbHNlKTtcbiAgICAgIGlmIChjb25zdW1lZCl7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgY2F0OiBzdHJlYW0uY3VycmVudCgpLnRvVXBwZXJDYXNlKCksXG4gICAgICAgICAgc3R5bGU6IFwia2V5d29yZFwiLFxuICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxuICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgfTtcbiAgICAgIH1cblxuICAgICAgLy8gUHVuY3R1YXRpb25cbiAgICAgIGNvbnN1bWVkID0gc3RyZWFtLm1hdGNoKGdyYW1tYXIucHVuY3QsIHRydWUsIGZhbHNlKTtcbiAgICAgIGlmIChjb25zdW1lZCl7XG4gICAgICAgIGlmKHN0cmVhbS5jdXJyZW50KCkhPScqJyBcbiAgICAgICAgICAmJiBzdHJlYW0uY3VycmVudCgpIT0nKydcbiAgICAgICAgICAgJiYgc3RyZWFtLmN1cnJlbnQoKSE9Jz8nKXtcblxuICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBjYXQ6IHN0cmVhbS5jdXJyZW50KCksXG4gICAgICAgICAgICBzdHlsZTogXCJwdW5jXCIsXG4gICAgICAgICAgICB0ZXh0OiBjb25zdW1lZFswXSxcbiAgICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgICB9O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICBjYXQ6IHN0cmVhbS5jdXJyZW50KCksXG4gICAgICAgICAgc3R5bGU6IFwiY2FyZFwiLFxuICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxuICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgfTtcblxuICAgICAgIFxuICAgICAgfVxuX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BhIHVzZWQgcHJlZml4IGlzIGFjdHVhbGx5IGRlZmluZWRcbiAgICAgICAgICAgIGlmICghc3RhdGUuaW5QcmVmaXhEZWNsICYmICh0b2tlbiA9PT0gXCJQTkFNRV9OU1wiIHx8IHRva2VuID09PSBcIlBOQU1FX0xOXCIpKSB7XG4gICAgICAgICAgICAgIHZhciBjb2xvbkluZGV4ID0gdG9rZW5PYi50ZXh0LmluZGV4T2YoXCI6XCIpO1xuICAgICAgICAgICAgICBpZiAoY29sb25JbmRleCA+PSAwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHByZWZOcyA9IHRva2VuT2IudGV4dC5zbGljZSgwLCBjb2xvbkluZGV4KTtcbiAgICAgICAgICAgICAgICAvL2F2b2lkIHdhcm5pbmdzIGZvciBtaXNzaW5nIGJpZiBwcmVmaXhlcyAoeXVjaywgdmlydHVvc28tc3BlY2lmaWMpXG4gICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5wcmVmaXhlc1twcmVmTnNdICYmIFtcImJpZlwiLCBcInhzZFwiLCBcInNxbFwiXS5pbmRleE9mKHByZWZOcykgPCAwKSB7XG4gICAgICAgICAgICAgICAgICBzdGF0ZS5PSyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgcmVjb3JkRmFpbHVyZVBvcygpO1xuICAgICAgICAgICAgICAgICAgc3RhdGUuZXJyb3JNc2cgPSBcIlByZWZpeCAnXCIgKyBwcmVmTnMgKyBcIicgaXMgbm90IGRlZmluZWRcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcbiAgICAgICAgICAgIHN0YXRlLmNvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgICAgICByZWNvcmRGYWlsdXJlUG9zKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIC8vIHRvcFN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IHt9O1xuXG4gICAgICAgICAgICB0aGlzLmFjdGlvbiA9IG9wdGlvbnMuYWN0aW9uO1xuICAgICAgICAgICAgdGhpcy5jb250YWluZXIgPSBvcHRpb25zLmNvbnRhaW5lcjtcbiAgICAgICAgICAgIHRoaXMuZW1pdHRlciA9IG9wdGlvbnMuZW1pdHRlcjtcbiAgICAgICAgICAgIHRoaXMudGFyZ2V0ID0gb3B0aW9ucy50YXJnZXQ7XG4gICAgICAgICAgICB0aGlzLnRleHQgPSBvcHRpb25zLnRleHQ7XG4gICAgICAgICAgICB0aGlzLnRyaWdnZXIgPSBvcHRpb25zLnRyaWdnZXI7XG5cbiAgICAgICAgICAgIHRoaXMuc2VsZWN0ZWRUZXh0ID0gJyc7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVjaWRlcyB3aGljaCBzZWxlY3Rpb24gc3RyYXRlZ3kgaXMgZ29pbmcgdG8gYmUgYXBwbGllZCBiYXNlZFxuICAgICAgICAgKiBvbiB0aGUgZXhpc3RlbmNlIG9mIGB0ZXh0YCBhbmQgYHRhcmdldGAgcHJvcGVydGllcy5cbiAgICAgICAgICovXG5cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ2luaXRTZWxlY3Rpb24nLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gaW5pdFNlbGVjdGlvbigpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRleHQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdEZha2UoKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy50YXJnZXQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdFRhcmdldCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIENyZWF0ZXMgYSBmYWtlIHRleHRhcmVhIGVsZW1lbnQsIHNldHMgaXRzIHZhbHVlIGZyb20gYHRleHRgIHByb3BlcnR5LFxuICAgICA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iAgICAgICAgICovXG5cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ3JlbW92ZUZha2UnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gcmVtb3ZlRmFrZSgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VIYW5kbGVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcignY2xpY2snLCB0aGlzLmZha2VIYW5kbGVyQ2FsbGJhY2spO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXJDYWxsYmFjayA9IG51bGw7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VFbGVtKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlQ2hpbGQodGhpcy5mYWtlRWxlbSk7XG4gICAgICAgICAgICAgICAgdGhpcy5mYWtlRWxlbSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogU2VsZWN0cyB0aGUgY29udGVudCBmcm9tIGVsZW1lbnQgcGFzc2VkIG9uIGB0YXJnZXRgIHByb3BlcnR5LlxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnc2VsZWN0VGFyZ2V0JyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIHNlbGVjdFRhcmdldCgpIHtcbiAgICAgICAgICAgIHRoaXMuc2VsZWN0ZWRUZXh0ID0gKDAsIF9zZWxlY3QyLmRlZmF1bHQpKHRoaXMudGFyZ2V0KTtcbiAgICAgICAgICAgIHRoaXMuY29weVRleHQoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBFeGVjdXRlcyB0aGUgY29weSBvcGVyYXRpb24gYmFzZWQgb24gdGhlIGN1cnJlbnQgc2VsZWN0aW9uLlxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnY29weVRleHQnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gY29weVRleHQoKSB7XG4gICAgICAgICAgICB2YXIgc3VjY2VlZGVkID0gdm9pZCAwO1xuXG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHN1Y2NlZWRlZCA9IGRvY3VtZW50LmV4ZWNDb21tYW5kKHRoaXMuYWN0aW9uKTtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIHN1Y2NlZWRlZCA9IGZhbHNlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLmhhbmRsZVJlc3VsdChzdWNjZWVkZWQpO1xuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEZpcmVzIGFuIGV2ZW50IGJhc2VkIG9uIHRoZSBjb3B5IG9wZXJhdGlvbiByZXN1bHQuXG4gICAgICAgICAqIEBwYXJhbSB7Qm9vbGVhbn0gc3VjY2VlZGVkXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdoYW5kbGVSZXN1bHQnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gaGFuZGxlUmVzdWx0KHN1Y2NlZWRlZCkge1xuICAgICAgICAgICAgdGhpcy5lbWl0dGVyLmVtaXQoc3VjY2VlZGVkID8gJ3N1Y2Nlc3MnIDogJ2Vycm9yJywge1xuICAgICAgICAgICAgICAgIGFjdGlvbjogdGhpcy5hY3Rpb24sXG4gICAgICAgICAgICAgICAgdGV4dDogdGhpcy5zZWxlY3RlZFRleHQsXG4gICAgICAgICAgICAgICAgdHJpZ2dlcjogdGhpcy50cmlnZ2VyLFxuICAgICAgICAgICAgICAgIGNsZWFyU2VsZWN0aW9uOiB0aGlzLmNsZWFyU2VsZWN0aW9uLmJpbmQodGhpcylcbiAgICAgIC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dldC5ub2RlVHlwZSA9PT0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5hY3Rpb24gPT09ICdjb3B5JyAmJiB0YXJnZXQuaGFzQXR0cmlidXRlKCdkaXNhYmxlZCcpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0ludmFsaWQgXCJ0YXJnZXRcIiBhdHRyaWJ1dGUuIFBsZWFzZSB1c2UgXCJyZWFkb25seVwiIGluc3RlYWQgb2YgXCJkaXNhYmxlZFwiIGF0dHJpYnV0ZScpO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYWN0aW9uID09PSAnY3V0JyAmJiAodGFyZ2V0Lmhhc0F0dHJpYnV0ZSgncmVhZG9ubHknKSB8fCB0YXJnZXQuaGFzQXR0cmlidXRlKCdkaXNhYmxlZCcpKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIFwidGFyZ2V0XCIgYXR0cmlidXRlLiBZb3UgY2FuXFwndCBjdXQgdGV4dCBmcm9tIGVsZW1lbnRzIHdpdGggXCJyZWFkb25seVwiIG9yIFwiZGlzYWJsZWRcIiBhdHRyaWJ1dGVzJyk7XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICB0aGlzLl90YXJnZXQgPSB0YXJnZXQ7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIFwidGFyZ2V0XCIgdmFsdWUsIHVzZSBhIHZhbGlkIEVsZW1lbnQnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogR2V0cyB0aGUgYHRhcmdldGAgcHJvcGVydHkuXG4gICAgICAgICAqIEByZXR1cm4ge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fCBzaWduYWxET01FdmVudChjbSwgZSkpIHJldHVybjtcbiAgICAgICAgY20uc3RhdGUucGFzdGVJbmNvbWluZyA9IHRydWU7XG4gICAgICAgIGlucHV0LmZvY3VzKCk7XG4gICAgICB9KTtcblxuICAgICAgLy8gUHJldmVudCBub3JtYWwgc2VsZWN0aW9uIGluIHRoZSBlZGl0b3IgKHdlIGhhbmRsZSBvdXIgb3duKVxuICAgICAgb24oZGlzcGxheS5saW5lU3BhY2UsIFwic2VsZWN0c3RhcnRcIiwgZnVuY3Rpb24oZSkge1xuICAgICAgICBpZiAoIWV2ZW50SW5XaWRnZXQoZGlzcGxheSwgZSkpIGVfcHJldmVudERlZmF1bHQoZSk7XG4gICAgICB9KTtcblxuICAgICAgb24odGUsIFwiY29tcG9zaXRpb25zdGFydFwiLCBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIHN0YXJ0ID0gY20uZ2V0Q3Vyc29yKFwiZnJvbVwiKTtcbiAgICAgICAgaWYgKGlucHV0LmNvbXBvc2luZykgaW5wdXQuY29tcG9zaW5nLnJhbmdlLmNsZWFyKClcbiAgICAgICAgaW5wdXQuY29tcG9zaW5nID0ge1xuICAgICAgICAgIHN0YXJ0OiBzdGFydCxcbiAgICAgICAgICByYW5nZTogY20ubWFya1RleHQoc3RhcnQsIGNtLmdldEN1cnNvcihcInRvXCIpLCB7Y2xhc3NOYW1lOiBcIkNvZGVNaXJyb3ItY29tcG9zaW5nXCJ9KVxuICAgICAgICB9O1xuICAgICAgfSk7XG4gICAgICBvbih0ZSwgXCJjb21wb3NpdGlvbmVuZFwiLCBmdW5jdGlvbigpIHtcbiAgICAgICAgaWYgKGlucHV0LmNvbXBvc2luZykge1xuICAgICAgICAgIGlucHV0LnBvbGwoKTtcbiAgICAgICAgICBpbnB1dC5jb21wb3NpbmcucmFuZ2UuY2xlYXIoKTtcbiAgICAgICAgICBpbnB1dC5jb21wb3NpbmcgPSBudWxsO1xuICAgICAgICB9XG4gICAgICB9KTtcbiAg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gICAgICAgICB2YXIgZm91bmQgPSBjbS5maW5kTWFya3MoUG9zKGZyb21MaW5lLCAwKSwgUG9zKHRvTGluZSArIDEsIDApLCByZWNvZ25pemVNYXJrZXIoK21hcmtlcklEKSk7XG4gICAgICAgICAgaWYgKGZvdW5kLmxlbmd0aCAmJiAocmFuZ2UgPSBmb3VuZFswXS5maW5kKCkpKVxuICAgICAgICAgICAgdGV4dCArPSBnZXRCZXR3ZWVuKGNtLmRvYywgcmFuZ2UuZnJvbSwgcmFuZ2UudG8pLmpvaW4obGluZVNlcCk7XG4gICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG4gICAgICAgIGlmIChub2RlLmdldEF0dHJpYnV0ZShcImNvbnRlbnRlZGl0YWJsZVwiKSA9PSBcImZhbHNlXCIpIHJldHVybjtcbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBub2RlLmNoaWxkTm9kZXMubGVuZ3RoOyBpKyspXG4gICAgICAgICAgd2Fsayhub2RlLmNoaWxkTm9kZXNbaV0pO1xuICAgICAgICBpZiAoL14ocHJlfGRpdnxwKSQvaS50ZXN0KG5vZGUubm9kZU5hbWUpKVxuICAgICAgICAgIGNsb3NpbmcgPSB0cnVlO1xuICAgICAgfSBlbHNlIGlmIChub2RlLm5vZGVUeXBlID09IDMpIHtcbiAgICAgICAgdmFyIHZhbCA9IG5vZGUubm9kZVZhbHVlO1xuICAgICAgICBpZiAoIXZhbCkgcmV0dXJuO1xuICAgICAgICBpZiAoY2xvc2luZykge1xuICAgICAgICAgIHRleHQgKz0gbGluZVNlcDtcbiAgICAgICAgICBjbG9zaW5nID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgdGV4dCArPSB2YWw7XG4gICAgICB9XG4gICAgfVxuICAgIGZvciAoOzspIHtcbiAgICAgIHdhbGsoZnJvbSk7XG4gICAgICBpZiAoZnJvbSA9PSB0bykgYnJlYWs7XG4gICAgICBmcm9tID0gZnJvbS5uZXh0U2libGluZztcbiAgICB9XG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IHstLWk7IGNvbnRpbnVlO31cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFtLmF0b21pYykgY29udGludWU7XG5cbiAgICAgICAgaWYgKG9sZFBvcykge1xuICAgICAgICAgIHZhciBuZWFyID0gbS5maW5kKGRpciA8IDAgPyAxIDogLTEpLCBkaWZmO1xuICAgICAgICAgIGlmIChkaXIgPCAwID8gbS5pbmNsdXNpdmVSaWdodCA6IG0uaW5jbHVzaXZlTGVmdClcbiAgICAgICAgICAgIG5lYXIgPSBtb3ZlUG9zKGRvYywgbmVhciwgLWRpciwgbmVhciAmJiBuZWFyLmxpbmUgPT0gcG9zLmxpbmUgPyBsaW5lIDogbnVsbCk7XG4gICAgICAgICAgaWYgKG5lYXIgJiYgbmVhci5saW5lID09IHBvcy5saW5lICYmIChkaWZmID0gY21wKG5lYXIsIG9sZFBvcykpICYmIChkaXIgPCAwID8gZGlmZiA8IDAgOiBkaWZmID4gMCkpXG4gICAgICAgICAgICByZXR1cm4gc2tpcEF0b21pY0lubmVyKGRvYywgbmVhciwgcG9zLCBkaXIsIG1heUNsZWFyKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBmYXIgPSBtLmZpbmQoZGlyIDwgMCA/IC0xIDogMSk7XG4gICAgICAgIGlmIChkaXIgPCAwID8gbS5pbmNsdXNpdmVMZWZ0IDogbS5pbmNsdXNpdmVSaWdodClcbiAgICAgICAgICBmYXIgPSBtb3ZlUG9zKGRvYywgZmFyLCBkaXIsIGZhci5saW5lID09IHBvcy5saW5lID8gbGluZSA6IG51bGwpO1xuICAgICAgICByZXR1cm4gZmFyID8gc2tpcEF0b21pY0lubmVyKGRvYywgZmFyLCBwb3MsIGRpciwgbWF5Q2xlYXIpIDogbnVsbDtcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHBvcztcbiAgfVxuXG4gIC8vIEVuc3VyZSBhIGdpdmVuIHBvc2l0aW9uIGlzIG5vdCBpbnNpZGUgYW4gYXRv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2UudG8ubGVmdCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWluKHJhbmdlLmZyb20udG9wLCByYW5nZS50by50b3ApIC0gcmFuZ2UubWFyZ2luLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRoLm1heChyYW5nZS5mcm9tLnJpZ2h0LCByYW5nZS50by5yaWdodCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWF4KHJhbmdlLmZyb20uYm90dG9tLCByYW5nZS50by5ib3R0b20pICsgcmFuZ2UubWFyZ2luKTtcbiAgICAgICAgdGhpcy5zY3JvbGxUbyhzUG9zLnNjcm9sbExlZnQsIHNQb3Muc2Nyb2xsVG9wKTtcbiAgICAgIH1cbiAgICB9KSxcblxuICAgIHNldFNpemU6IG1ldGhvZE9wKGZ1bmN0aW9uKHdpZHRoLCBoZWlnaHQpIHtcbiAgICAgIHZhciBjbSA9IHRoaXM7XG4gICAgICBmdW5jdGlvbiBpbnRlcnByZXQodmFsKSB7XG4gICAgICAgIHJldHVybiB0eXBlb2YgdmFsID09IFwibnVtYmVyXCIgfHwgL15cXGQrJC8udGVzdChTdHJpbmcodmFsKSkgPyB2YWwgKyBcInB4XCIgOiB2YWw7XG4gICAgICB9XG4gICAgICBpZiAod2lkdGggIT0gbnVsbCkgY20uZGlzcGxheS53cmFwcGVyLnN0eWxlLndpZHRoID0gaW50ZXJwcmV0KHdpZHRoKTtcbiAgICAgIGlmIChoZWlnaHQgIT0gbnVsbCkgY20uZGlzcGxheS53cmFwcGVyLnN0eWxlLmhlaWdodCA9IGludGVycHJldChoZWlnaHQpO1xuICAgICAgaWYgKGNtLm9wdGlvbnMubGluZVdyYXBwaW5nKSBjbGVhckxpbmVNZWFzdXJlbWVudENhY2hlKHRoaXMpO1xuICAgICAgdmFyIGxpbmVObyA9IGNtLmRpc3BsYXkudmlld0Zyb207XG4gICAgICBjbS5kb2MuaXRlcihs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cGFucy5sZW5ndGg7ICsraikge1xuICAgICAgICAgIHZhciBzcCA9IHNwYW5zW2pdLCBtID0gc3AubWFya2VyO1xuICAgICAgICAgIGlmIChtLnR5cGUgPT0gXCJib29rbWFya1wiICYmIHNwLmZyb20gPT0gcG9zICYmIG0ud2lkZ2V0Tm9kZSkge1xuICAgICAgICAgICAgZm91bmRCb29rbWFya3MucHVzaChtKTtcbiAgICAgICAgICB9IGVsc2UgaWYgKHNwLmZyb20gPD0gcG9zICYmIChzcC50byA9PSBudWxsIHx8IHNwLnRvID4gcG9zIHx8IG0uY29sbGFwc2VkICYmIHNwLnRvID09IHBvcyAmJiBzcC5mcm9tID09IHBvcykpIHtcbiAgICAgICAgICAgIGlmIChzcC50byAhPSBudWxsICYmIHNwLnRvICE9IHBvcyAmJiBuZXh0Q2hhbmdlID4gc3AudG8pIHtcbiAgICAgICAgICAgICAgbmV4dENoYW5nZSA9IHNwLnRvO1xuICAgICAgICAgICAgICBzcGFuRW5kU3R5bGUgPSBcIlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG0uY2xhc3NOYW1lKSBzcGFuU3R5bGUgKz0gXCIgXCIgKyBtLmNsYXNzTmFtZTtcbiAgICAgICAgICAgIGlmIChtLmNzcykgY3NzID0gKGNzcyA/IGNzcyArIFwiO1wiIDogXCJcIikgKyBtLmNzcztcbiAgICAgICAgICAgIGlmIChtLnN0YXJ0U3R5bGUgJiYgc3AuZnJvbSA9PSBwb3MpIHNwYW5TdGFydFN0eWxlICs9IFwiIFwiICsgbS5zdGFydFN0eWxlO1xuICAgICAgICAgICAgaWYgKG0uZW5kU3R5bGUgJiYgc3AudG8gPT0gbmV4dENoYW5nZSkgKGVuZFN0eWxlcyB8fCAoZW5kU3R5bGVzID0gW10pKS5wdXNoKG0uZW5kU3R5bGUsIHNwLnRvKVxuICAgICAgICAgICAgaWYgKG0udGl0bGUgJiYgIXRpdGxlKSB0aXRsZSA9IG0udGl0bGU7XG4gICAgICAgICAg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Jic3NzdHdOTiUlJU5OTk5OTixOLE4xMTExMTExMTExTk5OTk5OTkxMTExMTExMTExMTExMTExMTExMTExMTExMTk5OTk5OTExMTExMTExMTExMTExMTExMTExMTExMTExOTk5OYmJiYmJic2JiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiLE4lJSUlTk5OTkxOTk5OTiUlMTFOTE5OTjFMTk5OTk5MTExMTExMTExMTExMTExMTExMTExMTE5MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTlwiO1xuICAgIC8vIENoYXJhY3RlciB0eXBlcyBmb3IgY29kZXBvaW50cyAweDYwMCB0byAweDZmZlxuICAgIHZhciBhcmFiaWNUeXBlcyA9IFwicnJycnJycnJycnJyLHJOTm1tbW1tbXJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJybW1tbW1tbW1tbW1tbW1ycnJycnJybm5ubm5ubm5ubiVubnJycm1ycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycm1tbW1tbW1tbW1tbW1tbW1tbW1ObW1tbVwiO1xuICAgIGZ1bmN0aW9uIGNoYXJUeXBlKGNvZGUpIHtcbiAgICAgIGlmIChjb2RlIDw9IDB4ZjcpIHJldHVybiBsb3dUeXBlcy5jaGFyQXQoY29kZSk7XG4gICAgICBlbHNlIGlmICgweDU5MCA8PSBjb2RlICYmIGNvZGUgPD0gMHg1ZjQpIHJldHVybiBcIlJcIjtcbiAgICAgIGVsc2UgaWYgKDB4NjAwIDw9IGNvZGUgJiYgY29kZSA8PSAweDZlZCkgcmV0dXJuIGFyYWJpY1R5cGVzLmNoYXJBdChjb2RlIC0gMHg2MDApO1xuICAgICAgZWxzZSBpZiAoMHg2ZWUgPD0gY29kZSAmJiBjb2RlIDw9IDB4OGFjKSByZXR1cm4gXCJyXCI7XG4gICAgICBlbHNlIGlmICgweDIwM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AgICByZXR1cm4gbmV3IERhdGUoRGF0ZS5VVEMoK2FbMV0sICthWzJdIC0gMSwgK2FbM10sICthWzRdLFxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgICthWzVdLCArYVs2XSkpO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbi8vICAgICAgICAgIH0pO1xuXG4vLyAgICAgICAgICBteURhdGEgPSBKU09OLnBhcnNlKCdbXCJEYXRlKDA5LzA5LzIwMDEpXCJdJywgZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcbi8vICAgICAgICAgICAgICB2YXIgZDtcbi8vICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSBcInN0cmluZ1wiICYmXG4vLyAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5zbGljZSgwLCA1KSA9PT0gXCJEYXRlKFwiICYmXG4vLyAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5zbGljZSgtMSkgPT09IFwiKVwiKSB7XG4vLyAgICAgICAgICAgICAgICAgIGQgPSBuZXcgRGF0ZSh2YWx1ZS5zbGljZSg1LCAtMSkpO1xuLy8gICAgICAgICAgICAgICAgICBpZiAoZCkge1xuLy8gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGQ7XG4vLyAgICAgICAgICAgICAgICAgIH1cbi8vICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuLy8gICAgICAgICAgfSk7XG5cbi8vICBUaGlzIGlzIGEgcmVmZXJlbmNlIGltcGxlbWVudGF0aW9uLiBZb3UgYXJlIGZyZWUgdG8gY29weSwgbW9kaWZ5LCBvclxuLy8gIHJlZGlzdHJpYnV0ZS5cblxuLypqc2xpbnRcbiAgICBldmFsLCBmb3IsIHRoaXNcbiovXG5cbi8qcHJvcGVydHlcbiAgICBKU09OLCBhcHBseSwgY2FsbCwgY2hhckNvZGVBd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gICAgICAgICAgIH1cblxuLy8gSm9pbiBhbGwgb2YgdGhlIGVsZW1lbnRzIHRvZ2V0aGVyLCBzZXBhcmF0ZWQgd2l0aCBjb21tYXMsIGFuZCB3cmFwIHRoZW0gaW5cbi8vIGJyYWNrZXRzLlxuXG4gICAgICAgICAgICAgICAgdiA9IHBhcnRpYWwubGVuZ3RoID09PSAwXG4gICAgICAgICAgICAgICAgICAgID8gXCJbXVwiXG4gICAgICAgICAgICAgICAgICAgIDogZ2FwXG4gICAgICAgICAgICAgICAgICAgICAgICA/IFwiW1xcblwiICsgZ2FwICsgcGFydGlhbC5qb2luKFwiLFxcblwiICsgZ2FwKSArIFwiXFxuXCIgKyBtaW5kICsgXCJdXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIDogXCJbXCIgKyBwYXJ0aWFsLmpvaW4oXCIsXCIpICsgXCJdXCI7XG4gICAgICAgICAgICAgICAgZ2FwID0gbWluZDtcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcbiAgICAgICAgICAgIH1cblxuLy8gSWYgdGhlIHJlcGxhY2VyIGlzIGFuIGFycmF5LCB1c2UgaXQgdG8gc2VsZWN0IHRoZSBtZW1iZXJzIHRvIGJlIHN0cmluZ2lmaWVkLlxuXG4gICAgICAgICAgICBpZiAocmVwICYmIHR5cGVvZiByZXAgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICBsZW5ndGggPSByZXAubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcFtpXSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgayA9IHJlcFtpXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBzdHIoaywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsLnB1c2gocXVvdGUoaykgKyAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBcIjogXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogXCI6XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApICsgdik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuXG4vLyBPdGhlcndpc2UsIGl0ZXJhdGUgdGhyb3VnaCBhbGwgb2YgdGhlIGtleXMgaW4gdGhlIG9iamVjdC5cblxuICAgICAgICAgICAgICAgIGZvciAoayBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbHVlLCBrKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdiA9IHN0cihrLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRpYWwucHVzaChxdW90ZShrKSArIChcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2FwXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IFwiOiBcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBcIjpcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgKyB2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuLy8gSm9pbiBhbGwgb2YgdGhlIG1lbWJlciB0ZXh0cyB0b2dldGhlciwgc2VwYXJhdGVkIHdpdGggY29tbWFz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B0ZXh0IGFuZCBhbiBvcHRpb25hbCByZXZpdmVyIGZ1bmN0aW9uLCBhbmQgcmV0dXJuc1xuLy8gYSBKYXZhU2NyaXB0IHZhbHVlIGlmIHRoZSB0ZXh0IGlzIGEgdmFsaWQgSlNPTiB0ZXh0LlxuXG4gICAgICAgICAgICB2YXIgajtcblxuICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhob2xkZXIsIGtleSkge1xuXG4vLyBUaGUgd2FsayBtZXRob2QgaXMgdXNlZCB0byByZWN1cnNpdmVseSB3YWxrIHRoZSByZXN1bHRpbmcgc3RydWN0dXJlIHNvXG4vLyB0aGF0IG1vZGlmaWNhdGlvbnMgY2FuIGJlIG1hZGUuXG5cbiAgICAgICAgICAgICAgICB2YXIgaztcbiAgICAgICAgICAgICAgICB2YXIgdjtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBob2xkZXJba2V5XTtcbiAgICAgICAgICAgICAgICBpZiAodmFsdWUgJiYgdHlwZW9mIHZhbHVlID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAoayBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbCh2YWx1ZSwgaykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ID0gd2Fsayh2YWx1ZSwgayk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZVtrXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHZhbHVlW2tdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAg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YWxsYmFja05hbWUsIGNvbXBsZXRlci5jYWxsYmFja3NbY2FsbGJhY2tOYW1lXSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHJldHVybk9iajtcbiAgfTtcblxuICByZXR1cm4ge1xuICAgIGluaXQ6IGluaXRDb21wbGV0ZXIsXG4gICAgY29tcGxldGVyczogY29tcGxldGVycyxcbiAgICBub3RpZmljYXRpb25zOiB7XG4gICAgICBnZXRFbDogZnVuY3Rpb24oY29tcGxldGVyKSB7XG4gICAgICAgIHJldHVybiAkKGNvbXBsZXRpb25Ob3RpZmljYXRpb25zW2NvbXBsZXRlci5uYW1lXSk7XG4gICAgICB9LFxuICAgICAgc2hvdzogZnVuY3Rpb24oeWFzaGUsIGNvbXBsZXRlcikge1xuICAgICAgICAvL29ubHkgZHJhdyB3aGVuIHRoZSB1c2VyIG5lZWRzIHRvIHVzZSBhIGtleXByZXNzIHRvIHN1bW1vbiBhdXRvY29tcGxldGlvbnNcbiAgICAgICAgaWYgKCFjb21wbGV0ZXIuYXV0b3Nob3cpIHtcbiAgICAgICAgICBpZiAoIWNvbXBsZXRpb25Ob3RpZmljYXRpb25zW2NvbXBsZXRlci5uYW1lXSlcbiAgICAgICAgICAgIGNvbXBsZXRpb25Ob3RpZmljYXRpb25zW2NvbXBsZXRlci5uYW1lXSA9ICQoXCI8ZGl2IGNsYXNzPSdjb21wbGV0aW9uTm90aWZpY2F0aW9uJz48L2Rpdj5cIik7XG4gICAgICAgICAgY29tcGxldGlvbk5vdGlmaWNhdGlvbnNbY29tcGxldGVyLm5hbWVdXG4gICAgICAgICAgICAuc2hvdygpXG4gICAgICAgICAgICAudGV4dChcIlByZXNzIENUUkwgLSA8c3BhY2ViYXI+IHRvIGF1dG9jb21wbGV0ZVwiKVxuICAgICAgICAgICAgLmFwcGVuZFRvKCQoeWFzaGUuZ2V0V3JhcHBlckVsZW1lbnQoKSkpO1xuICAgICAgICB9XG4gICAgICB9LFxuICAgICA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G4gICAgICAgIHZhciBxdWVyeSA9IFFVRVJZXG4gICAgICAgIHF1ZXJ5LnNlYXJjaD1wb3NzaWJsZUVudGl0eVxuXG4gICAgICAgIC8vQWRkIGV4dHJhIHBhcmFtIGlmIGl0IGlzIGEgcHJvcGVydHlcbiAgICAgICAgaWYocmRmVXRpbHMuaXNXaWtpZGF0YVByb3BlcnRpZXNQcmVmaXgoeWFzaGUscHJlZml4KSl7XG4gICAgICAgICAgcXVlcnkudHlwZT0ncHJvcGVydHknXG4gICAgICAgIH1lbHNle1xuICAgICAgICAgIGRlbGV0ZSBxdWVyeS50eXBlXG4gICAgICAgIH1cblxuXG4gICAgICAgICQuZ2V0KFxuICAgICAgICAgICAge1xuICAgICAgICAgIFxuICAgICAgICAgICAgICB1cmw6IEFQSV9FTkRQT0lOVCArICc/JyArICQucGFyYW0ocXVlcnkpLFxuICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb25wJyxcbiAgICAgICAgICBcbiAgICAgICAgICAgIH0pLmRvbmUoIGZ1bmN0aW9uKCBkYXRhICkge1xuXG4gICAgICAgICAgICAgIHZhciBsaXN0ID1bXVxuICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgLy9UaGlzIGNvbmRpdGlvbiBpcyBmb3IgYW4gZW1wdHkgc2VhcmNoXG4gICAgICAgICAgICAgIGlmKGRhdGEuZXJyb3Ipe1xuICAgICAgICAgICAgICAgIGxpc3QgPSBbIHtcbiAgICAgICAgICAgICAgICAgIHRleHQ6ICcnLFxuICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6ICdUeXBlIHRvIHNlYXJjaCBmb3IgYW4gZW50aXR5J1xuICAgICAgICAgICAgICAgIH0gXTtcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhsaXN0KVxuICAgIFxuICAgICAgICAgICAgICB9ZWxzZXtcblxuICAgICAgICAgICAgICAgIHZhciBlbnRpdGllcyA9IFtdXG4gICAgICAgICAgICAgICAgdmFyIGxhYmVsLGlkLGRlc2NyaXB0aW9uLGVudGl0aWVzXG4gICAgICAgICAgICAgICAgZm9yKHZhciBlbnRpdHkgaW4gZGF0YS5zZWFyY2gpe1xuXG4gICAgICAgICAgICAgICAgICAgIGxhYmVsID0gZGF0YS5zZWFyY2hbZW50aXR5XS5sYWJlbFxuICAgICAgICAgICAgICAgICAgICBpZCA9IGRhdGEuc2VhcmNoW2VudGl0eV0uaWRcbiAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSBkYXRhLnNlYXJjaFtlbnRpdHldLmRlc2NyaXB0aW9uXG5cbiAgICAgICAgICAgICAgICAgICAgbGlzdCA9ICB7XG4gICAgICAgICAgICAgICAgICAgICAgdGV4dDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6IGxhYmVsICsgXCIgKFwiICsgaWQgKyBcIikgXFxuIFwiICsgZGVzY3JpcHRpb25cbiAgICAgICAgICAgICAgICAgICAgfSA7XG5cbiAgICAgICAgICAgICAgICAgICAgZW50aXRpZXMucHVzaChsaXN0KVxuICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbnRpdGllcy5zb3J0KClcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhlbnRpdGllcylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIFxuICAgICAgICBcbiAgICB9LFxuICAgIGFzeW5jOiB0cnVlLFxuICAgIGJ1bGs6IGZhbHNlLFxuICAgIGF1dG9TaG93OiBmYWxzZVxuICB9O1xufTtcblxubW9kdWxlLmV4cG9ydHMuaXNWYWxpZENvbXBsZXRpb25Qb3NpdGlvbiA9IGZ1bmN0aW9uKHlhc2hlKSB7XG5cblxuICBcbiAgdmFyIHRva2VuID0geWFzaGUuZ2V0Q29tcGxldGVUb2tlbigpO1xuICB2YXIgY3VyID0geWFzaGUuZ2V0Q3Vyc29yKClcblxuICAvL1RoZSBjdXJzb3Igc2hvdWxkI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IC8vIGlmIGFsbCBsaW5lcyBzdGFydCB3aXRoICMsIHJlbW92ZSB0aGlzIGNoYXIuIE90aGVyd2lzZSBhZGQgdGhpcyBjaGFyXG4gICAgdmFyIGxpbmVzQXJlQ29tbWVudGVkID0gdHJ1ZTtcbiAgICBmb3IgKHZhciBpID0gbWluOyBpIDw9IG1heDsgaSsrKSB7XG4gICAgICB2YXIgbGluZSA9IHlhc2hlLmdldExpbmUoaSk7XG4gICAgICBpZiAobGluZS5sZW5ndGggPT0gMCB8fCBsaW5lLnN1YnN0cmluZygwLCAxKSAhPSBcIiNcIikge1xuICAgICAgICBsaW5lc0FyZUNvbW1lbnRlZCA9IGZhbHNlO1xuICAgICAgICBicmVhaztcbiAgICAgIH1cbiAgICB9XG4gICAgZm9yICh2YXIgaSA9IG1pbjsgaSA8PSBtYXg7IGkrKykge1xuICAgICAgaWYgKGxpbmVzQXJlQ29tbWVudGVkKSB7XG4gICAgICAgIC8vIGxpbmVzIGFyZSBjb21tZW50ZWQsIHNvIHJlbW92ZSBjb21tZW50c1xuICAgICAgICB5YXNoZS5yZXBsYWNlUmFuZ2UoXG4gICAgICAgICAgXCJcIixcbiAgICAgICAgICB7XG4gICAgICAgICAgICBsaW5lOiBpLFxuICAgICAgICAgICAgY2g6IDBcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIGxpbmU6IGksXG4gICAgICAgICAgICBjaDogMVxuICAgICAgICAgIH1cbiAgICAgICAgKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIC8vIE5vdCBhbGwgbGluZXMgYXJlIGNvbW1lbnRlZCwgc28gYWRkIGNvbW1lbnRzXG4gICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShcIiNcIiwge1xuICAgICAgICAgIGxpbmU6IGksXG4gICAgICAgICAgY2g6IDBcbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfVxuICB9O1xuXG52YXIgY29weUxpbmVVcCA9IGZ1bmN0aW9uKHlhc2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pcCxcbiAgZGVib3VuY2U6ZGVib3VuY2Vcbn07Il19 diff --git a/dist/yashe.css b/dist/yashe.css index 9305b7ef..57f37900 100755 --- a/dist/yashe.css +++ b/dist/yashe.css @@ -52,6 +52,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} color: #05a; } .yashe .cm-s-wiki .cm-constraint { color: #05a; } + .yashe .cm-s-wiki .cm-valueSet { + color: #05a; } .yashe .cm-s-wiki .cm-constraintKeyword { color: #f00; } .yashe .cm-s-wiki .cm-facet { @@ -111,6 +113,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} color: #7DB647; } .yashe .cm-s-dark .cm-constraint { color: #7DB647; } + .yashe .cm-s-dark .cm-valueSet { + color: #7DB647; } .yashe .cm-s-dark .cm-constraintKeyword { color: #f00; } .yashe .cm-s-dark .cm-meta { diff --git a/dist/yashe.min.css b/dist/yashe.min.css index e96c4cd3..ba0be01b 100755 --- a/dist/yashe.min.css +++ b/dist/yashe.min.css @@ -1 +1 @@ -.yashe{position:relative}.yashe .cm-s-wiki .cm-shape{color:#0f7a50}.yashe .cm-s-wiki .cm-keyword{color:red}.yashe .cm-s-wiki .cm-atom{color:#219}.yashe .cm-s-wiki .cm-number{color:#085}.yashe .cm-s-wiki .cm-def{color:#00f}.yashe .cm-s-default .cm-punctuation,.yashe .cm-s-wiki .cm-operator,.yashe .cm-s-wiki .cm-property,.yashe .cm-s-wiki .cm-variable{color:#05a}.yashe .cm-s-wiki .cm-variable-2{color:#0f7a50}.yashe .cm-s-wiki .cm-variable-3{color:#05a}.yashe .cm-s-wiki .cm-comment{color:#999}.yashe .cm-s-wiki .cm-string{color:#b98003}.yashe .cm-s-wiki .cm-constraint,.yashe .cm-s-wiki .cm-string-2{color:#05a}.yashe .cm-s-wiki .cm-constraintKeyword,.yashe .cm-s-wiki .cm-facet{color:red}.yashe .cm-s-wiki .cm-meta,.yashe .cm-s-wiki .cm-qualifier{color:#555}.yashe .cm-s-wiki .cm-builtin{color:#30a}.yashe .cm-s-wiki .cm-bracket{color:#997}.yashe .cm-s-wiki .cm-tag{color:#170}.yashe .cm-s-wiki .cm-attribute{color:#00c}.yashe .cm-s-wiki .cm-hr{color:#999}.yashe .cm-s-wiki .cm-link{color:#00c}.yashe .cm-s-wiki .cm-punc{color:#000}.yashe .cm-s-wiki .cm-logical{color:red}.yashe .cm-s-wiki .cm-at{color:#0f7a50}.yashe .cm-s-wiki .cm-prefixDelc{color:#6d0f7a}.yashe .cm-s-dark.CodeMirror{background:#2b2b2b;color:#a9b7c6;border:10px}.yashe .cm-s-dark .cm-shape{color:#68beeb}.yashe .cm-s-dark .cm-keyword{color:red}.yashe .cm-s-dark .cm-atom{color:#219}.yashe .cm-s-dark .cm-number{color:#e5f439}.yashe .cm-s-dark .cm-def{color:#00f}.yashe .cm-s-dark .cm-operator,.yashe .cm-s-dark .cm-property,.yashe .cm-s-dark .cm-punctuation,.yashe .cm-s-dark .cm-variable{color:#05a}.yashe .cm-s-dark .cm-variable-2,.yashe .cm-s-dark .cm-variable-3{color:#68beeb}.yashe .cm-s-dark .cm-comment{color:#999}.yashe .cm-s-dark .cm-string{color:#b98003}.yashe .cm-s-dark .cm-constraint,.yashe .cm-s-dark .cm-string-2{color:#7db647}.yashe .cm-s-dark .cm-constraintKeyword{color:red}.yashe .cm-s-dark .cm-meta,.yashe .cm-s-dark .cm-qualifier{color:#555}.yashe .cm-s-dark .cm-builtin{color:#30a}.yashe .cm-s-dark .cm-bracket{color:#997}.yashe .cm-s-dark .cm-tag{color:#170}.yashe .cm-s-dark .cm-attribute{color:#00c}.yashe .cm-s-dark .cm-hr{color:#999}.yashe .cm-s-dark .cm-link{color:#00c}.yashe .cm-s-dark .cm-punc{color:#fff}.yashe .cm-s-dark .cm-logical{color:#b271ff}.yashe .cm-s-dark .cm-at{color:#68beeb}.yashe .cm-s-dark .cm-prefixDelc{color:#f8c4ffc0}.yashe .cm-s-dark .CodeMirror-cursor{border-left:1px solid #a9b7c6}.yashe .cm-s-dark .CodeMirror-activeline-background{background:#323232}.yashe .cm-s-dark .CodeMirror-gutters{background:#313335;border-right:1px solid #313335}.yashe .cm-s-dark .CodeMirror-guttermarker{color:#ffee80}.yashe .cm-s-dark .CodeMirror-guttermarker-subtle{color:#d0d0d0}.yashe .cm-s-dark .CodeMirrir-linenumber{color:#606366}.yashe .cm-s-dark .CodeMirror-matchingbracket{background-color:#3b514d;color:#ffef28!important;font-weight:700}.yashe .cm-s-dark div.CodeMirror-selected{background:#214283}.yashe .CodeMirror-hints.dark{color:#9c9e9e;background-color:#3b3e3f!important}.yashe .CodeMirror-hints.dark .CodeMirror-hint-active{background-color:#494d4e!important;color:#9c9e9e!important}.yashe .CodeMirror{font-family:monospace;height:300px;color:#000;font-size:14px}.yashe .CodeMirror-lines{padding:4px 0}.yashe .CodeMirror pre{padding:0 4px}.yashe .CodeMirror-gutter-filler,.yashe .CodeMirror-scrollbar-filler{background-color:#fff}.yashe .CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f8f8f8;white-space:nowrap}.yashe .CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.yashe .CodeMirror-guttermarker{color:#000}.yashe .CodeMirror-guttermarker-subtle{color:#999}.yashe .CodeMirror-cursor{border-left:1px solid red;border-right:none;width:0}.yashe .CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.yashe .cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.yashe .cm-fat-cursor div.CodeMirror-cursors{z-index:1}.yashe .cm-animate-fat-cursor{width:auto;border:0;animation:a 1.06s steps(1) infinite;background-color:#7e7}@keyframes a{50%{background-color:transparent}}.yashe .cm-tab{display:inline-block;text-decoration:inherit}.yashe .CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:-20px;overflow:hidden}.yashe .CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.yashe .cm-s-default .cm-header{color:blue}.yashe .cm-s-default .cm-quote{color:#090}.yashe .cm-negative{color:#d44}.yashe .cm-positive{color:#292}.yashe .cm-header,.yashe .cm-strong{font-weight:700}.yashe .cm-em{font-style:italic}.yashe .cm-link{text-decoration:underline}.yashe .cm-strikethrough{text-decoration:line-through}.yashe .cm-s-default .cm-keyword{color:red}.yashe .cm-s-default .cm-atom{color:#219}.yashe .cm-s-default .cm-number{color:#085}.yashe .cm-s-default .cm-def{color:#00f}.yashe .cm-s-default .cm-operator,.yashe .cm-s-default .cm-property,.yashe .cm-s-default .cm-punctuation,.yashe .cm-s-default .cm-variable{color:#05a}.yashe .cm-s-default .cm-variable-2{color:#0f7a50}.yashe .cm-s-default .cm-variable-3{color:#05a}.yashe .cm-s-default .cm-comment{color:#999}.yashe .cm-s-default .cm-string{color:#b98003}.yashe .cm-s-default .cm-string-2{color:#05a}.yashe .cm-s-default .cm-meta,.yashe .cm-s-default .cm-qualifier{color:#555}.yashe .cm-s-default .cm-builtin{color:#30a}.yashe .cm-s-default .cm-bracket{color:#997}.yashe .cm-s-default .cm-tag{color:#170}.yashe .cm-s-default .cm-attribute{color:#00c}.yashe .cm-s-default .cm-hr{color:#999}.yashe .cm-s-default .cm-link{color:#00c}.yashe .cm-s-default .cm-punc{color:#000}.yashe .cm-s-default .cm-logical{color:red}.yashe .cm-s-default .cm-at{color:#0f7a50}.yashe .cm-invalidchar,.yashe .cm-s-default .cm-error{color:red}.yashe .CodeMirror-composing{border-bottom:2px solid}.yashe .CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.yashe .CodeMirror-activeline-background{background:#e8f2ff}.yashe .CodeMirror{position:relative;overflow:hidden;background:#fff}.yashe .CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative}.yashe .CodeMirror-sizer{position:relative;border-right:30px solid transparent}.yashe .CodeMirror-gutter-filler,.yashe .CodeMirror-hscrollbar,.yashe .CodeMirror-scrollbar-filler,.yashe .CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.yashe .CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.yashe .CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.yashe .CodeMirror-scrollbar-filler{right:0;bottom:0}.yashe .CodeMirror-gutter-filler{left:0;bottom:0}.yashe .CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.yashe .CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px;*zoom:1;*display:inline}.yashe .CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none!important;border:none!important}.yashe .CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.yashe .CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.yashe .CodeMirror-gutter-wrapper{-webkit-user-select:none;user-select:none}.yashe .CodeMirror-lines{cursor:text;min-height:1px}.yashe .CodeMirror pre{border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;font-variant-ligatures:none}.yashe .CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.yashe .CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.yashe .CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.yashe .CodeMirror-code{outline:none}.yashe .CodeMirror-gutter,.yashe .CodeMirror-gutters,.yashe .CodeMirror-linenumber,.yashe .CodeMirror-scroll,.yashe .CodeMirror-sizer{box-sizing:content-box}.yashe .CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.yashe .CodeMirror-cursor{position:absolute;pointer-events:none}.yashe .CodeMirror-measure pre{position:static}.yashe div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.yashe .CodeMirror-focused div.CodeMirror-cursors,.yashe div.CodeMirror-dragcursors{visibility:visible}.yashe .CodeMirror-selected{background:#d9d9d9}.yashe .CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.yashe .CodeMirror-crosshair{cursor:crosshair}.yashe .CodeMirror-line::selection,.yashe .CodeMirror-line>span::selection,.yashe .CodeMirror-line>span>span::selection{background:#d7d4f0}.yashe .CodeMirror-line::-moz-selection,.yashe .CodeMirror-line>span::-moz-selection,.yashe .CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.yashe .cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.yashe .CodeMirror span{*vertical-align:text-bottom}.yashe .cm-force-border{padding-right:.1px}@media print{.yashe .CodeMirror div.CodeMirror-cursors{visibility:hidden}}.yashe .cm-tab-wrap-hack:after{content:""}.yashe span.CodeMirror-selectedtext{background:none}.yashe .CodeMirror-fullscreen{position:fixed;top:0;left:0;right:0;bottom:0;height:auto}.yashe .CodeMirror-foldmarker{color:blue;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px;font-family:arial;line-height:.3;cursor:pointer}.yashe .CodeMirror-foldgutter{width:.7em}.yashe .CodeMirror-foldgutter-folded,.yashe .CodeMirror-foldgutter-open{cursor:pointer}.yashe .CodeMirror-foldgutter-open:after{content:"\25BE"}.yashe .CodeMirror-foldgutter-folded:after{content:"\25B8"}.yashe .yashe_btn{color:#333;border:1px solid transparent;background-color:#fff;border-color:#ccc;border-width:1px;display:inline-block;text-align:center;vertical-align:middle;cursor:pointer;white-space:nowrap;padding:6px 12px;border-radius:4px;-webkit-user-select:none;user-select:none;-webkit-appearance:button;overflow:visible;box-sizing:border-box}.yashe .yashe_btn.btn_icon{padding:4px 8px}.yashe .yashe_btn.disabled,.yashe .yashe_btn[disabled]{cursor:default;opacity:.5;filter:alpha(opacity=50);box-shadow:none}.yashe .yashe_btn:hover{outline:0;background-color:#ebebeb;border-color:#adadad}.yashe .yashe_btn.selected,.yashe .yashe_btn:focus{color:#fff;outline:0;background-color:#337ab7;border-color:#337ab7}.yashe .yashe_btn.btn_icon:focus{color:#333;border:1px solid transparent;background-color:#fff;border-color:#ccc}.yashe .yashe_btn.yashe_btn-sm{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.yashe .yashe_buttons{background:transparent;position:absolute;top:5px;right:5px;z-index:5}.yashe .yashe_buttons .yashe_share{cursor:pointer;height:20px;width:20px;margin-top:3px}.yashe .yashe_buttons div{vertical-align:top;margin-left:5px}.yashe .yashe_buttons div.yashe_sharePopup{position:absolute;padding:4px;margin-left:0;background-color:#fff;border:1px solid #e3e3e3;border-radius:4px;box-shadow:inset 0 1px 1px rgba(0,0,0,.05);width:600px;height:auto;display:flex}.yashe .yashe_buttons div.yashe_sharePopup .inputWrapper{flex-grow:100}.yashe .yashe_buttons div.yashe_sharePopup input{float:left;width:100%;border:0;-ms-box-sizing:border-box;-khtml-box-sizing:border-box;box-sizing:border-box}.yashe .yashe_buttons div.yashe_sharePopup button{float:right;margin-left:5px}.yashe .yashe_buttons div.yashe_sharePopup textarea{width:100%}.yashe .fullscreenToggleBtns{display:inline-block;margin-top:4px;margin-right:16px}.yashe .fullscreenToggleBtns div{cursor:pointer;width:20px;height:20px}.yashe .fullscreenToggleBtns .yashe_smallscreenBtn{display:none}.yashe .yashe_smallscreenBtn:hover{filter:invert(.4) sepia(.5) hue-rotate(.87turn) saturate(16.2) brightness(1.7)}.yashe .yashe_smallscreenBtn:active{fill:#da4567;transform:translateY(4px)}.yashe .yashe_fullscreenBtn:hover{filter:invert(.4) sepia(.5) hue-rotate(.87turn) saturate(16.2) brightness(1.7)}.yashe .yashe_fullscreenBtn:active{fill:#da4567;transform:translateY(4px)}.yashe .downloadBtns{display:inline-block;margin:2px}.yashe .downloadBtns div{cursor:pointer;width:20px;height:20px}.yashe .downloadBtns:hover{filter:invert(.4) sepia(.5) hue-rotate(.87turn) saturate(16.2) brightness(1.7)}.yashe .downloadBtns:active{fill:#da4567;transform:translateY(4px)}.yashe .inputfileBtn{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}.yashe .inputfileBtn+label{margin-top:3px;max-width:100%;font-size:1.25rem;font-weight:500;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;display:inline-block;overflow:hidden;color:#000;background-color:transparent}.yashe .yashe_downloadBtn{margin-top:2px;display:inline-block}.yashe .CodeMirror{line-height:1.5em;border:1px solid #d1d1d1}.yashe pre{font-size:13px}.yashe span.cm-error{border-bottom:2px dotted red}.yashe .gutterErrorBar{width:4px}.yashe .CodeMirror-fullscreen .fullscreenToggleBtns .yashe_smallscreenBtn{display:inline-block}.yashe .CodeMirror-fullscreen .fullscreenToggleBtns .yashe_fullscreenBtn{display:none}.yashe .CodeMirror-foldmarker{color:#6e2500;text-shadow:#ff935e 1px 1px 2px,#ff935e -1px -1px 2px,#ff935e 1px -1px 2px,#ff935e -1px 1px 2px;font-size:19px}.yashe .matchingVar{background-color:#dbdeed;border-radius:6px;transition:background .5s linear}.yashe .backdrop{background-color:#000;opacity:.5;position:absolute;top:0;left:0;right:0;bottom:0;z-index:5;display:none}.yashe .svgImg{display:inline-block}.yashe .CodeMirror-fullscreen{z-index:1100}.yashe span.shortlinkErr{font-size:small;color:red;font-weight:700;float:left}.yashe .completionNotification{color:#999;background-color:#f7f7f7;position:absolute;padding:0 5px;right:0;bottom:0;font-size:90%}.yashe .parseErrorIcon{width:15px;height:15px}.yashe .yashe_tooltip{display:inline;background:#333;background:rgba(0,0,0,.8);border-radius:5px;bottom:26px;color:#fff;left:20%;padding:5px 15px;position:absolute;width:220px;white-space:-moz-pre-wrap!important;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;white-space:normal}.yashe .notificationLoader{width:18px;height:18px;vertical-align:middle}.CodeMirror-hints{position:absolute;z-index:10;overflow:hidden;list-style:none;margin:0;padding:2px;box-shadow:2px 3px 5px rgba(0,0,0,.2);border-radius:3px;border:1px solid silver;background:#fff;font-size:90%;font-family:monospace;max-height:20em;overflow-y:auto;z-index:1200}.CodeMirror-hint{margin:0;padding:0 4px;border-radius:2px;white-space:pre;color:#000;cursor:pointer}li.CodeMirror-hint-active{background:#08f;color:#fff}.CodeMirror-hint{max-width:30em} \ No newline at end of file +.yashe{position:relative}.yashe .cm-s-wiki .cm-shape{color:#0f7a50}.yashe .cm-s-wiki .cm-keyword{color:red}.yashe .cm-s-wiki .cm-atom{color:#219}.yashe .cm-s-wiki .cm-number{color:#085}.yashe .cm-s-wiki .cm-def{color:#00f}.yashe .cm-s-default .cm-punctuation,.yashe .cm-s-wiki .cm-operator,.yashe .cm-s-wiki .cm-property,.yashe .cm-s-wiki .cm-variable{color:#05a}.yashe .cm-s-wiki .cm-variable-2{color:#0f7a50}.yashe .cm-s-wiki .cm-variable-3{color:#05a}.yashe .cm-s-wiki .cm-comment{color:#999}.yashe .cm-s-wiki .cm-string{color:#b98003}.yashe .cm-s-wiki .cm-constraint,.yashe .cm-s-wiki .cm-string-2,.yashe .cm-s-wiki .cm-valueSet{color:#05a}.yashe .cm-s-wiki .cm-constraintKeyword,.yashe .cm-s-wiki .cm-facet{color:red}.yashe .cm-s-wiki .cm-meta,.yashe .cm-s-wiki .cm-qualifier{color:#555}.yashe .cm-s-wiki .cm-builtin{color:#30a}.yashe .cm-s-wiki .cm-bracket{color:#997}.yashe .cm-s-wiki .cm-tag{color:#170}.yashe .cm-s-wiki .cm-attribute{color:#00c}.yashe .cm-s-wiki .cm-hr{color:#999}.yashe .cm-s-wiki .cm-link{color:#00c}.yashe .cm-s-wiki .cm-punc{color:#000}.yashe .cm-s-wiki .cm-logical{color:red}.yashe .cm-s-wiki .cm-at{color:#0f7a50}.yashe .cm-s-wiki .cm-prefixDelc{color:#6d0f7a}.yashe .cm-s-dark.CodeMirror{background:#2b2b2b;color:#a9b7c6;border:10px}.yashe .cm-s-dark .cm-shape{color:#68beeb}.yashe .cm-s-dark .cm-keyword{color:red}.yashe .cm-s-dark .cm-atom{color:#219}.yashe .cm-s-dark .cm-number{color:#e5f439}.yashe .cm-s-dark .cm-def{color:#00f}.yashe .cm-s-dark .cm-operator,.yashe .cm-s-dark .cm-property,.yashe .cm-s-dark .cm-punctuation,.yashe .cm-s-dark .cm-variable{color:#05a}.yashe .cm-s-dark .cm-variable-2,.yashe .cm-s-dark .cm-variable-3{color:#68beeb}.yashe .cm-s-dark .cm-comment{color:#999}.yashe .cm-s-dark .cm-string{color:#b98003}.yashe .cm-s-dark .cm-constraint,.yashe .cm-s-dark .cm-string-2,.yashe .cm-s-dark .cm-valueSet{color:#7db647}.yashe .cm-s-dark .cm-constraintKeyword{color:red}.yashe .cm-s-dark .cm-meta,.yashe .cm-s-dark .cm-qualifier{color:#555}.yashe .cm-s-dark .cm-builtin{color:#30a}.yashe .cm-s-dark .cm-bracket{color:#997}.yashe .cm-s-dark .cm-tag{color:#170}.yashe .cm-s-dark .cm-attribute{color:#00c}.yashe .cm-s-dark .cm-hr{color:#999}.yashe .cm-s-dark .cm-link{color:#00c}.yashe .cm-s-dark .cm-punc{color:#fff}.yashe .cm-s-dark .cm-logical{color:#b271ff}.yashe .cm-s-dark .cm-at{color:#68beeb}.yashe .cm-s-dark .cm-prefixDelc{color:#f8c4ffc0}.yashe .cm-s-dark .CodeMirror-cursor{border-left:1px solid #a9b7c6}.yashe .cm-s-dark .CodeMirror-activeline-background{background:#323232}.yashe .cm-s-dark .CodeMirror-gutters{background:#313335;border-right:1px solid #313335}.yashe .cm-s-dark .CodeMirror-guttermarker{color:#ffee80}.yashe .cm-s-dark .CodeMirror-guttermarker-subtle{color:#d0d0d0}.yashe .cm-s-dark .CodeMirrir-linenumber{color:#606366}.yashe .cm-s-dark .CodeMirror-matchingbracket{background-color:#3b514d;color:#ffef28!important;font-weight:700}.yashe .cm-s-dark div.CodeMirror-selected{background:#214283}.yashe .CodeMirror-hints.dark{color:#9c9e9e;background-color:#3b3e3f!important}.yashe .CodeMirror-hints.dark .CodeMirror-hint-active{background-color:#494d4e!important;color:#9c9e9e!important}.yashe .CodeMirror{font-family:monospace;height:300px;color:#000;font-size:14px}.yashe .CodeMirror-lines{padding:4px 0}.yashe .CodeMirror pre{padding:0 4px}.yashe .CodeMirror-gutter-filler,.yashe .CodeMirror-scrollbar-filler{background-color:#fff}.yashe .CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f8f8f8;white-space:nowrap}.yashe .CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.yashe .CodeMirror-guttermarker{color:#000}.yashe .CodeMirror-guttermarker-subtle{color:#999}.yashe .CodeMirror-cursor{border-left:1px solid red;border-right:none;width:0}.yashe .CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.yashe .cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.yashe .cm-fat-cursor div.CodeMirror-cursors{z-index:1}.yashe .cm-animate-fat-cursor{width:auto;border:0;animation:a 1.06s steps(1) infinite;background-color:#7e7}@keyframes a{50%{background-color:transparent}}.yashe .cm-tab{display:inline-block;text-decoration:inherit}.yashe .CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:-20px;overflow:hidden}.yashe .CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.yashe .cm-s-default .cm-header{color:blue}.yashe .cm-s-default .cm-quote{color:#090}.yashe .cm-negative{color:#d44}.yashe .cm-positive{color:#292}.yashe .cm-header,.yashe .cm-strong{font-weight:700}.yashe .cm-em{font-style:italic}.yashe .cm-link{text-decoration:underline}.yashe .cm-strikethrough{text-decoration:line-through}.yashe .cm-s-default .cm-keyword{color:red}.yashe .cm-s-default .cm-atom{color:#219}.yashe .cm-s-default .cm-number{color:#085}.yashe .cm-s-default .cm-def{color:#00f}.yashe .cm-s-default .cm-operator,.yashe .cm-s-default .cm-property,.yashe .cm-s-default .cm-punctuation,.yashe .cm-s-default .cm-variable{color:#05a}.yashe .cm-s-default .cm-variable-2{color:#0f7a50}.yashe .cm-s-default .cm-variable-3{color:#05a}.yashe .cm-s-default .cm-comment{color:#999}.yashe .cm-s-default .cm-string{color:#b98003}.yashe .cm-s-default .cm-string-2{color:#05a}.yashe .cm-s-default .cm-meta,.yashe .cm-s-default .cm-qualifier{color:#555}.yashe .cm-s-default .cm-builtin{color:#30a}.yashe .cm-s-default .cm-bracket{color:#997}.yashe .cm-s-default .cm-tag{color:#170}.yashe .cm-s-default .cm-attribute{color:#00c}.yashe .cm-s-default .cm-hr{color:#999}.yashe .cm-s-default .cm-link{color:#00c}.yashe .cm-s-default .cm-punc{color:#000}.yashe .cm-s-default .cm-logical{color:red}.yashe .cm-s-default .cm-at{color:#0f7a50}.yashe .cm-invalidchar,.yashe .cm-s-default .cm-error{color:red}.yashe .CodeMirror-composing{border-bottom:2px solid}.yashe .CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.yashe .CodeMirror-activeline-background{background:#e8f2ff}.yashe .CodeMirror{position:relative;overflow:hidden;background:#fff}.yashe .CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative}.yashe .CodeMirror-sizer{position:relative;border-right:30px solid transparent}.yashe .CodeMirror-gutter-filler,.yashe .CodeMirror-hscrollbar,.yashe .CodeMirror-scrollbar-filler,.yashe .CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.yashe .CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.yashe .CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.yashe .CodeMirror-scrollbar-filler{right:0;bottom:0}.yashe .CodeMirror-gutter-filler{left:0;bottom:0}.yashe .CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.yashe .CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px;*zoom:1;*display:inline}.yashe .CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:none!important;border:none!important}.yashe .CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.yashe .CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.yashe .CodeMirror-gutter-wrapper{-webkit-user-select:none;user-select:none}.yashe .CodeMirror-lines{cursor:text;min-height:1px}.yashe .CodeMirror pre{border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;font-variant-ligatures:none}.yashe .CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.yashe .CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.yashe .CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.yashe .CodeMirror-code{outline:none}.yashe .CodeMirror-gutter,.yashe .CodeMirror-gutters,.yashe .CodeMirror-linenumber,.yashe .CodeMirror-scroll,.yashe .CodeMirror-sizer{box-sizing:content-box}.yashe .CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.yashe .CodeMirror-cursor{position:absolute;pointer-events:none}.yashe .CodeMirror-measure pre{position:static}.yashe div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.yashe .CodeMirror-focused div.CodeMirror-cursors,.yashe div.CodeMirror-dragcursors{visibility:visible}.yashe .CodeMirror-selected{background:#d9d9d9}.yashe .CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.yashe .CodeMirror-crosshair{cursor:crosshair}.yashe .CodeMirror-line::selection,.yashe .CodeMirror-line>span::selection,.yashe .CodeMirror-line>span>span::selection{background:#d7d4f0}.yashe .CodeMirror-line::-moz-selection,.yashe .CodeMirror-line>span::-moz-selection,.yashe .CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.yashe .cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.yashe .CodeMirror span{*vertical-align:text-bottom}.yashe .cm-force-border{padding-right:.1px}@media print{.yashe .CodeMirror div.CodeMirror-cursors{visibility:hidden}}.yashe .cm-tab-wrap-hack:after{content:""}.yashe span.CodeMirror-selectedtext{background:none}.yashe .CodeMirror-fullscreen{position:fixed;top:0;left:0;right:0;bottom:0;height:auto}.yashe .CodeMirror-foldmarker{color:blue;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px;font-family:arial;line-height:.3;cursor:pointer}.yashe .CodeMirror-foldgutter{width:.7em}.yashe .CodeMirror-foldgutter-folded,.yashe .CodeMirror-foldgutter-open{cursor:pointer}.yashe .CodeMirror-foldgutter-open:after{content:"\25BE"}.yashe .CodeMirror-foldgutter-folded:after{content:"\25B8"}.yashe .yashe_btn{color:#333;border:1px solid transparent;background-color:#fff;border-color:#ccc;border-width:1px;display:inline-block;text-align:center;vertical-align:middle;cursor:pointer;white-space:nowrap;padding:6px 12px;border-radius:4px;-webkit-user-select:none;user-select:none;-webkit-appearance:button;overflow:visible;box-sizing:border-box}.yashe .yashe_btn.btn_icon{padding:4px 8px}.yashe .yashe_btn.disabled,.yashe .yashe_btn[disabled]{cursor:default;opacity:.5;filter:alpha(opacity=50);box-shadow:none}.yashe .yashe_btn:hover{outline:0;background-color:#ebebeb;border-color:#adadad}.yashe .yashe_btn.selected,.yashe .yashe_btn:focus{color:#fff;outline:0;background-color:#337ab7;border-color:#337ab7}.yashe .yashe_btn.btn_icon:focus{color:#333;border:1px solid transparent;background-color:#fff;border-color:#ccc}.yashe .yashe_btn.yashe_btn-sm{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.yashe .yashe_buttons{background:transparent;position:absolute;top:5px;right:5px;z-index:5}.yashe .yashe_buttons .yashe_share{cursor:pointer;height:20px;width:20px;margin-top:3px}.yashe .yashe_buttons div{vertical-align:top;margin-left:5px}.yashe .yashe_buttons div.yashe_sharePopup{position:absolute;padding:4px;margin-left:0;background-color:#fff;border:1px solid #e3e3e3;border-radius:4px;box-shadow:inset 0 1px 1px rgba(0,0,0,.05);width:600px;height:auto;display:flex}.yashe .yashe_buttons div.yashe_sharePopup .inputWrapper{flex-grow:100}.yashe .yashe_buttons div.yashe_sharePopup input{float:left;width:100%;border:0;-ms-box-sizing:border-box;-khtml-box-sizing:border-box;box-sizing:border-box}.yashe .yashe_buttons div.yashe_sharePopup button{float:right;margin-left:5px}.yashe .yashe_buttons div.yashe_sharePopup textarea{width:100%}.yashe .fullscreenToggleBtns{display:inline-block;margin-top:4px;margin-right:16px}.yashe .fullscreenToggleBtns div{cursor:pointer;width:20px;height:20px}.yashe .fullscreenToggleBtns .yashe_smallscreenBtn{display:none}.yashe .yashe_smallscreenBtn:hover{filter:invert(.4) sepia(.5) hue-rotate(.87turn) saturate(16.2) brightness(1.7)}.yashe .yashe_smallscreenBtn:active{fill:#da4567;transform:translateY(4px)}.yashe .yashe_fullscreenBtn:hover{filter:invert(.4) sepia(.5) hue-rotate(.87turn) saturate(16.2) brightness(1.7)}.yashe .yashe_fullscreenBtn:active{fill:#da4567;transform:translateY(4px)}.yashe .downloadBtns{display:inline-block;margin:2px}.yashe .downloadBtns div{cursor:pointer;width:20px;height:20px}.yashe .downloadBtns:hover{filter:invert(.4) sepia(.5) hue-rotate(.87turn) saturate(16.2) brightness(1.7)}.yashe .downloadBtns:active{fill:#da4567;transform:translateY(4px)}.yashe .inputfileBtn{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}.yashe .inputfileBtn+label{margin-top:3px;max-width:100%;font-size:1.25rem;font-weight:500;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;display:inline-block;overflow:hidden;color:#000;background-color:transparent}.yashe .yashe_downloadBtn{margin-top:2px;display:inline-block}.yashe .CodeMirror{line-height:1.5em;border:1px solid #d1d1d1}.yashe pre{font-size:13px}.yashe span.cm-error{border-bottom:2px dotted red}.yashe .gutterErrorBar{width:4px}.yashe .CodeMirror-fullscreen .fullscreenToggleBtns .yashe_smallscreenBtn{display:inline-block}.yashe .CodeMirror-fullscreen .fullscreenToggleBtns .yashe_fullscreenBtn{display:none}.yashe .CodeMirror-foldmarker{color:#6e2500;text-shadow:#ff935e 1px 1px 2px,#ff935e -1px -1px 2px,#ff935e 1px -1px 2px,#ff935e -1px 1px 2px;font-size:19px}.yashe .matchingVar{background-color:#dbdeed;border-radius:6px;transition:background .5s linear}.yashe .backdrop{background-color:#000;opacity:.5;position:absolute;top:0;left:0;right:0;bottom:0;z-index:5;display:none}.yashe .svgImg{display:inline-block}.yashe .CodeMirror-fullscreen{z-index:1100}.yashe span.shortlinkErr{font-size:small;color:red;font-weight:700;float:left}.yashe .completionNotification{color:#999;background-color:#f7f7f7;position:absolute;padding:0 5px;right:0;bottom:0;font-size:90%}.yashe .parseErrorIcon{width:15px;height:15px}.yashe .yashe_tooltip{display:inline;background:#333;background:rgba(0,0,0,.8);border-radius:5px;bottom:26px;color:#fff;left:20%;padding:5px 15px;position:absolute;width:220px;white-space:-moz-pre-wrap!important;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;white-space:normal}.yashe .notificationLoader{width:18px;height:18px;vertical-align:middle}.CodeMirror-hints{position:absolute;z-index:10;overflow:hidden;list-style:none;margin:0;padding:2px;box-shadow:2px 3px 5px rgba(0,0,0,.2);border-radius:3px;border:1px solid silver;background:#fff;font-size:90%;font-family:monospace;max-height:20em;overflow-y:auto;z-index:1200}.CodeMirror-hint{margin:0;padding:0 4px;border-radius:2px;white-space:pre;color:#000;cursor:pointer}li.CodeMirror-hint-active{background:#08f;color:#fff}.CodeMirror-hint{max-width:30em} \ No newline at end of file diff --git a/doc/examples/wiki.js b/doc/examples/wiki.js new file mode 100644 index 00000000..b0526f1e --- /dev/null +++ b/doc/examples/wiki.js @@ -0,0 +1,4006 @@ +export const SchemaEntities = [ + { + "id" : "E1", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E1", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E1", + "title" : "ShExR (E1) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "ShExR", + "descr" : "Schéma de Shex", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "ShExR", + "descr" : "schema per ShEx", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "ShExR", + "descr" : "Basis schema voor een vorm expression", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "ShExR", + "descr" : "Schema für ShEx", + "aliases" : "" + }, + "tr" : { + "lang" : "tr", + "label" : "ShExR", + "descr" : "ShEx için şema", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "ShExR", + "descr" : "Schema of ShEx", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "ShExR", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E2", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E2", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E2", + "title" : "Wikimedia (E2) - Wikidata", + "labels" : { + "lv" : { + "lang" : "lv", + "label" : "Wikimedia", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "Wikimedia", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Wikimedia", + "descr" : "schema per i progetti Wikimedia", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Wikimedia", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Wikimedia", + "descr" : "Schema of Wikimedia projects in Wikidata", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "Wikimedia", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E3", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E3", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E3", + "title" : "Wikidata Item (E3) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Wikidata Item", + "descr" : "Schema of a Wikidata item", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "élément Wikidata", + "descr" : "", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "Wikidata elem", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "elemento Wikidata", + "descr" : "schema per un elemento Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E4", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E4", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E4", + "title" : "Labels/Descriptions (E4) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Labels/Descriptions", + "descr" : "Schema of labels and descriptions", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "Libellés/Descriptions", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Etichetta/Descrizione", + "descr" : "schema per etichette e descrizioni di un elemento", + "aliases" : "" + } + } + }, + { + "id" : "E5", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E5", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E5", + "title" : "Statement (E5) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Statement", + "descr" : "Schema of a Statement", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "Déclaration", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Dichiarazione", + "descr" : "schema per una dichiarazione in un elemento", + "aliases" : "" + } + } + }, + { + "id" : "E6", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E6", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E6", + "title" : "Language mappings (E6) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Language mappings", + "descr" : "Schema for language mappings in Wikidata", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Mappatura lingue", + "descr" : "schema per mappare le lingue", + "aliases" : "" + } + } + }, + { + "id" : "E7", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E7", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E7", + "title" : "Citation (E7) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "Note", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "citação", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Nota/Citazione/Fonte", + "descr" : "schema per una nota/citazione/fonte", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Citation", + "descr" : "Schema of a Citation", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "Forráshivatkozás", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E8", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E8", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E8", + "title" : "External RDF (E8) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "RDF externe", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "RDF externo", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "RDF (esterna)", + "descr" : "schema per una nota/citazione/fonte (esterna)", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "External RDF", + "descr" : "Schema of a Citation", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "Külső RDF", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E9", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E9", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E9", + "title" : "Wikidata-Wikibase (E9) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Wikidata-Wikibase", + "descr" : "Schema linking wikibase and wikidata", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "Wikidata-Wikibase", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Link Wikibase-Wikidata", + "descr" : "schema per i link fra Wikibase e Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E10", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E10", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E10", + "title" : "human (E10) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "humain", + "descr" : "schéma simple pour un être humain", + "aliases" : "personne" + }, + "lv" : { + "lang" : "lv", + "label" : "cilvēks", + "descr" : "", + "aliases" : "persona" + }, + "it" : { + "lang" : "it", + "label" : "umano", + "descr" : "schema per descrivere un essere umano", + "aliases" : "persona | individuo | essere umano" + }, + "nl" : { + "lang" : "nl", + "label" : "mens", + "descr" : "simpel schema voor mensen", + "aliases" : "persoon" + }, + "ko" : { + "lang" : "ko", + "label" : "사람", + "descr" : "", + "aliases" : "인간 | 인물" + }, + "fy" : { + "lang" : "fy", + "label" : "minske", + "descr" : "", + "aliases" : "persoan" + }, + "ru" : { + "lang" : "ru", + "label" : "человек", + "descr" : "простая схема для людей", + "aliases" : "персона | персоналия" + }, + "en" : { + "lang" : "en", + "label" : "human", + "descr" : "simple schema for humans", + "aliases" : "person | human being" + }, + "sk" : { + "lang" : "sk", + "label" : "osoba", + "descr" : "schéma pre dátové položky ľudí", + "aliases" : "človek" + }, + "es" : { + "lang" : "es", + "label" : "ser humano", + "descr" : "esquema simple para una persona", + "aliases" : "persona" + }, + "ja" : { + "lang" : "ja", + "label" : "ヒト", + "descr" : "", + "aliases" : "人間" + }, + "fi" : { + "lang" : "fi", + "label" : "ihminen", + "descr" : "yksinkertainen skeema kohteelle ihminen", + "aliases" : "henkilö" + }, + "hu" : { + "lang" : "hu", + "label" : "ember", + "descr" : "", + "aliases" : "személy" + }, + "pt" : { + "lang" : "pt", + "label" : "humano", + "descr" : "esquema simples para humanos", + "aliases" : "" + }, + "cs" : { + "lang" : "cs", + "label" : "osoba", + "descr" : "", + "aliases" : "člověk" + }, + "gl" : { + "lang" : "gl", + "label" : "ser humano", + "descr" : "esquema simple para definir unha persoa", + "aliases" : "persoa" + }, + "sr" : { + "lang" : "sr", + "label" : "особа", + "descr" : "проста шема за особу", + "aliases" : "човек" + }, + "eo" : { + "lang" : "eo", + "label" : "homo", + "descr" : "simpla skemo por homoj", + "aliases" : "persono" + }, + "et" : { + "lang" : "et", + "label" : "inimene", + "descr" : "lihtne skeem inimese jaoks", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Mensch", + "descr" : "einfaches Schema für Objekte über Menschen", + "aliases" : "Person" + }, + "sv" : { + "lang" : "sv", + "label" : "människa", + "descr" : "ett enklare schema för människor", + "aliases" : "" + }, + "tr" : { + "lang" : "tr", + "label" : "insan", + "descr" : "insanlar için basit şema", + "aliases" : "kişi" + }, + "da" : { + "lang" : "da", + "label" : "menneske", + "descr" : "", + "aliases" : "person" + } + } + }, + { + "id" : "E11", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E11", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E11", + "title" : "film festival (E11) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "Festival de films", + "descr" : "", + "aliases" : "" + }, + "lv" : { + "lang" : "lv", + "label" : "kinofestivāls", + "descr" : "", + "aliases" : "kino festivāls | filmu festivāls" + }, + "bn" : { + "lang" : "bn", + "label" : "চলচ্চিত্র উৎসব", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "festival cinematografico", + "descr" : "schema per descrivere un festival cinematografico", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "filmfestival", + "descr" : "Schema voor een filmfestival", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "film festival", + "descr" : "scheme for film festivals", + "aliases" : "" + }, + "es" : { + "lang" : "es", + "label" : "festival cinematográfico", + "descr" : "", + "aliases" : "festival de cine" + }, + "fi" : { + "lang" : "fi", + "label" : "elokuvafestivaali", + "descr" : "", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "filmfesztivál", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "festival cinematográfico", + "descr" : "", + "aliases" : "" + }, + "cs" : { + "lang" : "cs", + "label" : "filmový festival", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "filmfestivalo", + "descr" : "", + "aliases" : "filmofestivalo" + }, + "de" : { + "lang" : "de", + "label" : "Filmfestival", + "descr" : "Schema für ein Filmfestival", + "aliases" : "Filmfest" + }, + "sv" : { + "lang" : "sv", + "label" : "filmfestival", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "filmfestival", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E12", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E12", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E12", + "title" : "film festival edition (E12) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "édition d'un festival de films", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "edição de festival cinematográfico", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "edizione festival cinematografico", + "descr" : "schema per descrivere un'edizione di un festival cinematografico", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "filmfestivalsudgave", + "descr" : "udgave af filmfestival", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "film festival edition", + "descr" : "scheme for film festival editions", + "aliases" : "" + } + } + }, + { + "id" : "E13", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E13", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E13", + "title" : "natural number (E13) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "nombre naturel", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "numero naturale", + "descr" : "schema per descrivere un numero naturale", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "natuurlijk getal", + "descr" : "schema voor een natuurlijk getal", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "natura nombro", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "natural number", + "descr" : "basic scheme for natural numbers", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "természetes szám", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "número natural", + "descr" : "", + "aliases" : "" + }, + "cs" : { + "lang" : "cs", + "label" : "přirozené číslo", + "descr" : "", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "naturligt tal", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "naturligt tal", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E14", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E14", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E14", + "title" : "human (basic properties) (E14) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "humain (propriétés de base)", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "ser humano (propriedades básicas)", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "essere umano (base)", + "descr" : "schema per descrivere un essere umano (proprietà base)", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Mensch", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "human (basic properties)", + "descr" : "scheme for humans with basic properties", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "ember (alaptulajdonságok)", + "descr" : "", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "människa", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "menneske", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E15", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E15", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E15", + "title" : "Danish Lexeme (E15) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "lexème danois", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "lexema danês", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "lessema (danese)", + "descr" : "schema per descrivere un lessema in lingua danese", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "dana leksemo", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk leksem", + "descr" : "leksemer på dansk", + "aliases" : "danske leksemer | leksem på dansk" + }, + "en" : { + "lang" : "en", + "label" : "Danish Lexeme", + "descr" : "", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "dán lexéma", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E16", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E16", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E16", + "title" : "Software Titles (E16) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "programme informatique", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "programa informático", + "descr" : "", + "aliases" : "software" + }, + "it" : { + "lang" : "it", + "label" : "software", + "descr" : "schema per descrivere un software", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Software Titles", + "descr" : "schema for Wikidata statements related to software", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "Mjukvarutitel", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "software", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E17", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E17", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E17", + "title" : "television series (E17) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "série télévisée", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "série de televisão", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "serie TV", + "descr" : "schema per descrivere una serie televisiva (proprietà base, senza identificatori)", + "aliases" : "serie televisiva" + }, + "en" : { + "lang" : "en", + "label" : "television series", + "descr" : "basic scheme for television series, without identifiers", + "aliases" : "" + }, + "es" : { + "lang" : "es", + "label" : "serie de televisión", + "descr" : "esquema simple para una serie de televisión", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "tévésorozat", + "descr" : "", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "TV serie", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "tv-serie", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E18", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E18", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E18", + "title" : "television series season (E18) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "saison de série télévisée", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "temporada de série de televisão", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "stagione serie TV", + "descr" : "schema per descrivere una stagione di una serie televisiva (proprietà base, senza identificatori)", + "aliases" : "stagione serie televisiva" + }, + "en" : { + "lang" : "en", + "label" : "television series season", + "descr" : "basic scheme for television series season, without identifiers", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "tévésorozat évad", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E19", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E19", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E19", + "title" : "television series episode (E19) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "épisode de série télévisée", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "episódio de série de televisão", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "episodio serie TV", + "descr" : "schema per descrivere un episodio di una serie televisiva (proprietà base, senza identificatori)", + "aliases" : "episodio serie televisiva" + }, + "da" : { + "lang" : "da", + "label" : "tv-serie-episode", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "television series episode", + "descr" : "basic scheme for television series episode, without identifiers", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "tévésorozat epizód", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E20", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E20", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E20", + "title" : "EastEnders (E20) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "EastEnders", + "descr" : "full scheme for TV series", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "EastEnders", + "descr" : "série mythique britannique", + "aliases" : "" + } + } + }, + { + "id" : "E21", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E21", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E21", + "title" : "rower (E21) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "rameur", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "remador", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "canottiere/canottiera", + "descr" : "schema per descrivere un/una canottiere/a", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "roeier", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "rower", + "descr" : "schema for items about rowers, defined by P106: Q13382576 or subclass thereof", + "aliases" : "oarswoman | oarsman" + }, + "eo" : { + "lang" : "eo", + "label" : "remisto", + "descr" : "", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Ruderer", + "descr" : "Schema für Objekte über Ruderer, definiert über P106: Q13382576 oder eine Unterklasse davon", + "aliases" : "Ruderin | Rudersportlerin | Rudersportler" + } + } + }, + { + "id" : "E22", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E22", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E22", + "title" : "screenwriter (E22) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "scénariste", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "roteirista", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "sceneggiatore/sceneggiatrice", + "descr" : "schema per descrivere uno/una sceneggiatore/sceneggiatrice", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "screenwriter", + "descr" : "basic scheme for screenwriters", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "forgatókönyvíró", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E23", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E23", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E23", + "title" : "film producer (E23) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "producteur de cinéma", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "produtor cinematográfico", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "produttore/produttrice cinematografico/a", + "descr" : "schema per descrivere un/una produttore/produttrice cinematografico/a", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "filmproducer", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "film producer", + "descr" : "basic schema for film producer", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "filmproducer", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E24", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E24", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E24", + "title" : "film director (E24) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "réalisateur", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "diretor cinematográfico", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "regista", + "descr" : "schema per descrivere un/una regista", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "filminstruktør", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "film director", + "descr" : "basic scheme for film directors", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "filmrendező", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E25", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E25", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E25", + "title" : "actor (E25) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "acteur/actrice", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "actor", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "attore/attrice", + "descr" : "schema per descrivere un/una attore/attrice", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "acteur", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "aktoro", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "skuespiller", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "actor", + "descr" : "basic scheme for actor", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "színész", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E26", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E26", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E26", + "title" : "lightbulb (E26) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "ampoule", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "lâmpada", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "lampadina", + "descr" : "schema per descrivere una lampadina", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "lightbulb", + "descr" : "basic scheme for lightbulbs", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "villanykörte", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E27", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E27", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E27", + "title" : "European lightbulb (E27) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "ampoule européenne", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "lâmpada europeia", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "lampadina europea", + "descr" : "schema per descrivere una lampadina di tipo europeo", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "European lightbulb", + "descr" : "basic scheme for European lightbulbs", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "európai villanykörte", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E28", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E28", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E28", + "title" : "cinematographer (E28) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "cinematographer", + "descr" : "basic schema for cinematographer", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "directeur de la photographie", + "descr" : "", + "aliases" : "" + }, + "hu" : { + "lang" : "hu", + "label" : "operatőr", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "direttore/direttrice della fotografia", + "descr" : "schema per descrivere un/una direttore/direttrice della fotografia", + "aliases" : "" + } + } + }, + { + "id" : "E29", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E29", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E29", + "title" : "camera operator (E29) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "camera operator", + "descr" : "basic scheme for camera operators", + "aliases" : "cameraman | camerawoman" + }, + "fr" : { + "lang" : "fr", + "label" : "caméraman", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "cineoperatore/cineoperatrice", + "descr" : "schema per descrivere un/una cineoperatore/cineoperatrice", + "aliases" : "cameraman | camerawoman" + } + } + }, + { + "id" : "E30", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E30", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E30", + "title" : "Australian national parks (E30) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "parc national australien", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "parque nacional da Austrália", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "parco nazionale australiano", + "descr" : "schema per descrivere un parco nazionale dell'Australia", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "autralsk nationalpark", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Australian national parks", + "descr" : "basic schema for national parks in Australia", + "aliases" : "" + } + } + }, + { + "id" : "E31", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E31", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E31", + "title" : "File Format Families (E31) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "File Format Families", + "descr" : "schema for Wikidata statements related to file format families", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "filformat-familie", + "descr" : "", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "format de fichier", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "formato file", + "descr" : "schema per descrivere un formato o una famiglia di formati di file", + "aliases" : "" + } + } + }, + { + "id" : "E32", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E32", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E32", + "title" : "sovereign state (E32) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "état souverain", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "Estado soberano", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "Stato", + "descr" : "schema per descrivere uno Stato", + "aliases" : "" + }, + "ko" : { + "lang" : "ko", + "label" : "주권국", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "suveræn stat", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "sovereign state", + "descr" : "basic schema for sovereign states", + "aliases" : "" + } + } + }, + { + "id" : "E33", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E33", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E33", + "title" : "Kakapo (E33) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Kakapo", + "descr" : "Schema for Items about Kakapos", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "Kakapo", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E34", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E34", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E34", + "title" : "Danish noun (E34) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "substantif danois", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "substantivo (danês)", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "sostantivo (danese)", + "descr" : "schema per descrivere un sostantivo in lingua danese", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Deens zelfstandig naamwoord", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "dana substantivo", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk navneord", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Danish noun", + "descr" : "schema for Danish nouns", + "aliases" : "" + } + } + }, + { + "id" : "E35", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E35", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E35", + "title" : "written work (E35) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "written work", + "descr" : "abstract concept of a written work and its relations with its manifestations as editions", + "aliases" : "book" + }, + "fr" : { + "lang" : "fr", + "label" : "œuvre écrite", + "descr" : "concept d'une œuvre écrite et ses relations avec ses manifestations comme éditions", + "aliases" : "livre | livres" + }, + "it" : { + "lang" : "it", + "label" : "opera scritta", + "descr" : "schema per descrivere un'opera scritta (e le sue relazioni con le edizioni e manifestazioni)", + "aliases" : "libro | poesia" + }, + "pt" : { + "lang" : "pt", + "label" : "obra escrita", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E36", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E36", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E36", + "title" : "edition of a written work (E36) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "édition d'une oeuvre écrite", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "edição de obra escrita", + "descr" : "", + "aliases" : "" + }, + "gl" : { + "lang" : "gl", + "label" : "edición dunha obra escrita", + "descr" : "edición concreta dunha libro ou outra obra escrita", + "aliases" : "edición" + }, + "it" : { + "lang" : "it", + "label" : "edizione di un'opera scritta", + "descr" : "schema per descrivere un'edizione di un'opera scritta", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "utgåva av ett skriftligt verk", + "descr" : "", + "aliases" : "utgåva | upplaga | edition" + }, + "en" : { + "lang" : "en", + "label" : "edition of a written work", + "descr" : "manifestation of a written work", + "aliases" : "edition | translation | manifestation" + }, + "hu" : { + "lang" : "hu", + "label" : "írott mű kiadása", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E37", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E37", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E37", + "title" : "human gene (E37) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "gène humain", + "descr" : "schema d'un gène humain selon Gene Wiki", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "gene humano", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "gene umano", + "descr" : "schema per descrivere un gene umano", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "menselijk gen", + "descr" : "basis schema voor een menselijk gen in Wikidata volgens gene wiki", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "menneske-gen", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "human gene", + "descr" : "schema of a human gene according to Gene Wiki", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "homa geno", + "descr" : "", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Menschliches Gen", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E38", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E38", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E38", + "title" : "human protein (E38) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "protéine humaine", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "proteína humana", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "proteina umana", + "descr" : "schema per descrivere una proteina umana", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "homa proteino", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "human protein", + "descr" : "schema of a human protein according to Gene Wiki", + "aliases" : "" + } + } + }, + { + "id" : "E39", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E39", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E39", + "title" : "Reactome Pathway (E39) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Reactome Pathway", + "descr" : "schema of a reactome pathway in wikidata", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "voie métabolique", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "percorso biologico Reactome", + "descr" : "schema per descrivere un percorso biologico (con identificatore Reactome)", + "aliases" : "" + } + } + }, + { + "id" : "E40", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E40", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E40", + "title" : "European route (E40) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "route européenne", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "estrada europeia", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "strada europea", + "descr" : "schema per descrivere una strada europea", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Europese weg", + "descr" : "basis schema voor Europese wegen", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "European route", + "descr" : "basic scheme for European routes, e.g. E40", + "aliases" : "" + } + } + }, + { + "id" : "E41", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E41", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E41", + "title" : "biological pathway sourced from WikiPathways in Wikidata (E41) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "biological pathway sourced from WikiPathways in Wikidata", + "descr" : "schema for a biological pathway from wikipathways.org in Wikidata", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "percorso biologico WikiPathways", + "descr" : "schema per descrivere un percorso biologico (con identificatore WikiPathways)", + "aliases" : "" + } + } + }, + { + "id" : "E42", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E42", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E42", + "title" : "author (E42) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "auteur", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "autor", + "descr" : "", + "aliases" : "" + }, + "gl" : { + "lang" : "gl", + "label" : "autor/a", + "descr" : "esquema para definir persoas creadoras", + "aliases" : "autora | autor" + }, + "it" : { + "lang" : "it", + "label" : "autore/autrice", + "descr" : "schema per descrivere un/una autore/autrice", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "author", + "descr" : "A Schema for authors", + "aliases" : "" + }, + "es" : { + "lang" : "es", + "label" : "autor", + "descr" : "esquema para autores", + "aliases" : "" + }, + "ja" : { + "lang" : "ja", + "label" : "著者", + "descr" : "著者用のスキーマ", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "aŭtoro", + "descr" : "", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Autor", + "descr" : "", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "författare", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "forfatter", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E43", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E43", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E43", + "title" : "poem (E43) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "poem", + "descr" : "schema for a poem", + "aliases" : "piece of poetry | rhyme" + }, + "eo" : { + "lang" : "eo", + "label" : "poemo", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "poema", + "descr" : "schema per descrivere un poema", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "poema", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E44", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E44", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E44", + "title" : "University Teacher (E44) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "University Teacher", + "descr" : "", + "aliases" : "person who teaches at a university" + }, + "da" : { + "lang" : "da", + "label" : "universitetslærer", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "professore/professoressa universitario/a", + "descr" : "schema per descrivere un/una professore/professoressa universitario/a", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "professor universitário", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E45", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E45", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E45", + "title" : "university (E45) - Wikidata", + "labels" : { + "pt" : { + "lang" : "pt", + "label" : "universidade", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "università", + "descr" : "schema per descrivere una università", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "universiteit", + "descr" : "", + "aliases" : "" + }, + "ko" : { + "lang" : "ko", + "label" : "대학", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "universitato", + "descr" : "", + "aliases" : "" + }, + "fy" : { + "lang" : "fy", + "label" : "universiteit", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "university", + "descr" : "schema for a university based on the basic metadata listed at https://www.wikidata.org/wiki/Wikidata:WikiProject_Universities/Recommended_statements", + "aliases" : "" + } + } + }, + { + "id" : "E46", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E46", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E46", + "title" : "chemical element (E46) - Wikidata", + "labels" : { + "pt" : { + "lang" : "pt", + "label" : "elemento químico", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "elemento chimico", + "descr" : "schema per descrivere un elemento chimico", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "scheikundig element", + "descr" : "", + "aliases" : "chemisch element" + }, + "eo" : { + "lang" : "eo", + "label" : "ĥemia elemento", + "descr" : "", + "aliases" : "kemia elemento" + }, + "da" : { + "lang" : "da", + "label" : "kemisk element", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "chemical element", + "descr" : "Concept from chemistry allowing properties of atoms to be consistently described", + "aliases" : "" + } + } + }, + { + "id" : "E47", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E47", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E47", + "title" : "racemic mixture (E47) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "racemic mixture", + "descr" : "mixture of chemicals with the same structure but different stereochemistry", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "miscela racemica", + "descr" : "schema per descrivere una miscela racemica", + "aliases" : "" + } + } + }, + { + "id" : "E48", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E48", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E48", + "title" : "human (E48) - Wikidata", + "labels" : { + "nl" : { + "lang" : "nl", + "label" : "mens", + "descr" : "", + "aliases" : "" + }, + "fy" : { + "lang" : "fy", + "label" : "minske", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "human", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "homo", + "descr" : "", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Mensch", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E49", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E49", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E49", + "title" : "Wikidata prefixes (E49) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Wikidata prefixes", + "descr" : "default prefixes", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "prefissi Wikidata", + "descr" : "schema per descrivere i prefissi SPARQL di Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E50", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E50", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E50", + "title" : "NationalFlag (E50) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "NationalFlag", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E51", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E51", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E51", + "title" : "hyperpolyglot (E51) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "hyperpolyglot", + "descr" : "basic scheme", + "aliases" : "" + } + } + }, + { + "id" : "E52", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E52", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E52", + "title" : "given names in Spain (E52) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "given names in Spain", + "descr" : "basic scheme for frequent given names in Spain", + "aliases" : "" + } + } + }, + { + "id" : "E53", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E53", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E53", + "title" : "sportsperson (E53) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "sportsperson", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "sportsudøver", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "desportista", + "descr" : "", + "aliases" : "esportista" + } + } + }, + { + "id" : "E54", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E54", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E54", + "title" : "lexeme (E54) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "lexeme", + "descr" : "schema for lexemes", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "leksem", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "leksemo", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "lexema", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E55", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E55", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E55", + "title" : "programming language (E55) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "programming language", + "descr" : "simple schema for programming language", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "linguagem de programação", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E56", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E56", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E56", + "title" : "Danish verb (E56) - Wikidata", + "labels" : { + "pt" : { + "lang" : "pt", + "label" : "verbo (danês)", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Deens werkwoord", + "descr" : "basisschema voor een Deens werkwoord", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "dana verbo", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk udsagnsord", + "descr" : "", + "aliases" : "dansk verbum | danske verber" + }, + "en" : { + "lang" : "en", + "label" : "Danish verb", + "descr" : "basic schema for Danish verbs", + "aliases" : "" + } + } + }, + { + "id" : "E57", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E57", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E57", + "title" : "gay pride (E57) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "gay pride", + "descr" : "", + "aliases" : "" + }, + "ca" : { + "lang" : "ca", + "label" : "pride", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "pride", + "descr" : "schema per un pride", + "aliases" : "gay pride" + } + } + }, + { + "id" : "E58", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E58", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E58", + "title" : "LGBT flag (E58) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "LGBT flag", + "descr" : "", + "aliases" : "" + }, + "ca" : { + "lang" : "ca", + "label" : "bandera LGBT", + "descr" : "", + "aliases" : "" + }, + "it" : { + "lang" : "it", + "label" : "bandiere LGBT", + "descr" : "schema per le bandiere legate al mondo LGBT+", + "aliases" : "" + } + } + }, + { + "id" : "E59", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E59", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E59", + "title" : "evidence and conclusion ontology term (E59) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "evidence and conclusion ontology term", + "descr" : "schema for terms from the evidence and conclusion ontology", + "aliases" : "" + } + } + }, + { + "id" : "E60", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E60", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E60", + "title" : "cellosaurus cell line (E60) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "cellosaurus cell line", + "descr" : "schema for a cellosaurus cell line in Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E61", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E61", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E61", + "title" : "kakapo schema (E61) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "kakapo schema", + "descr" : "schema for kakapo individuals on wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E62", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E62", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E62", + "title" : "Danish pronouns (E62) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Danish pronouns", + "descr" : "schema for Danish pronouns", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk stedord", + "descr" : "", + "aliases" : "danske stedord" + }, + "pt" : { + "lang" : "pt", + "label" : "pronome (danês)", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E63", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E63", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E63", + "title" : "ClinGen variant pathogenicity (E63) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "ClinGen variant pathogenicity", + "descr" : "schema on genetic variants from ClinGen", + "aliases" : "" + } + } + }, + { + "id" : "E64", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E64", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E64", + "title" : "bacterial genome annotation (E64) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "bacterial genome annotation", + "descr" : "schema for the bacterial genomes in Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E65", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E65", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E65", + "title" : "Danish numerals (E65) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "numéro en danois", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "numeral (danês)", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "deens telwoord", + "descr" : "basis schema voor een Deens telwoord", + "aliases" : "" + }, + "ru" : { + "lang" : "ru", + "label" : "датские числительные", + "descr" : "схема для датских числительных", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk talord", + "descr" : "skema for danske talord", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Danish numerals", + "descr" : "base schema for Danish numerals", + "aliases" : "" + } + } + }, + { + "id" : "E66", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E66", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E66", + "title" : "music composition by W.A.Mozart (E66) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "music composition by W.A.Mozart", + "descr" : "basic schema of a music composition by Wolfgang Amadeus Mozart", + "aliases" : "" + } + } + }, + { + "id" : "E67", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E67", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E67", + "title" : "Award (E67) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Award", + "descr" : "Basic schema for awards on Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E68", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E68", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E68", + "title" : "Danish hyphenation (E68) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Danish hyphenation", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk orddeling", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E69", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E69", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E69", + "title" : "disease (E69) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "disease", + "descr" : "basic schema for a human disease according to the disease ontology", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "malsano", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "ziekte", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "doença", + "descr" : "", + "aliases" : "enfermidade" + } + } + }, + { + "id" : "E70", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E70", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E70", + "title" : "Clinical Interpretations of Variants in Cancer (E70) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Clinical Interpretations of Variants in Cancer", + "descr" : "basic schema for items sourced from clinical interpretations in variants in cancer", + "aliases" : "CIViC schema" + } + } + }, + { + "id" : "E71", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E71", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E71", + "title" : "ceremonial county of England (E71) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "ceremonial county of England", + "descr" : "basic schema for a ceremonial county in England", + "aliases" : "" + } + } + }, + { + "id" : "E72", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E72", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E72", + "title" : "pharmaceutical drug (E72) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "pharmaceutical drug", + "descr" : "basic schema of a pharmaceutical drug", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "farmacêutico", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E73", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E73", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E73", + "title" : "software companies (E73) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "software companies", + "descr" : "schema for companies that produce software", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "empresa de software", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E74", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E74", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E74", + "title" : "pseudogene (E74) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "pseudogene", + "descr" : "basic schema of a pseudogene in Wikidata", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "pseudogene", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E75", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E75", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E75", + "title" : "gene (E75) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "gene", + "descr" : "basic schema for genes represented in Wikidata", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "geno", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "gen", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "gene", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E76", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E76", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E76", + "title" : "Danish adjective (E76) - Wikidata", + "labels" : { + "pt" : { + "lang" : "pt", + "label" : "adjetivo (danês)", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Deens bijvoeglijk naamwoord", + "descr" : "", + "aliases" : "" + }, + "eo" : { + "lang" : "eo", + "label" : "dana adjektivo", + "descr" : "", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "dansk tillægsord", + "descr" : "", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Danish adjective", + "descr" : "Danish adjective", + "aliases" : "" + } + } + }, + { + "id" : "E77", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E77", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E77", + "title" : "vernacular names according to the BSL (E77) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "vernacular names according to the BSL", + "descr" : "Schema on vernacular sourced from the Belgian Species List", + "aliases" : "" + } + } + }, + { + "id" : "E78", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E78", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E78", + "title" : "Western Lombard language common taxon names (E78) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Western Lombard language common taxon names", + "descr" : "schema of a vernacular name on Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E79", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E79", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E79", + "title" : "file format with PRONOM id (E79) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "file format with PRONOM id", + "descr" : "schema for a file format item that has a PUID identifier", + "aliases" : "file format with PUID" + } + } + }, + { + "id" : "E80", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E80", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E80", + "title" : "volcano (E80) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "volcano", + "descr" : "General schema for volcanos on Wikidata", + "aliases" : "vulcano" + }, + "eo" : { + "lang" : "eo", + "label" : "vulkano", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "vulkaan", + "descr" : "schema voor een vulkaan geregistreerd in Wikidata", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "vulcão", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E81", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E81", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E81", + "title" : "lighthouse (E81) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "lighthouse", + "descr" : "Schema for lighthouse on Wikidata", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "vuurtoren", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "farol", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E82", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E82", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E82", + "title" : "cryptocurrency (E82) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "cryptocurrency", + "descr" : "basic schema for cryptocurrencies", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "criptomoeda", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E83", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E83", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E83", + "title" : "W3C Recommendation (E83) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "W3C Recommendation", + "descr" : "basic schema for W3C Recommendation", + "aliases" : "W3C REC" + } + } + }, + { + "id" : "E84", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E84", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E84", + "title" : "Scores for a discipline in a figure skating competition (E84) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Scores for a discipline in a figure skating competition", + "descr" : "", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "Scores d'une discipline dans une compétition de patinage artistique", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E85", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E85", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E85", + "title" : "academic conference (E85) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "academic conference", + "descr" : "general schema for a academic conference in Wikidata", + "aliases" : "" + }, + "da" : { + "lang" : "da", + "label" : "videnskabelig konference", + "descr" : "", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "wissenschaftliche Konferenz", + "descr" : "", + "aliases" : "" + }, + "pt" : { + "lang" : "pt", + "label" : "conferência acadêmica", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E86", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E86", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E86", + "title" : "native Wikipathways schema (E86) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "native Wikipathways schema", + "descr" : "basic schema of a Pathway in Wikipathways as expressed on http://www.wikipathways.org", + "aliases" : "" + } + } + }, + { + "id" : "E87", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E87", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E87", + "title" : "biological pathway in Wikidata (E87) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "biological pathway in Wikidata", + "descr" : "basic schema of biological pathways in Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E88", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E88", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E88", + "title" : "health in region (E88) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "health in region", + "descr" : "basic scheme for health by region/country items", + "aliases" : "" + } + } + }, + { + "id" : "E89", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E89", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E89", + "title" : "Public library branch in The Netherlands (E89) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Public library branch in The Netherlands", + "descr" : "Schema for a public library branch (except library buses) in The Netherlands", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Öffentliche Bibliotheksfiliale in den Niederlanden", + "descr" : "Schema für eine öffentliche Bibliotheksfiliale (außer Bibliotheksbusse) in den Niederlanden", + "aliases" : "Öffentliche Büchereifiliale in den Niederlanden" + }, + "en-GB" : { + "lang" : "en-GB", + "label" : "Public library branch in The Netherlands", + "descr" : "Schema for a public library branch (except library buses) in The Netherlands", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Openbare bibliotheekvestiging in Nederland", + "descr" : "Schema voor een openbare bibliotheekvestiging (m.u.v.bibliobussen) in Nederland", + "aliases" : "" + } + } + }, + { + "id" : "E90", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E90", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E90", + "title" : "Public library organisation in The Netherlands (E90) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Public library organisation in The Netherlands", + "descr" : "Schema for a public library organisation in The Netherlands", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Openbare bibliotheekorganisatie in Nederland", + "descr" : "Schema voor een openbare bibliotheekorganisatie in Nederland", + "aliases" : "" + } + } + }, + { + "id" : "E91", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E91", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E91", + "title" : "Emulator (E91) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Emulator", + "descr" : "base schema for emulators", + "aliases" : "" + } + } + }, + { + "id" : "E92", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E92", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E92", + "title" : "Delftware pottery workshops (E92) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Delftware pottery workshops", + "descr" : "schema for Delftware pottery workshops", + "aliases" : "" + } + } + }, + { + "id" : "E93", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E93", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E93", + "title" : "FLOSS emulator (E93) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "FLOSS emulator", + "descr" : "schema for a free/libre/open source software emulator", + "aliases" : "" + } + } + }, + { + "id" : "E94", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E94", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E94", + "title" : "Newspaper clippings archives (E94) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Newspaper clippings archives", + "descr" : "Schema for instances of Q65651503", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Zeitungsauschnittsarchiv", + "descr" : "Schema für Instanzen von Q65651503", + "aliases" : "" + } + } + }, + { + "id" : "E95", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E95", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E95", + "title" : "Newspaper clippings archives (minimal) (E95) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Newspaper clippings archives (minimal)", + "descr" : "Minimal schema for instances of Q65651503", + "aliases" : "" + } + } + }, + { + "id" : "E96", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E96", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E96", + "title" : "dummy (E96) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "dummy", + "descr" : "for another variant of E94", + "aliases" : "" + } + } + }, + { + "id" : "E97", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E97", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E97", + "title" : "Instance of (E97) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Instance of", + "descr" : "Example schema for WikiProject:ShEx/How to get started?", + "aliases" : "" + } + } + }, + { + "id" : "E98", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E98", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E98", + "title" : "Instance of organization (or subclass) (E98) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Instance of organization (or subclass)", + "descr" : "for WikiProject: ShEx/How to get started?", + "aliases" : "" + } + } + }, + { + "id" : "E99", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E99", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E99", + "title" : "statue (E99) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "statue", + "descr" : "general schema for a statue", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Statue", + "descr" : "Allgemeines Schema für eine Statue", + "aliases" : "" + } + } + }, + { + "id" : "E100", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E100", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E100", + "title" : "city (E100) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "city", + "descr" : "schema of a city", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Stadt", + "descr" : "Schema für eine Stadt", + "aliases" : "" + }, + "es" : { + "lang" : "es", + "label" : "ciudad", + "descr" : "esquema para una localidad", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "ville", + "descr" : "schéma d'une ville", + "aliases" : "" + } + } + }, + { + "id" : "E101", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E101", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E101", + "title" : "book edition in Libris (E101) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "book edition in Libris", + "descr" : "schema for editions in the Libris library catalog", + "aliases" : "" + } + } + }, + { + "id" : "E102", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E102", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E102", + "title" : "operating system (E102) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "operating system", + "descr" : "base schema for operating systems", + "aliases" : "os" + }, + "es" : { + "lang" : "es", + "label" : "sistema operativo", + "descr" : "esquema simple para un sistema operativo", + "aliases" : "so" + } + } + }, + { + "id" : "E103", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E103", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E103", + "title" : "gene variant according to myvariant.info (E103) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "gene variant according to myvariant.info", + "descr" : "schema of gene variant statements sourced through myvariant.info", + "aliases" : "" + } + } + }, + { + "id" : "E104", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E104", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E104", + "title" : "Wikidata (E104) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Wikidata", + "descr" : "Wikidata is a WikiMedia project", + "aliases" : "WikiMedia" + } + } + }, + { + "id" : "E105", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E105", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E105", + "title" : "deceased person in Dutch Wikipedia (E105) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "deceased person in Dutch Wikipedia", + "descr" : "general schema for a deceased person described in the Dutch Wikipedia", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "Overleden persoon op de Nederlandstalige Wikipedia (bron bij overlijden)", + "descr" : "generiek schema voor overleden personen op de Nederlandstalige Wikipedia (bron bij overlijden)", + "aliases" : "" + } + } + }, + { + "id" : "E106", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E106", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E106", + "title" : "Lunar crater (E106) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Lunar crater", + "descr" : "schema for lunar craters", + "aliases" : "moon crater" + }, + "ast" : { + "lang" : "ast", + "label" : "cráter llunar", + "descr" : "esquema pa cráteres llunares", + "aliases" : "" + } + } + }, + { + "id" : "E107", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E107", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E107", + "title" : "chromosome (E107) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "chromosome", + "descr" : "general schema describing items on chromosomes on Wikidata", + "aliases" : "" + } + } + }, + { + "id" : "E108", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E108", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E108", + "title" : "sequence assembly (E108) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "sequence assembly", + "descr" : "general schema describing a sequence assembly", + "aliases" : "" + } + } + }, + { + "id" : "E109", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E109", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E109", + "title" : "human chromosome (E109) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "human chromosome", + "descr" : "general schema for human chromosomes that builds on the general schema for chromosome (E107)", + "aliases" : "" + }, + "ast" : { + "lang" : "ast", + "label" : "cromosoma humanu", + "descr" : "esquema xeneral pa cromosomes humanos que se forma dende l'esquema xeneral pa cromosoma (E107)", + "aliases" : "" + } + } + }, + { + "id" : "E110", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E110", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E110", + "title" : "software license (E110) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "software license", + "descr" : "schema for software license", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Softwarelizenz", + "descr" : "Schema für Softwarelizenzen", + "aliases" : "" + } + } + }, + { + "id" : "E111", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E111", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E111", + "title" : "virtual reality headset (E111) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "virtual reality headset", + "descr" : "schema for virtual reality headsets", + "aliases" : "VR headset" + } + } + }, + { + "id" : "E112", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E112", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E112", + "title" : "data set (E112) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "data set", + "descr" : "schema for data sets", + "aliases" : "" + } + } + }, + { + "id" : "E113", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E113", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E113", + "title" : "Disease Ontology mapping (E113) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Disease Ontology mapping", + "descr" : "schema for items sourced from the Disease Ontology", + "aliases" : "" + } + } + }, + { + "id" : "E114", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E114", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E114", + "title" : "trail (E114) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "trail", + "descr" : "schema for trails", + "aliases" : "hiking trail" + } + } + }, + { + "id" : "E115", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E115", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E115", + "title" : "Tsunami (E115) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Tsunami", + "descr" : "Extracted schema for Tsunami's on Wikidata", + "aliases" : "" + }, + "ast" : { + "lang" : "ast", + "label" : "tsunami", + "descr" : "Esquema estraíu pa tsunami en Wikidata", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "tsunami", + "descr" : "", + "aliases" : "" + }, + "ja" : { + "lang" : "ja", + "label" : "津波", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E117", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E117", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E117", + "title" : "newspaper with direct claim properties only (E117) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "newspaper with direct claim properties only", + "descr" : "schema of a newspaper with direct claim properties only (i.e. wdt:~", + "aliases" : "" + } + } + }, + { + "id" : "E118", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E118", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E118", + "title" : "virtual assistant (E118) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "virtual assistant", + "descr" : "schema for virtual assistant software agents", + "aliases" : "" + } + } + }, + { + "id" : "E119", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E119", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E119", + "title" : "space probe (E119) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "space probe", + "descr" : "schema for space probes", + "aliases" : "" + }, + "ast" : { + "lang" : "ast", + "label" : "sonda espacial", + "descr" : "esquema pa sondes espaciales", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "sonde spatiale", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E120", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E120", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E120", + "title" : "red panda (E120) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "red panda", + "descr" : "schema for red pandas", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "panda roux", + "descr" : "schéma pour les pandas roux", + "aliases" : "petit panda | renard de feu" + } + } + }, + { + "id" : "E121", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E121", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E121", + "title" : "0 (E121) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "0", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E122", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E122", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E122", + "title" : "2147483647 (E122) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "2147483647", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E123", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E123", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E123", + "title" : "Sandbox Schema (E123) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Sandbox Schema", + "descr" : "An EntitySchema to try things out, not intended for productive use", + "aliases" : "test schema" + }, + "nl" : { + "lang" : "nl", + "label" : "zandbak schema", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E124", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E124", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E124", + "title" : "2.133.165.110 (E124) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "2.133.165.110", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E125", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E125", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E125", + "title" : "museum (E125) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "museum", + "descr" : "base schema for museums", + "aliases" : "" + } + } + }, + { + "id" : "E126", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E126", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E126", + "title" : "Nobel Prize Winners (E126) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Nobel Prize Winners", + "descr" : "Nobel Prize Winners which includes ALL the Prize types including Peace Prize", + "aliases" : "nobel winner" + } + } + }, + { + "id" : "E127", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E127", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E127", + "title" : "interstellar object (E127) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "interstellar object", + "descr" : "schema for interstellar objects", + "aliases" : "" + } + } + }, + { + "id" : "E128", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E128", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E128", + "title" : "extrasolar planet (E128) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "extrasolar planet", + "descr" : "schema for extrasolar planets", + "aliases" : "exoplanet" + } + } + }, + { + "id" : "E129", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E129", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E129", + "title" : "one-of-a-kind computer (E129) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "one-of-a-kind computer", + "descr" : "schema for one-of-a-kind computers", + "aliases" : "" + } + } + }, + { + "id" : "E130", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E130", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E130", + "title" : "painting (E130) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "painting", + "descr" : "surface artistically covered with paint", + "aliases" : "paintings" + }, + "nb" : { + "lang" : "nb", + "label" : "maleri", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "schilderij", + "descr" : "", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "tavla", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E131", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E131", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E131", + "title" : "Standard German noun (E131) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Standard German noun", + "descr" : "German noun with Gender at the entry level and 8 inflected forms in case and number", + "aliases" : "German noun" + } + } + }, + { + "id" : "E132", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E132", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E132", + "title" : "web comic (E132) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "web comic", + "descr" : "schema for web comics", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "strip de webcomic", + "descr" : "un strip tiré d'un webcomic", + "aliases" : "" + } + } + }, + { + "id" : "E133", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E133", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E133", + "title" : "adminstrative district in Turkey (E133) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "adminstrative district in Turkey", + "descr" : "schema for administrative district in Turkey", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "entité administrative en Turquie", + "descr" : "schema pour une entité administrative en Turquie", + "aliases" : "" + }, + "tr" : { + "lang" : "tr", + "label" : "Türkiye idari birimi", + "descr" : "Türkiye'de bulunan idari birim şeması", + "aliases" : "" + } + } + }, + { + "id" : "E134", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E134", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E134", + "title" : "Swedish Parliament member (E134) - Wikidata", + "labels" : { + "fr" : { + "lang" : "fr", + "label" : "membre du Parlement suédois", + "descr" : "", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Mitglied des schwedischen Parlaments", + "descr" : "", + "aliases" : "" + }, + "sv" : { + "lang" : "sv", + "label" : "Riksdagsledamot 2018", + "descr" : "medlem av svenska Riksdagen 2018", + "aliases" : "" + }, + "en" : { + "lang" : "en", + "label" : "Swedish Parliament member", + "descr" : "member of the Swedish Parliament", + "aliases" : "" + }, + "ast" : { + "lang" : "ast", + "label" : "miembru del Parlamentu suecu", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E135", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E135", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E135", + "title" : "Languages should have an IETF language tag (E135) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Languages should have an IETF language tag", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E136", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E136", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E136", + "title" : "Malayalam lexeme (E136) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Malayalam lexeme", + "descr" : "entity schema for lexemes in Malayalam", + "aliases" : "" + }, + "ast" : { + "lang" : "ast", + "label" : "Lexema en malayalam", + "descr" : "esquema d'entidá pa lexemes en malayalam", + "aliases" : "" + }, + "ml" : { + "lang" : "ml", + "label" : "മലയാളം ലെക്സീം", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E137", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E137", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E137", + "title" : "privacy policy (E137) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "privacy policy", + "descr" : "this item has a privacy policy URL", + "aliases" : "" + } + } + }, + { + "id" : "E138", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E138", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E138", + "title" : "patent (E138) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "patent", + "descr" : "schema for patents", + "aliases" : "" + } + } + }, + { + "id" : "E139", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E139", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E139", + "title" : "competition class items (E139) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "competition class items", + "descr" : "schema for items that can be used as values for Property:P2094 (competition class)", + "aliases" : "" + }, + "de" : { + "lang" : "de", + "label" : "Wettbewerbsklassen-Objekte", + "descr" : "Schema für Objekte, die als Werte für die Eigenschaft Property:P2094 (Wettbewerbsklasse) genutzt werden können", + "aliases" : "" + } + } + }, + { + "id" : "E140", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E140", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E140", + "title" : "metropolitan statistical area (E140) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "metropolitan statistical area", + "descr" : "schema for metropolitan statistical areas", + "aliases" : "" + } + } + }, + { + "id" : "E141", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E141", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E141", + "title" : "web service (E141) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "web service", + "descr" : "schema for web services", + "aliases" : "" + } + } + }, + { + "id" : "E142", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E142", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E142", + "title" : "UNESCO world heritage site (E142) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "UNESCO world heritage site", + "descr" : "schema for UNESCO world heritage site", + "aliases" : "world heritage site" + }, + "nl" : { + "lang" : "nl", + "label" : "UNESCO wereld erfgoed", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E143", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E143", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E143", + "title" : "award laureate (E143) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "award laureate", + "descr" : "", + "aliases" : "" + }, + "nl" : { + "lang" : "nl", + "label" : "prijswinnaar", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E144", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E144", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E144", + "title" : "poem by Emily Dickinson (E144) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "poem by Emily Dickinson", + "descr" : "basic scheme", + "aliases" : "" + } + } + }, + { + "id" : "E145", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E145", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E145", + "title" : "file system (E145) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "file system", + "descr" : "schema for file systems", + "aliases" : "" + } + } + }, + { + "id" : "E147", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E147", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E147", + "title" : "submarine communications cable (E147) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "submarine communications cable", + "descr" : "schema for submarine communications cables", + "aliases" : "" + } + } + }, + { + "id" : "E148", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E148", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E148", + "title" : "Nazca lines (E148) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Nazca lines", + "descr" : "schema for geoglyphs that make up the Nazca lines", + "aliases" : "" + } + } + }, + { + "id" : "E149", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E149", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E149", + "title" : "cryptographic hash function (E149) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "cryptographic hash function", + "descr" : "schema for cryptographic hash function", + "aliases" : "" + } + } + }, + { + "id" : "E150", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E150", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E150", + "title" : "Specific event in figure skating (E150) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Specific event in figure skating", + "descr" : "Schema to check for specific figure skating events", + "aliases" : "" + }, + "fr" : { + "lang" : "fr", + "label" : "évènements spécifique en patinage artistique", + "descr" : "schema pour vérifier des évènements spécifiques en patinage artistique", + "aliases" : "" + } + } + }, + { + "id" : "E151", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E151", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E151", + "title" : "watercraft (E151) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "watercraft", + "descr" : "All types of vessels", + "aliases" : "watercraft | vessel | ship | boat" + }, + "nl" : { + "lang" : "nl", + "label" : "watervoertuig", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E152", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E152", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E152", + "title" : "Ship (E152) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Ship", + "descr" : "", + "aliases" : "" + } + } + }, + { + "id" : "E153", + "conceptUri" : "https://www.wikidata.org/wiki/Special:EntitySchemaText/E153", + "webUri" : "https://www.wikidata.org/wiki/EntitySchema:E153", + "title" : "Researcher (E153) - Wikidata", + "labels" : { + "en" : { + "lang" : "en", + "label" : "Researcher", + "descr" : "Schema for Researchers", + "aliases" : "" + } + } + } +]; \ No newline at end of file diff --git a/doc/main.js b/doc/main.js index 4d9601cf..2a689a8e 100755 --- a/doc/main.js +++ b/doc/main.js @@ -1,4 +1,5 @@ var $ = jQuery = require("jquery"); + require("../node_modules/bootstrap-sass/assets/javascripts/bootstrap/affix.js"); require("../node_modules/bootstrap-sass/assets/javascripts/bootstrap/scrollspy.js"); @@ -139,4 +140,8 @@ $(document).ready(function() { yashe.setValue(data); }, 'text'); } + + + + }); diff --git a/index.html b/index.html index 2dc1a807..a70c532b 100755 --- a/index.html +++ b/index.html @@ -68,7 +68,7 @@

About YASHE

- + var yashe = YASHE(document.getElementById("showcase"));
(or, if you would like to instantiate YASHE from an existing text area, use var yashe = YASHE.fromTextArea(document.getElementById('textAreaItem')); diff --git a/lib/grammar/tokenizer.js b/lib/grammar/tokenizer.js index c20fbda9..fbd201ef 100755 --- a/lib/grammar/tokenizer.js +++ b/lib/grammar/tokenizer.js @@ -530,6 +530,9 @@ CodeMirror.defineMode("shex", function(config, parserConfig) { } + if(topSymbol == 'valueSetValue'){ + tokenOb.style='valueSet'; + } if (topSymbol === 'var' && tokenOb.text) state.variables[tokenOb.text] = tokenOb.text; diff --git a/package-lock.json b/package-lock.json index 35c862a8..34bf1c57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yashe", - "version": "1.2.6", + "version": "1.2.16", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1055,8 +1055,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "atob": { "version": "2.1.2", @@ -1324,6 +1323,17 @@ "inherits": "~2.0.0" } }, + "bloodhound-js": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bloodhound-js/-/bloodhound-js-1.2.3.tgz", + "integrity": "sha512-gpcHaO8SqK/bLwWgobLGQvIVpSdTX4fKZFjfh6ltori5aULXJxC/ndrNRf3PYGOdyD4mFIqjySXLWX4pE88VmA==", + "requires": { + "es6-promise": "^3.0.2", + "object-assign": "^4.0.1", + "storage2": "^0.1.0", + "superagent": "^3.8.3" + } + }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", @@ -1407,6 +1417,11 @@ } } }, + "bootstrap": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.4.1.tgz", + "integrity": "sha512-tbx5cHubwE6e2ZG7nqM3g/FZ5PQEDMWmMGNrCUBVRPHXTJaH7CBDdsLeu3eCh3B1tzAxTnAbtmrzvWEvT2NNEA==" + }, "bootstrap-sass": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.4.1.tgz", @@ -2288,7 +2303,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -2301,8 +2315,7 @@ "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" }, "compressible": { "version": "2.0.18", @@ -2519,6 +2532,11 @@ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", "dev": true }, + "cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==" + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -2970,8 +2988,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "delegate": { "version": "3.2.0", @@ -3292,6 +3309,11 @@ "es6-symbol": "^3.1.1" } }, + "es6-promise": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", + "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=" + }, "es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -3792,8 +3814,7 @@ "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, "extend-shallow": { "version": "2.0.1", @@ -4272,13 +4293,17 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "dev": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, + "formidable": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz", + "integrity": "sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q==" + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -8381,8 +8406,7 @@ "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", - "dev": true + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, "micromatch": { "version": "3.1.10", @@ -8451,14 +8475,12 @@ "mime-db": { "version": "1.43.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", - "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", - "dev": true + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" }, "mime-types": { "version": "2.1.26", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", - "dev": true, "requires": { "mime-db": "1.43.0" } @@ -8616,8 +8638,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "multimatch": { "version": "2.1.0", @@ -9123,8 +9144,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "object-copy": { "version": "0.1.0", @@ -11532,6 +11552,11 @@ "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", "dev": true }, + "storage2": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/storage2/-/storage2-0.1.1.tgz", + "integrity": "sha512-WvgkYqQnpy0ElxtJfekp/I8evoafc8iZ57efcV+m74JjTJTksWHwF5RXnK2WMOUN61oeuV9buxP6PkldpbWb2g==" + }, "store": { "version": "2.0.12", "resolved": "https://registry.npmjs.org/store/-/store-2.0.12.tgz", @@ -11829,6 +11854,43 @@ "minimist": "^1.1.0" } }, + "superagent": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", + "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", + "requires": { + "component-emitter": "^1.2.0", + "cookiejar": "^2.1.0", + "debug": "^3.1.0", + "extend": "^3.0.0", + "form-data": "^2.3.1", + "formidable": "^1.2.0", + "methods": "^1.1.1", + "mime": "^1.4.1", + "qs": "^6.5.1", + "readable-stream": "^2.3.5" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "qs": { + "version": "6.9.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.3.tgz", + "integrity": "sha512-EbZYNarm6138UKKq46tdx08Yo/q9ZhFoAXAI1meAFd2GtbRDhbZY2WQSICskT0c5q99aFzLG1D4nvTk9tqfXIw==" + } + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -12442,6 +12504,11 @@ "mime-types": "~2.1.24" } }, + "typeahead.js-bootstrap4-css": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typeahead.js-bootstrap4-css/-/typeahead.js-bootstrap4-css-1.0.0.tgz", + "integrity": "sha1-xL1ufsUeSrbdR8a/1qSDqoXW22Y=" + }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", diff --git a/package.json b/package.json index e8ce2a76..f2ba1300 100755 --- a/package.json +++ b/package.json @@ -73,6 +73,8 @@ }, "dependencies": { "axios": "^0.19.2", + "bloodhound-js": "^1.2.3", + "bootstrap": "^4.4.1", "codemirror": "5.17.0", "file-reader": "^1.1.1", "gulp-uglify": "^3.0.2", @@ -80,6 +82,7 @@ "jquery": "^2.2.4", "prettier": "^1.4.4", "read-file": "^0.2.0", + "typeahead.js-bootstrap4-css": "^1.0.0", "yasgui-utils": "^1.6.7" }, "optionalShim": { diff --git a/src/main.js b/src/main.js index d2958e28..7f086e00 100755 --- a/src/main.js +++ b/src/main.js @@ -445,3 +445,59 @@ root.version = { 'jquery': $.fn.jquery, 'yasgui-utils': yutils.version, }; + + +/* + +var settings = { + "async": true, + "crossDomain": true, + "url": "https://www.mediawiki.org/w/api.php?action=query&meta=tokens&format=json", + "method": "GET", + "dataType": 'jsonp', +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); + + + + + +var Bloodhound = require('bloodhound-js'); + + // Defining the local dataset + var engine = new Bloodhound({ + local: ['dog', 'pig', 'moose'], + queryTokenizer: Bloodhound.tokenizers.whitespace, + datumTokenizer: Bloodhound.tokenizers.whitespace +}); + + + + +var typeahead = document.getElementsByClassName("typeahead")[0]; +typeahead.addEventListener("keyup",function(e){ + var aux = e.target.value + + var promise = engine.initialize(); + + promise.then(function() { + + engine.search( + aux, + function(d) { + console.log(d); + }, + function(d) { + console.log(d); + } + ); + +}); + + +}) +*/ + diff --git a/src/scss/cssIncludes/themes/_darkTheme.scss b/src/scss/cssIncludes/themes/_darkTheme.scss index ec6ef498..28a8532b 100755 --- a/src/scss/cssIncludes/themes/_darkTheme.scss +++ b/src/scss/cssIncludes/themes/_darkTheme.scss @@ -23,6 +23,7 @@ .cm-s-dark .cm-string {color: rgb(185, 128, 3);} .cm-s-dark .cm-string-2 {color: #7DB647;} .cm-s-dark .cm-constraint {color: #7DB647;} +.cm-s-dark .cm-valueSet {color: #7DB647;} .cm-s-dark .cm-constraintKeyword {color: #f00;} .cm-s-dark .cm-meta {color: #555;} .cm-s-dark .cm-qualifier {color: #555;} diff --git a/src/scss/cssIncludes/themes/_wikitheme.scss b/src/scss/cssIncludes/themes/_wikitheme.scss index ff1ef7e8..229f92cc 100755 --- a/src/scss/cssIncludes/themes/_wikitheme.scss +++ b/src/scss/cssIncludes/themes/_wikitheme.scss @@ -17,6 +17,7 @@ .cm-s-wiki .cm-string {color: rgb(185, 128, 3);} .cm-s-wiki .cm-string-2 {color: #05a;} .cm-s-wiki .cm-constraint {color: #05a;} +.cm-s-wiki .cm-valueSet {color: #05a;} .cm-s-wiki .cm-constraintKeyword {color: #f00;} .cm-s-wiki .cm-facet {color: #f00;} .cm-s-wiki .cm-meta {color: #555;} From 591fbfc8f4bbda7b019b338b7a0e82cffb5bf8b6 Mon Sep 17 00:00:00 2001 From: mistermboy Date: Fri, 27 Mar 2020 18:32:36 +0000 Subject: [PATCH 2/3] v.1.2.17 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f2ba1300..66c7563d 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yashe", "description": "Yet Another ShEx Editor", - "version": "1.2.16", + "version": "1.2.17", "main": "src/main.js", "license": "MIT", "author": "Pablo Menéndez", From b864b54d4a010c261c053017f847011437ddadc9 Mon Sep 17 00:00:00 2001 From: mistermboy Date: Fri, 3 Apr 2020 08:43:08 +0100 Subject: [PATCH 3/3] v1.2.22 --- dist/yashe.bundled.min.js | 16 ++++++++-------- index.html | 2 +- package-lock.json | 5 +++-- package.json | 3 +-- src/main.js | 9 +++------ src/utils/prefixFold.js | 6 ++++-- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/dist/yashe.bundled.min.js b/dist/yashe.bundled.min.js index 01e00694..4a95621f 100755 --- a/dist/yashe.bundled.min.js +++ b/dist/yashe.bundled.min.js @@ -25033,7 +25033,7 @@ module.exports = { module.exports={ "name": "yashe", "description": "Yet Another ShEx Editor", - "version": "1.2.16", + "version": "1.2.21", "main": "src/main.js", "license": "MIT", "author": "Pablo Menéndez", @@ -25107,7 +25107,6 @@ module.exports={ "axios": "^0.19.2", "bloodhound-js": "^1.2.3", "bootstrap": "^4.4.1", - "codemirror": "5.17.0", "file-reader": "^1.1.1", "gulp-uglify": "^3.0.2", "gulp-uglify-es": "^2.0.0", @@ -26347,7 +26346,7 @@ root.version = { }; -/* + var settings = { "async": true, @@ -26362,8 +26361,7 @@ $.ajax(settings).done(function (response) { }); - - +/* var Bloodhound = require('bloodhound-js'); @@ -26897,8 +26895,10 @@ function findFirstPrefix(cm, line, ch, lineText) { } CodeMirror.registerHelper("fold", "prefix", function(cm, start) { - var line = start.line, lineText = cm.getLine(line); - + if(!start){ + start = {line: 0, ch: 0} + } + var line = start.line,lineText = cm.getLine(line); var startCh, tokenType; function hasPreviousPrefix() { @@ -27573,4 +27573,4 @@ module.exports = { },{"./rdfUtils.js":47,"jquery":16}]},{},[38])(38) }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvZGVwYXJhbS5qcyIsImxpYi9ncmFtbWFyL190b2tlbml6ZXItdGFibGUuanMiLCJsaWIvZ3JhbW1hci90b2tlbml6ZXIuanMi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HJlYW0uc3RhcnRcbiAgICAgICAgICAgICB9O1xuICAgICAgICAgIH1cblxuICAgICAgICAgICovXG4gICAgICAgICAgXG5cbiAgICAgIFxuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNhdDogdGVybWluYWxzW2ldLm5hbWUsXG4gICAgICAgICAgICBzdHlsZTogdGVybWluYWxzW2ldLnN0eWxlLFxuICAgICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgICBzdGFydDogc3RyZWFtLnN0YXJ0XG4gICAgICAgICAgfTtcblxuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgXG4gICAgICAgIFxuICAgICAgfVxuXG4gIFxuICAgICAgLy8gS2V5d29yZHNcbiAgICAgIGNvbnN1bWVkID0gc3RyZWFtLm1hdGNoKGdyYW1tYXIua2V5d29yZHMsIHRydWUsIGZhbHNlKTtcbiAgICAgIGlmIChjb25zdW1lZCl7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgY2F0OiBzdHJlYW0uY3VycmVudCgpLnRvVXBwZXJDYXNlKCksXG4gICAgICAgICAgc3R5bGU6IFwia2V5d29yZFwiLFxuICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxuICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgfTtcbiAgICAgIH1cblxuICAgICAgLy8gUHVuY3R1YXRpb25cbiAgICAgIGNvbnN1bWVkID0gc3RyZWFtLm1hdGNoKGdyYW1tYXIucHVuY3QsIHRydWUsIGZhbHNlKTtcbiAgICAgIGlmIChjb25zdW1lZCl7XG4gICAgICAgIGlmKHN0cmVhbS5jdXJyZW50KCkhPScqJyBcbiAgICAgICAgICAmJiBzdHJlYW0uY3VycmVudCgpIT0nKydcbiAgICAgICAgICAgJiYgc3RyZWFtLmN1cnJlbnQoKSE9Jz8nKXtcblxuICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBjYXQ6IHN0cmVhbS5jdX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YoIXRva2VuLm1hdGNoKGdyYW1tYXIua2V5d29yZHMpKXtcbiAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdjb25zdHJhaW50JztcbiAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdjb25zdHJhaW50S2V5d29yZCc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYodG9wU3ltYm9sPT0nY2FyZGluYWxpdHknKXtcbiAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdjYXJkaW5hbGl0eSc7XG4gICAgICAgIH1cblxuICAgICAgICBpZih0b3BTeW1ib2wgPT0gJ3hzRmFjZXQnKXtcbiAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdmYWNldCc7XG5cbiAgICAgICAgfVxuXG4gICAgICAgIGlmKHRvcFN5bWJvbCA9PSAndmFsdWVTZXRWYWx1ZScpe1xuICAgICAgICAgIHRva2VuT2Iuc3R5bGU9J3ZhbHVlU2V0JztcbiAgICAgICAgfVxuICAgICAgIFxuXG4gICAgICAgIGlmICh0b3BTeW1ib2wgPT09ICd2YXInICYmIHRva2VuT2IudGV4dCkgc3RhdGUudmFyaWFibGVzW3Rva2VuT2IudGV4dF0gPSB0b2tlbk9iLnRleHQ7XG4gICAgICAgIGlmICghbGwxX3RhYmxlW3RvcFN5bWJvbF0pIHtcbiAgICAgICAgICAvLyBUb3Agc3ltYm9sIGlzIGEgdGVybWluYWxcbiAgICAgICAgICBpZiAodG9wU3ltYm9sID09IHRva2VuKSB7XG4gICAgICAgICAgICBpZiAoc3RhdGUuaW5QcmVmaXhEZWNsKSB7XG4gICAgICAgICAgICAgIGlmICh0b3BTeW1ib2wgPT09IFwiUE5BTUVfTlNcIiAmJiB0b2tlbk9iLnRleHQubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgIHN0YXRlLmN1cnJlbnRQbmFtZU5zID0gdG9rZW5PYi50ZXh0LnNsaWNlKDAsIC0xKTtcbiAgICAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlID0gJ3ByZWZpeERlbGMnXG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdGUuY3VycmVudFBuYW1lTnMgIT09IHVuZGVmaW5lZCAmJiB0b2tlbk9iLnRleHQubGVuZ3RoID4gMikge1xuICAgICAgICAgICAgICAgIHRva2VuT2Iuc3R5bGUgPSAncHJlZml4RGVsYydcbiAgICAgICAgICAgICAgICBzdGF0ZS5wcmVmaXhlc1tzdGF0ZS5jdXJyZW50UG5hbWVOc10gPSB0b2tlbk9iLnRleHQuc2xpY2UoMSwgLTEpO1xuICAgICAgICAgICAgICAgIC8vcmVzZXQgY3VycmVudCBwbmFtZSBuc1xuICAgICAgICAgICAgICAgIHN0YXRlLmN1cnJlbnRQbmFtZU5zID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBNYXRjaGluZyB0ZXJtaW5hbHNcbiAgICAgICAgICAgIC8vIC0gY29uc3VtZSB0b2tlbiBmcm9tIGlucHV0IHN0cmVhbVxuICAgICAgICAgICAgZmluaXNoZWQgPSB0cnVlO1xuICAgICAgICAgICAgLy9zZXRRdWVyeVR5cGUodG9wU3ltYm9sKTtcbiAgICAgICAgICAgIC8vIENoZWNrIHdoZXRoZXIgJCAoZW5kIG9mIGlucHV0IHRva2VuKSBpcyBwb3NzIG5leHRcbiAgICAgICAgICAgIC8vIGZvciBldmVyeXRoaW5nIG9uIHN0YWNrXG4gICAgICAgICAgICB2YXIgYWxsTmlsbGFibGUgPSB0cnVlO1xuICAgICAgICAgICAgZm9yICh2YXIgc3AgPSBzdGF0ZS5zdGFjay5sZW5ndGg7IHNwID4gMDsgLS1zcCkge1xuICAgICAgICAgICAgICB2YXIgaXRlbSA9IGxsMV90YWJsZVtzdGF0ZS5zdGFja1tzcCAtIDFdXTtcbiAgICAgICAgICAgICAgaWYgKCFpdGVtIHx8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VBvcygpO1xuICAgICAgICAgICAgICAgICAgc3RhdGUuZXJyb3JNc2cgPSBcIlByZWZpeCAnXCIgKyBwcmVmTnMgKyBcIicgaXMgbm90IGRlZmluZWRcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcbiAgICAgICAgICAgIHN0YXRlLmNvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgICAgICByZWNvcmRGYWlsdXJlUG9zKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIC8vIHRvcFN5bWJvbCBpcyBub250ZXJtaW5hbFxuICAgICAgICAgIC8vIC0gc2VlIGlmIHRoZXJlIGlzIGFuIGVudHJ5IGZvciB0b3BTeW1ib2xcbiAgICAgICAgICAvLyBhbmQgbmV4dFRva2VuIGluIHRhYmxlXG4gICAgICAgICAgXG4gICAgICAgICAgdmFyIG5leHRTeW1ib2xzID0gbGwxX3RhYmxlW3RvcFN5bWJvbF1bdG9rZW5dO1xuICAgICAgICAgIGlmIChuZXh0U3ltYm9scyAhPSB1bmRlZmluZWQgJiYgY2hlY2tTaWRlQ29uZGl0aW9ucyh0b3BTeW1ib2wpKSB7XG4gICAgICAgICAgICAvLyBNYXRjaCAtIGNvcHkgUkhTIG9mIHJ1bGUgdG8gc3RhY2tcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSBuZXh0U3ltYm9scy5sZW5ndGggLSAxOyBpID49IDA7IC0taSkge1xuICAgICAgICAgICAgICBzdGF0ZS5zdGFjay5wdXNoKG5leHRTeW1ib2xzW2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIFBlZm9ybSBhbnkgbm9uLWdyYW1tYXRpY2FsIHNpZGUtZWZmZWN0c1xuICAgICAgICAgICAgc2V0U2lkZUNvbmRpdGlvbnModG9wU3ltYm9sKT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0aGlzLmxpc3RlbmVyID0gKDAsIF9nb29kTGlzdGVuZXIyLmRlZmF1bHQpKHRyaWdnZXIsICdjbGljaycsIGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzMi5vbkNsaWNrKGUpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVmaW5lcyBhIG5ldyBgQ2xpcGJvYXJkQWN0aW9uYCBvbiBlYWNoIGNsaWNrIGV2ZW50LlxuICAgICAgICAgKiBAcGFyYW0ge0V2ZW50fSBlXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdvbkNsaWNrJyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIG9uQ2xpY2soZSkge1xuICAgICAgICAgICAgdmFyIHRyaWdnZXIgPSBlLmRlbGVnYXRlVGFyZ2V0IHx8IGUuY3VycmVudFRhcmdldDtcblxuICAgICAgICAgICAgaWYgKHRoaXMuY2xpcGJvYXJkQWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLmNsaXBib2FyZEFjdGlvbiA9IG5ldyBfY2xpcGJvYXJkQWN0aW9uMi5kZWZhdWx0KHtcbiAgICAgICAgICAgICAgICBhY3Rpb246IHRoaXMuYWN0aW9uKHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIHRhcmdldDogdGhpcy50YXJnZXQodHJpZ2dlciksXG4gICAgICAgICAgICAgICAgdGV4dDogdGhpcy50ZXh0KHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogdGhpcy5jb250YWluZXIsXG4gICAgICAgICAgICAgICAgdHJpZ2dlcjogdHJpZ2dlcixcbiAgICAgICAgICAgICAgICBlbWl0dGVyOiB0aGlzXG4gICAgICAgICAgICB9KTtcbiAg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cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnZGVmYXVsdFRleHQnLFxuXG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIERlZmF1bHQgYHRleHRgIGxvb2t1cCBmdW5jdGlvbi5cbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSB0cmlnZ2VyXG4gICAgICAgICAqL1xuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVmYXVsdFRleHQodHJpZ2dlcikge1xuICAgICAgICAgICAgcmV0dXJuIGdldEF0dHJpYnV0ZVZhbHVlKCd0ZXh0JywgdHJpZ2dlcik7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVzdHJveSBsaWZlY3ljbGUuXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdkZXN0cm95JyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGRlc3Ryb3koKSB7XG4gICAgICAgICAgICB0aGlzLmxpc3RlbmVyLmRlc3Ryb3koKTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuY2xpcGJvYXJkQWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24uZGVzdHJveSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuY2xpcGJvYXJkQWN0aW9uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1dLCBbe1xuICAgICAgICBrZXk6ICdpc1N1cHBvcnRlZCcsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBpc1N1cHBvcnRlZCgpIHtcbiAgICAgICAgICAgIHZhciBhY3Rpb24gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFsnY29weScsICdjdXQnXTtcblxuICAgICAgICAgICAgdmFyIGFjdGlvbnMgPSB0eXBlb2YgYWN0aW9uID09PSAnc3R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FrZUVsZW0pO1xuXG4gICAgICAgICAgICB0aGlzLnNlbGVjdGVkVGV4dCA9ICgwLCBfc2VsZWN0Mi5kZWZhdWx0KSh0aGlzLmZha2VFbGVtKTtcbiAgICAgICAgICAgIHRoaXMuY29weVRleHQoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBPbmx5IHJlbW92ZXMgdGhlIGZha2UgZWxlbWVudCBhZnRlciBhbm90aGVyIGNsaWNrIGV2ZW50LCB0aGF0IHdheVxuICAgICAgICAgKiBhIHVzZXIgY2FuIGhpdCBgQ3RybCtDYCB0byBjb3B5IGJlY2F1c2Ugc2VsZWN0aW9uIHN0aWxsIGV4aXN0cy5cbiAgICAgICAgICovXG5cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ3JlbW92ZUZha2UnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gcmVtb3ZlRmFrZSgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VIYW5kbGVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcignY2xpY2snLCB0aGlzLmZha2VIYW5kbGVyQ2FsbGJhY2spO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXJDYWxsYmFjayA9IG51bGw7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VFbGVtKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlQ2hpbGQodGhpcy5mYWtlRWxlbSk7XG4gICAgICAgICAgICAgICAgdGhpcy5mYWtlRWxlbSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogU2VsZWN0cyB0aGUgY29udGVudCBmcm9tIGVsZW1lbnQgcGFzc2VkIG9u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gfSwge1xuICAgICAgICBrZXk6ICdkZXN0cm95JyxcblxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBEZXN0cm95IGxpZmVjeWNsZS5cbiAgICAgICAgICovXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkZXN0cm95KCkge1xuICAgICAgICAgICAgdGhpcy5yZW1vdmVGYWtlKCk7XG4gICAgICAgIH1cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ2FjdGlvbicsXG4gICAgICAgIHNldDogZnVuY3Rpb24gc2V0KCkge1xuICAgICAgICAgICAgdmFyIGFjdGlvbiA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogJ2NvcHknO1xuXG4gICAgICAgICAgICB0aGlzLl9hY3Rpb24gPSBhY3Rpb247XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9hY3Rpb24gIT09ICdjb3B5JyAmJiB0aGlzLl9hY3Rpb24gIT09ICdjdXQnKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIFwiYWN0aW9uXCIgdmFsdWUsIHVzZSBlaXRoZXIgXCJjb3B5XCIgb3IgXCJjdXRcIicpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEdldHMgdGhlIGBhY3Rpb25gIHByb3BlcnR5LlxuICAgICAgICAgKiBAcmV0dXJuIHtTdHJpbmd9XG4gICAgICAgICAqL1xuICAgICAgICAsXG4gICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2FjdGlvbjtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBTZXRzIHRoZSBgdGFyZ2V0YCBwcm9wZXJ0eSB1c2luZyBhbiBlbGVtZW50XG4gICAgICAgICAqIHRoYXQgd2lsbCBi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biAgICAgICAgICAgIHNlbGVjdElucHV0KHRlKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGUudHlwZSA9PSBcImN1dFwiKSBjbS5zdGF0ZS5jdXRJbmNvbWluZyA9IHRydWU7XG4gICAgICB9XG4gICAgICBvbih0ZSwgXCJjdXRcIiwgcHJlcGFyZUNvcHlDdXQpO1xuICAgICAgb24odGUsIFwiY29weVwiLCBwcmVwYXJlQ29weUN1dCk7XG5cbiAgICAgIG9uKGRpc3BsYXkuc2Nyb2xsZXIsIFwicGFzdGVcIiwgZnVuY3Rpb24oZSkge1xuICAgICAgICBpZiAoZXZlbnRJbldpZGdldChkaXNwbGF5LCBlKSB8fCBzaWduYWxET01FdmVudChjbSwgZSkpIHJldHVybjtcbiAgICAgICAgY20uc3RhdGUucGFzdGVJbmNvbWluZyA9IHRydWU7XG4gICAgICAgIGlucHV0LmZvY3VzKCk7XG4gICAgICB9KTtcblxuICAgICAgLy8gUHJldmVudCBub3JtYWwgc2VsZWN0aW9uIGluIHRoZSBlZGl0b3IgKHdlIGhhbmRsZSBvdXIgb3duKVxuICAgICAgb24oZGlzcGxheS5saW5lU3BhY2UsIFwic2VsZWN0c3RhcnRcIiwgZnVuY3Rpb24oZSkge1xuICAgICAgICBpZiAoIWV2ZW50SW5XaWRnZXQoZGlzcGxheSwgZSkpIGVfcHJldmVudERlZmF1bHQoZSk7XG4gICAgICB9KTtcblxuICAgICAgb24odGUsIFwiY29tcG9zaXRpb25zdGFydFwiLCBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIHN0YXJ0ID0gY20uZ2V0Q3Vyc29yKFwiZnJvbVwiKTtcbiAgICAgICAgaWYgKGlucHV0LmNvbXBvc2luZykgaW5wdXQuY29tcG9zaW5nLnJhbmdlLmNsZWFyKClcbiAgICAgICAgaW5wdXQuY29tcG9zaW5nID0ge1xuICAgICAgICAgIHN0YXJ0OiBzdGFydCxcbiAgICAgICAgICByYW5nZTogY20ubWFya1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gICAgICBvbihkaXYsIFwiY29tcG9zaXRpb25zdGFydFwiLCBmdW5jdGlvbihlKSB7XG4gICAgICAgIHZhciBkYXRhID0gZS5kYXRhO1xuICAgICAgICBpbnB1dC5jb21wb3NpbmcgPSB7c2VsOiBjbS5kb2Muc2VsLCBkYXRhOiBkYXRhLCBzdGFydERhdGE6IGRhdGF9O1xuICAgICAgICBpZiAoIWRhdGEpIHJldHVybjtcbiAgICAgICAgdmFyIHByaW0gPSBjbS5kb2Muc2VsLnByaW1hcnkoKTtcbiAgICAgICAgdmFyIGxpbmUgPSBjbS5nZXRMaW5lKHByaW0uaGVhZC5saW5lKTtcbiAgICAgICAgdmFyIGZvdW5kID0gbGluZS5pbmRleE9mKGRhdGEsIE1hdGgubWF4KDAsIHByaW0uaGVhZC5jaCAtIGRhdGEubGVuZ3RoKSk7XG4gICAgICAgIGlmIChmb3VuZCA+IC0xICYmIGZvdW5kIDw9IHByaW0uaGVhZC5jaClcbiAgICAgICAgICBpbnB1dC5jb21wb3Npbmcuc2VsID0gc2ltcGxlU2VsZWN0aW9uKFBvcyhwcmltLmhlYWQubGluZSwgZm91bmQpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUG9zKHByaW0uaGVhZC5saW5lLCBmb3VuZCArIGRhdGEubGVuZ3RoKSk7XG4gICAgICB9KTtcbiAgICAgIG9uKGRpdiwgXCJjb21wb3NpdGlvbnVwZGF0ZVwiLCBmdW5jdGlvbihlKSB7XG4gICAgICAgIGlucHV0LmNvbXBvc2luZy5kYXRhID0gZS5kYXRhO1xuICAgICAgfSk7XG4gICAgICBvbihkaXYsIFwiY29tcG9zaXRpb25lbmRcIiwgZnVuY3Rpb24oZSkge1xuICAgICAgICB2YXIgb3VycyA9IGlucHV0LmNvbXBvc2luZztcbiAgICAgICAgaWYgKCFvdXJzKSByZXR1cm47XG4gICAgICAgIGlmIChlLmRhdGEgIT0gb3Vycy5zdGFydERhdGEgJiYgIS9cXHU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8gc3AuZnJvbSA8PSBwb3MuY2ggOiBzcC5mcm9tIDwgcG9zLmNoKSkgJiZcbiAgICAgICAgICAoc3AudG8gPT0gbnVsbCB8fCAobS5pbmNsdXNpdmVSaWdodCA/IHNwLnRvID49IHBvcy5jaCA6IHNwLnRvID4gcG9zLmNoKSkpIHtcbiAgICAgICAgaWYgKG1heUNsZWFyKSB7XG4gICAgICAgICAgc2lnbmFsKG0sIFwiYmVmb3JlQ3Vyc29yRW50ZXJcIik7XG4gICAgICAgICAgaWYgKG0uZXhwbGljaXRseUNsZWFyZWQpIHtcbiAgICAgICAgICAgIGlmICghbGluZS5tYXJrZWRTcGFucykgYnJlYWs7XG4gICAgICAgICAgICBlbHNlIHstLWk7IGNvbnRpbnVlO31cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFtLmF0b21pYykgY29udGludWU7XG5cbiAgICAgICAgaWYgKG9sZFBvcykge1xuICAgICAgICAgIHZhciBuZWFyID0gbS5maW5kKGRpciA8IDAgPyAxIDogLTEpLCBkaWZmO1xuICAgICAgICAgIGlmIChkaXIgPCAwID8gbS5pbmNsdXNpdmVSaWdodCA6IG0uaW5jbHVzaXZlTGVmdClcbiAgICAgICAgICAgIG5lYXIgPSBtb3ZlUG9zKGRvYywgbmVhciwgLWRpciwgbmVhciAmJiBuZWFyLmxpbmUgPT0gcG9zLmxpbmUgPyBsaW5lIDogbnVsbCk7XG4gICAgICAgICAgaWYgKG5lYXIgJiYgbmVhci5saW5lID09IHBvcy5saW5lICYmIChkaWZmID0gY21wKG5lYXIsIG9sZFBvcykpICYmIChkaXIgPCAwID8gZGlmZiA8IDAgOiBkaWZmID4gMCkpXG4gICAgICAgICAgICByZXR1cm4gc2tpcEF0b21pY0lubmVyKGRvYywgbmVhciwgcG9zLCBkaXIsIG1heUNsZWFyKTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciBmYXIgPSBtLmZpbmQoZGlyIDwgMCA/IC0xIDogMSk7XG4gICAgIC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ICAgfVxuICAgICAgaWYgKCFyYW5nZS50bykgcmFuZ2UudG8gPSByYW5nZS5mcm9tO1xuICAgICAgcmFuZ2UubWFyZ2luID0gbWFyZ2luIHx8IDA7XG5cbiAgICAgIGlmIChyYW5nZS5mcm9tLmxpbmUgIT0gbnVsbCkge1xuICAgICAgICByZXNvbHZlU2Nyb2xsVG9Qb3ModGhpcyk7XG4gICAgICAgIHRoaXMuY3VyT3Auc2Nyb2xsVG9Qb3MgPSByYW5nZTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHZhciBzUG9zID0gY2FsY3VsYXRlU2Nyb2xsUG9zKHRoaXMsIE1hdGgubWluKHJhbmdlLmZyb20ubGVmdCwgcmFuZ2UudG8ubGVmdCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWluKHJhbmdlLmZyb20udG9wLCByYW5nZS50by50b3ApIC0gcmFuZ2UubWFyZ2luLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRoLm1heChyYW5nZS5mcm9tLnJpZ2h0LCByYW5nZS50by5yaWdodCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWF4KHJhbmdlLmZyb20uYm90dG9tLCByYW5nZS50by5ib3R0b20pICsgcmFuZ2UubWFyZ2luKTtcbiAgICAgICAgdGhpcy5zY3JvbGxUbyhzUG9zLnNjcm9sbExlZnQsIHNQb3Muc2Nyb2xsVG9wKTtcbiAgICAgIH1cbiAgICB9KSxcblxuICAgIHNldFNpemU6IG1ldGhvZE9wKGZ1bmN0aW9uKHdpZHRoLCBoZWlnaHQpIHtcbiAgICAgIHZhciBjbSA9IHRoaXM7XG4gICAgICBmdW5jdGlvbiBpbnRlcnByZXQodmFsKSB7XG4gICAgICAgIHJldHVybiB0eXBlb2YgdmFsID09IFwibnVtYmVyXCIgfHwgL15cXGQrJC8udGVzdChTdHJpbmcodmFsKSkgPyB2YWwgKyBcInB4XCIg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3VyID0gbmV3IFBvcyhjdXIubGluZSwgY3VyLmNoIC0gMSk7XG4gICAgICAgICAgICBpZiAoY3VyLmNoID4gMCkge1xuICAgICAgICAgICAgICBjdXIgPSBuZXcgUG9zKGN1ci5saW5lLCBjdXIuY2ggKyAxKTtcbiAgICAgICAgICAgICAgY20ucmVwbGFjZVJhbmdlKGxpbmUuY2hhckF0KGN1ci5jaCAtIDEpICsgbGluZS5jaGFyQXQoY3VyLmNoIC0gMiksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQb3MoY3VyLmxpbmUsIGN1ci5jaCAtIDIpLCBjdXIsIFwiK3RyYW5zcG9zZVwiKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY3VyLmxpbmUgPiBjbS5kb2MuZmlyc3QpIHtcbiAgICAgICAgICAgICAgdmFyIHByZXYgPSBnZXRMaW5lKGNtLmRvYywgY3VyLmxpbmUgLSAxKS50ZXh0O1xuICAgICAgICAgICAgICBpZiAocHJldilcbiAgICAgICAgICAgICAgICBjbS5yZXBsYWNlUmFuZ2UobGluZS5jaGFyQXQoMCkgKyBjbS5kb2MubGluZVNlcGFyYXRvcigpICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jaGFyQXQocHJldi5sZW5ndGggLSAxKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUG9zKGN1ci5saW5lIC0gMSwgcHJldi5sZW5ndGggLSAxKSwgUG9zKGN1ci5saW5lLCAxKSwgXCIrdHJhbnNwb3NlXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBuZXdTZWwucHVzaChuZXcgUmFuZ2UoY3VyLCBjdXIpKTtcbiAgICAgICAgfVxuICAgICAgICBjbS5zZXRTZWxlY3Rpb25zKG5ld1NlbCk7XG4gICAgICB9KTtcbiAgICB9LFxuICAgIG5ld2xpbmVBbmRJbmRlbnQ6IGZ1bmN0aW9uKGNtKSB7XG4gICAgICBydW5Jbk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LCB0aXRsZSwgY29sbGFwc2VkO1xuICAgIGZvciAoOzspIHtcbiAgICAgIGlmIChuZXh0Q2hhbmdlID09IHBvcykgeyAvLyBVcGRhdGUgY3VycmVudCBtYXJrZXIgc2V0XG4gICAgICAgIHNwYW5TdHlsZSA9IHNwYW5FbmRTdHlsZSA9IHNwYW5TdGFydFN0eWxlID0gdGl0bGUgPSBjc3MgPSBcIlwiO1xuICAgICAgICBjb2xsYXBzZWQgPSBudWxsOyBuZXh0Q2hhbmdlID0gSW5maW5pdHk7XG4gICAgICAgIHZhciBmb3VuZEJvb2ttYXJrcyA9IFtdLCBlbmRTdHlsZXNcbiAgICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCBzcGFucy5sZW5ndGg7ICsraikge1xuICAgICAgICAgIHZhciBzcCA9IHNwYW5zW2pdLCBtID0gc3AubWFya2VyO1xuICAgICAgICAgIGlmIChtLnR5cGUgPT0gXCJib29rbWFya1wiICYmIHNwLmZyb20gPT0gcG9zICYmIG0ud2lkZ2V0Tm9kZSkge1xuICAgICAgICAgICAgZm91bmRCb29rbWFya3MucHVzaChtKTtcbiAgICAgICAgICB9IGVsc2UgaWYgKHNwLmZyb20gPD0gcG9zICYmIChzcC50byA9PSBudWxsIHx8IHNwLnRvID4gcG9zIHx8IG0uY29sbGFwc2VkICYmIHNwLnRvID09IHBvcyAmJiBzcC5mcm9tID09IHBvcykpIHtcbiAgICAgICAgICAgIGlmIChzcC50byAhPSBudWxsICYmIHNwLnRvICE9IHBvcyAmJiBuZXh0Q2hhbmdlID4gc3AudG8pIHtcbiAgICAgICAgICAgICAgbmV4dENoYW5nZSA9IHNwLnRvO1xuICAgICAgICAgICAgICBzcGFuRW5kU3R5bGUgPSBcIlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG0uY2xhc3NOYW1lKSBzcGFuU3R5bGUgKz0gXCIgXCIgKyBtLmNsYXNzTmFtZTtcbiAgICAgICAgICAgIGlmIChtLmNzcykgY3NzID0gKG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AwLCBmb3VuZEJvb2ttYXJrc1tqXSk7XG4gICAgICAgIGlmIChjb2xsYXBzZWQgJiYgKGNvbGxhcHNlZC5mcm9tIHx8IDApID09IHBvcykge1xuICAgICAgICAgIGJ1aWxkQ29sbGFwc2VkU3BhbihidWlsZGVyLCAoY29sbGFwc2VkLnRvID09IG51bGwgPyBsZW4gKyAxIDogY29sbGFwc2VkLnRvKSAtIHBvcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sbGFwc2VkLm1hcmtlciwgY29sbGFwc2VkLmZyb20gPT0gbnVsbCk7XG4gICAgICAgICAgaWYgKGNvbGxhcHNlZC50byA9PSBudWxsKSByZXR1cm47XG4gICAgICAgICAgaWYgKGNvbGxhcHNlZC50byA9PSBwb3MpIGNvbGxhcHNlZCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAocG9zID49IGxlbikgYnJlYWs7XG5cbiAgICAgIHZhciB1cHRvID0gTWF0aC5taW4obGVuLCBuZXh0Q2hhbmdlKTtcbiAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgIGlmICh0ZXh0KSB7XG4gICAgICAgICAgdmFyIGVuZCA9IHBvcyArIHRleHQubGVuZ3RoO1xuICAgICAgICAgIGlmICghY29sbGFwc2VkKSB7XG4gICAgICAgICAgICB2YXIgdG9rZW5UZXh0ID0gZW5kID4gdXB0byA/IHRleHQuc2xpY2UoMCwgdXB0byAtIHBvcykgOiB0ZXh0O1xuICAgICAgICAgICAgYnVpbGRlci5hZGRUb2tlbihidWlsZGVyLCB0b2tlblRleHQsIHN0eWxlID8gc3R5bGUgKyBzcGFuU3R5bGUgOiBzcGFuU3R5bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW5TdGFydFN0eWxlLCBwb3MgKyB0b2tlblRleHQubGVuZ3RoID09IG5leHRDaGFuZ2UgPyBzcGFuRW5kU3R5bGUgOiBcIlwiLCB0aXRsZSwgY3NzKTtcbiAgICAgIC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jdGVycyBhcmUgb3JkZXJlZCBhcyB0aGV5IGFwcGVhclxuICAvLyAobGVmdC10by1yaWdodCksIG9yIGFuIGFycmF5IG9mIHNlY3Rpb25zICh7ZnJvbSwgdG8sIGxldmVsfVxuICAvLyBvYmplY3RzKSBpbiB0aGUgb3JkZXIgaW4gd2hpY2ggdGhleSBvY2N1ciB2aXN1YWxseS5cbiAgdmFyIGJpZGlPcmRlcmluZyA9IChmdW5jdGlvbigpIHtcbiAgICAvLyBDaGFyYWN0ZXIgdHlwZXMgZm9yIGNvZGVwb2ludHMgMCB0byAweGZmXG4gICAgdmFyIGxvd1R5cGVzID0gXCJiYmJiYmJiYmJ0c3R3c2JiYmJiYmJiYmJiYmJic3NzdHdOTiUlJU5OTk5OTixOLE4xMTExMTExMTExTk5OTk5OTkxMTExMTExMTExMTExMTExMTExMTExMTExMTk5OTk5OTExMTExMTExMTExMTExMTExMTExMTExMTExOTk5OYmJiYmJic2JiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiLE4lJSUlTk5OTkxOTk5OTiUlMTFOTE5OTjFMTk5OTk5MTExMTExMTExMTExMTExMTExMTExMTE5MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTlwiO1xuICAgIC8vIENoYXJhY3RlciB0eXBlcyBmb3IgY29kZXBvaW50cyAweDYwMCB0byAweDZmZlxuICAgIHZhciBhcmFiaWNUeXBlcyA9IFwicnJycnJycnJycnJyLHJOTm1tbW1tbXJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJybW1tbW1tbW1tbW1tbW1ycnJycnJybm5ubm5ubm5ubiVubnJycm1ycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycm1tbW1tbW1tbW1tbW1tbW1tbW1ObW1tbVwiO1xuICAgIGZ1bmN0aW9uIGNoYXJUeXBlKGNvZGUpI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Skge1xuICAgICAgICAgIHZhciBzdGFydCA9IGk7XG4gICAgICAgICAgZm9yICgrK2k7IGkgPCBsZW4gJiYgY291bnRzQXNMZWZ0LnRlc3QodHlwZXNbaV0pOyArK2kpIHt9XG4gICAgICAgICAgb3JkZXIucHVzaChuZXcgQmlkaVNwYW4oMCwgc3RhcnQsIGkpKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB2YXIgcG9zID0gaSwgYXQgPSBvcmRlci5sZW5ndGg7XG4gICAgICAgICAgZm9yICgrK2k7IGkgPCBsZW4gJiYgdHlwZXNbaV0gIT0gXCJMXCI7ICsraSkge31cbiAgICAgICAgICBmb3IgKHZhciBqID0gcG9zOyBqIDwgaTspIHtcbiAgICAgICAgICAgIGlmIChjb3VudHNBc051bS50ZXN0KHR5cGVzW2pdKSkge1xuICAgICAgICAgICAgICBpZiAocG9zIDwgaikgb3JkZXIuc3BsaWNlKGF0LCAwLCBuZXcgQmlkaVNwYW4oMSwgcG9zLCBqKSk7XG4gICAgICAgICAgICAgIHZhciBuc3RhcnQgPSBqO1xuICAgICAgICAgICAgICBmb3IgKCsrajsgaiA8IGkgJiYgY291bnRzQXNOdW0udGVzdCh0eXBlc1tqXSk7ICsraikge31cbiAgICAgICAgICAgICAgb3JkZXIuc3BsaWNlKGF0LCAwLCBuZXcgQmlkaVNwYW4oMiwgbnN0YXJ0LCBqKSk7XG4gICAgICAgICAgICAgIHBvcyA9IGo7XG4gICAgICAgICAgICB9IGVsc2UgKytqO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAocG9zIDwgaSkgb3JkZXIuc3BsaWNlKGF0LCAwLCBuZXcgQmlkaVNwYW4oMSwgcG9zLCBpKSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChvcmRlclswXS5sZXZlbCA9PSAxICYmIChtID0gc3RyLm1hdGNoKC9eXFxzKy8pKSkge1xuICAgICAgICBvcmRlclswXS5mcm9tID0gbVswXS5sZW5ndGg7XG4gIC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bnRlZCBieSB0aGUgbmFtZS92YWx1ZSBwYWlyIHRoYXQgc2hvdWxkIGJlIHNlcmlhbGl6ZWQsXG4vLyAgICAgICAgICBvciB1bmRlZmluZWQgaWYgbm90aGluZyBzaG91bGQgYmUgc2VyaWFsaXplZC4gVGhlIHRvSlNPTiBtZXRob2Rcbi8vICAgICAgICAgIHdpbGwgYmUgcGFzc2VkIHRoZSBrZXkgYXNzb2NpYXRlZCB3aXRoIHRoZSB2YWx1ZSwgYW5kIHRoaXMgd2lsbCBiZVxuLy8gICAgICAgICAgYm91bmQgdG8gdGhlIHZhbHVlLlxuXG4vLyAgICAgICAgICBGb3IgZXhhbXBsZSwgdGhpcyB3b3VsZCBzZXJpYWxpemUgRGF0ZXMgYXMgSVNPIHN0cmluZ3MuXG5cbi8vICAgICAgICAgICAgICBEYXRlLnByb3RvdHlwZS50b0pTT04gPSBmdW5jdGlvbiAoa2V5KSB7XG4vLyAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGYobikge1xuLy8gICAgICAgICAgICAgICAgICAgICAgLy8gRm9ybWF0IGludGVnZXJzIHRvIGhhdmUgYXQgbGVhc3QgdHdvIGRpZ2l0cy5cbi8vICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAobiA8IDEwKVxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgID8gXCIwXCIgKyBuXG4vLyAgICAgICAgICAgICAgICAgICAgICAgICAgOiBuO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldFVUQ0Z1bGxZZWFyKCkgICArIFwiLVwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTW9udGgoKSArIDEpICsgXCItXCIgK1xuLy8gICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENEYXRlKCkpICAgICAgKyBcIlRcIiArXG4vLyAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ0hvdX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WRcXHUwNjAwLVxcdTA2MDRcXHUwNzBmXFx1MTdiNFxcdTE3YjVcXHUyMDBjLVxcdTIwMGZcXHUyMDI4LVxcdTIwMmZcXHUyMDYwLVxcdTIwNmZcXHVmZWZmXFx1ZmZmMC1cXHVmZmZmXS9nO1xuXG4gICAgZnVuY3Rpb24gZihuKSB7XG4gICAgICAgIC8vIEZvcm1hdCBpbnRlZ2VycyB0byBoYXZlIGF0IGxlYXN0IHR3byBkaWdpdHMuXG4gICAgICAgIHJldHVybiBuIDwgMTBcbiAgICAgICAgICAgID8gXCIwXCIgKyBuXG4gICAgICAgICAgICA6IG47XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdGhpc192YWx1ZSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudmFsdWVPZigpO1xuICAgIH1cblxuICAgIGlmICh0eXBlb2YgRGF0ZS5wcm90b3R5cGUudG9KU09OICE9PSBcImZ1bmN0aW9uXCIpIHtcblxuICAgICAgICBEYXRlLnByb3RvdHlwZS50b0pTT04gPSBmdW5jdGlvbiAoKSB7XG5cbiAgICAgICAgICAgIHJldHVybiBpc0Zpbml0ZSh0aGlzLnZhbHVlT2YoKSlcbiAgICAgICAgICAgICAgICA/IHRoaXMuZ2V0VVRDRnVsbFllYXIoKSArIFwiLVwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENNb250aCgpICsgMSkgKyBcIi1cIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDRGF0ZSgpKSArIFwiVFwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENIb3VycygpKSArIFwiOlwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENNaW51dGVzKCkpICsgXCI6XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ1NlY29uZHMoKSkgKyBcIlpcIlxuICAgICAgICAgICAgICAgIDogbnVs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3RoID09PSAwXG4gICAgICAgICAgICAgICAgICAgID8gXCJbXVwiXG4gICAgICAgICAgICAgICAgICAgIDogZ2FwXG4gICAgICAgICAgICAgICAgICAgICAgICA/IFwiW1xcblwiICsgZ2FwICsgcGFydGlhbC5qb2luKFwiLFxcblwiICsgZ2FwKSArIFwiXFxuXCIgKyBtaW5kICsgXCJdXCJcbiAgICAgICAgICAgICAgICAgICAgICAgIDogXCJbXCIgKyBwYXJ0aWFsLmpvaW4oXCIsXCIpICsgXCJdXCI7XG4gICAgICAgICAgICAgICAgZ2FwID0gbWluZDtcbiAgICAgICAgICAgICAgICByZXR1cm4gdjtcbiAgICAgICAgICAgIH1cblxuLy8gSWYgdGhlIHJlcGxhY2VyIGlzIGFuIGFycmF5LCB1c2UgaXQgdG8gc2VsZWN0IHRoZSBtZW1iZXJzIHRvIGJlIHN0cmluZ2lmaWVkLlxuXG4gICAgICAgICAgICBpZiAocmVwICYmIHR5cGVvZiByZXAgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICBsZW5ndGggPSByZXAubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcFtpXSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgayA9IHJlcFtpXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBzdHIoaywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsLnB1c2gocXVvdGUoaykgKyAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBcIjogXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogXCI6XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApICsgdik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuXG4vLyBPdGhlcndpc2UsIGl0ZXJhdGUgdGhyb3VnaCBhbGwgb2YgdGhlIGtleXMgaW4gdGhlIG9iamVjdC5cblxuICAgICAgICAgICAgICAgIGZvciAoayBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbHVlLCBrKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdiA9IHN0cihrLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRpYWwucHVzaChxdW90ZShrKSArIChcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2FwXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IFwiOiBcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBcIjpcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgKyB2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuLy8gSm9pbiBhbGwgb2YgdGhlIG1lbWJlciB0ZXh0cyB0b2dldGhlciwgc2VwYXJhdGVkIHdpdGggY29tbWFzLFxuLy8gYW5kIHdyYXAgdGhlbSBpbiBicmFjZXMuXG5cbiAgICAgICAgICAgIHYgPSBwYXJ0aWFsLmxlbmd0aCA9PT0gMFxuICAgICAgICAgICAgICAgID8gXCJ7fVwiXG4gICAgICAgICAgICAgICAgOiBnYXBcbiAgICAgICAgICAgICAgICAgICAgPyBcIntcXG5cIi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gICAgZnVuY3Rpb24gd2Fsayhob2xkZXIsIGtleSkge1xuXG4vLyBUaGUgd2FsayBtZXRob2QgaXMgdXNlZCB0byByZWN1cnNpdmVseSB3YWxrIHRoZSByZXN1bHRpbmcgc3RydWN0dXJlIHNvXG4vLyB0aGF0IG1vZGlmaWNhdGlvbnMgY2FuIGJlIG1hZGUuXG5cbiAgICAgICAgICAgICAgICB2YXIgaztcbiAgICAgICAgICAgICAgICB2YXIgdjtcbiAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBob2xkZXJba2V5XTtcbiAgICAgICAgICAgICAgICBpZiAodmFsdWUgJiYgdHlwZW9mIHZhbHVlID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAoayBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbCh2YWx1ZSwgaykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ID0gd2Fsayh2YWx1ZSwgayk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZVtrXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHZhbHVlW2tdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gcmV2aXZlci5jYWxsKGhvbGRlciwga2V5LCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG5cblxuLy8gUGFyc2luZyBoYXBwZW5zIGluIGZvdXIgc3RhZ2VzLiBJbiB0aGUgZmlyc3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AgZGlzcGxheVRleHQ6IHN1Z2dlc3RlZFN0cmluZyxcbiAgICAgICAgICBoaW50OiBzZWxlY3RIaW50XG4gICAgICAgIH0pO1xuICAgICAgfVxuXG4gICAgICBzdGFydENoYXIgPSB0b2tlbi5zdGFydFxuIFxuICAgIH1cblxuICAgIHZhciBjdXIgPSB5YXNoZS5nZXRDdXJzb3IoKTtcbiAgICB2YXIgcmV0dXJuT2JqID0ge1xuICAgICAgY29tcGxldGlvblRva2VuOiB0b2tlbi5zdHJpbmcsXG4gICAgICBsaXN0OiBoaW50TGlzdCxcbiAgICAgIGZyb206IHtcbiAgICAgICAgbGluZTogY3VyLmxpbmUsXG4gICAgICAgIGNoOiBzdGFydENoYXJcbiAgICAgIH0sXG4gICAgICB0bzoge1xuICAgICAgICBsaW5lOiBjdXIubGluZSxcbiAgICAgICAgY2g6IHRva2VuLmVuZFxuICAgICAgfVxuICAgIH07XG5cbiAgICAvL2lmIHdlIGhhdmUgc29tZSBhdXRvY29tcGxldGlvbiBoYW5kbGVycyBzcGVjaWZpZWQsIGFkZCB0aGVzZSB0aGVzZSB0byB0aGUgb2JqZWN0LiBDb2RlbWlycm9yIHdpbGwgdGFrZSBjYXJlIG9mIGZpcmluZyB0aGVzZVxuICAgIGlmIChjb21wbGV0ZXIuY2FsbGJhY2tzKSB7XG4gICAgICBmb3IgKHZhciBjYWxsYmFja05hbWUgaW4gY29tcGxldGVyLmNhbGxiYWNrcykge1xuICAgICAgICBpZiAoY29tcGxldGVyLmNhbGxiYWNrc1tjYWxsYmFja05hbWVdKSB7XG4gICAgICAgICAgWUFTSEUub24ocmV0dXJuT2JqLCBjYWxsYmFja05hbWUsIGNvbXBsZXRlci5jYWxsYmFja3NbY2FsbGJhY2tOYW1lXSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHJldHVybk9iajtcbiAgfTtcblxuICByZXR1cm4ge1xuICAgIGluaXQ6IGluaXRDb21wbGV0ZXIsXG4gICAg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VByb3BlcnRpZXNQcmVmaXgoeWFzaGUscHJlZml4KSl7XG4gICAgICAgICAgcXVlcnkudHlwZT0ncHJvcGVydHknXG4gICAgICAgIH1lbHNle1xuICAgICAgICAgIGRlbGV0ZSBxdWVyeS50eXBlXG4gICAgICAgIH1cblxuXG4gICAgICAgICQuZ2V0KFxuICAgICAgICAgICAge1xuICAgICAgICAgIFxuICAgICAgICAgICAgICB1cmw6IEFQSV9FTkRQT0lOVCArICc/JyArICQucGFyYW0ocXVlcnkpLFxuICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb25wJyxcbiAgICAgICAgICBcbiAgICAgICAgICAgIH0pLmRvbmUoIGZ1bmN0aW9uKCBkYXRhICkge1xuXG4gICAgICAgICAgICAgIHZhciBsaXN0ID1bXVxuICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgLy9UaGlzIGNvbmRpdGlvbiBpcyBmb3IgYW4gZW1wdHkgc2VhcmNoXG4gICAgICAgICAgICAgIGlmKGRhdGEuZXJyb3Ipe1xuICAgICAgICAgICAgICAgIGxpc3QgPSBbIHtcbiAgICAgICAgICAgICAgICAgIHRleHQ6ICcnLFxuICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6ICdUeXBlIHRvIHNlYXJjaCBmb3IgYW4gZW50aXR5J1xuICAgICAgICAgICAgICAgIH0gXTtcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhsaXN0KVxuICAgIFxuICAgICAgICAgICAgICB9ZWxzZXtcblxuICAgICAgICAgICAgICAgIHZhciBlbnRpdGllcyA9IFtdXG4gICAgICAgICAgICAgICAgdmFyIGxhYmVsLGlkLGRlc2NyaXB0aW9uLGVudGl0aWVzXG4gICAgICAgICAgICAgICAgZm9yKHZhciBlbnRpdHkgaW4gZGF0YS5zZWFyY2gpe1xuXG4gICAgICAgICAgICAgICAgICAgIGxhYmVsID0gZGF0YS5zZWFyY2hbZW50aXR5XS5sYWJlbFxuICAgICAgICAgICAgICAgICAgICBpZCA9IGRhdGEuc2VhcmNoW2VudGl0eV0uaWRcbiAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSBkYXRhLnNlYXJjaFtlbnRpdHldLmRlc2NyaXB0aW9uXG5cbiAgICAgICAgICAgICAgICAgICAgbGlzdCA9ICB7XG4gICAgICAgICAgICAgICAgICAgICAgdGV4dDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6IGxhYmVsICsgXCIgKFwiICsgaWQgKyBcIikgXFxuIFwiICsgZGVzY3JpcHRpb25cbiAgICAgICAgICAgICAgICAgICAgfSA7XG5cbiAgICAgICAgICAgICAgICAgICAgZW50aXRpZXMucHVzaChsaXN0KVxuICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbnRpdGllcy5zb3J0KClcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhlbnRpdGllcylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICAgIFxuICAgICAgICBcbiAgICB9LFxuICAgIGFzeW5jOiB0cnVlLFxuICAgIGJ1bGs6IGZhbHNlLFxuICAgIGF1dG9TaG93OiBmYWxzZVxuICB9O1xufTtcblxubW9kdWxlLmV4cG9ydHMuaXNWYWxpZENvbXBsZXRpb25Qb3NpdGlvbiA9IGZ1bmN0aW9uKHlhc2hlKSB7XG5cblxuICBcbiAgdmFyIHRva2VuID0geWFzaGUuZ2V0Q29tcGxldGVUb2tlbigpO1xuICB2YXIgY3VyID0geWFzaGUuZ2V0Q3Vyc29yKClcblxuICAvL1RoZSBjdXJzb3Igc2hvdWxkIHN0YXkgYXQgdGhlIGVuZCBvZiB0aGUgdG9rZW5cbiAgaWYodG9rZW4uZW5kIT1jdXIuY2gpcmV0dXJuIGZhbHNlXG5cbiAgdmFyIHByZWZpeE5hbWUgPSB0b2tlbi5zdHJpbmcuc3BsaXQoJzonKVswXVxuICB2YXIgcHJldmlvdXNUb2tlbiA9IHlhc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rKSB7XG4gICAgICB2YXIgbGluZSA9IHlhc2hlLmdldExpbmUoaSk7XG4gICAgICBpZiAobGluZS5sZW5ndGggPT0gMCB8fCBsaW5lLnN1YnN0cmluZygwLCAxKSAhPSBcIiNcIikge1xuICAgICAgICBsaW5lc0FyZUNvbW1lbnRlZCA9IGZhbHNlO1xuICAgICAgICBicmVhaztcbiAgICAgIH1cbiAgICB9XG4gICAgZm9yICh2YXIgaSA9IG1pbjsgaSA8PSBtYXg7IGkrKykge1xuICAgICAgaWYgKGxpbmVzQXJlQ29tbWVudGVkKSB7XG4gICAgICAgIC8vIGxpbmVzIGFyZSBjb21tZW50ZWQsIHNvIHJlbW92ZSBjb21tZW50c1xuICAgICAgICB5YXNoZS5yZXBsYWNlUmFuZ2UoXG4gICAgICAgICAgXCJcIixcbiAgICAgICAgICB7XG4gICAgICAgICAgICBsaW5lOiBpLFxuICAgICAgICAgICAgY2g6IDBcbiAgICAgICAgICB9LFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIGxpbmU6IGksXG4gICAgICAgICAgICBjaDogMVxuICAgICAgICAgIH1cbiAgICAgICAgKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIC8vIE5vdCBhbGwgbGluZXMgYXJlIGNvbW1lbnRlZCwgc28gYWRkIGNvbW1lbnRzXG4gICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShcIiNcIiwge1xuICAgICAgICAgIGxpbmU6IGksXG4gICAgICAgICAgY2g6IDBcbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfVxuICB9O1xuXG52YXIgY29weUxpbmVVcCA9IGZ1bmN0aW9uKHlhc2hlKSB7XG4gICAgdmFyIGN1cnNvciA9IHlhc2hlLmdldEN1cnNvcigpO1xuICAgIHZhciBsaW5lQ291bnQgPSB5YXNoZS5saW5lQ291bnQoKTtcbiAgICAvLyBGaXJzdCBjcmVhdGUgbmV3IGVtcHR5IGxpbmUgYXQgZW5kIG9mIHRleHRcbiAgICB5YXNoZS5y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ICAgICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgICAgICB9O1xuICAgICAgICAgIH1cblxuICAgICAgICAgICovXG4gICAgICAgICAgXG5cbiAgICAgIFxuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNhdDogdGVybWluYWxzW2ldLm5hbWUsXG4gICAgICAgICAgICBzdHlsZTogdGVybWluYWxzW2ldLnN0eWxlLFxuICAgICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgICBzdGFydDogc3RyZWFtLnN0YXJ0XG4gICAgICAgICAgfTtcblxuICAgICAgICB9XG4gICAgICAgIFxuICAgICAgXG4gICAgICAgIFxuICAgICAgfVxuXG4gIFxuICAgICAgLy8gS2V5d29yZHNcbiAgICAgIGNvbnN1bWVkID0gc3RyZWFtLm1hdGNoKGdyYW1tYXIua2V5d29yZHMsIHRydWUsIGZhbHNlKTtcbiAgICAgIGlmIChjb25zdW1lZCl7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgY2F0OiBzdHJlYW0uY3VycmVudCgpLnRvVXBwZXJDYXNlKCksXG4gICAgICAgICAgc3R5bGU6IFwia2V5d29yZFwiLFxuICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxuICAgICAgICAgIHN0YXJ0OiBzdHJlYW0uc3RhcnRcbiAgICAgICAgfTtcbiAgICAgIH1cblxuICAgICAgLy8gUHVuY3R1YXRpb25cbiAgICAgIGNvbnN1bWVkID0gc3RyZWFtLm1hdGNoKGdyYW1tYXIucHVuY3QsIHRydWUsIGZhbHNlKTtcbiAgICAgIGlmIChjb25zdW1lZCl7XG4gICAgICAgIGlmKHN0cmVhbS5jdXJyZW50KCkhPScqJyBcbiAgICAgICAgICAmJiBzdHJlYW0uY3VycmVudCgpIT0nKydcbiAgICAgICAgICAgJiYgc3RyZWFtLmN1cnJlbnQoKSE9J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lQ29uc3RyYWludCcpe1xuICAgICAgICAgIGlmKHRva2VuIT0nWycpe1xuICAgICAgICAgICAgaWYoIXRva2VuLm1hdGNoKGdyYW1tYXIua2V5d29yZHMpKXtcbiAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdjb25zdHJhaW50JztcbiAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdjb25zdHJhaW50S2V5d29yZCc7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYodG9wU3ltYm9sPT0nY2FyZGluYWxpdHknKXtcbiAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdjYXJkaW5hbGl0eSc7XG4gICAgICAgIH1cblxuICAgICAgICBpZih0b3BTeW1ib2wgPT0gJ3hzRmFjZXQnKXtcbiAgICAgICAgICB0b2tlbk9iLnN0eWxlPSdmYWNldCc7XG5cbiAgICAgICAgfVxuXG4gICAgICAgIGlmKHRvcFN5bWJvbCA9PSAndmFsdWVTZXRWYWx1ZScpe1xuICAgICAgICAgIHRva2VuT2Iuc3R5bGU9J3ZhbHVlU2V0JztcbiAgICAgICAgfVxuICAgICAgIFxuXG4gICAgICAgIGlmICh0b3BTeW1ib2wgPT09ICd2YXInICYmIHRva2VuT2IudGV4dCkgc3RhdGUudmFyaWFibGVzW3Rva2VuT2IudGV4dF0gPSB0b2tlbk9iLnRleHQ7XG4gICAgICAgIGlmICghbGwxX3RhYmxlW3RvcFN5bWJvbF0pIHtcbiAgICAgICAgICAvLyBUb3Agc3ltYm9sIGlzIGEgdGVybWluYWxcbiAgICAgICAgICBpZiAodG9wU3ltYm9sID09IHRva2VuKSB7XG4gICAgICAgICAgICBpZiAoc3RhdGUuaW5QcmVmaXhEZWNsKSB7XG4gICAgICAgICAgICAgIGlmICh0b3BTeW1ib2wgPT09IFwiUE5BTUVfTlNcIiAmJiB0b2tlbk9iLnRleHQubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgIHN0YXRlLmN1cnJlbnRQbmFtZU5zID0gdG9rZW5PYi50ZXh0LnNsaWNlKDAsIC0xKTtcbiAgICAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlID0gJ3ByZWZpeERlbGMnXG4gICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RhdGUuY3VycmVudFBuYW1lTnMgIT09IHVuZGVmaW5lZCAmJiB0b2tlbk9iLnRleHQubGVuZ3RoID4gMikge1xuICAgICAgICAgICAgICAgIHRva2VuT2Iuc3R5bGUgPSAncHJlZml4RGVsYydcbiAgICAgICAgICAgICAgICBzdGF0ZS5wcmVmaXhlc1tzdGF0ZS5jdXJyZW50UG5hbWVOc10gPSB0b2tlbk9iLnRleHQuc2xpY2UoMSwgLTEpO1xuICAgICAgICAgICAgICAgIC8vcmVzZXQgY3VycmVudCBwbmFtZSBuc1xuICAgICAgICAgICAgICAgIHN0YXRlLmN1cnJlbnRQbmFtZU5zID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBNYXRjaGluZyB0ZXJtaW5hbHNcbiAgICAgICAgICAgIC8vIC0gY29uc3VtZSB0b2tlbiBmcm9tIGlucHV0IHN0cmVhbVxuICAgICAgICAgICAgZmluaXNoZWQgPSB0cnVlO1xuICAgICAgICAgICAgLy9zZXRRdWVyeVR5cGUodG9wU3ltYm9sKTtcbiAgICAgICAgICAgIC8vIENoZWNrIHdoZXRoZXIgJCAoZW5kIG9mIGlucHV0IHRva2VuKSBpcyBwb3NzIG5leHRcbiAgICAgICAgICAgIC8vIGZvciBldmVyeXRoaW5nIG9uIHN0YWNrXG4gICAgICAgICAgICB2YXIgYWxsTmlsbGFibGUgPSB0cnVlO1xuICAgICAgICAgICAgZm9yICh2YXIgc3AgPSBzdGF0ZS5zdGFjay5sZW5ndGg7IHNwID4gMDsgLS1zcCkge1xuICAgICAgICAgICAgICB2YXIgaXRlbSA9IGxsMV90YWJs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gICBzdGF0ZS5PSyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgcmVjb3JkRmFpbHVyZVBvcygpO1xuICAgICAgICAgICAgICAgICAgc3RhdGUuZXJyb3JNc2cgPSBcIlByZWZpeCAnXCIgKyBwcmVmTnMgKyBcIicgaXMgbm90IGRlZmluZWRcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcbiAgICAgICAgICAgIHN0YXRlLmNvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgICAgICByZWNvcmRGYWlsdXJlUG9zKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIC8vIHRvcFN5bWJvbCBpcyBub250ZXJtaW5hbFxuICAgICAgICAgIC8vIC0gc2VlIGlmIHRoZXJlIGlzIGFuIGVudHJ5IGZvciB0b3BTeW1ib2xcbiAgICAgICAgICAvLyBhbmQgbmV4dFRva2VuIGluIHRhYmxlXG4gICAgICAgICAgXG4gICAgICAgICAgdmFyIG5leHRTeW1ib2xzID0gbGwxX3RhYmxlW3RvcFN5bWJvbF1bdG9rZW5dO1xuICAgICAgICAgIGlmIChuZXh0U3ltYm9scyAhPSB1bmRlZmluZWQgJiYgY2hlY2tTaWRlQ29uZGl0aW9ucyh0b3BTeW1ib2wpKSB7XG4gICAgICAgICAgICAvLyBNYXRjaCAtIGNvcHkgUkhTIG9mIHJ1bGUgdG8gc3RhY2tcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSBuZXh0U3ltYm9scy5sZW5ndGggLSAxOyBpID49IDA7IC0taSkge1xuICAgICAgICAgICAgICBzdGF0ZS5zdGFjay5wdXNoKG5leHRTeW1ib2xzW2ldKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIFBlZm9ybSBhbnkgbm9uLWdyYW1tYXRpY2FsIHNp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dnZXIpIHtcbiAgICAgICAgICAgIHZhciBfdGhpczIgPSB0aGlzO1xuXG4gICAgICAgICAgICB0aGlzLmxpc3RlbmVyID0gKDAsIF9nb29kTGlzdGVuZXIyLmRlZmF1bHQpKHRyaWdnZXIsICdjbGljaycsIGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzMi5vbkNsaWNrKGUpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVmaW5lcyBhIG5ldyBgQ2xpcGJvYXJkQWN0aW9uYCBvbiBlYWNoIGNsaWNrIGV2ZW50LlxuICAgICAgICAgKiBAcGFyYW0ge0V2ZW50fSBlXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdvbkNsaWNrJyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIG9uQ2xpY2soZSkge1xuICAgICAgICAgICAgdmFyIHRyaWdnZXIgPSBlLmRlbGVnYXRlVGFyZ2V0IHx8IGUuY3VycmVudFRhcmdldDtcblxuICAgICAgICAgICAgaWYgKHRoaXMuY2xpcGJvYXJkQWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLmNsaXBib2FyZEFjdGlvbiA9IG5ldyBfY2xpcGJvYXJkQWN0aW9uMi5kZWZhdWx0KHtcbiAgICAgICAgICAgICAgICBhY3Rpb246IHRoaXMuYWN0aW9uKHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIHRhcmdldDogdGhpcy50YXJnZXQodHJpZ2dlciksXG4gICAgICAgICAgICAgICAgdGV4dDogdGhpcy50ZXh0KHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogdGhpcy5jb250YWluZXIsXG4gICAgICAgICAgICAgICAgdHJpZ2dlcjogdHJpZ2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W4uXG4gICAgICAgICAqIEBwYXJhbSB7U3RyaW5nfSBbYWN0aW9uXVxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnZGVmYXVsdFRleHQnLFxuXG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIERlZmF1bHQgYHRleHRgIGxvb2t1cCBmdW5jdGlvbi5cbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSB0cmlnZ2VyXG4gICAgICAgICAqL1xuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVmYXVsdFRleHQodHJpZ2dlcikge1xuICAgICAgICAgICAgcmV0dXJuIGdldEF0dHJpYnV0ZVZhbHVlKCd0ZXh0JywgdHJpZ2dlcik7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVzdHJveSBsaWZlY3ljbGUuXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdkZXN0cm95JyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGRlc3Ryb3koKSB7XG4gICAgICAgICAgICB0aGlzLmxpc3RlbmVyLmRlc3Ryb3koKTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuY2xpcGJvYXJkQWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24uZGVzdHJveSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuY2xpcGJvYXJkQWN0aW9uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1dLCBbe1xuICAgICAgICBrZXk6ICdpc1N1cHBvcnRlZCcsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBpc1N1cHBvcnRlZCgpIHtcbiAgICAgICAgICAgIHZhciBhY3Rpb24gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFsnY29weScsICdjdXQn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ovXG5cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ2luaXRTZWxlY3Rpb24nLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gaW5pdFNlbGVjdGlvbigpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLnRleHQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdEZha2UoKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy50YXJnZXQpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNlbGVjdFRhcmdldCgpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIENyZWF0ZXMgYSBmYWtlIHRleHRhcmVhIGVsZW1lbnQsIHNldHMgaXRzIHZhbHVlIGZyb20gYHRleHRgIHByb3BlcnR5LFxuICAgICAgICAgKiBhbmQgbWFrZXMgYSBzZWxlY3Rpb24gb24gaXQuXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdzZWxlY3RGYWtlJyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIHNlbGVjdEZha2UoKSB7XG4gICAgICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuXG4gICAgICAgICAgICB2YXIgaXNSVEwgPSBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuZ2V0QXR0cmlidXRlKCdkaXInKSA9PSAncnRsJztcblxuICAgICAgICAgICAgdGhpcy5yZW1vdmVGYWtlKCk7XG5cbiAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXJDYWxsYmFjayA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gX3RoaXMucmVtb3ZlRmFrZSgpO1xuICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXIgPSB0aGlzLmNvbnRhaW5lci5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIHRoaXMuZmFrZUhhbmRsZXJDYWxsY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HQ7XG5cbiAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZENoaWxkKHRoaXMuZmFrZUVsZW0pO1xuXG4gICAgICAgICAgICB0aGlzLnNlbGVjdGVkVGV4dCA9ICgwLCBfc2VsZWN0Mi5kZWZhdWx0KSh0aGlzLmZha2VFbGVtKTtcbiAgICAgICAgICAgIHRoaXMuY29weVRleHQoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBPbmx5IHJlbW92ZXMgdGhlIGZha2UgZWxlbWVudCBhZnRlciBhbm90aGVyIGNsaWNrIGV2ZW50LCB0aGF0IHdheVxuICAgICAgICAgKiBhIHVzZXIgY2FuIGhpdCBgQ3RybCtDYCB0byBjb3B5IGJlY2F1c2Ugc2VsZWN0aW9uIHN0aWxsIGV4aXN0cy5cbiAgICAgICAgICovXG5cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ3JlbW92ZUZha2UnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gcmVtb3ZlRmFrZSgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VIYW5kbGVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcignY2xpY2snLCB0aGlzLmZha2VIYW5kbGVyQ2FsbGJhY2spO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXJDYWxsYmFjayA9IG51bGw7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VFbGVtKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlQ2hpbGQodGhpcy5mYWtlRWxlbSk7XG4gICAgICAgICAgICAgICAgdGhpcy5mYWtlRWxlbSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKipcb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uICAgICAgICAgKiBAcGFyYW0ge1N0cmluZ30gYWN0aW9uXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdkZXN0cm95JyxcblxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBEZXN0cm95IGxpZmVjeWNsZS5cbiAgICAgICAgICovXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkZXN0cm95KCkge1xuICAgICAgICAgICAgdGhpcy5yZW1vdmVGYWtlKCk7XG4gICAgICAgIH1cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ2FjdGlvbicsXG4gICAgICAgIHNldDogZnVuY3Rpb24gc2V0KCkge1xuICAgICAgICAgICAgdmFyIGFjdGlvbiA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogJ2NvcHknO1xuXG4gICAgICAgICAgICB0aGlzLl9hY3Rpb24gPSBhY3Rpb247XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9hY3Rpb24gIT09ICdjb3B5JyAmJiB0aGlzLl9hY3Rpb24gIT09ICdjdXQnKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIFwiYWN0aW9uXCIgdmFsdWUsIHVzZSBlaXRoZXIgXCJjb3B5XCIgb3IgXCJjdXRcIicpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEdldHMgdGhlIGBhY3Rpb25gIHByb3BlcnR5LlxuICAgICAgICAgKiBAcmV0dXJuIHtTdHJpbmd9XG4gICAgICAgICAqL1xuICAgICAgICAsXG4gICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2FjdGlvbjtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBTZXRzIHRoZSBgdGFyZ2V0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7XG4gICAgICBpZiAoKHNwLmZyb20gPT0gbnVsbCB8fCAobS5pbmNsdXNpdmVMZWZ0ID8gc3AuZnJvbSA8PSBwb3MuY2ggOiBzcC5mcm9tIDwgcG9zLmNoKSkgJiZcbiAgICAgICAgICAoc3AudG8gPT0gbnVsbCB8fCAobS5pbmNsdXNpdmVSaWdodCA/IHNwLnRvID49IHBvcy5jaCA6IHNwLnRvID4gcG9zLmNoKSkpIHtcbiAgICAgICAgaWYgKG1heUNsZWFyKSB7XG4gICAgICAgICAgc2lnbmFsKG0sIFwiYmVmb3JlQ3Vyc29yRW50ZXJcIik7XG4gICAgICAgICAgaWYgKG0uZXhwbGljaXRseUNsZWFyZWQpIHtcbiAgICAgICAgICAgIGlmICghbGluZS5tYXJrZWRTcGFucykgYnJlYWs7XG4gICAgICAgICAgICBlbHNlIHstLWk7IGNvbnRpbnVlO31cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFtLmF0b21pYykgY29udGludWU7XG5cbiAgICAgICAgaWYgKG9sZFBvcykge1xuICAgICAgICAgIHZhciBuZWFyID0gbS5maW5kKGRpciA8IDAgPyAxIDogLTEpLCBkaWZmO1xuICAgICAgICAgIGlmIChkaXIgPCAwID8gbS5pbmNsdXNpdmVSaWdodCA6IG0uaW5jbHVzaXZlTGVmdClcbiAgICAgICAgICAgIG5lYXIgPSBtb3ZlUG9zKGRvYywgbmVhciwgLWRpciwgbmVhciAmJiBuZWFyLmxpbmUgPT0gcG9zLmxpbmUgPyBsaW5lIDogbnVsbCk7XG4gICAgICAgICAgaWYgKG5lYXIgJiYgbmVhci5saW5lID09IHBvcy5saW5lICYmIChkaWZmID0gY21wKG5lYXIsIG9sZFBvcykpICYmIChkaXIgPCAwID8gZGlmZiA8IDAgOiBkaWZmID4gMCkpXG4gICAgICAgICAgICByZXR1cm4gc2tpcEF0b21pY0lubmVyKGRvYywgbmVhciwgcG9zLCBkaXIsIG1heUNsZWFyKTtcbiAgICAgICAgfVxu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bSwgbikge1xuICAgIGlmIChuID49IGNtLmRpc3BsYXkudmlld1RvKSByZXR1cm4gbnVsbDtcbiAgICBuIC09IGNtLmRpc3BsYXkudmlld0Zyb207XG4gICAgaWYgKG4gPCAwKSByZXR1cm4gbnVsbDtcbiAgICB2YXIgdmlldyA9IGNtLmRpc3BsYXkudmlldztcbiAgICBmb3IgKHZhciBpID0gMDsgaSA8IHZpZXcubGVuZ3RoOyBpKyspIHtcbiAgICAgIG4gLT0gdmlld1tpXS5zaXplO1xuICAgICAgaWYgKG4gPCAwKSByZXR1cm4gaTtcbiAgICB9XG4gIH1cblxuICBmdW5jdGlvbiB2aWV3Q3V0dGluZ1BvaW50KGNtLCBvbGROLCBuZXdOLCBkaXIpIHtcbiAgICB2YXIgaW5kZXggPSBmaW5kVmlld0luZGV4KGNtLCBvbGROKSwgZGlmZiwgdmlldyA9IGNtLmRpc3BsYXkudmlldztcbiAgICBpZiAoIXNhd0NvbGxhcHNlZFNwYW5zIHx8IG5ld04gPT0gY20uZG9jLmZpcnN0ICsgY20uZG9jLnNpemUpXG4gICAgICByZXR1cm4ge2luZGV4OiBpbmRleCwgbGluZU46IG5ld059O1xuICAgIGZvciAodmFyIGkgPSAwLCBuID0gY20uZGlzcGxheS52aWV3RnJvbTsgaSA8IGluZGV4OyBpKyspXG4gICAgICBuICs9IHZpZXdbaV0uc2l6ZTtcbiAgICBpZiAobiAhPSBvbGROKSB7XG4gICAgICBpZiAoZGlyID4gMCkge1xuICAgICAgICBpZiAoaW5kZXggPT0gdmlldy5sZW5ndGggLSAxKSByZXR1cm4gbnVsbDtcbiAgICAgICAgZGlmZiA9IChuICsgdmlld1tpbmRleF0uc2l6ZSkgLSBvbGROO1xuICAgICAgICBpbmRleCsrO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgZGlmZiA9IG4gLSBvbGROO1xuICAgICAgfVxuICAgICAgb2xkTiArPSBkaWZmOyBuZXdOICs9IGRpZmY7XG4gICAgfVxuICAgIHdoaWxlICh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gbnVsbCkge1xuICAgICAgICByYW5nZSA9IHtmcm9tOiByYW5nZSwgdG86IG51bGx9O1xuICAgICAgfVxuICAgICAgaWYgKCFyYW5nZS50bykgcmFuZ2UudG8gPSByYW5nZS5mcm9tO1xuICAgICAgcmFuZ2UubWFyZ2luID0gbWFyZ2luIHx8IDA7XG5cbiAgICAgIGlmIChyYW5nZS5mcm9tLmxpbmUgIT0gbnVsbCkge1xuICAgICAgICByZXNvbHZlU2Nyb2xsVG9Qb3ModGhpcyk7XG4gICAgICAgIHRoaXMuY3VyT3Auc2Nyb2xsVG9Qb3MgPSByYW5nZTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHZhciBzUG9zID0gY2FsY3VsYXRlU2Nyb2xsUG9zKHRoaXMsIE1hdGgubWluKHJhbmdlLmZyb20ubGVmdCwgcmFuZ2UudG8ubGVmdCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWluKHJhbmdlLmZyb20udG9wLCByYW5nZS50by50b3ApIC0gcmFuZ2UubWFyZ2luLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYXRoLm1heChyYW5nZS5mcm9tLnJpZ2h0LCByYW5nZS50by5yaWdodCksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1hdGgubWF4KHJhbmdlLmZyb20uYm90dG9tLCByYW5nZS50by5ib3R0b20pICsgcmFuZ2UubWFyZ2luKTtcbiAgICAgICAgdGhpcy5zY3JvbGxUbyhzUG9zLnNjcm9sbExlZnQsIHNQb3Muc2Nyb2xsVG9wKTtcbiAgICAgIH1cbiAgICB9KSxcblxuICAgIHNldFNpemU6IG1ldGhvZE9wKGZ1bmN0aW9uKHdpZHRoLCBoZWlnaHQpIHtcbiAgICAgIHZhciBjbSA9IHRoaXM7XG4gICAgICBmdW5jdGlvbiBpbnRlcnByZXQodmFsKSB7XG4gICAgICAgIHJldHVybiB0eXBlb2YgdmFsID09IFwibnV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BpZiAobGluZSkge1xuICAgICAgICAgICAgaWYgKGN1ci5jaCA9PSBsaW5lLmxlbmd0aCkgY3VyID0gbmV3IFBvcyhjdXIubGluZSwgY3VyLmNoIC0gMSk7XG4gICAgICAgICAgICBpZiAoY3VyLmNoID4gMCkge1xuICAgICAgICAgICAgICBjdXIgPSBuZXcgUG9zKGN1ci5saW5lLCBjdXIuY2ggKyAxKTtcbiAgICAgICAgICAgICAgY20ucmVwbGFjZVJhbmdlKGxpbmUuY2hhckF0KGN1ci5jaCAtIDEpICsgbGluZS5jaGFyQXQoY3VyLmNoIC0gMiksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQb3MoY3VyLmxpbmUsIGN1ci5jaCAtIDIpLCBjdXIsIFwiK3RyYW5zcG9zZVwiKTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAoY3VyLmxpbmUgPiBjbS5kb2MuZmlyc3QpIHtcbiAgICAgICAgICAgICAgdmFyIHByZXYgPSBnZXRMaW5lKGNtLmRvYywgY3VyLmxpbmUgLSAxKS50ZXh0O1xuICAgICAgICAgICAgICBpZiAocHJldilcbiAgICAgICAgICAgICAgICBjbS5yZXBsYWNlUmFuZ2UobGluZS5jaGFyQXQoMCkgKyBjbS5kb2MubGluZVNlcGFyYXRvcigpICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jaGFyQXQocHJldi5sZW5ndGggLSAxKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUG9zKGN1ci5saW5lIC0gMSwgcHJldi5sZW5ndGggLSAxKSwgUG9zKGN1ci5saW5lLCAxKSwgXCIrdHJhbnNwb3NlXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBuZXdTZWwucHVzaChuZXcgUmFuZ2UoY3VyLCBjdXIpKTtcbiAgICAgICAgfVxuICAgICAgICBjbS5zZXRTZWxlY3Rpb25zKG5ld1NlbCk7XG4gICAgICB9KTtcbiAgICB9LFxuIC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2hhbmdlID0gMCwgc3BhblN0eWxlLCBzcGFuRW5kU3R5bGUsIHNwYW5TdGFydFN0eWxlLCB0aXRsZSwgY29sbGFwc2VkO1xuICAgIGZvciAoOzspIHtcbiAgICAgIGlmIChuZXh0Q2hhbmdlID09IHBvcykgeyAvLyBVcGRhdGUgY3VycmVudCBtYXJrZXIgc2V0XG4gICAgICAgIHNwYW5TdHlsZSA9IHNwYW5FbmRTdHlsZSA9IHNwYW5TdGFydFN0eWxlID0gdGl0bGUgPSBjc3MgPSBcIlwiO1xuICAgICAgICBjb2xsYXBzZWQgPSBudWxsOyBuZXh0Q2hhbmdlID0gSW5maW5pdHk7XG4gICAgICAgIHZhciBmb3VuZEJvb2ttYXJrcyA9IFtdLCBlbmRTdHlsZXNcbiAgICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCBzcGFucy5sZW5ndGg7ICsraikge1xuICAgICAgICAgIHZhciBzcCA9IHNwYW5zW2pdLCBtID0gc3AubWFya2VyO1xuICAgICAgICAgIGlmIChtLnR5cGUgPT0gXCJib29rbWFya1wiICYmIHNwLmZyb20gPT0gcG9zICYmIG0ud2lkZ2V0Tm9kZSkge1xuICAgICAgICAgICAgZm91bmRCb29rbWFya3MucHVzaChtKTtcbiAgICAgICAgICB9IGVsc2UgaWYgKHNwLmZyb20gPD0gcG9zICYmIChzcC50byA9PSBudWxsIHx8IHNwLnRvID4gcG9zIHx8IG0uY29sbGFwc2VkICYmIHNwLnRvID09IHBvcyAmJiBzcC5mcm9tID09IHBvcykpIHtcbiAgICAgICAgICAgIGlmIChzcC50byAhPSBudWxsICYmIHNwLnRvICE9IHBvcyAmJiBuZXh0Q2hhbmdlID4gc3AudG8pIHtcbiAgICAgICAgICAgICAgbmV4dENoYW5nZSA9IHNwLnRvO1xuICAgICAgICAgICAgICBzcGFuRW5kU3R5bGUgPSBcIlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG0uY2xhc3NOYW1lKSBzcGFuU3R5bGUgKz0g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mxlbmd0aDsgKytqKVxuICAgICAgICAgIGJ1aWxkQ29sbGFwc2VkU3BhbihidWlsZGVyLCAwLCBmb3VuZEJvb2ttYXJrc1tqXSk7XG4gICAgICAgIGlmIChjb2xsYXBzZWQgJiYgKGNvbGxhcHNlZC5mcm9tIHx8IDApID09IHBvcykge1xuICAgICAgICAgIGJ1aWxkQ29sbGFwc2VkU3BhbihidWlsZGVyLCAoY29sbGFwc2VkLnRvID09IG51bGwgPyBsZW4gKyAxIDogY29sbGFwc2VkLnRvKSAtIHBvcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sbGFwc2VkLm1hcmtlciwgY29sbGFwc2VkLmZyb20gPT0gbnVsbCk7XG4gICAgICAgICAgaWYgKGNvbGxhcHNlZC50byA9PSBudWxsKSByZXR1cm47XG4gICAgICAgICAgaWYgKGNvbGxhcHNlZC50byA9PSBwb3MpIGNvbGxhcHNlZCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAocG9zID49IGxlbikgYnJlYWs7XG5cbiAgICAgIHZhciB1cHRvID0gTWF0aC5taW4obGVuLCBuZXh0Q2hhbmdlKTtcbiAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgIGlmICh0ZXh0KSB7XG4gICAgICAgICAgdmFyIGVuZCA9IHBvcyArIHRleHQubGVuZ3RoO1xuICAgICAgICAgIGlmICghY29sbGFwc2VkKSB7XG4gICAgICAgICAgICB2YXIgdG9rZW5UZXh0ID0gZW5kID4gdXB0byA/IHRleHQuc2xpY2UoMCwgdXB0byAtIHBvcykgOiB0ZXh0O1xuICAgICAgICAgICAgYnVpbGRlci5hZGRUb2tlbihidWlsZGVyLCB0b2tlblRleHQsIHN0eWxlID8gc3R5bGUgKyBzcGFuU3R5bGUgOiBzcGFuU3R5bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW5TdGFydFN0eWxlLCBwb3MgKyB0b2tlblRleHQubGVuZ3RoID09IG5leHRDa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oT04pOiAgT3RoZXIgTmV1dHJhbHNcblxuICAvLyBSZXR1cm5zIG51bGwgaWYgY2hhcmFjdGVycyBhcmUgb3JkZXJlZCBhcyB0aGV5IGFwcGVhclxuICAvLyAobGVmdC10by1yaWdodCksIG9yIGFuIGFycmF5IG9mIHNlY3Rpb25zICh7ZnJvbSwgdG8sIGxldmVsfVxuICAvLyBvYmplY3RzKSBpbiB0aGUgb3JkZXIgaW4gd2hpY2ggdGhleSBvY2N1ciB2aXN1YWxseS5cbiAgdmFyIGJpZGlPcmRlcmluZyA9IChmdW5jdGlvbigpIHtcbiAgICAvLyBDaGFyYWN0ZXIgdHlwZXMgZm9yIGNvZGVwb2ludHMgMCB0byAweGZmXG4gICAgdmFyIGxvd1R5cGVzID0gXCJiYmJiYmJiYmJ0c3R3c2JiYmJiYmJiYmJiYmJic3NzdHdOTiUlJU5OTk5OTixOLE4xMTExMTExMTExTk5OTk5OTkxMTExMTExMTExMTExMTExMTExMTExMTExMTk5OTk5OTExMTExMTExMTExMTExMTExMTExMTExMTExOTk5OYmJiYmJic2JiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiLE4lJSUlTk5OTkxOTk5OTiUlMTFOTE5OTjFMTk5OTk5MTExMTExMTExMTExMTExMTExMTExMTE5MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTlwiO1xuICAgIC8vIENoYXJhY3RlciB0eXBlcyBmb3IgY29kZXBvaW50cyAweDYwMCB0byAweDZmZlxuICAgIHZhciBhcmFiaWNUeXBlcyA9IFwicnJycnJycnJycnJyLHJOTm1tbW1tbXJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJybW1tbW1tbW1tbW1tbW1ycnJycnJybm5ubm5ubm5ubiVubnJycm1ycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycm1tbW1tbW1tb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SA8IGxlbjspIHtcbiAgICAgICAgaWYgKGNvdW50c0FzTGVmdC50ZXN0KHR5cGVzW2ldKSkge1xuICAgICAgICAgIHZhciBzdGFydCA9IGk7XG4gICAgICAgICAgZm9yICgrK2k7IGkgPCBsZW4gJiYgY291bnRzQXNMZWZ0LnRlc3QodHlwZXNbaV0pOyArK2kpIHt9XG4gICAgICAgICAgb3JkZXIucHVzaChuZXcgQmlkaVNwYW4oMCwgc3RhcnQsIGkpKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICB2YXIgcG9zID0gaSwgYXQgPSBvcmRlci5sZW5ndGg7XG4gICAgICAgICAgZm9yICgrK2k7IGkgPCBsZW4gJiYgdHlwZXNbaV0gIT0gXCJMXCI7ICsraSkge31cbiAgICAgICAgICBmb3IgKHZhciBqID0gcG9zOyBqIDwgaTspIHtcbiAgICAgICAgICAgIGlmIChjb3VudHNBc051bS50ZXN0KHR5cGVzW2pdKSkge1xuICAgICAgICAgICAgICBpZiAocG9zIDwgaikgb3JkZXIuc3BsaWNlKGF0LCAwLCBuZXcgQmlkaVNwYW4oMSwgcG9zLCBqKSk7XG4gICAgICAgICAgICAgIHZhciBuc3RhcnQgPSBqO1xuICAgICAgICAgICAgICBmb3IgKCsrajsgaiA8IGkgJiYgY291bnRzQXNOdW0udGVzdCh0eXBlc1tqXSk7ICsraikge31cbiAgICAgICAgICAgICAgb3JkZXIuc3BsaWNlKGF0LCAwLCBuZXcgQmlkaVNwYW4oMiwgbnN0YXJ0LCBqKSk7XG4gICAgICAgICAgICAgIHBvcyA9IGo7XG4gICAgICAgICAgICB9IGVsc2UgKytqO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAocG9zIDwgaSkgb3JkZXIuc3BsaWNlKGF0LCAwLCBuZXcgQmlkaVNwYW4oMSwgcG9zLCBpKSk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChvcmRlclswXS5sZXZlbCA9PSAxICYmIChtID0gc3RyLm1hdGNoK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gICAgICAgICAgICBEYXRlLnByb3RvdHlwZS50b0pTT04gPSBmdW5jdGlvbiAoa2V5KSB7XG4vLyAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGYobikge1xuLy8gICAgICAgICAgICAgICAgICAgICAgLy8gRm9ybWF0IGludGVnZXJzIHRvIGhhdmUgYXQgbGVhc3QgdHdvIGRpZ2l0cy5cbi8vICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAobiA8IDEwKVxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgID8gXCIwXCIgKyBuXG4vLyAgICAgICAgICAgICAgICAgICAgICAgICAgOiBuO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldFVUQ0Z1bGxZZWFyKCkgICArIFwiLVwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTW9udGgoKSArIDEpICsgXCItXCIgK1xuLy8gICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENEYXRlKCkpICAgICAgKyBcIlRcIiArXG4vLyAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ0hvdXJzKCkpICAgICArIFwiOlwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTWludXRlcygpKSAgICsgXCI6XCIgK1xuLy8gICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENTZWNvbmRzKCkpICAgKyBcIlpcIjtcbi8vICAgICAgICAgICAgICB9O1xuXG4vLyAgICAgICAgICBZb3UgY2FuIHByb3ZpZGUgYW4gb3B0aW9uYWwgcmVwbGFjZXIgbWV0aG9kLiBJdCB3aWxsIGJlIHBhc3NlZCB0aGVcbi8vICAgICAgICAgIGtleSBhbmQgdmFsdWUgb2YgZWFjaCBtZW1iZXIsIHdpdGggdGhpcyBib3VuZCB0byB0aGUgY29udGFpbmluZ1xuLy8gICAgICAgICAgb2JqZWN0LiB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bFxuLy8gICAgICAgICAgLy8gYmUgY29udmVydGVkIHRvIERhdGUgb2JqZWN0cy5cblxuLy8gICAgICAgICAgbXlEYXRhID0gSlNPTi5wYXJzZSh0ZXh0LCBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkge1xuLy8gICAgICAgICAgICAgIHZhciBhO1xuLy8gICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09IFwic3RyaW5nXCIpIHtcbi8vICAgICAgICAgICAgICAgICAgYSA9XG4vLyAgIC9eKFxcZHs0fSktKFxcZHsyfSktKFxcZHsyfSlUKFxcZHsyfSk6KFxcZHsyfSk6KFxcZHsyfSg/OlxcLlxcZCopPylaJC8uZXhlYyh2YWx1ZSk7XG4vLyAgICAgICAgICAgICAgICAgIGlmIChhKSB7XG4vLyAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IERhdGUoRGF0ZS5VVEMoK2FbMV0sICthWzJdIC0gMSwgK2FbM10sICthWzRdLFxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgICthWzVdLCArYVs2XSkpO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbi8vICAgICAgICAgIH0pO1xuXG4vLyAgICAgICAgICBteURhdGEgPSBKU09OLnBhcnNlKCdbXCJEYXRlKDA5LzA5LzIwMDEpXCJdJywgZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcbi8vICAgICAgICAgICAgICB2YXIgZDtcbi8vICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSBcInN0cmluZ1wiICYmXG4vLyAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5zbGljZSgwLCA1KSA9PT0gXCJEYXRlKFwiICYmXG4vLyAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5zbGljZSgtMSkgPT09IFwiKVwiKSB7XG4vLyAgICAgICAgICAgICAgICAgIGQgPSBuZXcgRGF0ZSh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gIH1cblxuICAgIGlmICh0eXBlb2YgRGF0ZS5wcm90b3R5cGUudG9KU09OICE9PSBcImZ1bmN0aW9uXCIpIHtcblxuICAgICAgICBEYXRlLnByb3RvdHlwZS50b0pTT04gPSBmdW5jdGlvbiAoKSB7XG5cbiAgICAgICAgICAgIHJldHVybiBpc0Zpbml0ZSh0aGlzLnZhbHVlT2YoKSlcbiAgICAgICAgICAgICAgICA/IHRoaXMuZ2V0VVRDRnVsbFllYXIoKSArIFwiLVwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENNb250aCgpICsgMSkgKyBcIi1cIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDRGF0ZSgpKSArIFwiVFwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENIb3VycygpKSArIFwiOlwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENNaW51dGVzKCkpICsgXCI6XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ1NlY29uZHMoKSkgKyBcIlpcIlxuICAgICAgICAgICAgICAgIDogbnVsbDtcbiAgICAgICAgfTtcblxuICAgICAgICBCb29sZWFuLnByb3RvdHlwZS50b0pTT04gPSB0aGlzX3ZhbHVlO1xuICAgICAgICBOdW1iZXIucHJvdG90eXBlLnRvSlNPTiA9IHRoaXNfdmFsdWU7XG4gICAgICAgIFN0cmluZy5wcm90b3R5cGUudG9KU09OID0gdGhpc192YWx1ZTtcbiAgICB9XG5cbiAgICB2YXIgZ2FwO1xuICAgIHZhciBpbmRlbnQ7XG4gICAgdmFyIG1ldGE7XG4gICAgdmFyIHJlcDtcblxuXG4gICAgZnVuY3Rpb24gcXVvdGUoc3RyaW5nKSB7XG5cbi8vIElmIHRoZSBzdHJpbmcgY29udGFpbnMgbm8gY29udHJvbCBjaGFyYWN0ZXJzLCBubyBxdW90ZSBjaGFyYWN0ZXJz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IHRoZSBtZW1iZXJzIHRvIGJlIHN0cmluZ2lmaWVkLlxuXG4gICAgICAgICAgICBpZiAocmVwICYmIHR5cGVvZiByZXAgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICBsZW5ndGggPSByZXAubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcFtpXSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgayA9IHJlcFtpXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBzdHIoaywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsLnB1c2gocXVvdGUoaykgKyAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBcIjogXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogXCI6XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApICsgdik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuXG4vLyBPdGhlcndpc2UsIGl0ZXJhdGUgdGhyb3VnaCBhbGwgb2YgdGhlIGtleXMgaW4gdGhlIG9iamVjdC5cblxuICAgICAgICAgICAgICAgIGZvciAoayBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbHVlLCBrKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdiA9IHN0cihrLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRpYWwucHVzaChxdW90ZShrKSArIChcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2FwXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IFwiOiBcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBcIjpcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgKyB2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuLy8gSm9pbiBhbGwgb2YgdGhlIG1lbWJlciB0ZXh0cyB0b2dldGhlciwgc2VwYXJhdGVkIHdpdGggY29tbWFzLFxuLy8gYW5kIHdyYXAgdGhlbSBpbiBicmFjZXMuXG5cbiAgICAgICAgICAgIHYgPSBwYXJ0aWFsLmxlbmd0aCA9PT0gMFxuICAgICAgICAgICAgICAgID8gXCJ7fVwiXG4gICAgICAgICAgICAgICAgOiBnYXBcbiAgICAgICAgICAgICAgICAgICAgPyBcIntcXG5cIiArIGdhcCArIHBhcnRpYWwuam9pbihcIixcXG5cIiArIGdhcCkgKyBcIlxcblwiICsgbWluZCArIFwifVwiXG4gICAgICAgICAgICAgICAgICAgIDogXCJ7XCIgKyBwYXJ0aWFsLmpvaW4oXCIsXCIpICsgXCJ9XCI7XG4gICAgICAgICAgICBnYXAgPSBtaW5kO1xuICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgIH1cbiAgICB9XG5cbi8vIElmIHRoZSBKU09OIG9iamVjdCBkb2VzIG5vdCB5ZXQgaGF2ZSBhIHN0cmluZ2lmeSBtZXRob2QsIGdpdmUgaXQgb25lLlxuXG4gICAgaWYgKHR5cGVvZiBKU09OLnN0cmluZ2lmeSAhPT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgIG1ldGEgPSB7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ldGVyIGlzIGEgbnVtYmVyLCBtYWtlIGFuIGluZGVudCBzdHJpbmcgY29udGFpbmluZyB0aGF0XG4vLyBtYW55IHNwYWNlcy5cblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBzcGFjZSA9PT0gXCJudW1iZXJcIikge1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBzcGFjZTsgaSArPSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGluZGVudCArPSBcIiBcIjtcbiAgICAgICAgICAgICAgICB9XG5cbi8vIElmIHRoZSBzcGFjZSBwYXJhbWV0ZXIgaXMgYSBzdHJpbmcsIGl0IHdpbGwgYmUgdXNlZCBhcyB0aGUgaW5kZW50IHN0cmluZy5cblxuICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2Ygc3BhY2UgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICBpbmRlbnQgPSBzcGFjZTtcbiAgICAgICAgICAgIH1cblxuLy8gSWYgdGhlcmUgaXMgYSByZXBsYWNlciwgaXQgbXVzdCBiZSBhIGZ1bmN0aW9uIG9yIGFuIGFycmF5LlxuLy8gT3RoZXJ3aXNlLCB0aHJvdyBhbiBlcnJvci5cblxuICAgICAgICAgICAgcmVwID0gcmVwbGFjZXI7XG4gICAgICAgICAgICBpZiAocmVwbGFjZXIgJiYgdHlwZW9mIHJlcGxhY2VyICE9PSBcImZ1bmN0aW9uXCIgJiZcbiAgICAgICAgICAgICAgICAgICAgKHR5cGVvZiByZXBsYWNlciAhPT0gXCJvYmplY3RcIiB8fFxuICAgICAgICAgICAgICAgICAgICB0eXBlb2YgcmVwbGFjZXIubGVuZ3RoICE9PSBcIm51bWJlclwiKSkge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkpTT04uc3RyaW5naWZ5XCIpO1xuICAgICAgICAgICAgfVxuXG4vLyBNYWtlIGEgZmFrZSByb290IG9iamVjdCBjb250YWluaW5nIG91ciB2YWx1ZSB1bmR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gICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbCh2YWx1ZSwgaykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ID0gd2Fsayh2YWx1ZSwgayk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZVtrXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHZhbHVlW2tdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gcmV2aXZlci5jYWxsKGhvbGRlciwga2V5LCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG5cblxuLy8gUGFyc2luZyBoYXBwZW5zIGluIGZvdXIgc3RhZ2VzLiBJbiB0aGUgZmlyc3Qgc3RhZ2UsIHdlIHJlcGxhY2UgY2VydGFpblxuLy8gVW5pY29kZSBjaGFyYWN0ZXJzIHdpdGggZXNjYXBlIHNlcXVlbmNlcy4gSmF2YVNjcmlwdCBoYW5kbGVzIG1hbnkgY2hhcmFjdGVyc1xuLy8gaW5jb3JyZWN0bHksIGVpdGhlciBzaWxlbnRseSBkZWxldGluZyB0aGVtLCBvciB0cmVhdGluZyB0aGVtIGFzIGxpbmUgZW5kaW5ncy5cblxuICAgICAgICAgICAgdGV4dCA9IFN0cmluZyh0ZXh0KTtcbiAgICAgICAgICAgIHJ4X2Rhbmdlcm91cy5sYXN0SW5kZXggPSAwO1xuICAgICAgICAgICAgaWYgKHJ4X2Rhbmdlcm91cy50ZXN0KHRleHQpKSB7XG4gICAgICAgICAgICAgICAg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V4cG9ydHMgPSBmdW5jdGlvbih5YXNoZSwgbmFtZSkge1xuICByZXR1cm4ge1xuICAgIGlzVmFsaWRDb21wbGV0aW9uUG9zaXRpb246IGZ1bmN0aW9uKCkge1xuICAgICAgcmV0dXJuIG1vZHVsZS5leHBvcnRzLmlzVmFsaWRDb21wbGV0aW9uUG9zaXRpb24oeWFzaGUpO1xuICAgIH0sXG4gICAgZ2V0OiBmdW5jdGlvbih0b2tlbiwgY2FsbGJhY2spIHtcbiAgICAgXG4gICAgICAgIHZhciBwb3NzaWJsZUVudGl0eSA9IHRva2VuLnN0cmluZy5zcGxpdCgnOicpWzFdXG4gICAgICAgIHZhciBwcmVmaXggPSB0b2tlbi5zdHJpbmcuc3BsaXQoJzonKVswXVxuXG4gICAgICAgIHZhciBxdWVyeSA9IFFVRVJZXG4gICAgICAgIHF1ZXJ5LnNlYXJjaD1wb3NzaWJsZUVudGl0eVxuXG4gICAgICAgIC8vQWRkIGV4dHJhIHBhcmFtIGlmIGl0IGlzIGEgcHJvcGVydHlcbiAgICAgICAgaWYocmRmVXRpbHMuaXNXaWtpZGF0YVByb3BlcnRpZXNQcmVmaXgoeWFzaGUscHJlZml4KSl7XG4gICAgICAgICAgcXVlcnkudHlwZT0ncHJvcGVydHknXG4gICAgICAgIH1lbHNle1xuICAgICAgICAgIGRlbGV0ZSBxdWVyeS50eXBlXG4gICAgICAgIH1cblxuXG4gICAgICAgICQuZ2V0KFxuICAgICAgICAgICAge1xuICAgICAgICAgIFxuICAgICAgICAgICAgICB1cmw6IEFQSV9FTkRQT0lOVCArICc/JyArICQucGFyYW0ocXVlcnkpLFxuICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb25wJyxcbiAgICAgICAgICBcbiAgICAgICAgICAgIH0pLmRvbmUoIGZ1bmN0aW9uKCBkYXRhICkge1xuXG4gICAgICAgICAgICAgIHZhciBsaXN0ID1bXVxuICAgICAgICAgICAgICBcbiAgICAgICAgICAgICAgLy9UaGlzIGNvbmRpdGlvbiBpcyBmb3IgYW4gZW1wdHkgc2VhcmNoXG4gICAgICAgICAgICAgIGlmKGRhdGEuZXJyb3Ipe1xuICAgICAgICAgICAgICAgIGxpc3QgPSBbIHtcbiAgICAgICAgICAgICAgICAgIHRleHQ6ICcnLFxuICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6ICdUeXBlIHRvIHNlYXJjaCBmb3IgYW4gZW50aXR5J1xuICAgICAgICAgICAgICAgIH0gXTtcbiAgICAgICAgICAgICAgICBjYWxsYmFjayhsaXN0KVxuICAgIFxuICAgICAgICAgICAgICB9ZWxzZXtcblxuICAgICAgICAgICAgICAgIHZhciBlbnRpdGllcyA9IFtdXG4gICAgICAgICAgICAgICAgdmFyIGxhYmVsLGlkLGRlc2NyaXB0aW9uLGVudGl0aWVzXG4gICAgICAgICAgICAgICAgZm9yKHZhciBlbnRpdHkgaW4gZGF0YS5zZWFyY2gpe1xuXG4gICAgICAgICAgICAgICAgICAgIGxhYmVsID0gZGF0YS5zZWFyY2hbZW50aXR5XS5sYWJlbFxuICAgICAgICAgICAgICAgICAgICBpZCA9IGRhdGEuc2VhcmNoW2VudGl0eV0uaWRcbiAgICAgICAgICAgICAgICAgICAgZGVzY3JpcHRpb24gPSBkYXRhLnNlYXJjaFtlbnRpdHldLmRlc2NyaXB0aW9uXG5cbiAgICAgICAgICAgICAgICAgICAgbGlzdCA9ICB7XG4gICAgICAgICAgICAgICAgICAgICAgdGV4dDogaWQsXG4gICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVRleHQ6IGxhYmVsICsgXCIgKFwiICsgaWQgKyBcIikgXFxuIFwiICsgZGVzY3JpcHRpb25cbiAgICAgICAgICAgICAgICAgICAgfSA7XG5cbiAgICAgICAgICAgICAgICAgICAgZW50aXRpZXMucHVzaChsaXN0KVxuICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbnRpdGllcy5zb3J0KClcbiAgICAgICAgICAgICAgICBjY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gZmlsZU5hbWVUb1NhdmVBcztcbiAgICAgICAgICAgIGRvd25sb2FkTGluay5pbm5lckhUTUwgPSBcIkRvd25sb2FkIEZpbGVcIjtcbiAgICAgICAgICAgIGlmICh3aW5kb3cuVVJMICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgLy8gQ2hyb21lIGFsbG93cyB0aGUgbGluayB0byBiZSBjbGlja2VkIHdpdGhvdXQgYWN0dWFsbHkgYWRkaW5nIGl0IHRvIHRoZSBET00uXG4gICAgICAgICAgICAgIGRvd25sb2FkTGluay5ocmVmID0gd2luZG93LlVSTC5jcmVhdGVPYmplY3RVUkwodGV4dEZpbGVBc0Jsb2IpO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgLy8gRmlyZWZveCByZXF1aXJlcyB0aGUgbGluayB0byBiZSBhZGRlZCB0byB0aGUgRE9NIGJlZm9yZSBpdCBjYW4gYmUgY2xpY2tlZC5cbiAgICAgICAgICAgICAgZG93bmxvYWRMaW5rLmhyZWYgPSB3aW5kb3cuVVJMLmNyZWF0ZU9iamVjdFVSTCh0ZXh0RmlsZUFzQmxvYik7XG4gICAgICAgICAgICAgIGRvd25sb2FkTGluay5vbmNsaWNrID0gZGVzdHJveUNsaWNrZWRFbGVtZW50O1xuICAgICAgICAgICAgICBkb3dubG9hZExpbmsuc3R5bGUuZGlzcGxheSA9IFwibm9uZVwiO1xuICAgICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGRvd25sb2FkTGluayk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBkb3dubG9hZExpbmsuY2xpY2soKTtcbiAgICAgICAgICAgIENvZGVtaXJyb3Iuc2lnbmFsKHlhc2hlLCdkb3dubG9hZCcpO1xuICAgICAgICAgIH0pXG4gICAgICApO1xuICAgIFxuICAgIC8qKlxuICAgICAqIGNvcHkgYnV0dG9uXG4gICAgICovXG4gIFxuICAgIHZhciBjb3B5QnV0dG9uID0gJChcIjxkaXY+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ic6ICcxcHggc29saWQgIzcwZGJlOScsXG4gICAgJ2JhY2tncm91bmQnOicjMjIyJyxcbiAgICAnY29sb3InOid3aGl0ZScsXG4gICAgJ3otaW5kZXgnOicxMjAwJ1xuICB9XG59XG5cblxuXG5tb2R1bGUuZXhwb3J0cyA9IHtcbiAgZ3JhbW1hclRvb3RsaXA6Z3JhbW1hclRvb3RsaXAsXG4gIHRyaWdnZXJUb29sdGlwOnRyaWdnZXJUb29sdGlwLFxuICByZW1vdmVXaWtpVG9vbFRpcDpyZW1vdmVXaWtpVG9vbFRpcCxcbiAgZGVib3VuY2U6ZGVib3VuY2Vcbn07Il19 diff --git a/index.html b/index.html index a70c532b..8d4841ca 100755 --- a/index.html +++ b/index.html @@ -186,7 +186,7 @@

Thanks!

persistent:null }); - yashe.setSize(1135,400) + yashe.setSize(1135,400); diff --git a/package-lock.json b/package-lock.json index 34bf1c57..bbf850c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yashe", - "version": "1.2.16", + "version": "1.2.19", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2188,7 +2188,8 @@ "codemirror": { "version": "5.17.0", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.17.0.tgz", - "integrity": "sha1-qUMTUzc/FS/ihR8pUCo6oSwdYkc=" + "integrity": "sha1-qUMTUzc/FS/ihR8pUCo6oSwdYkc=", + "dev": true }, "collect-stream": { "version": "1.2.1", diff --git a/package.json b/package.json index 66c7563d..6a275241 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yashe", "description": "Yet Another ShEx Editor", - "version": "1.2.17", + "version": "1.2.22", "main": "src/main.js", "license": "MIT", "author": "Pablo Menéndez", @@ -75,7 +75,6 @@ "axios": "^0.19.2", "bloodhound-js": "^1.2.3", "bootstrap": "^4.4.1", - "codemirror": "5.17.0", "file-reader": "^1.1.1", "gulp-uglify": "^3.0.2", "gulp-uglify-es": "^2.0.0", diff --git a/src/main.js b/src/main.js index 7f086e00..7f88dc73 100755 --- a/src/main.js +++ b/src/main.js @@ -447,9 +447,9 @@ root.version = { }; -/* -var settings = { + +/* var settings = { "async": true, "crossDomain": true, "url": "https://www.mediawiki.org/w/api.php?action=query&meta=tokens&format=json", @@ -462,9 +462,6 @@ $.ajax(settings).done(function (response) { }); - - - var Bloodhound = require('bloodhound-js'); // Defining the local dataset @@ -499,5 +496,5 @@ typeahead.addEventListener("keyup",function(e){ }) -*/ + */ diff --git a/src/utils/prefixFold.js b/src/utils/prefixFold.js index 2b01dc20..38e813b2 100755 --- a/src/utils/prefixFold.js +++ b/src/utils/prefixFold.js @@ -37,8 +37,10 @@ function findFirstPrefix(cm, line, ch, lineText) { } CodeMirror.registerHelper("fold", "prefix", function(cm, start) { - var line = start.line, lineText = cm.getLine(line); - + if(!start){ + start = {line: 0, ch: 0} + } + var line = start.line,lineText = cm.getLine(line); var startCh, tokenType; function hasPreviousPrefix() {