You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
24 KiB
JavaScript

!function(){function g(e){var t=new g.Index;return t.pipeline.add(g.trimmer,g.stopWordFilter,g.stemmer),e&&e.call(t,t),t}var t;g.version="0.9.5",(lunr=g).utils={},g.utils.warn=(t=this,function(e){t.console&&console.warn&&console.warn(e)}),g.utils.toString=function(e){return null==e?"":e.toString()},(g.EventEmitter=function(){this.events={}}).prototype.addListener=function(){var e=Array.prototype.slice.call(arguments);const t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},g.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!==(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0===this.events[e].length)&&delete this.events[e]},g.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){const t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},g.EventEmitter.prototype.hasHandler=function(e){return e in this.events},(g.tokenizer=function(n){if(!arguments.length||null==n)return[];if(Array.isArray(n)){let e=n.filter(function(e){return null!=e}),t=(e=e.map(function(e){return g.utils.toString(e).toLowerCase()}),[]);return e.forEach(function(e){e=e.split(g.tokenizer.seperator),t=t.concat(e)},this),t}return n.toString().trim().toLowerCase().split(g.tokenizer.seperator)}).defaultSeperator=/[\s-]+/,g.tokenizer.seperator=g.tokenizer.defaultSeperator,g.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(g.tokenizer.seperator=e)},g.tokenizer.resetSeperator=function(){g.tokenizer.seperator=g.tokenizer.defaultSeperator},g.tokenizer.getSeperator=function(){return g.tokenizer.seperator},(g.Pipeline=function(){this._queue=[]}).registeredFunctions={},g.Pipeline.registerFunction=function(e,t){t in g.Pipeline.registeredFunctions&&g.utils.warn("Overwriting existing registered function: "+t),e.label=t,g.Pipeline.registeredFunctions[t]=e},g.Pipeline.getRegisteredFunction=function(e){return e in g.Pipeline.registeredFunctions!=1?null:g.Pipeline.registeredFunctions[e]},g.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||g.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},g.Pipeline.load=function(e){const n=new g.Pipeline;return e.forEach(function(e){var t=g.Pipeline.getRegisteredFunction(e);if(!t)throw new Error("Cannot load un-registered function: "+e);n.add(t)}),n},g.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){g.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},g.Pipeline.prototype.after=function(e,t){if(g.Pipeline.warnIfFunctionNotRegistered(t),-1===(e=this._queue.indexOf(e)))throw new Error("Cannot find existingFn");this._queue.splice(e+1,0,t)},g.Pipeline.prototype.before=function(e,t){if(g.Pipeline.warnIfFunctionNotRegistered(t),-1===(e=this._queue.indexOf(e)))throw new Error("Cannot find existingFn");this._queue.splice(e,0,t)},g.Pipeline.prototype.remove=function(e){-1!==(e=this._queue.indexOf(e))&&this._queue.splice(e,1)},g.Pipeline.prototype.run=function(o){var e=[],t=o.length,i=this._queue.length;for(let n=0;n<t;n++){let t=o[n];for(let e=0;e<i&&void 0!==(t=this._queue[e](t,n,o))&&null!==t;e++);void 0!==t&&null!==t&&e.push(t)}return e},g.Pipeline.prototype.reset=function(){this._queue=[]},g.Pipeline.prototype.get=function(){return this._queue},g.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return g.Pipeline.warnIfFunctionNotRegistered(e),e.label})},(g.Index=function(){this._fields=[],this._ref="id",this.pipeline=new g.Pipeline,this.documentStore=new g.DocumentStore,this.index={},this.eventEmitter=new g.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))}).prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},g.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},g.Index.load=function(e){e.version!==g.version&&g.utils.warn("version mismatch: current "+g.version+" importing "+e.version);var t=new this;t._fields=e.fields,t._ref=e.ref,t.documentStore=g.DocumentStore.load(e.documentStore),t.pipeline=g.Pipeline.load(e.pipeline),t.index={};for(const n in e.index)t.index[n]=g.InvertedIndex.load(e.index[n]);return t},g.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new g.InvertedIndex,this},g.Index.prototype.setRef=function(e){return this._ref=e,this},g.Index.prototype.saveDocument=function(e){return this.documentStore=new g.DocumentStore(e),this},g.Index.prototype.addDoc=function(r,e){if(r){e=void 0===e||e;const s=r[this._ref];this.documentStore.addDoc(s,r),this._fields.forEach(function(e){var t=this.pipeline.run(g.tokenizer(r[e]));this.documentStore.addFieldLength(s,e,t.length);const n={};t.forEach(function(e){e in n?n[e]+=1:n[e]=1},this);for(const i in n){var o=n[i],o=Math.sqrt(o);this.index[e].addToken(i,{ref:s,tf:o})}},this),e&&this.eventEmitter.emit("add",r,this)}},g.Index.prototype.removeDocByRef=function(e,t){e&&!1!==this.documentStore.isDocStored()&&this.documentStore.hasDoc(e)&&(e=this.documentStore.getDoc(e),this.removeDoc(e,!1))},g.Index.prototype.removeDoc=function(e,t){if(e){t=void 0===t||t;const n=e[this._ref];this.documentStore.hasDoc(n)&&(this.documentStore.removeDoc(n),this._fields.forEach(function(t){this.pipeline.run(g.tokenizer(e[t])).forEach(function(e){this.index[t].removeToken(e,n)},this)},this),t)&&this.eventEmitter.emit("remove",e,this)}},g.Index.prototype.updateDoc=function(e,t){t=void 0===t||t,this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},g.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;return Object.prototype.hasOwnProperty.call(this._idfCache,n)?this._idfCache[n]:(t=this.index[t].getDocFreq(e),e=1+Math.log(this.documentStore.length/(t+1)),this._idfCache[n]=e)},g.Index.prototype.getFields=function(){return this._fields.slice()},g.Index.prototype.search=function(t,e){if(!t)return[];t="string"==typeof t?{any:t}:JSON.parse(JSON.stringify(t));let n=null;null!=e&&(n=JSON.stringify(e));var o=new g.Configuration(n,this.getFields()).get(),i={},r=Object.keys(t);for(let e=0;e<r.length;e++){var s=r[e];i[s]=this.pipeline.run(g.tokenizer(t[s]))}var l={};for(const p in o){var u=i[p]||i.any;if(u){var a=this.fieldSearch(u,p,o),c=o[p].boost;for(h in a)a[h]=a[h]*c;for(h in a)h in l?l[h]+=a[h]:l[h]=a[h]}}var d,h,f=[];for(h in l)d={ref:h,score:l[h]},this.documentStore.hasDoc(h)&&(d.doc=this.documentStore.getDoc(h)),f.push(d);return f.sort(function(e,t){return t.score-e.score}),f},g.Index.prototype.fieldSearch=function(e,a,t){const c=t[a].bool,n=t[a].expand;t=t[a].boost;let d=null;const h={};if(0!==t)return e.forEach(function(l){let e=[l];!0===n&&(e=this.index[a].expandToken(l));const u={};e.forEach(function(n){let e=this.index[a].getDocs(n);var o=this.idf(n,a);if(d&&"AND"===c){var i,t={};for(i in d)i in e&&(t[i]=e[i]);e=t}for(i in n===l&&this.fieldSearchStats(h,n,e),e){var r=this.index[a].getTermFrequency(n,i),s=this.documentStore.getFieldLength(i,a);let e=1,t=(0!==s&&(e=1/Math.sqrt(s)),1);n!==l&&(t=.15*(1-(n.length-l.length)/n.length)),s=r*o*e*t,i in u?u[i]+=s:u[i]=s}},this),d=this.mergeScores(d,u,c)},this),d=this.coordNorm(d,h,e.length)},g.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"===n){var o={};for(i in t)i in e&&(o[i]=e[i]+t[i]);return o}for(var i in t)i in e?e[i]+=t[i]:e[i]=t[i];return e},g.Index.prototype.fieldSearchStats=function(e,t,n){for(const o in n)o in e?e[o].push(t):e[o]=[t]},g.Index.prototype.coordNorm=function(e,t,n){for(const i in e){var o;i in t&&(o=t[i].length,e[i]=e[i]*o/n)}return e},g.Index.prototype.toJSON=function(){const t={};return this._fields.forEach(function(e){t[e]=this.index[e].toJSON()},this),{version:g.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:t,pipeline:this.pipeline.toJSON()}},g.Index.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},(g.DocumentStore=function(e){this._save=null==e||e,this.docs={},this.docInfo={},this.length=0}).load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},g.DocumentStore.prototype.isDocStored=function(){return this._save},g.DocumentStore.prototype.addDoc=function(e,t){this.hasDoc(e)||this.length++,!0===this._save?this.docs[e]=function(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(const n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(t):this.docs[e]=null},g.DocumentStore.prototype.getDoc=function(e){return!1===this.hasDoc(e)?null:this.docs[e]},g.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},g.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},g.DocumentStore.prototype.addFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},g.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!=e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},g.DocumentStore.prototype.getFieldLength=function(e,t){return null!=e&&e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},g.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},g.stemmer=function(){const a={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""};var e="[aeiouy]",t="[^aeiou][^aeiouy]*";const d=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*"),h=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*"),f=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$"),p=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy]"),g=/^(.+?)(ss|i)es$/,y=/^(.+?)([^s])s$/,m=/^(.+?)eed$/,v=/^(.+?)(ed|ing)$/,w=/.$/,S=/(at|bl|iz)$/,b=new RegExp("([^aeiouylsz])\\1$"),x=new RegExp("^"+t+e+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,I=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,k=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,_=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,D=/^(.+?)(s|t)(ion)$/,F=/^(.+?)e$/,A=/ll$/,P=new RegExp("^"+t+e+"[^aeiouwxy]$");return function(e){let t,n,o,i,r,s,l;var u;return e.length<3||("y"==(o=e.substr(0,1))&&(e=o.toUpperCase()+e.substr(1)),i=g,r=y,i.test(e)?e=e.replace(i,"$1$2"):r.test(e)&&(e=e.replace(r,"$1$2")),i=m,r=v,i.test(e)?(u=i.exec(e),(i=d).test(u[1])&&(i=w,e=e.replace(i,""))):r.test(e)&&(u=r.exec(e),t=u[1],(r=p).test(t))&&(e=t,r=S,s=b,l=x,r.test(e)?e+="e":s.test(e)?(i=w,e=e.replace(i,"")):l.test(e)&&(e+="e")),(i=E).test(e)&&(u=i.exec(e),e=(t=u[1])+"i"),(i=I).test(e)&&(u=i.exec(e),t=u[1],n=u[2],(i=d).test(t))&&(e=t+a[n]),(i=k).test(e)&&(u=i.exec(e),t=u[1],n=u[2],(i=d).test(t))&&(e=t+c[n]),i=_,r=D,i.test(e)?(u=i.exec(e),t=u[1],(i=h).test(t)&&(e=t)):r.test(e)&&(u=r.exec(e),t=u[1]+u[2],(r=h).test(t))&&(e=t),(i=F).test(e)&&(u=i.exec(e),t=u[1],i=h,r=f,s=P,i.test(t)||r.test(t)&&!s.test(t))&&(e=t),i=A,r=h,i.test(e)&&r.test(e)&&(i=w,e=e.replace(i,"")),"y"==o&&(e=o.toLowerCase()+e.substr(1))),e}}(),g.Pipeline.registerFunction(g.stemmer,"stemmer"),g.stopWordFilter=function(e){if(e&&!0!==g.stopWordFilter.stopWords[e])return e},g.clearStopWords=function(){g.stopWordFilter.stopWords={}},g.addStopWords=function(e){null!=e&&!1!==Array.isArray(e)&&e.forEach(function(e){g.stopWordFilter.stopWords[e]=!0},this)},g.resetStopWords=function(){g.stopWordFilter.stopWords=g.defaultStopWords},g.stopWordFilter.stopWords=g.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,do:!0,does:!0,either:!0,else:!0,ever:!0,every:!0,for:!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,if:!0,in:!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,this:!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,while:!0,who:!0,whom:!0,why:!0,will:!0,with:!0,would:!0,yet:!0,you:!0,your:!0},g.Pipeline.registerFunction(g.stopWordFilter,"stopWordFilter"),g.Pipeline.registerFunction(g.trimmer=function(e){if(null==e)throw new Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},"trimmer"),(g.InvertedIndex=function(){this.root={docs:{},df:0}}).load=function(e){var t=new this;return t.root=e.root,t},g.InvertedIndex.prototype.addToken=function(e,t,n){n=n||this.root;let o=0;for(;o<=e.length-1;){var i=e[o];i in n||(n[i]={docs:{},df:0}),o+=1,n=n[i]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},g.InvertedIndex.prototype.hasToken=function(t){if(!t)return!1;let n=this.root;for(let e=0;e<t.length;e++){if(!n[t[e]])return!1;n=n[t[e]]}return!0},g.InvertedIndex.prototype.getNode=function(t){if(!t)return null;let n=this.root;for(let e=0;e<t.length;e++){if(!n[t[e]])return null;n=n[t[e]]}return n},g.InvertedIndex.prototype.getDocs=function(e){return null==(e=this.getNode(e))?{}:e.docs},g.InvertedIndex.prototype.getTermFrequency=function(e,t){return null!=(e=this.getNode(e))&&t in e.docs?e.docs[t].tf:0},g.InvertedIndex.prototype.getDocFreq=function(e){return null==(e=this.getNode(e))?0:e.df},g.InvertedIndex.prototype.removeToken=function(e,t){e&&null!=(e=this.getNode(e))&&t in e.docs&&(delete e.docs[t],--e.df)},g.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];if(t=t||[],null!=n||null!=(n=this.getNode(e))){0<n.df&&t.push(e);for(const o in n)"docs"!==o&&"df"!==o&&this.expandToken(e+o,t,n[o])}return t},g.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},(g.Configuration=function(e,t){var n,e=e||"";if(null==t)throw new Error("fields should not be null");this.config={};try{n=JSON.parse(e),this.buildUserConfig(n,t)}catch(e){g.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(t)}}).prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},g.Configuration.prototype.buildUserConfig=function(t,e){let n="OR",o=!1;if(this.reset(),"bool"in t&&(n=t.bool||n),"expand"in t&&(o=t.expand||o),"fields"in t)for(const r in t.fields)if(-1<e.indexOf(r)){var i=t.fields[r];let e=o;null!=i.expand&&(e=i.expand),this.config[r]={boost:i.boost||0===i.boost?i.boost:1,bool:i.bool||n,expand:e}}else g.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(n,o,e)},g.Configuration.prototype.addAllFields2UserConfig=function(t,n,e){e.forEach(function(e){this.config[e]={boost:1,bool:t,expand:n}},this)},g.Configuration.prototype.get=function(){return this.config},g.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){let e,t;for(e=0;e<arguments.length;e++)t=arguments[e],~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){let t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];for(;1<o;){if(r===e)return i;r<e&&(t=i),r>e&&(n=i),o=n-t,i=t+Math.floor(o/2),r=this.elements[i]}return r===e?i:-1},lunr.SortedSet.prototype.locationFor=function(e){let t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];for(;1<o;)r<e&&(t=i),r>e&&(n=i),o=n-t,i=t+Math.floor(o/2),r=this.elements[i];return r>e?i:r<e?i+1:void 0},lunr.SortedSet.prototype.intersect=function(e){var t=new lunr.SortedSet;let n=0,o=0;for(var i=this.length,r=e.length,s=this.elements,l=e.elements;!(n>i-1||o>r-1);)s[n]===l[o]?(t.add(s[n]),n++,o++):s[n]<l[o]?n++:s[n]>l[o]&&o++;return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){let t,n,o;n=this.length>=e.length?(t=this,e):(t=e,this),o=t.clone();for(let e=0,t=n.toArray();e<t.length;e++)o.add(t[e]);return o},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},"function"==typeof define&&define.amd?define(function(){return g}):"object"==typeof exports?module.exports=g:this.elasticlunr=g}(),window.onload=function(){if(document.body.contains(document.getElementById("searchModal"))){const d=document.documentElement.lang,h=document.getElementById("searchInput"),f=document.getElementById("searchModal"),s=document.getElementById("search-button"),p=document.getElementById("clear-search"),g=document.getElementById("results-container"),y=document.getElementById("results"),m={zero_results:document.getElementById("zero_results"),one_results:document.getElementById("one_results"),two_results:document.getElementById("two_results"),few_results:document.getElementById("few_results"),many_results:document.getElementById("many_results")};{var n=s;const v=window.navigator.userAgent.toLowerCase().includes("mac")?"Cmd + K":"Ctrl + K";["title","aria-label"].forEach(e=>{let t=n.getAttribute(e);t&&(t=t.replace("$SHORTCUT",v),n.setAttribute(e,t))})}s.addEventListener("keydown",function(e){"Enter"!==e.key&&" "!==e.key||s.click()});let e,r=(f.addEventListener("click",o),f.addEventListener("touchend",o,{passive:!0}),document.addEventListener("keydown",function(e){"Escape"===e.key&&u()}),p.addEventListener("click",function(){t(),h.focus()}),p.addEventListener("keydown",function(e){"Enter"!==e.key&&" "!==e.key||(t(),h.focus(),e.preventDefault())}),s.addEventListener("mouseover",i),s.addEventListener("click",l),s.addEventListener("touchstart",l,{passive:!0}),null);function l(){e=document.activeElement,i(),f.style.display="block",h.focus()}function u(){f.style.display="none",t(),e&&document.body.contains(e)&&e.focus()}function a(e){var t;"true"!==e.getAttribute("aria-selected")&&([t=null]=[e],y.querySelectorAll("#results > div").forEach(e=>{e!==t&&e.setAttribute("aria-selected","false")}),e.setAttribute("aria-selected","true")),h.setAttribute("aria-activedescendant",e.id)}function t(){h.value="",y.innerHTML="",g.style.display="none",h.removeAttribute("aria-activedescendant"),p.style.display="none"}function o(e){e.target===f&&u(),e.stopPropagation()}function i(){if(!r)if(window.searchIndex)r=Promise.resolve(elasticlunr.Index.load(window.searchIndex));else{var t=document.documentElement.getAttribute("lang").substring(0,2);let e=document.querySelector("meta[name='base']").getAttribute("content");e.endsWith("/")&&(e=e.slice(0,-1)),r=fetch(e+"/search_index."+t+".json").then(e=>e.json()).then(e=>elasticlunr.Index.load(e))}}function S(e){return e=parseInt(e,16).toString(2),[0,1,2,3,4][Math.ceil(e.length/8)]}function c(){a(this)}h.addEventListener("input",async function(){var e=this.value;const s=e.trim();var t=await r;y.innerHTML="",p.style.display=0<e.length?"block":"none",g.style.display=0<s.length?"block":"none";var n,o=t=(e=t.search(s,{bool:"OR",fields:{title:{boost:3},body:{boost:2},description:{boost:1},path:{boost:1}}})).length,i=d,o=0===o?"zero_results":1===o?"one_results":"ar"===i?(n=o%100,2===o?"two_results":3<=n&&n<=10?"few_results":"many_results"):["uk","be","bs","hr","ru","sr"].includes(i)?(n=o%100,1==(i=o%10)&&11!=n?"one_results":2<=i&&i<=4&&!(12<=n&&n<=14)?"few_results":"many_results"):"many_results";Object.values(m).forEach(e=>{e&&(e.style.display="none")}),(o=m[o])&&(o.style.display="inline",o.textContent=o.textContent.replace("$NUMBER",t.toString()));let l=0;e.forEach(function(t){if(t.doc.title||t.doc.path||t.doc.id){var n=document.createElement("div"),o=(n.setAttribute("role","option"),n.id="result-"+l++,n.innerHTML="<a href><span></span><span></span></a>",n.querySelector("a")),i=n.querySelector("span:first-child"),r=n.querySelector("span:nth-child(2)"),i=(i.textContent=t.doc.title||t.doc.path||t.doc.id,t.doc.body?function(e,t){var n=t.map(function(e){return elasticlunr.stemmer(e.toLowerCase())});let o=0;var i=[];for(const m of e.toLowerCase().split(". ")){let t=!0;for(const v of m.split(/[\s\n]/)){if(0<v.length){let e=t?8:2;for(const w of n)elasticlunr.stemmer(v).startsWith(w)&&(e=40);i.push([v,e,o]),t=!1}o+=v.length+1}o+=1}if(0===i.length)return 150<e.length?e.substring(0,150)+"…":e;var r=[];let s=0;for(var l=0;l<Math.min(i.length,30);l++)s+=i[l][1];for(r.push(s),l=1;l<=i.length-30;l++)s=(s-=i[l-1][1])+i[l+30-1][1],r.push(s);let u=0,a=0;for(l=r.length-1;0<=l;l--)a<r[l]&&(a=r[l],u=l);var c=[];let d=function(e,t){let n=0,o=t-1;for(;0<=o&&n<4;){if(" "===e[o]&&"."!==e[o-1])n++;else if("."===e[o]&&" "===e[o+1])break;o--}return 4===n?o+1:t}(e,i[u][2]);for(var h=/^[\x00-\xff]+$/,l=u;l<u+30&&l<i.length;l++){var f,p=i[l],g=(d<p[2]&&(c.push(e.substring(d,p[2])),d=p[2]),40===p[1]&&c.push("<b>"),p[2]+p[0].length);!h.test(p[0])&&12<=p[0].length?(f=function(t){let n="",o=!1,i=0,r=0,s=0;for(let e=0;e<t.length;e++){var l=t.codePointAt(e).toString(16);if(o=4<l.length&&++e+1<t.length?"200d"===t.codePointAt(e+1).toString(16):o){if(i+=S(l),e==t.length-1){if(!((r+=i)<=12))break;n+=t.substr(s,e-s+1)}}else if(0!=i){if(!((r=(r+=i)+S(l))<=12))break;n+=t.substr(s,e-s+1),s=e+1,i=0}else{if(!((r+=S(l))<=12))break;l.length<=4?n+=t[e]:n+=t[e-1]+t[e],s=e+1}}return n}(e.substring(p[2],g)),c.push(f)):c.push(e.substring(p[2],g)),40===p[1]&&c.push("</b>"),d=g}c.push("…");var y=t=c.join("");return 150<t.replace(/<[^>]+>/g,"").length?t.substring(0,150)+"…":y}(t.doc.body,s.split(/\s+/)):t.doc.description||"");r.innerHTML=i;let e=t.ref;t.doc.body&&(r=encodeURIComponent(s),e+="#:~:text="+r),o.href=e,y.appendChild(n)}}),h.setAttribute("aria-expanded",0<l?"true":"false"),y.firstChild&&a(y.firstChild),y.addEventListener("mouseover",function(e){e.target.closest('div[role="option"]')&&a(e.target.closest('div[role="option"]'))}),y.addEventListener("click",function(e){var t,n,o=e.target.closest("a");o&&(o=o.getAttribute("href"),t=window.location.href,(n=e=>e.split("#")[0].replace(/\/$/,""))(o)!==n(t)||e.ctrlKey||e.metaKey||u())}),document.querySelectorAll("#results > div").forEach(e=>{e.removeEventListener("touchstart",c),e.addEventListener("touchstart",c,{passive:!0})})},!0),document.addEventListener("keydown",function(t){var e=navigator.userAgent.toLowerCase().includes("mac")?t.metaKey:t.ctrlKey;if("k"===t.key&&e)t.preventDefault(),("block"===f.style.display?u:l)();else if(e=document.activeElement,"Tab"!==t.key||e!==h&&e!==p){if(0!==(r=y.querySelectorAll("#results > div")).length){var n,o,i=Array.from(r),r=y.querySelector('[aria-selected="true"]'),s=i.indexOf(r);if(["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)){t.preventDefault();let e=s;switch(t.key){case"ArrowUp":e=Math.max(s-1,0);break;case"ArrowDown":e=Math.min(s+1,i.length-1);break;case"Home":e=0;break;case"End":e=i.length-1;break;case"PageUp":e=Math.max(s-3,0);break;case"PageDown":e=Math.min(s+3,i.length-1)}e!==s&&(a((o=i)[n=e]),o[n].scrollIntoView({block:"nearest",inline:"start"}))}"Enter"===t.key&&r&&(t.preventDefault(),t.stopImmediatePropagation(),(o=r.querySelector("a"))&&(window.location.href=o.getAttribute("href")),u())}}else t.preventDefault(),(e===h?p:h).focus()})}};