1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-01 18:03:56 +02:00

v0.5.2 Intersect Partial Results, Fix: #38 #39

This commit is contained in:
Thomas Wilkerling
2019-02-12 18:29:38 +01:00
parent 8b11bf4c8f
commit f1a162137e
10 changed files with 599 additions and 491 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
#### v0.5.2
- Intersect Partial Results
#### v0.5.1
- Provide customizable scoring resolution

View File

@@ -1,28 +1,28 @@
/*
FlexSearch v0.5.1
FlexSearch v0.5.2
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(n,u,A){let f;(f=A.define)&&f.amd?f([],function(){return u}):(f=A.modules)?f[n.toLowerCase()]=u:"object"===typeof exports?module.exports=u:A[n]=u})("FlexSearch",function(){function n(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:Q++;this.init(a,b);A(this,"index",function(){return this.f});A(this,"length",function(){return Object.keys(this.f).length})}function u(a,b){a=a.concat.apply([],a);b&&(F(b)||(x=b.split(":"),1<x.length?b=R:(x=x[0],b=S)),a.sort(b));return a}function A(a,
b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function z(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function G(a,b,c,d,g,h,e,k){if(b[c])return b[c];g=g?(k-(e||k/1.5))*h+(e||k/1.5)*g:h;b[c]=g;g>=e&&(a=a[k-(g+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return g}function I(a,b){if(a){const c=Object.keys(a);for(let d=0,g=c.length;d<g;d++){const g=c[d],e=a[g];if(e)for(let c=0,d=e.length;c<d;c++)if(e[c]===b){1===d?delete a[g]:e.splice(c,1);break}else y(e[c])&&
I(e[c],b)}}}function J(a){let b="",c="";var d="";for(let g=0;g<a.length;g++){const h=a[g];if(h!==c)if(g&&"h"===h){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=h}else b+=h;d=g===a.length-1?"":a[g+1];c=h}return b}function T(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function U(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function S(a,b){a=a[x];b=b[x];return a<b?-1:a>b?1:0}function R(a,b){const c=x.length;for(let d=
0;d<c;d++)a=a[x[d]],b=b[x[d]];return a<b?-1:a>b?1:0}function V(a,b,c,d,g){c=[];let h;const e=a.length;if(1<e){a.sort(U);const k=v();let m=a[0],l=m.length,w=0;for(;w<l;)k["@"+m[w++]]=1;let p,B=0,r=0;for(;++r<e;){let q=!1;const n=r===e-1;h=[];m=a[r];l=m.length;for(w=0;w<l;){p=m[w++];var f="@"+p;if(k[f]){const a=k[f];if(a===r){if(n){if(c[B++]=d?d[p]:p,b&&B===b)return c}else k[f]=r+1;q=!0}else g&&(f=h[a]||(h[a]=[]),f[f.length]=p)}}if(!q&&!g)break}if(g&&(B=c.length,(r=h.length)&&(!b||B<b)))for(;r--;)if(p=
h[r])for(w=0,l=p.length;w<l;w++)if(c[B++]=d?d[p[w]]:p[w],b&&B===b)return c}else if(e)if(d)for(a=a[0],g=a.length,b&&b<g&&(g=b),c=Array(g),b=0;b<g;b++)c[b]=d[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function H(a){return"string"===typeof a}function F(a){return"function"===typeof a}function y(a){return"object"===typeof a}function D(a){return"undefined"===typeof a}function L(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=v();return b}function v(){return Object.create(null)}const t={encode:"icase",
c:"forward",v:!1,cache:!1,async:!1,w:!1,m:!1,b:!1,s:!1,a:9,threshold:0,depth:0},M={memory:{encode:"extra",c:"strict",threshold:0,a:1},speed:{encode:"icase",c:"strict",threshold:1,a:3,depth:2},match:{encode:"extra",c:"full",threshold:1,a:3},score:{encode:"extra",c:"strict",threshold:1,a:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,a:3,depth:3},fast:{encode:"icase",c:"strict",threshold:8,a:9,depth:1}},K=[];let Q=0;const N=f("\\W+"),O={},P={};n.create=function(a){return new n(a)};n.registerMatcher=
function(a){for(const b in a)a.hasOwnProperty(b)&&K.push(f(b),a[b]);return this};n.registerEncoder=function(a,b){E[a]=b.bind(E);return this};n.registerLanguage=function(a,b){O[a]=b.filter;P[a]=b.stemmer;return this};n.encode=function(a,b){return E[a](b)};n.prototype.init=function(a,b){this.o=[];if(b){var c=b.preset;a=b}else a||(a=t),c=a.preset;b={};H(a)?(b=M[a],a={}):c&&(b=M[c]);this.c=a.tokenize||b.c||this.c||t.c;this.m=a.rtl||this.m||t.m;this.async="undefined"===typeof Promise||D(c=a.async)?this.async||
t.async:c;this.threshold=D(c=a.threshold)?b.threshold||this.threshold||t.threshold:c;this.a=D(c=a.resolution)?c=b.a||this.a||t.a:c;c<=this.threshold&&(this.a=this.threshold+1);this.depth=D(c=a.depth)?b.depth||this.depth||t.depth:c;this.s=D(c=a.paging)?this.s||t.s:c;this.i=(c=D(c=a.encode)?b.encode||t.encode:c)&&E[c]&&E[c].bind(E)||(F(c)?c:this.i||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=O[c]||c;b=this.i;var d=v();if(c)for(var g=0;g<c.length;g++){var h=b?b(c[g]):c[g];d[h]=String.fromCharCode(65E3-
c.length+g)}this.filter=c=d}if(c=a.stemmer){var e;b=P[c]||c;d=this.i;g=[];if(b)for(e in b)b.hasOwnProperty(e)&&(h=d?d(e):e,g.push(f("(?=.{"+(h.length+3)+",})"+h+"$"),d?d(b[e]):b[e]));this.stemmer=e=g}this.b=e=(c=a.doc)?c:this.b||t.b;this.l=L(this.a-(this.threshold||0));this.h=v();this.f=v();if(e&&(this.g=v(),a.doc=null,c=e.index=[],b=e.ref={},d=e.field,e.id.constructor===Array||(e.id=e.id.split(":")),d)){let g;d.constructor!==Array&&(y(d)?(g=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)d[e].constructor!==
Array&&(g&&(a=g[d[e]]),b[d[e]]=e,d[e]=d[e].split(":")),c[e]=new n(a),c[e].g=this.g}return this};n.prototype.encode=function(a){a&&K.length&&(a=z(a,K));a&&this.o.length&&(a=z(a,this.o));a&&this.i&&(a=this.i(a));a&&this.stemmer&&(a=z(a,this.stemmer));return a};n.prototype.addMatcher=function(a){const b=this.o;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};n.prototype.add=function(a,b,c,d,g){if(this.b&&y(a))return this.j("add",a,b);if(b&&H(b)&&(a||0===a)){var f="@"+a;if(this.f[f]&&
!d)return this.update(a,b);if(!g){if(this.async&&"function"!==typeof importScripts){let e=this;f=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)f.then(c);else return f;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;g=F(c)?c(b):b.split(N);const h=v();h._ctx=v();const p=this.threshold,n=this.depth,r=this.a,t=this.l,C=g.length,u=this.m;for(let b=0;b<C;b++){var e=g[b];if(e){var k=e.length,q=(u?b+1:C-b)/
C,m="";switch(c){case "reverse":case "both":for(var l=k;--l;)m=e[l]+m,G(t,h,m,a,u?1:(k-l)/k,q,p,r-1);m="";case "forward":for(l=0;l<k;l++)m+=e[l],G(t,h,m,a,u?(l+1)/k:1,q,p,r-1);break;case "full":for(l=0;l<k;l++){const b=(u?l+1:k-l)/k;for(let c=k;c>l;c--)m=e.substring(l,c),G(t,h,m,a,b,q,p,r-1)}break;default:if(k=G(t,h,e,a,1,q,p,r-1),n&&1<C&&k>=p)for(k=h._ctx[e]||(h._ctx[e]=v()),e=this.h[e]||(this.h[e]=L(r-(p||0))),q=b-n,m=b+n+1,0>q&&(q=0),m>C&&(m=C);q<m;q++)q!==b&&G(e,k,g[q],a,0,r-(q<b?b-q:q-b),p,r-
1)}}}this.f[f]=1}return this};n.prototype.j=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.j(a,b[d],c);this.j(a,b[d])}else{const h=this.b.index;var d=this.b.tag,g=this.b.id;let m;let l;for(var f=0;f<g.length;f++)m=(m||b)[g[f]];if(d){for(g=0;g<d.length;g++){var e=d[g];var k=e.split(":");for(f=0;f<k.length;f++)l=(l||b)[k[f]];l="@"+l}k=this.u[e];k=k[l]||(k[l]=[])}if("remove"===a){delete this.g[m];for(let a=0,b=h.length;a<b;a++){if(a===b-1)return h[a].remove(m,
c);h[a].remove(m)}}g=this.b.field;k&&(k[k.length]=b);for(let f=0,k=g.length;f<k;f++){d=g[f];let l;for(e=0;e<d.length;e++)l=(l||b)[d[e]];this.g[m]=b;d=h[f];e="add"===a?d.add:d.update;if(f===k-1)return e.call(d,m,l,c);e.call(d,m,l)}}};n.prototype.update=function(a,b,c){if(this.b&&y(a))return this.j("update",a,b);this.f["@"+a]&&H(b)&&(this.remove(a),this.add(a,b,c,!0));return this};n.prototype.remove=function(a,b,c){if(this.b&&y(a))return this.j("remove",a,b);var d="@"+a;if(this.f[d]){if(!c){if(this.async&&
"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.a-(this.threshold||0);b++)I(this.l[b],a);this.depth&&I(this.h,a);delete this.f[d]}return this};let x;n.prototype.search=function(a,b,c,d){if(y(b)){if(b.constructor===Array)for(var f=0;f<b.length;f++)b[f].query=a;else b.query=a;a=b;b=0}let h=a;let e,k=[];if(y(a)&&a.constructor!==
Array){(c=a.callback||b)&&(h.callback=null);e=a.sort;b=a.limit;var q=a.threshold;a=a.query}if(this.b){q=this.b.ref;var m=this.b.index,l=h.field;if(l)h.field=null;else if(h.constructor===Array){var n=h;l=[];for(var p=0;p<h.length;p++)l[p]=h[p].field}else l=Object.keys(q);if(y(l)){e&&(h.sort=null);l.constructor===Array||(l=[l]);p=l.length;for(a=0;a<p;a++)n&&(h=n[a]),k[a]=m[q[l[a]]].search(h);return c?c(u(k,e)):this.async?new Promise(function(a){Promise.all(k).then(function(b){a(u(b,e))})}):u(k,e)}return m[q[l]].search(h,
c)}q||(q=this.threshold||0);F(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;q=new Promise(function(c){setTimeout(function(){c(a.search(h,b,null,!0));a=null})});if(c)q.then(c);else return q;return this}if(c)return c(this.search(h,b,null,!0)),this}if(!a||!H(a))return k;h=a;h=this.encode(h);if(!h.length)return k;c=this.c;c=F(c)?c(h):h.split(N);n=c.length;a=!0;d=[];f=v();1<n&&(this.depth?(m=!0,p=c[0],f[p]=1):c.sort(T));if(!m||(l=this.h)[p]){let b=
this.a;for(let e=m?1:0;e<n;e++){const g=c[e];if(g){if(!f[g]){const c=[];let e=!1,h=0;if(p=m?l[p]:this.l){let a;for(let d=0;d<b-q;d++)if(a=p[d][g])c[h++]=a,e=!0}if(e)d[d.length]=1<h?c.concat.apply([],c):c[0];else{a=!1;break}f[g]=1}p=g}}}else a=!1;a&&(k=V(d,b,void 0,this.g,!1));e&&(k=u([k],e));return k};n.prototype.clear=function(){return this.destroy().init()};n.prototype.destroy=function(){this.l=this.h=this.f=null;if(this.b){const a=this.g.index;for(let b=0;b<a.length;b++)a.destroy();this.g=null}return this};
const E={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=z(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=
[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=z(b,a));c||1<b.length&&(b=J(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=
b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+z(d.substring(1),a))}b=b.join(" ");b=J(b)}return b}}(),balance:function(){const a=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return J(z(b.toLowerCase(),a))}}()};return n}(!1),this);
'use strict';(function(n,z,A){let x;(x=A.define)&&x.amd?x([],function(){return z}):(x=A.modules)?x[n.toLowerCase()]=z:"object"===typeof exports?module.exports=z:A[n]=z})("FlexSearch",function(){function n(b,a){const c=a?a.id:b&&b.id;this.id=c||0===c?c:T++;this.init(b,a);x(this,"index",function(){return this.f});x(this,"length",function(){return Object.keys(this.f).length})}function z(b,a){const c=b.length,d=E(a),f=[];for(let h=0,g=0;h<c;h++){const c=b[h];if(d&&a(c)||!d&&!a[c])f[g++]=c}return f}function A(b,
a,c,d,f,h){b=this.g;a=N(a,f?0:d,h,!1);{h=a.length;const c=Array(h);for(let d=0;d<h;d++)c[d]=b[a[d]];a=c}f&&(a=this.where(f,null,d,a));c&&(E(c)||(v=c.split(":"),1<v.length?c=U:(v=v[0],c=V)),a.sort(c));return a}function x(b,a,c){Object.defineProperty(b,a,{get:c})}function e(b){return new RegExp(b,"g")}function B(b,a){for(let c=0;c<a.length;c+=2)b=b.replace(a[c],a[c+1]);return b}function I(b,a,c,d,f,h,g,l){if(a[c])return a[c];f=f?(l-(g||l/1.5))*h+(g||l/1.5)*f:h;a[c]=f;f>=g&&(b=b[l-(f+.5>>0)],b=b[c]||
(b[c]=[]),b[b.length]=d);return f}function K(b,a){if(b){const c=Object.keys(b);for(let d=0,f=c.length;d<f;d++){const f=c[d],g=b[f];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===a){1===d?delete b[f]:g.splice(c,1);break}else C(g[c])&&K(g[c],a)}}}function L(b){let a="",c="";var d="";for(let f=0;f<b.length;f++){const h=b[f];if(h!==c)if(f&&"h"===h){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=h}else a+=h;d=f===b.length-
1?"":b[f+1];c=h}return a}function W(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function V(b,a){b=b[v];a=a[v];return b<a?-1:b>a?1:0}function U(b,a){const c=v.length;for(let d=0;d<c;d++)b=b[v[d]],a=a[v[d]];return b<a?-1:b>a?1:0}function N(b,a,c,d){c=[];let f;const h=b.length;if(1<h){const l=u();let e=b[0],m=e.length,k=0;for(;k<m;)l["@"+e[k++]]=1;let p,q=0,y=0;for(;++y<h;){let t=!1;const n=y===h-1;f=[];e=b[y];m=e.length;for(k=0;k<m;){p=e[k++];var g="@"+p;if(l[g]){const b=l[g];if(b===y){if(n){if(c[q++]=
p,a&&q===a)return c}else l[g]=y+1;t=!0}else d&&(g=f[b]||(f[b]=[]),g[g.length]=p)}}if(!t&&!d)break}if(d&&(q=c.length,(y=f.length)&&(!a||q<a)))for(;y--;)if(p=f[y])for(k=0,m=p.length;k<m;k++)if(c[q++]=p[k],a&&q===a)return c}else h&&(c=b[0],a&&c.length>a&&(c=c.slice(0,a)));return c}function F(b){return"string"===typeof b}function w(b){return b.constructor===Array}function E(b){return"function"===typeof b}function C(b){return"object"===typeof b}function G(b){return"undefined"===typeof b}function O(b){const a=
Array(b);for(let c=0;c<b;c++)a[c]=u();return a}function u(){return Object.create(null)}const r={encode:"icase",c:"forward",v:!1,cache:!1,async:!1,w:!1,m:!1,a:!1,s:!1,b:9,threshold:0,depth:0},P={memory:{encode:"extra",c:"strict",threshold:0,b:1},speed:{encode:"icase",c:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",c:"full",threshold:1,b:3},score:{encode:"extra",c:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",c:"strict",
threshold:8,b:9,depth:1}},M=[];let T=0;const Q=/\W+/,R={},S={};n.create=function(b){return new n(b)};n.registerMatcher=function(b){for(const a in b)b.hasOwnProperty(a)&&M.push(e(a),b[a]);return this};n.registerEncoder=function(b,a){H[b]=a.bind(H);return this};n.registerLanguage=function(b,a){R[b]=a.filter;S[b]=a.stemmer;return this};n.encode=function(b,a){return H[b](a)};n.prototype.init=function(b,a){this.o=[];if(a){var c=a.preset;b=a}else b||(b=r),c=b.preset;a={};F(b)?(a=P[b],b={}):c&&(a=P[c]);
this.c=b.tokenize||a.c||this.c||r.c;this.m=b.rtl||this.m||r.m;this.async="undefined"===typeof Promise||G(c=b.async)?this.async||r.async:c;this.threshold=G(c=b.threshold)?a.threshold||this.threshold||r.threshold:c;this.b=G(c=b.resolution)?c=a.b||this.b||r.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth=G(c=b.depth)?a.depth||this.depth||r.depth:c;this.s=G(c=b.paging)?this.s||r.s:c;this.i=(c=G(c=b.encode)?a.encode||r.encode:c)&&H[c]&&H[c].bind(H)||(E(c)?c:this.i||!1);(c=b.matcher)&&this.addMatcher(c);
if(c=b.filter){F(c)&&(c=R[c]);if(w(c)){a=this.i;var d=u();for(var f=0;f<c.length;f++){var h=a?a(c[f]):c[f];d[h]=1}c=d}this.filter=c}if(c=b.stemmer){var g;a=F(c)?S[c]:c;d=this.i;f=[];for(g in a)a.hasOwnProperty(g)&&(h=d?d(g):g,f.push(e(h+"($|\\W)"),d?d(a[g]):a[g]));this.stemmer=g=f}this.a=d=(c=b.doc)?c:this.a||r.a;this.l=O(this.b-(this.threshold||0));this.h=u();this.f=u();if(d&&(this.g=u(),b.doc=null,g=d.index={},c=d.keys=[],a=d.field,w(d.id)||(d.id=d.id.split(":")),a)){let h;w(a)||(C(a)?(h=a,d.field=
a=Object.keys(a)):d.field=a=[a]);for(d=0;d<a.length;d++)f=a[d],w(f)||(h&&(b=h[f]),c[d]=f,a[d]=f.split(":")),g[f]=new n(b),g[f].g=this.g}return this};n.prototype.encode=function(b){b&&M.length&&(b=B(b,M));b&&this.o.length&&(b=B(b,this.o));b&&this.i&&(b=this.i(b));b&&this.stemmer&&(b=B(b,this.stemmer));return b};n.prototype.addMatcher=function(b){const a=this.o;for(const c in b)b.hasOwnProperty(c)&&a.push(e(c),b[c]);return this};n.prototype.add=function(b,a,c,d,f){if(this.a&&C(b))return this.j("add",
b,a);if(a&&F(a)&&(b||0===b)){var h="@"+b;if(this.f[h]&&!d)return this.update(b,a);if(!f){if(this.async&&"function"!==typeof importScripts){let f=this;h=new Promise(function(c){setTimeout(function(){f.add(b,a,null,d,!0);f=null;c()})});if(c)h.then(c);else return h;return this}if(c)return this.add(b,a,null,d,!0),c(),this}a=this.encode(a);if(!a.length)return this;c=this.c;f=E(c)?c(a):a.split(Q);this.filter&&(f=z(f,this.filter));const p=u();p._ctx=u();const q=f.length,l=this.threshold,n=this.depth,D=this.b,
J=this.l,r=this.m;for(let a=0;a<q;a++){var g=f[a];if(g){var e=g.length,t=(r?a+1:q-a)/q,m="";switch(c){case "reverse":case "both":for(var k=e;--k;)m=g[k]+m,I(J,p,m,b,r?1:(e-k)/e,t,l,D-1);m="";case "forward":for(k=0;k<e;k++)m+=g[k],I(J,p,m,b,r?(k+1)/e:1,t,l,D-1);break;case "full":for(k=0;k<e;k++){const a=(r?k+1:e-k)/e;for(let c=e;c>k;c--)m=g.substring(k,c),I(J,p,m,b,a,t,l,D-1)}break;default:if(e=I(J,p,g,b,1,t,l,D-1),n&&1<q&&e>=l)for(e=p._ctx[g]||(p._ctx[g]=u()),g=this.h[g]||(this.h[g]=O(D-(l||0))),
t=a-n,m=a+n+1,0>t&&(t=0),m>q&&(m=q);t<m;t++)t!==a&&I(g,e,f[t],b,0,D-(t<a?a-t:t-a),l,D-1)}}}this.f[h]=1}return this};n.prototype.j=function(b,a,c){if(w(a))for(let d=0,f=a.length;d<f;d++){if(d===f-1)return this.j(b,a[d],c);this.j(b,a[d])}else{const g=this.a.index,m=this.a.keys;var d=this.a.tag,f=this.a.id;let k;let p;for(var h=0;h<f.length;h++)k=(k||a)[f[h]];if(d){for(f=0;f<d.length;f++){var e=d[f];var l=e.split(":");for(h=0;h<l.length;h++)p=(p||a)[l[h]];p="@"+p}l=this.u[e];l=l[p]||(l[p]=[])}if("remove"===
b){delete this.g[k];for(let a=0,b=m.length;a<b;a++){if(a===b-1)return g[m[a]].remove(k,c);g[m[a]].remove(k)}}f=this.a.field;l&&(l[l.length]=a);for(let h=0,l=f.length;h<l;h++){d=f[h];let p;for(e=0;e<d.length;e++)p=(p||a)[d[e]];this.g[k]=a;d=g[m[h]];e="add"===b?d.add:d.update;if(h===l-1)return e.call(d,k,p,c);e.call(d,k,p)}}};n.prototype.update=function(b,a,c){if(this.a&&C(b))return this.j("update",b,a);this.f["@"+b]&&F(a)&&(this.remove(b),this.add(b,a,c,!0));return this};n.prototype.remove=function(b,
a,c){if(this.a&&C(b))return this.j("remove",b,a);var d="@"+b;if(this.f[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<this.b-(this.threshold||0);a++)K(this.l[a],b);this.depth&&K(this.h,b);delete this.f[d]}return this};let v;n.prototype.search=function(b,a,c,d){if(C(a)){if(w(a))for(var f=0;f<a.length;f++)a[f].query=
b;else a.query=b;b=a;a=0}let e=b;let g,l=[];if(C(b)&&!w(b)){(c=b.callback||a)&&(e.callback=null);g=b.sort;a=b.limit;var n=b.threshold;b=b.query}if(this.a){n=this.a.index;var m=e.field;if(m)e.field=null,w(m)||(m=[m]);else if(w(e)){var k=e;m=[];for(var p=0;p<e.length;p++)m[p]=e[p].field}else m=this.a.keys;g&&(e.sort=null);p=m.length;for(var q=0;q<p;q++)k&&(e=k[q]),l[q]=n[m[q]].search(e);if(c)return c(A.call(this,b,l,g,a,void 0,void 0));if(this.async){const c=this;return new Promise(function(d){Promise.all(l).then(function(e){d(A.call(c,
b,e,g,a,void 0,void 0))})})}return A.call(this,b,l,g,a,void 0,void 0)}n||(n=this.threshold||0);E(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let b=this;n=new Promise(function(c){setTimeout(function(){c(b.search(e,a,null,!0));b=null})});if(c)n.then(c);else return n;return this}if(c)return c(this.search(e,a,null,!0)),this}if(!b||!F(b))return l;e=b;e=this.encode(e);if(!e.length)return l;c=this.c;c=E(c)?c(e):e.split(Q);this.filter&&(c=z(c,this.filter));k=
c.length;d=!0;f=[];const r=u();1<k&&(this.depth?(m=!0,q=c[0],r[q]=1):c.sort(W));if(!m||(p=this.h)[q]){let a=this.b;for(let b=m?1:0;b<k;b++){const e=c[b];if(e){if(!r[e]){const b=[];let c=!1,g=0;if(q=m?p[q]:this.l){let d;for(let f=0;f<a-n;f++)if(d=q[f][e])b[g++]=d,c=!0}if(c)f[f.length]=1<g?b.concat.apply([],b):b[0];else{d=!1;break}r[e]=1}q=e}}}else d=!1;d&&(l=N(f,a,void 0,!1));return l};n.prototype.clear=function(){return this.destroy().init()};n.prototype.destroy=function(){this.l=this.h=this.f=null;
if(this.a){const b=this.a.keys;for(let a=0;a<b.length;a++)this.a.index[b[a]].destroy();this.a=this.g=null}return this};const H={icase:function(b){return b.toLowerCase()},simple:function(){const b=[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("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",
e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(a){a=B(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=B(a,b));c||1<a.length&&(a=L(a));return a}}(),extra:function(){const b=[e("p"),"b",e("z"),
"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(let c=0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+B(d.substring(1),b))}a=a.join(" ");a=L(a)}return a}}(),balance:function(){const b=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(a){return L(B(a.toLowerCase(),b))}}()};return n}(!1),this);

View File

@@ -1,45 +1,45 @@
/*
FlexSearch v0.5.1
FlexSearch v0.5.2
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';function S(f){var k=0;return function(){return k<f.length?{done:!1,value:f[k++]}:{done:!0}}}function T(f){var k="undefined"!=typeof Symbol&&Symbol.iterator&&f[Symbol.iterator];return k?k.call(f):{next:S(f)}}var Z="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(f,k,e){f!=Array.prototype&&f!=Object.prototype&&(f[k]=e.value)};
function ba(f,k){if(k){var e=Z;f=f.split(".");for(var n=0;n<f.length-1;n++){var l=f[n];l in e||(e[l]={});e=e[l]}f=f[f.length-1];n=e[f];k=k(n);k!=n&&null!=k&&aa(e,f,{configurable:!0,writable:!0,value:k})}}
ba("Promise",function(f){function k(d){this.g=0;this.s=void 0;this.a=[];var e=this.l();try{d(e.resolve,e.reject)}catch(B){e.reject(B)}}function e(){this.a=null}function n(d){return d instanceof k?d:new k(function(e){e(d)})}if(f)return f;e.prototype.g=function(d){if(null==this.a){this.a=[];var e=this;this.l(function(){e.s()})}this.a.push(d)};var l=Z.setTimeout;e.prototype.l=function(d){l(d,0)};e.prototype.s=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var e=0;e<d.length;++e){var k=
d[e];d[e]=null;try{k()}catch(H){this.m(H)}}}this.a=null};e.prototype.m=function(d){this.l(function(){throw d;})};k.prototype.l=function(){function d(d){return function(f){k||(k=!0,d.call(e,f))}}var e=this,k=!1;return{resolve:d(this.N),reject:d(this.m)}};k.prototype.N=function(d){if(d===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof k)this.O(d);else{a:switch(typeof d){case "object":var e=null!=d;break a;case "function":e=!0;break a;default:e=!1}e?this.M(d):this.w(d)}};
k.prototype.M=function(d){var e=void 0;try{e=d.then}catch(B){this.m(B);return}"function"==typeof e?this.P(e,d):this.w(d)};k.prototype.m=function(d){this.B(2,d)};k.prototype.w=function(d){this.B(1,d)};k.prototype.B=function(d,e){if(0!=this.g)throw Error("Cannot settle("+d+", "+e+"): Promise already settled in state"+this.g);this.g=d;this.s=e;this.J()};k.prototype.J=function(){if(null!=this.a){for(var d=0;d<this.a.length;++d)K.g(this.a[d]);this.a=null}};var K=new e;k.prototype.O=function(d){var e=this.l();
d.G(e.resolve,e.reject)};k.prototype.P=function(d,e){var k=this.l();try{d.call(e,k.resolve,k.reject)}catch(H){k.reject(H)}};k.prototype.then=function(d,e){function f(d,e){return"function"==typeof d?function(e){try{n(d(e))}catch(Q){t(Q)}}:e}var n,t,l=new k(function(d,e){n=d;t=e});this.G(f(d,n),f(e,t));return l};k.prototype.catch=function(d){return this.then(void 0,d)};k.prototype.G=function(d,e){function k(){switch(f.g){case 1:d(f.s);break;case 2:e(f.s);break;default:throw Error("Unexpected state: "+
f.g);}}var f=this;null==this.a?K.g(k):this.a.push(k)};k.resolve=n;k.reject=function(d){return new k(function(e,k){k(d)})};k.race=function(d){return new k(function(e,k){for(var f=T(d),l=f.next();!l.done;l=f.next())n(l.value).G(e,k)})};k.all=function(d){var e=T(d),f=e.next();return f.done?n([]):new k(function(d,k){function l(e){return function(k){t[e]=k;B--;0==B&&d(t)}}var t=[],B=0;do t.push(void 0),B++,n(f.value).G(l(t.length-1),k),f=e.next();while(!f.done)})};return k});
(function(f,k,e){var n;(n=e.define)&&n.amd?n([],function(){return k}):(n=e.modules)?n[f.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[f]=k})("FlexSearch",function ha(f){function e(a,b){var c=b?b.id:a&&a.id;this.id=c||0===c?c:ia++;this.init(a,b);K(this,"index",function(){return this.c});K(this,"length",function(){return Object.keys(this.c).length})}function n(a,b,c,g){this.D!==this.i&&(this.v=this.v.concat(c),this.D++,g&&this.v.length>=g&&(this.D=this.i),this.I&&this.D===this.i&&(this.cache&&
this.A.set(b,this.v),this.I(this.v),this.v=[]));return this}function l(a,b){a=a.concat.apply([],a);b&&(L(b)||(F=b.split(":"),1<F.length?b=ea:(F=F[0],b=da)),a.sort(b));return a}function K(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function t(a,b){for(var c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function B(a,b,c,g,m,d,e,h){if(b[c])return b[c];m=m?(h-(e||h/1.5))*d+(e||h/1.5)*m:d;b[c]=m;m>=e&&(a=a[h-(m+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=g);return m}
function H(a,b){if(a)for(var c=Object.keys(a),g=0,m=c.length;g<m;g++){var d=c[g],e=a[d];if(e)for(var h=0,f=e.length;h<f;h++)if(e[h]===b){1===f?delete a[d]:e.splice(h,1);break}else J(e[h])&&H(e[h],b)}}function P(a){for(var b="",c="",g="",d=0;d<a.length;d++){var e=a[d];if(e!==c)if(d&&"h"===e){if(g="a"===g||"e"===g||"i"===g||"o"===g||"u"===g||"y"===g,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&g||" "===c)b+=e}else b+=e;g=d===a.length-1?"":a[d+1];c=e}return b}function fa(a,b){a=a.length-b.length;
return 0>a?1:a?-1:0}function ca(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function da(a,b){a=a[F];b=b[F];return a<b?-1:a>b?1:0}function ea(a,b){for(var c=F.length,g=0;g<c;g++)a=a[F[g]],b=b[F[g]];return a<b?-1:a>b?1:0}function Q(a,b,c,g,d){c=[];var e=a.length;if(1<e){a.sort(ca);for(var m=C(),h=a[0],f=h.length,p=0;p<f;)m["@"+h[p++]]=1;for(var q,z=0,r=0;++r<e;){var n=!1,l=r===e-1;var u=[];h=a[r];f=h.length;for(p=0;p<f;){q=h[p++];var v="@"+q;if(m[v]){var w=m[v];if(w===r){if(l){if(c[z++]=g?g[q]:q,b&&
z===b)return c}else m[v]=r+1;n=!0}else d&&(v=u[w]||(u[w]=[]),v[v.length]=q)}}if(!n&&!d)break}if(d&&(z=c.length,(r=u.length)&&(!b||z<b)))for(;r--;)if(q=u[r])for(p=0,f=q.length;p<f;p++)if(c[z++]=g?g[q[p]]:q[p],b&&z===b)return c}else if(e)if(g)for(a=a[0],d=a.length,b&&b<d&&(d=b),c=Array(d),b=0;b<d;b++)c[b]=g[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function M(a){return"string"===typeof a}function I(a){return a.constructor===Array}function L(a){return"function"===typeof a}function J(a){return"object"===
typeof a}function E(a){return"undefined"===typeof a}function U(a){for(var b=Array(a),c=0;c<a;c++)b[c]=C();return b}function C(){return Object.create(null)}function ja(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),
c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ka(a,b,c,d){a=f("flexsearch","id"+a,ja,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);var g=ha.toString();c.id=b;a.postMessage({register:g,options:c,id:b});return a}var y={encode:"icase",h:"forward",F:!1,cache:!1,async:!1,i:!1,H:!1,b:!1,L:!1,f:9,
threshold:0,depth:0},V={memory:{encode:"extra",h:"strict",threshold:0,f:1},speed:{encode:"icase",h:"strict",threshold:1,f:3,depth:2},match:{encode:"extra",h:"full",threshold:1,f:3},score:{encode:"extra",h:"strict",threshold:1,f:9,depth:4},balance:{encode:"balance",h:"strict",threshold:0,f:3,depth:3},fast:{encode:"icase",h:"strict",threshold:8,f:9,depth:1}},O=[],ia=0,W=d("\\W+"),X={},Y={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&O.push(d(b),
a[b]);return this};e.registerEncoder=function(a,b){N[a]=b.bind(N);return this};e.registerLanguage=function(a,b){X[a]=b.filter;Y[a]=b.stemmer;return this};e.encode=function(a,b){return N[a](b)};e.prototype.init=function(a,b){this.g=[];if(b){var c=b.preset;a=b}else a||(a=y),c=a.preset;b={};M(a)?((b=V[a])||console.warn("Preset not found: "+a),a={}):c&&((b=V[c])||console.warn("Preset not found: "+c));if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.a=null;else{var g=parseInt(c,10)||4;this.w=
-1;this.D=0;this.v=[];this.I=null;this.a=Array(g);for(var m=0;m<g;m++)this.a[m]=ka(this.id,m,a,n.bind(this))}this.h=a.tokenize||b.h||this.h||y.h;this.H=a.rtl||this.H||y.H;this.async="undefined"===typeof Promise||E(c=a.async)?this.async||y.async:c;this.i=E(c=a.worker)?this.i||y.i:c;this.threshold=E(c=a.threshold)?b.threshold||this.threshold||y.threshold:c;this.f=E(c=a.resolution)?c=b.f||this.f||y.f:c;c<=this.threshold&&(this.f=this.threshold+1);this.depth=E(c=a.depth)?b.depth||this.depth||y.depth:
c;this.L=E(c=a.paging)?this.L||y.L:c;this.F=E(c=a.suggest)?this.F||y.F:c;this.l=(c=E(c=a.encode)?b.encode||y.encode:c)&&N[c]&&N[c].bind(N)||(L(c)?c:this.l||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=X[c]||c;b=this.l;g=C();if(c)for(m=0;m<c.length;m++){var G=b?b(c[m]):c[m];g[G]=String.fromCharCode(65E3-c.length+m)}this.filter=g}if(c=a.stemmer){b=Y[c]||c;g=this.l;m=[];if(b)for(var f in b)b.hasOwnProperty(f)&&(G=g?g(f):f,m.push(d("(?=.{"+(G.length+3)+",})"+G+"$"),g?g(b[f]):b[f]));this.stemmer=
m}this.b=g=(c=a.doc)?c:this.b||y.b;this.o=U(this.f-(this.threshold||0));this.u=C();this.c=C();if(g){this.j=C();a.doc=null;f=g.index=[];b=g.ref={};m=g.field;G=g.tag;I(g.id)||(g.id=g.id.split(":"));if(G){this.B=C();var h=C();if(m)if(M(m))h[m]=a;else if(I(m))for(var R=0;R<m.length;R++)h[m[R]]=a;else J(m)&&(h=m);I(G)||(g.tag=G=[G]);for(m=0;m<G.length;m++)this.B[G[m]]=C();this.J=G;m=h}if(m){if(!I(m))if(J(m)){var p=m;g.field=m=Object.keys(m)}else g.field=m=[m];for(g=0;g<m.length;g++)I(m[g])||(p&&(a=p[m[g]]),
b[m[g]]=g,m[g]=m[g].split(":")),f[g]=new e(a),f[g].j=this.j}}this.s=!0;this.A=(this.cache=c=E(c=a.cache)?this.cache||y.cache:c)?new la(c):!1;return this};e.prototype.encode=function(a){a&&O.length&&(a=t(a,O));a&&this.g.length&&(a=t(a,this.g));a&&this.l&&(a=this.l(a));a&&this.stemmer&&(a=t(a,this.stemmer));return a};e.prototype.addMatcher=function(a){var b=this.g,c;for(c in a)a.hasOwnProperty(c)&&b.push(d(c),a[c]);return this};e.prototype.add=function(a,b,c,d,e){if(this.b&&J(a))return this.m("add",
a,b);if(b&&M(b)&&(a||0===a)){var g="@"+a;if(this.c[g]&&!d)return this.update(a,b);if(this.i)return++this.w>=this.a.length&&(this.w=0),this.a[this.w].postMessage({add:!0,id:a,content:b}),this.c[g]=""+this.w,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var m=this;g=new Promise(function(c){setTimeout(function(){m.add(a,b,null,d,!0);m=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.h;
e=L(c)?c(b):b.split(W);var h=C();h._ctx=C();for(var f=this.threshold,p=this.depth,q=this.f,z=this.o,r=e.length,n=this.H,l=0;l<r;l++){var u=e[l];if(u){var v=u.length,w=(n?l+1:r-l)/r,A="";switch(c){case "reverse":case "both":for(var x=v;--x;)A=u[x]+A,B(z,h,A,a,n?1:(v-x)/v,w,f,q-1);A="";case "forward":for(x=0;x<v;x++)A+=u[x],B(z,h,A,a,n?(x+1)/v:1,w,f,q-1);break;case "full":for(x=0;x<v;x++)for(var t=(n?x+1:v-x)/v,y=v;y>x;y--)A=u.substring(x,y),B(z,h,A,a,t,w,f,q-1);break;default:if(v=B(z,h,u,a,1,w,f,q-
1),p&&1<r&&v>=f)for(v=h._ctx[u]||(h._ctx[u]=C()),u=this.u[u]||(this.u[u]=U(q-(f||0))),w=l-p,A=l+p+1,0>w&&(w=0),A>r&&(A=r);w<A;w++)w!==l&&B(u,v,e[w],a,0,q-(w<l?l-w:w-l),f,q-1)}}}this.c[g]=1;this.s=!1}return this};e.prototype.m=function(a,b,c){if(I(b))for(var d=0,e=b.length;d<e;d++){if(d===e-1)return this.m(a,b[d],c);this.m(a,b[d])}else{d=this.b.index;for(var f=this.b.tag,D=this.b.id,h,l,p,q=0;q<D.length;q++)e=(e||b)[D[q]];if(f){for(D=0;D<f.length;D++){l=f[D];h=l.split(":");for(q=0;q<h.length;q++)p=
(p||b)[h[q]];p="@"+p}h=this.B[l];h=h[p]||(h[p]=[])}if("remove"===a)for(delete this.j[e],D=0,f=d.length;D<f;D++){if(D===f-1)return d[D].remove(e,c);d[D].remove(e)}D=this.b.field;h&&(h[h.length]=b);f=0;for(l=D.length;f<l;f++){h=D[f];p=void 0;for(q=0;q<h.length;q++)p=(p||b)[h[q]];this.j[e]=b;h=d[f];q="add"===a?h.add:h.update;if(f===l-1)return q.call(h,e,p,c);q.call(h,e,p)}}};e.prototype.update=function(a,b,c){if(this.b&&J(a))return this.m("update",a,b);this.c["@"+a]&&M(b)&&(this.remove(a),this.add(a,
b,c,!0));return this};e.prototype.remove=function(a,b,c){if(this.b&&J(a))return this.m("remove",a,b);var d="@"+a;if(this.c[d]){if(this.i)return this.a[this.c[d]].postMessage({remove:!0,id:a}),delete this.c[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var e=this;d=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.f-(this.threshold||0);b++)H(this.o[b],
a);this.depth&&H(this.u,a);delete this.c[d];this.s=!1}return this};var F;e.prototype.search=function(a,b,c,d){if(J(b)){if(I(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var g=a,f=[];if(J(a)&&!I(a)){(c=a.callback||b)&&(g.callback=null);var h=a.where;var n=a.sort;b=a.limit;var p=a.threshold;a=a.query}if(this.b){a=this.b.ref;p=this.b.index;if(h=g.field)g.field=null;else if(I(g)){var q=g;h=[];for(var z=0;z<g.length;z++)h[z]=g[z].field}else h=Object.keys(a);if(J(h)){n&&(g.sort=null);
I(h)||(h=[h]);z=h.length;for(var r=0;r<z;r++)q&&(g=q[r]),f[r]=p[a[h[r]]].search(g);return c?c(l(f,n)):this.async?new Promise(function(a){Promise.all(f).then(function(b){a(l(b,n))})}):l(f,n)}return p[a[h]].search(g,c)}p||(p=this.threshold||0);L(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.i)for(this.I=c,this.D=0,this.v=[],h=0;h<this.i;h++)this.a[h].postMessage({search:!0,limit:b,threshold:p,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var t=this;a=new Promise(function(a){setTimeout(function(){a(t.search(g,
b,null,!0));t=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!M(a))return f;g=a;if(this.cache)if(this.s){if(c=this.A.get(a))return c}else this.A.clear(),this.s=!0;g=this.encode(g);if(!g.length)return f;c=this.h;c=L(c)?c(g):g.split(W);q=c.length;d=!0;e=[];var y=C();if(1<q)if(this.depth){z=!0;var u=c[0];y[u]=1}else c.sort(fa);if(!z||(r=this.u)[u])for(var v=this.f,w=z?1:0;w<q;w++){var A=c[w];if(A){if(!y[A]){var x=[],B=!1,E=0;if(u=z?r[u]:this.o)for(var F=
void 0,H=0;H<v-p;H++)if(F=u[H][A])x[E++]=F,B=!0;if(B)e[e.length]=1<E?x.concat.apply([],x):x[0];else if(!this.F){d=!1;break}y[A]=1}u=A}}else d=!1;d&&(f=Q(e,b,void 0,this.j,this.F));h&&(f=this.where(h,null,b,f));n&&(f=l([f],n));this.cache&&this.A.set(a,f);return f}};e.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};e.prototype.where=function(a,b,c,d){var e=d||this.j,g=[],f=0,h;if("number"===typeof a)return[e[a]];if(M(a)){if(E(b))return[e[a]];if("id"===a)return[e[b]];var l=1;var p=[a.split(":")];
var q=!0}else{if(L(a)){b=d||Object.keys(e);c=b.length;for(h=0;h<c;h++)l=d?d[h]:e[b[h]],a(l)&&(g[f++]=l);return g}c||(c=b);h=Object.keys(a);l=h.length;q=!1;if(1===l&&"id"===h[0])return[e[a.id]];if((p=this.J)&&!d)for(var n=0;n<p.length;n++){var r=p[n],t=a[r];if(!E(t)){d=this.B[r]["@"+t];if(0===--l)return d;h.splice(h.indexOf(r),1);delete a[r];break}}p=Array(l);for(n=0;n<l;n++)p[n]=h[n].split(":")}n=d||Object.keys(e);r=n.length;for(t=0;t<r;t++){for(var y=d?d[t]:e[n[t]],u=!0,v=0;v<l;v++){q||(b=a[h[v]]);
var w=p[v],A=w.length,x=y;if(1<A)for(var B=0;B<A;B++)x=x[w[B]];else x=x[w[0]];if(x!==b){u=!1;break}}if(u&&(g[f++]=y,c&&f===c))break}return g};e.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.a[a].postMessage({info:!0,id:this.id});else{for(var b,c=0,d=0,e=0,f=0;f<this.f-(this.threshold||0);f++){a=Object.keys(this.o[f]);for(var l=0;l<a.length;l++)b=this.o[f][a[l]].length,c+=1*b+2*a[l].length+4,d+=b,e+=2*a[l].length}a=Object.keys(this.c);b=a.length;for(f=0;f<b;f++)c+=2*a[f].length+
2;return{id:this.id,memory:c,items:b,sequences:d,chars:e,cache:this.cache&&this.cache.C?this.cache.C.length:!1,matcher:O.length+(this.g?this.g.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.h}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.A.clear(),this.A=null);this.o=this.u=this.c=null;if(this.b){for(var a=this.j.index,b=0;b<a.length;b++)a.destroy();this.j=null}return this};e.prototype.export=
function(){if(this.b){for(var a=this.b.index,b=Array(a.length+1),c=0;c<a.length;c++)b[c]=[a[c].o,a[c].u,a[c].c];b[c]=this.j;return JSON.stringify(b)}return JSON.stringify([this.o,this.u,this.c])};e.prototype.import=function(a){a=JSON.parse(a);if(this.b){for(var b=this.b.index,c=b.length,d=0;d<c;d++){var e=b[d];e.o=a[d][0];e.u=a[d][1];e.c=a[d][2];e.j=a[c]}this.j=a[c]}else this.o=a[0],this.u=a[1],this.c=a[2],this.j=a[3]};var N={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),
"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=t(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),
"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=t(b,a));c||1<b.length&&(b=P(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+t(d.substring(1),a))}b=b.join(" ");
b=P(b)}return b}}(),balance:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return P(t(b.toLowerCase(),a))}}()},la=function(){function a(a){this.clear();this.K=!0!==a&&a}a.prototype.clear=function(){this.cache=C();this.count=C();this.index=C();this.C=[]};a.prototype.set=function(a,c){if(this.K&&E(this.cache[a])){var b=this.C.length;if(b===this.K){b--;var d=this.C[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.C[b]=a;this.count[a]=
-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){var b=this.cache[a];if(this.K&&b){var d=++this.count[a],e=this.index,f=e[a];if(0<f){for(var l=this.C,h=f;this.count[l[--f]]<=d&&-1!==f;);f++;if(f!==h){for(d=h;d>f;d--)h=l[d-1],l[d]=h,e[h]=d;l[f]=a;e[a]=f}}}return b};return a}();return e}(function(){var f={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,n,l,K,d){l=k?URL.createObjectURL(new Blob(["("+l.toString()+")()"],{type:"text/javascript"})):
e+".es5.js";e+="-"+n;f[e]||(f[e]=[]);f[e][d]=new Worker(l);f[e][d].onmessage=K;console.log("Register Worker: "+e+"@"+d);return f[e][d]}}()),this);
'use strict';function S(h){var l=0;return function(){return l<h.length?{done:!1,value:h[l++]}:{done:!0}}}function T(h){var l="undefined"!=typeof Symbol&&Symbol.iterator&&h[Symbol.iterator];return l?l.call(h):{next:S(h)}}var Z="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(h,l,f){h!=Array.prototype&&h!=Object.prototype&&(h[l]=f.value)};
function ba(h,l){if(l){var f=Z;h=h.split(".");for(var m=0;m<h.length-1;m++){var A=h[m];A in f||(f[A]={});f=f[A]}h=h[h.length-1];m=f[h];l=l(m);l!=m&&null!=l&&aa(f,h,{configurable:!0,writable:!0,value:l})}}
ba("Promise",function(h){function l(d){this.g=0;this.s=void 0;this.b=[];var e=this.j();try{d(e.resolve,e.reject)}catch(t){e.reject(t)}}function f(){this.b=null}function m(d){return d instanceof l?d:new l(function(e){e(d)})}if(h)return h;f.prototype.g=function(d){if(null==this.b){this.b=[];var e=this;this.j(function(){e.s()})}this.b.push(d)};var A=Z.setTimeout;f.prototype.j=function(d){A(d,0)};f.prototype.s=function(){for(;this.b&&this.b.length;){var d=this.b;this.b=[];for(var e=0;e<d.length;++e){var f=
d[e];d[e]=null;try{f()}catch(H){this.l(H)}}}this.b=null};f.prototype.l=function(d){this.j(function(){throw d;})};l.prototype.j=function(){function d(d){return function(l){f||(f=!0,d.call(e,l))}}var e=this,f=!1;return{resolve:d(this.N),reject:d(this.l)}};l.prototype.N=function(d){if(d===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof l)this.O(d);else{a:switch(typeof d){case "object":var e=null!=d;break a;case "function":e=!0;break a;default:e=!1}e?this.M(d):this.w(d)}};
l.prototype.M=function(d){var e=void 0;try{e=d.then}catch(t){this.l(t);return}"function"==typeof e?this.P(e,d):this.w(d)};l.prototype.l=function(d){this.B(2,d)};l.prototype.w=function(d){this.B(1,d)};l.prototype.B=function(d,e){if(0!=this.g)throw Error("Cannot settle("+d+", "+e+"): Promise already settled in state"+this.g);this.g=d;this.s=e;this.J()};l.prototype.J=function(){if(null!=this.b){for(var d=0;d<this.b.length;++d)J.g(this.b[d]);this.b=null}};var J=new f;l.prototype.O=function(d){var e=this.j();
d.G(e.resolve,e.reject)};l.prototype.P=function(d,e){var f=this.j();try{d.call(e,f.resolve,f.reject)}catch(H){f.reject(H)}};l.prototype.then=function(d,e){function f(e,d){return"function"==typeof e?function(d){try{h(e(d))}catch(O){m(O)}}:d}var h,m,A=new l(function(e,d){h=e;m=d});this.G(f(d,h),f(e,m));return A};l.prototype.catch=function(d){return this.then(void 0,d)};l.prototype.G=function(d,e){function f(){switch(l.g){case 1:d(l.s);break;case 2:e(l.s);break;default:throw Error("Unexpected state: "+
l.g);}}var l=this;null==this.b?J.g(f):this.b.push(f)};l.resolve=m;l.reject=function(d){return new l(function(e,f){f(d)})};l.race=function(d){return new l(function(e,f){for(var l=T(d),h=l.next();!h.done;h=l.next())m(h.value).G(e,f)})};l.all=function(d){var e=T(d),f=e.next();return f.done?m([]):new l(function(d,l){function h(e){return function(f){A[e]=f;t--;0==t&&d(A)}}var A=[],t=0;do A.push(void 0),t++,m(f.value).G(h(A.length-1),l),f=e.next();while(!f.done)})};return l});
(function(h,l,f){var m;(m=f.define)&&m.amd?m([],function(){return l}):(m=f.modules)?m[h.toLowerCase()]=l:"object"===typeof exports?module.exports=l:f[h]=l})("FlexSearch",function fa(h){function f(a,b){var c=b?b.id:a&&a.id;this.id=c||0===c?c:ha++;this.init(a,b);d(this,"index",function(){return this.c});d(this,"length",function(){return Object.keys(this.c).length})}function m(a,b,c,g){this.F!==this.i&&(this.A=this.A.concat(c),this.F++,g&&this.A.length>=g&&(this.F=this.i),this.F===this.i&&(this.cache&&
this.v.set(b,this.A),this.I&&this.I(this.A)));return this}function A(a,b){for(var c=a.length,g=M(b),k=[],p=0,e=0;p<c;p++){var f=a[p];if(g&&b(f)||!g&&!b[f])k[e++]=f}return k}function J(a,b,c,g,k,p){var e=this.m;b=O(b,k?0:g,p,this.D);p=b.length;for(var f=Array(p),d=0;d<p;d++)f[d]=e[b[d]];b=f;k&&(b=this.where(k,null,g,b));c&&(M(c)||(G=c.split(":"),1<G.length?c=ea:(G=G[0],c=da)),b.sort(c));this.cache&&this.v.set(a,b);return b}function d(a,b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,
"g")}function t(a,b){for(var c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function H(a,b,c,g,k,p,e,f){if(b[c])return b[c];k=k?(f-(e||f/1.5))*p+(e||f/1.5)*k:p;b[c]=k;k>=e&&(a=a[f-(k+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=g);return k}function Q(a,b){if(a)for(var c=Object.keys(a),g=0,k=c.length;g<k;g++){var p=c[g],e=a[p];if(e)for(var f=0,d=e.length;f<d;f++)if(e[f]===b){1===d?delete a[p]:e.splice(f,1);break}else K(e[f])&&Q(e[f],b)}}function R(a){for(var b="",c="",g="",k=0;k<a.length;k++){var p=
a[k];if(p!==c)if(k&&"h"===p){if(g="a"===g||"e"===g||"i"===g||"o"===g||"u"===g||"y"===g,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&g||" "===c)b+=p}else b+=p;g=k===a.length-1?"":a[k+1];c=p}return b}function ca(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function da(a,b){a=a[G];b=b[G];return a<b?-1:a>b?1:0}function ea(a,b){for(var c=G.length,g=0;g<c;g++)a=a[G[g]],b=b[G[g]];return a<b?-1:a>b?1:0}function O(a,b,c,g){c=[];var k=a.length;if(1<k){for(var p=C(),e=a[0],f=e.length,d=0;d<f;)p["@"+
e[d++]]=1;for(var h,q=0,n=0;++n<k;){var m=!1,v=n===k-1;var B=[];e=a[n];f=e.length;for(d=0;d<f;){h=e[d++];var y="@"+h;if(p[y]){var x=p[y];if(x===n){if(v){if(c[q++]=h,b&&q===b)return c}else p[y]=n+1;m=!0}else g&&(y=B[x]||(B[x]=[]),y[y.length]=h)}}if(!m&&!g)break}if(g&&(q=c.length,(n=B.length)&&(!b||q<b)))for(;n--;)if(h=B[n])for(d=0,f=h.length;d<f;d++)if(c[q++]=h[d],b&&q===b)return c}else k&&(c=a[0],b&&c.length>b&&(c=c.slice(0,b)));return c}function L(a){return"string"===typeof a}function I(a){return a.constructor===
Array}function M(a){return"function"===typeof a}function K(a){return"object"===typeof a}function F(a){return"undefined"===typeof a}function U(a){for(var b=Array(a),c=0;c<a;c++)b[c]=C();return b}function C(){return Object.create(null)}function ia(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var g=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:g})}else c.add?b.add(c.id,c.content):
c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ja(a,b,c,g){a=h("flexsearch","id"+a,ia,function(a){(a=a.data)&&a.result&&g(a.id,a.content,a.result,a.limit,a.where,a.cursor,a.suggest)},b);var k=fa.toString();c.id=b;a.postMessage({register:k,
options:c,id:b});return a}var z={encode:"icase",h:"forward",D:!1,cache:!1,async:!1,i:!1,H:!1,a:!1,L:!1,f:9,threshold:0,depth:0},V={memory:{encode:"extra",h:"strict",threshold:0,f:1},speed:{encode:"icase",h:"strict",threshold:1,f:3,depth:2},match:{encode:"extra",h:"full",threshold:1,f:3},score:{encode:"extra",h:"strict",threshold:1,f:9,depth:4},balance:{encode:"balance",h:"strict",threshold:0,f:3,depth:3},fast:{encode:"icase",h:"strict",threshold:8,f:9,depth:1}},P=[],ha=0,W=/\W+/,X={},Y={};f.create=
function(a){return new f(a)};f.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&P.push(e(b),a[b]);return this};f.registerEncoder=function(a,b){N[a]=b.bind(N);return this};f.registerLanguage=function(a,b){X[a]=b.filter;Y[a]=b.stemmer;return this};f.encode=function(a,b){return N[a](b)};f.prototype.init=function(a,b){this.g=[];if(b){var c=b.preset;a=b}else a||(a=z),c=a.preset;b={};L(a)?((b=V[a])||console.warn("Preset not found: "+a),a={}):c&&((b=V[c])||console.warn("Preset not found: "+
c));if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.b=null;else{var g=parseInt(c,10)||4;this.w=-1;this.F=0;this.A=[];this.I=null;this.b=Array(g);for(var k=0;k<g;k++)this.b[k]=ja(this.id,k,a,m.bind(this))}this.h=a.tokenize||b.h||this.h||z.h;this.H=a.rtl||this.H||z.H;this.async="undefined"===typeof Promise||F(c=a.async)?this.async||z.async:c;this.i=F(c=a.worker)?this.i||z.i:c;this.threshold=F(c=a.threshold)?b.threshold||this.threshold||z.threshold:c;this.f=F(c=a.resolution)?c=b.f||this.f||
z.f:c;c<=this.threshold&&(this.f=this.threshold+1);this.depth=F(c=a.depth)?b.depth||this.depth||z.depth:c;this.L=F(c=a.paging)?this.L||z.L:c;this.D=F(c=a.suggest)?this.D||z.D:c;this.j=(c=F(c=a.encode)?b.encode||z.encode:c)&&N[c]&&N[c].bind(N)||(M(c)?c:this.j||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){L(c)&&(c=X[c]);if(I(c)){b=this.j;g=C();for(k=0;k<c.length;k++){var p=b?b(c[k]):c[k];g[p]=1}c=g}this.filter=c}if(c=a.stemmer){b=L(c)?Y[c]:c;g=this.j;k=[];for(var d in b)b.hasOwnProperty(d)&&
(p=g?g(d):d,k.push(e(p+"($|\\W)"),g?g(b[d]):b[d]));this.stemmer=k}this.a=k=(c=a.doc)?c:this.a||z.a;this.o=U(this.f-(this.threshold||0));this.u=C();this.c=C();if(k){this.m=C();a.doc=null;d=k.index={};b=k.keys=[];g=k.field;p=k.tag;I(k.id)||(k.id=k.id.split(":"));if(p){this.B=C();var h=C();if(g)if(L(g))h[g]=a;else if(I(g))for(var u=0;u<g.length;u++)h[g[u]]=a;else K(g)&&(h=g);I(p)||(k.tag=p=[p]);for(g=0;g<p.length;g++)this.B[p[g]]=C();this.J=p;g=h}if(g){if(!I(g))if(K(g)){var r=g;k.field=g=Object.keys(g)}else k.field=
g=[g];for(k=0;k<g.length;k++)p=g[k],I(p)||(r&&(a=r[p]),b[k]=p,g[k]=p.split(":")),d[p]=new f(a),d[p].m=this.m}}this.s=!0;this.v=(this.cache=c=F(c=a.cache)?this.cache||z.cache:c)?new ka(c):!1;return this};f.prototype.encode=function(a){a&&P.length&&(a=t(a,P));a&&this.g.length&&(a=t(a,this.g));a&&this.j&&(a=this.j(a));a&&this.stemmer&&(a=t(a,this.stemmer));return a};f.prototype.addMatcher=function(a){var b=this.g,c;for(c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};f.prototype.add=function(a,
b,c,g,k){if(this.a&&K(a))return this.l("add",a,b);if(b&&L(b)&&(a||0===a)){var e="@"+a;if(this.c[e]&&!g)return this.update(a,b);if(this.i)return++this.w>=this.b.length&&(this.w=0),this.b[this.w].postMessage({add:!0,id:a,content:b}),this.c[e]=""+this.w,c&&c(),this;if(!k){if(this.async&&"function"!==typeof importScripts){var f=this;e=new Promise(function(c){setTimeout(function(){f.add(a,b,null,g,!0);f=null;c()})});if(c)e.then(c);else return e;return this}if(c)return this.add(a,b,null,g,!0),c(),this}b=
this.encode(b);if(!b.length)return this;c=this.h;k=M(c)?c(b):b.split(W);this.filter&&(k=A(k,this.filter));var d=C();d._ctx=C();for(var h=k.length,r=this.threshold,q=this.depth,n=this.f,m=this.o,v=this.H,B=0;B<h;B++){var y=k[B];if(y){var x=y.length,D=(v?B+1:h-B)/h,E="";switch(c){case "reverse":case "both":for(var w=x;--w;)E=y[w]+E,H(m,d,E,a,v?1:(x-w)/x,D,r,n-1);E="";case "forward":for(w=0;w<x;w++)E+=y[w],H(m,d,E,a,v?(w+1)/x:1,D,r,n-1);break;case "full":for(w=0;w<x;w++)for(var t=(v?w+1:x-w)/x,z=x;z>
w;z--)E=y.substring(w,z),H(m,d,E,a,t,D,r,n-1);break;default:if(x=H(m,d,y,a,1,D,r,n-1),q&&1<h&&x>=r)for(x=d._ctx[y]||(d._ctx[y]=C()),y=this.u[y]||(this.u[y]=U(n-(r||0))),D=B-q,E=B+q+1,0>D&&(D=0),E>h&&(E=h);D<E;D++)D!==B&&H(y,x,k[D],a,0,n-(D<B?B-D:D-B),r,n-1)}}}this.c[e]=1;this.s=!1}return this};f.prototype.l=function(a,b,c){if(I(b))for(var g=0,e=b.length;g<e;g++){if(g===e-1)return this.l(a,b[g],c);this.l(a,b[g])}else{g=this.a.index;e=this.a.keys;for(var d=this.a.tag,f=this.a.id,h,u,r,q,n=0;n<f.length;n++)h=
(h||b)[f[n]];if(d){for(f=0;f<d.length;f++){r=d[f];u=r.split(":");for(n=0;n<u.length;n++)q=(q||b)[u[n]];q="@"+q}u=this.B[r];u=u[q]||(u[q]=[])}if("remove"===a)for(delete this.m[h],f=0,d=e.length;f<d;f++){if(f===d-1)return g[e[f]].remove(h,c);g[e[f]].remove(h)}f=this.a.field;u&&(u[u.length]=b);d=0;for(r=f.length;d<r;d++){u=f[d];q=void 0;for(n=0;n<u.length;n++)q=(q||b)[u[n]];this.m[h]=b;u=g[e[d]];n="add"===a?u.add:u.update;if(d===r-1)return n.call(u,h,q,c);n.call(u,h,q)}}};f.prototype.update=function(a,
b,c){if(this.a&&K(a))return this.l("update",a,b);this.c["@"+a]&&L(b)&&(this.remove(a),this.add(a,b,c,!0));return this};f.prototype.remove=function(a,b,c){if(this.a&&K(a))return this.l("remove",a,b);var g="@"+a;if(this.c[g]){if(this.i)return this.b[this.c[g]].postMessage({remove:!0,id:a}),delete this.c[g],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var e=this;g=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=null;b()})});if(b)g.then(b);else return g;return this}if(b)return this.remove(a,
null,!0),b(),this}for(b=0;b<this.f-(this.threshold||0);b++)Q(this.o[b],a);this.depth&&Q(this.u,a);delete this.c[g];this.s=!1}return this};var G;f.prototype.search=function(a,b,c,g){if(K(b)){if(I(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var d=a,f=[];if(K(a)&&!I(a)){(c=a.callback||b)&&(d.callback=null);var h=a.sort;var u=a.where;b=a.limit;var r=a.threshold;a=a.query}if(this.a){r=this.a.index;var q=d.field;if(q)d.field=null,I(q)||(q=[q]);else if(I(d)){var n=d;q=[];for(var m=
0;m<d.length;m++)q[m]=d[m].field}else q=this.a.keys;h&&(d.sort=null);m=q.length;for(var v=0;v<m;v++)n&&(d=n[v]),f[v]=r[q[v]].search(d);if(c)return c(J.call(this,a,f,h,b,u,void 0));if(this.async){var B=this;return new Promise(function(c){Promise.all(f).then(function(g){c(J.call(B,a,g,h,b,u,void 0))})})}return J.call(this,a,f,h,b,u,void 0)}r||(r=this.threshold||0);M(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.i)for(this.I=c,this.F=0,this.A=[],q=0;q<this.i;q++)this.b[q].postMessage({search:!0,limit:b,cursor:void 0,
threshold:r,where:u,content:a});else{if(!g){if(this.async&&"function"!==typeof importScripts){var y=this;r=new Promise(function(a){setTimeout(function(){a(y.search(d,b,null,!0));y=null})});if(c)r.then(c);else return r;return this}if(c)return c(this.search(d,b,null,!0)),this}if(!a||!L(a))return f;d=a;if(this.cache)if(this.s){if(c=this.v.get(a))return c}else this.v.clear(),this.s=!0;d=this.encode(d);if(!d.length)return f;c=this.h;c=M(c)?c(d):d.split(W);this.filter&&(c=A(c,this.filter));n=c.length;g=
!0;e=[];var x=C();1<n&&(this.depth?(q=!0,v=c[0],x[v]=1):c.sort(ca));if(!q||(m=this.u)[v])for(var D=this.f,E=q?1:0;E<n;E++){var w=c[E];if(w){if(!x[w]){var t=[],z=!1,F=0;if(v=q?m[v]:this.o)for(var H=void 0,G=0;G<D-r;G++)if(H=v[G][w])t[F++]=H,z=!0;if(z)e[e.length]=1<F?t.concat.apply([],t):t[0];else if(!this.D){g=!1;break}x[w]=1}v=w}}else g=!1;g&&(f=O(e,b,void 0,this.D));this.cache&&!this.a&&this.v.set(a,f);return f}};f.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};f.prototype.where=
function(a,b,c,g){var d=g||this.m,e=[],f=0,h;if("number"===typeof a)return[d[a]];if(L(a)){if(F(b))return[d[a]];if("id"===a)return[d[b]];var m=1;var r=[a.split(":")];var q=!0}else{if(M(a)){b=g||Object.keys(d);c=b.length;for(h=0;h<c;h++)m=g?g[h]:d[b[h]],a(m)&&(e[f++]=m);return e}c||(c=b);h=Object.keys(a);m=h.length;q=!1;if(1===m&&"id"===h[0])return[d[a.id]];if((r=this.J)&&!g)for(var n=0;n<r.length;n++){var t=r[n],v=a[t];if(!F(v)){g=this.B[t]["@"+v];if(0===--m)return g;h.splice(h.indexOf(t),1);delete a[t];
break}}r=Array(m);for(n=0;n<m;n++)r[n]=h[n].split(":")}n=g||Object.keys(d);t=n.length;for(v=0;v<t;v++){for(var B=g?g[v]:d[n[v]],y=!0,x=0;x<m;x++){q||(b=a[h[x]]);var z=r[x],A=z.length,w=B;if(1<A)for(var C=0;C<A;C++)w=w[z[C]];else w=w[z[0]];if(w!==b){y=!1;break}}if(y&&(e[f++]=B,c&&f===c))break}return e};f.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.b[a].postMessage({info:!0,id:this.id});else{for(var b,c=0,d=0,e=0,f=0;f<this.f-(this.threshold||0);f++){a=Object.keys(this.o[f]);for(var h=
0;h<a.length;h++)b=this.o[f][a[h]].length,c+=1*b+2*a[h].length+4,d+=b,e+=2*a[h].length}a=Object.keys(this.c);b=a.length;for(f=0;f<b;f++)c+=2*a[f].length+2;return{id:this.id,memory:c,items:b,sequences:d,chars:e,cache:this.cache&&this.cache.C?this.cache.C.length:!1,matcher:P.length+(this.g?this.g.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.h}}};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.cache&&
(this.v.clear(),this.v=null);this.o=this.u=this.c=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.m=null}return this};f.prototype.export=function(){if(this.a){for(var a=this.a.keys,b=Array(a.length+1),c=0;c<a.length;c++){var d=this.a.index[a[c]];b[c]=[d.o,d.u,d.c]}b[c]=this.m;return JSON.stringify(b)}return JSON.stringify([this.o,this.u,this.c])};f.prototype.import=function(a){a=JSON.parse(a);if(this.a){for(var b=this.a.keys,c=b.length,d=0;d<c;d++){var e=
this.a.index[b[d]];e.o=a[d][0];e.u=a[d][1];e.c=a[d][2];e.m=a[c]}this.m=a[c]}else this.o=a[0],this.u=a[1],this.c=a[2]};var N={icase:function(a){return a.toLowerCase()},simple:function(){var a=[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("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]"),
" ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=t(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=t(b,a));c||1<b.length&&(b=R(b));return b}}(),extra:function(){var a=[e("p"),"b",e("z"),"s",e("[cgq]"),
"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+t(d.substring(1),a))}b=b.join(" ");b=R(b)}return b}}(),balance:function(){var a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return R(t(b.toLowerCase(),a))}}()},ka=function(){function a(a){this.clear();this.K=!0!==a&&a}a.prototype.clear=function(){this.cache=C();this.count=
C();this.index=C();this.C=[]};a.prototype.set=function(a,c){if(this.K&&F(this.cache[a])){var b=this.C.length;if(b===this.K){b--;var d=this.C[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.C[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){var b=this.cache[a];if(this.K&&b){var d=++this.count[a],e=this.index,f=e[a];if(0<f){for(var h=this.C,m=f;this.count[h[--f]]<=d&&-1!==f;);f++;if(f!==m){for(d=m;d>f;d--)m=h[d-
1],h[d]=m,e[m]=d;h[f]=a;e[a]=f}}}return b};return a}();return f}(function(){var h={},l="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(f,m,A,J,d){A=l?URL.createObjectURL(new Blob(["("+A.toString()+")()"],{type:"text/javascript"})):f+".es5.js";f+="-"+m;h[f]||(h[f]=[]);h[f][d]=new Worker(A);h[f][d].onmessage=J;console.log("Register Worker: "+f+"@"+d);return h[f][d]}}()),this);

View File

@@ -1,18 +1,18 @@
/*
FlexSearch v0.5.1
FlexSearch v0.5.2
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(d,l,v){let t;(t=v.define)&&t.amd?t([],function(){return l}):(t=v.modules)?t[d.toLowerCase()]=l:"object"===typeof exports?module.exports=l:v[d]=l})("FlexSearch",function(){function d(a,c){const b=c?c.id:a&&a.id;this.id=b||0===b?b:G++;this.init(a,c);l(this,"index",function(){return this.b});l(this,"length",function(){return Object.keys(this.b).length})}function l(a,c,b){Object.defineProperty(a,c,{get:b})}function v(a,c){for(let b=0;b<c.length;b+=2)a=a.replace(c[b],c[b+1]);return a}
function t(a,c,b,f,e,p,g,h){if(c[b])return c[b];e=e?(h-(g||h/1.5))*p+(g||h/1.5)*e:p;c[b]=e;e>=g&&(a=a[h-(e+.5>>0)],a=a[b]||(a[b]=[]),a[a.length]=f);return e}function A(a,c){if(a){const b=Object.keys(a);for(let f=0,e=b.length;f<e;f++){const e=b[f],g=a[e];if(g)for(let b=0,f=g.length;b<f;b++)if(g[b]===c){1===f?delete a[e]:g.splice(b,1);break}else"object"===typeof g[b]&&A(g[b],c)}}}function H(a,c){a=a.length-c.length;return 0>a?1:a?-1:0}function I(a,c){a=a.length-c.length;return 0>a?-1:a?1:0}function z(a){return"function"===
typeof a}function y(a){return"undefined"===typeof a}function C(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=u();return c}function u(){return Object.create(null)}const n={encode:"icase",c:"forward",o:!1,cache:!1,async:!1,s:!1,i:!1,m:!1,l:!1,a:9,threshold:0,depth:0},B=[];let G=0;const D=/\W+/g,E={},F={};d.create=function(a){return new d(a)};d.registerMatcher=function(a){for(const c in a)a.hasOwnProperty(c)&&B.push(new RegExp(c,"g"),a[c]);return this};d.registerEncoder=function(a,c){w[a]=c.bind(w);return this};
d.registerLanguage=function(a,c){E[a]=c.filter;F[a]=c.stemmer;return this};d.encode=function(a,c){return w[a](c)};d.prototype.init=function(a,c){this.j=[];if(c){var b=c.preset;a=c}else a||(a=n),b=a.preset;c={};this.c=a.tokenize||c.c||this.c||n.c;this.i=a.rtl||this.i||n.i;this.threshold=y(b=a.threshold)?c.threshold||this.threshold||n.threshold:b;this.a=y(b=a.resolution)?b=c.a||this.a||n.a:b;b<=this.threshold&&(this.a=this.threshold+1);this.depth=y(b=a.depth)?c.depth||this.depth||n.depth:b;this.l=y(b=
a.paging)?this.l||n.l:b;this.g=(b=y(b=a.encode)?c.encode||n.encode:b)&&w[b]&&w[b].bind(w)||(z(b)?b:this.g||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=E[b]||b;c=this.g;var f=u();if(b)for(let a=0;a<b.length;a++){const e=c?c(b[a]):b[a];f[e]=String.fromCharCode(65E3-b.length+a)}this.filter=b=f}if(b=a.stemmer){var e;a=F[b]||b;b=this.g;c=[];if(a)for(e in a)a.hasOwnProperty(e)&&(f=b?b(e):e,c.push(new RegExp("(?=.{"+(f.length+3)+",})"+f+"$","g"),b?b(a[e]):a[e]));this.stemmer=e=c}this.h=C(this.a-
(this.threshold||0));this.f=u();this.b=u();return this};d.prototype.encode=function(a){a&&B.length&&(a=v(a,B));a&&this.j.length&&(a=v(a,this.j));a&&this.g&&(a=this.g(a));a&&this.stemmer&&(a=v(a,this.stemmer));return a};d.prototype.addMatcher=function(a){const c=this.j;for(const b in a)a.hasOwnProperty(b)&&c.push(new RegExp(b,"g"),a[b]);return this};d.prototype.add=function(a,c,b,f,e){if(c&&"string"===typeof c&&(a||0===a)){const d="@"+a;if(this.b[d]&&!f)return this.update(a,c);if(!e&&b)return this.add(a,
c,null,f,!0),b(),this;c=this.encode(c);if(!c.length)return this;b=this.c;c=z(b)?b(c):c.split(D);f=u();f._ctx=u();e=this.threshold;const n=this.depth,r=this.a,q=this.h,x=c.length,l=this.i;for(let d=0;d<x;d++){var p=c[d];if(p){var g=p.length,h=(l?d+1:x-d)/x,m="";switch(b){case "reverse":case "both":for(var k=g;--k;)m=p[k]+m,t(q,f,m,a,l?1:(g-k)/g,h,e,r-1);m="";case "forward":for(k=0;k<g;k++)m+=p[k],t(q,f,m,a,l?(k+1)/g:1,h,e,r-1);break;case "full":for(k=0;k<g;k++){const b=(l?k+1:g-k)/g;for(let c=g;c>
k;c--)m=p.substring(k,c),t(q,f,m,a,b,h,e,r-1)}break;default:if(g=t(q,f,p,a,1,h,e,r-1),n&&1<x&&g>=e)for(g=f._ctx[p]||(f._ctx[p]=u()),p=this.f[p]||(this.f[p]=C(r-(e||0))),h=d-n,m=d+n+1,0>h&&(h=0),m>x&&(m=x);h<m;h++)h!==d&&t(p,g,c[h],a,0,r-(h<d?d-h:h-d),e,r-1)}}}this.b[d]=1}return this};d.prototype.update=function(a,c,b){this.b["@"+a]&&"string"===typeof c&&(this.remove(a),this.add(a,c,b,!0));return this};d.prototype.remove=function(a,c,b){const f="@"+a;if(this.b[f]){if(!b&&c)return this.remove(a,null,
!0),c(),this;for(c=0;c<this.a-(this.threshold||0);c++)A(this.h[c],a);this.depth&&A(this.f,a);delete this.b[f]}return this};d.prototype.search=function(a,c,b,f){var e=a,d=[];if("object"===typeof a){c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);z(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(e,c,null,!0)),this;if(!a||"string"!==typeof a)return d;e=this.encode(a);if(!e.length)return d;a=this.c;a=z(a)?a(e):e.split(D);b=a.length;f=!0;e=[];var h=u();if(1<b)if(this.depth){var m=
!0;var k=a[0];h[k]=1}else a.sort(H);var l;if(!m||(l=this.f)[k]){var n=this.a;for(var r=m?1:0;r<b;r++){var q=a[r];if(q){if(!h[q]){const a=[];let b=!1,c=0;if(k=m?l[k]:this.h){let e;for(let d=0;d<n-g;d++)if(e=k[d][q])a[c++]=e,b=!0}if(b)e[e.length]=1<c?a.concat.apply([],a):a[0];else{f=!1;break}h[q]=1}k=q}}}else f=!1;if(f)a:{g=[];d=e.length;if(1<d){e.sort(I);m=u();l=e[0];k=l.length;for(a=0;a<k;)m["@"+l[a++]]=1;for(h=f=0;++h<d;){n=!1;r=h===d-1;l=e[h];k=l.length;for(a=0;a<k;)if(b=l[a++],q="@"+b,m[q]&&m[q]===
h){if(r){if(g[f++]=b,c&&f===c){d=g;break a}}else m[q]=h+1;n=!0}if(!n)break}}else d&&(g=e[0],c&&g.length>c&&(g=g.slice(0,c)));d=g}return d};d.prototype.clear=function(){return this.destroy().init()};d.prototype.destroy=function(){this.h=this.f=this.b=null;return this};const w={icase:function(a){return a.toLowerCase()}};return d}(!1),this);
'use strict';(function(e,u,r){let l;(l=r.define)&&l.amd?l([],function(){return u}):(l=r.modules)?l[e.toLowerCase()]=u:"object"===typeof exports?module.exports=u:r[e]=u})("FlexSearch",function(){function e(a,c){const b=c?c.id:a&&a.id;this.id=b||0===b?b:I++;this.init(a,c);r(this,"index",function(){return this.b});r(this,"length",function(){return Object.keys(this.b).length})}function u(a,c){const b=a.length,f=x(c),d=[];for(let n=0,g=0;n<b;n++){const b=a[n];if(f&&c(b)||!f&&!c[b])d[g++]=b}return d}function r(a,
c,b){Object.defineProperty(a,c,{get:b})}function l(a,c){for(let b=0;b<c.length;b+=2)a=a.replace(c[b],c[b+1]);return a}function y(a,c,b,f,d,n,g,h){if(c[b])return c[b];d=d?(h-(g||h/1.5))*n+(g||h/1.5)*d:n;c[b]=d;d>=g&&(a=a[h-(d+.5>>0)],a=a[b]||(a[b]=[]),a[a.length]=f);return d}function C(a,c){if(a){const b=Object.keys(a);for(let f=0,d=b.length;f<d;f++){const d=b[f],g=a[d];if(g)for(let b=0,f=g.length;b<f;b++)if(g[b]===c){1===f?delete a[d]:g.splice(b,1);break}else"object"===typeof g[b]&&C(g[b],c)}}}function J(a,
c){a=a.length-c.length;return 0>a?1:a?-1:0}function z(a){return"string"===typeof a}function x(a){return"function"===typeof a}function A(a){return"undefined"===typeof a}function E(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=t();return c}function t(){return Object.create(null)}const p={encode:"icase",c:"forward",o:!1,cache:!1,async:!1,s:!1,i:!1,m:!1,l:!1,a:9,threshold:0,depth:0},D=[];let I=0;const F=/\W+/,G={},H={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(const c in a)a.hasOwnProperty(c)&&
D.push(new RegExp(c,"g"),a[c]);return this};e.registerEncoder=function(a,c){w[a]=c.bind(w);return this};e.registerLanguage=function(a,c){G[a]=c.filter;H[a]=c.stemmer;return this};e.encode=function(a,c){return w[a](c)};e.prototype.init=function(a,c){this.j=[];if(c){var b=c.preset;a=c}else a||(a=p),b=a.preset;c={};this.c=a.tokenize||c.c||this.c||p.c;this.i=a.rtl||this.i||p.i;this.threshold=A(b=a.threshold)?c.threshold||this.threshold||p.threshold:b;this.a=A(b=a.resolution)?b=c.a||this.a||p.a:b;b<=this.threshold&&
(this.a=this.threshold+1);this.depth=A(b=a.depth)?c.depth||this.depth||p.depth:b;this.l=A(b=a.paging)?this.l||p.l:b;this.g=(b=A(b=a.encode)?c.encode||p.encode:b)&&w[b]&&w[b].bind(w)||(x(b)?b:this.g||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){z(b)&&(b=G[b]);if(b.constructor===Array){c=this.g;var f=t();for(let a=0;a<b.length;a++){const d=c?c(b[a]):b[a];f[d]=1}b=f}this.filter=b}if(b=a.stemmer){var d;a=z(b)?H[b]:b;b=this.g;c=[];for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp(f+
"($|\\W)","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.h=E(this.a-(this.threshold||0));this.f=t();this.b=t();return this};e.prototype.encode=function(a){a&&D.length&&(a=l(a,D));a&&this.j.length&&(a=l(a,this.j));a&&this.g&&(a=this.g(a));a&&this.stemmer&&(a=l(a,this.stemmer));return a};e.prototype.addMatcher=function(a){const c=this.j;for(const b in a)a.hasOwnProperty(b)&&c.push(new RegExp(b,"g"),a[b]);return this};e.prototype.add=function(a,c,b,f,d){if(c&&z(c)&&(a||0===a)){const e="@"+a;if(this.b[e]&&
!f)return this.update(a,c);if(!d&&b)return this.add(a,c,null,f,!0),b(),this;c=this.encode(c);if(!c.length)return this;b=this.c;c=x(b)?b(c):c.split(F);this.filter&&(c=u(c,this.filter));f=t();f._ctx=t();d=c.length;const v=this.threshold,l=this.depth,q=this.a,B=this.h,p=this.i;for(let e=0;e<d;e++){var n=c[e];if(n){var g=n.length,h=(p?e+1:d-e)/d,m="";switch(b){case "reverse":case "both":for(var k=g;--k;)m=n[k]+m,y(B,f,m,a,p?1:(g-k)/g,h,v,q-1);m="";case "forward":for(k=0;k<g;k++)m+=n[k],y(B,f,m,a,p?(k+
1)/g:1,h,v,q-1);break;case "full":for(k=0;k<g;k++){const b=(p?k+1:g-k)/g;for(let c=g;c>k;c--)m=n.substring(k,c),y(B,f,m,a,b,h,v,q-1)}break;default:if(g=y(B,f,n,a,1,h,v,q-1),l&&1<d&&g>=v)for(g=f._ctx[n]||(f._ctx[n]=t()),n=this.f[n]||(this.f[n]=E(q-(v||0))),h=e-l,m=e+l+1,0>h&&(h=0),m>d&&(m=d);h<m;h++)h!==e&&y(n,g,c[h],a,0,q-(h<e?e-h:h-e),v,q-1)}}}this.b[e]=1}return this};e.prototype.update=function(a,c,b){this.b["@"+a]&&z(c)&&(this.remove(a),this.add(a,c,b,!0));return this};e.prototype.remove=function(a,
c,b){const f="@"+a;if(this.b[f]){if(!b&&c)return this.remove(a,null,!0),c(),this;for(c=0;c<this.a-(this.threshold||0);c++)C(this.h[c],a);this.depth&&C(this.f,a);delete this.b[f]}return this};e.prototype.search=function(a,c,b,f){var d=a,e=[];if("object"===typeof a){c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);x(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(d,c,null,!0)),this;if(!a||!z(a))return e;d=this.encode(a);if(!d.length)return e;a=this.c;a=x(a)?a(d):d.split(F);
this.filter&&(a=u(a,this.filter));b=a.length;f=!0;d=[];var h=t();if(1<b)if(this.depth){var m=!0;var k=a[0];h[k]=1}else a.sort(J);var l;if(!m||(l=this.f)[k]){var p=this.a;for(var r=m?1:0;r<b;r++){var q=a[r];if(q){if(!h[q]){const a=[];let b=!1,c=0;if(k=m?l[k]:this.h){let d;for(let e=0;e<p-g;e++)if(d=k[e][q])a[c++]=d,b=!0}if(b)d[d.length]=1<c?a.concat.apply([],a):a[0];else{f=!1;break}h[q]=1}k=q}}}else f=!1;if(f)a:{g=[];e=d.length;if(1<e){m=t();l=d[0];k=l.length;for(a=0;a<k;)m["@"+l[a++]]=1;for(h=f=0;++h<
e;){p=!1;r=h===e-1;l=d[h];k=l.length;for(a=0;a<k;)if(b=l[a++],q="@"+b,m[q]&&m[q]===h){if(r){if(g[f++]=b,c&&f===c){e=g;break a}}else m[q]=h+1;p=!0}if(!p)break}}else e&&(g=d[0],c&&g.length>c&&(g=g.slice(0,c)));e=g}return e};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.h=this.f=this.b=null;return this};const w={icase:function(a){return a.toLowerCase()}};return e}(!1),this);

View File

@@ -1,38 +1,39 @@
/*
FlexSearch v0.5.1
FlexSearch v0.5.2
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(w,F,g){let y;(y=g.define)&&y.amd?y([],function(){return F}):(y=g.modules)?y[w.toLowerCase()]=F:"object"===typeof exports?module.exports=F:g[w]=F})("FlexSearch",function U(w){function g(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:V++;this.init(a,b);K(this,"index",function(){return this.b});K(this,"length",function(){return Object.keys(this.b).length})}function y(a,b,c,d){this.u!==this.g&&(this.l=this.l.concat(c),this.u++,d&&this.l.length>=d&&(this.u=this.g),this.G&&this.u===
this.g&&(this.cache&&this.o.set(b,this.l),this.G(this.l),this.l=[]));return this}function B(a,b){a=a.concat.apply([],a);b&&(G(b)||(z=b.split(":"),1<z.length?b=W:(z=z[0],b=X)),a.sort(b));return a}function K(a,b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function E(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function J(a,b,c,d,e,l,k,h){if(b[c])return b[c];e=e?(h-(k||h/1.5))*l+(k||h/1.5)*e:l;b[c]=e;e>=k&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=
d);return e}function N(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],k=a[e];if(k)for(let c=0,d=k.length;c<d;c++)if(k[c]===b){1===d?delete a[e]:k.splice(c,1);break}else A(k[c])&&N(k[c],b)}}}function O(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const l=a[e];if(l!==c)if(e&&"h"===l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=l}else b+=l;d=e===a.length-1?"":a[e+1];c=l}return b}
function Y(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function Z(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function X(a,b){a=a[z];b=b[z];return a<b?-1:a>b?1:0}function W(a,b){const c=z.length;for(let d=0;d<c;d++)a=a[z[d]],b=b[z[d]];return a<b?-1:a>b?1:0}function aa(a,b,c,d,e){c=[];let l;const k=a.length;if(1<k){a.sort(Z);const C=r();let f=a[0],q=f.length,m=0;for(;m<q;)C["@"+f[m++]]=1;let p,g=0,t=0;for(;++t<k;){let n=!1;const D=t===k-1;l=[];f=a[t];q=f.length;for(m=0;m<q;){p=f[m++];var h="@"+p;
if(C[h]){const a=C[h];if(a===t){if(D){if(c[g++]=d?d[p]:p,b&&g===b)return c}else C[h]=t+1;n=!0}else e&&(h=l[a]||(l[a]=[]),h[h.length]=p)}}if(!n&&!e)break}if(e&&(g=c.length,(t=l.length)&&(!b||g<b)))for(;t--;)if(p=l[t])for(m=0,q=p.length;m<q;m++)if(c[g++]=d?d[p[m]]:p[m],b&&g===b)return c}else if(k)if(d)for(a=a[0],e=a.length,b&&b<e&&(e=b),c=Array(e),b=0;b<e;b++)c[b]=d[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function H(a){return"string"===typeof a}function x(a){return a.constructor===
Array}function G(a){return"function"===typeof a}function A(a){return"object"===typeof a}function v(a){return"undefined"===typeof a}function P(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=r();return b}function r(){return Object.create(null)}function ba(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?
b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ca(a,b,c,d){a=w("flexsearch","id"+a,ba,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);const e=U.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}
const u={encode:"icase",f:"forward",B:!1,cache:!1,async:!1,g:!1,F:!1,a:!1,J:!1,c:9,threshold:0,depth:0},Q={memory:{encode:"extra",f:"strict",threshold:0,c:1},speed:{encode:"icase",f:"strict",threshold:1,c:3,depth:2},match:{encode:"extra",f:"full",threshold:1,c:3},score:{encode:"extra",f:"strict",threshold:1,c:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,c:3,depth:3},fast:{encode:"icase",f:"strict",threshold:8,c:9,depth:1}},M=[];let V=0;const R=f("\\W+"),S={},T={};g.create=function(a){return new g(a)};
g.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&M.push(f(b),a[b]);return this};g.registerEncoder=function(a,b){I[a]=b.bind(I);return this};g.registerLanguage=function(a,b){S[a]=b.filter;T[a]=b.stemmer;return this};g.encode=function(a,b){return I[a](b)};g.prototype.init=function(a,b){this.v=[];if(b){var c=b.preset;a=b}else a||(a=u),c=a.preset;b={};H(a)?(b=Q[a],a={}):c&&(b=Q[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.m=null;else{var d=parseInt(c,10)||4;this.D=
-1;this.u=0;this.l=[];this.G=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ca(this.id,e,a,y.bind(this))}this.f=a.tokenize||b.f||this.f||u.f;this.F=a.rtl||this.F||u.F;this.async="undefined"===typeof Promise||v(c=a.async)?this.async||u.async:c;this.g=v(c=a.worker)?this.g||u.g:c;this.threshold=v(c=a.threshold)?b.threshold||this.threshold||u.threshold:c;this.c=v(c=a.resolution)?c=b.c||this.c||u.c:c;c<=this.threshold&&(this.c=this.threshold+1);this.depth=v(c=a.depth)?b.depth||this.depth||u.depth:
c;this.J=v(c=a.paging)?this.J||u.J:c;this.B=v(c=a.suggest)?this.B||u.B:c;this.w=(c=v(c=a.encode)?b.encode||u.encode:c)&&I[c]&&I[c].bind(I)||(G(c)?c:this.w||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=S[c]||c;b=this.w;d=r();if(c)for(e=0;e<c.length;e++){var l=b?b(c[e]):c[e];d[l]=String.fromCharCode(65E3-c.length+e)}this.filter=c=d}if(c=a.stemmer){var k;b=T[c]||c;d=this.w;e=[];if(b)for(k in b)b.hasOwnProperty(k)&&(l=d?d(k):k,e.push(f("(?=.{"+(l.length+3)+",})"+l+"$"),d?d(b[k]):b[k]));this.stemmer=
k=e}this.a=d=(c=a.doc)?c:this.a||u.a;this.i=P(this.c-(this.threshold||0));this.j=r();this.b=r();if(d){this.h=r();a.doc=null;k=d.index=[];b=d.ref={};e=d.field;l=d.tag;x(d.id)||(d.id=d.id.split(":"));if(l){this.H=r();let b=r();if(e)if(H(e))b[e]=a;else if(x(e))for(let c=0;c<e.length;c++)b[e[c]]=a;else A(e)&&(b=e);x(l)||(d.tag=l=[l]);for(e=0;e<l.length;e++)this.H[l[e]]=r();this.K=l;e=b}if(e){let c;x(e)||(A(e)?(c=e,d.field=e=Object.keys(e)):d.field=e=[e]);for(d=0;d<e.length;d++)x(e[d])||(c&&(a=c[e[d]]),
b[e[d]]=d,e[d]=e[d].split(":")),k[d]=new g(a),k[d].h=this.h}}this.C=!0;this.o=(this.cache=c=v(c=a.cache)?this.cache||u.cache:c)?new da(c):!1;return this};g.prototype.encode=function(a){a&&M.length&&(a=E(a,M));a&&this.v.length&&(a=E(a,this.v));a&&this.w&&(a=this.w(a));a&&this.stemmer&&(a=E(a,this.stemmer));return a};g.prototype.addMatcher=function(a){const b=this.v;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};g.prototype.add=function(a,b,c,d,e){if(this.a&&A(a))return this.A("add",
a,b);if(b&&H(b)&&(a||0===a)){var l="@"+a;if(this.b[l]&&!d)return this.update(a,b);if(this.g)return++this.D>=this.m.length&&(this.D=0),this.m[this.D].postMessage({add:!0,id:a,content:b}),this.b[l]=""+this.D,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;l=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)l.then(c);else return l;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;
e=G(c)?c(b):b.split(R);const m=r();m._ctx=r();const p=this.threshold,C=this.depth,t=this.c,q=this.i,D=e.length,L=this.F;for(let b=0;b<D;b++){var k=e[b];if(k){var h=k.length,f=(L?b+1:D-b)/D,n="";switch(c){case "reverse":case "both":for(var g=h;--g;)n=k[g]+n,J(q,m,n,a,L?1:(h-g)/h,f,p,t-1);n="";case "forward":for(g=0;g<h;g++)n+=k[g],J(q,m,n,a,L?(g+1)/h:1,f,p,t-1);break;case "full":for(g=0;g<h;g++){const b=(L?g+1:h-g)/h;for(let c=h;c>g;c--)n=k.substring(g,c),J(q,m,n,a,b,f,p,t-1)}break;default:if(h=J(q,
m,k,a,1,f,p,t-1),C&&1<D&&h>=p)for(h=m._ctx[k]||(m._ctx[k]=r()),k=this.j[k]||(this.j[k]=P(t-(p||0))),f=b-C,n=b+C+1,0>f&&(f=0),n>D&&(n=D);f<n;f++)f!==b&&J(k,h,e[f],a,0,t-(f<b?b-f:f-b),p,t-1)}}}this.b[l]=1;this.C=!1}return this};g.prototype.A=function(a,b,c){if(x(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.A(a,b[d],c);this.A(a,b[d])}else{const g=this.a.index;var d=this.a.tag,e=this.a.id;let h;let q;for(var l=0;l<e.length;l++)h=(h||b)[e[l]];if(d){for(e=0;e<d.length;e++){var k=d[e];var f=
k.split(":");for(l=0;l<f.length;l++)q=(q||b)[f[l]];q="@"+q}f=this.H[k];f=f[q]||(f[q]=[])}if("remove"===a){delete this.h[h];for(let a=0,b=g.length;a<b;a++){if(a===b-1)return g[a].remove(h,c);g[a].remove(h)}}e=this.a.field;f&&(f[f.length]=b);for(let f=0,l=e.length;f<l;f++){d=e[f];let m;for(k=0;k<d.length;k++)m=(m||b)[d[k]];this.h[h]=b;d=g[f];k="add"===a?d.add:d.update;if(f===l-1)return k.call(d,h,m,c);k.call(d,h,m)}}};g.prototype.update=function(a,b,c){if(this.a&&A(a))return this.A("update",a,b);this.b["@"+
a]&&H(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=function(a,b,c){if(this.a&&A(a))return this.A("remove",a,b);var d="@"+a;if(this.b[d]){if(this.g)return this.m[this.b[d]].postMessage({remove:!0,id:a}),delete this.b[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<
this.c-(this.threshold||0);b++)N(this.i[b],a);this.depth&&N(this.j,a);delete this.b[d];this.C=!1}return this};let z;g.prototype.search=function(a,b,c,d){if(A(b)){if(x(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let f=a;let k,h=[];if(A(a)&&!x(a)){(c=a.callback||b)&&(f.callback=null);var g=a.where;k=a.sort;b=a.limit;var n=a.threshold;a=a.query}if(this.a){a=this.a.ref;n=this.a.index;if(g=f.field)f.field=null;else if(x(f)){var q=f;g=[];for(var m=0;m<f.length;m++)g[m]=f[m].field}else g=
Object.keys(a);if(A(g)){k&&(f.sort=null);x(g)||(g=[g]);m=g.length;for(var p=0;p<m;p++)q&&(f=q[p]),h[p]=n[a[g[p]]].search(f);return c?c(B(h,k)):this.async?new Promise(function(a){Promise.all(h).then(function(b){a(B(b,k))})}):B(h,k)}return n[a[g]].search(f,c)}n||(n=this.threshold||0);G(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.g)for(this.G=c,this.u=0,this.l=[],g=0;g<this.g;g++)this.m[g].postMessage({search:!0,limit:b,threshold:n,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let d=
this;a=new Promise(function(a){setTimeout(function(){a(d.search(f,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!H(a))return h;f=a;if(this.cache)if(this.C){if(c=this.o.get(a))return c}else this.o.clear(),this.C=!0;f=this.encode(f);if(!f.length)return h;c=this.f;c=G(c)?c(f):f.split(R);q=c.length;d=!0;e=[];var u=r();if(1<q)if(this.depth){m=!0;var t=c[0];u[t]=1}else c.sort(Y);if(!m||(p=this.j)[t]){let a=this.c;for(let b=m?1:0;b<q;b++){const f=
c[b];if(f){if(!u[f]){const b=[];let c=!1,g=0;if(t=m?p[t]:this.i){let d;for(let e=0;e<a-n;e++)if(d=t[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!this.B){d=!1;break}u[f]=1}t=f}}}else d=!1;d&&(h=aa(e,b,void 0,this.h,this.B));g&&(h=this.where(g,null,b,h));k&&(h=B([h],k));this.cache&&this.o.set(a,h);return h}};g.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};g.prototype.where=function(a,b,c,d){const e=d||this.h,f=[];let g=0;var h;let u;if("number"===typeof a)return[e[a]];
if(H(a)){if(v(b))return[e[a]];if("id"===a)return[e[b]];var n=1;var q=[a.split(":")];u=!0}else{if(G(a)){b=d||Object.keys(e);c=b.length;for(h=0;h<c;h++)n=d?d[h]:e[b[h]],a(n)&&(f[g++]=n);return f}c||(c=b);h=Object.keys(a);n=h.length;u=!1;if(1===n&&"id"===h[0])return[e[a.id]];if((q=this.K)&&!d)for(var m=0;m<q.length;m++){var p=q[m],r=a[p];if(!v(r)){d=this.H[p]["@"+r];if(0===--n)return d;h.splice(h.indexOf(p),1);delete a[p];break}}q=Array(n);for(m=0;m<n;m++)q[m]=h[m].split(":")}m=d||Object.keys(e);p=m.length;
for(r=0;r<p;r++){const k=d?d[r]:e[m[r]];let l=!0;for(let c=0;c<n;c++){u||(b=a[h[c]]);const d=q[c],e=d.length;let f=k;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){l=!1;break}}if(l&&(f[g++]=k,c&&g===c))break}return f};g.prototype.info=function(){if(this.g)for(var a=0;a<this.g;a++)this.m[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,d=0;for(var e=0;e<this.c-(this.threshold||0);e++){a=Object.keys(this.i[e]);for(let g=0;g<a.length;g++){var f=this.i[e][a[g]].length;b+=1*f+2*a[g].length+
4;c+=f;d+=2*a[g].length}}a=Object.keys(this.b);f=a.length;for(e=0;e<f;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:M.length+(this.v?this.v.length:0),worker:this.g,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.f}}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&(this.o.clear(),this.o=null);this.i=this.j=this.b=null;
if(this.a){const a=this.h.index;for(let b=0;b<a.length;b++)a.destroy();this.h=null}return this};g.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].i,a[c].j,a[c].b];b[c]=this.h;return JSON.stringify(b)}return JSON.stringify([this.i,this.j,this.b])};g.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.i=a[d][0];e.j=a[d][1];e.b=a[d][2];e.h=a[c]}this.h=a[c]}else this.i=
a[0],this.j=a[1],this.b=a[2],this.h=a[3]};const I={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=E(b.toLowerCase(),
a);return" "===b?"":b}}(),advanced:function(){const a=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=E(b,a));c||1<b.length&&(b=O(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;
b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+E(d.substring(1),a))}b=b.join(" ");b=O(b)}return b}}(),balance:function(){const a=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return O(E(b.toLowerCase(),a))}}()},da=function(){function a(a){this.clear();this.I=!0!==a&&a}a.prototype.clear=function(){this.cache=r();this.count=r();this.index=r();this.s=[]};a.prototype.set=function(a,c){if(this.I&&v(this.cache[a])){let b=
this.s.length;if(b===this.I){b--;const a=this.s[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.s[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.I&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.s;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return g}(function(){const w=
{},F="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,y,B,K,f){B=F?URL.createObjectURL(new Blob(["("+B.toString()+")()"],{type:"text/javascript"})):g+".min.js";g+="-"+y;w[g]||(w[g]=[]);w[g][f]=new Worker(B);w[g][f].onmessage=K;return w[g][f]}}()),this);
'use strict';(function(x,G,h){let y;(y=h.define)&&y.amd?y([],function(){return G}):(y=h.modules)?y[x.toLowerCase()]=G:"object"===typeof exports?module.exports=G:h[x]=G})("FlexSearch",function X(x){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:Y++;this.init(a,b);H(this,"index",function(){return this.b});H(this,"length",function(){return Object.keys(this.b).length})}function y(a,b,c,d){this.v!==this.g&&(this.o=this.o.concat(c),this.v++,d&&this.o.length>=d&&(this.v=this.g),this.v===this.g&&
(this.cache&&this.l.set(b,this.o),this.G&&this.G(this.o)));return this}function I(a,b){const c=a.length,d=D(b),e=[];for(let f=0,k=0;f<c;f++){const c=a[f];if(d&&b(c)||!d&&!b[c])e[k++]=c}return e}function K(a,b,c,d,e,f){const k=this.h;b=R(b,e?0:d,f,this.u);{f=b.length;const a=Array(f);for(let c=0;c<f;c++)a[c]=k[b[c]];b=a}e&&(b=this.where(e,null,d,b));c&&(D(c)||(A=c.split(":"),1<A.length?c=Z:(A=A[0],c=aa)),b.sort(c));this.cache&&this.l.set(a,b);return b}function H(a,b,c){Object.defineProperty(a,b,{get:c})}
function g(a){return new RegExp(a,"g")}function E(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function L(a,b,c,d,e,f,k,p){if(b[c])return b[c];e=e?(p-(k||p/1.5))*f+(k||p/1.5)*e:f;b[c]=e;e>=k&&(a=a[p-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function P(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],k=a[e];if(k)for(let c=0,d=k.length;c<d;c++)if(k[c]===b){1===d?delete a[e]:k.splice(c,1);break}else B(k[c])&&P(k[c],b)}}}function Q(a){let b=
"",c="";var d="";for(let e=0;e<a.length;e++){const f=a[e];if(f!==c)if(e&&"h"===f){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=f}else b+=f;d=e===a.length-1?"":a[e+1];c=f}return b}function ba(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function aa(a,b){a=a[A];b=b[A];return a<b?-1:a>b?1:0}function Z(a,b){const c=A.length;for(let d=0;d<c;d++)a=a[A[d]],b=b[A[d]];return a<b?-1:a>b?1:0}function R(a,b,c,d){c=[];let e;const f=
a.length;if(1<f){const p=u();let z=a[0],m=z.length,l=0;for(;l<m;)p["@"+z[l++]]=1;let g,q=0,n=0;for(;++n<f;){let h=!1;const r=n===f-1;e=[];z=a[n];m=z.length;for(l=0;l<m;){g=z[l++];var k="@"+g;if(p[k]){const a=p[k];if(a===n){if(r){if(c[q++]=g,b&&q===b)return c}else p[k]=n+1;h=!0}else d&&(k=e[a]||(e[a]=[]),k[k.length]=g)}}if(!h&&!d)break}if(d&&(q=c.length,(n=e.length)&&(!b||q<b)))for(;n--;)if(g=e[n])for(l=0,m=g.length;l<m;l++)if(c[q++]=g[l],b&&q===b)return c}else f&&(c=a[0],b&&c.length>b&&(c=c.slice(0,
b)));return c}function C(a){return"string"===typeof a}function w(a){return a.constructor===Array}function D(a){return"function"===typeof a}function B(a){return"object"===typeof a}function v(a){return"undefined"===typeof a}function S(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}function ca(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold,where:c.where}:c.limit);
self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function da(a,b,c,d){a=x("flexsearch","id"+a,ca,function(a){(a=a.data)&&a.result&&d(a.id,
a.content,a.result,a.limit,a.where,a.cursor,a.suggest)},b);const e=X.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}const t={encode:"icase",f:"forward",u:!1,cache:!1,async:!1,g:!1,F:!1,a:!1,J:!1,c:9,threshold:0,depth:0},T={memory:{encode:"extra",f:"strict",threshold:0,c:1},speed:{encode:"icase",f:"strict",threshold:1,c:3,depth:2},match:{encode:"extra",f:"full",threshold:1,c:3},score:{encode:"extra",f:"strict",threshold:1,c:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,
c:3,depth:3},fast:{encode:"icase",f:"strict",threshold:8,c:9,depth:1}},N=[];let Y=0;const U=/\W+/,V={},W={};h.create=function(a){return new h(a)};h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&N.push(g(b),a[b]);return this};h.registerEncoder=function(a,b){J[a]=b.bind(J);return this};h.registerLanguage=function(a,b){V[a]=b.filter;W[a]=b.stemmer;return this};h.encode=function(a,b){return J[a](b)};h.prototype.init=function(a,b){this.w=[];if(b){var c=b.preset;a=b}else a||(a=t),c=
a.preset;b={};C(a)?(b=T[a],a={}):c&&(b=T[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.m=null;else{var d=parseInt(c,10)||4;this.D=-1;this.v=0;this.o=[];this.G=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=da(this.id,e,a,y.bind(this))}this.f=a.tokenize||b.f||this.f||t.f;this.F=a.rtl||this.F||t.F;this.async="undefined"===typeof Promise||v(c=a.async)?this.async||t.async:c;this.g=v(c=a.worker)?this.g||t.g:c;this.threshold=v(c=a.threshold)?b.threshold||this.threshold||t.threshold:
c;this.c=v(c=a.resolution)?c=b.c||this.c||t.c:c;c<=this.threshold&&(this.c=this.threshold+1);this.depth=v(c=a.depth)?b.depth||this.depth||t.depth:c;this.J=v(c=a.paging)?this.J||t.J:c;this.u=v(c=a.suggest)?this.u||t.u:c;this.A=(c=v(c=a.encode)?b.encode||t.encode:c)&&J[c]&&J[c].bind(J)||(D(c)?c:this.A||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){C(c)&&(c=V[c]);if(w(c)){b=this.A;d=u();for(e=0;e<c.length;e++){var f=b?b(c[e]):c[e];d[f]=1}c=d}this.filter=c}if(c=a.stemmer){var k;b=C(c)?W[c]:c;d=
this.A;e=[];for(k in b)b.hasOwnProperty(k)&&(f=d?d(k):k,e.push(g(f+"($|\\W)"),d?d(b[k]):b[k]));this.stemmer=k=e}this.a=e=(c=a.doc)?c:this.a||t.a;this.i=S(this.c-(this.threshold||0));this.j=u();this.b=u();if(e){this.h=u();a.doc=null;k=e.index={};b=e.keys=[];d=e.field;f=e.tag;w(e.id)||(e.id=e.id.split(":"));if(f){this.H=u();let b=u();if(d)if(C(d))b[d]=a;else if(w(d))for(let c=0;c<d.length;c++)b[d[c]]=a;else B(d)&&(b=d);w(f)||(e.tag=f=[f]);for(d=0;d<f.length;d++)this.H[f[d]]=u();this.K=f;d=b}if(d){let c;
w(d)||(B(d)?(c=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)f=d[e],w(f)||(c&&(a=c[f]),b[e]=f,d[e]=f.split(":")),k[f]=new h(a),k[f].h=this.h}}this.C=!0;this.l=(this.cache=c=v(c=a.cache)?this.cache||t.cache:c)?new ea(c):!1;return this};h.prototype.encode=function(a){a&&N.length&&(a=E(a,N));a&&this.w.length&&(a=E(a,this.w));a&&this.A&&(a=this.A(a));a&&this.stemmer&&(a=E(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.w;for(const c in a)a.hasOwnProperty(c)&&
b.push(g(c),a[c]);return this};h.prototype.add=function(a,b,c,d,e){if(this.a&&B(a))return this.B("add",a,b);if(b&&C(b)&&(a||0===a)){var f="@"+a;if(this.b[f]&&!d)return this.update(a,b);if(this.g)return++this.D>=this.m.length&&(this.D=0),this.m[this.D].postMessage({add:!0,id:a,content:b}),this.b[f]=""+this.D,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;f=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)f.then(c);else return f;
return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;e=D(c)?c(b):b.split(U);this.filter&&(e=I(e,this.filter));const h=u();h._ctx=u();const q=e.length,n=this.threshold,z=this.depth,F=this.c,M=this.i,O=this.F;for(let b=0;b<q;b++){var k=e[b];if(k){var p=k.length,g=(O?b+1:q-b)/q,m="";switch(c){case "reverse":case "both":for(var l=p;--l;)m=k[l]+m,L(M,h,m,a,O?1:(p-l)/p,g,n,F-1);m="";case "forward":for(l=0;l<p;l++)m+=k[l],L(M,h,m,a,O?(l+1)/p:1,g,n,F-
1);break;case "full":for(l=0;l<p;l++){const b=(O?l+1:p-l)/p;for(let c=p;c>l;c--)m=k.substring(l,c),L(M,h,m,a,b,g,n,F-1)}break;default:if(p=L(M,h,k,a,1,g,n,F-1),z&&1<q&&p>=n)for(p=h._ctx[k]||(h._ctx[k]=u()),k=this.j[k]||(this.j[k]=S(F-(n||0))),g=b-z,m=b+z+1,0>g&&(g=0),m>q&&(m=q);g<m;g++)g!==b&&L(k,p,e[g],a,0,F-(g<b?b-g:g-b),n,F-1)}}}this.b[f]=1;this.C=!1}return this};h.prototype.B=function(a,b,c){if(w(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.B(a,b[d],c);this.B(a,b[d])}else{const p=
this.a.index,h=this.a.keys;var d=this.a.tag,e=this.a.id;let l;let r;for(var f=0;f<e.length;f++)l=(l||b)[e[f]];if(d){for(e=0;e<d.length;e++){var k=d[e];var g=k.split(":");for(f=0;f<g.length;f++)r=(r||b)[g[f]];r="@"+r}g=this.H[k];g=g[r]||(g[r]=[])}if("remove"===a){delete this.h[l];for(let a=0,b=h.length;a<b;a++){if(a===b-1)return p[h[a]].remove(l,c);p[h[a]].remove(l)}}e=this.a.field;g&&(g[g.length]=b);for(let f=0,g=e.length;f<g;f++){d=e[f];let m;for(k=0;k<d.length;k++)m=(m||b)[d[k]];this.h[l]=b;d=p[h[f]];
k="add"===a?d.add:d.update;if(f===g-1)return k.call(d,l,m,c);k.call(d,l,m)}}};h.prototype.update=function(a,b,c){if(this.a&&B(a))return this.B("update",a,b);this.b["@"+a]&&C(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&B(a))return this.B("remove",a,b);var d="@"+a;if(this.b[d]){if(this.g)return this.m[this.b[d]].postMessage({remove:!0,id:a}),delete this.b[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,
null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.c-(this.threshold||0);b++)P(this.i[b],a);this.depth&&P(this.j,a);delete this.b[d];this.C=!1}return this};let A;h.prototype.search=function(a,b,c,d){if(B(b)){if(w(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let f=a;let k,g,h=[];if(B(a)&&!w(a)){(c=a.callback||b)&&(f.callback=null);g=a.sort;k=a.where;b=a.limit;var m=a.threshold;a=a.query}if(this.a){m=this.a.index;
var l=f.field;if(l)f.field=null,w(l)||(l=[l]);else if(w(f)){var r=f;l=[];for(var q=0;q<f.length;q++)l[q]=f[q].field}else l=this.a.keys;g&&(f.sort=null);q=l.length;for(var n=0;n<q;n++)r&&(f=r[n]),h[n]=m[l[n]].search(f);if(c)return c(K.call(this,a,h,g,b,k,void 0));if(this.async){const c=this;return new Promise(function(d){Promise.all(h).then(function(e){d(K.call(c,a,e,g,b,k,void 0))})})}return K.call(this,a,h,g,b,k,void 0)}m||(m=this.threshold||0);D(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.g)for(this.G=
c,this.v=0,this.o=[],l=0;l<this.g;l++)this.m[l].postMessage({search:!0,limit:b,cursor:void 0,threshold:m,where:k,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;m=new Promise(function(c){setTimeout(function(){c(a.search(f,b,null,!0));a=null})});if(c)m.then(c);else return m;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!C(a))return h;f=a;if(this.cache)if(this.C){if(c=this.l.get(a))return c}else this.l.clear(),this.C=!0;f=this.encode(f);if(!f.length)return h;
c=this.f;c=D(c)?c(f):f.split(U);this.filter&&(c=I(c,this.filter));r=c.length;d=!0;e=[];var t=u();1<r&&(this.depth?(l=!0,n=c[0],t[n]=1):c.sort(ba));if(!l||(q=this.j)[n]){let a=this.c;for(let b=l?1:0;b<r;b++){const f=c[b];if(f){if(!t[f]){const b=[];let c=!1,g=0;if(n=l?q[n]:this.i){let d;for(let e=0;e<a-m;e++)if(d=n[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!this.u){d=!1;break}t[f]=1}n=f}}}else d=!1;d&&(h=R(e,b,void 0,this.u));this.cache&&!this.a&&this.l.set(a,h);return h}};
h.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};h.prototype.where=function(a,b,c,d){const e=d||this.h,f=[];let g=0;var h;let t;if("number"===typeof a)return[e[a]];if(C(a)){if(v(b))return[e[a]];if("id"===a)return[e[b]];var m=1;var l=[a.split(":")];t=!0}else{if(D(a)){b=d||Object.keys(e);c=b.length;for(h=0;h<c;h++)m=d?d[h]:e[b[h]],a(m)&&(f[g++]=m);return f}c||(c=b);h=Object.keys(a);m=h.length;t=!1;if(1===m&&"id"===h[0])return[e[a.id]];if((l=this.K)&&!d)for(var r=0;r<l.length;r++){var q=
l[r],n=a[q];if(!v(n)){d=this.H[q]["@"+n];if(0===--m)return d;h.splice(h.indexOf(q),1);delete a[q];break}}l=Array(m);for(r=0;r<m;r++)l[r]=h[r].split(":")}r=d||Object.keys(e);q=r.length;for(n=0;n<q;n++){const k=d?d[n]:e[r[n]];let p=!0;for(let c=0;c<m;c++){t||(b=a[h[c]]);const d=l[c],e=d.length;let f=k;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){p=!1;break}}if(p&&(f[g++]=k,c&&g===c))break}return f};h.prototype.info=function(){if(this.g)for(var a=0;a<this.g;a++)this.m[a].postMessage({info:!0,
id:this.id});else{var b=0,c=0,d=0;for(var e=0;e<this.c-(this.threshold||0);e++){a=Object.keys(this.i[e]);for(let g=0;g<a.length;g++){var f=this.i[e][a[g]].length;b+=1*f+2*a[g].length+4;c+=f;d+=2*a[g].length}}a=Object.keys(this.b);f=a.length;for(e=0;e<f;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:N.length+(this.w?this.w.length:0),worker:this.g,threshold:this.threshold,depth:this.depth,contextual:this.depth&&
"strict"===this.f}}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.l.clear(),this.l=null);this.i=this.j=this.b=null;if(this.a){const a=this.a.keys;for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.h=null}return this};h.prototype.export=function(){if(this.a){const a=this.a.keys,b=Array(a.length+1);let c=0;for(;c<a.length;c++){const d=this.a.index[a[c]];b[c]=[d.i,d.j,d.b]}b[c]=this.h;return JSON.stringify(b)}return JSON.stringify([this.i,
this.j,this.b])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.keys,c=b.length;for(let d=0;d<c;d++){const e=this.a.index[b[d]];e.i=a[d][0];e.j=a[d][1];e.b=a[d][2];e.h=a[c]}this.h=a[c]}else this.i=a[0],this.j=a[1],this.b=a[2]};const J={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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("\u00e7"),"c",g("\u00df"),"s",g(" & ")," and ",g("[-/]")," ",g("[^a-z0-9 ]"),"",g("\\s+")," "];return function(b){b=E(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[g("ae"),"a",g("ai"),"ei",g("ay"),"ei",g("ey"),"ei",g("oe"),"o",g("ue"),"u",g("ie"),"i",g("sz"),"s",g("zs"),"s",g("sh"),"s",g("ck"),"k",g("cc"),"k",g("dt"),"t",g("ph"),"f",g("pf"),"f",g("ou"),"o",g("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);
2<b.length&&(b=E(b,a));c||1<b.length&&(b=Q(b));return b}}(),extra:function(){const a=[g("p"),"b",g("z"),"s",g("[cgq]"),"k",g("n"),"m",g("d"),"t",g("[vw]"),"f",g("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+E(d.substring(1),a))}b=b.join(" ");b=Q(b)}return b}}(),balance:function(){const a=[g("[-/]")," ",g("[^a-z0-9 ]"),"",g("\\s+")," "];return function(b){return Q(E(b.toLowerCase(),
a))}}()},ea=function(){function a(a){this.clear();this.I=!0!==a&&a}a.prototype.clear=function(){this.cache=u();this.count=u();this.index=u();this.s=[]};a.prototype.set=function(a,c){if(this.I&&v(this.cache[a])){let b=this.s.length;if(b===this.I){b--;const a=this.s[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.s[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.I&&b){var d=++this.count[a];
const b=this.index;let c=b[a];if(0<c){const f=this.s;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return h}(function(){const x={},G="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(h,y,I,K,H){I=G?URL.createObjectURL(new Blob(["("+I.toString()+")()"],{type:"text/javascript"})):h+".min.js";h+="-"+y;x[h]||(x[h]=[]);x[h][H]=new Worker(I);x[h][H].onmessage=K;return x[h][H]}}()),
this);

View File

@@ -1,34 +1,35 @@
/*
FlexSearch v0.5.1
FlexSearch v0.5.2
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(h,y,D){let e;(e=D.define)&&e.amd?e([],function(){return y}):(e=D.modules)?e[h.toLowerCase()]=y:"object"===typeof exports?module.exports=y:D[h]=y})("FlexSearch",function(){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:S++;this.init(a,b);D(this,"index",function(){return this.c});D(this,"length",function(){return Object.keys(this.c).length})}function y(a,b){a=a.concat.apply([],a);b&&(E(b)||(z=b.split(":"),1<z.length?b=T:(z=z[0],b=U)),a.sort(b));return a}function D(a,
b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function C(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function H(a,b,c,d,f,l,g,k){if(b[c])return b[c];f=f?(k-(g||k/1.5))*l+(g||k/1.5)*f:l;b[c]=f;f>=g&&(a=a[k-(f+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return f}function L(a,b){if(a){const c=Object.keys(a);for(let d=0,f=c.length;d<f;d++){const f=c[d],g=a[f];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===b){1===d?delete a[f]:g.splice(c,1);break}else A(g[c])&&
L(g[c],b)}}}function M(a){let b="",c="";var d="";for(let f=0;f<a.length;f++){const l=a[f];if(l!==c)if(f&&"h"===l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=l}else b+=l;d=f===a.length-1?"":a[f+1];c=l}return b}function V(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function W(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function U(a,b){a=a[z];b=b[z];return a<b?-1:a>b?1:0}function T(a,b){const c=z.length;for(let d=
0;d<c;d++)a=a[z[d]],b=b[z[d]];return a<b?-1:a>b?1:0}function X(a,b,c,d,f){c=[];let l;const g=a.length;if(1<g){a.sort(W);const u=t();let e=a[0],m=e.length,p=0;for(;p<m;)u["@"+e[p++]]=1;let q,w=0,h=0;for(;++h<g;){let n=!1;const B=h===g-1;l=[];e=a[h];m=e.length;for(p=0;p<m;){q=e[p++];var k="@"+q;if(u[k]){const a=u[k];if(a===h){if(B){if(c[w++]=d?d[q]:q,b&&w===b)return c}else u[k]=h+1;n=!0}else f&&(k=l[a]||(l[a]=[]),k[k.length]=q)}}if(!n&&!f)break}if(f&&(w=c.length,(h=l.length)&&(!b||w<b)))for(;h--;)if(q=
l[h])for(p=0,m=q.length;p<m;p++)if(c[w++]=d?d[q[p]]:q[p],b&&w===b)return c}else if(g)if(d)for(a=a[0],f=a.length,b&&b<f&&(f=b),c=Array(f),b=0;b<f;b++)c[b]=d[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function F(a){return"string"===typeof a}function x(a){return a.constructor===Array}function E(a){return"function"===typeof a}function A(a){return"object"===typeof a}function v(a){return"undefined"===typeof a}function N(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=t();return b}function t(){return Object.create(null)}
const r={encode:"icase",f:"forward",u:!1,cache:!1,async:!1,F:!1,w:!1,a:!1,C:!1,b:9,threshold:0,depth:0},O={memory:{encode:"extra",f:"strict",threshold:0,b:1},speed:{encode:"icase",f:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",f:"full",threshold:1,b:3},score:{encode:"extra",f:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",f:"strict",threshold:8,b:9,depth:1}},K=[];let S=0;const P=e("\\W+"),Q={},R={};h.create=function(a){return new h(a)};
h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&K.push(e(b),a[b]);return this};h.registerEncoder=function(a,b){G[a]=b.bind(G);return this};h.registerLanguage=function(a,b){Q[a]=b.filter;R[a]=b.stemmer;return this};h.encode=function(a,b){return G[a](b)};h.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;a=b}else a||(a=r),c=a.preset;b={};F(a)?(b=O[a],a={}):c&&(b=O[c]);this.f=a.tokenize||b.f||this.f||r.f;this.w=a.rtl||this.w||r.w;this.async="undefined"===typeof Promise||
v(c=a.async)?this.async||r.async:c;this.threshold=v(c=a.threshold)?b.threshold||this.threshold||r.threshold:c;this.b=v(c=a.resolution)?c=b.b||this.b||r.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth=v(c=a.depth)?b.depth||this.depth||r.depth:c;this.C=v(c=a.paging)?this.C||r.C:c;this.u=v(c=a.suggest)?this.u||r.u:c;this.o=(c=v(c=a.encode)?b.encode||r.encode:c)&&G[c]&&G[c].bind(G)||(E(c)?c:this.o||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=Q[c]||c;b=this.o;var d=t();if(c)for(var f=
0;f<c.length;f++){var l=b?b(c[f]):c[f];d[l]=String.fromCharCode(65E3-c.length+f)}this.filter=c=d}if(c=a.stemmer){var g;b=R[c]||c;d=this.o;f=[];if(b)for(g in b)b.hasOwnProperty(g)&&(l=d?d(g):g,f.push(e("(?=.{"+(l.length+3)+",})"+l+"$"),d?d(b[g]):b[g]));this.stemmer=g=f}this.a=d=(c=a.doc)?c:this.a||r.a;this.h=N(this.b-(this.threshold||0));this.i=t();this.c=t();if(d){this.g=t();a.doc=null;g=d.index=[];b=d.ref={};f=d.field;l=d.tag;x(d.id)||(d.id=d.id.split(":"));if(l){this.A=t();let b=t();if(f)if(F(f))b[f]=
a;else if(x(f))for(let c=0;c<f.length;c++)b[f[c]]=a;else A(f)&&(b=f);x(l)||(d.tag=l=[l]);for(f=0;f<l.length;f++)this.A[l[f]]=t();this.D=l;f=b}if(f){let c;x(f)||(A(f)?(c=f,d.field=f=Object.keys(f)):d.field=f=[f]);for(d=0;d<f.length;d++)x(f[d])||(c&&(a=c[f[d]]),b[f[d]]=d,f[d]=f[d].split(":")),g[d]=new h(a),g[d].g=this.g}}this.v=!0;this.l=(this.cache=c=v(c=a.cache)?this.cache||r.cache:c)?new Y(c):!1;return this};h.prototype.encode=function(a){a&&K.length&&(a=C(a,K));a&&this.m.length&&(a=C(a,this.m));
a&&this.o&&(a=this.o(a));a&&this.stemmer&&(a=C(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};h.prototype.add=function(a,b,c,d,f){if(this.a&&A(a))return this.s("add",a,b);if(b&&F(b)&&(a||0===a)){var l="@"+a;if(this.c[l]&&!d)return this.update(a,b);if(!f){if(this.async&&"function"!==typeof importScripts){let f=this;l=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)l.then(c);
else return l;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;f=E(c)?c(b):b.split(P);const p=t();p._ctx=t();const q=this.threshold,h=this.depth,u=this.b,I=this.h,B=f.length,J=this.w;for(let b=0;b<B;b++){var g=f[b];if(g){var k=g.length,e=(J?b+1:B-b)/B,n="";switch(c){case "reverse":case "both":for(var m=k;--m;)n=g[m]+n,H(I,p,n,a,J?1:(k-m)/k,e,q,u-1);n="";case "forward":for(m=0;m<k;m++)n+=g[m],H(I,p,n,a,J?(m+1)/k:1,e,q,u-1);break;case "full":for(m=
0;m<k;m++){const b=(J?m+1:k-m)/k;for(let c=k;c>m;c--)n=g.substring(m,c),H(I,p,n,a,b,e,q,u-1)}break;default:if(k=H(I,p,g,a,1,e,q,u-1),h&&1<B&&k>=q)for(k=p._ctx[g]||(p._ctx[g]=t()),g=this.i[g]||(this.i[g]=N(u-(q||0))),e=b-h,n=b+h+1,0>e&&(e=0),n>B&&(n=B);e<n;e++)e!==b&&H(g,k,f[e],a,0,u-(e<b?b-e:e-b),q,u-1)}}}this.c[l]=1;this.v=!1}return this};h.prototype.s=function(a,b,c){if(x(b))for(let d=0,f=b.length;d<f;d++){if(d===f-1)return this.s(a,b[d],c);this.s(a,b[d])}else{const k=this.a.index;var d=this.a.tag,
f=this.a.id;let n;let m;for(var l=0;l<f.length;l++)n=(n||b)[f[l]];if(d){for(f=0;f<d.length;f++){var g=d[f];var e=g.split(":");for(l=0;l<e.length;l++)m=(m||b)[e[l]];m="@"+m}e=this.A[g];e=e[m]||(e[m]=[])}if("remove"===a){delete this.g[n];for(let a=0,b=k.length;a<b;a++){if(a===b-1)return k[a].remove(n,c);k[a].remove(n)}}f=this.a.field;e&&(e[e.length]=b);for(let e=0,l=f.length;e<l;e++){d=f[e];let m;for(g=0;g<d.length;g++)m=(m||b)[d[g]];this.g[n]=b;d=k[e];g="add"===a?d.add:d.update;if(e===l-1)return g.call(d,
n,m,c);g.call(d,n,m)}}};h.prototype.update=function(a,b,c){if(this.a&&A(a))return this.s("update",a,b);this.c["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&A(a))return this.s("remove",a,b);var d="@"+a;if(this.c[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,
!0),b(),this}for(b=0;b<this.b-(this.threshold||0);b++)L(this.h[b],a);this.depth&&L(this.i,a);delete this.c[d];this.v=!1}return this};let z;h.prototype.search=function(a,b,c,d){if(A(b)){if(x(b))for(var f=0;f<b.length;f++)b[f].query=a;else b.query=a;a=b;b=0}let e=a;let g,k=[];if(A(a)&&!x(a)){(c=a.callback||b)&&(e.callback=null);var h=a.where;g=a.sort;b=a.limit;var n=a.threshold;a=a.query}if(this.a){a=this.a.ref;n=this.a.index;if(h=e.field)e.field=null;else if(x(e)){var m=e;h=[];for(var p=0;p<e.length;p++)h[p]=
e[p].field}else h=Object.keys(a);if(A(h)){g&&(e.sort=null);x(h)||(h=[h]);p=h.length;for(var q=0;q<p;q++)m&&(e=m[q]),k[q]=n[a[h[q]]].search(e);return c?c(y(k,g)):this.async?new Promise(function(a){Promise.all(k).then(function(b){a(y(b,g))})}):y(k,g)}return n[a[h]].search(e,c)}n||(n=this.threshold||0);E(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(e,b,null,!0));d=null})});if(c)a.then(c);
else return a;return this}if(c)return c(this.search(e,b,null,!0)),this}if(!a||!F(a))return k;e=a;if(this.cache)if(this.v){if(c=this.l.get(a))return c}else this.l.clear(),this.v=!0;e=this.encode(e);if(!e.length)return k;c=this.f;c=E(c)?c(e):e.split(P);m=c.length;d=!0;f=[];const w=t();if(1<m)if(this.depth){p=!0;var r=c[0];w[r]=1}else c.sort(V);if(!p||(q=this.i)[r]){let a=this.b;for(let b=p?1:0;b<m;b++){const e=c[b];if(e){if(!w[e]){const b=[];let c=!1,g=0;if(r=p?q[r]:this.h){let d;for(let f=0;f<a-n;f++)if(d=
r[f][e])b[g++]=d,c=!0}if(c)f[f.length]=1<g?b.concat.apply([],b):b[0];else if(!this.u){d=!1;break}w[e]=1}r=e}}}else d=!1;d&&(k=X(f,b,void 0,this.g,this.u));h&&(k=this.where(h,null,b,k));g&&(k=y([k],g));this.cache&&this.l.set(a,k);return k};h.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};h.prototype.where=function(a,b,c,d){const f=d||this.g,e=[];let g=0;var k;let h;if("number"===typeof a)return[f[a]];if(F(a)){if(v(b))return[f[a]];if("id"===a)return[f[b]];var n=1;var m=[a.split(":")];
h=!0}else{if(E(a)){b=d||Object.keys(f);c=b.length;for(k=0;k<c;k++)n=d?d[k]:f[b[k]],a(n)&&(e[g++]=n);return e}c||(c=b);k=Object.keys(a);n=k.length;h=!1;if(1===n&&"id"===k[0])return[f[a.id]];if((m=this.D)&&!d)for(var p=0;p<m.length;p++){var q=m[p],r=a[q];if(!v(r)){d=this.A[q]["@"+r];if(0===--n)return d;k.splice(k.indexOf(q),1);delete a[q];break}}m=Array(n);for(p=0;p<n;p++)m[p]=k[p].split(":")}p=d||Object.keys(f);q=p.length;for(r=0;r<q;r++){const l=d?d[r]:f[p[r]];let q=!0;for(let c=0;c<n;c++){h||(b=
a[k[c]]);const d=m[c],f=d.length;let e=l;if(1<f)for(let a=0;a<f;a++)e=e[d[a]];else e=e[d[0]];if(e!==b){q=!1;break}}if(q&&(e[g++]=l,c&&g===c))break}return e};h.prototype.info=function(){let a;let b=0,c=0,d=0;for(var f=0;f<this.b-(this.threshold||0);f++){a=Object.keys(this.h[f]);for(let g=0;g<a.length;g++){var e=this.h[f][a[g]].length;b+=1*e+2*a[g].length+4;c+=e;d+=2*a[g].length}}a=Object.keys(this.c);e=a.length;for(f=0;f<e;f++)b+=2*a[f].length+2;return{id:this.id,memory:b,items:e,sequences:c,chars:d,
cache:this.cache&&this.cache.j?this.cache.j.length:!1,matcher:K.length+(this.m?this.m.length:0),worker:this.F,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.f}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.l.clear(),this.l=null);this.h=this.i=this.c=null;if(this.a){const a=this.g.index;for(let b=0;b<a.length;b++)a.destroy();this.g=null}return this};h.prototype.export=function(){if(this.a){const a=this.a.index,
b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].h,a[c].i,a[c].c];b[c]=this.g;return JSON.stringify(b)}return JSON.stringify([this.h,this.i,this.c])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const f=b[d];f.h=a[d][0];f.i=a[d][1];f.c=a[d][2];f.g=a[c]}this.g=a[c]}else this.h=a[0],this.i=a[1],this.c=a[2],this.g=a[3]};const G={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=C(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",
e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=C(b,a));c||1<b.length&&(b=M(b));return b}}(),extra:function(){const a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+C(d.substring(1),
a))}b=b.join(" ");b=M(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return M(C(b.toLowerCase(),a))}}()},Y=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache=t();this.count=t();this.index=t();this.j=[]};a.prototype.set=function(a,c){if(this.B&&v(this.cache[a])){let b=this.j.length;if(b===this.B){b--;const a=this.j[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=
b;this.j[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.B&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const e=this.j;for(var f=c;this.count[e[--c]]<=d&&-1!==c;);c++;if(c!==f){for(d=f;d>c;d--)f=e[d-1],e[d]=f,b[f]=d;e[c]=a;b[a]=c}}}return b};return a}();return h}(!1),this);
'use strict';(function(h,C,D){let z;(z=D.define)&&z.amd?z([],function(){return C}):(z=D.modules)?z[h.toLowerCase()]=C:"object"===typeof exports?module.exports=C:D[h]=C})("FlexSearch",function(){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:T++;this.init(a,b);z(this,"index",function(){return this.c});z(this,"length",function(){return Object.keys(this.c).length})}function C(a,b){const c=a.length,d=E(b),e=[];for(let f=0,k=0;f<c;f++){const c=a[f];if(d&&b(c)||!d&&!b[c])e[k++]=c}return e}function D(a,
b,c,d,e,f){const k=this.g;b=N(b,e?0:d,f,this.m);{f=b.length;const a=Array(f);for(let c=0;c<f;c++)a[c]=k[b[c]];b=a}e&&(b=this.where(e,null,d,b));c&&(E(c)||(y=c.split(":"),1<y.length?c=U:(y=y[0],c=V)),b.sort(c));this.cache&&this.j.set(a,b);return b}function z(a,b,c){Object.defineProperty(a,b,{get:c})}function g(a){return new RegExp(a,"g")}function F(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function H(a,b,c,d,e,f,k,p){if(b[c])return b[c];e=e?(p-(k||p/1.5))*f+(k||p/1.5)*e:f;
b[c]=e;e>=k&&(a=a[p-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function L(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],k=a[e];if(k)for(let c=0,d=k.length;c<d;c++)if(k[c]===b){1===d?delete a[e]:k.splice(c,1);break}else A(k[c])&&L(k[c],b)}}}function M(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const f=a[e];if(f!==c)if(e&&"h"===f){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||
" "===c)b+=f}else b+=f;d=e===a.length-1?"":a[e+1];c=f}return b}function W(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function V(a,b){a=a[y];b=b[y];return a<b?-1:a>b?1:0}function U(a,b){const c=y.length;for(let d=0;d<c;d++)a=a[y[d]],b=b[y[d]];return a<b?-1:a>b?1:0}function N(a,b,c,d){c=[];let e;const f=a.length;if(1<f){const p=t();let x=a[0],m=x.length,l=0;for(;l<m;)p["@"+x[l++]]=1;let g,q=0,n=0;for(;++n<f;){let r=!1;const h=n===f-1;e=[];x=a[n];m=x.length;for(l=0;l<m;){g=x[l++];var k="@"+g;if(p[k]){const a=
p[k];if(a===n){if(h){if(c[q++]=g,b&&q===b)return c}else p[k]=n+1;r=!0}else d&&(k=e[a]||(e[a]=[]),k[k.length]=g)}}if(!r&&!d)break}if(d&&(q=c.length,(n=e.length)&&(!b||q<b)))for(;n--;)if(g=e[n])for(l=0,m=g.length;l<m;l++)if(c[q++]=g[l],b&&q===b)return c}else f&&(c=a[0],b&&c.length>b&&(c=c.slice(0,b)));return c}function B(a){return"string"===typeof a}function v(a){return a.constructor===Array}function E(a){return"function"===typeof a}function A(a){return"object"===typeof a}function w(a){return"undefined"===
typeof a}function O(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=t();return b}function t(){return Object.create(null)}const u={encode:"icase",f:"forward",m:!1,cache:!1,async:!1,F:!1,w:!1,a:!1,C:!1,b:9,threshold:0,depth:0},P={memory:{encode:"extra",f:"strict",threshold:0,b:1},speed:{encode:"icase",f:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",f:"full",threshold:1,b:3},score:{encode:"extra",f:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,b:3,depth:3},
fast:{encode:"icase",f:"strict",threshold:8,b:9,depth:1}},J=[];let T=0;const Q=/\W+/,R={},S={};h.create=function(a){return new h(a)};h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&J.push(g(b),a[b]);return this};h.registerEncoder=function(a,b){G[a]=b.bind(G);return this};h.registerLanguage=function(a,b){R[a]=b.filter;S[a]=b.stemmer;return this};h.encode=function(a,b){return G[a](b)};h.prototype.init=function(a,b){this.o=[];if(b){var c=b.preset;a=b}else a||(a=u),c=a.preset;b={};
B(a)?(b=P[a],a={}):c&&(b=P[c]);this.f=a.tokenize||b.f||this.f||u.f;this.w=a.rtl||this.w||u.w;this.async="undefined"===typeof Promise||w(c=a.async)?this.async||u.async:c;this.threshold=w(c=a.threshold)?b.threshold||this.threshold||u.threshold:c;this.b=w(c=a.resolution)?c=b.b||this.b||u.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth=w(c=a.depth)?b.depth||this.depth||u.depth:c;this.C=w(c=a.paging)?this.C||u.C:c;this.m=w(c=a.suggest)?this.m||u.m:c;this.s=(c=w(c=a.encode)?b.encode||u.encode:
c)&&G[c]&&G[c].bind(G)||(E(c)?c:this.s||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){B(c)&&(c=R[c]);if(v(c)){b=this.s;var d=t();for(var e=0;e<c.length;e++){var f=b?b(c[e]):c[e];d[f]=1}c=d}this.filter=c}if(c=a.stemmer){var k;b=B(c)?S[c]:c;d=this.s;e=[];for(k in b)b.hasOwnProperty(k)&&(f=d?d(k):k,e.push(g(f+"($|\\W)"),d?d(b[k]):b[k]));this.stemmer=k=e}this.a=e=(c=a.doc)?c:this.a||u.a;this.h=O(this.b-(this.threshold||0));this.i=t();this.c=t();if(e){this.g=t();a.doc=null;k=e.index={};b=e.keys=
[];d=e.field;f=e.tag;v(e.id)||(e.id=e.id.split(":"));if(f){this.A=t();let b=t();if(d)if(B(d))b[d]=a;else if(v(d))for(let c=0;c<d.length;c++)b[d[c]]=a;else A(d)&&(b=d);v(f)||(e.tag=f=[f]);for(d=0;d<f.length;d++)this.A[f[d]]=t();this.D=f;d=b}if(d){let c;v(d)||(A(d)?(c=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)f=d[e],v(f)||(c&&(a=c[f]),b[e]=f,d[e]=f.split(":")),k[f]=new h(a),k[f].g=this.g}}this.v=!0;this.j=(this.cache=c=w(c=a.cache)?this.cache||u.cache:c)?new X(c):!1;return this};
h.prototype.encode=function(a){a&&J.length&&(a=F(a,J));a&&this.o.length&&(a=F(a,this.o));a&&this.s&&(a=this.s(a));a&&this.stemmer&&(a=F(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.o;for(const c in a)a.hasOwnProperty(c)&&b.push(g(c),a[c]);return this};h.prototype.add=function(a,b,c,d,e){if(this.a&&A(a))return this.u("add",a,b);if(b&&B(b)&&(a||0===a)){var f="@"+a;if(this.c[f]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;
f=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)f.then(c);else return f;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;e=E(c)?c(b):b.split(Q);this.filter&&(e=C(e,this.filter));const r=t();r._ctx=t();const q=e.length,n=this.threshold,x=this.depth,h=this.b,I=this.h,K=this.w;for(let b=0;b<q;b++){var k=e[b];if(k){var p=k.length,g=(K?b+1:q-b)/q,m="";switch(c){case "reverse":case "both":for(var l=p;--l;)m=
k[l]+m,H(I,r,m,a,K?1:(p-l)/p,g,n,h-1);m="";case "forward":for(l=0;l<p;l++)m+=k[l],H(I,r,m,a,K?(l+1)/p:1,g,n,h-1);break;case "full":for(l=0;l<p;l++){const b=(K?l+1:p-l)/p;for(let c=p;c>l;c--)m=k.substring(l,c),H(I,r,m,a,b,g,n,h-1)}break;default:if(p=H(I,r,k,a,1,g,n,h-1),x&&1<q&&p>=n)for(p=r._ctx[k]||(r._ctx[k]=t()),k=this.i[k]||(this.i[k]=O(h-(n||0))),g=b-x,m=b+x+1,0>g&&(g=0),m>q&&(m=q);g<m;g++)g!==b&&H(k,p,e[g],a,0,h-(g<b?b-g:g-b),n,h-1)}}}this.c[f]=1;this.v=!1}return this};h.prototype.u=function(a,
b,c){if(v(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.u(a,b[d],c);this.u(a,b[d])}else{const p=this.a.index,m=this.a.keys;var d=this.a.tag,e=this.a.id;let l;let h;for(var f=0;f<e.length;f++)l=(l||b)[e[f]];if(d){for(e=0;e<d.length;e++){var k=d[e];var g=k.split(":");for(f=0;f<g.length;f++)h=(h||b)[g[f]];h="@"+h}g=this.A[k];g=g[h]||(g[h]=[])}if("remove"===a){delete this.g[l];for(let b=0,a=m.length;b<a;b++){if(b===a-1)return p[m[b]].remove(l,c);p[m[b]].remove(l)}}e=this.a.field;g&&(g[g.length]=
b);for(let f=0,g=e.length;f<g;f++){d=e[f];let h;for(k=0;k<d.length;k++)h=(h||b)[d[k]];this.g[l]=b;d=p[m[f]];k="add"===a?d.add:d.update;if(f===g-1)return k.call(d,l,h,c);k.call(d,l,h)}}};h.prototype.update=function(a,b,c){if(this.a&&A(a))return this.u("update",a,b);this.c["@"+a]&&B(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&A(a))return this.u("remove",a,b);var d="@"+a;if(this.c[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=
this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.b-(this.threshold||0);b++)L(this.h[b],a);this.depth&&L(this.i,a);delete this.c[d];this.v=!1}return this};let y;h.prototype.search=function(a,b,c,d){if(A(b)){if(v(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let f=a;let k,g,h=[];if(A(a)&&!v(a)){(c=a.callback||b)&&(f.callback=null);g=a.sort;k=
a.where;b=a.limit;var m=a.threshold;a=a.query}if(this.a){m=this.a.index;var l=f.field;if(l)f.field=null,v(l)||(l=[l]);else if(v(f)){var r=f;l=[];for(var q=0;q<f.length;q++)l[q]=f[q].field}else l=this.a.keys;g&&(f.sort=null);q=l.length;for(var n=0;n<q;n++)r&&(f=r[n]),h[n]=m[l[n]].search(f);if(c)return c(D.call(this,a,h,g,b,k,void 0));if(this.async){const c=this;return new Promise(function(d){Promise.all(h).then(function(e){d(D.call(c,a,e,g,b,k,void 0))})})}return D.call(this,a,h,g,b,k,void 0)}m||(m=
this.threshold||0);E(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;m=new Promise(function(c){setTimeout(function(){c(a.search(f,b,null,!0));a=null})});if(c)m.then(c);else return m;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!B(a))return h;f=a;if(this.cache)if(this.v){if(c=this.j.get(a))return c}else this.j.clear(),this.v=!0;f=this.encode(f);if(!f.length)return h;c=this.f;c=E(c)?c(f):f.split(Q);this.filter&&(c=C(c,this.filter));
r=c.length;d=!0;e=[];const u=t();1<r&&(this.depth?(l=!0,n=c[0],u[n]=1):c.sort(W));if(!l||(q=this.i)[n]){let b=this.b;for(let a=l?1:0;a<r;a++){const f=c[a];if(f){if(!u[f]){const a=[];let c=!1,g=0;if(n=l?q[n]:this.h){let d;for(let e=0;e<b-m;e++)if(d=n[e][f])a[g++]=d,c=!0}if(c)e[e.length]=1<g?a.concat.apply([],a):a[0];else if(!this.m){d=!1;break}u[f]=1}n=f}}}else d=!1;d&&(h=N(e,b,void 0,this.m));this.cache&&!this.a&&this.j.set(a,h);return h};h.prototype.find=function(a,b){return this.where(a,b,1)[0]||
null};h.prototype.where=function(a,b,c,d){const e=d||this.g,f=[];let g=0;var h;let t;if("number"===typeof a)return[e[a]];if(B(a)){if(w(b))return[e[a]];if("id"===a)return[e[b]];var m=1;var l=[a.split(":")];t=!0}else{if(E(a)){b=d||Object.keys(e);c=b.length;for(h=0;h<c;h++)m=d?d[h]:e[b[h]],a(m)&&(f[g++]=m);return f}c||(c=b);h=Object.keys(a);m=h.length;t=!1;if(1===m&&"id"===h[0])return[e[a.id]];if((l=this.D)&&!d)for(var r=0;r<l.length;r++){var q=l[r],n=a[q];if(!w(n)){d=this.A[q]["@"+n];if(0===--m)return d;
h.splice(h.indexOf(q),1);delete a[q];break}}l=Array(m);for(r=0;r<m;r++)l[r]=h[r].split(":")}r=d||Object.keys(e);q=r.length;for(n=0;n<q;n++){const k=d?d[n]:e[r[n]];let p=!0;for(let c=0;c<m;c++){t||(b=a[h[c]]);const d=l[c],e=d.length;let f=k;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){p=!1;break}}if(p&&(f[g++]=k,c&&g===c))break}return f};h.prototype.info=function(){let a;let b=0,c=0,d=0;for(var e=0;e<this.b-(this.threshold||0);e++){a=Object.keys(this.h[e]);for(let g=0;g<a.length;g++){var f=
this.h[e][a[g]].length;b+=1*f+2*a[g].length+4;c+=f;d+=2*a[g].length}}a=Object.keys(this.c);f=a.length;for(e=0;e<f;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:J.length+(this.o?this.o.length:0),worker:this.F,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.f}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.j.clear(),
this.j=null);this.h=this.i=this.c=null;if(this.a){const a=this.a.keys;for(let b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.g=null}return this};h.prototype.export=function(){if(this.a){const a=this.a.keys,b=Array(a.length+1);let c=0;for(;c<a.length;c++){const d=this.a.index[a[c]];b[c]=[d.h,d.i,d.c]}b[c]=this.g;return JSON.stringify(b)}return JSON.stringify([this.h,this.i,this.c])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.keys,c=b.length;for(let d=0;d<
c;d++){const e=this.a.index[b[d]];e.h=a[d][0];e.i=a[d][1];e.c=a[d][2];e.g=a[c]}this.g=a[c]}else this.h=a[0],this.i=a[1],this.c=a[2]};const G={icase:function(a){return a.toLowerCase()},simple:function(){const a=[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("\u00e7"),"c",g("\u00df"),"s",g(" & "),
" and ",g("[-/]")," ",g("[^a-z0-9 ]"),"",g("\\s+")," "];return function(b){b=F(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[g("ae"),"a",g("ai"),"ei",g("ay"),"ei",g("ey"),"ei",g("oe"),"o",g("ue"),"u",g("ie"),"i",g("sz"),"s",g("zs"),"s",g("sh"),"s",g("ck"),"k",g("cc"),"k",g("dt"),"t",g("ph"),"f",g("pf"),"f",g("ou"),"o",g("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=F(b,a));c||1<b.length&&(b=M(b));return b}}(),extra:function(){const a=[g("p"),
"b",g("z"),"s",g("[cgq]"),"k",g("n"),"m",g("d"),"t",g("[vw]"),"f",g("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+F(d.substring(1),a))}b=b.join(" ");b=M(b)}return b}}(),balance:function(){const a=[g("[-/]")," ",g("[^a-z0-9 ]"),"",g("\\s+")," "];return function(b){return M(F(b.toLowerCase(),a))}}()},X=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache=
t();this.count=t();this.index=t();this.l=[]};a.prototype.set=function(a,c){if(this.B&&w(this.cache[a])){let b=this.l.length;if(b===this.B){b--;const a=this.l[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.l[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.B&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.l;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);
c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return h}(!1),this);

View File

@@ -1,5 +1,5 @@
/**!
* @preserve FlexSearch v0.5.1
* @preserve FlexSearch v0.5.2
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Released under the Apache 2.0 Licence
@@ -129,7 +129,7 @@
* @const {RegExp}
*/
const regex_split = regex("\\W+"); // regex("[\\s/-_]");
const regex_split = /\W+/; //regex("\\W+"); // regex("[\\s/-_]");
const filter = {};
const stemmer = {};
@@ -262,7 +262,7 @@
return global_encoder[name](value);
};
function worker_handler(id, query, result, limit){
function worker_handler(id, query, result, limit, where, cursor, suggest){
if(this._task_completed !== this.worker){
@@ -276,15 +276,22 @@
this._task_completed = this.worker;
}
if(this._current_callback && (this._task_completed === this.worker)){
if(this._task_completed === this.worker){
// this._task_result = intersect(this._task_result, where ? 0 : limit, cursor, suggest);
if(this.cache){
this._cache.set(query, this._task_result);
}
this._current_callback(this._task_result);
this._task_result = [];
if(this._current_callback){
this._current_callback(this._task_result);
}
//this._task_completed = 0;
//this._task_result = [];
}
}
@@ -525,14 +532,28 @@
if((custom = options["filter"])) {
if(is_string(custom)){
custom = filter[custom];
}
if(is_array(custom)){
custom = init_filter(custom, this.encoder);
}
/** @private */
this.filter = init_filter(filter[custom] || custom, this.encoder);
this.filter = custom;
}
if((custom = options["stemmer"])) {
/** @private */
this.stemmer = init_stemmer(stemmer[custom] || custom, this.encoder);
this.stemmer = init_stemmer(
is_string(custom) ? stemmer[custom] : custom,
this.encoder
);
}
let doc;
@@ -565,8 +586,8 @@
options["doc"] = null;
const index = doc["index"] = [];
const ref = doc["ref"] = {};
const index = doc["index"] = {};
const keys = doc["keys"] = [];
let field = doc["field"];
let tag = doc["tag"];
@@ -638,21 +659,23 @@
for(let i = 0; i < field.length; i++){
if(!is_array(field[i])){
const ref = field[i];
if(!is_array(ref)){
if(has_custom){
options = has_custom[field[i]];
options = has_custom[ref];
}
ref[field[i]] = i;
field[i] = field[i].split(":");
keys[i] = ref;
field[i] = ref.split(":");
}
// TODO: move fields to main index to provide pagination
index[i] = new FlexSearch(options);
index[i]._doc = this._doc;
index[ref] = new FlexSearch(options);
index[ref]._doc = this._doc;
// if(SUPPORT_WHERE && tag){
//
@@ -725,35 +748,6 @@
value = this.encoder(value);
}
// TODO completely filter out words actually can break the context chain
/*
if(value && this.filter){
const words = value.split(" ");
//const final = "";
for(const i = 0; i < words.length; i++){
const word = words[i];
const filter = this.filter[word];
if(filter){
//const length = word.length - 1;
words[i] = filter;
//words[i] = word[0] + (length ? word[1] : "");
//words[i] = "~" + word[0];
//words.splice(i, 1);
//i--;
//final += (final ? " " : "") + word;
}
}
value = words.join(" "); // final;
}
*/
if(value && this.stemmer){
value = replace(value, this.stemmer);
@@ -787,6 +781,26 @@
return this;
};
function filter_words(words, filter){
const length = words.length;
const has_function = is_function(filter);
const filtered = [];
for(let i = 0, count = 0; i < length; i++){
const word = words[i];
if((has_function && filter(word)) ||
(!has_function && !filter[word])){
filtered[count++] = word;
}
}
return filtered;
}
/**
* @param {number|string} id
* @param {string|Function} content
@@ -898,7 +912,7 @@
const tokenizer = this.tokenize;
const words = (
let words = (
is_function(tokenizer) ?
@@ -914,14 +928,19 @@
)
);
if(this.filter){
words = filter_words(words, this.filter);
}
const dupes = create_object();
dupes["_ctx"] = create_object();
const word_length = words.length;
const threshold = this.threshold;
const depth = this.depth;
const resolution = this.resolution;
const map = this._map;
const word_length = words.length;
const rtl = this.rtl;
// tokenize
@@ -1109,6 +1128,7 @@
else{
const index = this.doc["index"];
const keys = this.doc["keys"];
const tags = this.doc["tag"];
let tree = this.doc["id"];
let id;
@@ -1145,15 +1165,15 @@
delete this._doc[id];
for(let z = 0, length = index.length; z < length; z++){
for(let z = 0, length = keys.length; z < length; z++){
if(z === length - 1){
return index[z].remove(id, callback);
return index[keys[z]].remove(id, callback);
}
else{
index[z].remove(id);
index[keys[z]].remove(id);
}
}
}
@@ -1177,7 +1197,7 @@
this._doc[id] = doc;
const self = index[i];
const self = index[keys[i]];
let fn;
@@ -1348,11 +1368,31 @@
let field_to_sort;
// TODO: apply intersect here
function enrich_documents(arr, docs){
function merge_and_sort(arrays, sort){
const length = arr.length;
const result = new Array(length);
arrays = arrays.concat.apply([], arrays);
for(let i = 0; i < length; i++){
result[i] = docs[arr[i]];
}
return result;
}
function merge_and_sort(query, result, sort, limit, where, cursor){
const doc = this._doc;
const suggest = SUPPORT_SUGGESTIONS && this.suggest;
result = intersect(result, where ? 0 : limit, cursor, suggest);
result = enrich_documents(result, doc);
if(where){
result = this.where(where, null, limit, result);
}
if(sort){
@@ -1371,10 +1411,15 @@
}
}
arrays.sort(sort);
result.sort(sort);
}
return arrays;
if(SUPPORT_CACHE && this.cache){
this._cache.set(query, result);
}
return result;
}
/**
@@ -1433,8 +1478,12 @@
if(SUPPORT_DOCUMENTS){
//boost = query["boost"];
where = query["where"];
sort = query["sort"];
if(SUPPORT_WHERE){
where = query["where"];
}
}
//cursor = this.paging && query["cursor"];
@@ -1445,7 +1494,6 @@
if(SUPPORT_DOCUMENTS && this.doc){
const doc_ref = this.doc["ref"];
const doc_idx = this.doc["index"];
let queries;
@@ -1454,6 +1502,11 @@
if(field){
_query["field"] = null;
if(!is_array(field)){
field = [field];
}
}
else if(is_array(_query)){
@@ -1467,60 +1520,45 @@
}
else{
field = get_keys(doc_ref);
field = this.doc["keys"];
}
if(is_object(field)){
if(sort){
if(sort){
_query["sort"] = null;
}
_query["sort"] = null;
const len = field.length;
for(let i = 0; i < len; i++){
if(queries){
_query = queries[i];
}
if(!is_array(field)){
result[i] = doc_idx[field[i]].search(_query);
}
field = [field];
}
if(callback){
const len = field.length;
return callback(merge_and_sort.call(this, query, result, sort, limit, where, cursor));
}
else if(SUPPORT_ASYNC && this.async){
for(let i = 0; i < len; i++){
const self = this;
if(queries){
return new Promise(function(resolve){
_query = queries[i];
}
Promise.all(/** @type {!Iterable<Promise>} */ (result)).then(function(values){
const ref = doc_ref[field[i]];
// TODO: Support Field-Merging (return array before intersection and apply here)
result[i] = doc_idx[ref].search(_query);
}
if(SUPPORT_ASYNC && callback){
return callback(merge_and_sort(result, sort));
}
else if(SUPPORT_ASYNC && this.async){
return new Promise(function(resolve){
Promise.all(/** @type {!Iterable<Promise>} */ (result)).then(function(values){
resolve(merge_and_sort(values, sort));
});
resolve(merge_and_sort.call(self, query, values, sort, limit, where, cursor));
});
}
else{
return merge_and_sort(result, sort);
}
});
}
else{
const ref = doc_ref[field];
return doc_idx[ref].search(_query, callback);
return merge_and_sort.call(this, query, result, sort, limit, where, cursor);
}
}
@@ -1548,8 +1586,9 @@
"search": true,
"limit": limit,
//"cursor": cursor,
"cursor": cursor,
"threshold": threshold,
"where": where,
"content": query
});
}
@@ -1641,7 +1680,7 @@
const tokenizer = this.tokenize;
const words = (
let words = (
is_function(tokenizer) ?
@@ -1658,6 +1697,11 @@
)
);
if(this.filter){
words = filter_words(words, this.filter);
}
const length = words.length;
let found = true;
const check = [];
@@ -1793,26 +1837,16 @@
// Not handled by intersection:
result = intersect(check, limit, cursor, SUPPORT_DOCUMENTS && this._doc, SUPPORT_SUGGESTIONS && this.suggest);
result = intersect(check, limit, cursor, /*SUPPORT_DOCUMENTS && this._doc,*/ SUPPORT_SUGGESTIONS && this.suggest);
// Handled by intersection:
//result = intersect_3d(check, limit, this.suggest);
}
if(SUPPORT_WHERE && where){
result = this.where(where, null, limit, result);
}
if(SUPPORT_DOCUMENTS && sort){
result = merge_and_sort([result], sort);
}
// store result to cache
if(SUPPORT_CACHE && this.cache){
if(SUPPORT_CACHE && this.cache && (!SUPPORT_DOCUMENTS || !this.doc)){
this._cache.set(query, result);
}
@@ -2092,13 +2126,14 @@
if(SUPPORT_DOCUMENTS && this.doc){
const index = this._doc["index"];
const keys = this.doc["keys"];
for(let i = 0; i < index.length; i++){
for(let i = 0; i < keys.length; i++){
index.destroy();
this.doc.index[keys[i]].destroy();
}
this.doc =
this._doc = null;
}
@@ -2116,19 +2151,19 @@
if(SUPPORT_DOCUMENTS && this.doc){
const index = this.doc["index"];
const length = index.length;
const keys = this.doc["keys"];
const length = keys.length;
const payload = new Array(length + 1);
let i = 0;
for(; i < index.length; i++){
for(; i < keys.length; i++){
const idx = this.doc.index[keys[i]];
payload[i] = [
index[i]._map,
index[i]._ctx,
index[i]._ids
idx._map, idx._ctx, idx._ids
];
}
@@ -2155,12 +2190,12 @@
if(SUPPORT_DOCUMENTS && this.doc){
const index = this.doc["index"];
const length = index.length;
const keys = this.doc["keys"];
const length = keys.length;
for(let i = 0; i < length; i++){
const idx = index[i];
const idx = this.doc.index[keys[i]];
idx._map = payload[i][0];
idx._ctx = payload[i][1];
@@ -2175,7 +2210,7 @@
this._map = payload[0];
this._ctx = payload[1];
this._ids = payload[2];
this._doc = payload[3];
//this._doc = payload[3];
}
};
}
@@ -2872,14 +2907,11 @@
const final = create_object();
if(words){
for(let i = 0; i < words.length; i++){
for(let i = 0; i < words.length; i++){
const word = encoder ? encoder(words[i]) : words[i];
const word = encoder ? encoder(words[i]) : words[i];
final[word] = String.fromCharCode((65000 - words.length) + i);
}
final[word] = 1; // String.fromCharCode((65000 - words.length) + i); // mask filtered words?
}
return final;
@@ -2895,25 +2927,23 @@
const final = [];
if(stem){
for(const key in stem){
for(const key in stem){
if(stem.hasOwnProperty(key)){
if(stem.hasOwnProperty(key)){
const tmp = encoder ? encoder(key) : key;
const tmp = encoder ? encoder(key) : key;
final.push(
final.push(
//regex("(?=.{" + tmp.length + ",})" + tmp + "$"),
regex(tmp + "($|\\W)"),
regex("(?=.{" + (tmp.length + 3) + ",})" + tmp + "$"),
encoder ?
encoder ?
encoder(stem[key])
:
stem[key]
);
}
encoder(stem[key])
:
stem[key]
);
}
}
@@ -2921,8 +2951,8 @@
}
/**
* @param {string} a
* @param {string} b
* @param {Array<number|string>} a
* @param {Array<number|string>} b
* @returns {number}
*/
@@ -3019,12 +3049,11 @@
* @param {!Array<Array<number|string>>} arrays
* @param {number=} limit
* @param {number=} cursor
* @param {Object=} docs
* @param {boolean=} suggest
* @returns {Array}
*/
function intersect(arrays, limit, cursor, docs, suggest) {
function intersect(arrays, limit, cursor, /*docs,*/ suggest) {
let result = [];
let suggestions;
@@ -3032,9 +3061,10 @@
if(length_z > 1){
// pre-sort arrays by length up
// pre-sort arrays
arrays.sort(sort_by_length_up);
//TODO: test strategy
//arrays.sort(sort_by_length_down);
// fill initial map
@@ -3079,7 +3109,8 @@
if(is_final_loop){
result[count++] = docs ? docs[tmp] : tmp;
//result[count++] = docs ? docs[tmp] : tmp;
result[count++] = tmp;
if(limit && (count === limit)){
@@ -3142,7 +3173,8 @@
for(i = 0, length = tmp.length; i < length; i++){
result[count++] = docs ? docs[tmp[i]] : tmp[i];
//result[count++] = docs ? docs[tmp[i]] : tmp[i];
result[count++] = tmp[i];
if(limit && (count === limit)){
@@ -3156,24 +3188,24 @@
}
else if(length_z){
if(docs){
const arr = arrays[0];
let length = arr.length;
if(limit && (limit < length)){
length = limit;
}
result = new Array(length);
for(let i = 0; i < length; i++){
result[i] = docs[arr[i]];
}
}
else{
// if(docs){
//
// const arr = arrays[0];
// let length = arr.length;
//
// if(limit && (limit < length)){
//
// length = limit;
// }
//
// result = new Array(length);
//
// for(let i = 0; i < length; i++){
//
// result[i] = docs[arr[i]];
// }
// }
// else{
result = arrays[0];
@@ -3183,7 +3215,7 @@
result = result.slice(0, limit);
}
}
//}
// Note: handle references to the original index array
//return result.slice(0);
@@ -3410,101 +3442,6 @@
return Object.keys(obj);
}
/**
* @param {FlexSearch} ref
*/
/*
function runner(ref){
const async = ref.async;
let current;
if(async){
ref.async = false;
}
if(ref._stack_keys.length){
const start = time();
let key;
// TODO: optimize shift() using a loop and splice()
while((key = ref._stack_keys.shift()) || (key === 0)){
current = ref._stack[key];
switch(current[0]){
case enum_task.add:
ref.add(current[1], current[2]);
break;
// Note: Update is handled by .remove() + .add()
//
// case enum_task.update:
//
// ref.update(current[1], current[2]);
// break;
case enum_task.remove:
ref.remove(current[1]);
break;
}
delete ref._stack[key];
if((time() - start) > 100){
break;
}
}
if(ref._stack_keys.length){
register_task(ref);
}
}
if(async){
ref.async = async;
}
}
*/
/**
* @param {FlexSearch} ref
*/
/*
function register_task(ref){
ref._timer || (
ref._timer = queue(function(){
ref._timer = 0;
runner(ref);
}, 1, "@" + ref.id)
);
}
*/
/**
* @returns {number}
*/
function time(){
return Date.now();
}
/**
* https://jsperf.com/comparison-object-index-type
* @param {number} count
@@ -3550,7 +3487,8 @@
{
"limit": data["limit"],
"threshold": data["threshold"]
"threshold": data["threshold"],
"where": data["where"]
}
:
data["limit"]
@@ -3635,7 +3573,16 @@
if(data && data["result"]){
callback(data["id"], data["content"], data["result"], data["limit"]);
callback(
data["id"],
data["content"],
data["result"],
data["limit"],
data["where"],
data["cursor"],
data["suggest"]
);
}
},

View File

@@ -1,6 +1,6 @@
{
"name": "flexsearch",
"version": "0.5.1",
"version": "0.5.2",
"description": "Next-Generation full text search library with zero dependencies.",
"homepage": "https://github.com/nextapps-de/flexsearch/",
"author": "Thomas Wilkerling",

View File

@@ -71,8 +71,8 @@ describe("Index Multi-Field Documents (ES6)", function(){
await index.add(data);
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
@@ -80,23 +80,34 @@ describe("Index Multi-Field Documents (ES6)", function(){
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
// expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(await index.search({field: ["data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
expect(await index.search({query: "body"})).to.have.members(data);
expect(await index.search("title")).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(await index.search({query: "body"})).to.have.members(data);
// expect(await index.search("title")).to.have.members(data);
expect(await index.search({field: ["data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
await index.update(update);
expect(await index.search("foo")).not.to.have.members(data);
expect(await index.search("bar")).not.to.have.members(data);
expect(await index.search("foo")).to.have.members(update);
expect(await index.search("bar")).to.have.members(update);
//TODO: provide logical operator "OR"
// expect(await index.search("foo")).not.to.have.members(data);
// expect(await index.search("bar")).not.to.have.members(data);
// expect(await index.search("foo")).to.have.members(update);
// expect(await index.search("bar")).to.have.members(update);
expect(await index.search("foo", {field: "data:title"})).not.to.have.members(data);
expect(await index.search("bar", {field: "data:body"})).not.to.have.members(data);
expect(await index.search("foo", {field: "data:title"})).to.have.members(update);
expect(await index.search("bar", {field: "data:body"})).to.have.members(update);
await index.remove(update);
expect(await index.doc.index[0].length).to.equal(0);
expect(await index.doc.index[1].length).to.equal(0);
expect(await index.doc.index["data:title"].length).to.equal(0);
expect(await index.doc.index["data:body"].length).to.equal(0);
});
it("Should have been indexed properly (Worker)", async function(){
@@ -117,8 +128,8 @@ describe("Index Multi-Field Documents (ES6)", function(){
await index.add(data);
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
@@ -126,22 +137,33 @@ describe("Index Multi-Field Documents (ES6)", function(){
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
// expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(await index.search({field: ["data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
expect(await index.search({query: "body"})).to.have.members(data);
expect(await index.search("title")).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(await index.search({query: "body"})).to.have.members(data);
// expect(await index.search("title")).to.have.members(data);
expect(await index.search({query: "body", field: "data:body"})).to.have.members(data);
expect(await index.search("title", {field: "data:title"})).to.have.members(data);
await index.update(update);
expect(await index.search("foo")).not.to.have.members(data);
expect(await index.search("bar")).not.to.have.members(data);
expect(await index.search("foo")).to.have.members(update);
expect(await index.search("bar")).to.have.members(update);
//TODO: provide logical operator "OR"
// expect(await index.search("foo")).not.to.have.members(data);
// expect(await index.search("bar")).not.to.have.members(data);
// expect(await index.search("foo")).to.have.members(update);
// expect(await index.search("bar")).to.have.members(update);
expect(await index.search("foo", {field: "data:title"})).not.to.have.members(data);
expect(await index.search("bar", {field: "data:body"})).not.to.have.members(data);
expect(await index.search("foo", {field: "data:title"})).to.have.members(update);
expect(await index.search("bar", {field: "data:body"})).to.have.members(update);
await index.remove(update);
expect(await index.doc.index[0].length).to.equal(0);
expect(await index.doc.index[1].length).to.equal(0);
expect(await index.doc.index["data:title"].length).to.equal(0);
expect(await index.doc.index["data:body"].length).to.equal(0);
});
});

View File

@@ -1009,6 +1009,92 @@ describe("Options", function(){
}
});
// ------------------------------------------------------------------------
// Filter Tests
// ------------------------------------------------------------------------
describe("Filter", function(){
it("Should have been filtered properly", function(){
var index = new FlexSearch({
encode: "icase",
tokenize: "strict",
filter: ["in", "the"]
});
index.add(0, "Today in the morning.");
expect(index.length).to.equal(1);
expect(index.search("today in the morning.")).to.include(0);
expect(index.search("today morning")).to.include(0);
expect(index.search("in the")).to.have.length(0);
});
it("Should have been filtered properly (custom function)", function(){
var index = new FlexSearch({
encode: "icase",
tokenize: "strict",
filter: function(word){
return word.length > 3;
}
});
index.add(0, "Today in the morning.");
expect(index.length).to.equal(1);
expect(index.search("today in the morning.")).to.include(0);
expect(index.search("today morning")).to.include(0);
expect(index.search("in the")).to.have.length(0);
});
});
describe("Stemmer", function(){
it("Should have been stemmed properly", function(){
var index = new FlexSearch({
encode: "icase",
tokenize: "reverse",
stemmer: {
"ization": "ize",
"tional": "tion"
}
});
index.add(0, "Just a multinational colonization.");
expect(index.length).to.equal(1);
expect(index.search("Just a multinational colonization.")).to.include(0);
expect(index.search("multinational colonization")).to.include(0);
expect(index.search("tional tion")).to.have.length(0);
});
it("Should have been stemmed properly (custom function)", function(){
var stems = {
"ization": "ize",
"tional": "tion"
};
var index = new FlexSearch({
encode: "icase",
tokenize: "strict",
stemmer: function(word){
return stems[word] || word;
}
});
index.add(0, "Just a multinational colonization.");
expect(index.length).to.equal(1);
expect(index.search("Just a multinational colonization.")).to.include(0);
expect(index.search("multinational colonization")).to.include(0);
expect(index.search("tional tion")).to.have.length(0);
});
});
// ------------------------------------------------------------------------
// Relevance Tests
// ------------------------------------------------------------------------
@@ -1031,7 +1117,7 @@ describe("Relevance", function(){
expect(index.search("one two")).to.have.members([1, 2]);
expect(index.search("four one")).to.have.members([1, 2]);
var index = new FlexSearch({
index = new FlexSearch({
encode: "advanced",
tokenize: "strict",
threshold: 5,
@@ -1047,7 +1133,7 @@ describe("Relevance", function(){
expect(index.search("one two")).to.have.members([1, 2]);
expect(index.search("four one")).to.have.members([1, 2]);
var index = new FlexSearch({
index = new FlexSearch({
encode: "extra",
tokenize: "ngram",
threshold: 5,
@@ -1231,8 +1317,8 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
}
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
@@ -1241,11 +1327,17 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
expect(index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
//TODO: provide logical operator "OR"
//expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
//expect(index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(index.search({field: ["data:title"], query: "title"})).to.have.members(data);
expect(index.search({query: "body"})).to.have.members(data);
expect(index.search("title")).to.have.members(data);
//TODO: provide logical operator "OR"
//expect(index.search({query: "body"})).to.have.members(data);
//expect(index.search("title")).to.have.members(data);
expect(index.search("body", {field: "data:body"})).to.have.members(data);
expect(index.search("title", {field: ["data:title"]})).to.have.members(data);
expect(index.search({
@@ -1255,17 +1347,18 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
})).to.have.members(data);
expect(index.search([{
field: "data:title",
query: "body",
boost: 2
},{
field: "data:body",
query: "body",
boost: 2
}])).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(index.search([{
//
// field: "data:title",
// query: "body",
// boost: 2
// },{
// field: "data:body",
// query: "body",
// boost: 2
//
// }])).to.have.members(data);
expect(index.search("title", {
@@ -1281,29 +1374,35 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
})).to.have.lengthOf(0);
expect(index.search("body", [{
field: "data:title",
boost: 2
},{
field: "data:body",
boost: 2
}])).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(index.search("body", [{
//
// field: "data:title",
// boost: 2
// },{
// field: "data:body",
// boost: 2
//
// }])).to.have.members(data);
index.update(update);
expect(index.search("foo")).not.to.have.members(data);
expect(index.search("bar")).not.to.have.members(data);
expect(index.search("foo")).to.have.members(update);
expect(index.search("bar")).to.have.members(update);
//TODO: provide logical operator "OR"
// expect(index.search("foo")).not.to.have.members(data);
// expect(index.search("bar")).not.to.have.members(data);
// expect(index.search("foo")).to.have.members(update);
// expect(index.search("bar")).to.have.members(update);
expect(index.search("foo", {field: "data:title"})).not.to.have.members(data);
expect(index.search("bar", {field: "data:body"})).not.to.have.members(data);
expect(index.search("foo", {field: "data:title"})).to.have.members(update);
expect(index.search("bar", {field: "data:body"})).to.have.members(update);
index.remove(update);
if(env === ""){
expect(index.doc.index[0].length).to.equal(0);
expect(index.doc.index[1].length).to.equal(0);
expect(index.doc.index["data:title"].length).to.equal(0);
expect(index.doc.index["data:body"].length).to.equal(0);
}
});
@@ -1331,8 +1430,8 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
}
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
@@ -1341,11 +1440,17 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
expect(index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: ["data:body", "data:title"], query: "tle"})).to.have.members(data);
//TODO: provide logical operator "OR"
//expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
//expect(index.search({field: ["data:body", "data:title"], query: "tle"})).to.have.members(data);
expect(index.search({field: ["data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: "data:title", query: "tle"})).to.have.members(data);
expect(index.search({query: "body"})).to.have.members(data);
expect(index.search("tle")).to.have.members(data);
//TODO: provide logical operator "OR"
//expect(index.search({query: "body"})).to.have.members(data);
//expect(index.search("tle")).to.have.members(data);
expect(index.search({query: "body", field: "data:body"})).to.have.members(data);
expect(index.search("tle", {field: "data:title"})).to.have.members(data);
expect(index.search({
@@ -1354,15 +1459,16 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
})).to.have.members(data);
expect(index.search([{
field: "data:title",
query: "body"
},{
field: "data:body",
query: "body"
}])).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(index.search([{
//
// field: "data:title",
// query: "body"
// },{
// field: "data:body",
// query: "body"
//
// }])).to.have.members(data);
expect(index.search("tle", {
@@ -1376,30 +1482,57 @@ if(env !== "light") describe("Index Multi-Field Documents", function(){
})).to.have.lengthOf(0);
expect(index.search("body", [{
field: "data:title"
},{
field: "data:body"
}])).to.have.members(data);
//TODO: provide logical operator "OR"
// expect(index.search("body", [{
//
// field: "data:title"
// },{
// field: "data:body"
//
// }])).to.have.members(data);
index.update(update);
expect(index.search("foo")).not.to.have.members(data);
expect(index.search("bar")).not.to.have.members(data);
expect(index.search("foo")).to.have.members(update);
expect(index.search("bar")).to.have.members(update);
//TODO: provide logical operator "OR"
// expect(index.search("foo")).not.to.have.members(data);
// expect(index.search("bar")).not.to.have.members(data);
// expect(index.search("foo")).to.have.members(update);
// expect(index.search("bar")).to.have.members(update);
expect(index.search("foo", {field: "data:title"})).not.to.have.members(data);
expect(index.search("bar", {field: "data:body"})).not.to.have.members(data);
expect(index.search("foo", {field: "data:title"})).to.have.members(update);
expect(index.search("bar", {field: "data:body"})).to.have.members(update);
index.remove(update);
if(env === ""){
expect(index.doc.index[0].length).to.equal(0);
expect(index.doc.index[1].length).to.equal(0);
expect(index.doc.index["data:title"].length).to.equal(0);
expect(index.doc.index["data:body"].length).to.equal(0);
}
});
it("Should have been unique results", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: ["field1", "field2"]
}
});
var docs = [{
id: 1,
field1: "phrase",
field2: "phrase"
}];
index.add(docs);
expect(index.search("phrase")).to.have.lengthOf(1);
expect(index.search("phrase")).to.have.members(docs);
});
/*
it("Should have been indexed properly (tag)", function(){
@@ -1635,12 +1768,12 @@ if(env !== "light") describe("Export / Import", function(){
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index["title"].length).to.equal(3);
expect(data).to.equal(JSON.stringify([
[
index.doc.index[0]._map,
index.doc.index[0]._ctx,
index.doc.index[0]._ids
index.doc.index["title"]._map,
index.doc.index["title"]._ctx,
index.doc.index["title"]._ids
],
index._doc
]));
@@ -1660,7 +1793,7 @@ if(env !== "light") describe("Export / Import", function(){
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index["title"].length).to.equal(3);
}
expect(index.search("foo")).to.have.lengthOf(2);