!function(e){"use strict";var t="undefined"==typeof e.jQuery;if(function(){var e=function(){this._documents=null,this._processing={},this._data={titleScore:100,apiScore:50,textScore:5}};return e.prototype.initDocs=function(e){this._documents=t?e:JSON.parse(JSON.stringify(e));for(var s in this._documents)this._documents.hasOwnProperty(s)&&this._preDoc(this._documents[s])},e.prototype._preDoc=function(e){e.content=e.content.replace(/^\s+|\s+$/g,"").replace(/^#\s?(.*?)[\r|\n]/,function(t,s){return e.title=s,""}).replace(/([^#]#{3} *请求地址[\n\r]{1,4})([-\w:\/\.]+?)[\n\r]{1,}(#{3} *请求类型[\s\S]+?#{3} *请求参数)/,function(t,s,r,i){return e.api=r,s+i}).replace(/#{1,6}(.*?)#{0,6}\s*[\r\n]/g,"$1").replace(/[_\*~]{1,2}(.*?)[_\*~]{1,2}/g,"$1").replace(/!\[.*?]\(.*?\)/g,"").replace(/\[(.*?)]\(.*?\)/g,"$1").replace(/`{3}.*?[\n\r]([\s\S]*?)`{3}/g,"$1").replace(/`(.*?)`/g,"$1").replace(/<.+?>/g,"").replace(/> *(.+?)[n\r]/g,"$1").replace(/-{3,} *[\n\r]/g,"").replace(/(\|.*?[\n\r]{1,2}){3,}/g,function(e){return e.replace(/\|.*?[\n\r]{1,2}/g,function(e){return e.indexOf("---")>=0?"":e.replace(/\|/g,"")})}).replace(/[\n\r\t]/g," ").replace(/\s{2,}/g," ")},e.prototype._addPorcessing=function(e,t,s){"undefined"==typeof this._processing[e]?(this._processing[e]={},this._processing[e][t]=s):"undefined"==typeof this._processing[e][t]?this._processing[e][t]=s:this._processing[e][t]+=s},e.prototype.matchWords=function(e){var t=new RegExp(e,"gi");for(var s in this._documents)if(this._documents.hasOwnProperty(s)){if(this._documents[s].title){var r=this._documents[s].title.match(t);if(r&&r.length>0){var i=this._documents[s].title.replace(t,function(e){return"<mark>"+e+"</mark>"});this._addPorcessing(s,"title",i),this._addPorcessing(s,"score",this._data.titleScore)}}if(this._documents[s].api){var n=this._documents[s].api.match(t);if(n&&n.length>0){var o='<p class="p1"><em>接口</em>'+this._documents[s].api.replace(t,function(e){return"<mark>"+e+"</mark>"})+"</p>";this._addPorcessing(s,"api",o),this._addPorcessing(s,"score",this._data.apiScore)}}var c=this._documents[s].content.match(new RegExp(".{0,15}"+e+".{0,30}","gi"));if(c){for(var a,p="<p>",h=0;a=c[h];h++)h<2&&(p+=a.replace(t,function(e){return"<mark>"+e+"</mark>"})+"... ");p+="</p>",this._addPorcessing(s,"content",p),this._addPorcessing(s,"score",c.length*this._data.textScore)}}this._auxiliary()},e.prototype._auxiliary=function(){},e.prototype._sortByScore=function(){var e=[];for(var t in this._processing)this._processing.hasOwnProperty(t)&&("undefined"==typeof this._processing[t].title&&(this._processing[t].title=this._documents[t].title?this._documents[t].title:""),"undefined"==typeof this._processing[t].api&&(this._processing[t].api=""),"undefined"==typeof this._processing[t].content&&(this._processing[t].content="<p>"+this._documents[t].content.substr(0,45)+"...</p>"),this._processing[t].path=this._documents[t].uri,this._processing[t].timestamp=this._documents[t].timestamp,e.push(this._processing[t]));return e.sort(function(e,t){return e.score>t.score?-1:1}),e},e.prototype.getResult=function(){return this._sortByScore()},this.AWSearcher=e}.call(e),t){var s=new e.AWSearcher;e.onmessage=function(t){var r=t.data;"searcher:docs"==r.type?(s.initDocs(r.docs),e.postMessage({type:"searcher:ready"})):"searcher:search"==r.type&&(s.matchWords(r.words),e.postMessage({type:"searcher:result",result:s.getResult()}))},e.postMessage({type:"searcher:loaded"})}}(self);