1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-08 21:20:41 +02:00

improved intersection strategy

This commit is contained in:
Thomas Wilkerling
2021-06-02 10:57:18 +02:00
parent 8b9be00251
commit d1491da259
12 changed files with 825 additions and 708 deletions

View File

@@ -5,32 +5,31 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function _f(self){'use strict';try{if(module)self=module}catch(e){}self._factory=_f;var r;function t(a,b){return"undefined"!==typeof a?a:b}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}function aa(a,b){return b.length-a.length}function A(a){return"string"===typeof a}function B(a){return"object"===typeof a}function C(a){return"function"===typeof a};const ba=/[\u0300-\u036f]/g;function D(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function ca(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(e[g++]=E(b?"(?!\\b)"+k+"(\\b|_)":k),e[g++]=l):f+=(f?"|":"")+k;f&&(e[g++]=E(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function F(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function E(a){return new RegExp(a,"g")}
function da(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};const ea=/[\W_]+/;function fa(a){return ha(this,D(a).toLowerCase(),!1,ea)};const ia={},G={};let ja=Promise;function ka(a){I(a,"add");I(a,"append");I(a,"search");I(a,"update");I(a,"remove")}function I(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;C(e)&&(f=e,delete d[d.length-1]);e=new ja(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,d);c.async=!1;g(h)})});return f?(e.then(f),this):e}};function la(a,b,c,d){var e=a.length;let f=[],g,h=0;d&&(d=[]);for(--e;0<=e;e--){const k=a[e],l=k.length,p=x();let u=!g;for(let q=0;q<l;q++){const v=k[q],m=v.length;if(m)for(let n=0,y=0,z;n<m;n++)if(z=v[n],!g)p[z]=1;else if(g[z]){if(e)d&&y<b&&((d[q]||(d[q]=[]))[y++]=z),p[z]=1;else if(c)c--;else if(f[h++]=z,h===b)return f;u=!0}}if(!u&&!d)return[];g=p}if(d)for(let k=d.length-1,l,p;0<=k;k--)if((p=(l=d[k])&&l.length)&&c&&(p<=c?(c-=p,p=0):p-=c),p){if(h+p>=b)return f.concat(l.slice(c,b-h+c));f=f.concat(c?
l.slice(c):l);h+=p;c=0}return f}function ma(a,b){const c=x(),d=x(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function J(a){this.l=!0!==a&&a;this.cache=x();this.h=[]}function na(a,b,c){B(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}J.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};J.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const oa={memory:{charset:"latin:extra",C:3,B:3,o:!1,A:"memory"},performance:{threshold:8,B:3,context:{depth:1,G:!0}},match:{charset:"latin:extra",I:"full",C:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,G:!0}},"default":{C:3,threshold:0,depth:3}};function ra(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};G["latin:default"]=fa;
function K(a,b){if(!(this instanceof K))return new K(a);var c;if(a){A(a)?a=oa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;A(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=G[c]);A(d)&&(d=ia[d])}else a={};let e,f,g,h=a.context||{};this.encode=a.encode||c&&c.encode||fa;this.register=b||x();e=a.resolution||9;f=a.threshold||0;f>=e&&(f=e-1);this.C=e;this.threshold=f;this.D=b=c&&c.I||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.G=t(h.bidirectional,!0);this.A=g="memory"===
a.optimize;this.o=t(a.fastupdate,!0);this.B=a.minlength||1;this.map=g?w(e-f):x();e=h.resolution||e;f=h.threshold||f;f>=e&&(f=e-1);this.l=e;this.s=f;this.h=g?w(e-f):x();this.F=c&&c.F||a.rtl;this.L=(b=a.matcher||d&&d.L)&&ca(b,!1);this.M=(b=a.stemmer||d&&d.M)&&ca(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=x();for(let k=0,l=c.length;k<l;k++)d[c[k]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new J(b)}
function ha(a,b,c,d){if(b&&(c&&(b=F(b,c)),a.L&&(b=F(b,a.L)),a.M&&1<b.length&&(b=F(b,a.M)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(let e=0,f=0;e<c;e++){const g=b[e];g&&!a[g]&&(d[f++]=g)}a=d}else a=b;return a}return b}r=K.prototype;r.append=function(a,b){return this.add(a,b,!0)};
r.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){const p=this.depth,u=this.C-this.threshold,q=x(),v=x();for(let m=0;m<d;m++){let n=b[this.F?d-1-m:m];var e=n.length;if(n&&e>=this.B&&(p||!q[n])){var f=Math.min(this.C/d*m|0,m);if(f<u){var g="";switch(this.D){case "full":if(3<e){for(var h=0;h<e;h++){var k=h?Math.min(f/2+this.C/e*h/2|0,f+h):f;if(k<u)for(var l=e;l>h;l--)g=n.substring(h,l),g.length>=this.B&&L(this,q,g,k,a,c)}break}case "reverse":if(2<
e){for(h=e-1;0<h;h--)g=n[h]+g,g.length>=this.B&&L(this,q,g,f,a,c);g=""}case "forward":if(1<e)for(h=0;h<e;h++)g+=n[h],g.length>=this.B&&L(this,q,g,f,a,c);break;default:if(L(this,q,n,f,a,c),p&&1<d&&m<d-1)for(e=this.l-this.s,f=x(),g=n,h=Math.min(p+1,d-m),f[g]=1,k=1;k<h;k++)if((n=b[this.F?d-1-m-k:m+k])&&n.length>=this.B&&!f[n]){if(f[n]=1,l=Math.min((this.l-h)/d*m+k|0,m+(k-1)),l<e){const y=this.G&&n>g;L(this,v,y?g:n,l,a,c,y?n:g)}}else h=Math.min(h+1,d-m)}}}}this.o||(this.register[a]=1)}return this};
function L(a,b,c,d,e,f,g){let h=g?a.h:a.map;if(!b[c]||g&&!b[c][g])a.A&&(h=h[d]),g?(b=b[c]||(b[c]=x()),b[g]=1,h=h[g]||(h[g]=x())):b[c]=1,h=h[c]||(h[c]=[]),a.A||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.o&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
r.search=function(a,b,c){B(a)?(c=a,a=c.query):B(b)&&(c=b);let d=[],e;var f=this.threshold;let g,h=0;if(c){b=c.limit;h=c.offset||0;f=t(c.threshold,f);var k=c.context;g=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=x();var l=[];for(let u=0,q=0,v;u<e;u++)if((v=a[u])&&v.length>=this.B&&!c[v])if(this.A||g||this.map[v])l[q++]=v,c[v]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);c=this.C-f;f=this.l-f;k=this.depth&&1<e&&!1!==k;l=0;let p;k?(p=a[0],l=1):1<e&&a.sort(aa);for(let u,q;l<e;l++){q=
a[l];k?(u=sa(this,d,g,f,b,h,2===e,q,p),g&&!1===u&&d.length||(p=q)):u=sa(this,d,g,c,b,h,1===e,q);if(u)return u;if(g&&l===e-1){let v=d.length;if(!v){if(k){k=0;l=-1;continue}return d}if(1===v)return ta(d[0],b,h)}}return la(d,b,h,g)};
function sa(a,b,c,d,e,f,g,h,k){let l=[],p=k?a.h:a.map;a.A||(p=ua(p,h,k,a.G));if(p){let u=0;d=Math.min(p.length,d);for(let q=0,v=0,m,n;q<d&&!(m=p[q],a.A&&(m=ua(m,h,k,a.G)),m&&g&&(n=m.length,n<=f?(f-=n,m=null):f&&(m=m.slice(f),f=0)),m&&(l[u++]=m,g&&(v+=m.length,v>=e)));q++);if(u){if(g)return ta(l,e,0);b[b.length]=l;return}}return!c&&l}function ta(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ua(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}r.contain=function(a){return!!this.register[a]};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a,b){const c=this.register[a];if(c){if(this.o)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else M(this.map,a,this.C-this.threshold,this.A),this.depth&&M(this.h,a,this.l-this.s,this.A);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
function M(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=M(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=M(a[g],b,c,d,e))||delete a[g];return f}r.searchCache=na;
r.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.o){g=x();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.A?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.h;break;default:return}ra(a,b||this,c?c+"."+f:f,d,e,g);return!0};r.import=function(a,b){if(b)switch(A(b)&&(b=JSON.parse(b)),a){case "cfg":this.A=!!b.opt;break;case "reg":this.o=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ka(K.prototype);function va(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new K(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let wa=0;function N(a){var b;a?C(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c=self.exports,d=this;this.m=xa(b,c,a.worker);this.h=x();if(this.m){if(c)this.m.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.m.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.m.postMessage({task:"init",factory:b,options:a})}}P("add");P("append");P("search");P("update");P("remove");
function P(a){N.prototype[a]=N.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;C(d)&&(e=d,c.splice(c.length-1,1));d=new ja(function(f){setTimeout(function(){b.h[++wa]=f;b.m.postMessage({task:a,id:wa,args:c})})});return e?(d.then(e),this):d}}
function xa(a,b,c){let d;try{d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+va.toString()],{type:"text/javascript"}))):new Worker(A(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function Q(a){if(!(this instanceof Q))return new Q(a);var b=a.document||a.doc||a,c;this.N=[];this.h=[];this.D=[];this.register=x();this.key=(c=b.key||b.id)&&R(c,this.D)||"id";this.o=t(a.fastupdate,!0);this.J=!!(c=b.extern);this.H=!this.J&&(c=b.store)&&!0!==c&&[];this.store=c&&(this.J?c:x());this.K=(c=b.tag)&&R(c,this.D);this.l=c&&x();this.cache=(c=a.cache)&&new J(c);a.cache=!1;this.m=a.worker;this.async=!1;c=x();let d=b.index||b.field||b;A(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],A(f)||(g=
f,f=f.field),g=B(g)?Object.assign({},a,g):a,this.m&&(c[f]=new N(g),c[f].m||(this.m=!1)),this.m||(c[f]=new K(g,this.register)),this.N[e]=R(f,this.D),this.h[e]=f;if(this.H)for(a=b.store,A(a)&&(a=[a]),b=0;b<a.length;b++)this.H[b]=R(a[b],this.D);this.s=c}function R(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}
function S(a,b){if(A(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}function T(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)T(a,b,c,d,e);else b=b[e]||(b[e]=x()),e=c[++d],T(a,b,c,d,e)}
function W(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,c,d,e,f,g,h);else g=b[++d],W(a,b,c,d,e,f,g,h)}r=Q.prototype;
r.add=function(a,b,c){B(a)&&(b=a,a=S(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.N[d],A(e)&&(e=[e]),W(b,e,this.D,0,this.s[f],a,e[0],c);if(this.K){let d=S(b,this.K),e=x();A(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.l[g]||(this.l[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.o){const k=this.register[a]||(this.register[a]=[]);k[k.length]=h}}if(this.store&&!this.J){let d;if(this.H){d=
x();for(let e=0,f;e<this.H.length;e++)f=this.H[e],A(f)?d[f]=b[f]:T(b,d,f,0,f[0])}this.store[a]=d||b}}return this};r.append=function(a,b){return this.add(a,b,!0)};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a){B(a)&&(a=S(a,this.key));if(this.register[a]){var b=this.o&&!this.m;for(var c=0;c<this.h.length&&(this.s[this.h[c]].remove(a,b),!b);c++);if(this.K&&!b)for(let d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&!this.J&&delete this.store[a];delete this.register[a]}return this};
r.search=function(a,b,c,d){B(a)?(c=a,a=c.query):B(b)&&(c=b,b=0);let e=[],f=[],g,h,k,l,p,u,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;l=c.tag;h=this.store&&c.enrich;p="and"===c.bool;b=c.limit||100;u=c.offset||0;if(l&&(A(l)&&(l=[l]),!a)){for(let m=0,n;m<l.length;m++)if(n=ya.call(this,l[m],b,u,h))e[e.length]=n,q++;return q?e:[]}A(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);p=p&&(1<k.length||l&&1<l.length);const v=!d&&(this.m||this.async)&&[];for(let m=
0,n,y,z;m<k.length;m++){let U;y=k[m];A(y)||(U=y,y=y.field);if(v)v[m]=this.s[y].searchAsync(a,b,U||c);else{d?n=d[m]:n=this.s[y].search(a,b,U||c);z=n&&n.length;if(l&&z){const H=[];let pa=0;p&&(H[0]=[n]);for(let V=0,qa,O;V<l.length;V++)if(qa=l[V],z=(O=this.l[qa])&&O.length)pa++,H[H.length]=p?[O]:O;pa&&(n=p?la(H,b||100,u||0):ma(n,H),z=n.length)}if(z)f[q]=y,e[q++]=n;else if(p)return[]}}if(v){const m=this;return new Promise(function(n){Promise.all(v).then(function(y){n(m.search(a,b,c,y))})})}if(!q)return[];
if(g&&(!h||!this.store))return e[0];for(let m=0,n;m<f.length;m++){n=e[m];n.length&&h&&(n=za.call(this,n));if(g)return n;e[m]={field:f[m],result:n}}return e};function ya(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=za.call(this,e));return{tag:a,result:e}}}function za(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}r.contain=function(a){return!!this.register[a]};r.get=function(a){return this.store[a]};
r.set=function(a,b){this.store[a]=b;return this};r.searchCache=na;r.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.h.length){const f=this.h[d],g=this.s[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.l;break;case 2:c="store";f=this.store;break;default:return}ra(a,this,c,d,e,f)}};
r.import=function(a,b){if(b)switch(A(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.o=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.s[this.h[d]],e.register=b,e.o=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.s[c].import(a,b)}};ka(Q.prototype);const Aa=/[\W_]+/,Ba=[E("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",E("[\u00e8\u00e9\u00ea\u00eb]"),"e",E("[\u00ec\u00ed\u00ee\u00ef]"),"i",E("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",E("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",E("[\u00fd\u0177\u00ff]"),"y",E("\u00f1"),"n",E("[\u00e7c]"),"k",E("\u00df"),"s",E(" & ")," and "];function Ca(a){return ha(this,D(a).toLowerCase(),!a.normalize&&Ba,Aa)};var Ea={encode:Da,F:!1,I:"strict"};const Fa=/[^a-z0-9]+/,Ga={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Da(a){a=Ca.call(this,a).join(" ");const b=[];if(a){const c=a.split(Fa),d=c.length;for(let e=0,f,g=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let h=Ga[f]||f,k=h;for(let l=1;l<a.length;l++){f=a[l];const p=Ga[f]||f;p&&p!==k&&(h+=p,k=p)}b[g++]=h}}return b};var Ia={encode:Ha,F:!1,I:""};const Ja=[E("ae"),"a",E("oe"),"o",E("sh"),"s",E("th"),"t",E("ph"),"f",E("pf"),"f"];function Ha(a,b){a&&(a=Da.call(this,a).join(" "),2<a.length&&(a=F(a,Ja)),b||(1<a.length&&(a=da(a)),a&&(a=a.split(" "))));return a};var La={encode:Ka,F:!1,I:""};const Ma=E("(?!\\b)[aeiouy]");function Ka(a){a&&(a=Ha.call(this,a,!0),1<a.length&&(a=a.replace(Ma,"")),1<a.length&&(a=da(a)),a&&(a=a.split(" ")));return a};G["latin:simple"]={encode:Ca,F:!1,I:""};G["latin:balance"]=Ea;G["latin:advanced"]=Ia;G["latin:extra"]=La;const X=self;let Y;const Z={Index:K,Document:Q,Worker:N,registerCharset:function(a,b){G[a]=b},registerLanguage:function(a,b){ia[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
(function _f(self){'use strict';try{if(module)self=module}catch(e){}self._factory=_f;var r;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a}function E(a){return"function"===typeof a};const ba=/[\u0300-\u036f]/g;function ca(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function da(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,l,m;h<d;h++)l=c[h],(m=a[l])?(e[g++]=F(b?"(?!\\b)"+l+"(\\b|_)":l),e[g++]=m):f+=(f?"|":"")+l;f&&(e[g++]=F(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function H(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function F(a){return new RegExp(a,"g")}
function ea(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};const fa=/[\W_]+/;function ha(a){return ia(this,ca(a).toLowerCase(),!1,fa)};const ja={},I={};function ka(a){J(a,"add");J(a,"append");J(a,"search");J(a,"update");J(a,"remove")}function J(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;E(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,d);c.async=!1;g(h)})});return f?(e.then(f),this):e}};function la(a,b,c,d){const e=a.length;let f=[],g;let h,l;for(var m=0;m<e;m++){var p=a[m],u=p.length,t=0;for(let k=0,n;k<u;k++)(n=p[k])&&(t+=n.length);if(!q||t<q){var q=t;h=p;l=m}}h=1===h.length?h[0]:[].concat.apply([],h);d&&(d=[h],g=y());m=q=0;for(p=e-1;0<=p;p--)if(p!==l){m++;u=a[p];t=u.length;const k=[];let n=0;for(let x=0,z;x<h.length;x++){z=h[x];let A;for(let B=0;B<t;B++){const G=u[B];if(G.length&&(A=-1!==G.indexOf(z))){if(m===e-1){if(c)c--;else if(f[q++]=z,q===b)return f;d&&(g[z]=1)}break}}A&&
(k[n++]=z)}if(d)d[m]=k;else if(!n)return[];h=k}if(d)for(let k=d.length-1,n,x;0<=k;k--)if(x=(n=d[k])&&n.length)for(let z=0,A;z<x;z++)if(A=n[z],!g[A])if(g[A]=1,c)c--;else if(f[q++]=A,q===b)return f;return f}function ma(a,b){const c=y(),d=y(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,l;h<g.length;h++)l=g[h],c[l]&&!d[l]&&(d[l]=1,e[e.length]=l)}return e};function K(a){this.l=!0!==a&&a;this.cache=y();this.h=[]}function na(a,b,c){D(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}K.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};K.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const oa={memory:{charset:"latin:extra",D:3,A:3,o:!1,s:"memory"},performance:{threshold:8,A:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",H:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function qa(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};I["latin:default"]=ha;
function L(a,b){if(!(this instanceof L))return new L(a);var c;if(a){C(a)?a=oa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=I[c]);C(d)&&(d=ja[d])}else a={};let e,f,g=a.context||{};this.encode=a.encode||c&&c.encode||ha;this.register=b||y();this.D=e=a.resolution||9;this.B=b=c&&c.H||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f="memory"===a.optimize;this.o=v(a.fastupdate);this.A=a.minlength||
1;this.map=f?w(e):y();this.l=e=g.resolution||1;this.h=f?w(e):y();this.C=c&&c.C||a.rtl;this.I=(b=a.matcher||d&&d.I)&&da(b,!1);this.K=(b=a.stemmer||d&&d.K)&&da(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=y();for(let h=0,l=c.length;h<l;h++)d[c[h]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new K(b)}
function ia(a,b,c,d){if(b&&(c&&(b=H(b,c)),a.I&&(b=H(b,a.I)),a.K&&1<b.length&&(b=H(b,a.K)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(let e=0,f=0;e<c;e++){const g=b[e];g&&!a[g]&&(d[f++]=g)}a=d}else a=b;return a}return b}r=L.prototype;r.append=function(a,b){return this.add(a,b,!0)};
r.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){const m=this.depth,p=this.D,u=y(),t=y();for(let q=0;q<d;q++){let k=b[this.C?d-1-q:q];var e=k.length;if(k&&e>=this.A&&(m||!u[k])){var f=Math.min(p/d*q|0,q),g="";switch(this.B){case "full":if(3<e){for(var h=0;h<e;h++){var l=h?Math.min(f/2+p/e*h/2|0,f+h):f;for(let n=e;n>h;n--)g=k.substring(h,n),g.length>=this.A&&M(this,u,g,l,a,c)}break}case "reverse":if(2<e){for(h=e-1;0<h;h--)g=
k[h]+g,g.length>=this.A&&M(this,u,g,f,a,c);g=""}case "forward":if(1<e)for(h=0;h<e;h++)g+=k[h],g.length>=this.A&&M(this,u,g,f,a,c);break;default:if(M(this,u,k,f,a,c),m&&1<d&&q<d-1)for(e=y(),f=k,g=Math.min(m+1,d-q),e[f]=1,h=1;h<g;h++)(k=b[this.C?d-1-q-h:q+h])&&k.length>=this.A&&!e[k]?(e[k]=1,l=this.F&&k>f,M(this,t,l?f:k,0,a,c,l?k:f)):g=Math.min(g+1,d-q)}}}this.o||(this.register[a]=1)}return this};
function M(a,b,c,d,e,f,g){let h=g?a.h:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[d]),g?(b=b[c]||(b[c]=y()),b[g]=1,h=h[g]||(h[g]=y())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.o&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
r.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let d=[],e;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=y();var l=[];for(let p=0,u=0,t;p<e;p++)if((t=a[p])&&t.length>=this.A&&!c[t])if(this.s||f||this.map[t])l[u++]=t,c[t]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);h=this.depth&&1<e&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<e&&a.sort(aa);for(let p,u;c<e;c++){u=a[c];h?(p=ra(this,d,f,b,g,2===e,u,m),f&&!1===p&&d.length||
(m=u)):p=ra(this,d,f,b,g,1===e,u);if(p)return p;if(f&&c===e-1){l=d.length;if(!l){if(h){h=0;c=-1;continue}return d}if(1===l)return sa(d[0],b,g)}}return la(d,b,g,f)};
function ra(a,b,c,d,e,f,g,h){let l=[],m=h?a.h:a.map;a.s||(m=ta(m,g,h,a.F));if(m){let p=0;const u=Math.min(m.length,h?a.l:a.D);for(let t=0,q=0,k,n;t<u;t++)if(k=m[t])if(a.s&&(k=ta(k,g,h,a.F)),e&&k&&f&&(n=k.length,n<=e?(e-=n,k=null):(k=k.slice(e),e=0)),k&&(l[p++]=k,f&&(q+=k.length,q>=d)))break;if(p){if(f)return sa(l,d,0);b[b.length]=l;return}}return!c&&l}function sa(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ta(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}r.contain=function(a){return!!this.register[a]};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a,b){const c=this.register[a];if(c){if(this.o)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else N(this.map,a,this.D,this.s),this.depth&&N(this.h,a,this.l,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
function N(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=N(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=N(a[g],b,c,d,e))||delete a[g];return f}r.searchCache=na;
r.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.o){g=y();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.s?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.h;break;default:return}qa(a,b||this,c?c+"."+f:f,d,e,g);return!0};r.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.o=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ka(L.prototype);function ua(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new L(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let va=0;function O(a){var b;a?E(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c=self.exports,d=this;this.m=wa(b,c,a.worker);this.h=y();if(this.m){if(c)this.m.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.m.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.m.postMessage({task:"init",factory:b,options:a})}}Q("add");Q("append");Q("search");Q("update");Q("remove");
function Q(a){O.prototype[a]=O.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;E(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++va]=f;b.m.postMessage({task:a,id:va,args:c})})});return e?(d.then(e),this):d}}
function wa(a,b,c){let d;try{d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+ua.toString()],{type:"text/javascript"}))):new Worker(C(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function R(a){if(!(this instanceof R))return new R(a);var b=a.document||a.doc||a,c;this.L=[];this.h=[];this.B=[];this.register=y();this.key=(c=b.key||b.id)&&S(c,this.B)||"id";this.o=v(a.fastupdate);this.G=(c=b.store)&&!0!==c&&[];this.store=c&&y();this.J=(c=b.tag)&&S(c,this.B);this.l=c&&y();this.cache=(c=a.cache)&&new K(c);a.cache=!1;this.m=a.worker;this.async=!1;c=y();let d=b.index||b.field||b;C(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,
this.m&&(c[f]=new O(g),c[f].m||(this.m=!1)),this.m||(c[f]=new L(g,this.register)),this.L[e]=S(f,this.B),this.h[e]=f;if(this.G)for(a=b.store,C(a)&&(a=[a]),b=0;b<a.length;b++)this.G[b]=S(a[b],this.B);this.index=c}function S(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function T(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function U(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)U(a,b,c,d,e);else b=b[e]||(b[e]=y()),e=c[++d],U(a,b,c,d,e)}function V(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)V(a,b,c,d,e,f,g,h);else g=b[++d],V(a,b,c,d,e,f,g,h)}r=R.prototype;
r.add=function(a,b,c){D(a)&&(b=a,a=T(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.L[d],C(e)&&(e=[e]),V(b,e,this.B,0,this.index[f],a,e[0],c);if(this.J){let d=T(b,this.J),e=y();C(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.l[g]||(this.l[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.o){const l=this.register[a]||(this.register[a]=[]);l[l.length]=h}}if(this.store){let d;if(this.G){d=
y();for(let e=0,f;e<this.G.length;e++)f=this.G[e],C(f)?d[f]=b[f]:U(b,d,f,0,f[0])}this.store[a]=d||b}}return this};r.append=function(a,b){return this.add(a,b,!0)};r.update=function(a,b){return this.remove(a).add(a,b)};
r.remove=function(a){D(a)&&(a=T(a,this.key));if(this.register[a]){var b=this.o&&!this.m;for(var c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.J&&!b)for(let d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
r.search=function(a,b,c,d){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let e=[],f=[],g,h,l,m,p,u,t=0;if(c)if(c.constructor===Array)l=c,c=null;else{l=(g=c.pluck)||c.index||c.field||c;m=c.tag;h=this.store&&c.enrich;p="and"===c.bool;b=c.limit||100;u=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let k=0,n;k<m.length;k++)if(n=xa.call(this,m[k],b,u,h))e[e.length]=n,t++;return t?e:[]}C(l)?l=[l]:l.constructor===Array||(l=null)}l||(l=this.h);p=p&&(1<l.length||m&&1<m.length);const q=!d&&(this.m||this.async)&&[];for(let k=
0,n,x,z;k<l.length;k++){let A;x=l[k];C(x)||(A=x,x=x.field);if(q)q[k]=this.index[x].searchAsync(a,b,A||c);else{d?n=d[k]:n=this.index[x].search(a,b,A||c);z=n&&n.length;if(m&&z){const B=[];let G=0;p&&(B[0]=[n]);for(let W=0,pa,P;W<m.length;W++)if(pa=m[W],z=(P=this.l[pa])&&P.length)G++,B[B.length]=p?[P]:P;G&&(n=p?la(B,b||100,u||0):ma(n,B),z=n.length)}if(z)f[t]=x,e[t++]=n;else if(p)return[]}}if(q){const k=this;return new Promise(function(n){Promise.all(q).then(function(x){n(k.search(a,b,c,x))})})}if(!t)return[];
if(g&&(!h||!this.store))return e[0];for(let k=0,n;k<f.length;k++){n=e[k];n.length&&h&&(n=ya.call(this,n));if(g)return n;e[k]={field:f[k],result:n}}return e};function xa(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=ya.call(this,e));return{tag:a,result:e}}}function ya(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}r.contain=function(a){return!!this.register[a]};r.get=function(a){return this.store[a]};
r.set=function(a,b){this.store[a]=b;return this};r.searchCache=na;r.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.h.length){const f=this.h[d],g=this.index[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.l;break;case 2:c="store";f=this.store;break;default:return}qa(a,this,c,d,e,f)}};
r.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.o=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.o=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};ka(R.prototype);const za=/[\W_]+/,Aa=[F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",F("[\u00e8\u00e9\u00ea\u00eb]"),"e",F("[\u00ec\u00ed\u00ee\u00ef]"),"i",F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",F("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",F("[\u00fd\u0177\u00ff]"),"y",F("\u00f1"),"n",F("[\u00e7c]"),"k",F("\u00df"),"s",F(" & ")," and "];function Ba(a){return ia(this,ca(a).toLowerCase(),!a.normalize&&Aa,za)};var Da={encode:Ca,C:!1,H:"strict"};const Ea=/[^a-z0-9]+/,Fa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ca(a){a=Ba.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ea),d=c.length;for(let e=0,f,g=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let h=Fa[f]||f,l=h;for(let m=1;m<a.length;m++){f=a[m];const p=Fa[f]||f;p&&p!==l&&(h+=p,l=p)}b[g++]=h}}return b};var Ha={encode:Ga,C:!1,H:""};const Ia=[F("ae"),"a",F("oe"),"o",F("sh"),"s",F("th"),"t",F("ph"),"f",F("pf"),"f"];function Ga(a,b){a&&(a=Ca.call(this,a).join(" "),2<a.length&&(a=H(a,Ia)),b||(1<a.length&&(a=ea(a)),a&&(a=a.split(" "))));return a};var Ka={encode:Ja,C:!1,H:""};const La=F("(?!\\b)[aeiouy]");function Ja(a){a&&(a=Ga.call(this,a,!0),1<a.length&&(a=a.replace(La,"")),1<a.length&&(a=ea(a)),a&&(a=a.split(" ")));return a};I["latin:simple"]={encode:Ba,C:!1,H:""};I["latin:balance"]=Da;I["latin:advanced"]=Ha;I["latin:extra"]=Ka;const X=self;let Y;const Z={Index:L,Document:R,Worker:O,registerCharset:function(a,b){I[a]=b},registerLanguage:function(a,b){ja[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));

View File

@@ -5,25 +5,25 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var u;function v(a,b){return"undefined"!==typeof a?a:b}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function aa(a,b){return b.length-a.length}function A(a){return"string"===typeof a}function B(a){return"object"===typeof a};const ba=/[\u0300-\u036f]/g;function C(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function D(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",g=0;for(let h=0,k,l;h<e;h++)k=c[h],(l=a[k])?(d[g++]=E(b?"(?!\\b)"+k+"(\\b|_)":k),d[g++]=l):f+=(f?"|":"")+k;f&&(d[g++]=E(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[g]="");return d}function F(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function E(a){return new RegExp(a,"g")}
function H(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};const ca=/[\W_]+/;function I(a){return J(this,C(a).toLowerCase(),!1,ca)};const L={},M={};let da=Promise;function ea(a){N(a,"add");N(a,"append");N(a,"search");N(a,"update");N(a,"remove")}function N(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new da(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,e);c.async=!1;g(h)})});return f?(d.then(f),this):d}};function fa(a,b,c,e){var d=a.length;let f=[],g,h=0;e&&(e=[]);for(--d;0<=d;d--){const k=a[d],l=k.length,p=y();let r=!g;for(let q=0;q<l;q++){const t=k[q],m=t.length;if(m)for(let n=0,x=0,z;n<m;n++)if(z=t[n],!g)p[z]=1;else if(g[z]){if(d)e&&x<b&&((e[q]||(e[q]=[]))[x++]=z),p[z]=1;else if(c)c--;else if(f[h++]=z,h===b)return f;r=!0}}if(!r&&!e)return[];g=p}if(e)for(let k=e.length-1,l,p;0<=k;k--)if((p=(l=e[k])&&l.length)&&c&&(p<=c?(c-=p,p=0):p-=c),p){if(h+p>=b)return f.concat(l.slice(c,b-h+c));f=f.concat(c?
l.slice(c):l);h+=p;c=0}return f}function ja(a,b){const c=y(),e=y(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d[d.length]=k)}return d};const ka={memory:{charset:"latin:extra",A:3,o:3,D:!1,s:"memory"},performance:{threshold:8,o:3,context:{depth:1,G:!0}},match:{charset:"latin:extra",H:"full",A:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,G:!0}},"default":{A:3,threshold:0,depth:3}};M["latin:default"]=I;
function O(a,b){if(!(this instanceof O))return new O(a);var c;let e;a?(A(a)?a=ka[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,A(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=M[c]),A(e)&&(e=L[e])):a={};let d,f,g,h=a.context||{};this.encode=a.encode||c&&c.encode||I;this.register=b||y();d=a.resolution||9;f=a.threshold||0;f>=d&&(f=d-1);this.A=d;this.threshold=f;this.F=b=c&&c.H||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.G=v(h.bidirectional,!0);this.s=g="memory"===a.optimize;
this.D=v(a.fastupdate,!0);this.o=a.minlength||1;this.h=g?w(d-f):y();d=h.resolution||d;f=h.threshold||f;f>=d&&(f=d-1);this.l=d;this.B=f;this.m=g?w(d-f):y();this.C=c&&c.C||a.rtl;this.I=(b=a.matcher||e&&e.I)&&D(b,!1);this.J=(b=a.stemmer||e&&e.J)&&D(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=y();for(let k=0,l=a.length;k<l;k++)c[a[k]]=1;a=c}this.filter=a}
function J(a,b,c,e){if(b&&(c&&(b=F(b,c)),a.I&&(b=F(b,a.I)),a.J&&1<b.length&&(b=F(b,a.J)),e||""===e)){b=b.split(e);if(a.filter){a=a.filter;c=b.length;e=[];for(let d=0,f=0;d<c;d++){const g=b[d];g&&!a[g]&&(e[f++]=g)}a=e}else a=b;return a}return b}u=O.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,e){if(!e&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),e=b.length)){const p=this.depth,r=this.A-this.threshold,q=y(),t=y();for(let m=0;m<e;m++){let n=b[this.C?e-1-m:m];var d=n.length;if(n&&d>=this.o&&(p||!q[n])){var f=Math.min(this.A/e*m|0,m);if(f<r){var g="";switch(this.F){case "full":if(3<d){for(var h=0;h<d;h++){var k=h?Math.min(f/2+this.A/d*h/2|0,f+h):f;if(k<r)for(var l=d;l>h;l--)g=n.substring(h,l),g.length>=this.o&&R(this,q,g,k,a,c)}break}case "reverse":if(2<
d){for(h=d-1;0<h;h--)g=n[h]+g,g.length>=this.o&&R(this,q,g,f,a,c);g=""}case "forward":if(1<d)for(h=0;h<d;h++)g+=n[h],g.length>=this.o&&R(this,q,g,f,a,c);break;default:if(R(this,q,n,f,a,c),p&&1<e&&m<e-1)for(d=this.l-this.B,f=y(),g=n,h=Math.min(p+1,e-m),f[g]=1,k=1;k<h;k++)if((n=b[this.C?e-1-m-k:m+k])&&n.length>=this.o&&!f[n]){if(f[n]=1,l=Math.min((this.l-h)/e*m+k|0,m+(k-1)),l<d){const x=this.G&&n>g;R(this,t,x?g:n,l,a,c,x?n:g)}}else h=Math.min(h+1,e-m)}}}}this.D||(this.register[a]=1)}return this};
function R(a,b,c,e,d,f,g){let h=g?a.m:a.h;if(!b[c]||g&&!b[c][g])a.s&&(h=h[e]),g?(b=b[c]||(b[c]=y()),b[g]=1,h=h[g]||(h[g]=y())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[e]||(h[e]=[])),f&&-1!==h.indexOf(d)||(h[h.length]=d,a.D&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=h))}
u.search=function(a,b,c){B(a)?(c=a,a=c.query):B(b)&&(c=b);let e=[],d;var f=this.threshold;let g,h=0;if(c){b=c.limit;h=c.offset||0;f=v(c.threshold,f);var k=c.context;g=c.suggest}if(a&&(a=this.encode(a),d=a.length,1<d)){c=y();var l=[];for(let r=0,q=0,t;r<d;r++)if((t=a[r])&&t.length>=this.o&&!c[t])if(this.s||g||this.h[t])l[q++]=t,c[t]=1;else return e;a=l;d=a.length}if(!d)return e;b||(b=100);c=this.A-f;f=this.l-f;k=this.depth&&1<d&&!1!==k;l=0;let p;k?(p=a[0],l=1):1<d&&a.sort(aa);for(let r,q;l<d;l++){q=
a[l];k?(r=la(this,e,g,f,b,h,2===d,q,p),g&&!1===r&&e.length||(p=q)):r=la(this,e,g,c,b,h,1===d,q);if(r)return r;if(g&&l===d-1){let t=e.length;if(!t){if(k){k=0;l=-1;continue}return e}if(1===t)return ma(e[0],b,h)}}return fa(e,b,h,g)};
function la(a,b,c,e,d,f,g,h,k){let l=[],p=k?a.m:a.h;a.s||(p=na(p,h,k,a.G));if(p){let r=0;e=Math.min(p.length,e);for(let q=0,t=0,m,n;q<e&&!(m=p[q],a.s&&(m=na(m,h,k,a.G)),m&&g&&(n=m.length,n<=f?(f-=n,m=null):f&&(m=m.slice(f),f=0)),m&&(l[r++]=m,g&&(t+=m.length,t>=d)));q++);if(r){if(g)return ma(l,d,0);b[b.length]=l;return}}return!c&&l}function ma(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function na(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};u.remove=function(a,b){const c=this.register[a];if(c){if(this.D)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else S(this.h,a,this.A-this.threshold,this.s),this.depth&&S(this.m,a,this.l-this.B,this.s);b||delete this.register[a]}return this};
function S(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let g=0,h;g<d;g++)if(h=a[g])f=S(h,b,c,e,d),e||f||delete a[g]}else for(let g in a)(f=S(a[g],b,c,e,d))||delete a[g];return f}ea(O.prototype);function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.K=[];this.h=[];this.F=[];this.register=y();this.key=(c=b.key||b.id)&&U(c,this.F)||"id";this.D=v(a.fastupdate,!0);this.B=!!(c=b.extern);this.l=!this.B&&(c=b.store)&&!0!==c&&[];this.store=c&&(this.B?c:y());this.async=!1;c=y();let e=b.index||b.field||b;A(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],A(f)||(g=f,f=f.field),g=B(g)?Object.assign({},a,g):a,this.L||(c[f]=new O(g,this.register)),this.K[d]=U(f,this.F),
this.h[d]=f;if(this.l)for(a=b.store,A(a)&&(a=[a]),b=0;b<a.length;b++)this.l[b]=U(a[b],this.F);this.m=c}function U(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function oa(a,b){if(A(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function V(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)V(a,b,c,e,d);else b=b[d]||(b[d]=y()),d=c[++e],V(a,b,c,e,d)}function W(a,b,c,e,d,f,g,h){a=a[g];if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,c,e,d,f,g,h);else g=b[++e],W(a,b,c,e,d,f,g,h)}u=T.prototype;
u.add=function(a,b,c){B(a)&&(b=a,a=oa(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.K[e],A(d)&&(d=[d]),W(b,d,this.F,0,this.m[f],a,d[0],c);if(this.store&&!this.B){let e;if(this.l){e=y();for(let d=0,f;d<this.l.length;d++)f=this.l[d],A(f)?e[f]=b[f]:V(b,e,f,0,f[0])}this.store[a]=e||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){B(a)&&(a=oa(a,this.key));if(this.register[a]){const b=this.D&&!this.L;for(let c=0;c<this.h.length&&(this.m[this.h[c]].remove(a,b),!b);c++);this.store&&!this.B&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,e){B(a)?(c=a,a=c.query):B(b)&&(c=b,b=0);let d=[],f=[],g,h,k,l,p,r,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;l=!1;h=this.store&&c.enrich;p="and"===c.bool;b=c.limit||100;r=c.offset||0;if(l&&(A(l)&&(l=[l]),!a)){for(let m=0,n;m<l.length;m++)if(n=pa.call(this,l[m],b,r,h))d[d.length]=n,q++;return q?d:[]}A(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);p=p&&(1<k.length||l&&1<l.length);const t=!e&&(this.L||this.async)&&[];for(let m=
0,n,x,z;m<k.length;m++){let P;x=k[m];A(x)||(P=x,x=x.field);if(t)t[m]=this.m[x].searchAsync(a,b,P||c);else{e?n=e[m]:n=this.m[x].search(a,b,P||c);z=n&&n.length;if(l&&z){const G=[];let ha=0;p&&(G[0]=[n]);for(let Q=0,ia,K;Q<l.length;Q++)if(ia=l[Q],z=(K=this.M[ia])&&K.length)ha++,G[G.length]=p?[K]:K;ha&&(n=p?fa(G,b||100,r||0):ja(n,G),z=n.length)}if(z)f[q]=x,d[q++]=n;else if(p)return[]}}if(t){const m=this;return new Promise(function(n){Promise.all(t).then(function(x){n(m.search(a,b,c,x))})})}if(!q)return[];
if(g&&(!h||!this.store))return d[0];for(let m=0,n;m<f.length;m++){n=d[m];n.length&&h&&(n=qa.call(this,n));if(g)return n;d[m]={field:f[m],result:n}}return d};function pa(a,b,c,e){let d=this.M[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=qa.call(this,d));return{tag:a,result:d}}}function qa(a){const b=Array(a.length);for(let c=0,e;c<a.length;c++)e=a[c],b[c]={key:e,doc:this.store[e]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};ea(T.prototype);const ra=/[\W_]+/,sa=[E("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",E("[\u00e8\u00e9\u00ea\u00eb]"),"e",E("[\u00ec\u00ed\u00ee\u00ef]"),"i",E("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",E("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",E("[\u00fd\u0177\u00ff]"),"y",E("\u00f1"),"n",E("[\u00e7c]"),"k",E("\u00df"),"s",E(" & ")," and "];function ta(a){return J(this,C(a).toLowerCase(),!a.normalize&&sa,ra)};var va={encode:ua,C:!1,H:"strict"};const wa=/[^a-z0-9]+/,xa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function ua(a){a=ta.call(this,a).join(" ");const b=[];if(a){const c=a.split(wa),e=c.length;for(let d=0,f,g=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let h=xa[f]||f,k=h;for(let l=1;l<a.length;l++){f=a[l];const p=xa[f]||f;p&&p!==k&&(h+=p,k=p)}b[g++]=h}}return b};var za={encode:ya,C:!1,H:""};const Aa=[E("ae"),"a",E("oe"),"o",E("sh"),"s",E("th"),"t",E("ph"),"f",E("pf"),"f"];function ya(a,b){a&&(a=ua.call(this,a).join(" "),2<a.length&&(a=F(a,Aa)),b||(1<a.length&&(a=H(a)),a&&(a=a.split(" "))));return a};var Ca={encode:Ba,C:!1,H:""};const Da=E("(?!\\b)[aeiouy]");function Ba(a){a&&(a=ya.call(this,a,!0),1<a.length&&(a=a.replace(Da,"")),1<a.length&&(a=H(a)),a&&(a=a.split(" ")));return a};M["latin:simple"]={encode:ta,C:!1,H:""};M["latin:balance"]=va;M["latin:advanced"]=za;M["latin:extra"]=Ca;const X=self;let Y;const Z={Index:O,Document:T,Worker:null,registerCharset:function(a,b){M[a]=b},registerLanguage:function(a,b){L[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
(function(self){'use strict';var u;function v(a){return"undefined"!==typeof a?a:!0}function x(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=z();return b}function z(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};const ba=/[\u0300-\u036f]/g;function E(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function F(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",h=0;for(let g=0,l,m;g<e;g++)l=c[g],(m=a[l])?(d[h++]=H(b?"(?!\\b)"+l+"(\\b|_)":l),d[h++]=m):f+=(f?"|":"")+l;f&&(d[h++]=H(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[h]="");return d}function I(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function H(a){return new RegExp(a,"g")}
function J(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};const ca=/[\W_]+/;function K(a){return M(this,E(a).toLowerCase(),!1,ca)};const da={},N={};function ea(a){O(a,"add");O(a,"append");O(a,"search");O(a,"update");O(a,"remove")}function O(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(h){setTimeout(function(){c.async=!0;const g=c[b].apply(c,e);c.async=!1;h(g)})});return f?(d.then(f),this):d}};function fa(a,b,c,e){const d=a.length;let f=[],h;let g,l;for(var m=0;m<d;m++){var p=a[m],t=p.length,r=0;for(let k=0,n;k<t;k++)(n=p[k])&&(r+=n.length);if(!q||r<q){var q=r;g=p;l=m}}g=1===g.length?g[0]:[].concat.apply([],g);e&&(e=[g],h=z());m=q=0;for(p=d-1;0<=p;p--)if(p!==l){m++;t=a[p];r=t.length;const k=[];let n=0;for(let w=0,y;w<g.length;w++){y=g[w];let A;for(let B=0;B<r;B++){const G=t[B];if(G.length&&(A=-1!==G.indexOf(y))){if(m===d-1){if(c)c--;else if(f[q++]=y,q===b)return f;e&&(h[y]=1)}break}}A&&
(k[n++]=y)}if(e)e[m]=k;else if(!n)return[];g=k}if(e)for(let k=e.length-1,n,w;0<=k;k--)if(w=(n=e[k])&&n.length)for(let y=0,A;y<w;y++)if(A=n[y],!h[A])if(h[A]=1,c)c--;else if(f[q++]=A,q===b)return f;return f}function ha(a,b){const c=z(),e=z(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,h;f<b.length;f++){h=b[f];for(let g=0,l;g<h.length;g++)l=h[g],c[l]&&!e[l]&&(e[l]=1,d[d.length]=l)}return d};const ja={memory:{charset:"latin:extra",C:3,m:3,B:!1,o:"memory"},performance:{threshold:8,m:3,context:{depth:1,D:!0}},match:{charset:"latin:extra",F:"full",C:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,D:!0}},"default":{C:3,threshold:0,depth:3}};N["latin:default"]=K;
function P(a,b){if(!(this instanceof P))return new P(a);var c;let e;a?(C(a)?a=ja[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=N[c]),C(e)&&(e=da[e])):a={};let d,f,h=a.context||{};this.encode=a.encode||c&&c.encode||K;this.register=b||z();this.C=d=a.resolution||9;this.G=b=c&&c.F||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.D=v(h.bidirectional);this.o=f="memory"===a.optimize;this.B=v(a.fastupdate);this.m=a.minlength||1;
this.h=f?x(d):z();this.s=d=h.resolution||1;this.l=f?x(d):z();this.A=c&&c.A||a.rtl;this.H=(b=a.matcher||e&&e.H)&&F(b,!1);this.I=(b=a.stemmer||e&&e.I)&&F(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=z();for(let g=0,l=a.length;g<l;g++)c[a[g]]=1;a=c}this.filter=a}
function M(a,b,c,e){if(b&&(c&&(b=I(b,c)),a.H&&(b=I(b,a.H)),a.I&&1<b.length&&(b=I(b,a.I)),e||""===e)){b=b.split(e);if(a.filter){a=a.filter;c=b.length;e=[];for(let d=0,f=0;d<c;d++){const h=b[d];h&&!a[h]&&(e[f++]=h)}a=e}else a=b;return a}return b}u=P.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,e){if(!e&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),e=b.length)){const m=this.depth,p=this.C,t=z(),r=z();for(let q=0;q<e;q++){let k=b[this.A?e-1-q:q];var d=k.length;if(k&&d>=this.m&&(m||!t[k])){var f=Math.min(p/e*q|0,q),h="";switch(this.G){case "full":if(3<d){for(var g=0;g<d;g++){var l=g?Math.min(f/2+p/d*g/2|0,f+g):f;for(let n=d;n>g;n--)h=k.substring(g,n),h.length>=this.m&&Q(this,t,h,l,a,c)}break}case "reverse":if(2<d){for(g=d-1;0<g;g--)h=
k[g]+h,h.length>=this.m&&Q(this,t,h,f,a,c);h=""}case "forward":if(1<d)for(g=0;g<d;g++)h+=k[g],h.length>=this.m&&Q(this,t,h,f,a,c);break;default:if(Q(this,t,k,f,a,c),m&&1<e&&q<e-1)for(d=z(),f=k,h=Math.min(m+1,e-q),d[f]=1,g=1;g<h;g++)(k=b[this.A?e-1-q-g:q+g])&&k.length>=this.m&&!d[k]?(d[k]=1,l=this.D&&k>f,Q(this,r,l?f:k,0,a,c,l?k:f)):h=Math.min(h+1,e-q)}}}this.B||(this.register[a]=1)}return this};
function Q(a,b,c,e,d,f,h){let g=h?a.l:a.h;if(!b[c]||h&&!b[c][h])a.o&&(g=g[e]),h?(b=b[c]||(b[c]=z()),b[h]=1,g=g[h]||(g[h]=z())):b[c]=1,g=g[c]||(g[c]=[]),a.o||(g=g[e]||(g[e]=[])),f&&-1!==g.indexOf(d)||(g[g.length]=d,a.B&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=g))}
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let e=[],d;let f,h=0;if(c){b=c.limit;h=c.offset||0;var g=c.context;f=c.suggest}if(a&&(a=this.encode(a),d=a.length,1<d)){c=z();var l=[];for(let p=0,t=0,r;p<d;p++)if((r=a[p])&&r.length>=this.m&&!c[r])if(this.o||f||this.h[r])l[t++]=r,c[r]=1;else return e;a=l;d=a.length}if(!d)return e;b||(b=100);g=this.depth&&1<d&&!1!==g;c=0;let m;g?(m=a[0],c=1):1<d&&a.sort(aa);for(let p,t;c<d;c++){t=a[c];g?(p=ka(this,e,f,b,h,2===d,t,m),f&&!1===p&&e.length||(m=
t)):p=ka(this,e,f,b,h,1===d,t);if(p)return p;if(f&&c===d-1){l=e.length;if(!l){if(g){g=0;c=-1;continue}return e}if(1===l)return la(e[0],b,h)}}return fa(e,b,h,f)};
function ka(a,b,c,e,d,f,h,g){let l=[],m=g?a.l:a.h;a.o||(m=ma(m,h,g,a.D));if(m){let p=0;const t=Math.min(m.length,g?a.s:a.C);for(let r=0,q=0,k,n;r<t;r++)if(k=m[r])if(a.o&&(k=ma(k,h,g,a.D)),d&&k&&f&&(n=k.length,n<=d?(d-=n,k=null):(k=k.slice(d),d=0)),k&&(l[p++]=k,f&&(q+=k.length,q>=e)))break;if(p){if(f)return la(l,e,0);b[b.length]=l;return}}return!c&&l}function la(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function ma(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};u.remove=function(a,b){const c=this.register[a];if(c){if(this.B)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else S(this.h,a,this.C,this.o),this.depth&&S(this.l,a,this.s,this.o);b||delete this.register[a]}return this};
function S(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let h=0,g;h<d;h++)if(g=a[h])f=S(g,b,c,e,d),e||f||delete a[h]}else for(let h in a)(f=S(a[h],b,c,e,d))||delete a[h];return f}ea(P.prototype);function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.G=[];this.h=[];this.s=[];this.register=z();this.key=(c=b.key||b.id)&&U(c,this.s)||"id";this.B=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&z();this.async=!1;c=z();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,h;d<e.length;d++)f=e[d],C(f)||(h=f,f=f.field),h=D(h)?Object.assign({},a,h):a,this.J||(c[f]=new P(h,this.register)),this.G[d]=U(f,this.s),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
[a]),b=0;b<a.length;b++)this.l[b]=U(a[b],this.s);this.index=c}function U(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function na(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function V(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)V(a,b,c,e,d);else b=b[d]||(b[d]=z()),d=c[++e],V(a,b,c,e,d)}function W(a,b,c,e,d,f,h,g){a=a[h];if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,g,!0)}else if(a)if(a.constructor===Array)for(h=0;h<a.length;h++)W(a,b,c,e,d,f,h,g);else h=b[++e],W(a,b,c,e,d,f,h,g)}u=T.prototype;
u.add=function(a,b,c){D(a)&&(b=a,a=na(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.G[e],C(d)&&(d=[d]),W(b,d,this.s,0,this.index[f],a,d[0],c);if(this.store){let e;if(this.l){e=z();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:V(b,e,f,0,f[0])}this.store[a]=e||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){D(a)&&(a=na(a,this.key));if(this.register[a]){const b=this.B&&!this.J;for(let c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,e){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let d=[],f=[],h,g,l,m,p,t,r=0;if(c)if(c.constructor===Array)l=c,c=null;else{l=(h=c.pluck)||c.index||c.field||c;m=!1;g=this.store&&c.enrich;p="and"===c.bool;b=c.limit||100;t=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let k=0,n;k<m.length;k++)if(n=oa.call(this,m[k],b,t,g))d[d.length]=n,r++;return r?d:[]}C(l)?l=[l]:l.constructor===Array||(l=null)}l||(l=this.h);p=p&&(1<l.length||m&&1<m.length);const q=!e&&(this.J||this.async)&&[];for(let k=
0,n,w,y;k<l.length;k++){let A;w=l[k];C(w)||(A=w,w=w.field);if(q)q[k]=this.index[w].searchAsync(a,b,A||c);else{e?n=e[k]:n=this.index[w].search(a,b,A||c);y=n&&n.length;if(m&&y){const B=[];let G=0;p&&(B[0]=[n]);for(let R=0,ia,L;R<m.length;R++)if(ia=m[R],y=(L=this.K[ia])&&L.length)G++,B[B.length]=p?[L]:L;G&&(n=p?fa(B,b||100,t||0):ha(n,B),y=n.length)}if(y)f[r]=w,d[r++]=n;else if(p)return[]}}if(q){const k=this;return new Promise(function(n){Promise.all(q).then(function(w){n(k.search(a,b,c,w))})})}if(!r)return[];
if(h&&(!g||!this.store))return d[0];for(let k=0,n;k<f.length;k++){n=d[k];n.length&&g&&(n=pa.call(this,n));if(h)return n;d[k]={field:f[k],result:n}}return d};function oa(a,b,c,e){let d=this.K[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=pa.call(this,d));return{tag:a,result:d}}}function pa(a){const b=Array(a.length);for(let c=0,e;c<a.length;c++)e=a[c],b[c]={key:e,doc:this.store[e]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};ea(T.prototype);const qa=/[\W_]+/,ra=[H("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",H("[\u00e8\u00e9\u00ea\u00eb]"),"e",H("[\u00ec\u00ed\u00ee\u00ef]"),"i",H("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",H("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",H("[\u00fd\u0177\u00ff]"),"y",H("\u00f1"),"n",H("[\u00e7c]"),"k",H("\u00df"),"s",H(" & ")," and "];function sa(a){return M(this,E(a).toLowerCase(),!a.normalize&&ra,qa)};var ua={encode:ta,A:!1,F:"strict"};const va=/[^a-z0-9]+/,wa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function ta(a){a=sa.call(this,a).join(" ");const b=[];if(a){const c=a.split(va),e=c.length;for(let d=0,f,h=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let g=wa[f]||f,l=g;for(let m=1;m<a.length;m++){f=a[m];const p=wa[f]||f;p&&p!==l&&(g+=p,l=p)}b[h++]=g}}return b};var ya={encode:xa,A:!1,F:""};const za=[H("ae"),"a",H("oe"),"o",H("sh"),"s",H("th"),"t",H("ph"),"f",H("pf"),"f"];function xa(a,b){a&&(a=ta.call(this,a).join(" "),2<a.length&&(a=I(a,za)),b||(1<a.length&&(a=J(a)),a&&(a=a.split(" "))));return a};var Ba={encode:Aa,A:!1,F:""};const Ca=H("(?!\\b)[aeiouy]");function Aa(a){a&&(a=xa.call(this,a,!0),1<a.length&&(a=a.replace(Ca,"")),1<a.length&&(a=J(a)),a&&(a=a.split(" ")));return a};N["latin:simple"]={encode:sa,A:!1,F:""};N["latin:balance"]=ua;N["latin:advanced"]=ya;N["latin:extra"]=Ba;const X=self;let Y;const Z={Index:P,Document:T,Worker:null,registerCharset:function(a,b){N[a]=b},registerLanguage:function(a,b){da[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));

File diff suppressed because it is too large Load Diff

View File

@@ -6,42 +6,41 @@
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';var u;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}var v="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var w=ba(this);function z(a,b){if(b)a:{var c=w;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
z("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+f++,g)}function c(g,e){this.h=g;v(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",f=0;return b});
z("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=w[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,f={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};f[Symbol.iterator]=function(){return f};return f}z("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}
z("Promise",function(a){function b(e){this.l=0;this.m=void 0;this.h=[];this.I=!1;var h=this.o();try{e(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(e){return e instanceof b?e:new b(function(h){h(e)})}if(a)return a;c.prototype.l=function(e){if(null==this.h){this.h=[];var h=this;this.m(function(){h.B()})}this.h.push(e)};var f=w.setTimeout;c.prototype.m=function(e){f(e,0)};c.prototype.B=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var h=0;h<e.length;++h){var k=
e[h];e[h]=null;try{k()}catch(l){this.o(l)}}}this.h=null};c.prototype.o=function(e){this.m(function(){throw e;})};b.prototype.o=function(){function e(l){return function(n){k||(k=!0,l.call(h,n))}}var h=this,k=!1;return{resolve:e(this.T),reject:e(this.B)}};b.prototype.T=function(e){if(e===this)this.B(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.V(e);else{a:switch(typeof e){case "object":var h=null!=e;break a;case "function":h=!0;break a;default:h=!1}h?this.S(e):this.G(e)}};
b.prototype.S=function(e){var h=void 0;try{h=e.then}catch(k){this.B(k);return}"function"==typeof h?this.W(h,e):this.G(e)};b.prototype.B=function(e){this.J(2,e)};b.prototype.G=function(e){this.J(1,e)};b.prototype.J=function(e,h){if(0!=this.l)throw Error("Cannot settle("+e+", "+h+"): Promise already settled in state"+this.l);this.l=e;this.m=h;2===this.l&&this.U();this.P()};b.prototype.U=function(){var e=this;f(function(){if(e.R()){var h=w.console;"undefined"!==typeof h&&h.error(e.m)}},1)};b.prototype.R=
function(){if(this.I)return!1;var e=w.CustomEvent,h=w.Event,k=w.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"===typeof h?e=new h("unhandledrejection",{cancelable:!0}):(e=w.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e));e.promise=this;e.reason=this.m;return k(e)};b.prototype.P=function(){if(null!=this.h){for(var e=0;e<this.h.length;++e)g.l(this.h[e]);this.h=null}};var g=new c;b.prototype.V=
function(e){var h=this.o();e.M(h.resolve,h.reject)};b.prototype.W=function(e,h){var k=this.o();try{e.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(e,h){function k(m,p){return"function"==typeof m?function(r){try{l(m(r))}catch(t){n(t)}}:p}var l,n,q=new b(function(m,p){l=m;n=p});this.M(k(e,l),k(h,n));return q};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.M=function(e,h){function k(){switch(l.l){case 1:e(l.m);break;case 2:h(l.m);break;default:throw Error("Unexpected state: "+
l.l);}}var l=this;null==this.h?g.l(k):this.h.push(k);this.I=!0};b.resolve=d;b.reject=function(e){return new b(function(h,k){k(e)})};b.race=function(e){return new b(function(h,k){for(var l=ea(e),n=l.next();!n.done;n=l.next())d(n.value).M(h,k)})};b.all=function(e){var h=ea(e),k=h.next();return k.done?d([]):new b(function(l,n){function q(r){return function(t){m[r]=t;p--;0==p&&l(m)}}var m=[],p=0;do m.push(void 0),p++,d(k.value).M(q(m.length-1),n),k=h.next();while(!k.done)})};return b});
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(a[f]=d[f])}return a};z("Object.assign",function(a){return a||fa});function A(a,b){return"undefined"!==typeof a?a:b}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}function ia(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a}function F(a){return"function"===typeof a};var ja=/[\u0300-\u036f]/g;function ka(a){a.normalize&&(a=a.normalize("NFD").replace(ja,""));return a}function la(a,b){for(var c=Object.keys(a),d=c.length,f=[],g="",e=0,h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(f[e++]=G(b?"(?!\\b)"+k+"(\\b|_)":k),f[e++]=l):g+=(g?"|":"")+k;g&&(f[e++]=G(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),f[e]="");return f}function H(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function G(a){return new RegExp(a,"g")}
function ma(a){for(var b="",c="",d=0,f=a.length,g=void 0;d<f;d++)(g=a[d])!==c&&(b+=c=g);return b};var na=/[\W_]+/;function oa(a){return pa(this,ka(a).toLowerCase(),!1,na)};var qa={},I={};var ra=Promise;function sa(a){J(a,"add");J(a,"append");J(a,"search");J(a,"update");J(a,"remove")}function J(a,b){a[b+"Async"]=function(){var c=this,d=arguments,f=d[d.length-1];if(F(f)){var g=f;delete d[d.length-1]}f=new ra(function(e){setTimeout(function(){c.async=!0;var h=c[b].apply(c,d);c.async=!1;e(h)})});return g?(f.then(g),this):f}};function ua(a,b,c,d){var f=a.length,g=[],e=0;d&&(d=[]);for(--f;0<=f;f--){for(var h=a[f],k=h.length,l=B(),n=!x,q=0;q<k;q++){var m=h[q],p=m.length;if(p)for(var r=0,t=0,y;r<p;r++)if(y=m[r],!x)l[y]=1;else if(x[y]){if(f)d&&t<b&&((d[q]||(d[q]=[]))[t++]=y),l[y]=1;else if(c)c--;else if(g[e++]=y,e===b)return g;n=!0}}if(!n&&!d)return[];var x=l}if(d)for(a=d.length-1;0<=a;a--)if((f=(x=d[a])&&x.length)&&c&&(f<=c?(c-=f,f=0):f-=c),f){if(e+f>=b)return g.concat(x.slice(c,b-e+c));g=g.concat(c?x.slice(c):x);e+=f;c=
0}return g}function va(a,b){for(var c=B(),d=B(),f=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var e=0,h;e<g.length;e++)h=g[e],c[h]&&!d[h]&&(d[h]=1,f[f.length]=h)}return f};function L(a){this.l=!0!==a&&a;this.cache=B();this.h=[]}function wa(a,b,c){D(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}L.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};L.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var xa={memory:{charset:"latin:extra",F:3,D:3,A:!1,C:"memory"},performance:{threshold:8,D:3,context:{depth:1,K:!0}},match:{charset:"latin:extra",L:"full",F:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,K:!0}},"default":{F:3,threshold:0,depth:3}};function ya(a,b,c,d,f,g){setTimeout(function(){var e=a(c,JSON.stringify(g));e&&e.then?e.then(function(){b.export(a,b,c,d,f+1)}):b.export(a,b,c,d,f+1)})};I["latin:default"]=oa;
function M(a,b){if(!(this instanceof M))return new M(a);var c;if(a){C(a)?a=xa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=I[c]);C(d)&&(d=qa[d])}else a={};var f,g=a.context||{};this.encode=a.encode||c&&c.encode||oa;this.register=b||B();var e=a.resolution||9;var h=a.threshold||0;h>=e&&(h=e-1);this.F=e;this.threshold=h;this.o=b=c&&c.L||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.K=A(g.bidirectional,!0);this.C=f="memory"===
a.optimize;this.A=A(a.fastupdate,!0);this.D=a.minlength||1;this.map=f?ha(e-h):B();e=g.resolution||e;h=g.threshold||h;h>=e&&(h=e-1);this.l=e;this.m=h;this.h=f?ha(e-h):B();this.H=c&&c.H||a.rtl;this.N=(b=a.matcher||d&&d.N)&&la(b,!1);this.O=(b=a.stemmer||d&&d.O)&&la(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=B();g=0;for(e=c.length;g<e;g++)d[c[g]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new L(b)}
function pa(a,b,c,d){if(b&&(c&&(b=H(b,c)),a.N&&(b=H(b,a.N)),a.O&&1<b.length&&(b=H(b,a.O)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(var f=0,g=0;f<c;f++){var e=b[f];e&&!a[e]&&(d[g++]=e)}b=d}return b}return b}u=M.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){for(var f=this.depth,g=this.F-this.threshold,e=B(),h=B(),k=0;k<d;k++){var l=b[this.H?d-1-k:k],n=l.length;if(l&&n>=this.D&&(f||!e[l])){var q=Math.min(this.F/d*k|0,k);if(q<g){var m="";switch(this.o){case "full":if(3<n){for(var p=0;p<n;p++){var r=p?Math.min(q/2+this.F/n*p/2|0,q+p):q;if(r<g)for(var t=n;t>p;t--)m=l.substring(p,t),m.length>=this.D&&N(this,e,m,r,a,c)}break}case "reverse":if(2<
n){for(p=n-1;0<p;p--)m=l[p]+m,m.length>=this.D&&N(this,e,m,q,a,c);m=""}case "forward":if(1<n)for(p=0;p<n;p++)m+=l[p],m.length>=this.D&&N(this,e,m,q,a,c);break;default:if(N(this,e,l,q,a,c),f&&1<d&&k<d-1)for(n=this.l-this.m,q=B(),m=l,p=Math.min(f+1,d-k),r=q[m]=1;r<p;r++)if((l=b[this.H?d-1-k-r:k+r])&&l.length>=this.D&&!q[l]){if(q[l]=1,t=Math.min((this.l-p)/d*k+r|0,k+(r-1)),t<n){var y=this.K&&l>m;N(this,h,y?m:l,t,a,c,y?l:m)}}else p=Math.min(p+1,d-k)}}}}this.A||(this.register[a]=1)}return this};
function N(a,b,c,d,f,g,e){var h=e?a.h:a.map;if(!b[c]||e&&!b[c][e])a.C&&(h=h[d]),e?(b=b[c]||(b[c]=B()),b[e]=1,h=h[e]||(h[e]=B())):b[c]=1,h=h[c]||(h[c]=[]),a.C||(h=h[d]||(h[d]=[])),g&&-1!==h.indexOf(f)||(h[h.length]=f,a.A&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=h))}
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);var d=[],f=this.threshold,g=0;if(c){b=c.limit;g=c.offset||0;f=A(c.threshold,f);var e=c.context;var h=c.suggest}if(a){a=this.encode(a);var k=a.length;if(1<k){c=B();for(var l=[],n=0,q=0,m;n<k;n++)if((m=a[n])&&m.length>=this.D&&!c[m])if(this.C||h||this.map[m])l[q++]=m,c[m]=1;else return d;a=l;k=a.length}}if(!k)return d;b||(b=100);c=this.F-f;f=this.l-f;e=this.depth&&1<k&&!1!==e;l=0;if(e){var p=a[0];l=1}else 1<k&&a.sort(ia);for(;l<k;l++){q=a[l];
e?(n=za(this,d,h,f,b,g,2===k,q,p),h&&!1===n&&d.length||(p=q)):n=za(this,d,h,c,b,g,1===k,q);if(n)return n;if(h&&l===k-1){n=d.length;if(!n){if(e){e=0;l=-1;continue}return d}if(1===n)return Aa(d[0],b,g)}}return ua(d,b,g,h)};
function za(a,b,c,d,f,g,e,h,k){var l=[],n=k?a.h:a.map;a.C||(n=Ba(n,h,k,a.K));if(n){var q=0;d=Math.min(n.length,d);for(var m=0,p=0,r,t;m<d&&!(r=n[m],a.C&&(r=Ba(r,h,k,a.K)),r&&e&&(t=r.length,t<=g?(g-=t,r=null):g&&(r=r.slice(g),g=0)),r&&(l[q++]=r,e&&(p+=r.length,p>=f)));m++);if(q){if(e)return Aa(l,f,0);b[b.length]=l;return}}return!c&&l}function Aa(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function Ba(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a,b){var c=this.register[a];if(c){if(this.A)for(var d=0,f;d<c.length;d++)f=c[d],f.splice(f.indexOf(a),1);else O(this.map,a,this.F-this.threshold,this.C),this.depth&&O(this.h,a,this.l-this.m,this.C);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.h.length;c++)f=b.h[c],d=b.cache[f],-1!==d.indexOf(a)&&(b.h.splice(c--,1),delete b.cache[f])}return this};
function O(a,b,c,d,f){var g=0;if(a.constructor===Array)if(f)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),g++):g++;else{f=Math.min(a.length,c);for(var e=0,h;e<f;e++)if(h=a[e])g=O(h,b,c,d,f),d||g||delete a[e]}else for(e in a)(g=O(a[e],b,c,d,f))||delete a[e];return g}u.searchCache=wa;
u.export=function(a,b,c,d,f){switch(f||(f=0)){case 0:var g="reg";if(this.A){var e=B();for(var h in this.register)e[h]=1}else e=this.register;break;case 1:g="cfg";e={doc:0,opt:this.C?1:0};break;case 2:g="map";e=this.map;break;case 3:g="ctx";e=this.h;break;default:return}ya(a,b||this,c?c+"."+g:g,d,f,e);return!0};u.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "cfg":this.C=!!b.opt;break;case "reg":this.A=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};sa(M.prototype);function Ca(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new M(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Da=0;function P(a){var b;a?F(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c=self.exports,d=this;this.s=Ea(b,c,a.worker);this.h=B();if(this.s){if(c)this.s.on("message",function(f){d.h[f.id](f.msg);delete d.h[f.id]});else this.s.onmessage=function(f){f=f.data;d.h[f.id](f.msg);delete d.h[f.id]};this.s.postMessage({task:"init",factory:b,options:a})}}Q("add");Q("append");Q("search");Q("update");Q("remove");
function Q(a){P.prototype[a]=P.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(F(d)){var f=d;c.splice(c.length-1,1)}d=new ra(function(g){setTimeout(function(){b.h[++Da]=g;b.s.postMessage({task:a,id:Da,args:c})})});return f?(d.then(f),this):d}}
function Ea(a,b,c){try{var d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Ca.toString()],{type:"text/javascript"}))):new Worker(C(c)?c:"worker/worker.js",{type:"module"})}catch(f){}return d};function R(a){if(!(this instanceof R))return new R(a);var b=a.document||a.doc||a,c;this.J=[];this.h=[];this.o=[];this.register=B();this.key=(c=b.key||b.id)&&S(c,this.o)||"id";this.A=A(a.fastupdate,!0);this.G=!!(c=b.extern);this.B=!this.G&&(c=b.store)&&!0!==c&&[];this.store=c&&(this.G?c:B());this.I=(c=b.tag)&&S(c,this.o);this.l=c&&B();this.cache=(c=a.cache)&&new L(c);a.cache=!1;this.s=a.worker;this.async=!1;c=B();var d=b.index||b.field||b;C(d)&&(d=[d]);for(var f=0,g,e=void 0;f<d.length;f++)g=d[f],
C(g)||(e=g,g=g.field),e=D(e)?Object.assign({},a,e):a,this.s&&(c[g]=new P(e),c[g].s||(this.s=!1)),this.s||(c[g]=new M(e,this.register)),this.J[f]=S(g,this.o),this.h[f]=g;if(this.B)for(a=b.store,C(a)&&(a=[a]),b=0;b<a.length;b++)this.B[b]=S(a[b],this.o);this.m=c}function S(a,b){for(var c=a.split(":"),d=0,f=0;f<c.length;f++)a=c[f],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}
function T(a,b){if(C(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}function U(a,b,c,d,f){a=a[f];if(d===c.length-1)b[f]=a;else if(a)if(a.constructor===Array)for(b=b[f]=Array(a.length),f=0;f<a.length;f++)U(a,b,c,d,f);else b=b[f]||(b[f]=B()),f=c[++d],U(a,b,c,d,f)}
function V(a,b,c,d,f,g,e,h){a=a[e];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)f.add(g,a[b],!0,!0);return}a=a.join(" ")}f.add(g,a,h,!0)}else if(a)if(a.constructor===Array)for(e=0;e<a.length;e++)V(a,b,c,d,f,g,e,h);else e=b[++d],V(a,b,c,d,f,g,e,h)}u=R.prototype;
u.add=function(a,b,c){D(a)&&(b=a,a=T(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(var d=0,f,g;d<this.h.length;d++)g=this.h[d],f=this.J[d],C(f)&&(f=[f]),V(b,f,this.o,0,this.m[g],a,f[0],c);if(this.I){d=T(b,this.I);f=B();C(d)&&(d=[d]);g=0;for(var e;g<d.length;g++)if(e=d[g],!f[e]&&(f[e]=1,e=this.l[e]||(this.l[e]=[]),!c||-1===e.indexOf(a)))if(e[e.length]=a,this.A){var h=this.register[a]||(this.register[a]=[]);h[h.length]=e}}if(this.store&&!this.G){if(this.B){var k=B();
for(c=0;c<this.B.length;c++)d=this.B[c],C(d)?k[d]=b[d]:U(b,k,d,0,d[0])}this.store[a]=k||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){D(a)&&(a=T(a,this.key));if(this.register[a]){for(var b=this.A&&!this.s,c=0;c<this.h.length&&(this.m[this.h[c]].remove(a,b),!b);c++);if(this.I&&!b)for(var d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&!this.G&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,d){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);var f=[],g=[],e,h=0;if(c)if(c.constructor===Array){var k=c;c=null}else{k=(e=c.pluck)||c.index||c.field||c;var l=c.tag;var n=this.store&&c.enrich;var q="and"===c.bool;b=c.limit||100;var m=c.offset||0;if(l&&(C(l)&&(l=[l]),!a)){g=0;for(e=void 0;g<l.length;g++)if(e=Fa.call(this,l[g],b,m,n))f[f.length]=e,h++;return h?f:[]}C(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);q=q&&(1<k.length||l&&1<l.length);for(var p=!d&&(this.s||this.async)&&
[],r=0,t=void 0,y=void 0,x=void 0;r<k.length;r++)if(x=void 0,y=k[r],C(y)||(x=y,y=y.field),p)p[r]=this.m[y].searchAsync(a,b,x||c);else{d?t=d[r]:t=this.m[y].search(a,b,x||c);x=t&&t.length;if(l&&x){var K=[],ta=0;q&&(K[0]=[t]);var X=0,E=void 0;for(E=void 0;X<l.length;X++)if(E=l[X],x=(E=this.l[E])&&E.length)ta++,K[K.length]=q?[E]:E;ta&&(t=q?ua(K,b||100,m||0):va(t,K),x=t.length)}if(x)g[h]=y,f[h++]=t;else if(q)return[]}if(p){var La=this;return new Promise(function(Ma){Promise.all(p).then(function(Na){Ma(La.search(a,
b,c,Na))})})}if(!h)return[];if(e&&(!n||!this.store))return f[0];l=0;for(m=void 0;l<g.length;l++){m=f[l];m.length&&n&&(m=Ga.call(this,m));if(e)return m;f[l]={field:g[l],result:m}}return f};function Fa(a,b,c,d){var f=this.l[a],g=f&&f.length-c;if(g&&0<g){if(g>b||c)f=f.slice(c,c+b);d&&(f=Ga.call(this,f));return{tag:a,result:f}}}function Ga(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};u.searchCache=wa;u.export=function(a,b,c,d,f){f||(f=0);d||(d=0);if(d<this.h.length){var g=this.h[d],e=this.m[g];b=this;setTimeout(function(){e.export(a,b,f?g.replace(":","-"):"",d,f++)||(d++,f=1,b.export(a,b,g,d,f))})}else{switch(f){case 1:c="tag";var h=this.l;break;case 2:c="store";h=this.store;break;default:return}ya(a,this,c,d,f,h)}};
u.import=function(a,b){if(b)switch(C(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.A=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.m[this.h[a]],c.register=b,c.A=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.m[c].import(a,b)}};sa(R.prototype);var Ha=/[\W_]+/,Ia=[G("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",G("[\u00e8\u00e9\u00ea\u00eb]"),"e",G("[\u00ec\u00ed\u00ee\u00ef]"),"i",G("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",G("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",G("[\u00fd\u0177\u00ff]"),"y",G("\u00f1"),"n",G("[\u00e7c]"),"k",G("\u00df"),"s",G(" & ")," and "];function Ja(a){return pa(this,ka(a).toLowerCase(),!a.normalize&&Ia,Ha)};var Oa={encode:Ka,H:!1,L:"strict"},Pa=/[^a-z0-9]+/,Qa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ka(a){a=Ja.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Pa),d=c.length,f=0,g,e=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){g=a[0];for(var h=Qa[g]||g,k=h,l=1;l<a.length;l++)g=a[l],(g=Qa[g]||g)&&g!==k&&(h+=g,k=g);b[e++]=h}return b};var Sa={encode:Ra,H:!1,L:""},Ta=[G("ae"),"a",G("oe"),"o",G("sh"),"s",G("th"),"t",G("ph"),"f",G("pf"),"f"];function Ra(a,b){a&&(a=Ka.call(this,a).join(" "),2<a.length&&(a=H(a,Ta)),b||(1<a.length&&(a=ma(a)),a&&(a=a.split(" "))));return a};var Va={encode:Ua,H:!1,L:""},Wa=G("(?!\\b)[aeiouy]");function Ua(a){a&&(a=Ra.call(this,a,!0),1<a.length&&(a=a.replace(Wa,"")),1<a.length&&(a=ma(a)),a&&(a=a.split(" ")));return a};I["latin:simple"]={encode:Ja,H:!1,L:""};I["latin:balance"]=Oa;I["latin:advanced"]=Sa;I["latin:extra"]=Va;var W=self,Y,Z={Index:M,Document:R,Worker:P,registerCharset:function(a,b){I[a]=b},registerLanguage:function(a,b){qa[a]=b}};(Y=W.define)&&Y.amd?Y([],function(){return Z}):W.exports?W.exports=Z:W.FlexSearch=Z;}(this));
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var w=ba(this);function x(a,b){if(b)a:{var c=w;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
x("Symbol",function(a){function b(h){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(h||"")+"_"+f++,h)}function c(h,e){this.h=h;v(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",f=0;return b});
x("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=w[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,f={next:function(){if(!d&&c<a.length){var h=c++;return{value:b(h,a[h]),done:!1}}d=!0;return{done:!0,value:void 0}}};f[Symbol.iterator]=function(){return f};return f}x("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}
x("Promise",function(a){function b(e){this.l=0;this.m=void 0;this.h=[];this.N=!1;var g=this.A();try{e(g.resolve,g.reject)}catch(k){g.reject(k)}}function c(){this.h=null}function d(e){return e instanceof b?e:new b(function(g){g(e)})}if(a)return a;c.prototype.l=function(e){if(null==this.h){this.h=[];var g=this;this.m(function(){g.C()})}this.h.push(e)};var f=w.setTimeout;c.prototype.m=function(e){f(e,0)};c.prototype.C=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var g=0;g<e.length;++g){var k=
e[g];e[g]=null;try{k()}catch(l){this.A(l)}}}this.h=null};c.prototype.A=function(e){this.m(function(){throw e;})};b.prototype.A=function(){function e(l){return function(m){k||(k=!0,l.call(g,m))}}var g=this,k=!1;return{resolve:e(this.T),reject:e(this.C)}};b.prototype.T=function(e){if(e===this)this.C(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.V(e);else{a:switch(typeof e){case "object":var g=null!=e;break a;case "function":g=!0;break a;default:g=!1}g?this.S(e):this.H(e)}};
b.prototype.S=function(e){var g=void 0;try{g=e.then}catch(k){this.C(k);return}"function"==typeof g?this.W(g,e):this.H(e)};b.prototype.C=function(e){this.O(2,e)};b.prototype.H=function(e){this.O(1,e)};b.prototype.O=function(e,g){if(0!=this.l)throw Error("Cannot settle("+e+", "+g+"): Promise already settled in state"+this.l);this.l=e;this.m=g;2===this.l&&this.U();this.P()};b.prototype.U=function(){var e=this;f(function(){if(e.R()){var g=w.console;"undefined"!==typeof g&&g.error(e.m)}},1)};b.prototype.R=
function(){if(this.N)return!1;var e=w.CustomEvent,g=w.Event,k=w.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"===typeof g?e=new g("unhandledrejection",{cancelable:!0}):(e=w.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e));e.promise=this;e.reason=this.m;return k(e)};b.prototype.P=function(){if(null!=this.h){for(var e=0;e<this.h.length;++e)h.l(this.h[e]);this.h=null}};var h=new c;b.prototype.V=
function(e){var g=this.A();e.K(g.resolve,g.reject)};b.prototype.W=function(e,g){var k=this.A();try{e.call(g,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(e,g){function k(n,p){return"function"==typeof n?function(r){try{l(n(r))}catch(t){m(t)}}:p}var l,m,q=new b(function(n,p){l=n;m=p});this.K(k(e,l),k(g,m));return q};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.K=function(e,g){function k(){switch(l.l){case 1:e(l.m);break;case 2:g(l.m);break;default:throw Error("Unexpected state: "+
l.l);}}var l=this;null==this.h?h.l(k):this.h.push(k);this.N=!0};b.resolve=d;b.reject=function(e){return new b(function(g,k){k(e)})};b.race=function(e){return new b(function(g,k){for(var l=ea(e),m=l.next();!m.done;m=l.next())d(m.value).K(g,k)})};b.all=function(e){var g=ea(e),k=g.next();return k.done?d([]):new b(function(l,m){function q(r){return function(t){n[r]=t;p--;0==p&&l(n)}}var n=[],p=0;do n.push(void 0),p++,d(k.value).K(q(n.length-1),m),k=g.next();while(!k.done)})};return b});
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(a[f]=d[f])}return a};x("Object.assign",function(a){return a||fa});function A(a){return"undefined"!==typeof a?a:!0}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}function ia(a,b){return b.length-a.length}function D(a){return"string"===typeof a}function E(a){return"object"===typeof a}function I(a){return"function"===typeof a};var ja=/[\u0300-\u036f]/g;function ka(a){a.normalize&&(a=a.normalize("NFD").replace(ja,""));return a}function la(a,b){for(var c=Object.keys(a),d=c.length,f=[],h="",e=0,g=0,k,l;g<d;g++)k=c[g],(l=a[k])?(f[e++]=J(b?"(?!\\b)"+k+"(\\b|_)":k),f[e++]=l):h+=(h?"|":"")+k;h&&(f[e++]=J(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")"),f[e]="");return f}function K(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function J(a){return new RegExp(a,"g")}
function ma(a){for(var b="",c="",d=0,f=a.length,h=void 0;d<f;d++)(h=a[d])!==c&&(b+=c=h);return b};var na=/[\W_]+/;function oa(a){return pa(this,ka(a).toLowerCase(),!1,na)};var qa={},L={};function ra(a){M(a,"add");M(a,"append");M(a,"search");M(a,"update");M(a,"remove")}function M(a,b){a[b+"Async"]=function(){var c=this,d=arguments,f=d[d.length-1];if(I(f)){var h=f;delete d[d.length-1]}f=new Promise(function(e){setTimeout(function(){c.async=!0;var g=c[b].apply(c,d);c.async=!1;e(g)})});return h?(f.then(h),this):f}};function sa(a,b,c,d){for(var f=a.length,h=[],e,g,k,l,m=0;m<f;m++){for(var q=a[m],n=q.length,p=0,r=0,t;r<n;r++)(t=q[r])&&(p+=t.length);if(!g||p<g)g=p,k=q,l=m}k=1===k.length?k[0]:[].concat.apply([],k);d&&(d=[k],e=B());m=g=0;for(q=f-1;0<=q;q--)if(q!==l){m++;n=a[q];p=n.length;r=[];for(var z=t=0,y;z<k.length;z++){y=k[z];for(var C=void 0,G=0;G<p;G++){var H=n[G];if(H.length&&(C=-1!==H.indexOf(y))){if(m===f-1){if(c)c--;else if(h[g++]=y,g===b)return h;d&&(e[y]=1)}break}}C&&(r[t++]=y)}if(d)d[m]=r;else if(!t)return[];
k=r}if(d)for(a=d.length-1;0<=a;a--)if(k=(f=d[a])&&f.length)for(l=0;l<k;l++)if(m=f[l],!e[m])if(e[m]=1,c)c--;else if(h[g++]=m,g===b)return h;return h}function ta(a,b){for(var c=B(),d=B(),f=[],h=0;h<a.length;h++)c[a[h]]=1;for(a=0;a<b.length;a++){h=b[a];for(var e=0,g;e<h.length;e++)g=h[e],c[g]&&!d[g]&&(d[g]=1,f[f.length]=g)}return f};function N(a){this.l=!0!==a&&a;this.cache=B();this.h=[]}function ua(a,b,c){E(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}N.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};N.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var va={memory:{charset:"latin:extra",G:3,D:3,s:!1,B:"memory"},performance:{threshold:8,D:3,context:{depth:1,I:!0}},match:{charset:"latin:extra",J:"full",G:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,I:!0}},"default":{G:3,threshold:0,depth:3}};function wa(a,b,c,d,f,h){setTimeout(function(){var e=a(c,JSON.stringify(h));e&&e.then?e.then(function(){b.export(a,b,c,d,f+1)}):b.export(a,b,c,d,f+1)})};L["latin:default"]=oa;
function O(a,b){if(!(this instanceof O))return new O(a);var c;if(a){D(a)?a=va[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;D(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=L[c]);D(d)&&(d=qa[d])}else a={};var f,h,e=a.context||{};this.encode=a.encode||c&&c.encode||oa;this.register=b||B();this.G=f=a.resolution||9;this.m=b=c&&c.J||a.tokenize||"strict";this.depth="strict"===b&&e.depth;this.I=A(e.bidirectional);this.B=h="memory"===a.optimize;this.s=A(a.fastupdate);this.D=a.minlength||
1;this.map=h?ha(f):B();this.l=f=e.resolution||1;this.h=h?ha(f):B();this.F=c&&c.F||a.rtl;this.L=(b=a.matcher||d&&d.L)&&la(b,!1);this.M=(b=a.stemmer||d&&d.M)&&la(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=B();e=0;for(f=c.length;e<f;e++)d[c[e]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new N(b)}
function pa(a,b,c,d){if(b&&(c&&(b=K(b,c)),a.L&&(b=K(b,a.L)),a.M&&1<b.length&&(b=K(b,a.M)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(var f=0,h=0;f<c;f++){var e=b[f];e&&!a[e]&&(d[h++]=e)}b=d}return b}return b}u=O.prototype;u.append=function(a,b){return this.add(a,b,!0)};
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){for(var f=this.depth,h=this.G,e=B(),g=B(),k=0;k<d;k++){var l=b[this.F?d-1-k:k],m=l.length;if(l&&m>=this.D&&(f||!e[l])){var q=Math.min(h/d*k|0,k),n="";switch(this.m){case "full":if(3<m){for(var p=0;p<m;p++)for(var r=p?Math.min(q/2+h/m*p/2|0,q+p):q,t=m;t>p;t--)n=l.substring(p,t),n.length>=this.D&&P(this,e,n,r,a,c);break}case "reverse":if(2<m){for(p=m-1;0<p;p--)n=l[p]+n,n.length>=
this.D&&P(this,e,n,q,a,c);n=""}case "forward":if(1<m)for(p=0;p<m;p++)n+=l[p],n.length>=this.D&&P(this,e,n,q,a,c);break;default:if(P(this,e,l,q,a,c),f&&1<d&&k<d-1)for(m=B(),q=l,n=Math.min(f+1,d-k),p=m[q]=1;p<n;p++)(l=b[this.F?d-1-k-p:k+p])&&l.length>=this.D&&!m[l]?(m[l]=1,r=this.I&&l>q,P(this,g,r?q:l,0,a,c,r?l:q)):n=Math.min(n+1,d-k)}}}this.s||(this.register[a]=1)}return this};
function P(a,b,c,d,f,h,e){var g=e?a.h:a.map;if(!b[c]||e&&!b[c][e])a.B&&(g=g[d]),e?(b=b[c]||(b[c]=B()),b[e]=1,g=g[e]||(g[e]=B())):b[c]=1,g=g[c]||(g[c]=[]),a.B||(g=g[d]||(g[d]=[])),h&&-1!==g.indexOf(f)||(g[g.length]=f,a.s&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=g))}
u.search=function(a,b,c){E(a)?(c=a,a=c.query):E(b)&&(c=b);var d=[],f=0;if(c){b=c.limit;f=c.offset||0;var h=c.context;var e=c.suggest}if(a){a=this.encode(a);var g=a.length;if(1<g){c=B();for(var k=[],l=0,m=0,q;l<g;l++)if((q=a[l])&&q.length>=this.D&&!c[q])if(this.B||e||this.map[q])k[m++]=q,c[q]=1;else return d;a=k;g=a.length}}if(!g)return d;b||(b=100);h=this.depth&&1<g&&!1!==h;c=0;if(h){var n=a[0];c=1}else 1<g&&a.sort(ia);for(;c<g;c++){l=a[c];h?(k=xa(this,d,e,b,f,2===g,l,n),e&&!1===k&&d.length||(n=l)):
k=xa(this,d,e,b,f,1===g,l);if(k)return k;if(e&&c===g-1){k=d.length;if(!k){if(h){h=0;c=-1;continue}return d}if(1===k)return ya(d[0],b,f)}}return sa(d,b,f,e)};
function xa(a,b,c,d,f,h,e,g){var k=[],l=g?a.h:a.map;a.B||(l=za(l,e,g,a.I));if(l){for(var m=0,q=Math.min(l.length,g?a.l:a.G),n=0,p=0,r,t;n<q;n++)if(r=l[n])if(a.B&&(r=za(r,e,g,a.I)),f&&r&&h&&(t=r.length,t<=f?(f-=t,r=null):(r=r.slice(f),f=0)),r&&(k[m++]=r,h&&(p+=r.length,p>=d)))break;if(m){if(h)return ya(k,d,0);b[b.length]=k;return}}return!c&&k}function ya(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function za(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a,b){var c=this.register[a];if(c){if(this.s)for(var d=0,f;d<c.length;d++)f=c[d],f.splice(f.indexOf(a),1);else Q(this.map,a,this.G,this.B),this.depth&&Q(this.h,a,this.l,this.B);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.h.length;c++)f=b.h[c],d=b.cache[f],-1!==d.indexOf(a)&&(b.h.splice(c--,1),delete b.cache[f])}return this};
function Q(a,b,c,d,f){var h=0;if(a.constructor===Array)if(f)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),h++):h++;else{f=Math.min(a.length,c);for(var e=0,g;e<f;e++)if(g=a[e])h=Q(g,b,c,d,f),d||h||delete a[e]}else for(e in a)(h=Q(a[e],b,c,d,f))||delete a[e];return h}u.searchCache=ua;
u.export=function(a,b,c,d,f){switch(f||(f=0)){case 0:var h="reg";if(this.s){var e=B();for(var g in this.register)e[g]=1}else e=this.register;break;case 1:h="cfg";e={doc:0,opt:this.B?1:0};break;case 2:h="map";e=this.map;break;case 3:h="ctx";e=this.h;break;default:return}wa(a,b||this,c?c+"."+h:h,d,f,e);return!0};u.import=function(a,b){if(b)switch(D(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.s=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ra(O.prototype);function Aa(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Ba=0;function R(a){var b;a?I(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c=self.exports,d=this;this.o=Ca(b,c,a.worker);this.h=B();if(this.o){if(c)this.o.on("message",function(f){d.h[f.id](f.msg);delete d.h[f.id]});else this.o.onmessage=function(f){f=f.data;d.h[f.id](f.msg);delete d.h[f.id]};this.o.postMessage({task:"init",factory:b,options:a})}}S("add");S("append");S("search");S("update");S("remove");
function S(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(I(d)){var f=d;c.splice(c.length-1,1)}d=new Promise(function(h){setTimeout(function(){b.h[++Ba]=h;b.o.postMessage({task:a,id:Ba,args:c})})});return f?(d.then(f),this):d}}
function Ca(a,b,c){try{var d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Aa.toString()],{type:"text/javascript"}))):new Worker(D(c)?c:"worker/worker.js",{type:"module"})}catch(f){}return d};function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.H=[];this.h=[];this.m=[];this.register=B();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.s=A(a.fastupdate);this.A=(c=b.store)&&!0!==c&&[];this.store=c&&B();this.C=(c=b.tag)&&U(c,this.m);this.l=c&&B();this.cache=(c=a.cache)&&new N(c);a.cache=!1;this.o=a.worker;this.async=!1;c=B();var d=b.index||b.field||b;D(d)&&(d=[d]);for(var f=0,h,e=void 0;f<d.length;f++)h=d[f],D(h)||(e=h,h=h.field),e=E(e)?Object.assign({},
a,e):a,this.o&&(c[h]=new R(e),c[h].o||(this.o=!1)),this.o||(c[h]=new O(e,this.register)),this.H[f]=U(h,this.m),this.h[f]=h;if(this.A)for(a=b.store,D(a)&&(a=[a]),b=0;b<a.length;b++)this.A[b]=U(a[b],this.m);this.index=c}function U(a,b){for(var c=a.split(":"),d=0,f=0;f<c.length;f++)a=c[f],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function V(a,b){if(D(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}
function W(a,b,c,d,f){a=a[f];if(d===c.length-1)b[f]=a;else if(a)if(a.constructor===Array)for(b=b[f]=Array(a.length),f=0;f<a.length;f++)W(a,b,c,d,f);else b=b[f]||(b[f]=B()),f=c[++d],W(a,b,c,d,f)}function X(a,b,c,d,f,h,e,g){a=a[e];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)f.add(h,a[b],!0,!0);return}a=a.join(" ")}f.add(h,a,g,!0)}else if(a)if(a.constructor===Array)for(e=0;e<a.length;e++)X(a,b,c,d,f,h,e,g);else e=b[++d],X(a,b,c,d,f,h,e,g)}u=T.prototype;
u.add=function(a,b,c){E(a)&&(b=a,a=V(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(var d=0,f,h;d<this.h.length;d++)h=this.h[d],f=this.H[d],D(f)&&(f=[f]),X(b,f,this.m,0,this.index[h],a,f[0],c);if(this.C){d=V(b,this.C);f=B();D(d)&&(d=[d]);h=0;for(var e;h<d.length;h++)if(e=d[h],!f[e]&&(f[e]=1,e=this.l[e]||(this.l[e]=[]),!c||-1===e.indexOf(a)))if(e[e.length]=a,this.s){var g=this.register[a]||(this.register[a]=[]);g[g.length]=e}}if(this.store){if(this.A){var k=B();for(c=
0;c<this.A.length;c++)d=this.A[c],D(d)?k[d]=b[d]:W(b,k,d,0,d[0])}this.store[a]=k||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
u.remove=function(a){E(a)&&(a=V(a,this.key));if(this.register[a]){for(var b=this.s&&!this.o,c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.C&&!b)for(var d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
u.search=function(a,b,c,d){E(a)?(c=a,a=c.query):E(b)&&(c=b,b=0);var f=[],h=[],e,g=0;if(c)if(c.constructor===Array){var k=c;c=null}else{k=(e=c.pluck)||c.index||c.field||c;var l=c.tag;var m=this.store&&c.enrich;var q="and"===c.bool;b=c.limit||100;var n=c.offset||0;if(l&&(D(l)&&(l=[l]),!a)){h=0;for(e=void 0;h<l.length;h++)if(e=Da.call(this,l[h],b,n,m))f[f.length]=e,g++;return g?f:[]}D(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);q=q&&(1<k.length||l&&1<l.length);for(var p=!d&&(this.o||this.async)&&
[],r=0,t=void 0,z=void 0,y=void 0;r<k.length;r++)if(y=void 0,z=k[r],D(z)||(y=z,z=z.field),p)p[r]=this.index[z].searchAsync(a,b,y||c);else{d?t=d[r]:t=this.index[z].search(a,b,y||c);y=t&&t.length;if(l&&y){var C=[],G=0;q&&(C[0]=[t]);var H=0,F=void 0;for(F=void 0;H<l.length;H++)if(F=l[H],y=(F=this.l[F])&&F.length)G++,C[C.length]=q?[F]:F;G&&(t=q?sa(C,b||100,n||0):ta(t,C),y=t.length)}if(y)h[g]=z,f[g++]=t;else if(q)return[]}if(p){var Ka=this;return new Promise(function(La){Promise.all(p).then(function(Ma){La(Ka.search(a,
b,c,Ma))})})}if(!g)return[];if(e&&(!m||!this.store))return f[0];l=0;for(n=void 0;l<h.length;l++){n=f[l];n.length&&m&&(n=Ea.call(this,n));if(e)return n;f[l]={field:h[l],result:n}}return f};function Da(a,b,c,d){var f=this.l[a],h=f&&f.length-c;if(h&&0<h){if(h>b||c)f=f.slice(c,c+b);d&&(f=Ea.call(this,f));return{tag:a,result:f}}}function Ea(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
u.set=function(a,b){this.store[a]=b;return this};u.searchCache=ua;u.export=function(a,b,c,d,f){f||(f=0);d||(d=0);if(d<this.h.length){var h=this.h[d],e=this.index[h];b=this;setTimeout(function(){e.export(a,b,f?h.replace(":","-"):"",d,f++)||(d++,f=1,b.export(a,b,h,d,f))})}else{switch(f){case 1:c="tag";var g=this.l;break;case 2:c="store";g=this.store;break;default:return}wa(a,this,c,d,f,g)}};
u.import=function(a,b){if(b)switch(D(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.s=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.index[this.h[a]],c.register=b,c.s=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};ra(T.prototype);var Fa=/[\W_]+/,Ga=[J("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",J("[\u00e8\u00e9\u00ea\u00eb]"),"e",J("[\u00ec\u00ed\u00ee\u00ef]"),"i",J("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",J("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",J("[\u00fd\u0177\u00ff]"),"y",J("\u00f1"),"n",J("[\u00e7c]"),"k",J("\u00df"),"s",J(" & ")," and "];function Ha(a){return pa(this,ka(a).toLowerCase(),!a.normalize&&Ga,Fa)};var Ja={encode:Ia,F:!1,J:"strict"},Na=/[^a-z0-9]+/,Oa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ia(a){a=Ha.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Na),d=c.length,f=0,h,e=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){h=a[0];for(var g=Oa[h]||h,k=g,l=1;l<a.length;l++)h=a[l],(h=Oa[h]||h)&&h!==k&&(g+=h,k=h);b[e++]=g}return b};var Qa={encode:Pa,F:!1,J:""},Ra=[J("ae"),"a",J("oe"),"o",J("sh"),"s",J("th"),"t",J("ph"),"f",J("pf"),"f"];function Pa(a,b){a&&(a=Ia.call(this,a).join(" "),2<a.length&&(a=K(a,Ra)),b||(1<a.length&&(a=ma(a)),a&&(a=a.split(" "))));return a};var Ta={encode:Sa,F:!1,J:""},Ua=J("(?!\\b)[aeiouy]");function Sa(a){a&&(a=Pa.call(this,a,!0),1<a.length&&(a=a.replace(Ua,"")),1<a.length&&(a=ma(a)),a&&(a=a.split(" ")));return a};L["latin:simple"]={encode:Ha,F:!1,J:""};L["latin:balance"]=Ja;L["latin:advanced"]=Qa;L["latin:extra"]=Ta;var Y=self,Z,Va={Index:O,Document:T,Worker:R,registerCharset:function(a,b){L[a]=b},registerLanguage:function(a,b){qa[a]=b}};(Z=Y.define)&&Z.amd?Z([],function(){return Va}):Y.exports?Y.exports=Va:Y.FlexSearch=Va;}(this));

View File

@@ -5,15 +5,15 @@
* Licence: Apache-2.0
* https://github.com/nextapps-de/flexsearch
*/
(function(self){'use strict';function u(a,b){return"undefined"!==typeof a?a:b}function v(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function z(a,b){return b.length-a.length};const A=/[\u0300-\u036f]/g;function B(a,b){const c=Object.keys(a),d=c.length,e=[];let h="",g=0;for(let f=0,k,l;f<d;f++)k=c[f],(l=a[k])?(e[g++]=new RegExp(b?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[g++]=l):h+=(h?"|":"")+k;h&&(e[g++]=new RegExp(b?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[g]="");return e}function C(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};const D=/[\W_]+/;function E(a){a.normalize&&(a=a.normalize("NFD").replace(A,""));if(a=a.toLowerCase())if(this.o&&(a=C(a,this.o)),this.A&&1<a.length&&(a=C(a,this.A)),D||""===D)if(a=a.split(D),this.filter){var b=this.filter;const c=a.length,d=[];for(let e=0,h=0;e<c;e++){const g=a[e];g&&!b[g]&&(d[h++]=g)}a=d}return a};const F={},G={};function H(a,b,c,d){var e=a.length;let h=[],g,f=0;d&&(d=[]);for(--e;0<=e;e--){const k=a[e],l=k.length,n=y();let r=!g;for(let q=0;q<l;q++){const t=k[q],m=t.length;if(m)for(let p=0,x=0,w;p<m;p++)if(w=t[p],!g)n[w]=1;else if(g[w]){if(e)d&&x<b&&((d[q]||(d[q]=[]))[x++]=w),n[w]=1;else if(c)c--;else if(h[f++]=w,f===b)return h;r=!0}}if(!r&&!d)return[];g=n}if(d)for(let k=d.length-1,l,n;0<=k;k--)if((n=(l=d[k])&&l.length)&&c&&(n<=c?(c-=n,n=0):n-=c),n){if(f+n>=b)return h.concat(l.slice(c,b-f+c));h=h.concat(c?
l.slice(c):l);f+=n;c=0}return h};G["latin:default"]=E;
function I(a,b){if(!(this instanceof I))return new I(a);let c;if(a){var d=a.charset;c=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=G[d]);"string"===typeof c&&(c=F[c])}else a={};let e,h,g,f=a.context||{};this.encode=a.encode||d&&d.encode||E;this.register=b||y();e=a.resolution||9;h=a.threshold||0;h>=e&&(h=e-1);this.i=e;this.s=h;this.F=b=d&&d.G||a.tokenize||"strict";this.m="strict"===b&&f.depth;this.v=u(f.bidirectional,!0);this.g=g="memory"===a.optimize;this.C=u(a.fastupdate,!0);
this.h=a.minlength||1;this.j=g?v(e-h):y();e=f.resolution||e;h=f.threshold||h;h>=e&&(h=e-1);this.l=e;this.D=h;this.B=g?v(e-h):y();this.u=d&&d.u||a.rtl;this.o=(b=a.matcher||c&&c.o)&&B(b,!1);this.A=(b=a.stemmer||c&&c.A)&&B(b,!0);if(a=b=a.filter||c&&c.filter){a=b;d=y();for(let k=0,l=a.length;k<l;k++)d[a[k]]=1;a=d}this.filter=a}I.prototype.append=function(a,b){return this.add(a,b,!0)};
I.prototype.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){const n=this.m,r=this.i-this.s,q=y(),t=y();for(let m=0;m<d;m++){let p=b[this.u?d-1-m:m];var e=p.length;if(p&&e>=this.h&&(n||!q[p])){var h=Math.min(this.i/d*m|0,m);if(h<r){var g="";switch(this.F){case "full":if(3<e){for(var f=0;f<e;f++){var k=f?Math.min(h/2+this.i/e*f/2|0,h+f):h;if(k<r)for(var l=e;l>f;l--)g=p.substring(f,l),g.length>=this.h&&J(this,q,g,k,a,c)}break}case "reverse":if(2<
e){for(f=e-1;0<f;f--)g=p[f]+g,g.length>=this.h&&J(this,q,g,h,a,c);g=""}case "forward":if(1<e)for(f=0;f<e;f++)g+=p[f],g.length>=this.h&&J(this,q,g,h,a,c);break;default:if(J(this,q,p,h,a,c),n&&1<d&&m<d-1)for(e=this.l-this.D,h=y(),g=p,f=Math.min(n+1,d-m),h[g]=1,k=1;k<f;k++)if((p=b[this.u?d-1-m-k:m+k])&&p.length>=this.h&&!h[p]){if(h[p]=1,l=Math.min((this.l-f)/d*m+k|0,m+(k-1)),l<e){const x=this.v&&p>g;J(this,t,x?g:p,l,a,c,x?p:g)}}else f=Math.min(f+1,d-m)}}}}this.C||(this.register[a]=1)}return this};
function J(a,b,c,d,e,h,g){let f=g?a.B:a.j;if(!b[c]||g&&!b[c][g])a.g&&(f=f[d]),g?(b=b[c]||(b[c]=y()),b[g]=1,f=f[g]||(f[g]=y())):b[c]=1,f=f[c]||(f[c]=[]),a.g||(f=f[d]||(f[d]=[])),h&&-1!==f.indexOf(e)||(f[f.length]=e,a.C&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=f))}
I.prototype.search=function(a,b,c){"object"===typeof a?(c=a,a=c.query):"object"===typeof b&&(c=b);let d=[],e;var h=this.s;let g,f=0;if(c){b=c.limit;f=c.offset||0;h=u(c.threshold,h);var k=c.context;g=!1}if(a&&(a=this.encode(a),e=a.length,1<e)){c=y();var l=[];for(let r=0,q=0,t;r<e;r++)if((t=a[r])&&t.length>=this.h&&!c[t])if(this.g||g||this.j[t])l[q++]=t,c[t]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);c=this.i-h;h=this.l-h;k=this.m&&1<e&&!1!==k;l=0;let n;k?(n=a[0],l=1):1<e&&a.sort(z);for(let r,
q;l<e;l++){q=a[l];k?(r=K(this,d,g,h,b,f,2===e,q,n),g&&!1===r&&d.length||(n=q)):r=K(this,d,g,c,b,f,1===e,q);if(r)return r;if(g&&l===e-1){let t=d.length;if(!t){if(k){k=0;l=-1;continue}return d}if(1===t)return L(d[0],b,f)}}return H(d,b,f,g)};
function K(a,b,c,d,e,h,g,f,k){let l=[],n=k?a.B:a.j;a.g||(n=M(n,f,k,a.v));if(n){let r=0;d=Math.min(n.length,d);for(let q=0,t=0,m,p;q<d&&!(m=n[q],a.g&&(m=M(m,f,k,a.v)),m&&g&&(p=m.length,p<=h?(h-=p,m=null):h&&(m=m.slice(h),h=0)),m&&(l[r++]=m,g&&(t+=m.length,t>=e)));q++);if(r){if(g)return L(l,e,0);b[b.length]=l;return}}return!c&&l}function L(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
function M(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}I.prototype.contain=function(a){return!!this.register[a]};I.prototype.update=function(a,b){return this.remove(a).add(a,b)};I.prototype.remove=function(a,b){const c=this.register[a];if(c){if(this.C)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else N(this.j,a,this.i-this.s,this.g),this.m&&N(this.B,a,this.l-this.D,this.g);b||delete this.register[a]}return this};
function N(a,b,c,d,e){let h=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),h++):h++;else{e=Math.min(a.length,c);for(let g=0,f;g<e;g++)if(f=a[g])h=N(f,b,c,d,e),d||h||delete a[g]}else for(let g in a)(h=N(a[g],b,c,d,e))||delete a[g];return h};const O=self;let P;const Q={Index:I,Document:null,Worker:null,registerCharset:function(a,b){G[a]=b},registerLanguage:function(a,b){F[a]=b}};(P=O.define)&&P.amd?P([],function(){return Q}):O.exports?O.exports=Q:O.FlexSearch=Q;}(this));
(function(self){'use strict';function u(a){return"undefined"!==typeof a?a:!0}function w(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=z();return c}function z(){return Object.create(null)}function A(a,c){return c.length-a.length};const B=/[\u0300-\u036f]/g;function C(a,c){const b=Object.keys(a),d=b.length,f=[];let h="",g=0;for(let e=0,l,m;e<d;e++)l=b[e],(m=a[l])?(f[g++]=new RegExp(c?"(?!\\b)"+l+"(\\b|_)":l,"g"),f[g++]=m):h+=(h?"|":"")+l;h&&(f[g++]=new RegExp(c?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),f[g]="");return f}function D(a,c){for(let b=0,d=c.length;b<d&&(a=a.replace(c[b],c[b+1]),a);b+=2);return a};const F=/[\W_]+/;function G(a){a.normalize&&(a=a.normalize("NFD").replace(B,""));if(a=a.toLowerCase())if(this.o&&(a=D(a,this.o)),this.A&&1<a.length&&(a=D(a,this.A)),F||""===F)if(a=a.split(F),this.filter){var c=this.filter;const b=a.length,d=[];for(let f=0,h=0;f<b;f++){const g=a[f];g&&!c[g]&&(d[h++]=g)}a=d}return a};const H={},I={};function J(a,c,b,d){const f=a.length;let h=[],g;let e,l;for(var m=0;m<f;m++){var n=a[m],q=n.length,r=0;for(let k=0,t;k<q;k++)(t=n[k])&&(r+=t.length);if(!p||r<p){var p=r;e=n;l=m}}e=1===e.length?e[0]:[].concat.apply([],e);d&&(d=[e],g=z());m=p=0;for(n=f-1;0<=n;n--)if(n!==l){m++;q=a[n];r=q.length;const k=[];let t=0;for(let y=0,v;y<e.length;y++){v=e[y];let x;for(let E=0;E<r;E++){const N=q[E];if(N.length&&(x=-1!==N.indexOf(v))){if(m===f-1){if(b)b--;else if(h[p++]=v,p===c)return h;d&&(g[v]=1)}break}}x&&
(k[t++]=v)}if(d)d[m]=k;else if(!t)return[];e=k}if(d)for(let k=d.length-1,t,y;0<=k;k--)if(y=(t=d[k])&&t.length)for(let v=0,x;v<y;v++)if(x=t[v],!g[x])if(g[x]=1,b)b--;else if(h[p++]=x,p===c)return h;return h};I["latin:default"]=G;
function K(a,c){if(!(this instanceof K))return new K(a);let b;if(a){var d=a.charset;b=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=I[d]);"string"===typeof b&&(b=H[b])}else a={};let f,h,g=a.context||{};this.encode=a.encode||d&&d.encode||G;this.register=c||z();this.v=f=a.resolution||9;this.C=c=d&&d.D||a.tokenize||"strict";this.j="strict"===c&&g.depth;this.l=u(g.bidirectional);this.g=h="memory"===a.optimize;this.s=u(a.fastupdate);this.h=a.minlength||1;this.i=h?w(f):z();this.B=
f=g.resolution||1;this.m=h?w(f):z();this.u=d&&d.u||a.rtl;this.o=(c=a.matcher||b&&b.o)&&C(c,!1);this.A=(c=a.stemmer||b&&b.A)&&C(c,!0);if(a=c=a.filter||b&&b.filter){a=c;d=z();for(let e=0,l=a.length;e<l;e++)d[a[e]]=1;a=d}this.filter=a}K.prototype.append=function(a,c){return this.add(a,c,!0)};
K.prototype.add=function(a,c,b,d){if(!d&&!b&&this.register[a])return this.update(a,c);if(c&&(a||0===a)&&(c=this.encode(c),d=c.length)){const m=this.j,n=this.v,q=z(),r=z();for(let p=0;p<d;p++){let k=c[this.u?d-1-p:p];var f=k.length;if(k&&f>=this.h&&(m||!q[k])){var h=Math.min(n/d*p|0,p),g="";switch(this.C){case "full":if(3<f){for(var e=0;e<f;e++){var l=e?Math.min(h/2+n/f*e/2|0,h+e):h;for(let t=f;t>e;t--)g=k.substring(e,t),g.length>=this.h&&L(this,q,g,l,a,b)}break}case "reverse":if(2<f){for(e=f-1;0<
e;e--)g=k[e]+g,g.length>=this.h&&L(this,q,g,h,a,b);g=""}case "forward":if(1<f)for(e=0;e<f;e++)g+=k[e],g.length>=this.h&&L(this,q,g,h,a,b);break;default:if(L(this,q,k,h,a,b),m&&1<d&&p<d-1)for(f=z(),h=k,g=Math.min(m+1,d-p),f[h]=1,e=1;e<g;e++)(k=c[this.u?d-1-p-e:p+e])&&k.length>=this.h&&!f[k]?(f[k]=1,l=this.l&&k>h,L(this,r,l?h:k,0,a,b,l?k:h)):g=Math.min(g+1,d-p)}}}this.s||(this.register[a]=1)}return this};
function L(a,c,b,d,f,h,g){let e=g?a.m:a.i;if(!c[b]||g&&!c[b][g])a.g&&(e=e[d]),g?(c=c[b]||(c[b]=z()),c[g]=1,e=e[g]||(e[g]=z())):c[b]=1,e=e[b]||(e[b]=[]),a.g||(e=e[d]||(e[d]=[])),h&&-1!==e.indexOf(f)||(e[e.length]=f,a.s&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=e))}
K.prototype.search=function(a,c,b){"object"===typeof a?(b=a,a=b.query):"object"===typeof c&&(b=c);let d=[],f;let h,g=0;if(b){c=b.limit;g=b.offset||0;var e=b.context;h=!1}if(a&&(a=this.encode(a),f=a.length,1<f)){b=z();var l=[];for(let n=0,q=0,r;n<f;n++)if((r=a[n])&&r.length>=this.h&&!b[r])if(this.g||h||this.i[r])l[q++]=r,b[r]=1;else return d;a=l;f=a.length}if(!f)return d;c||(c=100);e=this.j&&1<f&&!1!==e;b=0;let m;e?(m=a[0],b=1):1<f&&a.sort(A);for(let n,q;b<f;b++){q=a[b];e?(n=M(this,d,h,c,g,2===f,q,
m),h&&!1===n&&d.length||(m=q)):n=M(this,d,h,c,g,1===f,q);if(n)return n;if(h&&b===f-1){l=d.length;if(!l){if(e){e=0;b=-1;continue}return d}if(1===l)return O(d[0],c,g)}}return J(d,c,g,h)};
function M(a,c,b,d,f,h,g,e){let l=[],m=e?a.m:a.i;a.g||(m=P(m,g,e,a.l));if(m){let n=0;const q=Math.min(m.length,e?a.B:a.v);for(let r=0,p=0,k,t;r<q;r++)if(k=m[r])if(a.g&&(k=P(k,g,e,a.l)),f&&k&&h&&(t=k.length,t<=f?(f-=t,k=null):(k=k.slice(f),f=0)),k&&(l[n++]=k,h&&(p+=k.length,p>=d)))break;if(n){if(h)return O(l,d,0);c[c.length]=l;return}}return!b&&l}function O(a,c,b){a=1===a.length?a[0]:[].concat.apply([],a);return b||a.length>c?a.slice(b,b+c):a}
function P(a,c,b,d){b?(d=d&&c>b,a=(a=a[d?c:b])&&a[d?b:c]):a=a[c];return a}K.prototype.contain=function(a){return!!this.register[a]};K.prototype.update=function(a,c){return this.remove(a).add(a,c)};K.prototype.remove=function(a,c){const b=this.register[a];if(b){if(this.s)for(let d=0,f;d<b.length;d++)f=b[d],f.splice(f.indexOf(a),1);else Q(this.i,a,this.v,this.g),this.j&&Q(this.m,a,this.B,this.g);c||delete this.register[a]}return this};
function Q(a,c,b,d,f){let h=0;if(a.constructor===Array)if(f)c=a.indexOf(c),-1!==c?1<a.length&&(a.splice(c,1),h++):h++;else{f=Math.min(a.length,b);for(let g=0,e;g<f;g++)if(e=a[g])h=Q(e,c,b,d,f),d||h||delete a[g]}else for(let g in a)(h=Q(a[g],c,b,d,f))||delete a[g];return h};const R=self;let S;const T={Index:K,Document:null,Worker:null,registerCharset:function(a,c){I[a]=c},registerLanguage:function(a,c){H[a]=c}};(S=R.define)&&S.amd?S([],function(){return T}):R.exports?R.exports=T:R.FlexSearch=T;}(this));

View File

@@ -128,7 +128,6 @@ These profiles are covering standard use cases. It is recommended to apply custo
- New memory-friendly strategy for indexes (switchable, saves up to 50% of memory for each index, slightly decrease performance)
- Better scoring calculation (one of the biggest concerns of the old implementation was that the order of arrays processed in the intersection has affected the order of relevance in the final result)
- Fix resolution (the resolution in the old implementation was not fully stretched through the whole range in some cases)
- Fix threshold (the threshold in the old implementation often has almost no effect, especially when using contextual index)
- Skip words (optionally, automatically skip words from the context chain which are too short)
- Hugely improves performance of long queries (up to 450x faster!) and also memory allocation (up to 250x less memory)
- New fast-update strategy (optionally, hugely improves performance of all updates and removals of indexed contents up to 2850x)
@@ -150,7 +149,6 @@ These profiles are covering standard use cases. It is recommended to apply custo
- Enhanced Field Search
- Improved sorting by relevance (score)
- Added Context Scoring (context index has its own resolution)
- Extern Stores
- Enhanced charset normalization
- Improved bundler (support for inline WebWorker)
@@ -166,7 +164,6 @@ A full configuration example for a context-based index:
var index = new Index({
tokenize: "strict",
resolution: 9,
threshold: 0,
minlength: 3,
optimize: "memory",
fastupdate: true,
@@ -174,13 +171,12 @@ var index = new Index({
context: {
depth: 1,
resolution: 3,
threshold: 0,
bidirectional: true
}
});
```
The parameters `resolution` and `threshold` could be also set independently for the contextual index also, e.g. set those values more aggressive on contextual index only.
The `resolution` could be set also for the contextual index.
A full configuration example for a document based index:
@@ -189,7 +185,6 @@ const index = new Document({
tokenize: "forward",
optimize: "memory",
resolution: 9,
threshold: 0,
cache: 100,
worker: true,
document: {
@@ -202,19 +197,16 @@ const index = new Document({
field: "title",
tokenize: "forward",
optimize: "memory",
resolution: 9,
threshold: 0
resolution: 9
},{
field: "content",
tokenize: "strict",
optimize: "memory",
resolution: 9,
threshold: 3,
minlength: 3,
context: {
depth: 1,
resolution: 3,
threshold: 0
resolution: 3
}
}]
}
@@ -452,19 +444,16 @@ const index = new Document({
field: "title",
tokenize: "forward",
optimize: "memory",
resolution: 9,
threshold: 0
resolution: 9
},{
field: "content",
tokenize: "strict",
optimize: "memory",
resolution: 9,
threshold: 3,
minlength: 3,
context: {
depth: 1,
resolution: 3,
threshold: 0
resolution: 3
}
}]
});
@@ -477,7 +466,6 @@ const index = new Document({
tokenize: "strict",
optimize: "memory",
resolution: 9,
threshold: 0,
document: {
key: "id",
index:[{
@@ -485,19 +473,17 @@ const index = new Document({
tokenize: "forward"
},{
field: "content",
threshold: 3,
minlength: 3,
context: {
depth: 1,
resolution: 3,
threshold: 0
resolution: 3
}
}]
}
});
```
Note: The context options from the field "content" also gets inherited by the corresponding field options, whereas this field options was inherited by the global option (so threshold would be "3" if not set in context options).
Note: The context options from the field "content" also gets inherited by the corresponding field options, whereas this field options was inherited by the global option.
### Nested Data Fields
@@ -1065,28 +1051,7 @@ Your results are now looking like:
Both field "author" and "email" are not indexed.
### Extern Stores
When the data already exist in your application runtime, then you did not need to add those to the store again. You can assign your data as "extern store":
```js
const data = [{ ... }, { ... }, { ... }];
const index = new Document({
document: {
index: "content",
extern: data // <--- extern store
}
});
index.add(data[0]);
```
> Entries from an extern store are not being managed/changed automatically by FlexSearch. When removing items from the index, the corresponding data item from the extern dataset stays untouched. Please consider, using the method `index.set(id, data)` will change extern stores also.
When you didn't use the data anywhere in your application (just for searching) then it is better to use an internal store and just select fields you need in the results, which costs you less memory.
## WebWorker
## Worker Parallelism (Browser + Node.js)
The whole worker implementation has changed by also keeping Node.js support in mind. The good news is worker will also get supported by Node.js by the library.
@@ -1217,7 +1182,21 @@ index.searchAsync(query).then(callback);
index.searchAsync(query).then(callback);
```
When using `await` you can prioritize the order ("first task completed") and solve requests one by one and process sub-tasks in parallel:
Or when you have just one callback when all requests are done, simply use `Promise.all()` which also prioritize "all tasks completed":
```js
Promise.all([
index.searchAsync(query).then(callback),
index.searchAsync(query).then(callback),
index.searchAsync(query).then(callback)
]).then(callback);
```
Inside the callback of `Promise.all()` you will also get an array of results as the first parameter respectively for each query you put into.
When using `await` you can prioritize the order (prioritize "first task completed") and solve requests one by one and just process the sub-tasks in parallel:
```js
await index.searchAsync(query);
@@ -1545,7 +1524,6 @@ index = new Index({
tokenize: "strict",
optimize: "memory",
resolution: 1,
threshold: 0,
minlength: 3,
fastupdate: false,
context: false
@@ -1555,28 +1533,25 @@ index = new Index({
### Compare Impact of Memory Allocation
by default a lexical index is very small:<br>
`depth: 0, bidirectional: 0, resolution: 3, threshold: 0, minlength: 0` => 2.1 Mb
`depth: 0, bidirectional: 0, resolution: 3, minlength: 0` => 2.1 Mb
a higher resolution will increase the memory allocation:<br>
`depth: 0, bidirectional: 0, resolution: 9, threshold: 0, minlength: 0` => 2.9 Mb
`depth: 0, bidirectional: 0, resolution: 9, minlength: 0` => 2.9 Mb
using the contextual index will increase the memory allocation:<br>
`depth: 1, bidirectional: 0, resolution: 9, threshold: 0, minlength: 0` => 12.5 Mb
`depth: 1, bidirectional: 0, resolution: 9, minlength: 0` => 12.5 Mb
a higher contextual depth will increase the memory allocation:<br>
`depth: 2, bidirectional: 0, resolution: 9, threshold: 0, minlength: 0` => 21.5 Mb
`depth: 2, bidirectional: 0, resolution: 9, minlength: 0` => 21.5 Mb
a higher minlength will decrease memory allocation:<br>
`depth: 2, bidirectional: 0, resolution: 9, threshold: 0, minlength: 3` => 19.0 Mb
`depth: 2, bidirectional: 0, resolution: 9, minlength: 3` => 19.0 Mb
using bidirectional will decrease memory allocation:<br>
`depth: 2, bidirectional: 1, resolution: 9, threshold: 0, minlength: 3` => 17.9 Mb
a higher threshold will decrease memory allocation:<br>
`depth: 2, bidirectional: 1, resolution: 9, threshold: 5, minlength: 3` => 5.8 Mb
`depth: 2, bidirectional: 1, resolution: 9, minlength: 3` => 17.9 Mb
enable the option "fastupdate" will increase memory allocation:<br>
`depth: 2, bidirectional: 1, resolution: 9, threshold: 5, minlength: 3` => 6.3 Mb
`depth: 2, bidirectional: 1, resolution: 9, minlength: 3` => 6.3 Mb
### Full Comparison Table
@@ -1608,14 +1583,6 @@ FlexSearch provides you many parameters you can use to adjust the optimal balanc
<td>+2 (per level)</td>
</tr>
<tr></tr>
<tr>
<td>threshold</td>
<td>-4 (per level)</td>
<td>-3 (per level)</td>
<td>+2 (per level)</td>
<td>0</td>
</tr>
<tr></tr>
<tr>
<td>depth</td>
<td>+4 (per level)</td>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1,5 +1,5 @@
import { IndexInterface, DocumentInterface } from "./type.js";
import { promise as Promise } from "./polyfill.js";
//import { promise as Promise } from "./polyfill.js";
import { is_function, is_object, is_string } from "./common.js";
export default function(prototype){

View File

@@ -52,9 +52,8 @@ function Document(options){
if(SUPPORT_STORE){
this.extern = !!(opt = document["extern"]);
this.storetree = !this.extern && (opt = document["store"]) && (opt !== true) && [];
this.store = opt && (this.extern ? opt : create_object());
this.storetree = (opt = document["store"]) && (opt !== true) && [];
this.store = opt && create_object();
}
if(SUPPORT_TAGS){
@@ -84,6 +83,7 @@ function Document(options){
this.async = false;
}
/** @export */
this.index = parse_descriptor.call(this, options, document);
}
@@ -97,17 +97,11 @@ function parse_descriptor(options, document){
const index = create_object();
let field = document["index"] || document["field"] || document;
//let field_options;
if(is_string(field)){
field = [field];
}
// else if(!is_array(field)){
//
// field_options = field;
// field = get_keys(field);
// }
for(let i = 0, key, opt; i < field.length; i++){
@@ -118,10 +112,6 @@ function parse_descriptor(options, document){
opt = key;
key = key["field"];
}
// else if(field_options){
//
// opt = field_options[key];
// }
opt = is_object(opt) ? Object.assign({}, options, opt) : options;
@@ -363,7 +353,7 @@ Document.prototype.add = function(id, content, _append){
}
}
if(SUPPORT_STORE && this.store && !this.extern){
if(SUPPORT_STORE && this.store){
let store;
@@ -454,7 +444,7 @@ Document.prototype.remove = function(id){
}
}
if(SUPPORT_STORE && this.store && !this.extern){
if(SUPPORT_STORE && this.store){
delete this.store[id];
}
@@ -488,7 +478,7 @@ Document.prototype.search = function(query, limit, options, _resolve){
let result = [], result_field = [];
let pluck, enrich;
let field, field_options, tag, bool, offset, count = 0;
let field, tag, bool, offset, count = 0;
if(options){
@@ -497,11 +487,6 @@ Document.prototype.search = function(query, limit, options, _resolve){
field = options;
options = null;
}
// else if(is_string(options)){
//
// field = [options];
// options = null;
// }
else{
pluck = options["pluck"];
@@ -539,22 +524,14 @@ Document.prototype.search = function(query, limit, options, _resolve){
}
}
//if(field){
if(is_string(field)){
if(is_string(field)){
field = [field];
}
else if(!is_array(field)){
field = [field];
}
else if(!is_array(field)){
field = null;
}
// else if(!is_array(field)){
//
// field_options = field;
// field = get_keys(field);
// }
//}
field = null;
}
}
}
@@ -576,10 +553,6 @@ Document.prototype.search = function(query, limit, options, _resolve){
opt = key;
key = key["field"];
}
// else if(field_options){
//
// opt = field_options[key];
// }
if(promises){

View File

@@ -76,22 +76,12 @@ function Index(options, _register){
options = {};
}
let resolution, threshold, optimize, context = options["context"] || {};
let resolution, optimize, context = options["context"] || {};
/** @export */
this.encode = options["encode"] || (charset && charset.encode) || default_encoder;
this.register = _register || create_object();
resolution = options["resolution"] || 9;
threshold = options["threshold"] || 0;
if(threshold >= resolution){
threshold = resolution - 1;
}
this.resolution = resolution;
this.threshold = threshold;
this.resolution = resolution = options["resolution"] || 9;
this.tokenizer = tmp = (charset && charset.tokenize) || options["tokenize"] || "strict";
this.depth = (tmp === "strict") && context["depth"];
this.bidirectional = parse_option(context["bidirectional"], true);
@@ -101,19 +91,9 @@ function Index(options, _register){
// when not using the memory strategy the score array should not pre-allocated to its full length
this.map = optimize ? create_object_array(resolution - threshold) : create_object();
resolution = context["resolution"] || resolution;
threshold = context["threshold"] || threshold;
if(threshold >= resolution){
threshold = resolution - 1;
}
this.resolution_ctx = resolution;
this.threshold_ctx = threshold;
this.ctx = optimize ? create_object_array(resolution - threshold) : create_object();
this.map = optimize ? create_object_array(resolution) : create_object();
this.resolution_ctx = resolution = context["resolution"] || 1;
this.ctx = optimize ? create_object_array(resolution) : create_object();
this.rtl = (charset && charset.rtl) || options["rtl"];
this.matcher = (tmp = options["matcher"] || (lang && lang.matcher)) && init_stemmer_or_matcher(tmp, false);
this.stemmer = (tmp = options["stemmer"] || (lang && lang.stemmer)) && init_stemmer_or_matcher(tmp, true);
@@ -161,7 +141,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
if(length){
const depth = this.depth;
const resolution = this.resolution - this.threshold;
const resolution = this.resolution;
const dupes = create_object();
// check context dupes to skip all contextual redundancy in the whole document
const dupes_ctx = create_object();
@@ -174,9 +154,9 @@ Index.prototype.add = function(id, content, _append, _skip_update){
// skip dupes will break the context chain
if(term && (term_length >= this.minlength) && (depth || !dupes[term])){
const score = Math.min((this.resolution / length * i) | 0, i);
const score = Math.min((resolution / length * i) | 0, i);
if(score < resolution){
//if(score < resolution){
let token = "";
@@ -188,9 +168,9 @@ Index.prototype.add = function(id, content, _append, _skip_update){
for(let x = 0; x < term_length; x++){
const partial_score = x ? Math.min((score / 2 + this.resolution / term_length * x / 2) | 0, score + x) : score;
const partial_score = x ? Math.min((score / 2 + resolution / term_length * x / 2) | 0, score + x) : score;
if(partial_score < resolution){
//if(partial_score < resolution){
for(let y = term_length; y > x; y--){
@@ -201,7 +181,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
this.push_index(dupes, token, partial_score, id, _append);
}
}
}
//}
}
break;
@@ -256,7 +236,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
if((length > 1) && (i < (length - 1))){
const resolution = this.resolution_ctx - this.threshold_ctx;
const resolution = this.resolution_ctx;
// check inner dupes to skip repeating words in the current context
const dupes_inner = create_object();
const keyword = term;
@@ -272,14 +252,17 @@ Index.prototype.add = function(id, content, _append, _skip_update){
dupes_inner[term] = 1;
const context_score = Math.min(((this.resolution_ctx - size /*+ 1*/) / length * i + x) | 0, i + (x - 1));
const context_score = 0;
if(context_score < resolution){
// const context_score = Math.min(((resolution - size /*+ 1*/) / length * i + x) | 0, i + (x - 1));
//
// // TODO: this check is not required when calculated properly
// if((context_score >= 0) && (context_score < resolution)){
const swap = this.bidirectional && (term > keyword);
this.push_index(dupes_ctx, swap ? keyword : term, context_score, id, _append, swap ? term : keyword);
}
//}
}
else{
@@ -289,7 +272,7 @@ Index.prototype.add = function(id, content, _append, _skip_update){
}
}
}
}
//}
}
}
@@ -376,13 +359,12 @@ Index.prototype.search = function(query, limit, options){
let result = [];
let length;
let threshold = this.threshold, context, suggest, offset = 0;
let context, suggest, offset = 0;
if(options){
limit = options["limit"];
offset = options["offset"] || 0;
threshold = parse_option(options["threshold"], threshold);
context = options["context"];
suggest = SUPPORT_SUGGESTION && options["suggest"];
}
@@ -433,8 +415,6 @@ Index.prototype.search = function(query, limit, options){
limit || (limit = 100);
const resolution = this.resolution - threshold;
const resolution_ctx = this.resolution_ctx - threshold;
let depth = this.depth && (length > 1) && (context !== false);
let index = 0, keyword;
@@ -457,7 +437,7 @@ Index.prototype.search = function(query, limit, options){
if(depth){
arr = this.add_result(result, suggest, resolution_ctx, limit, offset, length === 2, term, keyword);
arr = this.add_result(result, suggest, limit, offset, length === 2, term, keyword);
// when suggestion enabled just forward keyword if term was found
// as long as the result is empty forward the pointer also
@@ -469,7 +449,7 @@ Index.prototype.search = function(query, limit, options){
}
else{
arr = this.add_result(result, suggest, resolution, limit, offset, length === 1, term);
arr = this.add_result(result, suggest, limit, offset, length === 1, term);
}
if(arr){
@@ -517,7 +497,6 @@ Index.prototype.search = function(query, limit, options){
* @private
* @param {Array} result
* @param {Array} suggest
* @param {number} resolution
* @param {number} limit
* @param {number} offset
* @param {boolean} single_term
@@ -526,7 +505,7 @@ Index.prototype.search = function(query, limit, options){
* @return {Array<Array<string|number>>|boolean|undefined}
*/
Index.prototype.add_result = function(result, suggest, resolution, limit, offset, single_term, term, keyword){
Index.prototype.add_result = function(result, suggest, limit, offset, single_term, term, keyword){
let word_arr = [];
let arr = keyword ? this.ctx : this.map;
@@ -539,53 +518,57 @@ Index.prototype.add_result = function(result, suggest, resolution, limit, offset
if(arr){
let count = 0;
const arr_len = Math.min(arr.length, resolution);
const arr_len = Math.min(arr.length, keyword ? this.resolution_ctx : this.resolution);
// relevance:
for(let x = 0, size = 0, tmp, len; x < arr_len; x++){
tmp = arr[x];
if(this.optimize){
tmp = get_array(tmp, term, keyword, this.bidirectional);
}
if(tmp && single_term){
len = tmp.length;
if(len <= offset){
offset -= len;
tmp = null;
}
else{
if(offset){
tmp = tmp.slice(offset);
offset = 0;
}
}
}
if(tmp){
// keep score (sparse array):
//word_arr[x] = tmp;
if(this.optimize){
// simplified score order:
word_arr[count++] = tmp;
tmp = get_array(tmp, term, keyword, this.bidirectional);
}
if(single_term){
if(offset){
size += tmp.length;
if(tmp && single_term){
if(size >= limit){
len = tmp.length;
// fast path optimization
if(len <= offset){
break;
offset -= len;
tmp = null;
}
else{
tmp = tmp.slice(offset);
offset = 0;
}
}
}
if(tmp){
// keep score (sparse array):
//word_arr[x] = tmp;
// simplified score order:
word_arr[count++] = tmp;
if(single_term){
size += tmp.length;
if(size >= limit){
// fast path optimization
break;
}
}
}
}
@@ -679,11 +662,11 @@ Index.prototype.remove = function(id, _skip_deletion){
}
else{
remove_index(this.map, id, this.resolution - this.threshold, this.optimize);
remove_index(this.map, id, this.resolution, this.optimize);
if(this.depth){
remove_index(this.ctx, id, this.resolution_ctx - this.threshold_ctx, this.optimize);
remove_index(this.ctx, id, this.resolution_ctx, this.optimize);
}
}

View File

@@ -1,6 +1,7 @@
import { create_object, concat } from "./common.js";
/**
* Implementation based on Array.indexOf()
* @param arrays
* @param limit
* @param offset
@@ -12,124 +13,177 @@ export function intersect(arrays, limit, offset, suggest) {
const length = arrays.length;
let result = [];
// arrays.sort(function(a, b){
//
// return a.length - b.length;
// });
let check;
let count = 0;
// determine shortest array and collect results
// from the sparse relevance arrays
let smallest_size;
let smallest_arr;
let smallest_index;
for(let x = 0; x < length; x++){
const arr = arrays[x];
const len = arr.length;
let size = 0;
for(let y = 0, tmp; y < len; y++){
tmp = arr[y];
if(tmp){
size += tmp.length;
}
}
if(!smallest_size || (size < smallest_size)){
smallest_size = size;
smallest_arr = arr;
smallest_index = x;
}
}
smallest_arr = smallest_arr.length === 1 ?
smallest_arr[0]
:
concat(smallest_arr);
if(suggest){
suggest = [];
suggest = [smallest_arr];
check = create_object();
}
// terms in reversed order!
let size = 0;
let steps = 0;
// TODO: the first word should be processed in the last round?
// process terms in reversed order often results in better performance
// the outer loop must be the words array,
// using the smallest array here disables the "fast fail" optimization
for(let x = length - 1; x >= 0; x--){
const word_arr = arrays[x];
const word_arr_len = word_arr.length;
const new_check = create_object();
if(x !== smallest_index){
let found = !check;
steps++;
// but relevance in forward order
for(let y = 0; y < word_arr_len; y++){
const word_arr = arrays[x];
const word_arr_len = word_arr.length;
const new_arr = [];
//const arr = [].concat.apply([], word_arr);
const arr = word_arr[y];
const arr_len = arr.length;
let count = 0;
if(arr_len){
for(let z = 0, id; z < smallest_arr.length; z++){
// ids
for(let z = 0, count_suggest = 0, id; z < arr_len; z++){
id = smallest_arr[z];
id = arr[z];
let found;
if(!check){
// process relevance in forward order (direction is
// important for the "fill" during the last round)
new_check[id] = 1;
}
else if(check[id]){
for(let y = 0; y < word_arr_len; y++){
if(!x){
const arr = word_arr[y];
if(offset){
if(arr.length){
offset--;
}
else{
found = arr.indexOf(id) !== -1;
result[count++] = id;
if(found){
if(count === limit){
// check if in last round
// fast path "end reached"
if(steps === length - 1){
return result;
if(offset){
offset--;
}
else{
result[size++] = id;
if(size === limit){
// fast path "end reached"
return result;
}
}
if(suggest){
check[id] = 1;
}
}
break;
}
else{
if(suggest && (count_suggest < limit)){
const tmp = suggest[y] || (suggest[y] = []);
tmp[count_suggest++] = id;
}
new_check[id] = 1;
}
found = true;
}
}
if(found){
new_arr[count++] = id;
}
}
if(suggest){
suggest[steps] = new_arr;
}
else if(!count){
return [];
}
smallest_arr = new_arr;
}
if(!found && !suggest){
return [];
}
check = new_check;
}
if(suggest){
for(let i = suggest.length - 1, res, len; i >= 0; i--){
// has to iterate in reverse direction
res = suggest[i];
len = res && res.length;
for(let x = suggest.length - 1, arr, len; x >= 0; x--){
if(len && offset){
if(len <= offset){
offset -= len;
len = 0;
}
else{
len -= offset;
}
}
arr = suggest[x];
len = arr && arr.length;
if(len){
if(count + len >= limit){
for(let y = 0, id; y < len; y++){
return result.concat(res.slice(offset, limit - count + offset));
}
else{
id = arr[y];
result = result.concat(offset ? res.slice(offset) : res);
count += len;
offset = 0;
if(!check[id]){
check[id] = 1;
if(offset){
offset--;
}
else{
result[size++] = id;
if(size === limit){
// fast path "end reached"
return result;
}
}
}
}
}
}
@@ -138,6 +192,145 @@ export function intersect(arrays, limit, offset, suggest) {
return result;
}
/**
* Implementation based on Object[key]
* @param arrays
* @param limit
* @param offset
* @param {boolean|Array=} suggest
* @returns {Array}
*/
// export function intersect(arrays, limit, offset, suggest) {
//
// const length = arrays.length;
// let result = [];
//
// // arrays.sort(function(a, b){
// //
// // return a.length - b.length;
// // });
//
// let check;
// let count = 0;
//
// if(suggest){
//
// suggest = [];
// }
//
// // terms in reversed order!
// for(let x = length - 1; x >= 0; x--){
//
// const word_arr = arrays[x];
// const word_arr_len = word_arr.length;
// const new_check = create_object();
//
// let found = !check;
//
// // relevance in forward order
// for(let y = 0, count_suggest = 0; y < word_arr_len; y++){
//
// //const arr = [].concat.apply([], word_arr);
// const arr = word_arr[y];
// const arr_len = arr.length;
//
// if(arr_len){
//
// // ids
// for(let z = 0, id; z < arr_len; z++){
//
// id = arr[z];
//
// if(!check){
//
// new_check[id] = 1;
// }
// else if(check[id]){
//
// if(!x){
//
// if(offset){
//
// offset--;
// }
// else{
//
// result[count++] = id;
//
// if(count === limit){
//
// // fast path "end reached"
//
// return result;
// }
// }
// }
// else{
//
// if(suggest && (count_suggest < limit)){
//
// const tmp = suggest[y] || (suggest[y] = []);
// tmp[tmp.length] = id;
// count_suggest++;
// }
//
// new_check[id] = 1;
// }
//
// found = true;
// }
// }
// }
// }
//
// if(!found && !suggest){
//
// return [];
// }
//
// check = new_check;
// }
//
// if(suggest){
//
// for(let i = suggest.length - 1, res, len; i >= 0; i--){
//
// res = suggest[i];
// len = res && res.length;
//
// if(len && offset){
//
// if(len <= offset){
//
// offset -= len;
// len = 0;
// }
// else{
//
// len -= offset;
// }
// }
//
// if(len){
//
// if(count + len >= limit){
//
// return result.concat(res.slice(offset, limit - count + offset));
// }
// else{
//
// result = result.concat(offset ? res.slice(offset) : res);
// count += len;
// offset = 0;
// }
// }
// }
// }
//
// return result;
// }
/**
* @param mandatory
* @param arrays

View File

@@ -1,4 +1,4 @@
import { promise as Promise } from "../polyfill.js";
//import { promise as Promise } from "../polyfill.js";
import { create_object, is_function, is_object, is_string } from "../common.js";
import handler from "./handler.js";