varScore;!function(r){r[r.TopicNumber=0]="TopicNumber",r[r.TopicScore=1]="TopicScore"}(Score||(Score={}));varHndJsSeWordList=function(){functionr(){this.words=[]}returnr.prototype.AddWord=function(r){this.words.push(r.toLowerCase())},r.prototype.Clear=function(){this.words=[]},r.prototype.Count=function(){returnthis.words.length},r.prototype.FindExact=function(r){returnr=r.toLowerCase(),this.words.indexOf(r)},r.prototype.FindPartial=function(r){r=r.toLowerCase();for(varo=0;o<this.words.length;o++)if(-1!==r.indexOf(this.words[o]))returno;return-1},r}(),HndJsSeResultScore=function(){functionr(){this.scores=[]}returnr.prototype.FindTopicIndex=function(r){for(varo=0;o<this.scores.length;o++){if(this.scores[o][Score.TopicNumber]===r)returno}return-1},r.prototype.AddTopics=function(r){varo=this;if(!r||!r.forEach)returnvoidconsole.error("Invalid AddTopics call");r.forEach(function(r){if(!r||!Array.isArray(r)||2!==r.length)returnvoidconsole.error("Invalid data in AddTopics");vare=r[Score.TopicNumber],t=r[Score.TopicScore];if("number"!=typeofe||e<0||"number"!=typeoft||t<0)returnvoidconsole.error("Invalid topic data in AddTopics");vari=o.FindTopicIndex(e);i>-1?o.scores[i][Score.TopicScore]=o.scores[i][Score.TopicScore]+t:o.scores.push([e,t])})},r.prototype.Clear=function(){this.scores=[]},r.prototype.ExcludeTopics=function(r){varo=this;if(!r||!r.forEach)returnvoidconsole.error("Invalid ExcludeTopics call");r.forEach(function(r){if(!r||!Array.isArray(r)||2!==r.length)returnvoidconsole.error("Invalid data in ExcludeTopics");vare=r[Score.TopicNumber];if("number"!=typeofe||e<0)returnvoidconsole.error("Invalid topic data in ExcludeTopics");vart=o.FindTopicIndex(e);t>-1&&o.scores.splice(t,1)})},r.prototype.SortByScore=function(){this.scores.sort(function(r,o){returnr[Score.TopicScore]>o[Score.TopicScore]?-1:r[Score.TopicScore]<o[Score.TopicScore]?1:0})},r}(),HndJsSe=function(){functionr(){this.inputWordsExcluded=newHndJsSeWordList,this.inputWordsIncluded=newHndJsSeWordList,this.inputWordsMandatory=newHndJsSeWordList,this.resultScoreIncluded=newHndJsSeResultScore,this.resultScoreMandatory=newHndJsSeResultScore,this.resultScoreExcluded=newHndJsSeResultScore}returnr.prototype.Reset=function(){this.input="",this.inputWordsExcluded.Clear(),this.inputWordsIncluded.Clear(),this.inputWordsMandatory.Clear(),this.resultScoreIncluded.Clear(),this.resultScoreMandatory.Clear(),this.resultScoreExcluded.Clear()},r.prototype.ParseInput=function(r){this.Reset(),this.input=r.trim();for(varo,e=/[-+]?"[^"]+"|[-+]?[^"\s]+/g;o=e.exec(this.input);)if(o[0]){vart=o[0].trim().toLowerCase();if(""!=t){vari="";for("-"!==t[0]&&"+"!==t[0]||(i=t[0],t=t.substr(1));t.length>0&&'"'===t[0];)t=t.substr(1);for(;t.length>0&&'"'===t[t.length-1];)t=t.substr(0,t.length-1);switch(i){case"-":this.inputWordsExcluded.AddWord(t);break;case"+":this.inputWordsIncluded.AddWord(t);break;default:this.inputWordsMandatory.AddWord(t)}}}},r.prototype.PerformSearch=function(r){varo=this;if(this.resultScoreIncluded=newHndJsSeResultScore,this.resultScoreMandatory=newHndJsSeResultScore,this.resultScoreExcluded=newHndJsSeResultScore,!r||!r.length)returnconsole.error("Invalid word list data"),[];vare;r.forEach(function(r){if("string"==typeofr)e=r.trim().toLowerCase();else{if(!Array.isArray(r))returnvoidconsole.error("Invalid element in word list data:",r);if(""==e)returnvoidconsole.warn("Empty word should not be included in list");-1!==o.inputWordsIncluded.FindPartial(e)&&o.resultScoreIncluded.AddTopics(r),-1!==o.inputWordsMandatory.FindPartial(e)&&o.resultScoreMandatory.AddTopics(r),-1!==o.inputWordsExcluded.FindPartial(e)&&o.resultScoreExcluded.AddTopics(r)}});vart=this.resultScoreIncluded;returnt.AddTopics(this.resultScoreMandatory.scores),t.ExcludeTopics(this.resultScoreExcluded.scores),t.SortByScore(),t.scores},r}();