1
0
Fork 0
ejv2.cc/themes/dead-simple/static/js/lunr.js

2 lines
28 KiB
JavaScript
Raw Normal View History

2024-08-01 06:21:40 +01:00
!function(){var e,t,r,i,n,s,o,a,u,l,c,h,d,f,p,y,m,g,x,v,w,Q,k,S,E,L,b,P,T,O,I,R,F=function(e){var t=new F.Builder;return t.pipeline.add(F.trimmer,F.stopWordFilter,F.stemmer),t.searchPipeline.add(F.stemmer),e.call(t,t),t.build()};F.version="2.3.9",F.utils={},F.utils.warn=(e=this,function(t){e.console&&console.warn&&console.warn(t)}),F.utils.asString=function(e){return null==e?"":e.toString()},F.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],s=e[n];if(Array.isArray(s))t[n]=s.slice();else{if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s)throw new TypeError("clone is not deep and does not support nested objects");t[n]=s}}return t},F.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},F.FieldRef.joiner="/",F.FieldRef.fromString=function(e){var t=e.indexOf(F.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),i=e.slice(t+1);return new F.FieldRef(i,r,e)},F.FieldRef.prototype.toString=function(){return null==this._stringValue&&(this._stringValue=this.fieldName+F.FieldRef.joiner+this.docRef),this._stringValue},F.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},F.Set.complete={intersect:function(e){return e},union:function(){return this},contains:function(){return!0}},F.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},F.Set.prototype.contains=function(e){return!!this.elements[e]},F.Set.prototype.intersect=function(e){var t,r,i,n=[];if(e===F.Set.complete)return this;if(e===F.Set.empty)return e;this.length<e.length?(t=this,r=e):(t=e,r=this),i=Object.keys(t.elements);for(var s=0;s<i.length;s++){var o=i[s];o in r.elements&&n.push(o)}return new F.Set(n)},F.Set.prototype.union=function(e){return e===F.Set.complete?F.Set.complete:e===F.Set.empty?this:new F.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},F.idf=function(e,t){var r=0;for(var i in e)"_index"!=i&&(r+=Object.keys(e[i]).length);var n=(t-r+.5)/(r+.5);return Math.log(1+Math.abs(n))},F.Token=function(e,t){this.str=e||"",this.metadata=t||{}},F.Token.prototype.toString=function(){return this.str},F.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},F.Token.prototype.clone=function(e){return e=e||function(e){return e},new F.Token(e(this.str,this.metadata),this.metadata)},F.tokenizer=function(e,t){if(null==e||null==e)return[];if(Array.isArray(e))return e.map((function(e){return new F.Token(F.utils.asString(e).toLowerCase(),F.utils.clone(t))}));for(var r=e.toString().toLowerCase(),i=r.length,n=[],s=0,o=0;s<=i;s++){var a=s-o;if(r.charAt(s).match(F.tokenizer.separator)||s==i){if(a>0){var u=F.utils.clone(t)||{};u.position=[o,a],u.index=n.length,n.push(new F.Token(r.slice(o,s),u))}o=s+1}}return n},F.tokenizer.separator=/[\s\-]+/,F.Pipeline=function(){this._stack=[]},F.Pipeline.registeredFunctions=Object.create(null),F.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&F.utils.warn("Overwriting existing registered function: "+t),e.label=t,F.Pipeline.registeredFunctions[e.label]=e},F.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||F.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},F.Pipeline.load=function(e){var t=new F.Pipeline;return e.forEach((function(e){var r=F.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load unregistered function: "+e);t.add(r)})),t},F.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach((function(e){F.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},F.Pipeline.prototype.after=function(e,t){F.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},F.Pipeline.prototype.before=function(e,t){F.Pipeline.warnIfFunctionNotRegistered(t);var r=this.