diff --git a/dist/yashe.bundled.min.js b/dist/yashe.bundled.min.js index 4b8d7d71..a76b19ec 100755 --- a/dist/yashe.bundled.min.js +++ b/dist/yashe.bundled.min.js @@ -1902,6 +1902,7 @@ CodeMirror.defineMode("shex", function(config, parserConfig) { state.defShapes[tokenOb.text] = tokenOb tokenOb.style='shape'; } + // console.log({topSymbol:topSymbol,tokenOb:tokenOb.text}) if(topSymbol == 'valueSetValue')tokenOb.style='valueSet'; //if(tokenOb.cat == 'ATPNAME_LN')tokenOb.style='shapeRef'; if(topSymbol=='cardinality')tokenOb.style='cardinality'; @@ -1910,15 +1911,14 @@ CodeMirror.defineMode("shex", function(config, parserConfig) { if(topSymbol=='nodeConstraint'){ if(token!='['){ - if(!token.match(grammar.keywords)){ - tokenOb.style='constraint'; + if(!token.match(grammar.keywords) || token == 'IRI_REF'){ // IRI_REF MATCHES WITH IRI + tokenOb.style='constraint'; }else{ tokenOb.style='constraintKeyword'; } } } - if (!ll1_table[topSymbol]) { // Top symbol is a terminal if (topSymbol == token) { @@ -25342,7 +25342,7 @@ function createStore(storages, plugins, namespace) { } },{"./util":21}],21:[function(require,module,exports){ -(function (global){ +(function (global){(function (){ var assign = make_assign() var create = make_create() var trim = make_trim() @@ -25462,7 +25462,7 @@ function isObject(val) { return val && {}.toString.call(val) === '[object Object]' } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],22:[function(require,module,exports){ module.exports = [ @@ -25837,7 +25837,7 @@ module.exports={ "_args": [ [ "yasgui-utils@1.6.7", - "/home/mistermboy/Downloads/YASHE-d2ff371b7a852195619fcadd5ec0b115437e7a86" + "D:\\Repositories\\YASHE" ] ], "_from": "yasgui-utils@1.6.7", @@ -25861,7 +25861,7 @@ module.exports={ ], "_resolved": "https://registry.npmjs.org/yasgui-utils/-/yasgui-utils-1.6.7.tgz", "_spec": "1.6.7", - "_where": "/home/mistermboy/Downloads/YASHE-d2ff371b7a852195619fcadd5ec0b115437e7a86", + "_where": "D:\\Repositories\\YASHE", "author": { "name": "Laurens Rietveld" }, @@ -26061,7 +26061,7 @@ module.exports={ "browserify-shim": "^3.8.12", "browserify-transform-tools": "^1.6.0", "clipboard": "^2.0.4", - "cypress": "^4.3.0", + "cypress": "^4.10.0", "eslint": "^6.4.0", "eslint-config-google": "^0.14.0", "exorcist": "^0.4.0", @@ -26331,7 +26331,7 @@ module.exports = function(YASHE, yashe) { var startChar; //For the wikidata completer we recive the {text, displayText} object if(completer.name == 'wikibase' || completer.name == 'definedShapes' - || completer.name == 'prefixesAndKeywords'){ + || completer.name == 'prefixes' || completer.name == 'keywords'){ for (var i = 0; i < suggestions.length; i++) { hintList.push({ @@ -26405,7 +26405,7 @@ module.exports = function(YASHE, yashe) { //only draw when the user needs to use a keypress to summon autocompletions if (!completer.autoshow) { if (!completionNotifications[completer.name]) - completionNotifications[completer.name] = $("
"); + completionNotifications[completer.name] = $("
"); completionNotifications[completer.name] .show() .text("Press CTRL - to autocomplete") @@ -26449,7 +26449,7 @@ var selectHint = function(yashe, data, completion) { // loadBulkCompletions: loadBulkCompletions, //}; -},{"../../lib/trie.js":4,"../main.js":41,"../utils/baseUtils.js":42,"jquery":16,"yasgui-utils":30}],35:[function(require,module,exports){ +},{"../../lib/trie.js":4,"../main.js":42,"../utils/baseUtils.js":43,"jquery":16,"yasgui-utils":30}],35:[function(require,module,exports){ "use strict"; var $ = require("jquery") var yashe = require('../main.js') @@ -26476,7 +26476,11 @@ module.exports = function(yashe, name) { }, async: false, bulk: false, - autoShow: false + autoShow: false/* , + callbacks: { + validPosition: yashe.autocompleters.notifications.show, + invalidPosition: yashe.autocompleters.notifications.hide + } */ }; }; @@ -26493,7 +26497,85 @@ module.exports.isValidCompletionPosition = function(yashe) { -},{"../../lib/trie.js":4,"../main.js":41,"../utils/syntaxUtils.js":54,"jquery":16}],36:[function(require,module,exports){ +},{"../../lib/trie.js":4,"../main.js":42,"../utils/syntaxUtils.js":55,"jquery":16}],36:[function(require,module,exports){ +"use strict"; +var $ = require("jquery") +var yashe = require('../main.js') +var Trie = require('../../lib/trie.js') + +module.exports = function(yashe, name) { + + + return { + isValidCompletionPosition: function() { + return module.exports.isValidCompletionPosition(yashe); + }, + get: function(token) { + + var trie = new Trie() + for(var key in KEYWORDS){ + trie.insert(KEYWORDS[key]); + } + + var completions = trie.autoComplete(token.toLowerCase()) + var final = [] + var list={} + for(var c in completions){ + + var text = completions[c] + var displayText = completions[c]; + + list = { + text: text, + displayText: displayText + } + + final.push(list) + } + + + return final + + }, + async: false, + bulk: false, + autoShow: true + }; +}; + +module.exports.isValidCompletionPosition = function(yashe) { + let token = yashe.getCompleteToken(); + for(let k in KEYWORDS){ + if(token.string==KEYWORDS[k])return false; + } + if(token.string.length>1 + && !token.string.includes(':'))return true; + return false; +}; + + +var KEYWORDS = [ + 'base', + 'prefix', + 'import', + 'external', + 'iri', + 'bnode', + 'literal', + 'nonliteral', + 'length', + 'minlength', + 'maxlength', + 'mininclusive', + 'minexclusive', + 'maxinclusive', + 'maxexclusive', + 'totaldigits', + 'fractiondigits', + 'closed', + 'extra' + ] +},{"../../lib/trie.js":4,"../main.js":42,"jquery":16}],37:[function(require,module,exports){ "use strict"; var $ = require("jquery"); //this is a mapping from the class names (generic ones, for compatability with codemirror themes), to what they -actually- represent @@ -26621,7 +26703,7 @@ module.exports.appendPrefixIfNeeded = function(yashe, completerName) { module.exports.fetchFrom = (window.location.protocol.indexOf("http") === 0 ? "//" : "http://") + "prefix.cc/popular/all.file.json"; -},{"jquery":16}],37:[function(require,module,exports){ +},{"jquery":16}],38:[function(require,module,exports){ "use strict"; var $ = require("jquery") var yashe = require('../main.js') @@ -26641,10 +26723,6 @@ module.exports = function(yashe, name) { for(var prefix in prefixes){ trie.insert(prefix+":"); } - for(var key in KEYWORDS){ - trie.insert(KEYWORDS[key]); - } - var completions = trie.autoComplete(token.toLowerCase()) var final = [] @@ -26672,14 +26750,18 @@ module.exports = function(yashe, name) { }, async: false, bulk: false, - autoShow: false + autoShow: true }; }; module.exports.isValidCompletionPosition = function(yashe) { module.exports.PREFIXES = yashe.getDefinedPrefixes(); - - return true + let token = yashe.getCompleteToken(); + if(token.string.length>0 + && token.type != 'ws' + && token.type != 'punc' + && !token.string.includes(':'))return true; + return false }; @@ -26695,34 +26777,12 @@ module.exports.isInPrefixList = function(completion){ module.exports.PREFIXES = [] -var KEYWORDS = [ - 'base', - 'prefix', - 'import', - 'external', - 'or', - 'and', - 'not"', - 'iri', - 'bnode', - 'literal', - 'nonliteral', - 'length', - 'minlength', - 'maxlength', - 'mininclusive', - 'minexclusive', - 'maxinclusive', - 'maxexclusive', - 'totaldigits', - 'fractiondigits', - 'closed', - 'extra' - ] -},{"../../lib/trie.js":4,"../main.js":41,"jquery":16}],38:[function(require,module,exports){ + +},{"../../lib/trie.js":4,"../main.js":42,"jquery":16}],39:[function(require,module,exports){ "use strict"; var $ = require("jquery"), -rdfUtils = require('../utils/rdfUtils.js') +wikiUtils = require('../utils/wikiUtils.js'); +const { isWikidataPrefix } = require("../utils/wikiUtils.js"); var API_ENDPOINT = 'https://www.wikidata.org/w/'; var QUERY = { @@ -26748,20 +26808,20 @@ module.exports = function(yashe, name) { query.search=possibleEntity //Add extra param if it is a property - if(rdfUtils.isWikidataPropertiesPrefix(yashe,prefix)){ + if(wikiUtils.isWikidataPropertiesPrefix(yashe,prefix)){ query.type='property'; }else{ delete query.type; } - let endpoint = rdfUtils.getEndPoint(yashe,prefix); + let endpoint = wikiUtils.getEndPoint(yashe,prefix); if(endpoint!=null){ API_ENDPOINT = endpoint; } getEntities(API_ENDPOINT,query) .done((data)=>setHints(data,callback)) - .fail( + .fail( //I had to do this for one wikibase instance I don't know why... ()=>getEntities(API_ENDPOINT.replace('/w/','/wiki/'),query) .done((data)=>setHints(data,callback)) ) @@ -26770,7 +26830,11 @@ module.exports = function(yashe, name) { }, async: true, bulk: false, - autoShow: false + autoShow: false, + callbacks: { + validPosition: yashe.autocompleters.notifications.show, + invalidPosition: yashe.autocompleters.notifications.hide + } }; }; @@ -26830,32 +26894,23 @@ module.exports.isValidCompletionPosition = function(yashe) { //The cursor should stay at the end of the token if(token.end!=cur.ch)return false - var prefixName = token.string.split(':')[0] + var previousToken = yashe.getPreviousNonWsToken(cur.line, token); //This line avoid the autocomplete in the prefix definition if(previousToken.string.toUpperCase() == 'PREFIX')return false - if(token.type == 'shape' || token.type=='string-2' || token.type=='constraint'){ - if(rdfUtils.isWikidataEntitiesPrefix(yashe,prefixName) - || rdfUtils.isWikidataPropertiesPrefix(yashe,prefixName) - || rdfUtils.getEndPoint(yashe,prefixName)!=null){ - return true - } - } + return wikiUtils.isWikidataPrefix(yashe,token); - - return false; - }; -},{"../utils/rdfUtils.js":53,"jquery":16}],39:[function(require,module,exports){ +},{"../utils/wikiUtils.js":58,"jquery":16}],40:[function(require,module,exports){ //this is the entry-point for browserify. //the current browserify version does not support require-ing js files which are used as entry-point //this way, we can still require our main.js file module.exports = require("../main.js"); -},{"../main.js":41}],40:[function(require,module,exports){ +},{"../main.js":42}],41:[function(require,module,exports){ /** * The default options of YASHE (check the CodeMirror documentation for even * more options, such as disabling line numbers, or changing keyboard shortcut @@ -26870,19 +26925,17 @@ YASHE.defaults = $.extend(true, {}, YASHE.defaults, { /** * Default shape */ - value: `PREFIX rdf: -PREFIX rdfs: -PREFIX wd: -PREFIX wdt: - -start = @ - - EXTRA wdt:P31 { - wdt:P31 [ - wd:Q5 #1 - wd:Q11574 #2 - ]; -} + value: ` + + prefix schema: + prefix : + + :Person { + schema:asd { + schema:asd . + } or{ schema:sdaf .} + } + `, highlightSelectionMatches: { @@ -26903,12 +26956,14 @@ start = @ syntaxErrorCheck: true, showTooltip: true, showShareButton: true, + showWikiBtn:true, showUploadButton: true, showDownloadButton: true, showCopyButton: true, showDeleteButton: true, showThemeButton: true, showFullScreenButton: true, + wikiFormatInProgress:false, onQuotaExceeded: function(e) { //fail silently console.warn("Could not store in localstorage. Skipping..", e); @@ -26930,14 +26985,12 @@ start = @ "Ctrl-Up": YASHE.copyLineUp, "Cmd-Down": YASHE.copyLineDown, "Cmd-Up": YASHE.copyLineUp, - "Shift-Ctrl-F": YASHE.doAutoFormat, - "Shift-Cmd-F": YASHE.doAutoFormat, + "Shift-Ctrl-F": YASHE.prettify, + "Shift-Cmd-F": YASHE.prettify, "Ctrl-S": YASHE.storeContent, "Cmd-S": YASHE.storeConten, "Ctrl-Enter": YASHE.executeQuery, "Cmd-Enter": YASHE.executeQuery, - "Ctrl-F": YASHE.prettify, - "Cmd-F": YASHE.prettify, F11: function(yashe) { yashe.setOption("fullScreen", !yashe.getOption("fullScreen")); if(yashe.getOption("fullScreen")){ @@ -26974,7 +27027,7 @@ start = @ }); -},{"../main.js":41,"codemirror":15,"jquery":16}],41:[function(require,module,exports){ +},{"../main.js":42,"codemirror":15,"jquery":16}],42:[function(require,module,exports){ 'use strict'; // make sure any console statements window.console = window.console || { @@ -26996,6 +27049,7 @@ const tooltipUtils = require('./utils/tooltipUtils.js'); const formatUtils = require('./utils/formatUtils.js'); const buttonsUtils = require('./utils/buttonsUtils.js'); const prettyUtils = require('./utils/pretty/prettyUtils.js'); +const interact = require('./utils/interactUtils.js'); const prefixFold = require('./utils/prefixFold.js'); const autocompletersBase = require('./autocompleters/autocompleterBase.js'); const Clipboard = require('clipboard'); @@ -27187,10 +27241,16 @@ const extendCmInstance = function(yashe) { formatUtils.wikiFormat(yashe); } + yashe.stopWikiFormat = function(){ + yashe.wikiFormatInProgress = false; + } + yashe.prettify = function(){ if(!yashe.hasErrors()){ prettyUtils.prettify(yashe); - if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + //if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + }else{ + interact.showErrAlertMsg(yashe); } } @@ -27365,8 +27425,10 @@ root.storeContent = function(yashe) { root.prettify = function(yashe){ if(!yashe.hasErrors()){ - prettyUtils.prettify(yashe); - // if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + prettyUtils.prettify(yashe); + //if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + }else{ + interact.showErrAlertMsg(yashe); } } @@ -27376,10 +27438,12 @@ root.prettify = function(yashe){ * @return {string} Check result */ const checkSyntax = function(yashe) { - return syntaxUtils.checkSyntax(yashe); + syntaxUtils.checkSyntax(yashe); + return syntaxUtils.reCheckSyntax(yashe); }; + // ---- Static Utils ----- // first take all codeMirror references and store them in the YASHE object @@ -27408,8 +27472,17 @@ root.registerAutocompleter('wikibase', root.registerAutocompleter('prefixDefinition', require('./autocompleters/prefixDefinition.js')); -root.registerAutocompleter('prefixesAndKeywords', - require('./autocompleters/prefixesAndKeywords.js')); +root.registerAutocompleter('keywords', + require('./autocompleters/keywords.js')); + +root.registerAutocompleter('prefixes', + require('./autocompleters/prefixes.js')); + + + + +/* root.registerAutocompleter('prefixesAndKeywords', + require('./autocompleters/prefixesAndKeywords.js')); */ /** @@ -27524,7 +27597,7 @@ root.version = { -},{"../lib/deparam.js":1,"../lib/grammar/tokenizer.js":3,"../package.json":33,"./autocompleters/autocompleterBase.js":34,"./autocompleters/definedShapes.js":35,"./autocompleters/prefixDefinition.js":36,"./autocompleters/prefixesAndKeywords.js":37,"./autocompleters/wikibase.js":38,"./config/defaults.js":40,"./utils/baseUtils.js":42,"./utils/buttonsUtils.js":43,"./utils/formatUtils.js":45,"./utils/prefixFold.js":47,"./utils/prefixUtils.js":48,"./utils/pretty/prettyUtils.js":50,"./utils/syntaxUtils.js":54,"./utils/tokenUtils.js":55,"./utils/tooltipUtils.js":56,"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}],42:[function(require,module,exports){ +},{"../lib/deparam.js":1,"../lib/grammar/tokenizer.js":3,"../package.json":33,"./autocompleters/autocompleterBase.js":34,"./autocompleters/definedShapes.js":35,"./autocompleters/keywords.js":36,"./autocompleters/prefixDefinition.js":37,"./autocompleters/prefixes.js":38,"./autocompleters/wikibase.js":39,"./config/defaults.js":41,"./utils/baseUtils.js":43,"./utils/buttonsUtils.js":44,"./utils/formatUtils.js":46,"./utils/interactUtils.js":48,"./utils/prefixFold.js":49,"./utils/prefixUtils.js":50,"./utils/pretty/prettyUtils.js":52,"./utils/syntaxUtils.js":55,"./utils/tokenUtils.js":56,"./utils/tooltipUtils.js":57,"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}],43:[function(require,module,exports){ "use strict"; var $ = require("jquery"); var Codemirror = require('codemirror'); @@ -27611,7 +27684,7 @@ module.exports = { readFile: readFile }; -},{"codemirror":15,"jquery":16}],43:[function(require,module,exports){ +},{"codemirror":15,"jquery":16}],44:[function(require,module,exports){ var imgs = require("./imgs.js"), yutils = require("yasgui-utils"), utils = require("./baseUtils.js"), @@ -27623,9 +27696,6 @@ var drawButtons = function(yashe){ yashe.buttons = $("
").appendTo($(yashe.getWrapperElement())); - /** - * upload button - */ var uploadButton = $("
", { class: "downloadBtns" }).append($('{utils.readFile(yashe)})); - /** - * download button - */ - + var downloadButton = $("
", { class: "downloadBtns" }) @@ -27668,10 +27735,7 @@ var drawButtons = function(yashe){ }) ); - /** - * copy button - */ - + var copyButton = $("
", { class: "downloadBtns" }) @@ -27684,10 +27748,7 @@ var drawButtons = function(yashe){ Codemirror.signal(yashe,'copy'); })) - - /** - * delete button - */ + var deleteButton = $("
", { class: "downloadBtns" }).append($(yutils.svg.getElement(imgs.delete)) @@ -27700,9 +27761,6 @@ var drawButtons = function(yashe){ })); - /** - * theme button - */ var themeButton = $("
", { class: "downloadBtns" }).append($(yutils.svg.getElement(imgs.theme)) @@ -27722,24 +27780,21 @@ var drawButtons = function(yashe){ yashe.setOption("theme",themeValue) //Change fill of buttons - $('#shareBtn').css('fill', color) - $('#uploadBntLabel').css('fill', color) - $('#downloadBtn').css('fill', color) - $('#copyBtn').css('fill', color) - $('#deleteBtn').css('fill', color) - $('#themeBtn').css('fill', color) - $('#fullBtn').css('fill', color) - $('#smallBtn').css('fill', color) + $('#shareBtn').css('fill', color); + $('#wikiBtn').css('fill', color); + $('#wikiBtn').css('fill', color); + $('#uploadBntLabel').css('fill', color); + $('#downloadBtn').css('fill', color); + $('#copyBtn').css('fill', color); + $('#deleteBtn').css('fill', color); + $('#themeBtn').css('fill', color); + $('#fullBtn').css('fill', color); + $('#smallBtn').css('fill', color); Codemirror.signal(yashe,'themeChange'); })) - - - /** - * fullscreen button - */ var toggleFullscreen = $("
", { class: "fullscreenToggleBtns" }) @@ -27766,7 +27821,7 @@ var drawButtons = function(yashe){ - var shareLinkBtn = $("
", { + var shareLinkBtn = $("
", { class: "downloadBtns" }).append($(yutils.svg.getElement(imgs.share)) .addClass("yashe_shareBtn") @@ -27781,13 +27836,32 @@ var drawButtons = function(yashe){ })); + var wikiBtn = $("
", { + class: "downloadBtns" + }).append($(yutils.svg.getElement(imgs.tag)) + .addClass("yashe_wikiBtn") + .attr('id','wikiBtn') + .attr("title", "Generate Wikidata Comments") + .click(function() { + !yashe.wikiFormatInProgress ? + yashe.wikiformat() : + yashe.stopWikiFormat(); + })); + + + + //Draw buttons if(yashe.options.showShareButton){ - yashe.buttons.append(shareLinkBtn); + yashe.buttons.append(shareLinkBtn); } + if(yashe.options.showWikiBtn){ + yashe.buttons.append(wikiBtn); + } + if(yashe.options.showUploadButton){ yashe.buttons.append(uploadButton); } @@ -27820,14 +27894,15 @@ var drawButtons = function(yashe){ module.exports = { drawButtons:drawButtons } -},{"./baseUtils.js":42,"./imgs.js":46,"codemirror":15,"jquery":16,"yasgui-utils":30}],44:[function(require,module,exports){ +},{"./baseUtils.js":43,"./imgs.js":47,"codemirror":15,"jquery":16,"yasgui-utils":30}],45:[function(require,module,exports){ // Symbols const OPENING_PARENTHESIS = '('; const CLOSING_PARENTHESIS = ')'; -const OPENING_CURLY_BRACKET= '{'; -const CLOSING_CURLY_BRACKET= '}'; -const OPENING_SQUARE_BRACKET= '['; -const CLOSING_SQUARE_BRACKET= ']'; +const OPENING_CURLY_BRACKET = '{'; +const CLOSING_CURLY_BRACKET = '}'; +const OPENING_SQUARE_BRACKET = '['; +const CLOSING_SQUARE_BRACKET = ']'; +const LOGICAL_OR = '|'; const SEMICOLON=';'; const DOLLAR = '$'; const AMPERSAND = '&'; @@ -27864,7 +27939,10 @@ module.exports ={ CLOSING_CURLY_BRACKET:CLOSING_CURLY_BRACKET, OPENING_SQUARE_BRACKET:OPENING_SQUARE_BRACKET, CLOSING_SQUARE_BRACKET:CLOSING_SQUARE_BRACKET, + LOGICAL_OR:LOGICAL_OR, + DOLLAR:DOLLAR, SEMICOLON:SEMICOLON, + AMPERSAND:AMPERSAND, EQUALS:EQUALS, SHAPE_TYPE:SHAPE_TYPE, @@ -27888,9 +27966,12 @@ module.exports ={ IMPORT_KEYWORD:IMPORT_KEYWORD, START_KEYWORD:START_KEYWORD } -},{}],45:[function(require,module,exports){ -var CodeMirror = require("codemirror") -const $ = require('jquery') +},{}],46:[function(require,module,exports){ +const CodeMirror = require("codemirror"); +const $ = require('jquery'); +const wikiUtils = require('../utils/wikiUtils.js'); +let interact = require("./interactUtils.js"); + "use strict"; var commentLines = function(yashe) { @@ -28046,32 +28127,80 @@ var copyLineDown = function(yashe) { }; - var wikiFormat = function(yashe){ + var wikiFormat = async function(yashe){ + if(yashe.hasErrors()){ + interact.showErrAlertMsg(yashe); + return; + } - - for (var l = 7; l < yashe.lineCount(); ++l) { - let lineTokens = yashe.getLineTokens(l); - let nonWs = getNonWsLineTokens(lineTokens) + interact.startWikiFormat(yashe); + yashe.prettify(); + let history = interact.disableEditor(yashe); + for (var l = 0; l < yashe.lineCount(); ++l) { + let lineTokens = getNonWsLineTokens(yashe.getLineTokens(l)); + let valueSetSize = getValueSetSizeIfClosed(lineTokens); + let comments = ' # '; for(let t in lineTokens){ + if(!yashe.wikiFormatInProgress){ + interact.stopWikiFormat(yashe,history); + return; + } let token = lineTokens[t]; - //console.log(next) - if(token.string.split(':')[0]=='wd' && !token.skip){ - console.log(token) - - //console.log({token:token,t:t,length:lineTokens.length,next:next}) - //console.log({line:l,col:{start:token.start,end:token.end},string:token.string}) - - yashe.replaceRange(token.string+" #human \n",{line:l,ch:token.start},{line:l,ch:token.end}) - - - - + if(wikiUtils.isWikidataPrefix(yashe,token)){ + let entity = token.string.split(':')[1].toUpperCase(); + let result = await wikiUtils.getEntity(entity,wikiUtils.wikidataEndpoint); + if(result.entities){ + let entityData = wikiUtils.getEntityData(entity,result); + if(entityData){ + comments += ' '+entityData.title; + valueSetSize--; + } + } + } + + if(isLastToken(t,lineTokens) && comments!=' # '){ + let endOfLine = lineTokens[lineTokens.length-1].end + yashe.replaceRange(comments,{line:l,ch:endOfLine},{line:l,ch:endOfLine}) + if(yashe.hasErrors(yashe))yashe.undo(); + //For some reason I'm not able to make codemirror scroll methods work, so I'm forcing the scroll with the cursor + yashe.setCursor({line:l+10,ch:token.start}); + valueSetSize = 0; + comments = ''; } } + } + interact.stopWikiFormat(yashe,history); + } + + var isLastToken = function(token,tokens){ + return token == tokens.length-1; } + /** + * Gets an array of linetokens. If the line closes the valueSet ']' return its size, otherwise 0 + * @param {Array} lineTokens + */ + var getValueSetSizeIfClosed = function(lineTokens){ + let open = false; + let close = false; + let decrement = true; + let size = lineTokens.reduce((acc,t)=>{ + if(t.string=='[')open=true; + if(t.string==']')close=true; + if(t.type=='valueSet')acc++; + if(t.type=='variable-3')decrement=false; + if(t.type=='string-2')decrement=false; + return acc; + },1) + + if(decrement)size--; + if(open && close)return size; + return 1; + } + + var getNonWsLineTokens = function(lineTokens){ return lineTokens.reduce((acc,t)=>{ if(t.type!='ws')acc.push(t); @@ -28079,27 +28208,17 @@ var copyLineDown = function(yashe) { },[]); } - var getNextNonWSLineToken = function(yashe,lineTokens,lineIndex){ - let i = 1; - let token = lineTokens[lineIndex+i]; - //console.log(token) - while(token && token.type=='ws'){ - i++; - token = lineTokens[lineIndex+i]; - } - return token; - } - module.exports = { commentLines:commentLines, copyLineUp: copyLineUp, copyLineDown: copyLineDown, doAutoFormat:doAutoFormat, + getNonWsLineTokens:getNonWsLineTokens, wikiFormat:wikiFormat }; -},{"codemirror":15,"jquery":16}],46:[function(require,module,exports){ +},{"../utils/wikiUtils.js":58,"./interactUtils.js":48,"codemirror":15,"jquery":16}],47:[function(require,module,exports){ "use strict"; module.exports = { copy: '', @@ -28112,11 +28231,73 @@ module.exports = { delete:'', theme:'', endpoint:'', + tag:'', + stop:'' }; -},{}],47:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ +let yutils = require("yasgui-utils"); +let imgs = require("./imgs.js"); +let wikiNotification = $("
"); + +var showErrAlertMsg = function(yashe){ + wikiNotification + .show() + .text("I can't do that...Fix the errors before") + .appendTo($(yashe.getWrapperElement())); + + setTimeout(() => { + wikiNotification.hide() + }, 3000); +} + +var startWikiFormat = function(yashe){ + yashe.wikiFormatInProgress = true; + $('#wikiBtn').attr("title", "STOP"); + $('#wikiBtn').empty(); + $('#wikiBtn').append($(yutils.svg.getElement(imgs.stop))); + $('#wikiBtn').removeClass("yashe_wikiBtn"); + $('#wikiBtn').removeClass("yashe_wikiBtnAfter"); + $('#wikiBtn').addClass("yashe_stopBtn"); + wikiNotification.show().text("Adding Wikidata Comments").appendTo($(yashe.getWrapperElement())); +} + +var stopWikiFormat = function(yashe,history){ + yashe.wikiFormatInProgress = false; + setTimeout(() => { //Just to wait until the last comment is setted + $('#wikiBtn').attr("title", "Generate Wikidata Comments"); + $('#wikiBtn').empty(); + $('#wikiBtn').removeClass("yashe_stopBtn"); + $('#wikiBtn').addClass("yashe_wikiBtnAfter"); + $('#wikiBtn').append($(yutils.svg.getElement(imgs.tag))); + wikiNotification.hide(); + yashe.prettify(); + enableEditor(yashe,history); + }, 400); +} + +var disableEditor = function(yashe){ + yashe.setOption('readOnly',true); + return yashe.getHistory(); +} +var enableEditor = function(yashe,history){ + yashe.setHistory(history); + yashe.setOption('readOnly',false); +} + + + +module.exports ={ + startWikiFormat:startWikiFormat, + stopWikiFormat:stopWikiFormat, + enableEditor:enableEditor, + disableEditor:disableEditor, + showErrAlertMsg:showErrAlertMsg + +} +},{"./imgs.js":47,"yasgui-utils":30}],49:[function(require,module,exports){ var CodeMirror = require("codemirror"), tokenUtils = require("./tokenUtils.js"); ("use strict"); @@ -28236,7 +28417,7 @@ CodeMirror.registerHelper("fold", "prefix", function(cm, start) { to: CodeMirror.Pos(prefixEndLine, prefixEndChar) }; }); -},{"./tokenUtils.js":55,"codemirror":15}],48:[function(require,module,exports){ +},{"./tokenUtils.js":56,"codemirror":15}],50:[function(require,module,exports){ "use strict"; /** * Append prefix declaration to list of prefixes in query window. @@ -28346,21 +28527,23 @@ module.exports = { removePrefixes: removePrefixes }; -},{}],49:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ class Node{ - constructor(constraints,triples,comment='',emptyBrackets,afterTriples=[],finalParenthesis=''){ + constructor(constraints,triples,comment='',emptyBrackets,afterTriples=[],finalParenthesis='',multiElementOneOf=false){ this.constraints = constraints; this.triples = triples; - this.comment = comment; //Comment at the end - this.emptyBrackets = emptyBrackets; //ej: schema:name {}; - this.afterTriples= afterTriples; // Whatever after {} - this.finalParenthesis = finalParenthesis; //Is an + this.comment = comment; //Comment at the end + this.emptyBrackets = emptyBrackets; //ej: schema:name {}; + this.afterTriples= afterTriples; // Whatever after {} + this.finalParenthesis = finalParenthesis; + this.hasAleardyAComment = false; //This is used in the methor getSemicolonIfNeeded due not to set the comment again if it has been already seted + this.multiElementOneOf = multiElementOneOf; } - toString(longest,isTriple,indent=1,isLastTriple=false){ + toString(longest=0,isTriple,indent=1,isLastTriple=false){ let str = EMPTY_STRING; - let constraints=this.getConstraints(longest,indent); + let constraints=this.getConstraints(this.constraints,longest,indent); str+=constraints.str; str+=this.getTriplesString(indent,constraints.tripleComment,isTriple,isLastTriple); @@ -28368,22 +28551,32 @@ class Node{ } //This method could be prettier - getConstraints(longest,indent){ - let valueSetSize = getValueSetSize(this.constraints); + getConstraints(constraints,longest,indent){ + let valueSetSize = getValueSetSize(constraints); let forceSeparator = false; let valueSet = false; - return this.constraints.reduce((acc,token,index)=>{ - let nexToken = this.constraints[index+1]; - let separator = getSeparatorIfNeeded(index,token,nexToken,this.triples.length,longest,this.constraints,this.emptyBrackets); + let previousToken; + return constraints.reduce((acc,token,index)=>{ + + if(token.skip)return acc; + + let nexToken = constraints[index+1]; + let separator = getSeparatorIfNeeded(index,token,nexToken,this.triples.length,longest,constraints,this.emptyBrackets); if(token.type==COMMENT_TYPE){ - - if(valueSet){ + //console.log({previousToken:previousToken.string,token:token.string,nexToken:nexToken}) + if(previousToken && previousToken.string=='[' && valueSetSize>2){ + acc.str+= token.string; + }else if(nexToken && nexToken.string=='[' && valueSetSize>2){ + acc.str+= '[ '+token.string; + nexToken.skip = true; + }else if(valueSet){ + acc.str+= token.string; - acc.str += this.getClosingValueSetIfNeeded(nexToken,valueSet,indent); + acc.str+= this.getClosingValueSetIfNeeded(nexToken,valueSet,indent); }else{ forceSeparator = this.startsWithComment(index);//If it's a comment before the constraints skip it - acc.tripleComment+= this.getTripleComment(forceSeparator,token); //If not, add it to the finish of the line + acc.tripleComment = this.getTripleComment(forceSeparator,token) + acc.tripleComment ; //If not, add it to the finish of the line } @@ -28392,13 +28585,15 @@ class Node{ index = this.decrementIndexIfNeeded(forceSeparator); separator = this.modifySeparatorIfNeeded(separator,nexToken,valueSetSize); - valueSet = this.isLongValueSet(token,valueSetSize); - acc.str += this.getOpeningValueSetIfNeeded(valueSet,indent); + valueSet = this.isValueSet(token,valueSetSize); + acc.str += this.getOpeningValueSetIfNeeded(valueSet,indent,nexToken); acc.str += this.getWhiteSpaceIfNeeded(token); acc.str += this.getTokenString(token,separator); acc.str += this.getClosingValueSetIfNeeded(nexToken,valueSet,indent); } + + previousToken = token; return acc; },{ str:EMPTY_STRING, @@ -28410,10 +28605,9 @@ class Node{ getTriplesString(indent,tripleComment,isTriple,isLastTriple){ let str = EMPTY_STRING; - str += this.getSubTriplesStrIfNeeded(indent,tripleComment,isTriple); str += this.getEmptyBracketsIfNeeded(); - str += this.getAfterTriplesStr(); + str += this.getAfterTriplesStr(indent); str += this.getSemicolonIfNeeded(isTriple,isLastTriple,tripleComment); str += this.getFinalParenthesisIfNeeded(); @@ -28425,12 +28619,18 @@ class Node{ let str = EMPTY_STRING; if(this.triples.length>0){ let linebreak = LINE_BREAK; - if(isTriple && this.triples.length==1){ - if(tripleComment==EMPTY_STRING){// If there is any comment after '{' we need to force the breakline - linebreak = EMPTY_STRING; - indent--; + // This is off at this moment + /* if(isTriple){ + if(this.triples.length==1) { + console.log('p') + // If there isn't any comment after '{' don't force the breakline + if(tripleComment==EMPTY_STRING && !this.hasComments(this.triples[0])){ + linebreak = EMPTY_STRING; + indent--; + } } - } + } */ + str+=this.getSubTriplesStr(indent,tripleComment,linebreak); } return str; @@ -28438,30 +28638,39 @@ class Node{ getSubTriplesStr(indent,tripleComment,linebreak){ + this.hasAleardyAComment=true; let str=OPENING_CURLY_BRACKET+tripleComment+linebreak; + if(tripleComment!='')tripleComment=''; this.triples.map((t,index)=>{ let currentLongest = getLongestTConstraint(this.triples); str+= getIndent(indent); str+= t.toString(currentLongest,true,indent+1,this.isLastTriple(index)); - str+= WHITE_SPACE+t.comment +linebreak; + str+= WHITE_SPACE + t.comment +linebreak; }) return str + getIndent(indent-1)+CLOSING_CURLY_BRACKET; } - getAfterTriplesStr(){ + getAfterTriplesStr(indent){ let str = EMPTY_STRING; - if(this.afterTriples.length>0)str+=WHITE_SPACE; - return this.afterTriples.reduce((acc,a)=>{ - return acc+=a.string+WHITE_SPACE; - },str); + if(this.afterTriples.length>0){ + str+=WHITE_SPACE; + }else{ + return ''; + } + let constraints = this.getConstraints(this.afterTriples,0,indent); + return constraints.str+constraints.tripleComment; } + + getSemicolonIfNeeded(isTriple,isLastTriple,tripleComment){ let str = EMPTY_STRING; if(isTriple){ - if(!isLastTriple)str+=SEMICOLON; - str+=tripleComment; + if(!isLastTriple){ + if(!this.multiElementOneOf)str+=SEMICOLON; + } + if(!this.hasAleardyAComment)str+=tripleComment; } return str; } @@ -28497,7 +28706,7 @@ class Node{ return token.string+separator; } - isLongValueSet(token,valueSetSize){ + isValueSet(token,valueSetSize){ return token.type==VALUESET_TYPE && valueSetSize>VALUESET_LINE_LIMIT; } @@ -28507,7 +28716,7 @@ class Node{ return index; } - getOpeningValueSetIfNeeded(valueSet,indent){ + getOpeningValueSetIfNeeded(valueSet,indent,nexToken){ if(valueSet) return LINE_BREAK+getIndent(indent); return EMPTY_STRING; @@ -28534,7 +28743,14 @@ class Node{ } + hasComments(triple){ + return triple.constraints.reduce((acc,c)=>{ + if(c.type=='comment' && c.start)acc = true; //c.start just to check it's a real comment token + return acc; + },false) + } + } @@ -28549,7 +28765,7 @@ let { WHITE_SPACE, EMPTY_STRING, VALUESET_LINE_LIMIT, - EMPTY_BRACKETS, + EMPTY_BRACKETS } = require('./printUtils.js'); let { @@ -28564,8 +28780,7 @@ let { AND_KEYWORD, OR_KEYWORD } = require('../constUtils.js'); - -},{"../constUtils.js":44,"./printUtils.js":51}],50:[function(require,module,exports){ +},{"../constUtils.js":45,"./printUtils.js":53}],52:[function(require,module,exports){ function prettify(yashe){ // Save the value before the prettify it @@ -28576,39 +28791,47 @@ function prettify(yashe){ let tokens = getTokens(yashe); // Objects - let firstComments = getFirstComments(tokens); - let directivesAndStarts = getDirectivesAndStarts(tokens); + let initialComments = getFirstComments(tokens); + let initialDirectivesAndStarts = getInitialDirectivesAndStarts(tokens); let shapes = getShapes(tokens); + console.log(shapes) // Strings - let directivesStr = getDirectivesAndStartsStr(directivesAndStarts); + let initialDirectivesAndStartsStr = getDirectivesAndStartsStr(initialDirectivesAndStarts); let shapesStr = getShapesStr(shapes); - let prettified = firstComments+directivesStr+shapesStr; + let prettified = initialComments+initialDirectivesAndStartsStr+shapesStr; // Is there any change? // It is true that without this check the user // wouldn't appreciate the difference but yashe // would be doing operations that would appear - // in the undo stack + // in the undo/redo stack if(previousValue!=prettified){ yashe.setValue(prettified) ; + prettifyComments(); setCursor(yashe,cursorPosition); } + } function getShapes(tokens){ return getShapesTokens(tokens).reduce((acc,shapeTokens)=>{ let nodes = getNodes(shapeTokens); let comments = getCommentsAfterShape(shapeTokens); - - acc.push(new Shape(nodes,comments)); + let prefixes = getPrefixesAfterShape(shapeTokens); + + acc.push(new Shape(nodes,comments,prefixes)); return acc; },[]) } +function getPrefixesAfterShape(shapeTokens){ + return getDirectivesAndStartsStr(getDirectivesAndStarts(shapeTokens.reverse())); +} + function getNodes(shapeTokens){ - return getSlots(shapeTokens).reduce((acc,slot,index)=>{ + return getSlots(shapeTokens).reduce((acc,slot)=>{ let constraints = getBeforeTriplesTokens(slot); let triples = getTriples(getTripleTokens(slot)); let paranthesis = hasFinalParenthesis(slot); @@ -28636,13 +28859,17 @@ function hasFinalParenthesis(slot){ function getCommentsAfterShape(shapeTokens){ let i = 0; return shapeTokens.reverse().reduce((acc,t,index)=>{ + if(t.type==COMMENT_TYPE && index == i){ //index == i is needed in order not to take comments after a differtent token (CLOSING_CURLY_BRACKET) - acc.push(t); + if(!isDirective(shapeTokens[index+1])){//check that it's not a directive comment + acc.push(t); + } i++; } + if(isDirective(t) || isStart(t,shapeTokens[index+1])){ - i++; + i++ } return acc; @@ -28660,17 +28887,18 @@ function getTriples(tokens) { if(token.skip) return acc; //Is a comment that is part of the previous triple singleTriple.push(token); - - if(isFinishOfTriple(tokens,token,index,finish)){ + let multiElementOneOf = isMultiElementOneOf(token); + if(isFinishOfTriple(tokens,token,index,finish) || multiElementOneOf){ if(singleTriple.length>1){ + console.log(singleTriple) let before = getBeforeTriplesTokens(singleTriple); let tripleTokens = getTripleTokens(singleTriple); let subTriples = getTriples(tripleTokens); - let after = getAfterTripleTokens(singleTriple); + let after = getAfterTripleTokens(singleTriple,multiElementOneOf); let comment = getComentsAfterToken(token,tokens,index); //We want the tokens after the Triple let emptyBrackets = start && subTriples.length==0; - - acc.push(new Node(before,subTriples,comment,emptyBrackets,after)); + + acc.push(new Node(before,subTriples,comment,emptyBrackets,after,'',multiElementOneOf)); start=false; } singleTriple = []; @@ -28689,10 +28917,11 @@ function getTriples(tokens) { },[]) } -function getAfterTripleTokens(tokens){ + +function getAfterTripleTokens(tokens,multiElementOneOf){ let start=false; let open = 0; - return tokens.reduce((acc,t)=>{ + let after = tokens.reduce((acc,t)=>{ if(open == 0 && start){ if(t.string != SEMICOLON @@ -28711,6 +28940,9 @@ function getAfterTripleTokens(tokens){ return acc; },[]) + + if(after.length==0 && multiElementOneOf)after.push(tokens[tokens.length-1]); + return after; } @@ -28725,7 +28957,7 @@ function getBeforeTriplesTokens(tokens){ start = false; } - if(index == tokens.length-1 && t.string!='.')start=false; //Break condition 2 + if(index == tokens.length-1 && t.string!='.' && t.string!=']')start=false; //Break condition 2 -> If it's the last token break unless it's a . or ] which we want it if(start){ acc.push(t); @@ -28816,10 +29048,15 @@ function getTokens(){ } +function getInitialDirectivesAndStarts(tokens){ + return getDirectivesAndStarts(tokens,SHAPE_TYPE); +} + + /** Sorry Acebal */ -function getDirectivesAndStarts(tokens){ +function getDirectivesAndStarts(tokens,breakCondition){ let prefix = {}; let base = {}; let importt = {}; @@ -28827,7 +29064,13 @@ function getDirectivesAndStarts(tokens){ let baseCont = 0; let importCont = 0; let startCont = 0; + let stop = false; return tokens.reduce((acc,t,index)=>{ + + if(stop)return acc; + if(t.type == breakCondition)stop=true; + + if(t.string.toUpperCase()==PREFIX_KEYWORD){ prefix = {}; prefix.comments = getComentsAfterToken(t,tokens,index); @@ -28945,6 +29188,7 @@ function getFirstComments(tokens){ } function isDirective(token) { + if(!token)return false; if( token.string.toUpperCase()==PREFIX_KEYWORD || token.string.toUpperCase()==BASE_KEYWORD || token.string.toUpperCase()==IMPORT_KEYWORD @@ -28995,17 +29239,58 @@ function setCursor(yashe,position){ } } -function isCursorToken(token1,token2,line){ - return token1.start == token2.start - && token1.end == token2.end - && token1.string == token2.string - && token1.type == token2.type - && line == token2.line; + +function prettifyComments(){ + let longest = getLongestCommentedLine(); + let history = yashe.getHistory(); + for (var l = 0; l < yashe.lineCount(); ++l) { + let lineTokens = formatUtils.getNonWsLineTokens(yashe.getLineTokens(l)); + if(!hasOnlyComments(lineTokens)){ + lineTokens.map(t=>{ + if(t.type == 'comment') { + yashe.replaceRange(printUtils.getSeparator(longest-t.start)+t.string,{line:l,ch:t.start},{line:l,ch:t.end}) + } + }); + } + } + yashe.setHistory(history); } -function isStart(token,previousToken) { - if((token.string.toUpperCase()==START_KEYWORD && token.type == KEYWORD_TYPE) - || (token.string== EQUALS && token.type == PUNC_TYPE) + +function getLongestCommentedLine(){ + let longest = 0; + for (var l = 0; l < yashe.lineCount(); ++l) { + let lineTokens = formatUtils.getNonWsLineTokens(yashe.getLineTokens(l)); + let lastLineToken = lineTokens[lineTokens.length-1]; + if(lastLineToken) + if(lastLineToken.start>longest) + longest = lastLineToken.start; + } + return longest; +} + +/** + * Returns true if the line has onlyComments + */ +function hasOnlyComments(lineTokens){ + return lineTokens.reduce((acc,t)=>{ + if(t.type!='comment')acc=false; + return acc; + },true); +} + + +function isCursorToken(token1,token2,line){ + return token1.start == token2.start + && token1.end == token2.end + && token1.string == token2.string + && token1.type == token2.type + && line == token2.line; +} + +function isStart(token,previousToken) { + if((token.string.toUpperCase()==START_KEYWORD && token.type == KEYWORD_TYPE) + || (token.string== EQUALS && token.type == PUNC_TYPE) || (token.type == SHAPE_REF_TYPE && previousToken && previousToken.string == EQUALS)) return true; return false; } @@ -29020,6 +29305,10 @@ function getNonWsTokens(tokens){ }) } +function isMultiElementOneOf(token){ + return token.string == LOGICAL_OR; +} + module.exports = { prettify:prettify, @@ -29028,6 +29317,7 @@ module.exports = { let Shape = require('./shape.js'); let Node = require('./node.js'); +let formatUtils = require('../formatUtils.js'); let { getLongestPrefix, getSeparator, @@ -29038,6 +29328,7 @@ let { OPENING_CURLY_BRACKET, CLOSING_CURLY_BRACKET, CLOSING_PARENTHESIS, + LOGICAL_OR, SEMICOLON, EQUALS, @@ -29059,7 +29350,9 @@ let { OR_KEYWORD, START_KEYWORD } = require('../constUtils.js'); -},{"../constUtils.js":44,"./node.js":49,"./printUtils.js":51,"./shape.js":52}],51:[function(require,module,exports){ +const printUtils = require('./printUtils.js'); + +},{"../constUtils.js":45,"../formatUtils.js":46,"./node.js":51,"./printUtils.js":53,"./shape.js":54}],53:[function(require,module,exports){ const VALUESET_LINE_LIMIT = 2; // Sets the máximun number of values inside a valueSet const LINE_BREAK = '\n'; const WHITE_SPACE = ' '; @@ -29094,7 +29387,7 @@ function getIndent(tab) { function getLongestPrefix(prefixes){ return prefixes.reduce((acc,p) =>{ - if(p.alias.string.length>acc)acc=p.alias.string.length; + if(p.alias && p.alias.string.length>acc)acc=p.alias.string.length; return acc; },0); } @@ -29113,6 +29406,7 @@ function getLongestTConstraint(triples){ } + function needsSeparator(index,token,nexToken,triplesLenght,constraints,emptyBrackets){ if(isJustEmptyBrackets(triplesLenght,emptyBrackets,constraints))return true; return index==0 @@ -29178,8 +29472,11 @@ function getDirectivesAndStartsStr(directives) { function getPrefixesStr(prefixes,keyword){ return prefixes.reduce((acc,p)=>{ - let dif = getLongestPrefix(prefixes) - p.alias.string.length; - return acc+= keyword+p.alias.string+getSeparator(dif)+p.iri.string+p.comments+'\n'; + if(p.alias){ + let dif = getLongestPrefix(prefixes) - p.alias.string.length; + return acc+= keyword+p.alias.string+getSeparator(dif)+p.iri.string+p.comments+'\n'; + } + return acc; },''); } @@ -29193,12 +29490,12 @@ function getConcreteDirectiveStr(directives,keyword) { function getStartsStr(starts) { return starts.reduce((acc,s)=>{ return acc+=s+"\n"; - },"")+'\n'; + },""); } function getShapesStr(shapes) { return shapes.reduce((acc,s)=>{ - return acc+=s.toString()+"\n\n"; + return acc+='\n'+s.toString()+'\n'; },''); } @@ -29242,12 +29539,13 @@ let { OR_KEYWORD } = require('../constUtils.js'); -},{"../constUtils.js":44}],52:[function(require,module,exports){ +},{"../constUtils.js":45}],54:[function(require,module,exports){ class Shape{ - constructor(nodes,comments=[]){ + constructor(nodes,comments=[],directivesAndStarts){ this.nodes = nodes; this.comments = comments; + this.directivesAndStarts = directivesAndStarts; } getCommentsStr(){ @@ -29256,131 +29554,22 @@ class Shape{ },""); } + getDirectivesAndStartsStr(){ + let str = ''; + if(this.directivesAndStarts.trim()!='') + str = '\n\n'+this.directivesAndStarts; + return str; + } + toString(){ return this.nodes.reduce((acc,n)=>{ - return acc+=n.toString(0) + this.getCommentsStr(); + return acc+=n.toString() + this.getCommentsStr() + this.getDirectivesAndStartsStr(); },""); } } module.exports = Shape; -},{}],53:[function(require,module,exports){ -const ENTITY_TYPES = { - 'http://www.wikidata.org/prop/direct/': 'property', - 'http://www.wikidata.org/prop/direct-normalized/': 'property', - 'http://www.wikidata.org/prop/': 'property', - 'http://www.wikidata.org/prop/novalue/': 'property', - 'http://www.wikidata.org/prop/statement/': 'property', - 'http://www.wikidata.org/prop/statement/value/': 'property', - 'http://www.wikidata.org/prop/statement/value-normalized/': 'property', - 'http://www.wikidata.org/prop/qualifier/': 'property', - 'http://www.wikidata.org/prop/qualifier/value/': 'property', - 'http://www.wikidata.org/prop/qualifier/value-normalized/': 'property', - 'http://www.wikidata.org/prop/reference/': 'property', - 'http://www.wikidata.org/prop/reference/value/': 'property', - 'http://www.wikidata.org/prop/reference/value-normalized/': 'property', - 'http://www.wikidata.org/wiki/Special:EntityData/': 'item', - 'http://www.wikidata.org/entity/': 'item' -}; - -const NAMESPACE_SHORTCUTS = { - wikibase: 'http://wikiba.se/ontology#', - wd: 'http://www.wikidata.org/entity/', - wdt: 'http://www.wikidata.org/prop/direct/', - wdtn: 'http://www.wikidata.org/prop/direct-normalized/', - wds: 'http://www.wikidata.org/entity/statement/', - p: 'http://www.wikidata.org/prop/', - wdref: 'http://www.wikidata.org/reference/', - wdv: 'http://www.wikidata.org/value/', - ps: 'http://www.wikidata.org/prop/statement/', - psv: 'http://www.wikidata.org/prop/statement/value/', - psn: 'http://www.wikidata.org/prop/statement/value-normalized/', - pq: 'http://www.wikidata.org/prop/qualifier/', - pqv: 'http://www.wikidata.org/prop/qualifier/value/', - pqn: 'http://www.wikidata.org/prop/qualifier/value-normalized/', - pr: 'http://www.wikidata.org/prop/reference/', - prv: 'http://www.wikidata.org/prop/reference/value/', - prn: 'http://www.wikidata.org/prop/reference/value-normalized/', - wdno: 'http://www.wikidata.org/prop/novalue/', - wdata: 'http://www.wikidata.org/wiki/Special:EntityData/' - } - -const WIKIDATA_ENDPOINT= 'https://www.wikidata.org/w/' - - - -var getEndPoint = function(yashe,prefixName){ - - let definedPrefixex = yashe.getDefinedPrefixes(); - let endpoint = null; - Object.keys(definedPrefixex).map(p =>{ - if(p==prefixName){ - if(definedPrefixex[p].includes('/wiki/')){ - endpoint = definedPrefixex[p].replace('http://','https://').split('/wiki/')[0]+'/w/'; - }else{ - Object.keys(ENTITY_TYPES).map(pref=>{ - if(pref === definedPrefixex[p]){ - endpoint = WIKIDATA_ENDPOINT; - } - }); - } - } - }) - - return endpoint; -} - - -var isWikidataEntitiesPrefix = function(yashe,prefixName){ - - var definedPrefixex = yashe.getDefinedPrefixes() - var iriPrefix - - //Gets de IRI of the prefix from the defined - for (const prop in definedPrefixex) { - if(prop === prefixName) - iriPrefix = definedPrefixex[prop] - } - - - //Compare iriPrefix with the valid wikidata entities prefixes - for(const pref in ENTITY_TYPES){ - if(ENTITY_TYPES[pref] === 'item' && pref == iriPrefix) - return true - } - return false -} - -var isWikidataPropertiesPrefix = function(yashe,prefixName){ - - var definedPrefixex = yashe.getDefinedPrefixes() - var iriPrefix - - //Gets de IRI of the prefix from the defined - for (const prop in definedPrefixex) { - if(prop === prefixName) - iriPrefix = definedPrefixex[prop] - } - - //Compare iriPrefix with the valid wikidata properties prefixes - for(const pref in ENTITY_TYPES){ - if(ENTITY_TYPES[pref] === 'property' && pref == iriPrefix) - return true - } - return false -} - - -module.exports = { - - entityTypes:ENTITY_TYPES, - namespaceShortCuts: NAMESPACE_SHORTCUTS, - getEndPoint:getEndPoint, - isWikidataEntitiesPrefix:isWikidataEntitiesPrefix, - isWikidataPropertiesPrefix:isWikidataPropertiesPrefix - -} -},{}],54:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ "use strict"; var $ = require("jquery"), yutils = require("yasgui-utils"), @@ -29394,8 +29583,12 @@ var checkSyntax = function(yashe) { resetValues(yashe); var state = null; - let openTokensCounter = 0; - let closedTokensCounter = 0; + let openBracketsCounter = 0; + let closedBracketsCounter = 0; + let openParenthesisCounter = 0; + let closedParenthesisCounter = 0; + let openSquareBracketsCounter = 0; + let closedSquareBracketsCounter = 0; for (var l = 0; l < yashe.lineCount(); ++l) { var precise = false; @@ -29449,6 +29642,7 @@ var checkSyntax = function(yashe) { warningEl.className = "parseErrorIcon"; yashe.setGutterMarker(l, "gutterErrorBar", warningEl); + yashe.queryValid = false; return false; } @@ -29456,25 +29650,54 @@ var checkSyntax = function(yashe) { let lineTokens = yashe.getLineTokens(l); for(let t in lineTokens){ let token = lineTokens[t]; - //This is only necessary to verify the if the last '}' is missing (See #104) + if(token.string=='{'){ - openTokensCounter++; + openBracketsCounter++; } if(token.string=='}'){ - closedTokensCounter++; + closedBracketsCounter++; + } + + if(token.string=='('){ + openParenthesisCounter++; + } + if(token.string==')'){ + closedParenthesisCounter++; } + + if(token.string=='['){ + openSquareBracketsCounter++; + } + if(token.string==']'){ + closedSquareBracketsCounter++; + } + } updateShapesAndPrefixes(yashe,l); } - //Is last '}' missing? (See #104) - if(openTokensCounter != closedTokensCounter){ + //Is last '}' missing? (See #104 https://github.com/weso/YASHE/issues/104) + if(openBracketsCounter != closedBracketsCounter){ setError(yashe.lastLine(),"This line is invalid. Expected: '}'",yashe) yashe.queryValid = false; return false; } + //Is last ')' missing? (See #150 https://github.com/weso/YASHE/issues/150) + if(openParenthesisCounter != closedParenthesisCounter){ + setError(yashe.lastLine(),"This line is invalid. Expected: ')'",yashe) + yashe.queryValid = false; + return false; + } + + //Is last ']' missing? (See #163 https://github.com/weso/YASHE/issues/163) + if(openSquareBracketsCounter != closedSquareBracketsCounter){ + setError(yashe.lastLine(),"This line is invalid. Expected: ']'",yashe) + yashe.queryValid = false; + return false; + } + if(!checkPrefixes(yashe))return false; @@ -29502,8 +29725,7 @@ var checkSyntax = function(yashe) { let token = lineTokens[t]; - if(token.type=='string-2' || - token.type=='constraint'){ + if(token.type=='string-2'|| (token.type=='constraint' && token.string.includes(":"))){ yashe.usedPrefixes.push({ alias:token.string.split(":")[0]+':', line:l }); @@ -29549,7 +29771,6 @@ var checkSyntax = function(yashe) { } - /** * Check if the ShapeRefs are defined @@ -29602,11 +29823,19 @@ var checkSyntax = function(yashe) { yashe.setGutterMarker(line, "gutterErrorBar", warningEl); } + + var reCheckSyntax = function(yashe){ + setTimeout(() => { + checkSyntax(yashe); + }, 400); + } + module.exports = { - checkSyntax:checkSyntax + checkSyntax:checkSyntax, + reCheckSyntax:reCheckSyntax }; -},{"./imgs.js":46,"./tooltipUtils.js":56,"jquery":16,"yasgui-utils":30}],55:[function(require,module,exports){ +},{"./imgs.js":47,"./tooltipUtils.js":57,"jquery":16,"yasgui-utils":30}],56:[function(require,module,exports){ "use strict"; /** * @param yashe {doc} @@ -29652,10 +29881,10 @@ module.exports = { getNextNonWsToken: getNextNonWsToken }; -},{}],56:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ "use strict"; var $ = require("jquery"), - rdfUtils = require('./rdfUtils.js') + wikiUtils = require('./wikiUtils.js') /** * Write our own tooltip, to avoid loading another library for just this functionality. For now, we only use tooltip for showing parse errors, so this is quite a tailored solution @@ -29711,13 +29940,13 @@ var triggerTooltip = function(yashe, e) { var wikiElement = token.split(':')[1] if(wikiElement!== undefined && wikiElement!== ''){ - let endpoint = rdfUtils.getEndPoint(yashe,prefixName); + let endpoint = wikiUtils.getEndPoint(yashe,prefixName); if(endpoint!=null){ - checkEntity(wikiElement,endpoint) + wikiUtils.getEntity(wikiElement,endpoint) .done((data)=>{loadTooltip(yashe,data,wikiElement,posX,posY)}) .fail( ()=>{ - checkEntity(wikiElement,endpoint.replace('/w/','/wiki/')) + wikiUtils.getEntity(wikiElement,endpoint.replace('/w/','/wiki/')) .done((data)=>{loadTooltip(yashe,data,wikiElement,posX,posY)}) }); } @@ -29726,42 +29955,9 @@ var triggerTooltip = function(yashe, e) { } var loadTooltip = function(yashe,data,wikiElement,posX,posY){ - if(!data.error){ - - var userLang; - var entity = ''; - var description='' - var theme; - //Gets the preference languaje from the navigator - userLang = (navigator.language || navigator.userLanguage).split("-")[0] - - - var content = data.entities[wikiElement.toUpperCase()] - - //Check if the property/entity exist - if(!content.labels)return; - - //Some properties and entities are only avalible in English - //So if they do not exist we take it in English - if(content.labels[userLang] && content.descriptions[userLang]){ - - entity = content.labels[userLang].value +' ('+wikiElement+')' - description = content.descriptions[userLang].value - - }else{ - - let lb = content.labels['en']; - let desc = content.descriptions['en']; - if(lb){ - entity = lb.value +' ('+wikiElement+')'; - } - if(desc){ - description = desc.value - } - - } - - theme = yashe.getOption('theme'); + var entityData = wikiUtils.getEntityData(wikiElement,data); + if(entityData && entityData.title!=''){ + let theme = yashe.getOption('theme'); let cssStyle = themeStyles['default']; if(theme=='dark'){ cssStyle = themeStyles['dark']; @@ -29779,23 +29975,12 @@ var loadTooltip = function(yashe,data,wikiElement,posX,posY){ .append( $('
').css(cssStyle) .append( - $('
').html(entity).css(styles.title)) + $('
').html(entityData.title).css(styles.title)) .append( - $('
').html(description).css(styles.description))) + $('
').html(entityData.description).css(styles.description))) .appendTo('body').fadeIn( 'slow' ); } -} - -// U S A R M É T O D O P Á R A M S -var checkEntity = function (entity,endPoint){ - return $.get( - { - - url: endPoint+'api.php?action=wbgetentities&format=json&ids='+entity, - dataType: 'jsonp', - - }) - + } @@ -29885,7 +30070,187 @@ module.exports = { removeWikiToolTip:removeWikiToolTip, debounce:debounce, }; -},{"./rdfUtils.js":53,"jquery":16}]},{},[39])(39) +},{"./wikiUtils.js":58,"jquery":16}],58:[function(require,module,exports){ +const ENTITY_TYPES = { + 'http://www.wikidata.org/prop/direct/': 'property', + 'http://www.wikidata.org/prop/direct-normalized/': 'property', + 'http://www.wikidata.org/prop/': 'property', + 'http://www.wikidata.org/prop/novalue/': 'property', + 'http://www.wikidata.org/prop/statement/': 'property', + 'http://www.wikidata.org/prop/statement/value/': 'property', + 'http://www.wikidata.org/prop/statement/value-normalized/': 'property', + 'http://www.wikidata.org/prop/qualifier/': 'property', + 'http://www.wikidata.org/prop/qualifier/value/': 'property', + 'http://www.wikidata.org/prop/qualifier/value-normalized/': 'property', + 'http://www.wikidata.org/prop/reference/': 'property', + 'http://www.wikidata.org/prop/reference/value/': 'property', + 'http://www.wikidata.org/prop/reference/value-normalized/': 'property', + 'http://www.wikidata.org/wiki/Special:EntityData/': 'item', + 'http://www.wikidata.org/entity/': 'item' +}; + +const NAMESPACE_SHORTCUTS = { + wikibase: 'http://wikiba.se/ontology#', + wd: 'http://www.wikidata.org/entity/', + wdt: 'http://www.wikidata.org/prop/direct/', + wdtn: 'http://www.wikidata.org/prop/direct-normalized/', + wds: 'http://www.wikidata.org/entity/statement/', + p: 'http://www.wikidata.org/prop/', + wdref: 'http://www.wikidata.org/reference/', + wdv: 'http://www.wikidata.org/value/', + ps: 'http://www.wikidata.org/prop/statement/', + psv: 'http://www.wikidata.org/prop/statement/value/', + psn: 'http://www.wikidata.org/prop/statement/value-normalized/', + pq: 'http://www.wikidata.org/prop/qualifier/', + pqv: 'http://www.wikidata.org/prop/qualifier/value/', + pqn: 'http://www.wikidata.org/prop/qualifier/value-normalized/', + pr: 'http://www.wikidata.org/prop/reference/', + prv: 'http://www.wikidata.org/prop/reference/value/', + prn: 'http://www.wikidata.org/prop/reference/value-normalized/', + wdno: 'http://www.wikidata.org/prop/novalue/', + wdata: 'http://www.wikidata.org/wiki/Special:EntityData/' + } + +const WIKIDATA_ENDPOINT= 'https://www.wikidata.org/w/'; +const GET_ENTITY_QUERY = { + action:'wbgetentities', + format: 'json' +} + + + +var getEndPoint = function(yashe,prefixName){ + + let definedPrefixex = yashe.getDefinedPrefixes(); + let endpoint = null; + Object.keys(definedPrefixex).map(p =>{ + if(p==prefixName){ + if(definedPrefixex[p].includes('/wiki/')){ + endpoint = definedPrefixex[p].replace('http://','https://').split('/wiki/')[0]+'/w/'; + }else{ + Object.keys(ENTITY_TYPES).map(pref=>{ + if(pref === definedPrefixex[p]){ + endpoint = WIKIDATA_ENDPOINT; + } + }); + } + } + }) + + return endpoint; +} + + +var isWikidataEntitiesPrefix = function(yashe,prefixName){ + + var definedPrefixex = yashe.getDefinedPrefixes() + var iriPrefix + + //Gets de IRI of the prefix from the defined + for (const prop in definedPrefixex) { + if(prop === prefixName) + iriPrefix = definedPrefixex[prop] + } + + + //Compare iriPrefix with the valid wikidata entities prefixes + for(const pref in ENTITY_TYPES){ + if(ENTITY_TYPES[pref] === 'item' && pref == iriPrefix) + return true + } + return false +} + +var isWikidataPropertiesPrefix = function(yashe,prefixName){ + + var definedPrefixex = yashe.getDefinedPrefixes() + var iriPrefix + + //Gets de IRI of the prefix from the defined + for (const prop in definedPrefixex) { + if(prop === prefixName) + iriPrefix = definedPrefixex[prop] + } + + //Compare iriPrefix with the valid wikidata properties prefixes + for(const pref in ENTITY_TYPES){ + if(ENTITY_TYPES[pref] === 'property' && pref == iriPrefix) + return true + } + return false +} + +var isWikidataPrefix = function(yashe,token){ + var prefixName = token.string.split(':')[0] + if(token.type == 'shape' || token.type=='string-2' || token.type=='constraint' || token.type=='valueSet'){ + if(isWikidataEntitiesPrefix(yashe,prefixName) + || isWikidataPropertiesPrefix(yashe,prefixName) + || getEndPoint(yashe,prefixName)!=null){ + return true + } + } + return false; +} + +var getEntity = function(entity,endpoint){ + GET_ENTITY_QUERY.ids = entity; + return $.get({ + url: endpoint+'api.php?'+$.param(GET_ENTITY_QUERY), + dataType: 'jsonp', + }); +} + +var getEntityData = function(element,data){ + var userLang; + var content; + var entityData = {title:'',description:''} + if(!data.error){ + //Gets the preference languaje from the navigator + userLang = (navigator.language || navigator.userLanguage).split("-")[0] + + content = data.entities[element.toUpperCase()] + + //Check if the property/entity exist + if(!content.labels)return; + + //Some properties and entities are only avalible in English + if(content.labels[userLang] && content.descriptions[userLang]){ + + entityData.title = content.labels[userLang].value +' ('+element+')' + entityData.description = content.descriptions[userLang].value + + }else{ //English by default + + let lb = content.labels['en']; + let desc = content.descriptions['en']; + if(lb){ + entityData.title = lb.value +' ('+element+')'; + } + if(desc){ + entityData.description = desc.value + } + + } + } + return entityData; +} + + +module.exports = { + + entityTypes:ENTITY_TYPES, + namespaceShortCuts: NAMESPACE_SHORTCUTS, + wikidataEndpoint:WIKIDATA_ENDPOINT, + getEndPoint:getEndPoint, + isWikidataPrefix:isWikidataPrefix, + isWikidataEntitiesPrefix:isWikidataEntitiesPrefix, + isWikidataPropertiesPrefix:isWikidataPropertiesPrefix, + getEntity:getEntity, + getEntityData:getEntityData + +} + +},{}]},{},[40])(40) }); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJsaWIvZGVwYXJhbS5qcyIsImxpYi9ncmFtbWFyL190b2tlbml6ZXItdGFibGUuanMiLCJsaWIvZ3JhbW1hci90b2tlbml6ZXIuan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NlIHRoaXMgaXMgdXNlZCBhY2Nyb3NzIGxpbmVzXG4gIHZhciBzdHJpbmdMaXRlcmFsTG9uZ1JlZ2V4ID0ge307XG4gIGZvciAodmFyIGtleSBpbiBTVFJJTkdfTElURVJBTF9MT05HKSB7XG4gICAgc3RyaW5nTGl0ZXJhbExvbmdSZWdleFtrZXldID0ge1xuICAgICAgY29tcGxldGU6IHtcbiAgICAgICAgbmFtZTogXCJTVFJJTkdfTElURVJBTF9MT05HX1wiICsga2V5LFxuICAgICAgICByZWdleDogbmV3IFJlZ0V4cChcIl5cIiArIFNUUklOR19MSVRFUkFMX0xPTkdba2V5XS5DT01QTEVURSksXG4gICAgICAgIHN0eWxlOiBcInN0cmluZ1wiXG4gICAgICB9LFxuICAgICAgY29udGVudHM6IHtcbiAgICAgICAgbmFtZTogXCJTVFJJTkdfTElURVJBTF9MT05HX1wiICsga2V5LFxuICAgICAgICByZWdleDogbmV3IFJlZ0V4cChcIl5cIiArIFNUUklOR19MSVRFUkFMX0xPTkdba2V5XS5DT05URU5UUyksXG4gICAgICAgIHN0eWxlOiBcInN0cmluZ1wiXG4gICAgICB9LFxuICAgICAgY2xvc2luZzoge1xuICAgICAgICBuYW1lOiBcIlNUUklOR19MSVRFUkFMX0xPTkdfXCIgKyBrZXksXG4gICAgICAgIHJlZ2V4OiBuZXcgUmVnRXhwKFwiXlwiICsgU1RSSU5HX0xJVEVSQUxfTE9OR1trZXldLkNPTlRFTlRTICsgU1RSSU5HX0xJVEVSQUxfTE9OR1trZXldLlFVT1RFUyksXG4gICAgICAgIHN0eWxlOiBcInN0cmluZ1wiXG4gICAgICB9LFxuICAgICAgcXVvdGVzOiB7XG4gICAgICAgIG5hbWU6IFwiU1RSSU5HX0xJVEVSQUxfTE9OR19RVU9URVNfXCIgKyBrZXksXG4gICAgICAgIHJlZ2V4OiBuZXcgUmVnRXhwKFwiXlwiICsgU1RSSU5HX0xJVEVSQUxfTE9OR1trZXldLlFVT1RFUyksXG4gICAgICAgIH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UpO1xuICAgICAgaWYgKGNvbnN1bWVkKXtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICBjYXQ6IHN0cmVhbS5jdXJyZW50KCkudG9VcHBlckNhc2UoKSxcbiAgICAgICAgICBzdHlsZTogXCJrZXl3b3JkXCIsXG4gICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICB9O1xuICAgICAgfVxuXG4gICAgICAvLyBQdW5jdHVhdGlvblxuICAgICAgY29uc3VtZWQgPSBzdHJlYW0ubWF0Y2goZ3JhbW1hci5wdW5jdCwgdHJ1ZSwgZmFsc2UpO1xuICAgICAgaWYgKGNvbnN1bWVkKXtcbiAgICAgICAgaWYoc3RyZWFtLmN1cnJlbnQoKSE9JyonIFxuICAgICAgICAgICYmIHN0cmVhbS5jdXJyZW50KCkhPScrJ1xuICAgICAgICAgICAmJiBzdHJlYW0uY3VycmVudCgpIT0nPycpe1xuXG4gICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGNhdDogc3RyZWFtLmN1cnJlbnQoKSxcbiAgICAgICAgICAgIHN0eWxlOiBcInB1bmNcIixcbiAgICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxuICAgICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICAgIH07XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgIGNhdDogc3RyZWFtLmN1cnJlbnQoKSxcbiAgICAgICAgICBzdHlsZTogXCJjYXJkXCIsXG4gICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXG4gICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxuICAgICAgICB9O1xuXG4gICAgICAgXG4gICAgICB9XG5cblxuXG4gICAgICAvLyBUb2tlbiBpcyBpbnZhbGlkXG4gICAgICAvLyBiZXR0ZXIgY29uc3VtZSBzb21ldGhpbmcgYW55d2F5L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IGJ1dCB3aXRoICdEZWNsJyBpbnN0ZWFkIG9mICdEZWxjJyBkb2Vzbid0IHdvcmtcbiAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdGF0ZS5jdXJyZW50UG5hbWVOcyAhPT0gdW5kZWZpbmVkICYmIHRva2VuT2IudGV4dC5sZW5ndGggPiAyKSB7XG4gICAgICAgICAgICAgICAgdG9rZW5PYi5zdHlsZSA9ICdwcmVmaXhEZWxjSVJJJzsgLy9TYW1lIGFzIGJlZm9yZVxuICAgICAgICAgICAgICAgIHN0YXRlLnByZWZpeGVzW3N0YXRlLmN1cnJlbnRQbmFtZU5zXSA9IHRva2VuT2IudGV4dC5zbGljZSgxLCAtMSk7XG4gICAgICAgICAgICAgICAgLy9yZXNldCBjdXJyZW50IHBuYW1lIG5zXG4gICAgICAgICAgICAgICAgc3RhdGUuY3VycmVudFBuYW1lTnMgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHN0YXRlLmluQmFzZURlY2wpIHtcbiAgICAgICAgICAgICAgIGlmICh0b3BTeW1ib2wgPT09IFwiSVJJX1JFRlwiKXtcbiAgICAgICAgICAgICAgICAgIHRva2VuT2Iuc3R5bGUgPSAnYmFzZURlY2wnO1xuICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoc3RhdGUuaW5JbXBvcnREZWNsKSB7XG4gICAgICAgICAgICAgICBpZiAodG9wU3ltYm9sID09PSBcIklSSV9SRUZcIil7XG4gICAgICAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlID0gJ2ltcG9ydERlY2wnO1xuICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICBcbiAgICAgICAgICAgXG4gICAgICAgICAgICAvLyBNYXRjaGluZyB0ZXJtaW5hbHNcbiAgICAgICAgICAgIC8vIC0gY29uc3VtZSB0b2tlbiBmcm9tIGlucHV0IHN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mluZGV4T2YoXCI6XCIpO1xuICAgICAgICAgICAgICBpZiAoY29sb25JbmRleCA+PSAwKSB7XG4gICAgICAgICAgICAgICAgdmFyIHByZWZOcyA9IHRva2VuT2IudGV4dC5zbGljZSgwLCBjb2xvbkluZGV4KTtcbiAgICAgICAgICAgICAgICAvL2F2b2lkIHdhcm5pbmdzIGZvciBtaXNzaW5nIGJpZiBwcmVmaXhlcyAoeXVjaywgdmlydHVvc28tc3BlY2lmaWMpXG4gICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5wcmVmaXhlc1twcmVmTnNdICYmIFtcImJpZlwiLCBcInhzZFwiLCBcInNxbFwiXS5pbmRleE9mKHByZWZOcykgPCAwKSB7XG4gICAgICAgICAgICAgICAgICBzdGF0ZS5PSyA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgcmVjb3JkRmFpbHVyZVBvcygpO1xuICAgICAgICAgICAgICAgICAgc3RhdGUuZXJyb3JNc2cgPSBcIlByZWZpeCAnXCIgKyBwcmVmTnMgKyBcIicgaXMgbm90IGRlZmluZWRcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcbiAgICAgICAgICAgIHN0YXRlLmNvbXBsZXRlID0gZmFsc2U7XG4gICAgICAgICAgICByZWNvcmRGYWlsdXJlUG9zKCk7XG4gICAgICAgICAgfVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIC8vIHRvcFN5bWJvbCBpcyBub250ZXJtaW5hbFxuICAgICAgICAgIC8vIC0gc2VlIGlmIHRoZXJlIGlzIGFuIGVudHJ5IGZvciB0b3BTeW1ib2xcbiAgICAgICAgICAvLyBhbmQgbmV4dFRva2VuIGluIHRhYmxlXG4gICAgICAgICAgXG4gICAgICAgICAgdmFyIG5leHRTeW1ib2xzID0gbGwxX3RhYmxlW3RvcFN5bWJvbF1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mRsZXJDYWxsYmFjayk7XG4gICAgICAgICAgICAgICAgdGhpcy5mYWtlSGFuZGxlciA9IG51bGw7XG4gICAgICAgICAgICAgICAgdGhpcy5mYWtlSGFuZGxlckNhbGxiYWNrID0gbnVsbDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKHRoaXMuZmFrZUVsZW0pIHtcbiAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5yZW1vdmVDaGlsZCh0aGlzLmZha2VFbGVtKTtcbiAgICAgICAgICAgICAgICB0aGlzLmZha2VFbGVtID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBTZWxlY3RzIHRoZSBjb250ZW50IGZyb20gZWxlbWVudCBwYXNzZWQgb24gYHRhcmdldGAgcHJvcGVydHkuXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdzZWxlY3RUYXJnZXQnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gc2VsZWN0VGFyZ2V0KCkge1xuICAgICAgICAgICAgdGhpcy5zZWxlY3RlZFRleHQgPSAoMCwgX3NlbGVjdDIuZGVmYXVsdCkodGhpcy50YXJnZXQpO1xuICAgICAgICAgICAgdGhpcy5jb3B5VGV4dCgpO1xuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEV4ZWN1dGVzIHRoZSBjb3B5IG9wZXJhdGlvbiBiYXNlZCBvbiB0aGUgY3VycmVudCBzZWxlY3Rpb24uXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdjb3B5VGV4dCcsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBjb3B5VGV4dCgpIHtcbiAgICAgICAgICAgIHZhciBzdWNjZWVkZWQgPSB2b2lkIDA7XG5cbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgc3VjY2VlZGVkID0gZG9jdW1lb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XCJhY3Rpb25cIiB2YWx1ZSwgdXNlIGVpdGhlciBcImNvcHlcIiBvciBcImN1dFwiJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogR2V0cyB0aGUgYGFjdGlvbmAgcHJvcGVydHkuXG4gICAgICAgICAqIEByZXR1cm4ge1N0cmluZ31cbiAgICAgICAgICovXG4gICAgICAgICxcbiAgICAgICAgZ2V0OiBmdW5jdGlvbiBnZXQoKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5fYWN0aW9uO1xuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIFNldHMgdGhlIGB0YXJnZXRgIHByb3BlcnR5IHVzaW5nIGFuIGVsZW1lbnRcbiAgICAgICAgICogdGhhdCB3aWxsIGJlIGhhdmUgaXRzIGNvbnRlbnQgY29waWVkLlxuICAgICAgICAgKiBAcGFyYW0ge0VsZW1lbnR9IHRhcmdldFxuICAgICAgICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAndGFyZ2V0JyxcbiAgICAgICAgc2V0OiBmdW5jdGlvbiBzZXQodGFyZ2V0KSB7XG4gICAgICAgICAgICBpZiAodGFyZ2V0ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICh0eXBlb2YgdGFyZ2V0ID09PSAndW5kZWZpbmVkJyA/ICd1bmRlZmluZWQnIDogX3R5cGVvZih0YXJnZXQpKSA9PT0gJ29iamVjdCcgJiYgdGFyZ2V0Lm5vZGVUeXBlID09PSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmFjdGlvbiA9PT0gJ2NvcHknICYmIHRhcmdldC5oYXNBdHRyaWJ1dGUoJ2Rpc2FibGVkJykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCBcInRhcmdldFwiIGF0dHJpYnV0ZS4gUGxlYXNl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9IHBvcyAmJiBuZXh0Q2hhbmdlID4gc3AudG8pIHtcbiAgICAgICAgICAgICAgbmV4dENoYW5nZSA9IHNwLnRvO1xuICAgICAgICAgICAgICBzcGFuRW5kU3R5bGUgPSBcIlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG0uY2xhc3NOYW1lKSB7IHNwYW5TdHlsZSArPSBcIiBcIiArIG0uY2xhc3NOYW1lOyB9XG4gICAgICAgICAgICBpZiAobS5jc3MpIHsgY3NzID0gKGNzcyA/IGNzcyArIFwiO1wiIDogXCJcIikgKyBtLmNzczsgfVxuICAgICAgICAgICAgaWYgKG0uc3RhcnRTdHlsZSAmJiBzcC5mcm9tID09IHBvcykgeyBzcGFuU3RhcnRTdHlsZSArPSBcIiBcIiArIG0uc3RhcnRTdHlsZTsgfVxuICAgICAgICAgICAgaWYgKG0uZW5kU3R5bGUgJiYgc3AudG8gPT0gbmV4dENoYW5nZSkgeyAoZW5kU3R5bGVzIHx8IChlbmRTdHlsZXMgPSBbXSkpLnB1c2gobS5lbmRTdHlsZSwgc3AudG8pOyB9XG4gICAgICAgICAgICAvLyBzdXBwb3J0IGZvciB0aGUgb2xkIHRpdGxlIHByb3BlcnR5XG4gICAgICAgICAgICAvLyBodHRwczovL2dpdGh1Yi5jb20vY29kZW1pcnJvci9Db2RlTWlycm9yL3B1bGwvNTY3M1xuICAgICAgICAgICAgaWYgKG0udGl0bGUpIHsgKGF0dHJpYnV0ZXMgfHwgKGF0dHJpYnV0ZXMgPSB7fSkpLnRpdGxlID0gbS50aXRsZTsgfVxuICAgICAgICAgICAgaWYgKG0uYXR0cmlidXRlcykge1xuICAgICAgICAgICAgICBmb3IgKHZhciBhdHRyIGluIG0uYXR0cmlidXRlcylcbiAgICAgICAgICAgICAgICB7IChhdHRyaWJ1dGVzIHx8IChhdHRyaWJ1dGVzID0ge30pKVthdHRyXSA9IG0uYXR0cmlidXRlc1thdHRyXTsgfVxuICAgICAgICAgICAgfVxuICAgICAgIC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cbiAgICAgICAgICBpZiAoY29sbGFwc2VkLnRvID09IG51bGwpIHsgcmV0dXJuIH1cbiAgICAgICAgICBpZiAoY29sbGFwc2VkLnRvID09IHBvcykgeyBjb2xsYXBzZWQgPSBmYWxzZTsgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBpZiAocG9zID49IGxlbikgeyBicmVhayB9XG5cbiAgICAgIHZhciB1cHRvID0gTWF0aC5taW4obGVuLCBuZXh0Q2hhbmdlKTtcbiAgICAgIHdoaWxlICh0cnVlKSB7XG4gICAgICAgIGlmICh0ZXh0KSB7XG4gICAgICAgICAgdmFyIGVuZCA9IHBvcyArIHRleHQubGVuZ3RoO1xuICAgICAgICAgIGlmICghY29sbGFwc2VkKSB7XG4gICAgICAgICAgICB2YXIgdG9rZW5UZXh0ID0gZW5kID4gdXB0byA/IHRleHQuc2xpY2UoMCwgdXB0byAtIHBvcykgOiB0ZXh0O1xuICAgICAgICAgICAgYnVpbGRlci5hZGRUb2tlbihidWlsZGVyLCB0b2tlblRleHQsIHN0eWxlID8gc3R5bGUgKyBzcGFuU3R5bGUgOiBzcGFuU3R5bGUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW5TdGFydFN0eWxlLCBwb3MgKyB0b2tlblRleHQubGVuZ3RoID09IG5leHRDaGFuZ2UgPyBzcGFuRW5kU3R5bGUgOiBcIlwiLCBjc3MsIGF0dHJpYnV0ZXMpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoZW5kID49IHVwdG8pIHt0ZXh0ID0gdGV4dC5zbGljZSh1cHRvIC0gcG9zKTsgcG9zID0gdXB0bzsgYnJlYWt9XG4gICAgICAgICAgcG9zID0gZW5kO1xuICAgICAgICAgIHNwYW5TdGFydFN0eWxlID0gXCJcIjtcbiAgICAgICAgfVxuICAgICAgICB0ZXh0ID0gYWxsVGV4dC5zbGljZShhdCwgYXQgPSBzdHlsZXNbaSsrXSk7XG4gICAgICAgIHN0eWxlID0gaW50ZXJwcmV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bih0aW1lLCBwb3MsIGJ1dHRvbikge1xuICAgIHRoaXMudGltZSA9IHRpbWU7XG4gICAgdGhpcy5wb3MgPSBwb3M7XG4gICAgdGhpcy5idXR0b24gPSBidXR0b247XG4gIH07XG5cbiAgUGFzdENsaWNrLnByb3RvdHlwZS5jb21wYXJlID0gZnVuY3Rpb24gKHRpbWUsIHBvcywgYnV0dG9uKSB7XG4gICAgcmV0dXJuIHRoaXMudGltZSArIERPVUJMRUNMSUNLX0RFTEFZID4gdGltZSAmJlxuICAgICAgY21wKHBvcywgdGhpcy5wb3MpID09IDAgJiYgYnV0dG9uID09IHRoaXMuYnV0dG9uXG4gIH07XG5cbiAgdmFyIGxhc3RDbGljaywgbGFzdERvdWJsZUNsaWNrO1xuICBmdW5jdGlvbiBjbGlja1JlcGVhdChwb3MsIGJ1dHRvbikge1xuICAgIHZhciBub3cgPSArbmV3IERhdGU7XG4gICAgaWYgKGxhc3REb3VibGVDbGljayAmJiBsYXN0RG91YmxlQ2xpY2suY29tcGFyZShub3csIHBvcywgYnV0dG9uKSkge1xuICAgICAgbGFzdENsaWNrID0gbGFzdERvdWJsZUNsaWNrID0gbnVsbDtcbiAgICAgIHJldHVybiBcInRyaXBsZVwiXG4gICAgfSBlbHNlIGlmIChsYXN0Q2xpY2sgJiYgbGFzdENsaWNrLmNvbXBhcmUobm93LCBwb3MsIGJ1dHRvbikpIHtcbiAgICAgIGxhc3REb3VibGVDbGljayA9IG5ldyBQYXN0Q2xpY2sobm93LCBwb3MsIGJ1dHRvbik7XG4gICAgICBsYXN0Q2xpY2sgPSBudWxsO1xuICAgICAgcmV0dXJuIFwiZG91YmxlXCJcbiAgICB9IGVsc2Uge1xuICAgICAgbGFzdENsaWNrID0gbmV3IFBhc3RDbGljayhub3csIHBvcywgYnV0dG9uKTtcbiAgICAgIGxhc3REb3VibGVDbGljayA9IG51bGw7XG4gICAgICByZXR1cm4gXCJzaW5nbGVcIlxuICAgIH1cbiAgfVxuXG4gIC8vIEEgbW91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AgICAgICAgICAgIGZ1bmN0aW9uIGYobikge1xuLy8gICAgICAgICAgICAgICAgICAgICAgLy8gRm9ybWF0IGludGVnZXJzIHRvIGhhdmUgYXQgbGVhc3QgdHdvIGRpZ2l0cy5cbi8vICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAobiA8IDEwKVxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgID8gXCIwXCIgKyBuXG4vLyAgICAgICAgICAgICAgICAgICAgICAgICAgOiBuO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldFVUQ0Z1bGxZZWFyKCkgICArIFwiLVwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTW9udGgoKSArIDEpICsgXCItXCIgK1xuLy8gICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENEYXRlKCkpICAgICAgKyBcIlRcIiArXG4vLyAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ0hvdXJzKCkpICAgICArIFwiOlwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTWludXRlcygpKSAgICsgXCI6XCIgK1xuLy8gICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENTZWNvbmRzKCkpICAgKyBcIlpcIjtcbi8vICAgICAgICAgICAgICB9O1xuXG4vLyAgICAgICAgICBZb3UgY2FuIHByb3ZpZGUgYW4gb3B0aW9uYWwgcmVwbGFjZXIgbWV0aG9kLiBJdCB3aWxsIGJlIHBhc3NlZCB0aGVcbi8vICAgICAgICAgIGtleSBhbmQgdmFsdWUgb2YgZWFjaCBtZW1iZXIsIHdpdGggdGhpcyBib3VuZCB0byB0aGUgY29udGFpbmluZ1xuLy8gICAgICAgICAgb2JqZWN0LiBUaGUgdmFsdWUgdGhhdCBpcyByZXR1cm5lZCBmcm9tIHlvdXIgbWV0aG9kIHdpbGwgYmVcbi8vICA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XlEYXRhID0gSlNPTi5wYXJzZSh0ZXh0LCBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkge1xuLy8gICAgICAgICAgICAgIHZhciBhO1xuLy8gICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09IFwic3RyaW5nXCIpIHtcbi8vICAgICAgICAgICAgICAgICAgYSA9XG4vLyAgIC9eKFxcZHs0fSktKFxcZHsyfSktKFxcZHsyfSlUKFxcZHsyfSk6KFxcZHsyfSk6KFxcZHsyfSg/OlxcLlxcZCopPylaJC8uZXhlYyh2YWx1ZSk7XG4vLyAgICAgICAgICAgICAgICAgIGlmIChhKSB7XG4vLyAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IERhdGUoRGF0ZS5VVEMoK2FbMV0sICthWzJdIC0gMSwgK2FbM10sICthWzRdLFxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgICthWzVdLCArYVs2XSkpO1xuLy8gICAgICAgICAgICAgICAgICB9XG4vLyAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbi8vICAgICAgICAgIH0pO1xuXG4vLyAgICAgICAgICBteURhdGEgPSBKU09OLnBhcnNlKCdbXCJEYXRlKDA5LzA5LzIwMDEpXCJdJywgZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcbi8vICAgICAgICAgICAgICB2YXIgZDtcbi8vICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSBcInN0cmluZ1wiICYmXG4vLyAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5zbGljZSgwLCA1KSA9PT0gXCJEYXRlKFwiICYmXG4vLyAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5zbGljZSgtMSkgPT09IFwiKVwiKSB7XG4vLyAgICAgICAgICAgICAgICAgIGQgPSBuZXcgRGF0ZSh2YWx1ZS5zbGljZSg1LCAtMSkpO1xuLy8gICAgICAgICAgICAgICAgICBpZiAoZCkge1xuLy8gICAgICAgICA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pIHtcblxuICAgICAgICBEYXRlLnByb3RvdHlwZS50b0pTT04gPSBmdW5jdGlvbiAoKSB7XG5cbiAgICAgICAgICAgIHJldHVybiBpc0Zpbml0ZSh0aGlzLnZhbHVlT2YoKSlcbiAgICAgICAgICAgICAgICA/IHRoaXMuZ2V0VVRDRnVsbFllYXIoKSArIFwiLVwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENNb250aCgpICsgMSkgKyBcIi1cIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDRGF0ZSgpKSArIFwiVFwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENIb3VycygpKSArIFwiOlwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENNaW51dGVzKCkpICsgXCI6XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ1NlY29uZHMoKSkgKyBcIlpcIlxuICAgICAgICAgICAgICAgIDogbnVsbDtcbiAgICAgICAgfTtcblxuICAgICAgICBCb29sZWFuLnByb3RvdHlwZS50b0pTT04gPSB0aGlzX3ZhbHVlO1xuICAgICAgICBOdW1iZXIucHJvdG90eXBlLnRvSlNPTiA9IHRoaXNfdmFsdWU7XG4gICAgICAgIFN0cmluZy5wcm90b3R5cGUudG9KU09OID0gdGhpc192YWx1ZTtcbiAgICB9XG5cbiAgICB2YXIgZ2FwO1xuICAgIHZhciBpbmRlbnQ7XG4gICAgdmFyIG1ldGE7XG4gICAgdmFyIHJlcDtcblxuXG4gICAgZnVuY3Rpb24gcXVvdGUoc3RyaW5nKSB7XG5cbi8vIElmIHRoZSBzdHJpbmcgY29udGFpbnMgbm8gY29udHJvbCBjaGFyYWN0ZXJzLCBubyBxdW90ZSBjaGFyYWN0ZXJzLCBhbmQgbm9cbi8vIGJhY2tzbGFzaCBjaGFyYWN0ZXJzLCB0aGVuIHdlIGNhbiBzYWZlbHkgc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cGVvZiByZXAgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAgICAgICBsZW5ndGggPSByZXAubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlcFtpXSA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgayA9IHJlcFtpXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBzdHIoaywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsLnB1c2gocXVvdGUoaykgKyAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBcIjogXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogXCI6XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApICsgdik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuXG4vLyBPdGhlcndpc2UsIGl0ZXJhdGUgdGhyb3VnaCBhbGwgb2YgdGhlIGtleXMgaW4gdGhlIG9iamVjdC5cblxuICAgICAgICAgICAgICAgIGZvciAoayBpbiB2YWx1ZSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS5oYXNPd25Qcm9wZXJ0eS5jYWxsKHZhbHVlLCBrKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdiA9IHN0cihrLCB2YWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRpYWwucHVzaChxdW90ZShrKSArIChcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2FwXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IFwiOiBcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBcIjpcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgKyB2KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuLy8gSm9pbiBhbGwgb2YgdGhlIG1lbWJlciB0ZXh0cyB0b2dldGhlciwgc2VwYXJhdGVkIHdpdGggY29tbWFzLFxuLy8gYW5kIHdyYXAgdGhlbSBpbiBicmFjZXMuXG5cbiAgICAgICAgICAgIHYgPSBwYXJ0aWFsLmxlbmd0aCA9PT0gMFxuICAgICAgICAgICAgICAgID8gXCJ7fVwiXG4gICAgICAgICAgICAgICAgOiBnYXBcbiAgICAgICAgICAgICAgICAgICAgPyBcIntcXG5cIiArIGdhcCArIHBhcnRpYWwuam9pbihcIixcXG5cIiArIGdhcCkgKyBcIlxcblwiICsgbWluZCArIFwifVwiXG4gICAgICAgICAgICAgICAgICAgIDogXCJ7XCIgKyBwYXJ0aWFsLmpvaW4oXCIsXCIpICsgXCJ9XCI7XG4gICAgICAgICAgICBnYXAgPSBtaW5kO1xuICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgIH1cbiAgICB9XG5cbi8vIElmIHRoZSBKU09OIG9iamVjdCBkb2VzIG5vdCB5ZXQgaGF2ZSBhIHN0cmluZ2lmeSBtZXRob2QsIGdpdmUgaXQgb25lLlxuXG4gICAgaWYgKHR5cGVvZiBKU09OLnN0cmluZ2lmeSAhPT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgIG1ldGEgPSB7ICAgIC8vIHRhYmxlIG9mIGNoYXJhY3RlciBzdWJzdGl0dXRpb25zXG4gICAgICAgICAgICBcIlxcYlwiO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tYW55IHNwYWNlcy5cblxuICAgICAgICAgICAgaWYgKHR5cGVvZiBzcGFjZSA9PT0gXCJudW1iZXJcIikge1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBzcGFjZTsgaSArPSAxKSB7XG4gICAgICAgICAgICAgICAgICAgIGluZGVudCArPSBcIiBcIjtcbiAgICAgICAgICAgICAgICB9XG5cbi8vIElmIHRoZSBzcGFjZSBwYXJhbWV0ZXIgaXMgYSBzdHJpbmcsIGl0IHdpbGwgYmUgdXNlZCBhcyB0aGUgaW5kZW50IHN0cmluZy5cblxuICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2Ygc3BhY2UgPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICBpbmRlbnQgPSBzcGFjZTtcbiAgICAgICAgICAgIH1cblxuLy8gSWYgdGhlcmUgaXMgYSByZXBsYWNlciwgaXQgbXVzdCBiZSBhIGZ1bmN0aW9uIG9yIGFuIGFycmF5LlxuLy8gT3RoZXJ3aXNlLCB0aHJvdyBhbiBlcnJvci5cblxuICAgICAgICAgICAgcmVwID0gcmVwbGFjZXI7XG4gICAgICAgICAgICBpZiAocmVwbGFjZXIgJiYgdHlwZW9mIHJlcGxhY2VyICE9PSBcImZ1bmN0aW9uXCIgJiZcbiAgICAgICAgICAgICAgICAgICAgKHR5cGVvZiByZXBsYWNlciAhPT0gXCJvYmplY3RcIiB8fFxuICAgICAgICAgICAgICAgICAgICB0eXBlb2YgcmVwbGFjZXIubGVuZ3RoICE9PSBcIm51bWJlclwiKSkge1xuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcIkpTT04uc3RyaW5naWZ5XCIpO1xuICAgICAgICAgICAgfVxuXG4vLyBNYWtlIGEgZmFrZSByb290IG9iamVjdCBjb250YWluaW5nIG91ciB2YWx1ZSB1bmRlciB0aGUga2V5IG9mIFwiXCIuXG4vLyBSZXR1cm4gdGhlIHJlc3VsdCBvZiBzdHJpbmdpZnlpbmc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1ZSwgaykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ID0gd2Fsayh2YWx1ZSwgayk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYgIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZVtrXSA9IHY7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHZhbHVlW2tdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gcmV2aXZlci5jYWxsKGhvbGRlciwga2V5LCB2YWx1ZSk7XG4gICAgICAgICAgICB9XG5cblxuLy8gUGFyc2luZyBoYXBwZW5zIGluIGZvdXIgc3RhZ2VzLiBJbiB0aGUgZmlyc3Qgc3RhZ2UsIHdlIHJlcGxhY2UgY2VydGFpblxuLy8gVW5pY29kZSBjaGFyYWN0ZXJzIHdpdGggZXNjYXBlIHNlcXVlbmNlcy4gSmF2YVNjcmlwdCBoYW5kbGVzIG1hbnkgY2hhcmFjdGVyc1xuLy8gaW5jb3JyZWN0bHksIGVpdGhlciBzaWxlbnRseSBkZWxldGluZyB0aGVtLCBvciB0cmVhdGluZyB0aGVtIGFzIGxpbmUgZW5kaW5ncy5cblxuICAgICAgICAgICAgdGV4dCA9IFN0cmluZyh0ZXh0KTtcbiAgICAgICAgICAgIHJ4X2Rhbmdlcm91cy5sYXN0SW5kZXggPSAwO1xuICAgICAgICAgICAgaWYgKHJ4X2Rhbmdlcm91cy50ZXN0KHRleHQpKSB7XG4gICAgICAgICAgICAgICAgdGV4dCA9IHRleHQucmVwbGFjZShyeF9kYW5nZXJvdXMsIGZ1bmN0aW9uIChhKSB7XG4gICAgICAgICAg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gICAgICAgIH1cblxuICAgICAgICBsZXQgZW5kcG9pbnQgPSByZGZVdGlscy5nZXRFbmRQb2ludCh5YXNoZSxwcmVmaXgpO1xuICAgICAgICBpZihlbmRwb2ludCE9bnVsbCl7XG4gICAgICAgICAgQVBJX0VORFBPSU5UID0gZW5kcG9pbnQ7XG4gICAgICAgIH1cblxuICAgICAgICBnZXRFbnRpdGllcyhBUElfRU5EUE9JTlQscXVlcnkpXG4gICAgICAgICAgLmRvbmUoKGRhdGEpPT5zZXRIaW50cyhkYXRhLGNhbGxiYWNrKSlcbiAgICAgICAgICAuZmFpbChcbiAgICAgICAgICAgICAgKCk9PmdldEVudGl0aWVzKEFQSV9FTkRQT0lOVC5yZXBsYWNlKCcvdy8nLCcvd2lraS8nKSxxdWVyeSlcbiAgICAgICAgICAgICAgLmRvbmUoKGRhdGEpPT5zZXRIaW50cyhkYXRhLGNhbGxiYWNrKSlcbiAgICAgICAgICApXG4gICAgICAgICAgICBcbiAgICAgICAgXG4gICAgfSxcbiAgICBhc3luYzogdHJ1ZSxcbiAgICBidWxrOiBmYWxzZSxcbiAgICBhdXRvU2hvdzogZmFsc2VcbiAgfTtcbn07XG5cblxudmFyIGdldEVudGl0aWVzID0gZnVuY3Rpb24oZW5kcG9pbnQscXVlcnkpe1xuICByZXR1cm4gJC5nZXQoXG4gICAgICAgICAgICAgIHtcbiAgICAgICAgICBcbiAgICAgICAgICAgICAgdXJsOiBlbmRwb2ludCArICdhcGkucGhwPycgKyAkLnBhcmFtKHF1ZXJ5KSxcbiAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29ucCcsXG4gICAgICAgICAgXG4gICAgICAgICAgICAgIH0pO1xufVxuXG52YXIgc2V0SGludHMgPSBmdW5jdGlvbiggZGF0YSxjYWxsYmFjayApIHtcblxuICB2YXIgbGlzdCA9W11cbiAgXG4gIC8vVGhpcyBjb25kaXRpb24gaXMgZm9yIGFuIGVtcHR5IHNlYXJjaFxuICBpZihkYXRhLmVycm9yKXtc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wgbGluZXMgYXJlIGNvbW1lbnRlZCwgc28gYWRkIGNvbW1lbnRzXG4gICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShcIiNcIiwge1xuICAgICAgICAgIGxpbmU6IGksXG4gICAgICAgICAgY2g6IDBcbiAgICAgICAgfSk7XG4gICAgICB9XG4gICAgfVxuICB9O1xuXG52YXIgY29weUxpbmVVcCA9IGZ1bmN0aW9uKHlhc2hlKSB7XG4gICAgdmFyIGN1cnNvciA9IHlhc2hlLmdldEN1cnNvcigpO1xuICAgIHZhciBsaW5lQ291bnQgPSB5YXNoZS5saW5lQ291bnQoKTtcbiAgICAvLyBGaXJzdCBjcmVhdGUgbmV3IGVtcHR5IGxpbmUgYXQgZW5kIG9mIHRleHRcbiAgICB5YXNoZS5yZXBsYWNlUmFuZ2UoXCJcXG5cIiwge1xuICAgICAgbGluZTogbGluZUNvdW50IC0gMSxcbiAgICAgIGNoOiB5YXNoZS5nZXRMaW5lKGxpbmVDb3VudCAtIDEpLmxlbmd0aFxuICAgIH0pO1xuICAgIC8vIENvcHkgYWxsIGxpbmVzIHRvIHRoZWlyIG5leHQgbGluZVxuICAgIGZvciAodmFyIGkgPSBsaW5lQ291bnQ7IGkgPiBjdXJzb3IubGluZTsgaS0tKSB7XG4gICAgICB2YXIgbGluZSA9IHlhc2hlLmdldExpbmUoaSAtIDEpO1xuICAgICAgeWFzaGUucmVwbGFjZVJhbmdlKFxuICAgICAgICBsaW5lLFxuICAgICAgICB7XG4gICAgICAgICAgbGluZTogaSxcbiAgICAgICAgICBjaDogMFxuICAgICAgICB9LFxuICAgICAgICB7XG4gICAgICAgICAgbGluZTogaSxcbiAgICAgICAgICBjaDogeWFzaGUuZ2V0TGluZShpKS5sZW5ndGhcbiAgICAgICAgfVxuICAgICAgKTtcbiAgICB9XG4gIH07XG5cbnZhciBjb3B5TGluZURvd24gPSBmdW5jdGlvbih5YXNoZSkge1xuICAgIGNvcHlMaW5lVXAoeWFzaGUpO1xuICAgIC8vIE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zW3RdO1xuICAgICAgICAgIC8vY29uc29sZS5sb2cobmV4dClcbiAgICAgICAgICBpZih0b2tlbi5zdHJpbmcuc3BsaXQoJzonKVswXT09J3dkJyAmJiAhdG9rZW4uc2tpcCl7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyh0b2tlbilcbiAgICAgICAgICAgXG4gICAgICAgICAgICAvL2NvbnNvbGUubG9nKHt0b2tlbjp0b2tlbix0OnQsbGVuZ3RoOmxpbmVUb2tlbnMubGVuZ3RoLG5leHQ6bmV4dH0pXG4gICAgICAgICAgICAvL2NvbnNvbGUubG9nKHtsaW5lOmwsY29sOntzdGFydDp0b2tlbi5zdGFydCxlbmQ6dG9rZW4uZW5kfSxzdHJpbmc6dG9rZW4uc3RyaW5nfSlcbiAgICAgICAgICAgXG4gICAgICAgICAgICAgeWFzaGUucmVwbGFjZVJhbmdlKHRva2VuLnN0cmluZytcIiAjaHVtYW4gXFxuXCIse2xpbmU6bCxjaDp0b2tlbi5zdGFydH0se2xpbmU6bCxjaDp0b2tlbi5lbmR9KVxuICAgICAgICAgICAgXG4gICAgICAgICAgICBcblxuICAgICAgICAgICAgXG4gICAgICAgICAgfVxuICAgICAgICAgIFxuICAgICAgICB9XG4gICAgfVxuICB9XG5cbiAgdmFyIGdldE5vbldzTGluZVRva2VucyA9IGZ1bmN0aW9uKGxpbmVUb2tlbnMpe1xuICAgIHJldHVybiBsaW5lVG9rZW5zLnJlZHVjZSgoYWNjLHQpPT57XG4gICAgICBpZih0LnR5cGUhPSd3cycpYWNjLnB1c2godCk7XG4gICAgICByZXR1cm4gYWNjO1xuICAgIH0sW10pO1xuICB9XG5cbiAgdmFyIGdldE5leHROb25XU0xpbmVUb2tlbiA9IGZ1bmN0aW9uKHlhc2hlLGxpbmVUb2tlbnMsbGluZUluZGV4KXtcbiAgICAgIGxldCBpID0gMTtcbiAgICAgIGxldCB0b2tlbiA9IGxpbmVUb2tlbnNbbGluZUluZGV4K2ldO1xuICAgICAgLy9jb25zb2xl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gbGV0IHZhbHVlU2V0ID0gZmFsc2U7XG4gICAgICAgIHJldHVybiB0aGlzLmNvbnN0cmFpbnRzLnJlZHVjZSgoYWNjLHRva2VuLGluZGV4KT0+e1xuICAgICAgICAgICAgbGV0IG5leFRva2VuID0gdGhpcy5jb25zdHJhaW50c1tpbmRleCsxXTtcbiAgICAgICAgICAgIGxldCBzZXBhcmF0b3IgPSBnZXRTZXBhcmF0b3JJZk5lZWRlZChpbmRleCx0b2tlbixuZXhUb2tlbix0aGlzLnRyaXBsZXMubGVuZ3RoLGxvbmdlc3QsdGhpcy5jb25zdHJhaW50cyx0aGlzLmVtcHR5QnJhY2tldHMpO1xuXG4gICAgICAgICAgICBpZih0b2tlbi50eXBlPT1DT01NRU5UX1RZUEUpe1xuXG4gICAgICAgICAgICAgICAgaWYodmFsdWVTZXQpe1xuICAgICAgICAgICAgICAgICAgICBhY2Muc3RyKz0gdG9rZW4uc3RyaW5nO1xuICAgICAgICAgICAgICAgICAgICBhY2Muc3RyICArPSB0aGlzLmdldENsb3NpbmdWYWx1ZVNldElmTmVlZGVkKG5leFRva2VuLHZhbHVlU2V0LGluZGVudCk7XG4gICAgICAgICAgICAgICAgfWVsc2V7XG4gICAgICAgICAgICAgICAgICAgIGZvcmNlU2VwYXJhdG9yID0gdGhpcy5zdGFydHNXaXRoQ29tbWVudChpbmRleCk7Ly9JZiBpdCdzIGEgY29tbWVudCBiZWZvcmUgdGhlIGNvbnN0cmFpbnRzIHNraXAgaXRcbiAgICAgICAgICAgICAgICAgICAgYWNjLnRyaXBsZUNvbW1lbnQrPSB0aGlzLmdldFRyaXBsZUNvbW1lbnQoZm9yY2VTZXBhcmF0b3IsdG9rZW4pOyAvL0lmIG5vdCwgYWRkIGl0IHRvIHRoZSBmaW5pc2ggb2YgdGhlIGxpbmVcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgXG5cbiAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgIC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2V0U3ViVHJpcGxlc1N0cklmTmVlZGVkKGluZGVudCx0cmlwbGVDb21tZW50LGlzVHJpcGxlKTtcbiAgICAgICAgc3RyICs9IHRoaXMuZ2V0RW1wdHlCcmFja2V0c0lmTmVlZGVkKCk7XG4gICAgICAgIHN0ciArPSB0aGlzLmdldEFmdGVyVHJpcGxlc1N0cigpO1xuICAgICAgICBzdHIgKz0gdGhpcy5nZXRTZW1pY29sb25JZk5lZWRlZChpc1RyaXBsZSxpc0xhc3RUcmlwbGUsdHJpcGxlQ29tbWVudCk7XG4gICAgICAgIHN0ciArPSB0aGlzLmdldEZpbmFsUGFyZW50aGVzaXNJZk5lZWRlZCgpO1xuICAgIFxuICAgICAgICByZXR1cm4gc3RyO1xuICAgIH1cblxuXG4gICAgZ2V0U3ViVHJpcGxlc1N0cklmTmVlZGVkKGluZGVudCx0cmlwbGVDb21tZW50LGlzVHJpcGxlKXtcbiAgICAgICAgbGV0IHN0ciA9IEVNUFRZX1NUUklORztcbiAgICAgICAgaWYodGhpcy50cmlwbGVzLmxlbmd0aD4wKXtcbiAgICAgICAgICAgIGxldCBsaW5lYnJlYWsgPSBMSU5FX0JSRUFLO1xuICAgICAgICAgICAgaWYoaXNUcmlwbGUgJiYgdGhpcy50cmlwbGVzLmxlbmd0aD09MSl7XG4gICAgICAgICAgICAgICAgaWYodHJpcGxlQ29tbWVudD09RU1QVFlfU1RSSU5HKXsvLyBJZiB0aGVyZSBpcyBhbnkgY29tbWVudCBhZnRlciAneycgd2UgbmVlZCB0byBmb3JjZSB0aGUgYnJlYWtsaW5lXG4gICAgICAgICAgICAgICAgICAgIGxpbmVicmVhayA9IEVNUFRZX1NUUklORztcbiAgICAgICAgICAgICAgICAgICAgaW5kZW50LS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBcbiAgICAgICAgICAgIHN0cis9dGhpcy5nZXRTdWJUcmlwbGVzU3RyKGluZGVudCx0cmlwbGVDb21tZW50LGxpbmVicmVhayk7ICBc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nMgPSBnZXRUcmlwbGVUb2tlbnMoc2luZ2xlVHJpcGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdWJUcmlwbGVzID0gZ2V0VHJpcGxlcyh0cmlwbGVUb2tlbnMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFmdGVyID0gZ2V0QWZ0ZXJUcmlwbGVUb2tlbnMoc2luZ2xlVHJpcGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb21tZW50ID0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odG9rZW4sdG9rZW5zLGluZGV4KTsgLy9XZSB3YW50IHRoZSB0b2tlbnMgYWZ0ZXIgdGhlIFRyaXBsZVxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVtcHR5QnJhY2tldHMgPSBzdGFydCAmJiBzdWJUcmlwbGVzLmxlbmd0aD09MDtcbiAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChuZXcgTm9kZShiZWZvcmUsc3ViVHJpcGxlcyxjb21tZW50LGVtcHR5QnJhY2tldHMsYWZ0ZXIpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0PWZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBzaW5nbGVUcmlwbGUgPSBbXTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYodG9rZW4uc3RyaW5nPT1PUEVOSU5HX0NVUkxZX0JSQUNLRVQpe1xuICAgICAgICAgICAgICAgIG9wZW4rKztcbiAgICAgICAgICAgICAgICBzdGFydCA9IHRydWU7XG4gICAgICAgICAgICAgICAgZmluaXNoID0gZmFsc2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICBpZih0b2tlbi5zdHJpbmc9PUNMT1NJTkdfQ1VSTFlfQlJBQ0tFVCkgb3Blbi0tO1xuICAgICAgICAgICAgaWYob3Blbj09MCAmJiBzdGFydClmaW5pc2g9dHJ1ZTtcbiAgICAgXG4gICAgICAgICAgICByZXR1cm4gYWNjO1xuICAgICAgICB9LFtdKVxufVxuXG5mdW5jdGlvbiBnZXRBZnRlclRyaXBsZVRva2Vucyh0b2tlbnMpe1xuICAgIGxldCBzdGFydD1mYWxzZTtcbiAgICBsZXQgb3BlbiA9IDA7XG4gICAgcmV0dXJuIHRva2Vucy5yZWR1Y2UoKGFjYyx0KT0+e1xuICAgICAgICBcbiAgICAgICAgaWYob3BlbiA9PSAwICYmIHN0YXJ0KXtcbiAgICAgICAgICAgIGlmKHQuc3RyaW5nICAhPSBTRU1JQ09MT05cbiAgICAgICAgICAgICAmJiB0LnN0cmluZyAhPSBDTE9TSU5HX0NVUkxZX0JSQUNLRVQpYWNjLnB1c2godCk7XG4gICAgICAgIH1cblxuICAgICAgICBpZih0LnN0cmluZz09T1BFTklOR19DVVJMWV9CUkFDS0VUKXtcbiAgICAgICAgICAgIG9wZW4rKztcbiAgICAgICAgICAgIHN0YXJ0PXRydWU7XG4gICAgICAgIH1cblxuICAgICAgICBpZih0LnN0cmluZz09Q0xPU0lOR19DVVJMWV9CUkFDS0VUKXtcbiAgICAgICAgICAgIG9wZW4tLTtcbiAgICAgICAgfVxuXG4gICAgICBcbiAgICAgICAgcmV0dXJuIGFjYztcbiAgICB9LFtdKVxufVxuXG5cbmZ1bmN0aW9uIGdldEJlZm9yZVRyaXBsZXNUb2tlbnModG9rZW5zKXtcbiAgICBsZXQgc3RhcnQ9dHJ1ZTtcbiAgICByZXR1cm4gdG9rZW5zLnJlZHVjZSgoYWNjLHQsaW5kZXgpPT57XG4gICAgICAgIFxuICAgICAgICBpZih0LnN0cmluZz09T1BFTklOR19DVVJMWV9CUkFDS0VUICYmIHN0YXJ0KXsgLy9CcmVhayBjb25kaXRpb24gMVxuICAgICAgICAgICAgLy9XZSB3YW50IHRoZSBjb21tZW50cyBhZnRlciB0aGUgJ3snXG4gICAgICAgICAgICBsZXQgY29tbWVudCA9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ZSh0KSAmJiAhaXNTdGFydCh0LHRva2Vuc1tpbmRleC0xXSkpe1xuICAgICAgICAgICAgc2xvdC5wdXNoKHQpO1xuICAgICAgICB9XG4gICAgICAgXG4gICAgICAgIGlmKGluZGV4ID09IHRva2Vucy5sZW5ndGgtMSl7XG4gICAgICAgICAgICBhY2MucHVzaChzbG90KTtcbiAgICAgICAgfVxuXG4gICAgICAgICByZXR1cm4gYWNjO1xuICAgICB9LFtdKVxufVxuXG5cblxuZnVuY3Rpb24gZ2V0VG9rZW5zKCl7XG4gICAgbGV0IHRva2VucyA9W107XG4gICAgaWYoeWFzaGUhPXVuZGVmaW5lZCl7XG4gICAgICAgIGZvciAodmFyIGwgPSAwOyBsIDwgeWFzaGUubGluZUNvdW50KCk7ICsrbCkge1xuICAgICAgICAgICAgbGV0IGxpbmVUb2tlbnMgPSBnZXROb25Xc1Rva2Vucyh5YXNoZS5nZXRMaW5lVG9rZW5zKGwpKTtcbiAgICAgICAgICAgIGxpbmVUb2tlbnMuZm9yRWFjaCh0b2tlbiA9PntcbiAgICAgICAgICAgICAgICB0b2tlbnMucHVzaCh0b2tlbik7XG4gICAgICAgICAgICB9KVxuXG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHRva2Vucztcbn1cblxuXG4vKipcblNvcnJ5IEFjZWJhbFxuICovXG5mdW5jdGlvbiBnZXREaXJlY3RpdmVzQW5kU3RhcnRzKHRva2Vucyl7XG4gICAgbGV0IHByZWZpeCA9IHt9O1xuICAgIGxldCBiYXNlID0ge307XG4gICAgbGV0IGltcG9ydHQgPSB7fTtcbiAgICBsZXQgcHJlZml4Q29udCA9IDA7XG4gICAgbGV0IGJhc2VDb250ID0gMDtcbiAgICBsZXQgaW1wb3J0Q29udCA9IDA7XG4gICAgbGV0IHN0YXJ0Q29udCA9IDA7XG4gICAgcmV0dXJuIHRva2Vucy5yZWR1Y2UoKGFjYyx0LGluZGV4KT0+e1xuICAgICAgICBpZih0LnN0cmluZy50b1VwcGV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250XT1zdHI7XG4gICAgICAgICAgICBzdGFydENvbnQrKztcbiAgICAgICAgfWVsc2V7ICAgIFxuXG4gICAgICAgICAgICBpZih0LnR5cGUgPT0gUFJFRklYX0FMSUFTX1RZUEUpe1xuICAgICAgICAgICAgICAgIHByZWZpeC5hbGlhcz0gdDtcbiAgICAgICAgICAgICAgICBwcmVmaXguY29tbWVudHMgKz0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odCx0b2tlbnMsaW5kZXgpOyBcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYodC50eXBlID09IFBSRUZJWF9JUklfVFlQRSl7XG4gICAgICAgICAgICAgICAgcHJlZml4LmlyaT0gdDtcbiAgICAgICAgICAgICAgICBwcmVmaXguY29tbWVudHMgKz0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odCx0b2tlbnMsaW5kZXgpOyBcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYodC50eXBlPT1CQVNFX1RZUEUpe1xuICAgICAgICAgICAgICAgIGJhc2UudG9rZW49IHQ7XG4gICAgICAgICAgICAgICAgYmFzZS5jb21tZW50cyArPSBnZXRDb21lbnRzQWZ0ZXJUb2tlbih0LHRva2VucyxpbmRleCk7IFxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZih0LnR5cGU9PUlNUE9SVF9UWVBFKXtcbiAgICAgICAgICAgICAgICBpbXBvcnR0LnRva2VuPSB0O1xuICAgICAgICAgICAgICAgIGltcG9ydHQuY29tbWVudHMgKz0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odCx0b2tlbnMsaW5kZXgpOyBcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYWNjO1xuICAgIH0se1xuICAgICAgICBwcmVmaXhlczpbXSxcbiAgICAgICAgYmFzZXM6W10sXG4gICAgICAgIGltcG9ydHM6W10sXG4gICAgICAgIHN0YXJ0czpbXVxuICAgIH0pXG59XG5cblxuXG4vKipcbiogICBTcGxpdCB0aGUgdG9rZW5zIGludG8gU2hhcGVzXG4qICAgQHBhcmFtIHtBcnJheX0gVG9rZW5zXG4qICAgQHJldHVybiB7QXJyYXl9IERlZmluZWQgU2hhcGVzIChBcnJheSBvZiBUb2tlbidzIGFycmF5cylcbipcbiAqL1xuZnVuY3Rpb24gZ2V0U2hhcGVzVG9rZW5zKHRva2Vucyl7XG4gICAgbGV0IHNoYXBlID0gW11cbiAgICBsZXQgc2hhcGVDb250ID0gMDtcbiAgICBsZXQgaGFzVHJpcGxlU3RhcnRlZCA9IGZhbHNlO1xuICAgIC8vU2VwYXJhdGUgc2hhcGVzIGluIGFycmF5c1xuICAgIHJldHVybiB0b2tlbnMucmVkdWNlKChhY2MsdCk9PntcblxuICAgICAgICBpZih0LnR5cGUgPT0gU0hBUEVfVFlQRSl7XG4gICAgICAgICAgICBzaGFwZSA9IFtdO1xuICAgICAgICAgICAgXG4gICAgICAgICAgICBzaGFwZS5wdXNoKHQpXG4gICAgICAgICAgICBhY2Nbc2hhcGVDb250XT1zaGFwZTtcbiAgICAgICAgICAgIHNoYXBlQ29udCsrO1xuICAgICAgICB9ZWxzZXsgICAgXG4gICAgICAgICAgICBzaGFwZS5wdXNoKHQpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGFjYztcblxuICAgIH0sW10pO1xufVxuXG4vKipcbiogIEdldHMgdGhlIGNvbW1lbnRzIGFmdGVyIGEgdG9rZW5cbiogKi9cbmZ1bmN0aW9uIGdldENvbWVudHNBZnRlclRva2VuKHRva2VuLHRva2VucyxpbmRleCkge1xuICAgIGxldCBpID0xO1xuICAgIGxldCBjb21tZW50ID0gXCJcIjtcbiAgICB3aGlsZSh0b2tlbnNbaW5kZXgraV0gJiYgdG9rZW5zW2luZGV4K2ldLnR5cGU9PUNPTU1FTlRfVFlQRSl7XG4gICAgICAgIGlmKHRva2Vuc1tpbmRleCtpXS5zdGFydCA8IHRva2VuLnN0YXJ0KXtcbiAgICAgICAgICAgIGNvbW1lbn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lwZSA9PSBQUkVGSVhfSVJJX1RZUEVcbiAgICAgICAgfHwgdG9rZW4udHlwZSA9PSBCQVNFX1RZUEVcbiAgICAgICAgfHwgdG9rZW4udHlwZSA9PSBJTVBPUlRfVFlQRSl7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gICAgcmV0dXJuIGZhbHNlO1xufVxuXG5cbmZ1bmN0aW9uIGdldEN1cnNvclBvc2l0aW9uKHlhc2hlKXtcbiAgICBsZXQgY3Vyc29yID0geWFzaGUuZ2V0Q3Vyc29yKCk7XG4gICAgbGV0IGN1cnNvclRva2VuID0geWFzaGUuZ2V0VG9rZW5BdCh7bGluZTpjdXJzb3IubGluZSxjaDpjdXJzb3IuY2h9KVxuICAgIGN1cnNvclRva2VuLmxpbmUgPSBjdXJzb3IubGluZTtcblxuICAgIGxldCBwb3NpdGlvbiA9IDA7XG4gICAgZm9yICh2YXIgbCA9IDA7IGwgPD0gY3Vyc29yLmxpbmU7ICsrbCkge1xuICAgICAgICBsZXQgbGluZVRva2VucyA9IHlhc2hlLmdldExpbmVUb2tlbnMobCk7XG4gICAgICAgIGZvcihsZXQgdCBpbiBsaW5lVG9rZW5zKXtcbiAgICAgICAgICAgIGxldCB0b2tlbiA9IGxpbmVUb2tlbnNbdF07XG4gICAgICAgICAgICBpZih0b2tlbi50eXBlIT1XU19UWVBFKXtcbiAgICAgICAgICAgICAgICBwb3NpdGlvbisrO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZihpc0N1cnNvclRva2VuKHRva2VuLGN1cnNvclRva2VuLGwpKXtcbiAgICAgICAgICAgICAgICByZXR1cm4gcG9zaXRpb247XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgfVxuICAgICByZXR1cm4gcG9zaXRpb247XG59XG5cbmZ1bmN0aW9uIHNldEN1cnNvcih5YXNoZSxwb3NpdGlvbil7XG4gICAgbGV0IGN1cnJlbnRQb3N0aW9uID0wO1xuICAgIGZvciAodmFyIGwgPSAwOyBsIDwgeWFzaGUubGluZUNvdW50KCk7ICsrbCkge1xuICAgICAgICBsZXQgbGluZVRva2VucyA9IHlhc2hlLmdldExpbmVUb2tlbnMobCk7XG4gICAgICAgIGZvcihsZXQgdCBpbiBsaW5lVG9rZW5zKXtcbiAgICAgICAgICAgIGxldCB0b2tlbiA9IGxpbmVUb2tlbnNbdF07XG4gICAgICAgICAgICBpZih0b2tlbi50eXBlIT1XU19UWVBFKWN1cnJlbnRQb3N0aW9uKys7XG4gICAgICAgICAgICBpZihwb3NpdGlvbj09Y3VycmVudFBvc3Rpb24pe1xuICAgICAgICAgICAgICAgIHlhc2hlLnNldEN1cnNvcih7bGluZTpsLGNoOnRva2VuLmVuZH0pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxufVxuXG5mdW5jdGlvbiBpc0N1cnNvclRva2VuKHRva2VuMSx0b2tlbjIsbGluZSl7XG4gICAgcmV0dXJuICB0b2tlbjEuc3RhcnQgPT0gdG9rZW4yLnN0YXJ0IFxuICAgICAgICAgICAgJiYgdG9rZW4xLmVuZCA9PSB0b2tlbjIuZW5kXG4gICAgICAgICAgICAmJiB0b2tlbjEuc3RyaW5nID09IHRva2VuMi5zdHJpbmdcbiAgICAgICAgICAgICYmIHRva2VuMS50eXBlID09IHRva2VuMi50eXBlXG4gICAgICAgICAgICAmJiBsaW5lID09IHRva2VuMi5saW5lO1xufVxuXG5mdW5jdGlvbiBpc1N0YXJ0KHRva2VuLHByZXZpb3VzVG9rZW4pIHtcbiAgICBpZigodG9rZW4uc3RyaW5nLnRvVXBwZXJDYXNlKCk9PVNUQVJUX0tFWVdPUkQgJiYgdG9rZW4udHlwZSA9PSBLRVlXT1JEX1RZUEUpXG4gICAgfHwgKHRva2VuLnN0cmluZz09IEVRVUFMUyAmJiB0b2tlbi50eXBlID09IFBVTkNfVFlQRSlcbiAgICB8fCAodG9rZW4udHlwZSA9PSBTSEF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XG4gICAgICAgIGlmKHRva2VuLnN0cmluZy5pbmNsdWRlcyhcIjpcIikgJiYgIXRva2VuLnN0cmluZy5zdGFydHNXaXRoKFwiPFwiKSl7XG4gICAgICAgICAgICB5YXNoZS51c2VkUHJlZml4ZXMucHVzaCh7XG4gICAgICAgICAgICAgICAgYWxpYXM6dG9rZW4uc3RyaW5nLnNwbGl0KFwiOlwiKVswXSsnOicsXG4gICAgICAgICAgICAgICAgbGluZTpsIH0pO1xuICAgICAgICB9ICBcbiAgICAgIH1cblxuXG4gICAgICBpZih0b2tlbi50eXBlPT0ncHJlZml4RGVsY0FsaWFzJyl7XG4gICAgICAgIHlhc2hlLmRlZlByZWZpeGVzLnB1c2godG9rZW4uc3RyaW5nKTtcbiAgICAgIH1cblxuICAgICAgaWYodG9rZW4udHlwZT09J3NoYXBlJyl7XG4gICAgICAgIHlhc2hlLmRlZlNoYXBlcy5wdXNoKHRva2VuLnN0cmluZyk7XG4gICAgICAgIGlmKCF0b2tlbi5zdHJpbmcuc3RhcnRzV2l0aChcIjxcIikgJiYgIXRva2VuLnN0cmluZy5zdGFydHNXaXRoKFwiXzpcIikpe1xuICAgICAgICAgIHlhc2hlLnVzZWRQcmVmaXhlcy5wdXNoKHtcbiAgICAgICAgICAgIGFsaWFzOnRva2VuLnN0cmluZy5zcGxpdChcIjpcIilbMF0rJzonLFxuICAgICAgICAgICAgbGluZTpsIH0pO1xuICAgICAgICB9ICBcblxuICAgICAgfVxuXG4gICAgICBpZih0b2tlbi50eXBlPT0nc2hhcGVSZWYnKXtcbiAgICAgICAgeWFzaGUuc2hhcGVSZWZzLnB1c2goe1xuICAgICAgICAgICAgcmVmOnRva2VuLnN0cmluZy5zbGljZSgxLHRva2VuLnN0cmluZy5sZW5ndGgpLFxuICAgICAgICAgICAgbGluZTpsIH0pO1xuICAgICAgfVxuXG4gICAgICAvL05lY2VzYXJ5IHdoZW4gdGhlIFNoYXBlUmVmIGlzIFwiQDpcIlxuICAgICAgaWYodG9rZW4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XS52YWx1ZVxuXG4gICAgICB9ZWxzZXtcblxuICAgICAgICAgIGxldCBsYiA9IGNvbnRlbnQubGFiZWxzWydlbiddO1xuICAgICAgICAgIGxldCBkZXNjID0gY29udGVudC5kZXNjcmlwdGlvbnNbJ2VuJ107XG4gICAgICAgICAgaWYobGIpe1xuICAgICAgICAgICAgZW50aXR5ID0gbGIudmFsdWUgKycgKCcrd2lraUVsZW1lbnQrJyknO1xuICAgICAgICAgIH1cbiAgICAgICAgICBpZihkZXNjKXtcbiAgICAgICAgICAgICBkZXNjcmlwdGlvbiA9IGRlc2MudmFsdWVcbiAgICAgICAgICB9XG4gICAgICAgICAgXG4gICAgICB9XG5cbiAgICAgIHRoZW1lID0geWFzaGUuZ2V0T3B0aW9uKCd0aGVtZScpO1xuICAgICAgbGV0IGNzc1N0eWxlID0gdGhlbWVTdHlsZXNbJ2RlZmF1bHQnXTtcbiAgICAgIGlmKHRoZW1lPT0nZGFyaycpe1xuICAgICAgICBjc3NTdHlsZSA9IHRoZW1lU3R5bGVzWydkYXJrJ107XG4gICAgICB9XG5cbiAgICAgIC8vSnF1ZXJ5IGluIDIwMjAgY29vb29vbFxuICAgICAgJCggJzxkaXYgY2xhc3M9XCJDb2RlTWlycm9yIGNtLXMtZGVmYXVsdCBDb2RlTWlycm9yLXdyYXBcIj4nIClcbiAgICAgICAgLmNzcyggJ3Bvc2l0aW9uJywgJ2Fic29sdXRlJyApXG4gICAgICAgIC5jc3MoICd6LWluZGV4JywgJzEyMDAnIClcbiAgICAgICAgLmNzcyggJ21heC13aWR0aCcsICcyMDBweCcgKS5jc3MoIHsgXG4gICAgICAgIHRvcDogcG9zWSArIDIsXG4gICAgICAgIGxlZnQ6IHBvc1ggKyAyXG4gICAgICAgIH0gKVxuICAgICAgICAuYWRkQ2xhc3MoJ3dpa2lkYXRhVG9vbHRpcCcpLmNzcygnaGVpZ2h0JywnYXV0bycpXG4gICAgICAgIC5hcHBlbmQoXG4gICAgICAgICAgJCgnPGRpdiB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VlLCBmYWxzZSk7XHJcbiAgICAgIGlmIChjb25zdW1lZCl7XHJcbiAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgIGNhdDogc3RyZWFtLmN1cnJlbnQoKS50b1VwcGVyQ2FzZSgpLFxyXG4gICAgICAgICAgc3R5bGU6IFwia2V5d29yZFwiLFxyXG4gICAgICAgICAgdGV4dDogY29uc3VtZWRbMF0sXHJcbiAgICAgICAgICBzdGFydDogc3RyZWFtLnN0YXJ0XHJcbiAgICAgICAgfTtcclxuICAgICAgfVxyXG5cclxuICAgICAgLy8gUHVuY3R1YXRpb25cclxuICAgICAgY29uc3VtZWQgPSBzdHJlYW0ubWF0Y2goZ3JhbW1hci5wdW5jdCwgdHJ1ZSwgZmFsc2UpO1xyXG4gICAgICBpZiAoY29uc3VtZWQpe1xyXG4gICAgICAgIGlmKHN0cmVhbS5jdXJyZW50KCkhPScqJyBcclxuICAgICAgICAgICYmIHN0cmVhbS5jdXJyZW50KCkhPScrJ1xyXG4gICAgICAgICAgICYmIHN0cmVhbS5jdXJyZW50KCkhPSc/Jyl7XHJcblxyXG4gICAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgICAgY2F0OiBzdHJlYW0uY3VycmVudCgpLFxyXG4gICAgICAgICAgICBzdHlsZTogXCJwdW5jXCIsXHJcbiAgICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxyXG4gICAgICAgICAgICBzdGFydDogc3RyZWFtLnN0YXJ0XHJcbiAgICAgICAgICB9O1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgcmV0dXJuIHtcclxuICAgICAgICAgIGNhdDogc3RyZWFtLmN1cnJlbnQoKSxcclxuICAgICAgICAgIHN0eWxlOiBcImNhcmRcIixcclxuICAgICAgICAgIHRleHQ6IGNvbnN1bWVkWzBdLFxyXG4gICAgICAgICAgc3RhcnQ6IHN0cmVhbS5zdGFydFxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgXHJcbiAgICAgIH1cclxu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TnMgPSB1bmRlZmluZWQ7XHJcbiAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZiAoc3RhdGUuaW5CYXNlRGVjbCkge1xyXG4gICAgICAgICAgICAgICBpZiAodG9wU3ltYm9sID09PSBcIklSSV9SRUZcIil7XHJcbiAgICAgICAgICAgICAgICAgIHRva2VuT2Iuc3R5bGUgPSAnYmFzZURlY2wnO1xyXG4gICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuXHJcbiAgICAgICAgICAgIGlmIChzdGF0ZS5pbkltcG9ydERlY2wpIHtcclxuICAgICAgICAgICAgICAgaWYgKHRvcFN5bWJvbCA9PT0gXCJJUklfUkVGXCIpe1xyXG4gICAgICAgICAgICAgICAgICB0b2tlbk9iLnN0eWxlID0gJ2ltcG9ydERlY2wnO1xyXG4gICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICBcclxuICAgICAgICAgICBcclxuICAgICAgICAgICAgLy8gTWF0Y2hpbmcgdGVybWluYWxzXHJcbiAgICAgICAgICAgIC8vIC0gY29uc3VtZSB0b2tlbiBmcm9tIGlucHV0IHN0cmVhbVxyXG4gICAgICAgICAgICBmaW5pc2hlZCA9IHRydWU7XHJcbiAgICAgICAgICAgIC8vc2V0UXVlcnlUeXBlKHRvcFN5bWJvbCk7XHJcbiAgICAgICAgICAgIC8vIENoZWNrIHdoZXRoZXIgJCAoZW5kIG9mIGlucHV0IHRva2VuKSBpcyBwb3NzIG5leHRcclxuICAgICAgICAgICAgLy8gZm9yIGV2ZXJ5dGhpbmcgb24gc3RhY2tcclxuICAgICAgICAgICAgdmFyIGFsbE5pbGxhYmxlID0gdHJ1ZTtcclxuICAgICAgICAgICAgZm9yICh2YXIgc3AgPSBzdGF0ZS5zdGFjay5sZW5ndGg7IHNwID4gMDsgLS1zcCkge1xyXG4gICAgICAgICAgICAgIHZhciBpdGVtID0gbGwxX3RhYmxlW3N0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A8IDApIHtcclxuICAgICAgICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcclxuICAgICAgICAgICAgICAgICAgcmVjb3JkRmFpbHVyZVBvcygpO1xyXG4gICAgICAgICAgICAgICAgICBzdGF0ZS5lcnJvck1zZyA9IFwiUHJlZml4ICdcIiArIHByZWZOcyArIFwiJyBpcyBub3QgZGVmaW5lZFwiO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgc3RhdGUuT0sgPSBmYWxzZTtcclxuICAgICAgICAgICAgc3RhdGUuY29tcGxldGUgPSBmYWxzZTtcclxuICAgICAgICAgICAgcmVjb3JkRmFpbHVyZVBvcygpO1xyXG4gICAgICAgICAgfVxyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAvLyB0b3BTeW1ib2wgaXMgbm9udGVybWluYWxcclxuICAgICAgICAgIC8vIC0gc2VlIGlmIHRoZXJlIGlzIGFuIGVudHJ5IGZvciB0b3BTeW1ib2xcclxuICAgICAgICAgIC8vIGFuZCBuZXh0VG9rZW4gaW4gdGFibGVcclxuICAgICAgICAgIFxyXG4gICAgICAgICAgdmFyIG5leHRTeW1ib2xzID0gbGwxX3RhYmxlW3RvcFN5bWJvbF1bdG9rZW5dO1xyXG4gICAgICAgICAgaWYgKG5leHRTeW1ib2xzICE9IHVuZGVmaW5lZCAmJiBjaGVja1NpZGVDb25kaXRpb25zKHRvcFN5bWJvbCkpIHtcclxuICAgICAgICAgICAgLy8gTWF0Y2ggLSBjb3B5IFJIUyBvZiBydWxlIHRvIHN0YWNrXHJcbiAgICAgICAgICAgIGZvciAodmFyIGkgPSBuZXh0U3ltYm9scy5sZW5ndGggLSAxOyBpID49IDA7IC0taSkge1xyXG4gICAgICAgICAgICAgIHN0YXRlLnN0YWNrLnB1c2gobmV4dFN5bWJvbHNbaV0pO1xyXG4gICAg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BpZiBhdCB0b3Agb2Ygc3RhY2tcclxuICAgICAgICB2YXIgZG4gPSBpbmRlbnRUb3Bbc3RhdGUuc3RhY2tbaV1dO1xyXG4gICAgICAgIGlmIChkbikge1xyXG4gICAgICAgICAgbiArPSBkbjtcclxuICAgICAgICAgIC0taTtcclxuICAgICAgICB9XHJcbiAgICAgIH1cclxuICAgICAgZm9yICg7IGkgPj0gMDsgLS1pKSB7XHJcbiAgICAgICAgdmFyIGRuID0gaW5kZW50VGFibGVbc3RhdGUuc3RhY2tbaV1dO1xyXG4gICAgICAgIGlmIChkbikge1xyXG4gICAgICAgICAgbiArPSBkbjtcclxuICAgICAgICB9XHJcbiAgICAgIH1cclxuICAgICAgcmV0dXJuIG4gKiBjb25maWcuaW5kZW50VW5pdDtcclxuICAgIH1cclxuICB9XHJcblxyXG5cclxuICByZXR1cm4ge1xyXG4gICAgdG9rZW46IHRva2VuQmFzZSxcclxuICAgIHN0YXJ0U3RhdGU6IGZ1bmN0aW9uKGJhc2UpIHtcclxuICAgICAgcmV0dXJuIHtcclxuICAgICAgICB0b2tlbml6ZTogdG9rZW5CYXNlLFxyXG4gICAgICAgIE9LOiB0cnVlLFxyXG4gICAgICAgIGNvbXBsZXRlOiBncmFtbWFyLmFjY2VwdEVtcHR5LFxyXG4gICAgICAgIGVycm9yU3RhcnRQb3M6IG51bGwsXHJcbiAgICAgICAgZXJyb3JFbmRQb3M6IG51bGwsXHJcbiAgICAgICAgcXVlcnlUeXBlOiBudWxsLFxyXG4gICAgICAgIHBvc3NpYmxlQ3VycmVudDogZ2V0UG9zc2libGVzKGdyYW1tYXIuc3RhcnRTeW1ib2wpLFxyXG4gICAgICAgIHBvc3NpYmxlTmV4dDogZ2V0UG9zc2libGVzKGdyYW1tYXIuc3RhcnRTeW1ib2wpLFxyXG4gICAgICAgIGFsbG93VmFyczogdHJ1ZSxcclxuICAgICAgICBhbGxvd0Jub2RlczogdHJ1ZSxcclxuICAgICAgICBzdG9yZVByb3BlcnR5OiB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AgICAgICB0aGlzLmxpc3RlbmVyID0gKDAsIF9nb29kTGlzdGVuZXIyLmRlZmF1bHQpKHRyaWdnZXIsICdjbGljaycsIGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIF90aGlzMi5vbkNsaWNrKGUpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVmaW5lcyBhIG5ldyBgQ2xpcGJvYXJkQWN0aW9uYCBvbiBlYWNoIGNsaWNrIGV2ZW50LlxuICAgICAgICAgKiBAcGFyYW0ge0V2ZW50fSBlXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdvbkNsaWNrJyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIG9uQ2xpY2soZSkge1xuICAgICAgICAgICAgdmFyIHRyaWdnZXIgPSBlLmRlbGVnYXRlVGFyZ2V0IHx8IGUuY3VycmVudFRhcmdldDtcblxuICAgICAgICAgICAgaWYgKHRoaXMuY2xpcGJvYXJkQWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24gPSBudWxsO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB0aGlzLmNsaXBib2FyZEFjdGlvbiA9IG5ldyBfY2xpcGJvYXJkQWN0aW9uMi5kZWZhdWx0KHtcbiAgICAgICAgICAgICAgICBhY3Rpb246IHRoaXMuYWN0aW9uKHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIHRhcmdldDogdGhpcy50YXJnZXQodHJpZ2dlciksXG4gICAgICAgICAgICAgICAgdGV4dDogdGhpcy50ZXh0KHRyaWdnZXIpLFxuICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogdGhpcy5jb250YWluZXIsXG4gICAgICAgICAgICAgICAgdHJpZ2dlcjogdHJpZ2dlcixcbiAgICAgICAgICAgICAgICBlbWl0dGVyOiB0aGlzXG4gICAgICAgICAgICB9K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gICAgKi9cblxuICAgIH0sIHtcbiAgICAgICAga2V5OiAnZGVmYXVsdFRleHQnLFxuXG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIERlZmF1bHQgYHRleHRgIGxvb2t1cCBmdW5jdGlvbi5cbiAgICAgICAgICogQHBhcmFtIHtFbGVtZW50fSB0cmlnZ2VyXG4gICAgICAgICAqL1xuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gZGVmYXVsdFRleHQodHJpZ2dlcikge1xuICAgICAgICAgICAgcmV0dXJuIGdldEF0dHJpYnV0ZVZhbHVlKCd0ZXh0JywgdHJpZ2dlcik7XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogRGVzdHJveSBsaWZlY3ljbGUuXG4gICAgICAgICAqL1xuXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdkZXN0cm95JyxcbiAgICAgICAgdmFsdWU6IGZ1bmN0aW9uIGRlc3Ryb3koKSB7XG4gICAgICAgICAgICB0aGlzLmxpc3RlbmVyLmRlc3Ryb3koKTtcblxuICAgICAgICAgICAgaWYgKHRoaXMuY2xpcGJvYXJkQWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jbGlwYm9hcmRBY3Rpb24uZGVzdHJveSgpO1xuICAgICAgICAgICAgICAgIHRoaXMuY2xpcGJvYXJkQWN0aW9uID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1dLCBbe1xuICAgICAgICBrZXk6ICdpc1N1cHBvcnRlZCcsXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBpc1N1cHBvcnRlZCgpIHtcbiAgICAgICAgICAgIHZhciBhY3Rpb24gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IFsnY29weScsICdjdXQnXTtcblxuICAgICAgICAgICAgdmFyIGFjdGlvbnMgPSB0eXBlb2YgYWN0aW9uID09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oaXMuZmFrZUVsZW0pO1xuXG4gICAgICAgICAgICB0aGlzLnNlbGVjdGVkVGV4dCA9ICgwLCBfc2VsZWN0Mi5kZWZhdWx0KSh0aGlzLmZha2VFbGVtKTtcbiAgICAgICAgICAgIHRoaXMuY29weVRleHQoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBPbmx5IHJlbW92ZXMgdGhlIGZha2UgZWxlbWVudCBhZnRlciBhbm90aGVyIGNsaWNrIGV2ZW50LCB0aGF0IHdheVxuICAgICAgICAgKiBhIHVzZXIgY2FuIGhpdCBgQ3RybCtDYCB0byBjb3B5IGJlY2F1c2Ugc2VsZWN0aW9uIHN0aWxsIGV4aXN0cy5cbiAgICAgICAgICovXG5cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ3JlbW92ZUZha2UnLFxuICAgICAgICB2YWx1ZTogZnVuY3Rpb24gcmVtb3ZlRmFrZSgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VIYW5kbGVyKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcignY2xpY2snLCB0aGlzLmZha2VIYW5kbGVyQ2FsbGJhY2spO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXIgPSBudWxsO1xuICAgICAgICAgICAgICAgIHRoaXMuZmFrZUhhbmRsZXJDYWxsYmFjayA9IG51bGw7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmICh0aGlzLmZha2VFbGVtKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIucmVtb3ZlQ2hpbGQodGhpcy5mYWtlRWxlbSk7XG4gICAgICAgICAgICAgICAgdGhpcy5mYWtlRWxlbSA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvKipcbiAgICAgICAgICogU2VsZWN0cyB0aGUgY29udGVudCBmcm9tIGVsZW1lbnQgcGFzc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uXG4gICAgfSwge1xuICAgICAgICBrZXk6ICdkZXN0cm95JyxcblxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBEZXN0cm95IGxpZmVjeWNsZS5cbiAgICAgICAgICovXG4gICAgICAgIHZhbHVlOiBmdW5jdGlvbiBkZXN0cm95KCkge1xuICAgICAgICAgICAgdGhpcy5yZW1vdmVGYWtlKCk7XG4gICAgICAgIH1cbiAgICB9LCB7XG4gICAgICAgIGtleTogJ2FjdGlvbicsXG4gICAgICAgIHNldDogZnVuY3Rpb24gc2V0KCkge1xuICAgICAgICAgICAgdmFyIGFjdGlvbiA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogJ2NvcHknO1xuXG4gICAgICAgICAgICB0aGlzLl9hY3Rpb24gPSBhY3Rpb247XG5cbiAgICAgICAgICAgIGlmICh0aGlzLl9hY3Rpb24gIT09ICdjb3B5JyAmJiB0aGlzLl9hY3Rpb24gIT09ICdjdXQnKSB7XG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdJbnZhbGlkIFwiYWN0aW9uXCIgdmFsdWUsIHVzZSBlaXRoZXIgXCJjb3B5XCIgb3IgXCJjdXRcIicpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgLyoqXG4gICAgICAgICAqIEdldHMgdGhlIGBhY3Rpb25gIHByb3BlcnR5LlxuICAgICAgICAgKiBAcmV0dXJuIHtTdHJpbmd9XG4gICAgICAgICAqL1xuICAgICAgICAsXG4gICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2FjdGlvbjtcbiAgICAgICAgfVxuXG4gICAgICAgIC8qKlxuICAgICAgICAgKiBTZXRzIHRoZSBgdGFyZ2V0YCBwcm9wZXJ0eSB1c2luZyBhbiBlbGVtZW50XG4gICAgICAgICAqIHRoYXQgd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Y2socmVzdWx0KVxuICAgIH1cbiAgfVxuXG4gIGZ1bmN0aW9uIHJlc29sdmVBdXRvSGludHMoY20sIHBvcykge1xuICAgIHZhciBoZWxwZXJzID0gY20uZ2V0SGVscGVycyhwb3MsIFwiaGludFwiKSwgd29yZHNcbiAgICBpZiAoaGVscGVycy5sZW5ndGgpIHtcbiAgICAgIHZhciByZXNvbHZlZCA9IGZ1bmN0aW9uKGNtLCBjYWxsYmFjaywgb3B0aW9ucykge1xuICAgICAgICB2YXIgYXBwID0gYXBwbGljYWJsZUhlbHBlcnMoY20sIGhlbHBlcnMpO1xuICAgICAgICBmdW5jdGlvbiBydW4oaSkge1xuICAgICAgICAgIGlmIChpID09IGFwcC5sZW5ndGgpIHJldHVybiBjYWxsYmFjayhudWxsKVxuICAgICAgICAgIGZldGNoSGludHMoYXBwW2ldLCBjbSwgb3B0aW9ucywgZnVuY3Rpb24ocmVzdWx0KSB7XG4gICAgICAgICAgICBpZiAocmVzdWx0ICYmIHJlc3VsdC5saXN0Lmxlbmd0aCA+IDApIGNhbGxiYWNrKHJlc3VsdClcbiAgICAgICAgICAgIGVsc2UgcnVuKGkgKyAxKVxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgICAgcnVuKDApXG4gICAgICB9XG4gICAgICByZXNvbHZlZC5hc3luYyA9IHRydWVcbiAgICAgIHJlc29sdmVkLnN1cHBvcnRzU2VsZWN0aW9uID0gdHJ1ZVxuICAgICAgcmV0dXJuIHJlc29sdmVkXG4gICAgfSBlbHNlIGlmICh3b3JkcyA9IGNtLmdldEhlbHBlcihjbS5nZXRDdXJzb3IoKSwgXCJoaW50V29yZHNcIikpIHtcbiAgICAgIHJldHVybiBmdW5jdGlvbihjbSkgeyByZXR1cm4gQ29kZU1pcnJvci5oaW50LmZyb21MaXN0KGNtLCB7d29yZHM6IHdvcmRzfSkgfVxuICAgIH0gZWxzZSBpZiAoQ29kZU1pcnJvci5oaW50LmFueXdvcmQpIHtcbiAgICAgIHJldHV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dGlvbnMgKHtmcm9tLCB0bywgbGV2ZWx9XG4gIC8vIG9iamVjdHMpIGluIHRoZSBvcmRlciBpbiB3aGljaCB0aGV5IG9jY3VyIHZpc3VhbGx5LlxuICB2YXIgYmlkaU9yZGVyaW5nID0gKGZ1bmN0aW9uKCkge1xuICAgIC8vIENoYXJhY3RlciB0eXBlcyBmb3IgY29kZXBvaW50cyAwIHRvIDB4ZmZcbiAgICB2YXIgbG93VHlwZXMgPSBcImJiYmJiYmJiYnRzdHdzYmJiYmJiYmJiYmJiYmJzc3N0d05OJSUlTk5OTk5OLE4sTjExMTExMTExMTFOTk5OTk5OTExMTExMTExMTExMTExMTExMTExMTExMTExOTk5OTk5MTExMTExMTExMTExMTExMTExMTExMTExMTE5OTk5iYmJiYmJzYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmIsTiUlJSVOTk5OTE5OTk5OJSUxMU5MTk5OMUxOTk5OTkxMTExMTExMTExMTExMTExMTExMTExMTkxMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExOXCI7XG4gICAgLy8gQ2hhcmFjdGVyIHR5cGVzIGZvciBjb2RlcG9pbnRzIDB4NjAwIHRvIDB4NmY5XG4gICAgdmFyIGFyYWJpY1R5cGVzID0gXCJubm5ubm5OTnIlJXIsck5ObW1tbW1tbW1tbW1ycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJtbW1tbW1tbW1tbW1tbW1tbW1tbW1ubm5ubm5ubm5uJW5ucnJybXJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJycnJybW1tbW1tbW5ObW1tbW1tcnJtbU5tbW1tcnIxMTExMTExMTExXCI7XG4gICAgZnVuY3Rpb24gY2hhclR5cGUoY29kZSkge1xuICAgICAgaWYgKGNvZGUgPD0gMHhmNykgeyByZXR1cm4gbG93VHlwZXMuY2hhckF0KGN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ydCA9IGokMjtcbiAgICAgICAgICAgICAgZm9yICgrK2okMjsgaiQyIDwgaSQ3ICYmIGNvdW50c0FzTnVtLnRlc3QodHlwZXNbaiQyXSk7ICsraiQyKSB7fVxuICAgICAgICAgICAgICBvcmRlci5zcGxpY2UoYXQsIDAsIG5ldyBCaWRpU3BhbigyLCBuc3RhcnQsIGokMikpO1xuICAgICAgICAgICAgICBhdCArPSBpc1JUTDtcbiAgICAgICAgICAgICAgcG9zID0gaiQyO1xuICAgICAgICAgICAgfSBlbHNlIHsgKytqJDI7IH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKHBvcyA8IGkkNykgeyBvcmRlci5zcGxpY2UoYXQsIDAsIG5ldyBCaWRpU3BhbigxLCBwb3MsIGkkNykpOyB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIGlmIChkaXJlY3Rpb24gPT0gXCJsdHJcIikge1xuICAgICAgICBpZiAob3JkZXJbMF0ubGV2ZWwgPT0gMSAmJiAobSA9IHN0ci5tYXRjaCgvXlxccysvKSkpIHtcbiAgICAgICAgICBvcmRlclswXS5mcm9tID0gbVswXS5sZW5ndGg7XG4gICAgICAgICAgb3JkZXIudW5zaGlmdChuZXcgQmlkaVNwYW4oMCwgMCwgbVswXS5sZW5ndGgpKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAobHN0KG9yZGVyKS5sZXZlbCA9PSAxICYmIChtID0gc3RyLm1hdGNoKC9cXHMrJC8pKSkge1xuICAgICAgICAgIGxzdChvcmRlcikudG8gLT0gbVswXS5sZW5ndGg7XG4gICAgICAgICAgb3JkZXIucHVzaChuZXcgQmlkaVNwYW4oMCwgbGVuIC0gbVswXS5sZW5ndGgsIGxlbikpO1xuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBkaXJlY3Rpb24gPT0gXCJydGxcIiA/IG9yZGVyLnJldmVyc2UoKSA6IG9yZGVyXG4gICAgfVxuICB9KSgpO1xuXG4gIC8vIEdldCB0aGUgYml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4gICAgICAgIHZhciBzcGlsbGVkID0gbWUuY2hpbGRyZW4uc3BsaWNlKG1lLmNoaWxkcmVuLmxlbmd0aCAtIDUsIDUpO1xuICAgICAgICB2YXIgc2libGluZyA9IG5ldyBCcmFuY2hDaHVuayhzcGlsbGVkKTtcbiAgICAgICAgaWYgKCFtZS5wYXJlbnQpIHsgLy8gQmVjb21lIHRoZSBwYXJlbnQgbm9kZVxuICAgICAgICAgIHZhciBjb3B5ID0gbmV3IEJyYW5jaENodW5rKG1lLmNoaWxkcmVuKTtcbiAgICAgICAgICBjb3B5LnBhcmVudCA9IG1lO1xuICAgICAgICAgIG1lLmNoaWxkcmVuID0gW2NvcHksIHNpYmxpbmddO1xuICAgICAgICAgIG1lID0gY29weTtcbiAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG1lLnNpemUgLT0gc2libGluZy5zaXplO1xuICAgICAgICAgIG1lLmhlaWdodCAtPSBzaWJsaW5nLmhlaWdodDtcbiAgICAgICAgICB2YXIgbXlJbmRleCA9IGluZGV4T2YobWUucGFyZW50LmNoaWxkcmVuLCBtZSk7XG4gICAgICAgICAgbWUucGFyZW50LmNoaWxkcmVuLnNwbGljZShteUluZGV4ICsgMSwgMCwgc2libGluZyk7XG4gICAgICAgIH1cbiAgICAgICAgc2libGluZy5wYXJlbnQgPSBtZS5wYXJlbnQ7XG4gICAgICB9IHdoaWxlIChtZS5jaGlsZHJlbi5sZW5ndGggPiAxMClcbiAgICAgIG1lLnBhcmVudC5tYXliZVNwaWxsKCk7XG4gICAgfSxcblxuICAgIGl0ZXJOOiBmdW5jdGlvbihhdCwgbiwgb3ApIHtcbiAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgdGhpcy5jaGlsZHJlbi5sZW5ndGg7ICsraSkge1xuICAgICAgICB2YXIgY2hpbGQgPSB0aGlzLmNoaWxkcmVuW2ldLCBzeiA9IGNoaWxkLmNodW5rU2l6ZSgpO1xuICAgICAgICBpZiAoYXQgPCBzeikge1xuICAgICAgIC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IGN1ci5jaCAtIDEpOyB9XG4gICAgICAgICAgaWYgKGN1ci5jaCA+IDApIHtcbiAgICAgICAgICAgIGN1ciA9IG5ldyBQb3MoY3VyLmxpbmUsIGN1ci5jaCArIDEpO1xuICAgICAgICAgICAgY20ucmVwbGFjZVJhbmdlKGxpbmUuY2hhckF0KGN1ci5jaCAtIDEpICsgbGluZS5jaGFyQXQoY3VyLmNoIC0gMiksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgUG9zKGN1ci5saW5lLCBjdXIuY2ggLSAyKSwgY3VyLCBcIit0cmFuc3Bvc2VcIik7XG4gICAgICAgICAgfSBlbHNlIGlmIChjdXIubGluZSA+IGNtLmRvYy5maXJzdCkge1xuICAgICAgICAgICAgdmFyIHByZXYgPSBnZXRMaW5lKGNtLmRvYywgY3VyLmxpbmUgLSAxKS50ZXh0O1xuICAgICAgICAgICAgaWYgKHByZXYpIHtcbiAgICAgICAgICAgICAgY3VyID0gbmV3IFBvcyhjdXIubGluZSwgMSk7XG4gICAgICAgICAgICAgIGNtLnJlcGxhY2VSYW5nZShsaW5lLmNoYXJBdCgwKSArIGNtLmRvYy5saW5lU2VwYXJhdG9yKCkgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jaGFyQXQocHJldi5sZW5ndGggLSAxKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvcyhjdXIubGluZSAtIDEsIHByZXYubGVuZ3RoIC0gMSksIGN1ciwgXCIrdHJhbnNwb3NlXCIpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBuZXdTZWwucHVzaChuZXcgUmFuZ2UoY3VyLCBjdXIpKTtcbiAgICAgIH1cbiAgICAgIGNtLnNldFNlbGVjdGlvbnMobmV3U2VsKTtcbiAgICB9KTsgfSxcbiAgICBuZXdsaW5lQW5kSW5kZW50OiBmdW5jdGlvbiAoY20pIHsgcmV0dXJuIHJ1bkluT3AoY20sIGZ1b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vdGhpbmcgc2hvdWxkIGJlIHNlcmlhbGl6ZWQuIFRoZSB0b0pTT04gbWV0aG9kXG4vLyAgICAgICAgICB3aWxsIGJlIHBhc3NlZCB0aGUga2V5IGFzc29jaWF0ZWQgd2l0aCB0aGUgdmFsdWUsIGFuZCB0aGlzIHdpbGwgYmVcbi8vICAgICAgICAgIGJvdW5kIHRvIHRoZSB2YWx1ZS5cblxuLy8gICAgICAgICAgRm9yIGV4YW1wbGUsIHRoaXMgd291bGQgc2VyaWFsaXplIERhdGVzIGFzIElTTyBzdHJpbmdzLlxuXG4vLyAgICAgICAgICAgICAgRGF0ZS5wcm90b3R5cGUudG9KU09OID0gZnVuY3Rpb24gKGtleSkge1xuLy8gICAgICAgICAgICAgICAgICBmdW5jdGlvbiBmKG4pIHtcbi8vICAgICAgICAgICAgICAgICAgICAgIC8vIEZvcm1hdCBpbnRlZ2VycyB0byBoYXZlIGF0IGxlYXN0IHR3byBkaWdpdHMuXG4vLyAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKG4gPCAxMClcbi8vICAgICAgICAgICAgICAgICAgICAgICAgICA/IFwiMFwiICsgblxuLy8gICAgICAgICAgICAgICAgICAgICAgICAgIDogbjtcbi8vICAgICAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRVVENGdWxsWWVhcigpICAgKyBcIi1cIiArXG4vLyAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ01vbnRoKCkgKyAxKSArIFwiLVwiICtcbi8vICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDRGF0ZSgpKSAgICAgICsgXCJUXCIgK1xuLy8gICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENIb3VycygpKSAgICAgKyBcIjpcIiArXG4vLyAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ01pbnV0ZXMoKSkgICArIFwiOlwiICtcbi8vICAgICAgICAgICAgICAg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WwgdmFsdWUuXG4vLyAgICAgICAgICBJZiBpdCByZXR1cm5zIHdoYXQgaXQgcmVjZWl2ZWQsIHRoZW4gdGhlIHN0cnVjdHVyZSBpcyBub3QgbW9kaWZpZWQuXG4vLyAgICAgICAgICBJZiBpdCByZXR1cm5zIHVuZGVmaW5lZCB0aGVuIHRoZSBtZW1iZXIgaXMgZGVsZXRlZC5cblxuLy8gICAgICAgICAgRXhhbXBsZTpcblxuLy8gICAgICAgICAgLy8gUGFyc2UgdGhlIHRleHQuIFZhbHVlcyB0aGF0IGxvb2sgbGlrZSBJU08gZGF0ZSBzdHJpbmdzIHdpbGxcbi8vICAgICAgICAgIC8vIGJlIGNvbnZlcnRlZCB0byBEYXRlIG9iamVjdHMuXG5cbi8vICAgICAgICAgIG15RGF0YSA9IEpTT04ucGFyc2UodGV4dCwgZnVuY3Rpb24gKGtleSwgdmFsdWUpIHtcbi8vICAgICAgICAgICAgICB2YXIgYTtcbi8vICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSBcInN0cmluZ1wiKSB7XG4vLyAgICAgICAgICAgICAgICAgIGEgPVxuLy8gICAvXihcXGR7NH0pLShcXGR7Mn0pLShcXGR7Mn0pVChcXGR7Mn0pOihcXGR7Mn0pOihcXGR7Mn0oPzpcXC5cXGQqKT8pWiQvLmV4ZWModmFsdWUpO1xuLy8gICAgICAgICAgICAgICAgICBpZiAoYSkge1xuLy8gICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBEYXRlKERhdGUuVVRDKCthWzFdLCArYVsyXSAtIDEsICthWzNdLCArYVs0XSxcbi8vICAgICAgICAgICAgICAgICAgICAgICAgICArYVs1XSwgK2FbNl0pKTtcbi8vICAgICAgICAgICAgICAgICAgfVxuLy8gICAgICAgICAgICAgIH1cbi8vICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7XG4vLyAgICAgICAgICB9KTtcblxuLy8gICAgICAgICAgbXlEYXRhID0gSlNPTi5wYXJzZSgnW1wiRG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ZlxcdWZmZjAtXFx1ZmZmZl0vZztcblxuICAgIGZ1bmN0aW9uIGYobikge1xuICAgICAgICAvLyBGb3JtYXQgaW50ZWdlcnMgdG8gaGF2ZSBhdCBsZWFzdCB0d28gZGlnaXRzLlxuICAgICAgICByZXR1cm4gbiA8IDEwXG4gICAgICAgICAgICA/IFwiMFwiICsgblxuICAgICAgICAgICAgOiBuO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHRoaXNfdmFsdWUoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnZhbHVlT2YoKTtcbiAgICB9XG5cbiAgICBpZiAodHlwZW9mIERhdGUucHJvdG90eXBlLnRvSlNPTiAhPT0gXCJmdW5jdGlvblwiKSB7XG5cbiAgICAgICAgRGF0ZS5wcm90b3R5cGUudG9KU09OID0gZnVuY3Rpb24gKCkge1xuXG4gICAgICAgICAgICByZXR1cm4gaXNGaW5pdGUodGhpcy52YWx1ZU9mKCkpXG4gICAgICAgICAgICAgICAgPyB0aGlzLmdldFVUQ0Z1bGxZZWFyKCkgKyBcIi1cIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTW9udGgoKSArIDEpICsgXCItXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgZih0aGlzLmdldFVUQ0RhdGUoKSkgKyBcIlRcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDSG91cnMoKSkgKyBcIjpcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBmKHRoaXMuZ2V0VVRDTWludXRlcygpKSArIFwiOlwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGYodGhpcy5nZXRVVENTZWNvbmRzKCkpICsgXCJaXCJcbiAgICAgICAgICAgICAgICA6IG51bGw7XG4gICAgICAgIH07XG5cbiAgICAgICAgQm9vbGVhbi5wcm90b3R5cGUudG9KU09OID0gdGhpc192YWx1ZTtcbiAgICAgICAgTnVtYmVyLnByb3RvdHlwZS50b0pTT04g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gICAgICAgICAgIGlmICghdmFsdWUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gXCJudWxsXCI7XG4gICAgICAgICAgICB9XG5cbi8vIE1ha2UgYW4gYXJyYXkgdG8gaG9sZCB0aGUgcGFydGlhbCByZXN1bHRzIG9mIHN0cmluZ2lmeWluZyB0aGlzIG9iamVjdCB2YWx1ZS5cblxuICAgICAgICAgICAgZ2FwICs9IGluZGVudDtcbiAgICAgICAgICAgIHBhcnRpYWwgPSBbXTtcblxuLy8gSXMgdGhlIHZhbHVlIGFuIGFycmF5P1xuXG4gICAgICAgICAgICBpZiAoT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5hcHBseSh2YWx1ZSkgPT09IFwiW29iamVjdCBBcnJheV1cIikge1xuXG4vLyBUaGUgdmFsdWUgaXMgYW4gYXJyYXkuIFN0cmluZ2lmeSBldmVyeSBlbGVtZW50LiBVc2UgbnVsbCBhcyBhIHBsYWNlaG9sZGVyXG4vLyBmb3Igbm9uLUpTT04gdmFsdWVzLlxuXG4gICAgICAgICAgICAgICAgbGVuZ3RoID0gdmFsdWUubGVuZ3RoO1xuICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkgKz0gMSkge1xuICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsW2ldID0gc3RyKGksIHZhbHVlKSB8fCBcIm51bGxcIjtcbiAgICAgICAgICAgICAgICB9XG5cbi8vIEpvaW4gYWxsIG9mIHRoZSBlbGVtZW50cyB0b2dldGhlciwgc2VwYXJhdGVkIHdpdGggY29tbWFzLCBhbmQgd3JhcCB0aGVtIGluXG4vLyBicmFja2V0cy5cblxuICAgICAgICAgICAgICAgIHYgPSBwYXJ0aWFsLmxlbmd0aCA9PT0gMFxuICAgICAgICAgICAgICAgICAgICA/IFwiW11cIlxuICAgICAgICAgICAgICAgICAgICA6IGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgPyBcIltcXG5cIiArIGdhcCArIHBhcnRpYWwuam9pbihcIixcXG5cIiArIGdhcCkgKyBcIlxcblwiICsgbWluZCArIFwiXVwiXG4gICAgICAgICAgICAgICAgICAgICAgICA6IFwiW1wiICsgcGFydGlhbC5qb2luKFwiLFwiKSArIFwiXVwiO1xuICAgICAgICAgICAgICAgIGdhcCA9IG1pbmQ7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgICAgICB9XG5cbi8vIElmIHRoZSByZXBsYWNlciBpcyBhbiBhcnJheSwgdXNlIGl0IHRvIHNlbGVjdCB0aGUgbWVtYmVycyB0byBiZSBzdHJpbmdpZmllZC5cblxuICAgICAgICAgICAgaWYgKHJlcCAmJiB0eXBlb2YgcmVwID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgbGVuZ3RoID0gcmVwLmxlbmd0aDtcbiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXBbaV0gPT09IFwic3RyaW5nXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGsgPSByZXBbaV07XG4gICAgICAgICAgICAgICAgICAgICAgICB2ID0gc3RyKGssIHZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydGlhbC5wdXNoKHF1b3RlKGspICsgKFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnYXBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gXCI6IFwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IFwiOlwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKSArIHYpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcblxuLy8gT3RoZXJ3aXNlLCBpdGVyYXRlIHRocm91Z2ggYWxsIG9mIHRoZSBrZXlzIGluIHRoZSBvYmplY3QuXG5cbiAgICAgICAgICAgICAgICBmb3IgKGsgaW4gdmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbCh2YWx1ZSwgaykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBzdHIoaywgdmFsdWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0aWFsLnB1c2gocXVvdGUoaykgKyAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdhcFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBcIjogXCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogXCI6XCJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICApICsgdik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbi8vIEpvaW4gYWxsIG9mIHRoZSBtZW1iZXIgdGV4dHMgdG9nZXRoZXIsIHNlcGFyYXRlZCB3aXRoIGNvbW1hcyxcbi8vIGFuZCB3cmFwIHRoZW0gaW4gYnJhY2VzLlxuXG4gICAgICAgICAgICB2ID0gcGFydGlhbC5sZW5ndGggPT09IDBcbiAgICAgICAgICAgICAgICA/IFwie31cIlxuICAgICAgICAgICAgICAgIDogZ2FwXG4gICAgICAgICAgICAgICAgICAgID8gXCJ7XFxuXCIgKyBnYXAgKyBwYXJ0aWFsLmpvaW4oXCIsXFxuXCIgKyBnYXApICsgXCJcXG5cIiArIG1pbmQgKyBcIn1cIlxuICAgICAgICAgICAgICAgICAgICA6IFwie1wiICsgcGFydGlhbC5qb2luKFwiLFwiK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SBzb1xuLy8gdGhhdCBtb2RpZmljYXRpb25zIGNhbiBiZSBtYWRlLlxuXG4gICAgICAgICAgICAgICAgdmFyIGs7XG4gICAgICAgICAgICAgICAgdmFyIHY7XG4gICAgICAgICAgICAgICAgdmFyIHZhbHVlID0gaG9sZGVyW2tleV07XG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlICYmIHR5cGVvZiB2YWx1ZSA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGsgaW4gdmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwodmFsdWUsIGspKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdiA9IHdhbGsodmFsdWUsIGspO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVba10gPSB2O1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB2YWx1ZVtrXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJldml2ZXIuY2FsbChob2xkZXIsIGtleSwgdmFsdWUpO1xuICAgICAgICAgICAgfVxuXG5cbi8vIFBhcnNpbmcgaGFwcGVucyBpbiBmb3VyIHN0YWdlcy4gSW4gdGhlIGZpcnN0IHN0YWdlLCB3ZSByZXBsYWNlIGNlcnRhaW5cbi8vIFVuaWNvZGUgY2hhcmFjdGVycyB3aXRoIGVzY2FwZSBzZXF1ZW5jZXMuIEphdmFTY3JpcHQgaGFuZGxlcyBtYW55IGNoYXJhY3Rl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HZhciBoaW50Q29uZmlnID0ge1xyXG4gICAgICAgIGNsb3NlQ2hhcmFjdGVyczogLyg/PWEpYi8sXHJcbiAgICAgICAgY29tcGxldGVTaW5nbGU6IGZhbHNlXHJcbiAgICAgIH07XHJcbiAgICAgIGlmICghY29tcGxldGVyLmJ1bGsgJiYgY29tcGxldGVyLmFzeW5jKSB7XHJcbiAgICAgICAgaGludENvbmZpZy5hc3luYyA9IHRydWU7XHJcbiAgICAgIH1cclxuICAgICAgdmFyIHdyYXBwZWRIaW50Q2FsbGJhY2sgPSBmdW5jdGlvbih5YXNoZSwgY2FsbGJhY2spIHtcclxuICAgICAgICByZXR1cm4gZ2V0Q29tcGxldGlvbkhpbnRzT2JqZWN0KGNvbXBsZXRlciwgY2FsbGJhY2spO1xyXG4gICAgICB9O1xyXG4gICAgICBcclxuXHJcbiAgICAgIHZhciByZXN1bHQgPSBZQVNIRS5zaG93SGludCh5YXNoZSwgd3JhcHBlZEhpbnRDYWxsYmFjaywgaGludENvbmZpZyk7XHJcbiAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgfTtcclxuICAgIGZvciAodmFyIGNvbXBsZXRlck5hbWUgaW4gY29tcGxldGVycykge1xyXG4gICAgICBpZiAoJC5pbkFycmF5KGNvbXBsZXRlck5hbWUsIHlhc2hlLm9wdGlvbnMuYXV0b2NvbXBsZXRlcnMpID09IC0xKSBjb250aW51ZTsgLy90aGlzIGNvbXBsZXRlciBpcyBkaXNhYmxlZFxyXG4gICAgICB2YXIgY29tcGxldGVyID0gY29tcGxldGVyc1tjb21wbGV0ZXJOYW1lXTtcclxuICAgICAgaWYgKCFjb21wbGV0ZXIuaXNWYWxpZENvbXBsZXRpb25Qb3NpdGlvbikgY29udGludWU7IC8vbm8gd2F5IHRvIGNoZWNrIHdoZXRoZXIgd2UgYXJlIGluIGEgdmFsaWQgcG9zaXRpb25cclxuXHJcbiAgICAgIGlmICghY29tcGxldGVyLmlzVmFsaWRDb21wbGV0aW9uUG9zaXRpb24o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UElfRU5EUE9JTlQscXVlcnkpXHJcbiAgICAgICAgICAuZG9uZSgoZGF0YSk9PnNldEhpbnRzKGRhdGEsY2FsbGJhY2spKVxyXG4gICAgICAgICAgLmZhaWwoIC8vSSBoYWQgdG8gZG8gdGhpcyBmb3Igb25lIHdpa2liYXNlIGluc3RhbmNlIEkgZG9uJ3Qga25vdyB3aHkuLi5cclxuICAgICAgICAgICAgICAoKT0+Z2V0RW50aXRpZXMoQVBJX0VORFBPSU5ULnJlcGxhY2UoJy93LycsJy93aWtpLycpLHF1ZXJ5KVxyXG4gICAgICAgICAgICAgIC5kb25lKChkYXRhKT0+c2V0SGludHMoZGF0YSxjYWxsYmFjaykpXHJcbiAgICAgICAgICApXHJcbiAgICAgICAgICAgIFxyXG4gICAgICAgIFxyXG4gICAgfSxcclxuICAgIGFzeW5jOiB0cnVlLFxyXG4gICAgYnVsazogZmFsc2UsXHJcbiAgICBhdXRvU2hvdzogZmFsc2UsXHJcbiAgICBjYWxsYmFja3M6IHtcclxuICAgICAgdmFsaWRQb3NpdGlvbjogeWFzaGUuYXV0b2NvbXBsZXRlcnMubm90aWZpY2F0aW9ucy5zaG93LFxyXG4gICAgICBpbnZhbGlkUG9zaXRpb246IHlhc2hlLmF1dG9jb21wbGV0ZXJzLm5vdGlmaWNhdGlvbnMuaGlkZVxyXG4gICAgfVxyXG4gIH07XHJcbn07XHJcblxyXG5cclxudmFyIGdldEVudGl0aWVzID0gZnVuY3Rpb24oZW5kcG9pbnQscXVlcnkpe1xyXG4gIHJldHVybiAkLmdldChcclxuICAgICAgICAgICAgICB7XHJcbiAgICAgICAgICBcclxuICAgICAgICAgICAgICB1cmw6IGVuZHBvaW50ICsgJ2FwaS5waHA/JyArICQucGFyYW0ocXVlcnkpLFxyXG4gICAgICAgICAgICAgIGRhdGFUeXBlOiAnanNvbnAnLFxyXG4gICAgICAgICAgXHJcbiAgICAgICAgICAgICAgfSk7XHJcbn1cclxuXHJcbnZhciBzZXRIaW50cyA9IGZ1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gLy8gRmlyZWZveCByZXF1aXJlcyB0aGUgbGluayB0byBiZSBhZGRlZCB0byB0aGUgRE9NIGJlZm9yZSBpdCBjYW4gYmUgY2xpY2tlZC5cclxuICAgICAgICAgICAgICBkb3dubG9hZExpbmsuaHJlZiA9IHdpbmRvdy5VUkwuY3JlYXRlT2JqZWN0VVJMKHRleHRGaWxlQXNCbG9iKTtcclxuICAgICAgICAgICAgICBkb3dubG9hZExpbmsub25jbGljayA9IGRlc3Ryb3lDbGlja2VkRWxlbWVudDtcclxuICAgICAgICAgICAgICBkb3dubG9hZExpbmsuc3R5bGUuZGlzcGxheSA9IFwibm9uZVwiO1xyXG4gICAgICAgICAgICAgIGRvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQoZG93bmxvYWRMaW5rKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICBkb3dubG9hZExpbmsuY2xpY2soKTtcclxuICAgICAgICAgICAgQ29kZW1pcnJvci5zaWduYWwoeWFzaGUsJ2Rvd25sb2FkJyk7XHJcbiAgICAgICAgICB9KVxyXG4gICAgICApO1xyXG4gICAgXHJcblxyXG4gICAgdmFyIGNvcHlCdXR0b24gPSAkKFwiPGRpdj5cIiwge1xyXG4gICAgICBjbGFzczogXCJkb3dubG9hZEJ0bnNcIlxyXG4gICAgfSlcclxuICAgICAgLmFwcGVuZChcclxuICAgICAgICAkKHl1dGlscy5zdmcuZ2V0RWxlbWVudChpbWdzLmNvcHkpKVxyXG4gICAgICAgICAgLmFkZENsYXNzKFwieWFzaGVfZG93bmxvYWRCdG5cIilcclxuICAgICAgICAgIC5hdHRyKFwiaWRcIiwgXCJjb3B5QnRuXCIpXHJcbiAgICAgICAgICAuYXR0cihcInRpdGxlXCIsIFwiQ29weSB0byB0aGUgY2xpcGJvYXJkXCIpXHJcbiAgICAgICAgICAuY2xpY2soZnVuY3Rpb24oKSB7IFxyXG4gICAgICAgICAgICAgIENvZGVtaXJyb3Iuc2lnbmFsKHlhc2hlLCdjb3B5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zaGUucmVwbGFjZVJhbmdlKFxyXG4gICAgICAgICAgXCJcIixcclxuICAgICAgICAgIHtcclxuICAgICAgICAgICAgbGluZTogaSxcclxuICAgICAgICAgICAgY2g6IDBcclxuICAgICAgICAgIH0sXHJcbiAgICAgICAgICB7XHJcbiAgICAgICAgICAgIGxpbmU6IGksXHJcbiAgICAgICAgICAgIGNoOiAxXHJcbiAgICAgICAgICB9XHJcbiAgICAgICAgKTtcclxuICAgICAgfSBlbHNlIHtcclxuICAgICAgICAvLyBOb3QgYWxsIGxpbmVzIGFyZSBjb21tZW50ZWQsIHNvIGFkZCBjb21tZW50c1xyXG4gICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShcIiNcIiwge1xyXG4gICAgICAgICAgbGluZTogaSxcclxuICAgICAgICAgIGNoOiAwXHJcbiAgICAgICAgfSk7XHJcbiAgICAgIH1cclxuICAgIH1cclxuICB9O1xyXG5cclxudmFyIGNvcHlMaW5lVXAgPSBmdW5jdGlvbih5YXNoZSkge1xyXG4gICAgdmFyIGN1cnNvciA9IHlhc2hlLmdldEN1cnNvcigpO1xyXG4gICAgdmFyIGxpbmVDb3VudCA9IHlhc2hlLmxpbmVDb3VudCgpO1xyXG4gICAgLy8gRmlyc3QgY3JlYXRlIG5ldyBlbXB0eSBsaW5lIGF0IGVuZCBvZiB0ZXh0XHJcbiAgICB5YXNoZS5yZXBsYWNlUmFuZ2UoXCJcXG5cIiwge1xyXG4gICAgICBsaW5lOiBsaW5lQ291bnQgLSAxLFxyXG4gICAgICBjaDogeWFzaGUuZ2V0TGluZShsaW5lQ291bnQgLSAxKS5sZW5ndGhcclxuICAgIH0pO1xyXG4gICAgLy8gQ29weSBhbGwgbGluZXMgdG8gdGhlaXIgbmV4dCBsaW5lXHJcbiAgICBmb3IgKHZhciBpID0gbGluZUNvdW50OyBpID4gY3Vyc29yLmxpbmU7IGktLSkge1xyXG4gICAgICB2YXIgbGluZSA9IHlhc2hlLmdldExpbmUoaSAtIDEpO1xyXG4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VybjtcclxuICAgICAgICAgIH1cclxuICAgICAgICAgIGxldCB0b2tlbiA9IGxpbmVUb2tlbnNbdF07XHJcbiAgICAgICAgICBpZih3aWtpVXRpbHMuaXNXaWtpZGF0YVByZWZpeCh5YXNoZSx0b2tlbikpe1xyXG4gICAgICAgICAgICBsZXQgZW50aXR5ID0gdG9rZW4uc3RyaW5nLnNwbGl0KCc6JylbMV0udG9VcHBlckNhc2UoKTtcclxuICAgICAgICAgICAgbGV0IHJlc3VsdCA9IGF3YWl0IHdpa2lVdGlscy5nZXRFbnRpdHkoZW50aXR5LHdpa2lVdGlscy53aWtpZGF0YUVuZHBvaW50KTtcclxuICAgICAgICAgICAgaWYocmVzdWx0LmVudGl0aWVzKXtcclxuICAgICAgICAgICAgICBsZXQgZW50aXR5RGF0YSA9IHdpa2lVdGlscy5nZXRFbnRpdHlEYXRhKGVudGl0eSxyZXN1bHQpO1xyXG4gICAgICAgICAgICAgIGlmKGVudGl0eURhdGEpe1xyXG4gICAgICAgICAgICAgICAgY29tbWVudHMgKz0gJyAnK2VudGl0eURhdGEudGl0bGU7XHJcbiAgICAgICAgICAgICAgICB2YWx1ZVNldFNpemUtLTtcclxuICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgIH1cclxuICAgICAgICAgIFxyXG4gICAgICAgICAgaWYoaXNMYXN0VG9rZW4odCxsaW5lVG9rZW5zKSAmJiBjb21tZW50cyE9JyAjICcpeyBcclxuICAgICAgICAgICAgbGV0IGVuZE9mTGluZSA9IGxpbmVUb2tlbnNbbGluZVRva2Vucy5sZW5ndGgtMV0uZW5kXHJcbiAgICAgICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShjb21tZW50cyx7bGluZTpsLGNoOmVuZE9mTGluZX0se2xpbmU6bCxjaDplbmRPZkxpbmV9KVxyXG4gICAgICAgICAgICBpZih5YXNoZS5oYXNFcnJvcnMoeWFzaGUpKXlhc2hlLnVuZG8oKTsgXHJcbiAgICAgICAg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md0aCxsb25nZXN0LGNvbnN0cmFpbnRzLHRoaXMuZW1wdHlCcmFja2V0cyk7XHJcblxyXG4gICAgICAgICAgICBpZih0b2tlbi50eXBlPT1DT01NRU5UX1RZUEUpe1xyXG4gICAgICAgICAgICAgICAvL2NvbnNvbGUubG9nKHtwcmV2aW91c1Rva2VuOnByZXZpb3VzVG9rZW4uc3RyaW5nLHRva2VuOnRva2VuLnN0cmluZyxuZXhUb2tlbjpuZXhUb2tlbn0pXHJcbiAgICAgICAgICAgICAgICBpZihwcmV2aW91c1Rva2VuICYmIHByZXZpb3VzVG9rZW4uc3RyaW5nPT0nWycgJiYgdmFsdWVTZXRTaXplPjIpe1xyXG4gICAgICAgICAgICAgICAgICAgIGFjYy5zdHIrPSB0b2tlbi5zdHJpbmc7XHJcbiAgICAgICAgICAgICAgICB9ZWxzZSBpZihuZXhUb2tlbiAmJiBuZXhUb2tlbi5zdHJpbmc9PSdbJyAmJiB2YWx1ZVNldFNpemU+Mil7XHJcbiAgICAgICAgICAgICAgICAgICAgYWNjLnN0cis9ICdbICcrdG9rZW4uc3RyaW5nO1xyXG4gICAgICAgICAgICAgICAgICAgIG5leFRva2VuLnNraXAgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgfWVsc2UgaWYodmFsdWVTZXQpe1xyXG4gICAgICAgICAgICAgXHJcbiAgICAgICAgICAgICAgICAgICAgYWNjLnN0cis9IHRva2VuLnN0cmluZztcclxuICAgICAgICAgICAgICAgICAgICBhY2Muc3RyKz0gdGhpcy5nZXRDbG9zaW5nVmFsdWVTZXRJZk5lZWRlZChuZXhUb2tlbix2YWx1ZVNldCxpbmRlbnQpO1xyXG4gICAgICAgICAgICAgICAgfWVsc2V7XHJcbiAgICAgICAgICAgICAgICAgICAgZm9yY2VTZXBhcmF0b3IgPSB0aGlzLnN0YXJ0c1dpdGhDb21tZW50KGluZGV4KTsvL0lmIGl0J3MgYSBjb21tZW50IGJlZm9yZSB0aGUgY29uc3RyYWludHMgc2tpcCBpdFxyXG4gICAgICAgICAgICAgICAgICAgIGFjYy50cmlwbGVDb21tZW50ID0gdGhpcy5nZXRUcmlwbGVDb21tZW50KGZvcmNlU2VwYXJhdG9yLHRva2VuKSArIGFjYy50cmlwbGVDb21tZW50IDsgLy9JZiBub3QsIGFkZCBpdCB0byB0aGUgZmluaXNoIG9mIHRoZSBsaW5lXHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBcclxuICAgICAgICAgICAgICAgIFxyXG5cclxuICAgICAgICAgICAgfWVsc2V7XHJcbiAgICAgICAgICAgICAgICBcclxuICAgICAgICAgICAgICAgIGluZGV4ICAgICA9IHRoaXMuZGVjcmVtZW50SW5kZXhJZk5lZWRlZChmb3JjZVNlcGFyYXRvcik7XHJcbiAgICAgICAgICAgICAgICBzZXBhcmF0b3IgPSB0aGlzLm1vZGlmeVNlcGFyYXRvcklmTmVlZGVkKHNlcGFyYXRvcixuZXhUb2tlbix2YWx1ZVNldFNpemUpO1xyXG4gICAgICAgICAgICAgICAgdmFsdWVTZXQgID0gdGhpcy5pc1ZhbHVlU2V0KHRva2VuLHZhbHVlU2V0U2l6ZSk7XHJcbiAgICAgICAgICAgICAgICBhY2Muc3RyICArPSB0aGlzLmdldE9wZW5pbmdWYWx1ZVNldElmTmVlZGVkKHZhbHVlU2V0LGluZGVudCxuZXhUb2tlbik7XHJcbiAgICAgICAgICAgICAgICBhY2Muc3RyICArPSB0aGlzLmdldFdoaXRlU3BhY2VJZk5lZWRlZCh0b2tlbik7XHJcbiAgICAgICAgICAgICAgICBhY2Muc3RyICArPSB0aGlzLmdldFRva2VuU3RyaW5nKHRva2VuLHNlcGFyYXRvcik7XHJcbiAgICAgICAgICAgICAgICBhY2Muc3RyICArPSB0aGlzLmdldENsb3NpbmdWYWx1ZVNldElmTmVlZGVkKG5leFRva2VuLHZhbHVlU2V0LGluZGVudCk7XHJcbiAgICAgICAgICAgICAgICBcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICA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5FX0JSRUFLO1xyXG4gICAgICAgICAgICAvLyBUaGlzIGlzIG9mZiBhdCB0aGlzIG1vbWVudFxyXG4gICAgICAgICAgICAvKiBpZihpc1RyaXBsZSl7XHJcbiAgICAgICAgICAgICAgICBpZih0aGlzLnRyaXBsZXMubGVuZ3RoPT0xKSB7IFxyXG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdwJylcclxuICAgICAgICAgICAgICAgICAgICAvLyBJZiB0aGVyZSBpc24ndCBhbnkgY29tbWVudCBhZnRlciAneycgZG9uJ3QgZm9yY2UgdGhlIGJyZWFrbGluZVxyXG4gICAgICAgICAgICAgICAgICAgIGlmKHRyaXBsZUNvbW1lbnQ9PUVNUFRZX1NUUklORyAmJiAhdGhpcy5oYXNDb21tZW50cyh0aGlzLnRyaXBsZXNbMF0pKXtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGluZWJyZWFrID0gRU1QVFlfU1RSSU5HO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmRlbnQtLTtcclxuICAgICAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0gKi9cclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIHN0cis9dGhpcy5nZXRTdWJUcmlwbGVzU3RyKGluZGVudCx0cmlwbGVDb21tZW50LGxpbmVicmVhayk7ICBcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHN0cjtcclxuICAgIH1cclxuXHJcblxyXG4gICAgZ2V0U3ViVHJpcGxlc1N0cihpbmRlbnQsdHJpcGxlQ29tbWVudCxsaW5lYnJlYWspe1xyXG4gICAgICAgIHRoaXMuaGFzQWxlYXJkeUFDb21tZW50PXRydWU7XHJcbiAgICAgICAgbGV0IHN0cj1PUEVOSU5HX0NVUkxZX0JSQUNLRVQrdHJpcGxlQ29tbWVudCtsaW5lYnJlYWs7XHJcbiAgICAgICAgaWYodHJpcGxlQ29tbWVudCE9JycpdHJpcGxlQ29tbWVudD0nJztcclxuICAgICAgICB0aGlzLnRyaXBsZXMubWFwKCh0LGluZGV4KT0+e1xyXG4gICAgICAgICAgICBsZXQgY3VycmVudExvbmdlc3QgPSBnZXRMb25nZXN0VENvbnN0cmFpbnQodGhpcy50cmlwbGVzKTtcclxuICAgICAgICAgICAgc3RyKz0gZ2V0SW5kZW50KGluZGVudCk7XHJcbiAgICAgICAgICAgIHN0cis9IHQudG9TdHJpbmcoY3VycmVudExvbmdlc3QsdHJ1ZSxpbmRlbnQrMSx0aGlzLmlzTGFzdFRyaXBsZShpbmRleCkpO1xyXG4gICAgICAgICAgICBzdHIrPSBXSElURV9TUEFDRSArIHQuY29tbWVudCArbGluZWJyZWFrO1xyXG4gICAgICAgIH0pXHJcbiAgICAgICAgcmV0dXJuIHN0ciArIGdldEluZGVudChpbmRlbnQtMSkrQ0xPU0lOR19DVVJMWV9CUkFDS0VUO1xyXG4gICAgfVxyXG5cclxuXHJcbiAgICBnZXRBZnRlclRyaXBsZXNTdHIoaW5kZW50KXtcclxuICAgICAgICBsZXQgc3RyID0gRU1QVFlfU1RSSU5HO1xyXG4gICAgICAgIGlmKHRoaXMuYWZ0ZXJUcmlwbGVzLmxlbmd0aD4wKXtcclxuICAgICAgICAgICAgc3RyKz1XSElURV9TUEFDRTtcclxuICAgICAgICB9ZWxzZXtcclxuICAgICAgICAgICAgcmV0dXJuICcnO1xyXG4gICAgICAgIH1cclxuICAgICAgICBsZXQgY29uc3RyYWludHMgPSB0aGlzLmdldENvbnN0cmFpbnRzKHRoaXMuYWZ0ZXJUcmlwbGVzLDAsaW5kZW50KTtcclxuICAgICAgICByZXR1cm4gY29uc3RyYWludHMuc3RyK2NvbnN0cmFpbnRzLnRyaXBsZUNvbW1lbnQ7XHJcbiAgICB9XHJcblxyXG5cclxuXHJcbiAgICBnZXRTZW1pY29sb25JZk5lZWRlZChpc1RyaXBsZSxpc0xhc3RUcmlwbGUsdHJpcGxlQ29tbWVudCl7XHJcbiAgICAgICAgbGV0IHN0ciA9IEVNUFRZX1NUUklORztcclxuICAgICAgICBpZihpc1RyaXBsZSl7XHJcbiAgICAgICAgICAgIGlmKCFpc0xhc3RUcmlwbGUpe1xyXG4gICAgICAgICAgICAgICAgaWYoIXRoaXMubXVsdGlFbGVtZW50T25lT2Ypc3RyKz1TRU1JQ09MT047XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgaWYoIXRoaXMuaGFzQWxlYXJkeUFDb21tZW50KXN0cis9dHJpcGxlQ29tbWVudDtcclxuICAgICAgICB9XHJcbiAgICAgICAgcmV0dXJuIHN0cjtcclxuICAgIH1cclxuXHJcbiAgICBnZXRFbXB0eUJyYWNrZXRzSWZOZWVkZWQoKXtcclxuICAgICAgICBpZih0aGlzLmVtcHR5QnJhY2tldHMgJiYgdGhpcy50cmlwbGVzLmxlbmd0aDw9MClcclxuICAgICAgICAgICAgcmV0dXJuIEVNUFRZX0JSQUNLRVRTO1xyXG4gICAgICAgIHJldHVybiBFTVBUWV9TVFJJTkc7XHJcbiAgICB9XHJcblxyXG4gICAgZ2V0RmluYWxQYXJlbnRoZXNpc0lmTmVlZGVkKCl7XHJcbiAgICAgICAgaWYodGhpcy5maW5hbFBhcmVudGhlc2lzKVxyXG4gICAgICAgICAgICByZXR1cm4gQ0xPU0lOR19QQVJFTlRIRVNJUztcclxuICAgICAgICByZXR1cm4gRU1QVFlfU1RSSU5HO1xyXG4gICAgfVxyXG5cclxuICAgIGlzTGFzdFRyaXBsZShpbmRleCl7XHJcbiAgICAgICAgcmV0dXJuIGluZGV4PT10aGlzLnRyaXBsZXMubGVuZ3RoLTE7XHJcbiAgICB9XHJcblxyXG4gICAgc3RhcnRzV2l0aENvbW1lbnQoaW5kZXgpe1xyXG4gICAgICAgIHJldHVybiBpbmRleD09MDtcclxuICAgIH1cclxuXHJcbiAgICBnZXRUcmlwbGVDb21tZW50KGZvcmNlU2VwYXJhdG9yLHRva2VuKXtcclxuICAgICAgICAvL09ubHkgaWYgd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gICAgIGlmKHRva2VuLnNraXApIHJldHVybiBhY2M7IC8vSXMgYSBjb21tZW50IHRoYXQgaXMgcGFydCBvZiB0aGUgcHJldmlvdXMgdHJpcGxlXHJcbiAgICAgICAgICAgIHNpbmdsZVRyaXBsZS5wdXNoKHRva2VuKTsgICAgIFxyXG4gICAgICAgICAgICBsZXQgbXVsdGlFbGVtZW50T25lT2YgPSBpc011bHRpRWxlbWVudE9uZU9mKHRva2VuKTtcclxuICAgICAgICAgICAgaWYoaXNGaW5pc2hPZlRyaXBsZSh0b2tlbnMsdG9rZW4saW5kZXgsZmluaXNoKSB8fCBtdWx0aUVsZW1lbnRPbmVPZil7XHJcbiAgICAgICAgICAgICAgICBpZihzaW5nbGVUcmlwbGUubGVuZ3RoPjEpe1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKHNpbmdsZVRyaXBsZSlcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJlZm9yZSA9IGdldEJlZm9yZVRyaXBsZXNUb2tlbnMoc2luZ2xlVHJpcGxlKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaXBsZVRva2VucyA9IGdldFRyaXBsZVRva2VucyhzaW5nbGVUcmlwbGUpO1xyXG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3ViVHJpcGxlcyA9IGdldFRyaXBsZXModHJpcGxlVG9rZW5zKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFmdGVyID0gZ2V0QWZ0ZXJUcmlwbGVUb2tlbnMoc2luZ2xlVHJpcGxlLG11bHRpRWxlbWVudE9uZU9mKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbW1lbnQgPSBnZXRDb21lbnRzQWZ0ZXJUb2tlbih0b2tlbix0b2tlbnMsaW5kZXgpOyAvL1dlIHdhbnQgdGhlIHRva2VucyBhZnRlciB0aGUgVHJpcGxlXHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbXB0eUJyYWNrZXRzID0gc3RhcnQgJiYgc3ViVHJpcGxlcy5sZW5ndGg9PTA7XHJcblxyXG4gICAgICAgICAgICAgICAgICAgICAgICBhY2MucHVzaChuZXcgTm9kZShiZWZvcmUsc3ViVHJpcGxlcyxjb21tZW50LGVtcHR5QnJhY2tldHMsYWZ0ZXIsJycsbXVsdGlFbGVtZW50T25lT2YpKTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ9ZmFsc2U7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgICBzaW5nbGVUcmlwbGUgPSBbXTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYodG9rZW4uc3RyaW5nPT1PUEVOSU5HX0NVUkxZX0JSQUNLRVQpe1xyXG4gICAgICAgICAgICAgICAgb3BlbisrO1xyXG4gICAgICAgICAgICAgICAgc3RhcnQgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgZmluaXNoID0gZmFsc2U7XHJcbiAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIFxyXG4gICAgICAgICAgICBpZih0b2tlbi5zdHJpbmc9PUNMT1NJTkdfQ1VSTFlfQlJBQ0tFVCkgb3Blbi0tO1xyXG4gICAgICAgICAgICBpZihvcGVuPT0wICYmIHN0YXJ0KWZpbmlzaD10cnVlO1xyXG4gICAgIFxyXG4gICAgICAgICAgICByZXR1cm4gYWNjO1xyXG4gICAgICAgIH0sW10pXHJcbn1cclxuXHJcblxyXG5mdW5jdGlvbiBnZXRBZnRlclRyaXBsZVRva2Vucyh0b2tlbnMsbXVsdGlFbGVtZW50T25lT2Ype1xyXG4gICAgbGV0IHN0YXJ0PWZhbHNlO1xyXG4gICAgbGV0IG9wZW4gPSAwO1xyXG4gICAgbGV0IGFmdGVyID0gdG9rZW5zLnJlZHVjZSgoYWNjLHQpPT57XHJcbiAgICAgICAgXHJcbiAgICAgICAgaWYob3BlbiA9PSAwICYmIHN0YXJ0KXtcclxuICAgIC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HVzaCh7dHlwZTpDT01NRU5UX1RZUEUsc3RyaW5nOmNvbW1lbnR9KTtcclxuICAgICAgICAgICAgc3RhcnQgPSBmYWxzZTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIGlmKGluZGV4ID09IHRva2Vucy5sZW5ndGgtMSAmJiB0LnN0cmluZyE9Jy4nICYmIHQuc3RyaW5nIT0nXScpc3RhcnQ9ZmFsc2U7IC8vQnJlYWsgY29uZGl0aW9uIDIgLT4gSWYgaXQncyB0aGUgbGFzdCB0b2tlbiBicmVhayB1bmxlc3MgaXQncyBhIC4gb3IgXSB3aGljaCB3ZSB3YW50IGl0XHJcblxyXG4gICAgICAgIGlmKHN0YXJ0KXtcclxuICAgICAgICAgICAgYWNjLnB1c2godCk7XHJcbiAgICAgICAgfWVsc2V7XHJcbiAgICAgICAgICAgIGlmKHQudHlwZSE9UFVOQ19UWVBFICYmIHQudHlwZSE9Q09NTUVOVF9UWVBFICYmIGluZGV4ID09IHRva2Vucy5sZW5ndGgtMSApYWNjLnB1c2godCk7IC8vIFRoaXMgaXMgbmVlZGVkIHdoZW4gYSBzbG90IGRvZXNuJ3QgaGF2ZSBhbnkgdHJpcGxlXHJcbiAgICAgICAgfVxyXG4gICAgICAgXHJcbiAgICAgICAgcmV0dXJuIGFjYztcclxuICAgIH0sW10pXHJcbn1cclxuXHJcblxyXG5mdW5jdGlvbiBnZXRUcmlwbGVUb2tlbnModG9rZW5zKXtcclxuICAgIGxldCBzdGFydD1mYWxzZTtcclxuICAgIGxldCBvcGVuID0gMDtcclxuICAgIHJldHVybiB0b2tlbnMucmVkdWNlKChhY2MsdCxpbmRleCk9PntcclxuICAgICAgICBcclxuICAgICAgICBpZihzdGFydClhY2MucHVzaCh0KTtcclxuICAgICAgICBcclxuICAgICAgICBpZih0LnN0cmluZz09T1BFTklOR19DVVJMWV9CUkFDS0VUKXtcclxuICAgICAgICAgICAgb3BlbisrO1xyXG4gICAgICAgICAgICBzdGFydD10cnVlO1xyXG4gIC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tlbnMsU0hBUEVfVFlQRSk7XHJcbn1cclxuXHJcblxyXG4vKipcclxuU29ycnkgQWNlYmFsXHJcbiAqL1xyXG5mdW5jdGlvbiBnZXREaXJlY3RpdmVzQW5kU3RhcnRzKHRva2VucyxicmVha0NvbmRpdGlvbil7XHJcbiAgICBsZXQgcHJlZml4ID0ge307XHJcbiAgICBsZXQgYmFzZSA9IHt9O1xyXG4gICAgbGV0IGltcG9ydHQgPSB7fTtcclxuICAgIGxldCBwcmVmaXhDb250ID0gMDtcclxuICAgIGxldCBiYXNlQ29udCA9IDA7XHJcbiAgICBsZXQgaW1wb3J0Q29udCA9IDA7XHJcbiAgICBsZXQgc3RhcnRDb250ID0gMDtcclxuICAgIGxldCBzdG9wID0gZmFsc2U7XHJcbiAgICByZXR1cm4gdG9rZW5zLnJlZHVjZSgoYWNjLHQsaW5kZXgpPT57XHJcblxyXG4gICAgICAgIGlmKHN0b3ApcmV0dXJuIGFjYztcclxuICAgICAgICBpZih0LnR5cGUgPT0gYnJlYWtDb25kaXRpb24pc3RvcD10cnVlO1xyXG5cclxuXHJcbiAgICAgICAgaWYodC5zdHJpbmcudG9VcHBlckNhc2UoKT09UFJFRklYX0tFWVdPUkQpe1xyXG4gICAgICAgICAgICBwcmVmaXggPSB7fTtcclxuICAgICAgICAgICAgcHJlZml4LmNvbW1lbnRzID0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odCx0b2tlbnMsaW5kZXgpOyBcclxuICAgICAgICAgICAgYWNjLnByZWZpeGVzW3ByZWZpeENvbnRdPXByZWZpeDtcclxuICAgICAgICAgICAgcHJlZml4Q29udCsrO1xyXG4gICAgICAgIH1lbHNlIGlmKHQuc3RyaW5nLnRvVXBwZXJDYXNlKCk9PUJBU0VfS0VZV09SRCl7XHJcbiAgICAgICAgICAgIGJhc2UgPSB7fTtcclxuICAgICAgICAgICAgYmFzZS5jb21tZW50cyA9IGdldENvbWVudHNBZnRlclRva2VuKHQsdG9rZW5zLGluZGV4KTsgXHJcbiAgICAgICAgICAgIGFjYy5iYXNlc1tiYXNlQ29udF09YmFzZTtcclxuICAgICAgICAgICAgYmFzZUNvbnQrKztcclxuICAgICAgICB9ZWxzZSBpZih0LnN0cmluZy50b1VwcGVyQ2FzZSgpPT1JTVBPUlRfS0VZV09SRCl7XHJcbiAgICAgICAgICAgIGltcG9ydHQgPSB7fTtcclxuICAgICAgICAgICAgaW1wb3J0dC5jb21tZW50cyA9IGdldENvbWVudHNBZnRlclRva2VuKHQsdG9rZW5zLGluZGV4KTsgXHJcbiAgICAgICAgICAgIGFjYy5pbXBvcnRzW2ltcG9ydENvbnRdPWltcG9ydHQ7XHJcbiAgICAgICAgICAgIGltcG9ydENvbnQrKztcclxuICAgICAgICB9ZWxzZSBpZih0LnN0cmluZy50b1VwcGVyQ2FzZSgpPT1TVEFSVF9LRVlXT1JEKXtcclxuICAgICAgICAgICAgbGV0IHN0ciA9IHQuc3RyaW5nK1wiID0gXCIrdG9rZW5zW2luZGV4KzJdLnN0cmluZytnZXRDb21lbnRzQWZ0ZXJUb2tlbih0b2tlbnNbaW5kZXgrMl0sdG9rZW5zLGluZGV4KzIpO1xyXG4gICAgICAgICAgICBhY2Muc3RhcnRzW2ltcG9ydENvbnRdPXN0cjtcclxuICAgICAgICAgICAgc3RhcnRDb250Kys7XHJcbiAgICAgICAgfWVsc2V7ICAgIFxyXG5cclxuICAgICAgICAgICAgaWYodC50eXBlID09IFBSRUZJWF9BTElBU19UWVBFKXtcclxuICAgICAgICAgICAgICAgIHByZWZpeC5hbGlhcz0gdDtcclxuICAgICAgICAgICAgICAgIHByZWZpeC5jb21tZW50cyArPSBnZXRDb21lbnRzQWZ0ZXJUb2tlbih0LHRva2VucyxpbmRleCk7IFxyXG4gICAgICAgICAgICB9XHJcblxyXG4gICAgICAgICAgICBpZih0LnR5cGUgPT0gUFJFRklYX0lSSV9UWVBFKXtcclxuICAgICAgICAgICAgICAgIHByZWZpeC5pcmk9IHQ7XHJcbiAgICAgICAgICAgICAgICBwcmVmaXguY29tbWVudHMgKz0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odCx0b2tlbnMsaW5kZXgpOyBcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYodC50eXBlPT1CQVNFX1RZUEUpe1xyXG4gICAgICAgICAgICAgICAgYmFzZS50b2tlbj0gdDtcclxuICAgICAgICAgICAgICAgIGJhc2UuY29tbWVudHMgKz0gZ2V0Q29tZW50c0FmdGVyVG9rZW4odCx0b2tlbnMsaW5kZXgpOyBcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgaWYodC50eXBlPT1JTVBPUlRfVFlQRSl7XHJcbiAgICAgICAgICAgICAgICBpbXBvcnR0LnRva2VuPSB0O1xyXG4gICAgICAgICAgICAgICAgaW1wb3J0dC5jb21tZW50cyArPSBnZXRDb21lbnRzQWZ0ZXJUb2tlbih0LHRva2VucyxpbmRleCk7IFxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHJldHVybiBhY2M7XHJcbiAgICB9LHtcclxuICAgICAgICBwcmVmaXhlczpbXSxcclxuICAgICAgICBiYXNlczpbXSxcclxuICAgICAgICBpbXBvcnRzOltdLFxyXG4gICAgICAgIHN0YXJ0czpbXVxyXG4gICAgfSlcclxufVxyXG5cclxuXHJcblxyXG4vKipcclxuKiAgIFNwbGl0IHRoZSB0b2tlbnMgaW50byBTaGFwZXNcclxuKiAgIEBwYXJhbSB7QXJyYXl9IFRva2Vuc1xyXG4qICAgQHJldHVybiB7QXJyYXl9IERlZmluZWQgU2hhcGVzIChBcnJheSBvZiBUb2tlbidzIGFycmF5cylcclxuKlxyXG4gKi9cclxuZnVuY3Rpb24gZ2V0U2hhcGVzVG9rZW5zKHRva2Vucyl7XHJcbiAgICBsZXQgc2hhcGUgPSBbXVxyXG4gICAgbGV0IHNoYXBlQ29udCA9IDA7XHJcbiAgICBsZXQgaGFzVHJpcGxlU3RhcnRlZCA9IGZhbHNlO1xyXG4gICAgLy9TZXBhcmF0ZSBzaGFwZXMgaW4gYXJyYXlzXHJcbiAgICByZXR1cm4gdG9rZW5zLnJlZHVjZSgoYWNjLHQpPT57XHJcblxyXG4gICAgICAgIGlmKHQudHlwZSA9PSBTSEFQRV9UWVBFKXtcclxuICAgICAgICAgICAgc2hhcGUgPSBbXTtcclxuICAgICAgICAgICAgXHJcbiAgICAgICAgICAgIHNoYXBlLnB1c2godClcclxuICAgICAgICAgICAgYWNjW3NoYXBlQ29udF09c2hhcGU7XHJcbiAgICAgICAgICAgIHNoYXBlQ29udCsrO1xyXG4gICAgICAgIH1lbHNleyAgICBcclxuICAgICAgICAgICAgc2hhcGUucHVzaCh0KTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIHJldHVybiBhY2M7XHJcblxyXG4gICAgfSxbXSk7XHJcbn1cclxuXHJcbi8qKlxyXG4qICBHZXRzIHRoZSBjb21tZW50cyBhZnRlciBhIHRva2VuXHJcbiogKi9cclxuZnVuY3Rpb24gZ2V0Q29tZW50c0FmdGVyVG9rZW4odG9rZW4sdG9rZW5zLGluZGV4KSB7XHJcbiAgICBsZXQgaSA9MTtcclxuICAgIGxldCBjb21tZW50ID0gXCJcIjtcclxuICAgIHdoaWxlKHRva2Vuc1tpbmRleCtpXSAmJiB0b2tlbnNbaW5kZXgraV0udHlwZT09Q09NTUVOVF9UWVBFKXtcclxuICAgICAgICBpZih0b2tlbnNbaW5kZXgraV0uc3RhcnQgPCB0b2tlbi5zdGFydCl7XHJcbiAgICAgICAgICAgIGNvbW1lbnQrPVwiXFxuXCI7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGNvbW1lbnQrPVwiIFwiK3Rva2Vuc1tpbmRleCtpXS5zdHJpbmc7XHJcbiAgICAgICAgdG9rZW5zW2luZGV4K2ldLnNraXAgPSB0cnVlO1xyXG4gICAgICAgIGkrKztcclxuICAgIH1cclxuXHJcbiAgICByZXR1cm4gY29tbWVudDtcclxufVxyXG5cclxuLyoqXHJc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Hlhc2hlLmxpbmVDb3VudCgpOyArK2wpIHtcclxuICAgICAgICBsZXQgbGluZVRva2VucyA9IHlhc2hlLmdldExpbmVUb2tlbnMobCk7XHJcbiAgICAgICAgZm9yKGxldCB0IGluIGxpbmVUb2tlbnMpe1xyXG4gICAgICAgICAgICBsZXQgdG9rZW4gPSBsaW5lVG9rZW5zW3RdO1xyXG4gICAgICAgICAgICBpZih0b2tlbi50eXBlIT1XU19UWVBFKWN1cnJlbnRQb3N0aW9uKys7XHJcbiAgICAgICAgICAgIGlmKHBvc2l0aW9uPT1jdXJyZW50UG9zdGlvbil7XHJcbiAgICAgICAgICAgICAgICB5YXNoZS5zZXRDdXJzb3Ioe2xpbmU6bCxjaDp0b2tlbi5lbmR9KVxyXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG59XHJcblxyXG5cclxuZnVuY3Rpb24gcHJldHRpZnlDb21tZW50cygpe1xyXG4gICAgbGV0IGxvbmdlc3QgPSBnZXRMb25nZXN0Q29tbWVudGVkTGluZSgpO1xyXG4gICAgbGV0IGhpc3RvcnkgPSB5YXNoZS5nZXRIaXN0b3J5KCk7XHJcbiAgICBmb3IgKHZhciBsID0gMDsgbCA8IHlhc2hlLmxpbmVDb3VudCgpOyArK2wpIHtcclxuICAgICAgICBsZXQgbGluZVRva2VucyA9IGZvcm1hdFV0aWxzLmdldE5vbldzTGluZVRva2Vucyh5YXNoZS5nZXRMaW5lVG9rZW5zKGwpKTtcclxuICAgICAgICBpZighaGFzT25seUNvbW1lbnRzKGxpbmVUb2tlbnMpKXtcclxuICAgICAgICAgICAgbGluZVRva2Vucy5tYXAodD0+e1xyXG4gICAgICAgICAgICAgICAgaWYodC50eXBlID09ICdjb21tZW50Jykge1xyXG4gICAgICAgICAgICAgICAgICAgIHlhc2hlLnJlcGxhY2VSYW5nZShwcmludFV0aWxzLmdldFNlcGFyYXRvcihsb25nZXN0LXQuc3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5pbmdFbC5zdHlsZS5tYXJnaW5Ub3AgPSBcIjJweFwiO1xyXG4gICAgICAgIHdhcm5pbmdFbC5zdHlsZS5tYXJnaW5MZWZ0ID0gXCIycHhcIjtcclxuICAgICAgICB3YXJuaW5nRWwuY2xhc3NOYW1lID0gXCJwYXJzZUVycm9ySWNvblwiO1xyXG4gICAgICAgIHlhc2hlLnNldEd1dHRlck1hcmtlcihsLCBcImd1dHRlckVycm9yQmFyXCIsIHdhcm5pbmdFbCk7XHJcbiAgXHJcblxyXG4gICAgICAgIHlhc2hlLnF1ZXJ5VmFsaWQgPSBmYWxzZTtcclxuICAgICAgICByZXR1cm4gZmFsc2U7XHJcbiAgICAgIH1cclxuXHJcbiAgICAgIGxldCBsaW5lVG9rZW5zID0geWFzaGUuZ2V0TGluZVRva2VucyhsKTtcclxuICAgICAgZm9yKGxldCB0IGluIGxpbmVUb2tlbnMpe1xyXG4gICAgICAgIGxldCB0b2tlbiA9IGxpbmVUb2tlbnNbdF07XHJcblxyXG4gICAgICAgIGlmKHRva2VuLnN0cmluZz09J3snKXtcclxuICAgICAgICAgIG9wZW5CcmFja2V0c0NvdW50ZXIrKztcclxuICAgICAgICB9XHJcbiAgICAgICAgaWYodG9rZW4uc3RyaW5nPT0nfScpe1xyXG4gICAgICAgICAgY2xvc2VkQnJhY2tldHNDb3VudGVyKys7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBpZih0b2tlbi5zdHJpbmc9PScoJyl7XHJcbiAgICAgICAgICBvcGVuUGFyZW50aGVzaXNDb3VudGVyKys7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIGlmKHRva2VuLnN0cmluZz09JyknKXtcclxuICAgICAgICAgIGNsb3NlZFBhcmVudGhlc2lzQ291bnRlcisrO1xyXG4gICAgICAgIH1cclxuXHJcbiAgICAgICAgaWYodG9rZW4uc3RyaW5nPT0nWycpe1xyXG4gICAgICAgICAgb3BlblNxdWFyZUJyYWNrZXRzQ291bnRlcisrO1xyXG4gICAg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JlZml4OmlzV2lraWRhdGFQcm9wZXJ0aWVzUHJlZml4LFxyXG4gICAgZ2V0RW50aXR5OmdldEVudGl0eSxcclxuICAgIGdldEVudGl0eURhdGE6Z2V0RW50aXR5RGF0YVxyXG5cclxufVxyXG4iXX0= diff --git a/dist/yashe.css b/dist/yashe.css index 4db1ddb0..a857157a 100755 --- a/dist/yashe.css +++ b/dist/yashe.css @@ -95,9 +95,9 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} color: #A9B7C6; border: 10px; } .yashe .cm-s-dark .cm-shape { - color: #68BEEB; } + color: #8fd5fa; } .yashe .cm-s-dark .cm-keyword { - color: #f00; } + color: #ff5656; } .yashe .cm-s-dark .cm-atom { color: #219; } .yashe .cm-s-dark .cm-number { @@ -109,26 +109,24 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} .yashe .cm-s-dark .cm-property, .yashe .cm-s-dark .cm-operator { color: #05a; } - .yashe .cm-s-dark .cm-variable-2 { - color: #68BEEB; } .yashe .cm-s-dark .cm-variable-3 { - color: #68BEEB; } + color: #8fd5fa; } .yashe .cm-s-dark .cm-comment { color: #999; } .yashe .cm-s-dark .cm-string { color: #b98003; } .yashe .cm-s-dark .cm-string-2 { - color: #7DB647; } + color: #a1df67; } .yashe .cm-s-dark .cm-constraint { - color: #7DB647; } + color: #a1df67; } .yashe .cm-s-dark .cm-valueSet { - color: #7DB647; } + color: #a1df67; } .yashe .cm-s-dark .cm-constraintKeyword { - color: #f00; } + color: #ff5656; } .yashe .cm-s-dark .cm-facet { - color: #f00; } + color: #ff5656; } .yashe .cm-s-dark .cm-shapeRef { - color: #68BEEB; } + color: #8fd5fa; } .yashe .cm-s-dark .cm-meta { color: #555; } .yashe .cm-s-dark .cm-qualifier { @@ -142,13 +140,13 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} .yashe .cm-s-dark .cm-attribute { color: #00c; } .yashe .cm-s-dark .cm-hr { - color: #999; } + color: #e42727; } .yashe .cm-s-dark .cm-link { color: #00c; } .yashe .cm-s-dark .cm-punc { color: #FFFFFF; } .yashe .cm-s-dark .cm-logical { - color: #B271FF; } + color: #ff5656; } .yashe .cm-s-dark .cm-at { color: #68BEEB; } .yashe .cm-s-dark .cm-prefixDelcAlias { @@ -653,12 +651,23 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} margin-top: 2px; display: inline-block; } .yashe .yashe_shareBtn { - margin-right: 8px; + margin-right: px; margin-top: 2px; } .yashe .shareInput { border-radius: 3px; width: 250px; border: 1px solid #222; } + .yashe .yashe_wikiBtn { + margin-right: 8px !important; } + .yashe .yashe_wikiBtnAfter { + margin-right: 14px !important; + margin-left: -3px !important; } + .yashe .yashe_stopBtn { + margin-right: 10px; + margin-left: -1px !important; + fill: red !important; } + .yashe .yashe_stopBtn:hover { + filter: invert(0) sepia(0) hue-rotate(0deg) saturate(0) brightness(0) !important; } .yashe .CodeMirror { line-height: 1.5em; border: 1px solid #d1d1d1; } @@ -699,12 +708,12 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} color: red; font-weight: bold; float: left; } - .yashe .completionNotification { + .yashe .notification { color: #999; background-color: #f7f7f7; position: absolute; padding: 0px 5px; - right: 0px; + right: 1.5%; bottom: 0px; font-size: 90%; } .yashe .parseErrorIcon { diff --git a/dist/yashe.min.css b/dist/yashe.min.css index 9ca897c5..529e4c2e 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,.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-shapeRef{color:#0f7a50}.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-baseDecl,.yashe .cm-s-wiki .cm-importDecl,.yashe .cm-s-wiki .cm-prefixDelcAlias,.yashe .cm-s-wiki .cm-prefixDelcIRI{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,.yashe .cm-s-dark .cm-facet{color:red}.yashe .cm-s-dark .cm-shapeRef{color:#68beeb}.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-baseDecl,.yashe .cm-s-dark .cm-importDecl,.yashe .cm-s-dark .cm-prefixDelcAlias,.yashe .cm-s-dark .cm-prefixDelcIRI{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 .yashe_shareBtn{margin-right:8px;margin-top:2px}.yashe .shareInput{border-radius:3px;width:250px;border:1px solid #222}.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-shapeRef{color:#0f7a50}.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-baseDecl,.yashe .cm-s-wiki .cm-importDecl,.yashe .cm-s-wiki .cm-prefixDelcAlias,.yashe .cm-s-wiki .cm-prefixDelcIRI{color:#6d0f7a}.yashe .cm-s-dark.CodeMirror{background:#2b2b2b;color:#a9b7c6;border:10px}.yashe .cm-s-dark .cm-shape{color:#8fd5fa}.yashe .cm-s-dark .cm-keyword{color:#ff5656}.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-3{color:#8fd5fa}.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:#a1df67}.yashe .cm-s-dark .cm-constraintKeyword,.yashe .cm-s-dark .cm-facet{color:#ff5656}.yashe .cm-s-dark .cm-shapeRef{color:#8fd5fa}.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:#e42727}.yashe .cm-s-dark .cm-link{color:#00c}.yashe .cm-s-dark .cm-punc{color:#fff}.yashe .cm-s-dark .cm-logical{color:#ff5656}.yashe .cm-s-dark .cm-at{color:#68beeb}.yashe .cm-s-dark .cm-baseDecl,.yashe .cm-s-dark .cm-importDecl,.yashe .cm-s-dark .cm-prefixDelcAlias,.yashe .cm-s-dark .cm-prefixDelcIRI{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 .yashe_shareBtn{margin-right:px;margin-top:2px}.yashe .shareInput{border-radius:3px;width:250px;border:1px solid #222}.yashe .yashe_wikiBtn{margin-right:8px!important}.yashe .yashe_wikiBtnAfter{margin-right:14px!important;margin-left:-3px!important}.yashe .yashe_stopBtn{margin-right:10px;margin-left:-1px!important;fill:red!important}.yashe .yashe_stopBtn:hover{filter:invert(0) sepia(0) hue-rotate(0deg) saturate(0) brightness(0)!important}.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 .notification{color:#999;background-color:#f7f7f7;position:absolute;padding:0 5px;right:1.5%;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/others/pretty b/doc/examples/others/pretty index 31a2562c..5c0c13ba 100644 --- a/doc/examples/others/pretty +++ b/doc/examples/others/pretty @@ -1,7 +1,7 @@ - # PRESS CTRL-F / Cmd-F + # PRESS Shift-Ctrl-F / Shift-Cmd-F PREFIX : PREFIX schema: PREFIX xsd: :User { schema:name xsd:string ; schema:birthDate xsd:date ? ; schema:gender [ schema:Male schema:Female ] OR xsd:string ; schema:knows IRI @:User * } PREFIX rdf: PREFIX rdfs: PREFIX wd: PREFIX wdt: start = @ EXTRA wdt:P31 { wdt:P31 [ wd:Q5 ] ; wdt:P21 [ wd:Q6581097 wd:Q6581072 wd:Q1097630 wd:Q1052281 wd:Q2449503 wd:Q48270 ] ? ; wdt:P19 . ? ; wdt:P569 . ? ; wdt:P735 . * ; wdt:P734 . * ; wdt:P106 . * ; wdt:P27 @ * ; wdt:P22 @ * ; wdt:P25 @ * ; wdt:P3373 @ * ; wdt:P26 @ * ; wdt:P40 @ * ; wdt:P1038 @ * ; wdt:P103 @ * ; wdt:P1412 @ * ; wdt:P6886 @ * ; rdfs:label rdf:langString + } EXTRA wdt:P31 { wdt:P31 [ wd:Q6256 wd:Q3024240 wd:Q3624078 ] + } EXTRA wdt:P31 { wdt:P31 [ wd:Q34770 wd:Q1288568 ] + } diff --git a/doc/examples/others/wikiComments b/doc/examples/others/wikiComments new file mode 100644 index 00000000..072ca93e --- /dev/null +++ b/doc/examples/others/wikiComments @@ -0,0 +1,39 @@ + + +# Press the second button ----------------------------------------------------------------------> 1 2 3 4 5 6 7 8 + +PREFIX rdf: +PREFIX rdfs: +PREFIX wd: +PREFIX wdt: + +start = @ + + EXTRA wdt:P31 { + wdt:P31 [wd:Q5]; + wdt:P21 [wd:Q6581097 wd:Q6581072 wd:Q1097630 wd:Q1052281 wd:Q2449503 wd:Q48270]?; + wdt:P19 . ?; + wdt:P569 . ? ; + wdt:P735 . * ; + wdt:P734 . * ; + wdt:P106 . * ; + wdt:P27 @ *; + wdt:P22 @ *; + wdt:P25 @ *; + wdt:P3373 @ *; + wdt:P26 @ *; + wdt:P40 @ *; + wdt:P1038 @ *; + wdt:P103 @ *; + wdt:P1412 @ *; + wdt:P6886 @ *; + rdfs:label rdf:langString+; +} + + EXTRA wdt:P31 { + wdt:P31 [wd:Q6256 wd:Q3024240 wd:Q3624078] +; +} + + EXTRA wdt:P31 { + wdt:P31 [wd:Q34770 wd:Q1288568] +; +} \ No newline at end of file diff --git a/doc/examples/validatingRdfData/Example-77-Difference-between-Or-and-| b/doc/examples/validatingRdfData/Example-77-Difference-between-Or-and-| deleted file mode 100644 index 32bba00d..00000000 --- a/doc/examples/validatingRdfData/Example-77-Difference-between-Or-and-| +++ /dev/null @@ -1,16 +0,0 @@ -# Example 77 Difference between Or and | -# https://book.validatingrdf.com/bookHtml010.html#sec103 - -PREFIX : -PREFIX schema: -PREFIX xsd: - -:User1 { schema:name xsd:string } - OR { schema:givenName xsd:string ; - schema:familyName xsd:string - } - -:User2 { schema:name xsd:string - | schema:givenName xsd:string ; - schema:familyName xsd:string - } \ No newline at end of file diff --git a/index.html b/index.html index 4313e5ac..349a270c 100755 --- a/index.html +++ b/index.html @@ -47,11 +47,6 @@
-

About YASHE

- YASHE is a ShEx editor which started as a fork of YASQE (which is based on SPARQL) - This tool performs lexical and syntactic analysis of the content of the editor, thus offering the user a realtime syntactic error detector. - It has features like: syntax highlighting, visual aid elements (tooltips) and autocomplete mechanisms. In addition, it offers a simple way of integrating into other projects. -
@@ -76,6 +72,12 @@

About YASHE

+

About YASHE

+ YASHE is a ShEx editor which started as a fork of YASQE (which is based on SPARQL) + This tool performs lexical and syntactic analysis of the content of the editor, thus offering the user a realtime syntactic error detector. + It has features like: syntax highlighting, visual aid elements (tooltips) and autocomplete mechanisms. In addition, it offers a simple way of integrating into other projects. + +

Features

@@ -188,16 +190,9 @@

Thanks!

persistent:null }); - yashe.setSize(1135,400); - - //yashe.prettify(); - //yashe.wikiformat(); - //yashe.prettify(); - + yashe.setSize(1135,500); - - diff --git a/lib/grammar/tokenizer.js b/lib/grammar/tokenizer.js index f347471a..905e5ce6 100755 --- a/lib/grammar/tokenizer.js +++ b/lib/grammar/tokenizer.js @@ -513,6 +513,7 @@ CodeMirror.defineMode("shex", function(config, parserConfig) { state.defShapes[tokenOb.text] = tokenOb tokenOb.style='shape'; } + // console.log({topSymbol:topSymbol,tokenOb:tokenOb.text}) if(topSymbol == 'valueSetValue')tokenOb.style='valueSet'; //if(tokenOb.cat == 'ATPNAME_LN')tokenOb.style='shapeRef'; if(topSymbol=='cardinality')tokenOb.style='cardinality'; @@ -521,15 +522,14 @@ CodeMirror.defineMode("shex", function(config, parserConfig) { if(topSymbol=='nodeConstraint'){ if(token!='['){ - if(!token.match(grammar.keywords)){ - tokenOb.style='constraint'; + if(!token.match(grammar.keywords) || token == 'IRI_REF'){ // IRI_REF MATCHES WITH IRI + tokenOb.style='constraint'; }else{ tokenOb.style='constraintKeyword'; } } } - if (!ll1_table[topSymbol]) { // Top symbol is a terminal if (topSymbol == token) { diff --git a/package-lock.json b/package-lock.json index a5ce18d0..4321bc0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -666,34 +666,6 @@ "@babel/types": "^7.3.0" } }, - "@types/blob-util": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@types/blob-util/-/blob-util-1.3.3.tgz", - "integrity": "sha512-4ahcL/QDnpjWA2Qs16ZMQif7HjGP2cw3AGjHabybjw7Vm1EKu+cfQN1D78BaZbS1WJNa1opSMF5HNMztx7lR0w==", - "dev": true - }, - "@types/bluebird": { - "version": "3.5.29", - "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.29.tgz", - "integrity": "sha512-kmVtnxTuUuhCET669irqQmPAez4KFnFVKvpleVRyfC3g+SHD1hIkFZcWLim9BVcwUBLO59o8VZE4yGCmTif8Yw==", - "dev": true - }, - "@types/chai": { - "version": "4.2.7", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", - "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", - "dev": true - }, - "@types/chai-jquery": { - "version": "1.1.40", - "resolved": "https://registry.npmjs.org/@types/chai-jquery/-/chai-jquery-1.1.40.tgz", - "integrity": "sha512-mCNEZ3GKP7T7kftKeIs7QmfZZQM7hslGSpYzKbOlR2a2HCFf9ph4nlMRA9UnuOETeOQYJVhJQK7MwGqNZVyUtQ==", - "dev": true, - "requires": { - "@types/chai": "*", - "@types/jquery": "*" - } - }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -719,49 +691,12 @@ "@types/istanbul-lib-report": "*" } }, - "@types/jquery": { - "version": "3.3.31", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.31.tgz", - "integrity": "sha512-Lz4BAJihoFw5nRzKvg4nawXPzutkv7wmfQ5121avptaSIXlDNJCUuxZxX/G+9EVidZGuO0UBlk+YjKbwRKJigg==", - "dev": true, - "requires": { - "@types/sizzle": "*" - } - }, - "@types/lodash": { - "version": "4.14.149", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.149.tgz", - "integrity": "sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ==", - "dev": true - }, - "@types/minimatch": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", - "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", - "dev": true - }, - "@types/mocha": { - "version": "5.2.7", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", - "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==", - "dev": true - }, - "@types/sinon": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-7.5.1.tgz", - "integrity": "sha512-EZQUP3hSZQyTQRfiLqelC9NMWd1kqLcmQE0dMiklxBkgi84T+cHOhnKpgk4NnOWpGX863yE6+IaGnOXUNFqDnQ==", + "@types/sinonjs__fake-timers": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz", + "integrity": "sha512-yYezQwGWty8ziyYLdZjwxyMb0CZR49h8JALHGrxjQHWlqGgc8kLdHEgWrgL0uZ29DMvEVBDnHU2Wg36zKSIUtA==", "dev": true }, - "@types/sinon-chai": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.3.tgz", - "integrity": "sha512-TOUFS6vqS0PVL1I8NGVSNcFaNJtFoyZPXZ5zur+qlhDfOmQECZZM4H4kKgca6O8L+QceX/ymODZASfUfn+y4yQ==", - "dev": true, - "requires": { - "@types/chai": "*", - "@types/sinon": "*" - } - }, "@types/sizzle": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz", @@ -841,9 +776,9 @@ } }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, "acorn-globals": { @@ -888,9 +823,9 @@ } }, "acorn-walk": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.0.0.tgz", - "integrity": "sha512-7Bv1We7ZGuU79zZbb6rRqcpxo3OY+zrdtloZWoyD8fmGX+FeXRjE+iuGkZjSXLVovLzrsvMGMy0EkwA0E0umxg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", "dev": true }, "ajv": { @@ -1031,9 +966,9 @@ "dev": true }, "arch": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/arch/-/arch-2.1.1.tgz", - "integrity": "sha512-BLM56aPo9vLLFVa8+/+pJLnrZ7QGGTVHWsCwieAWT9o9K8UeGaQbzZbGoabWLOo2ksBCztoXdqBZBplqLDDCSg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/arch/-/arch-2.1.2.tgz", + "integrity": "sha512-NTBIIbAfkJeIletyABbVtdPgeKfDafR+1mZV/AyyfC1UkVkp9iUjV+wwmqtUgphHYajbI86jejBJp5e+jkGTiQ==", "dev": true }, "archy": { @@ -1214,14 +1149,23 @@ } }, "asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", "dev": true, "requires": { "bn.js": "^4.0.0", "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "assert": { @@ -1510,9 +1454,9 @@ } }, "base64-js": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", - "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.0.tgz", + "integrity": "sha512-Jrdy04F2EKcNggUDfubMUPNAZg2vMquLQSm8sKLYJvz40ClFL1S8GKyDshGkNsbNNE5Z+fQavzU7nSK1I9JUGA==", "dev": true }, "base64-url": { @@ -1571,9 +1515,9 @@ } }, "bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", "dev": true, "requires": { "readable-stream": "^2.3.5", @@ -1607,9 +1551,9 @@ "dev": true }, "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.3.tgz", + "integrity": "sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==", "dev": true }, "body": { @@ -1779,17 +1723,17 @@ } }, "browserify": { - "version": "16.5.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.0.tgz", - "integrity": "sha512-6bfI3cl76YLAnCZ75AGu/XPOsqUhRyc0F/olGIJeCxtfxF2HvPKEcmjU9M8oAPxl4uBY1U7Nry33Q6koV3f2iw==", + "version": "16.5.2", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.2.tgz", + "integrity": "sha512-TkOR1cQGdmXU9zW4YukWzWVSJwrxmNdADFbqbE3HFgQWe5wqZmOawqZ7J/8MPCwk/W8yY7Y0h+7mOtcZxLP23g==", "dev": true, "requires": { "JSONStream": "^1.0.3", "assert": "^1.4.0", "browser-pack": "^6.0.1", - "browser-resolve": "^1.11.0", + "browser-resolve": "^2.0.0", "browserify-zlib": "~0.2.0", - "buffer": "^5.0.2", + "buffer": "~5.2.1", "cached-path-relative": "^1.0.0", "concat-stream": "^1.6.0", "console-browserify": "^1.1.0", @@ -1807,8 +1751,8 @@ "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", "labeled-stream-splicer": "^2.0.0", - "mkdirp": "^0.5.0", - "module-deps": "^6.0.0", + "mkdirp-classic": "^0.5.2", + "module-deps": "^6.2.3", "os-browserify": "~0.3.0", "parents": "^1.0.1", "path-browserify": "~0.0.0", @@ -1832,6 +1776,29 @@ "util": "~0.10.1", "vm-browserify": "^1.0.0", "xtend": "^4.0.0" + }, + "dependencies": { + "browser-resolve": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-2.0.0.tgz", + "integrity": "sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==", + "dev": true, + "requires": { + "resolve": "^1.17.0" + }, + "dependencies": { + "resolve": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "dev": true, + "requires": { + "is-core-module": "^2.1.0", + "path-parse": "^1.0.6" + } + } + } + } } }, "browserify-aes": { @@ -1879,6 +1846,14 @@ "requires": { "bn.js": "^4.1.0", "randombytes": "^2.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "browserify-shim": { @@ -1903,18 +1878,33 @@ } }, "browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", + "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", "dev": true, "requires": { - "bn.js": "^4.1.1", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.2", - "elliptic": "^6.0.0", - "inherits": "^2.0.1", - "parse-asn1": "^5.0.0" + "bn.js": "^5.1.1", + "browserify-rsa": "^4.0.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.3", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.5", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "browserify-transform-tools": { @@ -1956,9 +1946,9 @@ } }, "buffer": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", - "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", "dev": true, "requires": { "base64-js": "^1.0.2", @@ -2958,13 +2948,21 @@ "dev": true }, "create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", "dev": true, "requires": { "bn.js": "^4.1.0", - "elliptic": "^6.0.0" + "elliptic": "^6.5.3" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "create-hash": { @@ -3158,48 +3156,39 @@ } }, "cypress": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-4.3.0.tgz", - "integrity": "sha512-xO1oef4ns4koDAkQROGJIhKKhGHDOKfOmlirwP1QAk9w/no+YJpN7HZ6IUPiXwWw3C7xVLjScoI8Dad0z5uTTg==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-4.10.0.tgz", + "integrity": "sha512-eFv1WPp4zFrAgZ6mwherBGVsTpHvay/hEF5F7U7yfAkTxsUQn/ZG/LdX67fIi3bKDTQXYzFv/CvywlQSeug8Bg==", "dev": true, "requires": { "@cypress/listr-verbose-renderer": "0.4.1", "@cypress/request": "2.88.5", "@cypress/xvfb": "1.2.4", - "@types/blob-util": "1.3.3", - "@types/bluebird": "3.5.29", - "@types/chai": "4.2.7", - "@types/chai-jquery": "1.1.40", - "@types/jquery": "3.3.31", - "@types/lodash": "4.14.149", - "@types/minimatch": "3.0.3", - "@types/mocha": "5.2.7", - "@types/sinon": "7.5.1", - "@types/sinon-chai": "3.2.3", + "@types/sinonjs__fake-timers": "6.0.1", "@types/sizzle": "2.3.2", - "arch": "2.1.1", + "arch": "2.1.2", "bluebird": "3.7.2", "cachedir": "2.3.0", "chalk": "2.4.2", "check-more-types": "2.24.0", "cli-table3": "0.5.1", - "commander": "4.1.0", + "commander": "4.1.1", "common-tags": "1.8.0", "debug": "4.1.1", - "eventemitter2": "4.1.2", + "eventemitter2": "6.4.2", "execa": "1.0.0", "executable": "4.1.1", "extract-zip": "1.7.0", "fs-extra": "8.1.0", - "getos": "3.1.4", + "getos": "3.2.1", "is-ci": "2.0.0", - "is-installed-globally": "0.1.0", + "is-installed-globally": "0.3.2", "lazy-ass": "1.6.0", "listr": "0.14.3", "lodash": "4.17.15", "log-symbols": "3.0.0", "minimist": "1.2.5", - "moment": "2.24.0", + "moment": "2.26.0", "ospath": "1.2.2", "pretty-bytes": "5.3.0", "ramda": "0.26.1", @@ -3212,9 +3201,9 @@ }, "dependencies": { "commander": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.0.tgz", - "integrity": "sha512-NIQrwvv9V39FHgGFm36+U9SMQzbiHvU79k+iADraJTpmrFFfx7Ds0IvDoAdZsDrknlkRk14OYoWXb57uTh7/sw==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", "dev": true }, "has-flag": { @@ -3223,6 +3212,12 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, "minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", @@ -3565,6 +3560,14 @@ "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "doctrine": { @@ -3671,9 +3674,9 @@ "dev": true }, "elliptic": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", - "integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -3683,6 +3686,14 @@ "inherits": "^2.0.1", "minimalistic-assert": "^1.0.0", "minimalistic-crypto-utils": "^1.0.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "emoji-regex": { @@ -4066,9 +4077,9 @@ } }, "eventemitter2": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-4.1.2.tgz", - "integrity": "sha1-DhqEd6+CGm7zmVsxG/dMI6UkfxU=", + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.2.tgz", + "integrity": "sha512-r/Pwupa5RIzxIHbEKCkNXqpEQIIT4uQDxmP4G/Lug/NokVUWj0joz/WzWl3OxRpC5kDrH/WdiUJoR+IrwvXJEw==", "dev": true }, "events": { @@ -4466,27 +4477,21 @@ "dev": true }, "falafel": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/falafel/-/falafel-2.1.0.tgz", - "integrity": "sha1-lrsXdh2rqU9G0AFzizzt86Z/4Gw=", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/falafel/-/falafel-2.2.4.tgz", + "integrity": "sha512-0HXjo8XASWRmsS0X1EkhwEMZaD3Qvp7FfURwjLKjG1ghfRm/MGZl2r4cWUTv41KdNghTw4OUMmVtdGQp3+H+uQ==", "dev": true, "requires": { - "acorn": "^5.0.0", + "acorn": "^7.1.1", "foreach": "^2.0.5", - "isarray": "0.0.1", + "isarray": "^2.0.1", "object-keys": "^1.0.6" }, "dependencies": { - "acorn": { - "version": "5.7.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", - "dev": true - }, "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", "dev": true }, "object-keys": { @@ -5623,12 +5628,12 @@ "dev": true }, "getos": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/getos/-/getos-3.1.4.tgz", - "integrity": "sha512-UORPzguEB/7UG5hqiZai8f0vQ7hzynMQyJLxStoQ8dPGAcmgsfXOPA4iE/fGtweHYkK+z4zc9V0g+CIFRf5HYw==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/getos/-/getos-3.2.1.tgz", + "integrity": "sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==", "dev": true, "requires": { - "async": "^3.1.0" + "async": "^3.2.0" } }, "getpass": { @@ -5739,12 +5744,12 @@ } }, "global-dirs": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", - "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-2.0.1.tgz", + "integrity": "sha512-5HqUqdhkEovj2Of/ms3IeS/EekcO54ytHRLV4PEY2rhRwrHXLQjeVEES0Lhka0xwNDtGYn58wyC4s5+MHsOO6A==", "dev": true, "requires": { - "ini": "^1.3.4" + "ini": "^1.3.5" } }, "global-modules": { @@ -5788,9 +5793,9 @@ } }, "globule": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.0.tgz", - "integrity": "sha512-YlD4kdMqRCQHrhVdonet4TdRtv1/sZKepvoxNT4Nrhrp5HI8XFfc8kFlGlBn2myBo80aGp8Eft259mbcUJhgSg==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.2.tgz", + "integrity": "sha512-7IDTQTIu2xzXkT+6mlluidnWo+BypnbSoEVVQCGfzqnl5Ik8d3e1d4wycb8Rj9tWW+Z39uPWsdlquqiqPCd/pA==", "dev": true, "requires": { "glob": "~7.1.1", @@ -6774,13 +6779,27 @@ } }, "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", + "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "dev": true, "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "hash.js": { @@ -6901,9 +6920,9 @@ } }, "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true }, "ignore": { @@ -6939,9 +6958,9 @@ "dev": true }, "in-publish": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.0.tgz", - "integrity": "sha1-4g/146KvwmkDILbcVSaCqcf631E=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.1.tgz", + "integrity": "sha512-oDM0kUSNFC31ShNxHKUyfZKy8ZeXZBWMjMdZHKLOk13uvT27VTL/QzRGfRUcevJhpkZAvlhPYuXkF7eNWrtyxQ==", "dev": true }, "indent-string": { @@ -7017,9 +7036,9 @@ } }, "insert-module-globals": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz", - "integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.1.tgz", + "integrity": "sha512-ufS5Qq9RZN+Bu899eA9QCAYThY+gGW7oRkmb0vC93Vlyu/CFGcH0OYPEjVkDXA5FEbTt1+VWzdoOD3Ny9N+8tg==", "dev": true, "requires": { "JSONStream": "^1.0.3", @@ -7129,6 +7148,15 @@ "ci-info": "^2.0.0" } }, + "is-core-module": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.1.0.tgz", + "integrity": "sha512-YcV7BgVMRFRua2FqQzKtTDMz8iCuLEyGKjr70q8Zm1yy2qKcurbFEd79PAdHV77oL3NrAaOVQIbMmiHQCHB7ZA==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -7209,13 +7237,13 @@ } }, "is-installed-globally": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", - "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.3.2.tgz", + "integrity": "sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g==", "dev": true, "requires": { - "global-dirs": "^0.1.0", - "is-path-inside": "^1.0.0" + "global-dirs": "^2.0.1", + "is-path-inside": "^3.0.1" } }, "is-negated-glob": { @@ -7243,13 +7271,10 @@ } }, "is-path-inside": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", - "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", - "dev": true, - "requires": { - "path-is-inside": "^1.0.1" - } + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.2.tgz", + "integrity": "sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg==", + "dev": true }, "is-plain-obj": { "version": "1.1.0", @@ -7581,8 +7606,7 @@ }, "yargs-parser": { "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "resolved": "", "dev": true, "requires": { "camelcase": "^5.0.0", @@ -7988,9 +8012,9 @@ } }, "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "dev": true, "requires": { "camelcase": "^5.0.0", @@ -8644,9 +8668,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "dev": true }, "lodash._arraycopy": { @@ -9402,6 +9426,14 @@ "requires": { "bn.js": "^4.0.0", "brorand": "^1.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "mime": { @@ -9450,9 +9482,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "mixin-deep": { @@ -9477,30 +9509,28 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } + "minimist": "^1.2.5" } }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true + }, "module-deps": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.2.tgz", - "integrity": "sha512-a9y6yDv5u5I4A+IPHTnqFxcaKr4p50/zxTjcQJaX2ws9tN/W6J6YXnEKhqRyPhl494dkcxx951onSKVezmI+3w==", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.3.tgz", + "integrity": "sha512-fg7OZaQBcL4/L+AK5f4iVqf9OMbCclXfy/znXRxTVhJSeW5AIlS9AwheYwDaXM3lVW7OBeaeUEY3gbaC6cLlSA==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "browser-resolve": "^1.7.0", + "browser-resolve": "^2.0.0", "cached-path-relative": "^1.0.2", "concat-stream": "~1.6.0", "defined": "^1.0.0", @@ -9514,6 +9544,29 @@ "subarg": "^1.0.0", "through2": "^2.0.0", "xtend": "^4.0.0" + }, + "dependencies": { + "browser-resolve": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-2.0.0.tgz", + "integrity": "sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==", + "dev": true, + "requires": { + "resolve": "^1.17.0" + }, + "dependencies": { + "resolve": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "dev": true, + "requires": { + "is-core-module": "^2.1.0", + "path-parse": "^1.0.6" + } + } + } + } } }, "mold-source-map": { @@ -9535,9 +9588,9 @@ } }, "moment": { - "version": "2.24.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", - "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz", + "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==", "dev": true }, "morgan": { @@ -9884,9 +9937,9 @@ } }, "node-sass": { - "version": "4.13.1", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.13.1.tgz", - "integrity": "sha512-TTWFx+ZhyDx1Biiez2nB0L3YrCZ/8oHagaDalbuBSlqXgUPsdkUSzJsVxeDO9LtPB49+Fh3WQl3slABo6AotNw==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.14.1.tgz", + "integrity": "sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g==", "dev": true, "requires": { "async-foreach": "^0.1.3", @@ -9903,7 +9956,7 @@ "node-gyp": "^3.8.0", "npmlog": "^4.0.0", "request": "^2.88.0", - "sass-graph": "^2.2.4", + "sass-graph": "2.2.5", "stdout-stream": "^1.4.0", "true-case-path": "^1.0.2" }, @@ -10410,14 +10463,13 @@ } }, "parse-asn1": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.5.tgz", - "integrity": "sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", "dev": true, "requires": { - "asn1.js": "^4.0.0", + "asn1.js": "^5.2.0", "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.0", "pbkdf2": "^3.0.3", "safe-buffer": "^5.1.1" @@ -10504,12 +10556,6 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -10570,9 +10616,9 @@ } }, "pbkdf2": { - "version": "3.0.17", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", - "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.1.tgz", + "integrity": "sha512-4Ejy1OPxi9f2tt1rRV7Go7zmfDQ+ZectEQz3VGUQhgq62HtIRPDyG/JtnwIxs6x3uNMwo2V7q1fMvKjb+Tnpqg==", "dev": true, "requires": { "create-hash": "^1.1.2", @@ -11218,6 +11264,14 @@ "parse-asn1": "^5.0.0", "randombytes": "^2.0.1", "safe-buffer": "^5.1.2" + }, + "dependencies": { + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", + "dev": true + } } }, "pump": { @@ -11923,15 +11977,129 @@ } }, "sass-graph": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.4.tgz", - "integrity": "sha1-E/vWPNHK8JCLn9k0dq1DpR0eC0k=", + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz", + "integrity": "sha512-VFWDAHOe6mRuT4mZRd4eKE+d8Uedrk6Xnh7Sh9b4NGufQLQjOrvf/MQoOdx+0s92L89FeyUUNfU597j/3uNpag==", "dev": true, "requires": { "glob": "^7.0.0", "lodash": "^4.0.0", "scss-tokenizer": "^0.2.3", - "yargs": "^7.0.0" + "yargs": "^13.3.2" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + }, + "yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } } }, "sax": { @@ -12191,9 +12359,9 @@ "dev": true }, "simple-concat": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", - "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", "dev": true }, "sisteransi": { @@ -12623,21 +12791,21 @@ "dev": true }, "stream-http": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.0.tgz", - "integrity": "sha512-cuB6RgO7BqC4FBYzmnvhob5Do3wIdIsXAgGycHJnW+981gHqoYcYz9lqjJrk8WXRddbwPuqPYRl+bag6mYv4lw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.1.1.tgz", + "integrity": "sha512-S7OqaYu0EkFpgeGFb/NPOoPLxFko7TPqtEeFg5DXPB4v/KETHG0Ln6fRFrNezoelpaDKmycEmmZ81cC9DAwgYg==", "dev": true, "requires": { "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.1", - "readable-stream": "^3.0.6", - "xtend": "^4.0.0" + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "xtend": "^4.0.2" }, "dependencies": { "readable-stream": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz", - "integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, "requires": { "inherits": "^2.0.3", diff --git a/package.json b/package.json index 5bfe9fda..739c8f51 100755 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "browserify-shim": "^3.8.12", "browserify-transform-tools": "^1.6.0", "clipboard": "^2.0.4", - "cypress": "^4.3.0", + "cypress": "^4.10.0", "eslint": "^6.4.0", "eslint-config-google": "^0.14.0", "exorcist": "^0.4.0", diff --git a/src/autocompleters/autocompleterBase.js b/src/autocompleters/autocompleterBase.js index 014ef29e..82a1a79f 100755 --- a/src/autocompleters/autocompleterBase.js +++ b/src/autocompleters/autocompleterBase.js @@ -186,7 +186,7 @@ module.exports = function(YASHE, yashe) { var startChar; //For the wikidata completer we recive the {text, displayText} object if(completer.name == 'wikibase' || completer.name == 'definedShapes' - || completer.name == 'prefixesAndKeywords'){ + || completer.name == 'prefixes' || completer.name == 'keywords'){ for (var i = 0; i < suggestions.length; i++) { hintList.push({ @@ -260,7 +260,7 @@ module.exports = function(YASHE, yashe) { //only draw when the user needs to use a keypress to summon autocompletions if (!completer.autoshow) { if (!completionNotifications[completer.name]) - completionNotifications[completer.name] = $("
"); + completionNotifications[completer.name] = $("
"); completionNotifications[completer.name] .show() .text("Press CTRL - to autocomplete") diff --git a/src/autocompleters/definedShapes.js b/src/autocompleters/definedShapes.js index 00b47aeb..2dd628f6 100644 --- a/src/autocompleters/definedShapes.js +++ b/src/autocompleters/definedShapes.js @@ -24,7 +24,11 @@ module.exports = function(yashe, name) { }, async: false, bulk: false, - autoShow: false + autoShow: false/* , + callbacks: { + validPosition: yashe.autocompleters.notifications.show, + invalidPosition: yashe.autocompleters.notifications.hide + } */ }; }; diff --git a/src/autocompleters/keywords.js b/src/autocompleters/keywords.js new file mode 100755 index 00000000..1e093a6f --- /dev/null +++ b/src/autocompleters/keywords.js @@ -0,0 +1,77 @@ +"use strict"; +var $ = require("jquery") +var yashe = require('../main.js') +var Trie = require('../../lib/trie.js') + +module.exports = function(yashe, name) { + + + return { + isValidCompletionPosition: function() { + return module.exports.isValidCompletionPosition(yashe); + }, + get: function(token) { + + var trie = new Trie() + for(var key in KEYWORDS){ + trie.insert(KEYWORDS[key]); + } + + var completions = trie.autoComplete(token.toLowerCase()) + var final = [] + var list={} + for(var c in completions){ + + var text = completions[c] + var displayText = completions[c]; + + list = { + text: text, + displayText: displayText + } + + final.push(list) + } + + + return final + + }, + async: false, + bulk: false, + autoShow: true + }; +}; + +module.exports.isValidCompletionPosition = function(yashe) { + let token = yashe.getCompleteToken(); + for(let k in KEYWORDS){ + if(token.string==KEYWORDS[k])return false; + } + if(token.string.length>1 + && !token.string.includes(':'))return true; + return false; +}; + + +var KEYWORDS = [ + 'base', + 'prefix', + 'import', + 'external', + 'iri', + 'bnode', + 'literal', + 'nonliteral', + 'length', + 'minlength', + 'maxlength', + 'mininclusive', + 'minexclusive', + 'maxinclusive', + 'maxexclusive', + 'totaldigits', + 'fractiondigits', + 'closed', + 'extra' + ] \ No newline at end of file diff --git a/src/autocompleters/prefixesAndKeywords.js b/src/autocompleters/prefixes.js old mode 100755 new mode 100644 similarity index 75% rename from src/autocompleters/prefixesAndKeywords.js rename to src/autocompleters/prefixes.js index 661192e5..37b516c1 --- a/src/autocompleters/prefixesAndKeywords.js +++ b/src/autocompleters/prefixes.js @@ -17,10 +17,6 @@ module.exports = function(yashe, name) { for(var prefix in prefixes){ trie.insert(prefix+":"); } - for(var key in KEYWORDS){ - trie.insert(KEYWORDS[key]); - } - var completions = trie.autoComplete(token.toLowerCase()) var final = [] @@ -48,14 +44,18 @@ module.exports = function(yashe, name) { }, async: false, bulk: false, - autoShow: false + autoShow: true }; }; module.exports.isValidCompletionPosition = function(yashe) { module.exports.PREFIXES = yashe.getDefinedPrefixes(); - - return true + let token = yashe.getCompleteToken(); + if(token.string.length>0 + && token.type != 'ws' + && token.type != 'punc' + && !token.string.includes(':'))return true; + return false }; @@ -71,27 +71,3 @@ module.exports.isInPrefixList = function(completion){ module.exports.PREFIXES = [] -var KEYWORDS = [ - 'base', - 'prefix', - 'import', - 'external', - 'or', - 'and', - 'not"', - 'iri', - 'bnode', - 'literal', - 'nonliteral', - 'length', - 'minlength', - 'maxlength', - 'mininclusive', - 'minexclusive', - 'maxinclusive', - 'maxexclusive', - 'totaldigits', - 'fractiondigits', - 'closed', - 'extra' - ] \ No newline at end of file diff --git a/src/autocompleters/wikibase.js b/src/autocompleters/wikibase.js index 53422f51..85570a29 100755 --- a/src/autocompleters/wikibase.js +++ b/src/autocompleters/wikibase.js @@ -1,6 +1,7 @@ "use strict"; var $ = require("jquery"), -rdfUtils = require('../utils/rdfUtils.js') +wikiUtils = require('../utils/wikiUtils.js'); +const { isWikidataPrefix } = require("../utils/wikiUtils.js"); var API_ENDPOINT = 'https://www.wikidata.org/w/'; var QUERY = { @@ -26,20 +27,20 @@ module.exports = function(yashe, name) { query.search=possibleEntity //Add extra param if it is a property - if(rdfUtils.isWikidataPropertiesPrefix(yashe,prefix)){ + if(wikiUtils.isWikidataPropertiesPrefix(yashe,prefix)){ query.type='property'; }else{ delete query.type; } - let endpoint = rdfUtils.getEndPoint(yashe,prefix); + let endpoint = wikiUtils.getEndPoint(yashe,prefix); if(endpoint!=null){ API_ENDPOINT = endpoint; } getEntities(API_ENDPOINT,query) .done((data)=>setHints(data,callback)) - .fail( + .fail( //I had to do this for one wikibase instance I don't know why... ()=>getEntities(API_ENDPOINT.replace('/w/','/wiki/'),query) .done((data)=>setHints(data,callback)) ) @@ -48,7 +49,11 @@ module.exports = function(yashe, name) { }, async: true, bulk: false, - autoShow: false + autoShow: false, + callbacks: { + validPosition: yashe.autocompleters.notifications.show, + invalidPosition: yashe.autocompleters.notifications.hide + } }; }; @@ -108,21 +113,12 @@ module.exports.isValidCompletionPosition = function(yashe) { //The cursor should stay at the end of the token if(token.end!=cur.ch)return false - var prefixName = token.string.split(':')[0] + var previousToken = yashe.getPreviousNonWsToken(cur.line, token); //This line avoid the autocomplete in the prefix definition if(previousToken.string.toUpperCase() == 'PREFIX')return false - if(token.type == 'shape' || token.type=='string-2' || token.type=='constraint'){ - if(rdfUtils.isWikidataEntitiesPrefix(yashe,prefixName) - || rdfUtils.isWikidataPropertiesPrefix(yashe,prefixName) - || rdfUtils.getEndPoint(yashe,prefixName)!=null){ - return true - } - } + return wikiUtils.isWikidataPrefix(yashe,token); - - return false; - }; diff --git a/src/config/defaults.js b/src/config/defaults.js index ced3959b..0ee588a7 100755 --- a/src/config/defaults.js +++ b/src/config/defaults.js @@ -12,19 +12,17 @@ YASHE.defaults = $.extend(true, {}, YASHE.defaults, { /** * Default shape */ - value: `PREFIX rdf: -PREFIX rdfs: -PREFIX wd: -PREFIX wdt: - -start = @ - - EXTRA wdt:P31 { - wdt:P31 [ - wd:Q5 #1 - wd:Q11574 #2 - ]; -} + value: ` + + prefix schema: + prefix : + + :Person { + schema:asd { + schema:asd . + } or{ schema:sdaf .} + } + `, highlightSelectionMatches: { @@ -45,12 +43,14 @@ start = @ syntaxErrorCheck: true, showTooltip: true, showShareButton: true, + showWikiBtn:true, showUploadButton: true, showDownloadButton: true, showCopyButton: true, showDeleteButton: true, showThemeButton: true, showFullScreenButton: true, + wikiFormatInProgress:false, onQuotaExceeded: function(e) { //fail silently console.warn("Could not store in localstorage. Skipping..", e); @@ -72,14 +72,12 @@ start = @ "Ctrl-Up": YASHE.copyLineUp, "Cmd-Down": YASHE.copyLineDown, "Cmd-Up": YASHE.copyLineUp, - "Shift-Ctrl-F": YASHE.doAutoFormat, - "Shift-Cmd-F": YASHE.doAutoFormat, + "Shift-Ctrl-F": YASHE.prettify, + "Shift-Cmd-F": YASHE.prettify, "Ctrl-S": YASHE.storeContent, "Cmd-S": YASHE.storeConten, "Ctrl-Enter": YASHE.executeQuery, "Cmd-Enter": YASHE.executeQuery, - "Ctrl-F": YASHE.prettify, - "Cmd-F": YASHE.prettify, F11: function(yashe) { yashe.setOption("fullScreen", !yashe.getOption("fullScreen")); if(yashe.getOption("fullScreen")){ diff --git a/src/main.js b/src/main.js index d1467ee0..97e0b97c 100755 --- a/src/main.js +++ b/src/main.js @@ -19,6 +19,7 @@ const tooltipUtils = require('./utils/tooltipUtils.js'); const formatUtils = require('./utils/formatUtils.js'); const buttonsUtils = require('./utils/buttonsUtils.js'); const prettyUtils = require('./utils/pretty/prettyUtils.js'); +const interact = require('./utils/interactUtils.js'); const prefixFold = require('./utils/prefixFold.js'); const autocompletersBase = require('./autocompleters/autocompleterBase.js'); const Clipboard = require('clipboard'); @@ -210,10 +211,16 @@ const extendCmInstance = function(yashe) { formatUtils.wikiFormat(yashe); } + yashe.stopWikiFormat = function(){ + yashe.wikiFormatInProgress = false; + } + yashe.prettify = function(){ if(!yashe.hasErrors()){ prettyUtils.prettify(yashe); - if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + //if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + }else{ + interact.showErrAlertMsg(yashe); } } @@ -388,8 +395,10 @@ root.storeContent = function(yashe) { root.prettify = function(yashe){ if(!yashe.hasErrors()){ - prettyUtils.prettify(yashe); - // if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + prettyUtils.prettify(yashe); + //if(yashe.hasErrors())yashe.undo(); //Just in case the prettify fail + }else{ + interact.showErrAlertMsg(yashe); } } @@ -399,10 +408,12 @@ root.prettify = function(yashe){ * @return {string} Check result */ const checkSyntax = function(yashe) { - return syntaxUtils.checkSyntax(yashe); + syntaxUtils.checkSyntax(yashe); + return syntaxUtils.reCheckSyntax(yashe); }; + // ---- Static Utils ----- // first take all codeMirror references and store them in the YASHE object @@ -431,8 +442,17 @@ root.registerAutocompleter('wikibase', root.registerAutocompleter('prefixDefinition', require('./autocompleters/prefixDefinition.js')); -root.registerAutocompleter('prefixesAndKeywords', - require('./autocompleters/prefixesAndKeywords.js')); +root.registerAutocompleter('keywords', + require('./autocompleters/keywords.js')); + +root.registerAutocompleter('prefixes', + require('./autocompleters/prefixes.js')); + + + + +/* root.registerAutocompleter('prefixesAndKeywords', + require('./autocompleters/prefixesAndKeywords.js')); */ /** diff --git a/src/scss/buttons.scss b/src/scss/buttons.scss index 19425a1c..bcc047cd 100755 --- a/src/scss/buttons.scss +++ b/src/scss/buttons.scss @@ -226,7 +226,7 @@ } .yashe_shareBtn{ - margin-right: 8px; + margin-right: px; margin-top: 2px; } @@ -234,4 +234,30 @@ border-radius: 3px; width: 250px; border:1px solid #222; + } + + .yashe_wikiBtn{ + margin-right: 8px !important; + } + + + .yashe_wikiBtnAfter{ + margin-right: 14px !important; + margin-left: -3px !important; + } + + + .yashe_stopBtn{ + margin-right: 10px; + margin-left: -1px !important; + fill: red !important; + } + + .yashe_stopBtn:hover{ + filter: + invert(0) + sepia(0) + hue-rotate(0deg) + saturate(0) + brightness(0) !important; } \ No newline at end of file diff --git a/src/scss/cssIncludes/themes/_darkTheme.scss b/src/scss/cssIncludes/themes/_darkTheme.scss index 6fd4aa0e..5811d4ee 100755 --- a/src/scss/cssIncludes/themes/_darkTheme.scss +++ b/src/scss/cssIncludes/themes/_darkTheme.scss @@ -7,9 +7,9 @@ } -.cm-s-dark .cm-shape {color: #68BEEB;} +.cm-s-dark .cm-shape {color: #8fd5fa;} -.cm-s-dark .cm-keyword {color: #f00;} +.cm-s-dark .cm-keyword {color: #ff5656;} .cm-s-dark .cm-atom {color: #219;} .cm-s-dark .cm-number {color: #E5F439;} .cm-s-dark .cm-def {color: #00f;} @@ -17,26 +17,25 @@ .cm-s-dark .cm-punctuation, .cm-s-dark .cm-property, .cm-s-dark .cm-operator {color: #05a;} -.cm-s-dark .cm-variable-2 {color: #68BEEB;} -.cm-s-dark .cm-variable-3 {color: #68BEEB;} +.cm-s-dark .cm-variable-3 {color: #8fd5fa;} .cm-s-dark .cm-comment {color: #999;} -.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-facet {color: #f00;} -.cm-s-dark .cm-shapeRef {color:#68BEEB;} +.cm-s-dark .cm-string {color: #b98003;} +.cm-s-dark .cm-string-2 {color: #a1df67;} +.cm-s-dark .cm-constraint {color: #a1df67;} +.cm-s-dark .cm-valueSet {color: #a1df67;} +.cm-s-dark .cm-constraintKeyword {color: #ff5656;} +.cm-s-dark .cm-facet {color: #ff5656;} +.cm-s-dark .cm-shapeRef {color:#8fd5fa;} .cm-s-dark .cm-meta {color: #555;} .cm-s-dark .cm-qualifier {color: #555;} .cm-s-dark .cm-builtin {color: #30a;} .cm-s-dark .cm-bracket {color: #997;} .cm-s-dark .cm-tag {color: #170;} .cm-s-dark .cm-attribute {color: #00c;} -.cm-s-dark .cm-hr {color: #999;} +.cm-s-dark .cm-hr {color: #e42727;} .cm-s-dark .cm-link {color: #00c;} .cm-s-dark .cm-punc {color: #FFFFFF;} -.cm-s-dark .cm-logical {color:#B271FF;} +.cm-s-dark .cm-logical {color:#ff5656;} .cm-s-dark .cm-at {color:#68BEEB;} .cm-s-dark .cm-prefixDelcAlias {color:#f8c4ffc0;} .cm-s-dark .cm-prefixDelcIRI{color:#f8c4ffc0;} diff --git a/src/scss/yashe.scss b/src/scss/yashe.scss index caac5882..e57f31c8 100755 --- a/src/scss/yashe.scss +++ b/src/scss/yashe.scss @@ -20,17 +20,23 @@ color: red; font-weight: bold; float:left; - } + } + + .notification{ + color: #999; + background-color: #f7f7f7; + position: absolute; + padding: 0px 5px; + right: 1.5%; + bottom: 0px; + font-size: 90%; + } - .completionNotification { - color: #999; - background-color: #f7f7f7; - position: absolute; - padding: 0px 5px; - right: 0px; - bottom: 0px; - font-size: 90%; - } + .completionNotification {} + + .wikiFormatNotification{} + + .prettyNotification{} @@ -71,5 +77,3 @@ height: 18px; vertical-align: middle; } - - diff --git a/src/utils/buttonsUtils.js b/src/utils/buttonsUtils.js index 38a859a7..fe696b3f 100755 --- a/src/utils/buttonsUtils.js +++ b/src/utils/buttonsUtils.js @@ -9,9 +9,6 @@ var drawButtons = function(yashe){ yashe.buttons = $("
").appendTo($(yashe.getWrapperElement())); - /** - * upload button - */ var uploadButton = $("
", { class: "downloadBtns" }).append($('{utils.readFile(yashe)})); - /** - * download button - */ - + var downloadButton = $("
", { class: "downloadBtns" }) @@ -54,10 +48,7 @@ var drawButtons = function(yashe){ }) ); - /** - * copy button - */ - + var copyButton = $("
", { class: "downloadBtns" }) @@ -70,10 +61,7 @@ var drawButtons = function(yashe){ Codemirror.signal(yashe,'copy'); })) - - /** - * delete button - */ + var deleteButton = $("
", { class: "downloadBtns" }).append($(yutils.svg.getElement(imgs.delete)) @@ -86,9 +74,6 @@ var drawButtons = function(yashe){ })); - /** - * theme button - */ var themeButton = $("
", { class: "downloadBtns" }).append($(yutils.svg.getElement(imgs.theme)) @@ -108,24 +93,21 @@ var drawButtons = function(yashe){ yashe.setOption("theme",themeValue) //Change fill of buttons - $('#shareBtn').css('fill', color) - $('#uploadBntLabel').css('fill', color) - $('#downloadBtn').css('fill', color) - $('#copyBtn').css('fill', color) - $('#deleteBtn').css('fill', color) - $('#themeBtn').css('fill', color) - $('#fullBtn').css('fill', color) - $('#smallBtn').css('fill', color) + $('#shareBtn').css('fill', color); + $('#wikiBtn').css('fill', color); + $('#wikiBtn').css('fill', color); + $('#uploadBntLabel').css('fill', color); + $('#downloadBtn').css('fill', color); + $('#copyBtn').css('fill', color); + $('#deleteBtn').css('fill', color); + $('#themeBtn').css('fill', color); + $('#fullBtn').css('fill', color); + $('#smallBtn').css('fill', color); Codemirror.signal(yashe,'themeChange'); })) - - - /** - * fullscreen button - */ var toggleFullscreen = $("
", { class: "fullscreenToggleBtns" }) @@ -152,7 +134,7 @@ var drawButtons = function(yashe){ - var shareLinkBtn = $("
", { + var shareLinkBtn = $("
", { class: "downloadBtns" }).append($(yutils.svg.getElement(imgs.share)) .addClass("yashe_shareBtn") @@ -167,13 +149,32 @@ var drawButtons = function(yashe){ })); + var wikiBtn = $("
", { + class: "downloadBtns" + }).append($(yutils.svg.getElement(imgs.tag)) + .addClass("yashe_wikiBtn") + .attr('id','wikiBtn') + .attr("title", "Generate Wikidata Comments") + .click(function() { + !yashe.wikiFormatInProgress ? + yashe.wikiformat() : + yashe.stopWikiFormat(); + })); + + + + //Draw buttons if(yashe.options.showShareButton){ - yashe.buttons.append(shareLinkBtn); + yashe.buttons.append(shareLinkBtn); } + if(yashe.options.showWikiBtn){ + yashe.buttons.append(wikiBtn); + } + if(yashe.options.showUploadButton){ yashe.buttons.append(uploadButton); } diff --git a/src/utils/constUtils.js b/src/utils/constUtils.js index 8dc7d4b4..3e8ea274 100644 --- a/src/utils/constUtils.js +++ b/src/utils/constUtils.js @@ -1,10 +1,11 @@ // Symbols const OPENING_PARENTHESIS = '('; const CLOSING_PARENTHESIS = ')'; -const OPENING_CURLY_BRACKET= '{'; -const CLOSING_CURLY_BRACKET= '}'; -const OPENING_SQUARE_BRACKET= '['; -const CLOSING_SQUARE_BRACKET= ']'; +const OPENING_CURLY_BRACKET = '{'; +const CLOSING_CURLY_BRACKET = '}'; +const OPENING_SQUARE_BRACKET = '['; +const CLOSING_SQUARE_BRACKET = ']'; +const LOGICAL_OR = '|'; const SEMICOLON=';'; const DOLLAR = '$'; const AMPERSAND = '&'; @@ -41,7 +42,10 @@ module.exports ={ CLOSING_CURLY_BRACKET:CLOSING_CURLY_BRACKET, OPENING_SQUARE_BRACKET:OPENING_SQUARE_BRACKET, CLOSING_SQUARE_BRACKET:CLOSING_SQUARE_BRACKET, + LOGICAL_OR:LOGICAL_OR, + DOLLAR:DOLLAR, SEMICOLON:SEMICOLON, + AMPERSAND:AMPERSAND, EQUALS:EQUALS, SHAPE_TYPE:SHAPE_TYPE, diff --git a/src/utils/formatUtils.js b/src/utils/formatUtils.js index 5d38a5da..51f5d911 100755 --- a/src/utils/formatUtils.js +++ b/src/utils/formatUtils.js @@ -1,5 +1,8 @@ -var CodeMirror = require("codemirror") -const $ = require('jquery') +const CodeMirror = require("codemirror"); +const $ = require('jquery'); +const wikiUtils = require('../utils/wikiUtils.js'); +let interact = require("./interactUtils.js"); + "use strict"; var commentLines = function(yashe) { @@ -155,32 +158,80 @@ var copyLineDown = function(yashe) { }; - var wikiFormat = function(yashe){ + var wikiFormat = async function(yashe){ + if(yashe.hasErrors()){ + interact.showErrAlertMsg(yashe); + return; + } - - for (var l = 7; l < yashe.lineCount(); ++l) { - let lineTokens = yashe.getLineTokens(l); - let nonWs = getNonWsLineTokens(lineTokens) + interact.startWikiFormat(yashe); + yashe.prettify(); + let history = interact.disableEditor(yashe); + for (var l = 0; l < yashe.lineCount(); ++l) { + let lineTokens = getNonWsLineTokens(yashe.getLineTokens(l)); + let valueSetSize = getValueSetSizeIfClosed(lineTokens); + let comments = ' # '; for(let t in lineTokens){ + if(!yashe.wikiFormatInProgress){ + interact.stopWikiFormat(yashe,history); + return; + } let token = lineTokens[t]; - //console.log(next) - if(token.string.split(':')[0]=='wd' && !token.skip){ - console.log(token) - - //console.log({token:token,t:t,length:lineTokens.length,next:next}) - //console.log({line:l,col:{start:token.start,end:token.end},string:token.string}) - - yashe.replaceRange(token.string+" #human \n",{line:l,ch:token.start},{line:l,ch:token.end}) - - - - + if(wikiUtils.isWikidataPrefix(yashe,token)){ + let entity = token.string.split(':')[1].toUpperCase(); + let result = await wikiUtils.getEntity(entity,wikiUtils.wikidataEndpoint); + if(result.entities){ + let entityData = wikiUtils.getEntityData(entity,result); + if(entityData){ + comments += ' '+entityData.title; + valueSetSize--; + } + } + } + + if(isLastToken(t,lineTokens) && comments!=' # '){ + let endOfLine = lineTokens[lineTokens.length-1].end + yashe.replaceRange(comments,{line:l,ch:endOfLine},{line:l,ch:endOfLine}) + if(yashe.hasErrors(yashe))yashe.undo(); + //For some reason I'm not able to make codemirror scroll methods work, so I'm forcing the scroll with the cursor + yashe.setCursor({line:l+10,ch:token.start}); + valueSetSize = 0; + comments = ''; } } + } + interact.stopWikiFormat(yashe,history); + } + + var isLastToken = function(token,tokens){ + return token == tokens.length-1; } + /** + * Gets an array of linetokens. If the line closes the valueSet ']' return its size, otherwise 0 + * @param {Array} lineTokens + */ + var getValueSetSizeIfClosed = function(lineTokens){ + let open = false; + let close = false; + let decrement = true; + let size = lineTokens.reduce((acc,t)=>{ + if(t.string=='[')open=true; + if(t.string==']')close=true; + if(t.type=='valueSet')acc++; + if(t.type=='variable-3')decrement=false; + if(t.type=='string-2')decrement=false; + return acc; + },1) + + if(decrement)size--; + if(open && close)return size; + return 1; + } + + var getNonWsLineTokens = function(lineTokens){ return lineTokens.reduce((acc,t)=>{ if(t.type!='ws')acc.push(t); @@ -188,23 +239,13 @@ var copyLineDown = function(yashe) { },[]); } - var getNextNonWSLineToken = function(yashe,lineTokens,lineIndex){ - let i = 1; - let token = lineTokens[lineIndex+i]; - //console.log(token) - while(token && token.type=='ws'){ - i++; - token = lineTokens[lineIndex+i]; - } - return token; - } - module.exports = { commentLines:commentLines, copyLineUp: copyLineUp, copyLineDown: copyLineDown, doAutoFormat:doAutoFormat, + getNonWsLineTokens:getNonWsLineTokens, wikiFormat:wikiFormat }; \ No newline at end of file diff --git a/src/utils/imgs.js b/src/utils/imgs.js index a700906a..5e06a7a7 100755 --- a/src/utils/imgs.js +++ b/src/utils/imgs.js @@ -10,6 +10,8 @@ module.exports = { delete:'', theme:'', endpoint:'', + tag:'', + stop:'' }; diff --git a/src/utils/interactUtils.js b/src/utils/interactUtils.js new file mode 100644 index 00000000..bb102b35 --- /dev/null +++ b/src/utils/interactUtils.js @@ -0,0 +1,59 @@ +let yutils = require("yasgui-utils"); +let imgs = require("./imgs.js"); +let wikiNotification = $("
"); + +var showErrAlertMsg = function(yashe){ + wikiNotification + .show() + .text("I can't do that...Fix the errors before") + .appendTo($(yashe.getWrapperElement())); + + setTimeout(() => { + wikiNotification.hide() + }, 3000); +} + +var startWikiFormat = function(yashe){ + yashe.wikiFormatInProgress = true; + $('#wikiBtn').attr("title", "STOP"); + $('#wikiBtn').empty(); + $('#wikiBtn').append($(yutils.svg.getElement(imgs.stop))); + $('#wikiBtn').removeClass("yashe_wikiBtn"); + $('#wikiBtn').removeClass("yashe_wikiBtnAfter"); + $('#wikiBtn').addClass("yashe_stopBtn"); + wikiNotification.show().text("Adding Wikidata Comments").appendTo($(yashe.getWrapperElement())); +} + +var stopWikiFormat = function(yashe,history){ + yashe.wikiFormatInProgress = false; + setTimeout(() => { //Just to wait until the last comment is setted + $('#wikiBtn').attr("title", "Generate Wikidata Comments"); + $('#wikiBtn').empty(); + $('#wikiBtn').removeClass("yashe_stopBtn"); + $('#wikiBtn').addClass("yashe_wikiBtnAfter"); + $('#wikiBtn').append($(yutils.svg.getElement(imgs.tag))); + wikiNotification.hide(); + yashe.prettify(); + enableEditor(yashe,history); + }, 400); +} + +var disableEditor = function(yashe){ + yashe.setOption('readOnly',true); + return yashe.getHistory(); +} +var enableEditor = function(yashe,history){ + yashe.setHistory(history); + yashe.setOption('readOnly',false); +} + + + +module.exports ={ + startWikiFormat:startWikiFormat, + stopWikiFormat:stopWikiFormat, + enableEditor:enableEditor, + disableEditor:disableEditor, + showErrAlertMsg:showErrAlertMsg + +} \ No newline at end of file diff --git a/src/utils/pretty/node.js b/src/utils/pretty/node.js index 0b1ec560..8e8d6c94 100644 --- a/src/utils/pretty/node.js +++ b/src/utils/pretty/node.js @@ -1,17 +1,19 @@ class Node{ - constructor(constraints,triples,comment='',emptyBrackets,afterTriples=[],finalParenthesis=''){ + constructor(constraints,triples,comment='',emptyBrackets,afterTriples=[],finalParenthesis='',multiElementOneOf=false){ this.constraints = constraints; this.triples = triples; - this.comment = comment; //Comment at the end - this.emptyBrackets = emptyBrackets; //ej: schema:name {}; - this.afterTriples= afterTriples; // Whatever after {} - this.finalParenthesis = finalParenthesis; //Is an + this.comment = comment; //Comment at the end + this.emptyBrackets = emptyBrackets; //ej: schema:name {}; + this.afterTriples= afterTriples; // Whatever after {} + this.finalParenthesis = finalParenthesis; + this.hasAleardyAComment = false; //This is used in the methor getSemicolonIfNeeded due not to set the comment again if it has been already seted + this.multiElementOneOf = multiElementOneOf; } - toString(longest,isTriple,indent=1,isLastTriple=false){ + toString(longest=0,isTriple,indent=1,isLastTriple=false){ let str = EMPTY_STRING; - let constraints=this.getConstraints(longest,indent); + let constraints=this.getConstraints(this.constraints,longest,indent); str+=constraints.str; str+=this.getTriplesString(indent,constraints.tripleComment,isTriple,isLastTriple); @@ -19,22 +21,32 @@ class Node{ } //This method could be prettier - getConstraints(longest,indent){ - let valueSetSize = getValueSetSize(this.constraints); + getConstraints(constraints,longest,indent){ + let valueSetSize = getValueSetSize(constraints); let forceSeparator = false; let valueSet = false; - return this.constraints.reduce((acc,token,index)=>{ - let nexToken = this.constraints[index+1]; - let separator = getSeparatorIfNeeded(index,token,nexToken,this.triples.length,longest,this.constraints,this.emptyBrackets); + let previousToken; + return constraints.reduce((acc,token,index)=>{ + + if(token.skip)return acc; + + let nexToken = constraints[index+1]; + let separator = getSeparatorIfNeeded(index,token,nexToken,this.triples.length,longest,constraints,this.emptyBrackets); if(token.type==COMMENT_TYPE){ - - if(valueSet){ + //console.log({previousToken:previousToken.string,token:token.string,nexToken:nexToken}) + if(previousToken && previousToken.string=='[' && valueSetSize>2){ + acc.str+= token.string; + }else if(nexToken && nexToken.string=='[' && valueSetSize>2){ + acc.str+= '[ '+token.string; + nexToken.skip = true; + }else if(valueSet){ + acc.str+= token.string; - acc.str += this.getClosingValueSetIfNeeded(nexToken,valueSet,indent); + acc.str+= this.getClosingValueSetIfNeeded(nexToken,valueSet,indent); }else{ forceSeparator = this.startsWithComment(index);//If it's a comment before the constraints skip it - acc.tripleComment+= this.getTripleComment(forceSeparator,token); //If not, add it to the finish of the line + acc.tripleComment = this.getTripleComment(forceSeparator,token) + acc.tripleComment ; //If not, add it to the finish of the line } @@ -43,13 +55,15 @@ class Node{ index = this.decrementIndexIfNeeded(forceSeparator); separator = this.modifySeparatorIfNeeded(separator,nexToken,valueSetSize); - valueSet = this.isLongValueSet(token,valueSetSize); - acc.str += this.getOpeningValueSetIfNeeded(valueSet,indent); + valueSet = this.isValueSet(token,valueSetSize); + acc.str += this.getOpeningValueSetIfNeeded(valueSet,indent,nexToken); acc.str += this.getWhiteSpaceIfNeeded(token); acc.str += this.getTokenString(token,separator); acc.str += this.getClosingValueSetIfNeeded(nexToken,valueSet,indent); } + + previousToken = token; return acc; },{ str:EMPTY_STRING, @@ -61,10 +75,9 @@ class Node{ getTriplesString(indent,tripleComment,isTriple,isLastTriple){ let str = EMPTY_STRING; - str += this.getSubTriplesStrIfNeeded(indent,tripleComment,isTriple); str += this.getEmptyBracketsIfNeeded(); - str += this.getAfterTriplesStr(); + str += this.getAfterTriplesStr(indent); str += this.getSemicolonIfNeeded(isTriple,isLastTriple,tripleComment); str += this.getFinalParenthesisIfNeeded(); @@ -76,12 +89,18 @@ class Node{ let str = EMPTY_STRING; if(this.triples.length>0){ let linebreak = LINE_BREAK; - if(isTriple && this.triples.length==1){ - if(tripleComment==EMPTY_STRING){// If there is any comment after '{' we need to force the breakline - linebreak = EMPTY_STRING; - indent--; + // This is off at this moment + /* if(isTriple){ + if(this.triples.length==1) { + console.log('p') + // If there isn't any comment after '{' don't force the breakline + if(tripleComment==EMPTY_STRING && !this.hasComments(this.triples[0])){ + linebreak = EMPTY_STRING; + indent--; + } } - } + } */ + str+=this.getSubTriplesStr(indent,tripleComment,linebreak); } return str; @@ -89,30 +108,39 @@ class Node{ getSubTriplesStr(indent,tripleComment,linebreak){ + this.hasAleardyAComment=true; let str=OPENING_CURLY_BRACKET+tripleComment+linebreak; + if(tripleComment!='')tripleComment=''; this.triples.map((t,index)=>{ let currentLongest = getLongestTConstraint(this.triples); str+= getIndent(indent); str+= t.toString(currentLongest,true,indent+1,this.isLastTriple(index)); - str+= WHITE_SPACE+t.comment +linebreak; + str+= WHITE_SPACE + t.comment +linebreak; }) return str + getIndent(indent-1)+CLOSING_CURLY_BRACKET; } - getAfterTriplesStr(){ + getAfterTriplesStr(indent){ let str = EMPTY_STRING; - if(this.afterTriples.length>0)str+=WHITE_SPACE; - return this.afterTriples.reduce((acc,a)=>{ - return acc+=a.string+WHITE_SPACE; - },str); + if(this.afterTriples.length>0){ + str+=WHITE_SPACE; + }else{ + return ''; + } + let constraints = this.getConstraints(this.afterTriples,0,indent); + return constraints.str+constraints.tripleComment; } + + getSemicolonIfNeeded(isTriple,isLastTriple,tripleComment){ let str = EMPTY_STRING; if(isTriple){ - if(!isLastTriple)str+=SEMICOLON; - str+=tripleComment; + if(!isLastTriple){ + if(!this.multiElementOneOf)str+=SEMICOLON; + } + if(!this.hasAleardyAComment)str+=tripleComment; } return str; } @@ -148,7 +176,7 @@ class Node{ return token.string+separator; } - isLongValueSet(token,valueSetSize){ + isValueSet(token,valueSetSize){ return token.type==VALUESET_TYPE && valueSetSize>VALUESET_LINE_LIMIT; } @@ -158,7 +186,7 @@ class Node{ return index; } - getOpeningValueSetIfNeeded(valueSet,indent){ + getOpeningValueSetIfNeeded(valueSet,indent,nexToken){ if(valueSet) return LINE_BREAK+getIndent(indent); return EMPTY_STRING; @@ -185,7 +213,14 @@ class Node{ } + hasComments(triple){ + return triple.constraints.reduce((acc,c)=>{ + if(c.type=='comment' && c.start)acc = true; //c.start just to check it's a real comment token + return acc; + },false) + } + } @@ -200,7 +235,7 @@ let { WHITE_SPACE, EMPTY_STRING, VALUESET_LINE_LIMIT, - EMPTY_BRACKETS, + EMPTY_BRACKETS } = require('./printUtils.js'); let { @@ -214,4 +249,4 @@ let { VALUESET_TYPE, AND_KEYWORD, OR_KEYWORD -} = require('../constUtils.js'); +} = require('../constUtils.js'); \ No newline at end of file diff --git a/src/utils/pretty/prettyUtils.js b/src/utils/pretty/prettyUtils.js index f9f60feb..e53ab83f 100644 --- a/src/utils/pretty/prettyUtils.js +++ b/src/utils/pretty/prettyUtils.js @@ -8,39 +8,47 @@ function prettify(yashe){ let tokens = getTokens(yashe); // Objects - let firstComments = getFirstComments(tokens); - let directivesAndStarts = getDirectivesAndStarts(tokens); + let initialComments = getFirstComments(tokens); + let initialDirectivesAndStarts = getInitialDirectivesAndStarts(tokens); let shapes = getShapes(tokens); + console.log(shapes) // Strings - let directivesStr = getDirectivesAndStartsStr(directivesAndStarts); + let initialDirectivesAndStartsStr = getDirectivesAndStartsStr(initialDirectivesAndStarts); let shapesStr = getShapesStr(shapes); - let prettified = firstComments+directivesStr+shapesStr; + let prettified = initialComments+initialDirectivesAndStartsStr+shapesStr; // Is there any change? // It is true that without this check the user // wouldn't appreciate the difference but yashe // would be doing operations that would appear - // in the undo stack + // in the undo/redo stack if(previousValue!=prettified){ yashe.setValue(prettified) ; + prettifyComments(); setCursor(yashe,cursorPosition); } + } function getShapes(tokens){ return getShapesTokens(tokens).reduce((acc,shapeTokens)=>{ let nodes = getNodes(shapeTokens); let comments = getCommentsAfterShape(shapeTokens); - - acc.push(new Shape(nodes,comments)); + let prefixes = getPrefixesAfterShape(shapeTokens); + + acc.push(new Shape(nodes,comments,prefixes)); return acc; },[]) } +function getPrefixesAfterShape(shapeTokens){ + return getDirectivesAndStartsStr(getDirectivesAndStarts(shapeTokens.reverse())); +} + function getNodes(shapeTokens){ - return getSlots(shapeTokens).reduce((acc,slot,index)=>{ + return getSlots(shapeTokens).reduce((acc,slot)=>{ let constraints = getBeforeTriplesTokens(slot); let triples = getTriples(getTripleTokens(slot)); let paranthesis = hasFinalParenthesis(slot); @@ -68,13 +76,17 @@ function hasFinalParenthesis(slot){ function getCommentsAfterShape(shapeTokens){ let i = 0; return shapeTokens.reverse().reduce((acc,t,index)=>{ + if(t.type==COMMENT_TYPE && index == i){ //index == i is needed in order not to take comments after a differtent token (CLOSING_CURLY_BRACKET) - acc.push(t); + if(!isDirective(shapeTokens[index+1])){//check that it's not a directive comment + acc.push(t); + } i++; } + if(isDirective(t) || isStart(t,shapeTokens[index+1])){ - i++; + i++ } return acc; @@ -92,17 +104,18 @@ function getTriples(tokens) { if(token.skip) return acc; //Is a comment that is part of the previous triple singleTriple.push(token); - - if(isFinishOfTriple(tokens,token,index,finish)){ + let multiElementOneOf = isMultiElementOneOf(token); + if(isFinishOfTriple(tokens,token,index,finish) || multiElementOneOf){ if(singleTriple.length>1){ + console.log(singleTriple) let before = getBeforeTriplesTokens(singleTriple); let tripleTokens = getTripleTokens(singleTriple); let subTriples = getTriples(tripleTokens); - let after = getAfterTripleTokens(singleTriple); + let after = getAfterTripleTokens(singleTriple,multiElementOneOf); let comment = getComentsAfterToken(token,tokens,index); //We want the tokens after the Triple let emptyBrackets = start && subTriples.length==0; - - acc.push(new Node(before,subTriples,comment,emptyBrackets,after)); + + acc.push(new Node(before,subTriples,comment,emptyBrackets,after,'',multiElementOneOf)); start=false; } singleTriple = []; @@ -121,10 +134,11 @@ function getTriples(tokens) { },[]) } -function getAfterTripleTokens(tokens){ + +function getAfterTripleTokens(tokens,multiElementOneOf){ let start=false; let open = 0; - return tokens.reduce((acc,t)=>{ + let after = tokens.reduce((acc,t)=>{ if(open == 0 && start){ if(t.string != SEMICOLON @@ -143,6 +157,9 @@ function getAfterTripleTokens(tokens){ return acc; },[]) + + if(after.length==0 && multiElementOneOf)after.push(tokens[tokens.length-1]); + return after; } @@ -157,7 +174,7 @@ function getBeforeTriplesTokens(tokens){ start = false; } - if(index == tokens.length-1 && t.string!='.')start=false; //Break condition 2 + if(index == tokens.length-1 && t.string!='.' && t.string!=']')start=false; //Break condition 2 -> If it's the last token break unless it's a . or ] which we want it if(start){ acc.push(t); @@ -248,10 +265,15 @@ function getTokens(){ } +function getInitialDirectivesAndStarts(tokens){ + return getDirectivesAndStarts(tokens,SHAPE_TYPE); +} + + /** Sorry Acebal */ -function getDirectivesAndStarts(tokens){ +function getDirectivesAndStarts(tokens,breakCondition){ let prefix = {}; let base = {}; let importt = {}; @@ -259,7 +281,13 @@ function getDirectivesAndStarts(tokens){ let baseCont = 0; let importCont = 0; let startCont = 0; + let stop = false; return tokens.reduce((acc,t,index)=>{ + + if(stop)return acc; + if(t.type == breakCondition)stop=true; + + if(t.string.toUpperCase()==PREFIX_KEYWORD){ prefix = {}; prefix.comments = getComentsAfterToken(t,tokens,index); @@ -377,6 +405,7 @@ function getFirstComments(tokens){ } function isDirective(token) { + if(!token)return false; if( token.string.toUpperCase()==PREFIX_KEYWORD || token.string.toUpperCase()==BASE_KEYWORD || token.string.toUpperCase()==IMPORT_KEYWORD @@ -427,6 +456,47 @@ function setCursor(yashe,position){ } } + +function prettifyComments(){ + let longest = getLongestCommentedLine(); + let history = yashe.getHistory(); + for (var l = 0; l < yashe.lineCount(); ++l) { + let lineTokens = formatUtils.getNonWsLineTokens(yashe.getLineTokens(l)); + if(!hasOnlyComments(lineTokens)){ + lineTokens.map(t=>{ + if(t.type == 'comment') { + yashe.replaceRange(printUtils.getSeparator(longest-t.start)+t.string,{line:l,ch:t.start},{line:l,ch:t.end}) + } + }); + } + } + yashe.setHistory(history); +} + + +function getLongestCommentedLine(){ + let longest = 0; + for (var l = 0; l < yashe.lineCount(); ++l) { + let lineTokens = formatUtils.getNonWsLineTokens(yashe.getLineTokens(l)); + let lastLineToken = lineTokens[lineTokens.length-1]; + if(lastLineToken) + if(lastLineToken.start>longest) + longest = lastLineToken.start; + } + return longest; +} + +/** + * Returns true if the line has onlyComments + */ +function hasOnlyComments(lineTokens){ + return lineTokens.reduce((acc,t)=>{ + if(t.type!='comment')acc=false; + return acc; + },true); +} + + function isCursorToken(token1,token2,line){ return token1.start == token2.start && token1.end == token2.end @@ -452,6 +522,10 @@ function getNonWsTokens(tokens){ }) } +function isMultiElementOneOf(token){ + return token.string == LOGICAL_OR; +} + module.exports = { prettify:prettify, @@ -460,6 +534,7 @@ module.exports = { let Shape = require('./shape.js'); let Node = require('./node.js'); +let formatUtils = require('../formatUtils.js'); let { getLongestPrefix, getSeparator, @@ -470,6 +545,7 @@ let { OPENING_CURLY_BRACKET, CLOSING_CURLY_BRACKET, CLOSING_PARENTHESIS, + LOGICAL_OR, SEMICOLON, EQUALS, @@ -490,4 +566,5 @@ let { AND_KEYWORD, OR_KEYWORD, START_KEYWORD -} = require('../constUtils.js'); \ No newline at end of file +} = require('../constUtils.js'); +const printUtils = require('./printUtils.js'); diff --git a/src/utils/pretty/printUtils.js b/src/utils/pretty/printUtils.js index 005106c0..3a493e69 100644 --- a/src/utils/pretty/printUtils.js +++ b/src/utils/pretty/printUtils.js @@ -32,7 +32,7 @@ function getIndent(tab) { function getLongestPrefix(prefixes){ return prefixes.reduce((acc,p) =>{ - if(p.alias.string.length>acc)acc=p.alias.string.length; + if(p.alias && p.alias.string.length>acc)acc=p.alias.string.length; return acc; },0); } @@ -51,6 +51,7 @@ function getLongestTConstraint(triples){ } + function needsSeparator(index,token,nexToken,triplesLenght,constraints,emptyBrackets){ if(isJustEmptyBrackets(triplesLenght,emptyBrackets,constraints))return true; return index==0 @@ -116,8 +117,11 @@ function getDirectivesAndStartsStr(directives) { function getPrefixesStr(prefixes,keyword){ return prefixes.reduce((acc,p)=>{ - let dif = getLongestPrefix(prefixes) - p.alias.string.length; - return acc+= keyword+p.alias.string+getSeparator(dif)+p.iri.string+p.comments+'\n'; + if(p.alias){ + let dif = getLongestPrefix(prefixes) - p.alias.string.length; + return acc+= keyword+p.alias.string+getSeparator(dif)+p.iri.string+p.comments+'\n'; + } + return acc; },''); } @@ -131,12 +135,12 @@ function getConcreteDirectiveStr(directives,keyword) { function getStartsStr(starts) { return starts.reduce((acc,s)=>{ return acc+=s+"\n"; - },"")+'\n'; + },""); } function getShapesStr(shapes) { return shapes.reduce((acc,s)=>{ - return acc+=s.toString()+"\n\n"; + return acc+='\n'+s.toString()+'\n'; },''); } diff --git a/src/utils/pretty/shape.js b/src/utils/pretty/shape.js index cfb083ae..015432e5 100644 --- a/src/utils/pretty/shape.js +++ b/src/utils/pretty/shape.js @@ -1,8 +1,9 @@ class Shape{ - constructor(nodes,comments=[]){ + constructor(nodes,comments=[],directivesAndStarts){ this.nodes = nodes; this.comments = comments; + this.directivesAndStarts = directivesAndStarts; } getCommentsStr(){ @@ -11,9 +12,16 @@ class Shape{ },""); } + getDirectivesAndStartsStr(){ + let str = ''; + if(this.directivesAndStarts.trim()!='') + str = '\n\n'+this.directivesAndStarts; + return str; + } + toString(){ return this.nodes.reduce((acc,n)=>{ - return acc+=n.toString(0) + this.getCommentsStr(); + return acc+=n.toString() + this.getCommentsStr() + this.getDirectivesAndStartsStr(); },""); } } diff --git a/src/utils/syntaxUtils.js b/src/utils/syntaxUtils.js index 82caec2b..48d3b134 100755 --- a/src/utils/syntaxUtils.js +++ b/src/utils/syntaxUtils.js @@ -11,8 +11,12 @@ var checkSyntax = function(yashe) { resetValues(yashe); var state = null; - let openTokensCounter = 0; - let closedTokensCounter = 0; + let openBracketsCounter = 0; + let closedBracketsCounter = 0; + let openParenthesisCounter = 0; + let closedParenthesisCounter = 0; + let openSquareBracketsCounter = 0; + let closedSquareBracketsCounter = 0; for (var l = 0; l < yashe.lineCount(); ++l) { var precise = false; @@ -66,6 +70,7 @@ var checkSyntax = function(yashe) { warningEl.className = "parseErrorIcon"; yashe.setGutterMarker(l, "gutterErrorBar", warningEl); + yashe.queryValid = false; return false; } @@ -73,25 +78,54 @@ var checkSyntax = function(yashe) { let lineTokens = yashe.getLineTokens(l); for(let t in lineTokens){ let token = lineTokens[t]; - //This is only necessary to verify the if the last '}' is missing (See #104) + if(token.string=='{'){ - openTokensCounter++; + openBracketsCounter++; } if(token.string=='}'){ - closedTokensCounter++; + closedBracketsCounter++; + } + + if(token.string=='('){ + openParenthesisCounter++; + } + if(token.string==')'){ + closedParenthesisCounter++; } + + if(token.string=='['){ + openSquareBracketsCounter++; + } + if(token.string==']'){ + closedSquareBracketsCounter++; + } + } updateShapesAndPrefixes(yashe,l); } - //Is last '}' missing? (See #104) - if(openTokensCounter != closedTokensCounter){ + //Is last '}' missing? (See #104 https://github.com/weso/YASHE/issues/104) + if(openBracketsCounter != closedBracketsCounter){ setError(yashe.lastLine(),"This line is invalid. Expected: '}'",yashe) yashe.queryValid = false; return false; } + //Is last ')' missing? (See #150 https://github.com/weso/YASHE/issues/150) + if(openParenthesisCounter != closedParenthesisCounter){ + setError(yashe.lastLine(),"This line is invalid. Expected: ')'",yashe) + yashe.queryValid = false; + return false; + } + + //Is last ']' missing? (See #163 https://github.com/weso/YASHE/issues/163) + if(openSquareBracketsCounter != closedSquareBracketsCounter){ + setError(yashe.lastLine(),"This line is invalid. Expected: ']'",yashe) + yashe.queryValid = false; + return false; + } + if(!checkPrefixes(yashe))return false; @@ -119,8 +153,7 @@ var checkSyntax = function(yashe) { let token = lineTokens[t]; - if(token.type=='string-2' || - token.type=='constraint'){ + if(token.type=='string-2'|| (token.type=='constraint' && token.string.includes(":"))){ yashe.usedPrefixes.push({ alias:token.string.split(":")[0]+':', line:l }); @@ -166,7 +199,6 @@ var checkSyntax = function(yashe) { } - /** * Check if the ShapeRefs are defined @@ -219,6 +251,14 @@ var checkSyntax = function(yashe) { yashe.setGutterMarker(line, "gutterErrorBar", warningEl); } + + var reCheckSyntax = function(yashe){ + setTimeout(() => { + checkSyntax(yashe); + }, 400); + } + module.exports = { - checkSyntax:checkSyntax + checkSyntax:checkSyntax, + reCheckSyntax:reCheckSyntax }; diff --git a/src/utils/tooltipUtils.js b/src/utils/tooltipUtils.js index 4c3594f1..69e53deb 100755 --- a/src/utils/tooltipUtils.js +++ b/src/utils/tooltipUtils.js @@ -1,6 +1,6 @@ "use strict"; var $ = require("jquery"), - rdfUtils = require('./rdfUtils.js') + wikiUtils = require('./wikiUtils.js') /** * Write our own tooltip, to avoid loading another library for just this functionality. For now, we only use tooltip for showing parse errors, so this is quite a tailored solution @@ -56,13 +56,13 @@ var triggerTooltip = function(yashe, e) { var wikiElement = token.split(':')[1] if(wikiElement!== undefined && wikiElement!== ''){ - let endpoint = rdfUtils.getEndPoint(yashe,prefixName); + let endpoint = wikiUtils.getEndPoint(yashe,prefixName); if(endpoint!=null){ - checkEntity(wikiElement,endpoint) + wikiUtils.getEntity(wikiElement,endpoint) .done((data)=>{loadTooltip(yashe,data,wikiElement,posX,posY)}) .fail( ()=>{ - checkEntity(wikiElement,endpoint.replace('/w/','/wiki/')) + wikiUtils.getEntity(wikiElement,endpoint.replace('/w/','/wiki/')) .done((data)=>{loadTooltip(yashe,data,wikiElement,posX,posY)}) }); } @@ -71,42 +71,9 @@ var triggerTooltip = function(yashe, e) { } var loadTooltip = function(yashe,data,wikiElement,posX,posY){ - if(!data.error){ - - var userLang; - var entity = ''; - var description='' - var theme; - //Gets the preference languaje from the navigator - userLang = (navigator.language || navigator.userLanguage).split("-")[0] - - - var content = data.entities[wikiElement.toUpperCase()] - - //Check if the property/entity exist - if(!content.labels)return; - - //Some properties and entities are only avalible in English - //So if they do not exist we take it in English - if(content.labels[userLang] && content.descriptions[userLang]){ - - entity = content.labels[userLang].value +' ('+wikiElement+')' - description = content.descriptions[userLang].value - - }else{ - - let lb = content.labels['en']; - let desc = content.descriptions['en']; - if(lb){ - entity = lb.value +' ('+wikiElement+')'; - } - if(desc){ - description = desc.value - } - - } - - theme = yashe.getOption('theme'); + var entityData = wikiUtils.getEntityData(wikiElement,data); + if(entityData && entityData.title!=''){ + let theme = yashe.getOption('theme'); let cssStyle = themeStyles['default']; if(theme=='dark'){ cssStyle = themeStyles['dark']; @@ -124,23 +91,12 @@ var loadTooltip = function(yashe,data,wikiElement,posX,posY){ .append( $('
').css(cssStyle) .append( - $('
').html(entity).css(styles.title)) + $('
').html(entityData.title).css(styles.title)) .append( - $('
').html(description).css(styles.description))) + $('
').html(entityData.description).css(styles.description))) .appendTo('body').fadeIn( 'slow' ); } -} - -// U S A R M É T O D O P Á R A M S -var checkEntity = function (entity,endPoint){ - return $.get( - { - - url: endPoint+'api.php?action=wbgetentities&format=json&ids='+entity, - dataType: 'jsonp', - - }) - + } diff --git a/src/utils/rdfUtils.js b/src/utils/wikiUtils.js old mode 100755 new mode 100644 similarity index 66% rename from src/utils/rdfUtils.js rename to src/utils/wikiUtils.js index 9b587afd..4a539450 --- a/src/utils/rdfUtils.js +++ b/src/utils/wikiUtils.js @@ -38,7 +38,11 @@ const NAMESPACE_SHORTCUTS = { wdata: 'http://www.wikidata.org/wiki/Special:EntityData/' } -const WIKIDATA_ENDPOINT= 'https://www.wikidata.org/w/' +const WIKIDATA_ENDPOINT= 'https://www.wikidata.org/w/'; +const GET_ENTITY_QUERY = { + action:'wbgetentities', + format: 'json' +} @@ -103,13 +107,72 @@ var isWikidataPropertiesPrefix = function(yashe,prefixName){ return false } +var isWikidataPrefix = function(yashe,token){ + var prefixName = token.string.split(':')[0] + if(token.type == 'shape' || token.type=='string-2' || token.type=='constraint' || token.type=='valueSet'){ + if(isWikidataEntitiesPrefix(yashe,prefixName) + || isWikidataPropertiesPrefix(yashe,prefixName) + || getEndPoint(yashe,prefixName)!=null){ + return true + } + } + return false; +} + +var getEntity = function(entity,endpoint){ + GET_ENTITY_QUERY.ids = entity; + return $.get({ + url: endpoint+'api.php?'+$.param(GET_ENTITY_QUERY), + dataType: 'jsonp', + }); +} + +var getEntityData = function(element,data){ + var userLang; + var content; + var entityData = {title:'',description:''} + if(!data.error){ + //Gets the preference languaje from the navigator + userLang = (navigator.language || navigator.userLanguage).split("-")[0] + + content = data.entities[element.toUpperCase()] + + //Check if the property/entity exist + if(!content.labels)return; + + //Some properties and entities are only avalible in English + if(content.labels[userLang] && content.descriptions[userLang]){ + + entityData.title = content.labels[userLang].value +' ('+element+')' + entityData.description = content.descriptions[userLang].value + + }else{ //English by default + + let lb = content.labels['en']; + let desc = content.descriptions['en']; + if(lb){ + entityData.title = lb.value +' ('+element+')'; + } + if(desc){ + entityData.description = desc.value + } + + } + } + return entityData; +} + module.exports = { entityTypes:ENTITY_TYPES, namespaceShortCuts: NAMESPACE_SHORTCUTS, + wikidataEndpoint:WIKIDATA_ENDPOINT, getEndPoint:getEndPoint, + isWikidataPrefix:isWikidataPrefix, isWikidataEntitiesPrefix:isWikidataEntitiesPrefix, - isWikidataPropertiesPrefix:isWikidataPropertiesPrefix + isWikidataPropertiesPrefix:isWikidataPropertiesPrefix, + getEntity:getEntity, + getEntityData:getEntityData -} \ No newline at end of file +}