|
|
@@ -5,27 +5,26 @@
|
|
|
|
* Licence: Apache-2.0
|
|
|
|
* Licence: Apache-2.0
|
|
|
|
* https://github.com/nextapps-de/flexsearch
|
|
|
|
* https://github.com/nextapps-de/flexsearch
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
(function(){'use strict';var t;function aa(a){function b(c){return a.next(c)}function d(c){return a.throw(c)}return new Promise(function(c,e){function f(g){g.done?c(g.value):Promise.resolve(g.value).then(b,d).then(f,e)}f(a.next())})};const v=/[\W_]+/;function ba(a){if(a=a.toLowerCase())if(a&&this.B&&(a=ca(a,this.B)),this.D&&1<a.length&&(a=ca(a,this.D)),a&&(v||""===v)&&(a=a.split(v),this.filter)){var b=this.filter;const d=a.length,c=[];for(let e=0,f=0;e<d;e++){const g=a[e];g&&!b[g]&&(c[f++]=g)}a=c}return a};function y(a,b){return"undefined"!==typeof a?a:b}function da(a){const b=Array(a);for(let d=0;d<a;d++)b[d]=A();return b}function A(){return Object.create(null)}function ea(a,b){return b.length-a.length}function E(a){return"string"===typeof a}function G(a){return"object"===typeof a}function H(a){return"function"===typeof a};function fa(a,b){const d=Object.keys(a),c=d.length,e=[];let f="",g=0;for(let h=0,k,l;h<c;h++)k=d[h],(l=a[k])?(e[g++]=new RegExp(b?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[g++]=l):f+=(f?"|":"")+k;f&&(e[g++]=new RegExp(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")","g"),e[g]="");return e}function ca(a,b){for(let d=0,c=b.length;d<c&&(a=a.replace(b[d],b[d+1]),a);d+=2);return a};const ha={},ia={};let I=Promise;Object.assign||(Object.assign=function(){const a=arguments,b=a.length,d=a[0];for(let c=1,e,f,g;c<b;c++){e=a[c];f=Object.keys(e);g=f.length;for(let h=0,k;h<g;h++)k=f[h],d[k]=e[k]}return d});if(!I){function a(b){this.g=null;const d=this;b(function(c){d.g&&d.g(c)})}a.prototype.then=function(b){this.g=b};I=a};function ja(a){J(a,"add");J(a,"append");J(a,"search");J(a,"update");J(a,"remove")}function J(a,b){a[b+"Async"]=function(){const d=this,c=arguments;var e=c[c.length-1];let f;H(e)&&(f=e,delete c[c.length-1]);e=new I(function(g){setTimeout(function(){const h=d[b];h.async=!0;g(h.apply(d,c));h.async=!1})});return f?(e.then(f),this):e}};function ka(a,b,d,c){const e=a.length;let f=[],g=A(),h=0;c&&(c=[]);for(let k=0;k<e;k++){const l=a[k],r=l.length,q=A();let u=!k;for(let m=0;m<r;m++){const x=l[m],p=x.length;if(p){c&&(c[m]=[]);for(let z=0,w=0,n;z<p;z++)if(n=x[z],!k)q[n]=1;else if(g[n]){if(k===e-1)if(d)d--;else{if(f[h++]=n,h===b)return f}else c&&w<b&&(c[m][w++]=n),q[n]=1;u=!0}}}if(!u&&!c)return[];g=q}if(c)for(let k=c.length-1,l,r;0<=k;k--)if(r=(l=c[k])&&l.length){if(h+r>=b)return f.concat(l.slice(0,b-h));f=f.concat(l);h+=r}return f}
|
|
|
|
(function(self){'use strict';var u;const v=/[\W_]+/;function aa(a){if(a=a.toLowerCase())if(a&&this.B&&(a=y(a,this.B)),this.F&&1<a.length&&(a=y(a,this.F)),a&&(v||""===v)&&(a=a.split(v),this.filter)){var b=this.filter;const c=a.length,d=[];for(let e=0,f=0;e<c;e++){const g=a[e];g&&!b[g]&&(d[f++]=g)}a=d}return a};function A(a,b){return"undefined"!==typeof a?a:b}function B(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=C();return b}function C(){return Object.create(null)}function ba(a,b){return b.length-a.length}function D(a){return"string"===typeof a}function E(a){return"object"===typeof a}function F(a){return"function"===typeof a};function G(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(e[g++]=new RegExp(b?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[g++]=l):f+=(f?"|":"")+k;f&&(e[g++]=new RegExp(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")","g"),e[g]="");return e}function y(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a};const H={},ca={};let I=Promise;Object.assign||(Object.assign=function(){const a=arguments,b=a.length,c=a[0];for(let d=1,e,f,g;d<b;d++){e=a[d];f=Object.keys(e);g=f.length;for(let h=0,k;h<g;h++)k=f[h],c[k]=e[k]}return c});if(!I){function a(b){this.g=null;const c=this;b(function(d){c.g&&c.g(d)})}a.prototype.then=function(b){this.g=b};I=a};function da(a){J(a,"add");J(a,"append");J(a,"search");J(a,"update");J(a,"remove")}function J(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;F(e)&&(f=e,delete d[d.length-1]);e=new I(function(g){setTimeout(function(){const h=c[b];h.async=!0;g(h.apply(c,d));h.async=!1})});return f?(e.then(f),this):e}};function ea(a,b,c,d){const e=a.length;let f=[],g=C(),h=0;d&&(d=[]);for(let k=0;k<e;k++){const l=a[k],p=l.length,r=C();let w=!k;for(let q=0;q<p;q++){const t=l[q],m=t.length;if(m){d&&(d[q]=[]);for(let n=0,x=0,z;n<m;n++)if(z=t[n],!k)r[z]=1;else if(g[z]){if(k===e-1)if(c)c--;else{if(f[h++]=z,h===b)return f}else d&&x<b&&(d[q][x++]=z),r[z]=1;w=!0}}}if(!w&&!d)return[];g=r}if(d)for(let k=d.length-1,l,p;0<=k;k--)if(p=(l=d[k])&&l.length){if(h+p>=b)return f.concat(l.slice(0,b-h));f=f.concat(l);h+=p}return f}
|
|
|
|
;function N(a){this.h=!0!==a&&a;this.cache=A();this.g=[]}function la(a,b,d){G(a)&&(a=a.query);let c=this.cache.get(a);c||(c=this.search(a,b,d),this.cache.set(a,c));return c}N.prototype.set=function(a,b){if(!this.cache[a]){var d=this.g.length;d===this.h?delete this.cache[this.g[d-1]]:d++;for(--d;0<d;d--)this.g[d]=this.g[d-1];this.g[0]=a}this.cache[a]=b};N.prototype.get=function(a){const b=this.cache[a];if(this.h&&b&&(a=this.g.indexOf(a))){const d=this.g[a-1];this.g[a-1]=this.g[a];this.g[a]=d}return b};const ma={memory:{charset:"latin:extra",o:3,m:3,i:!1,j:"memory"},performance:{threshold:8,m:3,context:{depth:1,u:!0}},match:{charset:"latin:extra",H:"full",o:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,u:!0}},"default":{o:3,threshold:0,depth:3}};function na(a,b,d,c,e,f){setTimeout(function(){const g=a(d,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,d,c,e+1)}):b.export(a,b,d,c,e+1)})};function O(a,b){if(!(this instanceof O))return new O(a);var d;if(a){E(a)?a=ma[a]:(d=a.preset)&&(a=Object.assign({},d[d],a));d=a.charset;var c=a.lang;E(d)&&(-1===d.indexOf(":")&&(d+=":default"),d=ia[d]);E(c)&&(c=ha[c])}else a={};let e,f,g,h=a.context||{};this.encode=a.encode||d&&d.encode||ba;this.register=b||A();e=a.resolution||9;f=a.threshold||0;f>=e&&(f=e-1);this.o=e;this.threshold=f;this.s=b=d&&d.H||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.u=y(h.bidirectional,!0);this.j=g="memory"===
|
|
|
|
function fa(a,b){const c=C(),d=C(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function K(a){this.h=!0!==a&&a;this.cache=C();this.g=[]}function ha(a,b,c){E(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}K.prototype.set=function(a,b){if(!this.cache[a]){var c=this.g.length;c===this.h?delete this.cache[this.g[c-1]]:c++;for(--c;0<c;c--)this.g[c]=this.g[c-1];this.g[0]=a}this.cache[a]=b};K.prototype.get=function(a){const b=this.cache[a];if(this.h&&b&&(a=this.g.indexOf(a))){const c=this.g[a-1];this.g[a-1]=this.g[a];this.g[a]=c}return b};const ia={memory:{charset:"latin:extra",o:3,m:3,i:!1,l:"memory"},performance:{threshold:8,m:3,context:{depth:1,u:!0}},match:{charset:"latin:extra",I:"full",o:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,u:!0}},"default":{o:3,threshold:0,depth:3}};function la(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};function L(a,b){if(!(this instanceof L))return new L(a);var c;if(a){D(a)?a=ia[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;D(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=ca[c]);D(d)&&(d=H[d])}else a={};let e,f,g,h=a.context||{};this.encode=a.encode||c&&c.encode||aa;this.register=b||C();e=a.resolution||9;f=a.threshold||0;f>=e&&(f=e-1);this.o=e;this.threshold=f;this.s=b=c&&c.I||a.tokenize||"strict";this.depth="strict"===b&&h.depth;this.u=A(h.bidirectional,!0);this.l=g="memory"===
|
|
|
|
a.optimize;this.i=y(a.fastupdate,!0);this.m=a.minlength||1;this.map=g?da(e-f):A();e=h.resolution||e;f=h.threshold||f;f>=e&&(f=e-1);this.h=e;this.l=f;this.g=g?da(e-f):A();this.C=d&&d.C||a.rtl;this.B=(b=a.matcher||c&&c.B)&&fa(b,!1);this.D=(b=a.stemmer||c&&c.D)&&fa(b,!0);if(d=b=a.filter||c&&c.filter){d=b;c=A();for(let k=0,l=d.length;k<l;k++)c[d[k]]=1;d=c}this.filter=d;this.cache=(b=a.cache)&&new N(b)}t=O.prototype;t.append=function(a,b){return this.add(a,b,!0)};
|
|
|
|
a.optimize;this.i=A(a.fastupdate,!0);this.m=a.minlength||1;this.map=g?B(e-f):C();e=h.resolution||e;f=h.threshold||f;f>=e&&(f=e-1);this.h=e;this.j=f;this.g=g?B(e-f):C();this.D=c&&c.D||a.rtl;this.B=(b=a.matcher||d&&d.B)&&G(b,!1);this.F=(b=a.stemmer||d&&d.F)&&G(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=C();for(let k=0,l=c.length;k<l;k++)d[c[k]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new K(b)}u=L.prototype;u.append=function(a,b){return this.add(a,b,!0)};
|
|
|
|
t.add=function(a,b,d){if(this.register[a]&&!d)return this.update(a,b);if(b&&(a||0===a)){b=this.encode(b);const l=b.length;if(l){const r=this.depth,q=this.o-this.threshold,u=A(),m=A();for(let x=0;x<l;x++){let p=b[this.C?l-1-x:x];var c=p.length;if(p&&c>=this.m&&(r||!u[p])){var e=Math.min(this.o/l*x|0,x);if(e<q){var f="";switch(this.s){case "full":if(3<c){for(var g=0;g<c;g++){var h=g?Math.min(e/2+this.o/c*g/2|0,e+g):e;if(h<q)for(var k=c;k>g;k--)f=p.substring(g,k),f.length>=this.m&&P(this,u,f,h,a,d)}break}case "reverse":if(2<
|
|
|
|
u.add=function(a,b,c){if(this.register[a]&&!c)return this.update(a,b);if(b&&(a||0===a)){b=this.encode(b);const l=b.length;if(l){const p=this.depth,r=this.o-this.threshold,w=C(),q=C();for(let t=0;t<l;t++){let m=b[this.D?l-1-t:t];var d=m.length;if(m&&d>=this.m&&(p||!w[m])){var e=Math.min(this.o/l*t|0,t);if(e<r){var f="";switch(this.s){case "full":if(3<d){for(var g=0;g<d;g++){var h=g?Math.min(e/2+this.o/d*g/2|0,e+g):e;if(h<r)for(var k=d;k>g;k--)f=m.substring(g,k),f.length>=this.m&&N(this,w,f,h,a,c)}break}case "reverse":if(2<
|
|
|
|
c){for(g=c-1;0<g;g--)f=p[g]+f,f.length>=this.m&&P(this,u,f,e,a,d);f=""}case "forward":if(1<c)for(g=0;g<c;g++)f+=p[g],f.length>=this.m&&P(this,u,f,e,a,d);break;default:if(P(this,u,p,e,a,d),r&&1<l&&x<l-1)for(c=this.h-this.l,e=A(),f=p,g=Math.min(r+1,l-x),e[f]=1,h=1;h<g;h++)if((p=b[this.C?l-1-x-h:x+h])&&p.length>=this.m&&!e[p]){if(e[p]=1,k=Math.min((this.h-g)/l*x+h|0,x+(h-1)),k<c){const z=this.u&&p>f;P(this,m,z?f:p,k,a,d,z?p:f)}}else g=Math.min(g+1,l-x)}}}}this.i||(this.register[a]=1)}}return this};
|
|
|
|
d){for(g=d-1;0<g;g--)f=m[g]+f,f.length>=this.m&&N(this,w,f,e,a,c);f=""}case "forward":if(1<d)for(g=0;g<d;g++)f+=m[g],f.length>=this.m&&N(this,w,f,e,a,c);break;default:if(N(this,w,m,e,a,c),p&&1<l&&t<l-1)for(d=this.h-this.j,e=C(),f=m,g=Math.min(p+1,l-t),e[f]=1,h=1;h<g;h++)if((m=b[this.D?l-1-t-h:t+h])&&m.length>=this.m&&!e[m]){if(e[m]=1,k=Math.min((this.h-g)/l*t+h|0,t+(h-1)),k<d){const n=this.u&&m>f;N(this,q,n?f:m,k,a,c,n?m:f)}}else g=Math.min(g+1,l-t)}}}}this.i||(this.register[a]=1)}}return this};
|
|
|
|
function P(a,b,d,c,e,f,g){let h=g?a.g:a.map;if(!b[d]||g&&!b[d][g])a.j&&(h=h[c]),g?(b[d]||(b[d]=A()),b[d][g]=1,h=h[g]||(h[g]=A())):b[d]=1,h=h[d]||(h[d]=[]),a.j||(h=h[c]||(h[c]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.i&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
|
|
|
|
function N(a,b,c,d,e,f,g){let h=g?a.g:a.map;if(!b[c]||g&&!b[c][g])a.l&&(h=h[d]),g?(b[c]||(b[c]=C()),b[c][g]=1,h=h[g]||(h[g]=C())):b[c]=1,h=h[c]||(h[c]=[]),a.l||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.i&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
|
|
|
|
t.search=function(a,b,d){G(a)?(d=a,a=d.query):G(b)&&(d=b);let c=[],e;var f=this.threshold;let g,h=0;if(d){b=d.limit;h=d.offset||0;f=y(d.threshold,f);var k=d.context;g=d.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){d=A();var l=[];for(let q=0,u=0,m;q<e;q++)if((m=a[q])&&m.length>=this.m&&!d[m])if(this.j||g||this.map[m])l[u++]=m,d[m]=1;else return c;a=l;e=a.length}if(!e)return c;b||(b=100);d=this.o-f;f=this.h-f;k=this.depth&&1<e&&!1!==k;l=0;let r;k?(r=a[0],l=1):1<e&&a.sort(ea);for(let q,u;l<e;l++){u=
|
|
|
|
u.search=function(a,b,c){E(a)?(c=a,a=c.query):E(b)&&(c=b);let d=[],e;var f=this.threshold;let g,h=0;if(c){b=c.limit;h=c.offset||0;f=A(c.threshold,f);var k=c.context;g=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=C();var l=[];for(let r=0,w=0,q;r<e;r++)if((q=a[r])&&q.length>=this.m&&!c[q])if(this.l||g||this.map[q])l[w++]=q,c[q]=1;else return d;a=l;e=a.length}if(!e)return d;b||(b=100);c=this.o-f;f=this.h-f;k=this.depth&&1<e&&!1!==k;l=0;let p;k?(p=a[0],l=1):1<e&&a.sort(ba);for(let r,w;l<e;l++){w=
|
|
|
|
a[l];k?(q=oa(this,c,g,f,b,2===e,u,r),g&&!1===q&&c.length||(r=u)):q=oa(this,c,g,d,b,1===e,u);if(q)return q;if(g&&l===e-1){let m=c.length;if(!m){if(k){k=0;l=-1;continue}return c}if(1===m)return c=c[0],c=1===c.length?c[0]:[].concat.apply([],c),c.length>b?c.slice(0,b):c}}return ka(c,b,h,g)};function pa(a,b,d,c){d?(c=c&&b>d,a=(a=a[c?b:d])&&a[c?d:b]):a=a[b];return a}
|
|
|
|
a[l];k?(r=ma(this,d,g,f,b,2===e,w,p),g&&!1===r&&d.length||(p=w)):r=ma(this,d,g,c,b,1===e,w);if(r)return r;if(g&&l===e-1){let q=d.length;if(!q){if(k){k=0;l=-1;continue}return d}if(1===q)return d=d[0],d=1===d.length?d[0]:[].concat.apply([],d),d.length>b?d.slice(0,b):d}}return ea(d,b,h,g)};function na(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}
|
|
|
|
function oa(a,b,d,c,e,f,g,h){let k=[],l=h?a.g:a.map;a.j||(l=pa(l,g,h,a.u));if(l){let r=0;c=Math.min(l.length,c);for(let q=0,u=0,m;q<c&&!(m=l[q],a.j&&(m=pa(m,g,h,a.u)),m&&(k[r++]=m,f&&(u+=m.length,u>=e)));q++);if(r){if(f)return k=1===r?k[0]:[].concat.apply([],k),k.length>e?k.slice(0,e):k;b[b.length]=k;return}}return!d&&k}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};
|
|
|
|
function ma(a,b,c,d,e,f,g,h){let k=[],l=h?a.g:a.map;a.l||(l=na(l,g,h,a.u));if(l){let p=0;d=Math.min(l.length,d);for(let r=0,w=0,q;r<d&&!(q=l[r],a.l&&(q=na(q,g,h,a.u)),q&&(k[p++]=q,f&&(w+=q.length,w>=e)));r++);if(p){if(f)return k=1===p?k[0]:[].concat.apply([],k),k.length>e?k.slice(0,e):k;b[b.length]=k;return}}return!c&&k}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
|
|
|
|
t.remove=function(a,b){const d=this.register[a];if(d){if(this.i)for(let c=0,e;c<d.length;c++)e=d[c],e.splice(e.indexOf(a),1);else Q(this.map,a,this.o-this.threshold,this.j),this.depth&&Q(this.g,a,this.h-this.l,this.j);b||delete this.register[a];if(this.cache){b=this.cache;for(let c=0,e,f;c<b.g.length;c++)f=b.g[c],e=b.cache[f],-1!==e.indexOf(a)&&(b.g.splice(c--,1),delete b.cache[f])}}return this};
|
|
|
|
u.remove=function(a,b){const c=this.register[a];if(c){if(this.i)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else O(this.map,a,this.o-this.threshold,this.l),this.depth&&O(this.g,a,this.h-this.j,this.l);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.g.length;d++)f=b.g[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.g.splice(d--,1),delete b.cache[f])}}return this};
|
|
|
|
function Q(a,b,d,c,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,d);for(let g=0,h;g<e;g++)if(h=a[g])f=Q(h,b,d,c,e),c||f||delete a[g]}else for(let g in a)(f=Q(a[g],b,d,c,e))||delete a[g];return f}t.searchCache=la;
|
|
|
|
function O(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=O(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=O(a[g],b,c,d,e))||delete a[g];return f}u.searchCache=ha;
|
|
|
|
t.export=function(a,b,d,c,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.i){g=A();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.j?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.g;break;default:return}na(a,b||this,d?d+"."+f:f,c,e,g);return!0};t.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "cfg":this.j=!!b.opt;break;case "reg":this.i=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.g=b}};ja(O.prototype);let qa=0;function R(a){if(G(a)){var b=a;a=0}H(b.encode)&&(b.encode=b.encode.toString());const d=this;this.id=a||qa++;this.h=null;this.g=new Worker("worker.js",{type:"module"});this.g.onmessage=function(c){d.h(c.data)};this.g.postMessage({G:"create",options:b})}S("add");S("append");S("search");S("update");S("remove");
|
|
|
|
u.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.i){g=C();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.l?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.g;break;default:return}la(a,b||this,c?c+"."+f:f,d,e,g);return!0};u.import=function(a,b){if(b)switch(D(b)&&(b=JSON.parse(b)),a){case "cfg":this.l=!!b.opt;break;case "reg":this.i=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.g=b}};da(L.prototype);let oa=0;function P(a,b){E(a)&&(b=a,a=0);b&&F(b.encode)&&(b.encode=b.encode.toString());const c=this;this.id=a||oa++;this.h=null;this.g=new Worker("worker.js",{type:"module"});this.g.onmessage=function(d){c.h(d.data)};this.g.postMessage({H:"create",options:b})}Q("add");Q("append");Q("search");Q("update");Q("remove");
|
|
|
|
function S(a){R.prototype[a]=R.prototype[a+"Async"]=function(){const b=this,d=[].slice.call(arguments);var c=d[d.length-1];let e;H(c)&&(e=c,d.splice(d.length-1,1));c=new I(function(f){b.g.postMessage({G:a,I:d});"search"===a?b.h=f:f()});return e?(c.then(e),this):c}};function T(a){if(!(this instanceof T))return new T(a);var b;a||(a={});this.F=[];this.g=[];this.s=[];this.register=A();this.key=(b=a.key)&&U(b,this.s)||"id";this.i=y(a.fastupdate,!0);this.store=(b=a.store)&&A();this.v=b&&!0!==b&&[];this.A=(b=a.tag)&&U(b,this.s);this.h=b&&A();this.cache=(b=a.cache)&&new N(b);a.cache=!1;this.l=a.worker;this.async=!1;b=a;a=A();let d=b.doc;if(E(d))d=[d];else if(d.constructor!==Array){var c=d;d=Object.keys(d)}for(let e=0,f,g;e<d.length;e++)f=d[e],E(f)?c&&(g=c[f]):(g=f,
|
|
|
|
function Q(a){P.prototype[a]=P.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;F(d)&&(e=d,c.splice(c.length-1,1));d=new I(function(f){b.g.postMessage({H:a,J:c});"search"===a?b.h=f:f()});return e?(d.then(e),this):d}};function R(a){if(!(this instanceof R))return new R(a);var b;a||(a={});this.G=[];this.g=[];this.s=[];this.register=C();this.key=(b=a.key)&&U(b,this.s)||"id";this.i=A(a.fastupdate,!0);this.store=(b=a.store)&&C();this.v=b&&!0!==b&&[];this.C=(b=a.tag)&&U(b,this.s);this.h=b&&C();this.cache=(b=a.cache)&&new K(b);a.cache=!1;this.A=a.worker;this.async=!1;b=a;a=C();let c=b.doc;if(D(c))c=[c];else if(c.constructor!==Array){var d=c;c=Object.keys(c)}for(let e=0,f,g;e<c.length;e++)f=c[e],D(f)?d&&(g=d[f]):(g=f,
|
|
|
|
f=f.field),g=G(g)?Object.assign({},b,g):b,a[f]=this.l?new R(g):new O(g,this.register),this.F[e]=U(f,this.s),this.g[e]=f;if(this.v)for(c=b.store,E(c)&&(c=[c]),b=0;b<c.length;b++)this.v[b]=U(c[b],this.s);this.index=a}function U(a,b){const d=a.split(":");let c=0;for(let e=0;e<d.length;e++)a=d[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[c]=!0),a&&(d[c++]=a);c<d.length&&(d.length=c);return 1<c?d:d[0]}function ra(a,b){if(E(b))a=a[b];else for(let d=0;a&&d<b.length;d++)a=a[b[d]];return a}
|
|
|
|
f=f.field),g=E(g)?Object.assign({},b,g):b,a[f]=this.A?new P(g):new L(g,this.register),this.G[e]=U(f,this.s),this.g[e]=f;if(this.v)for(d=b.store,D(d)&&(d=[d]),b=0;b<d.length;b++)this.v[b]=U(d[b],this.s);this.j=a}function U(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function pa(a,b){if(D(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
|
|
|
|
function V(a,b,d,c,e){a=a[e];if(c===d.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)V(a,b,d,c,e);else b=b[e]||(b[e]=A()),e=d[++c],V(a,b,d,c,e)}function W(a,b,d,c,e,f,g,h){a=a[g];if(c===b.length-1){if(a.constructor===Array){if(d[c]){for(b=0;b<a.length;b++)e.add(f,a[b],!0);return}a=a.join(" ")}e.add(f,a,h)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,d,c,e,f,g,h);else g=b[++c],W(a,b,d,c,e,f,g,h)}t=T.prototype;
|
|
|
|
function V(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)V(a,b,c,d,e);else b=b[e]||(b[e]=C()),e=c[++d],V(a,b,c,d,e)}function W(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0);return}a=a.join(" ")}e.add(f,a,h)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,c,d,e,f,g,h);else g=b[++d],W(a,b,c,d,e,f,g,h)}u=R.prototype;
|
|
|
|
t.add=function(a,b,d){G(a)&&(b=a,a=ra(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let c=0,e,f;c<this.g.length;c++)f=this.g[c],e=this.F[c],E(e)&&(e=[e]),W(b,e,this.s,0,this.index[f],a,e[0],d);if(this.A){let c=ra(b,this.A),e=A();E(c)&&(c=[c]);for(let f=0,g,h;f<c.length;f++)if(g=c[f],!e[g]&&(e[g]=1,h=this.h[g]||(this.h[g]=[]),!d||-1===h.indexOf(a)))if(h[h.length]=a,this.i){const k=this.register[a]||(this.register[a]=[]);k[k.length]=h}}if(this.store){let c;if(this.v){c=
|
|
|
|
u.add=function(a,b,c){E(a)&&(b=a,a=pa(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.g.length;d++)f=this.g[d],e=this.G[d],D(e)&&(e=[e]),W(b,e,this.s,0,this.j[f],a,e[0],c);if(this.C){let d=pa(b,this.C),e=C();D(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.h[g]||(this.h[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.i){const k=this.register[a]||(this.register[a]=[]);k[k.length]=h}}if(this.store){let d;if(this.v){d=
|
|
|
|
A();for(let e=0,f;e<this.v.length;e++)f=this.v[e],E(f)?c[f]=b[f]:V(b,c,f,0,f[0])}this.store[a]=c||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
|
|
|
|
C();for(let e=0,f;e<this.v.length;e++)f=this.v[e],D(f)?d[f]=b[f]:V(b,d,f,0,f[0])}this.store[a]=d||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
|
|
|
|
t.remove=function(a){G(a)&&(a=a[this.key]);if(this.register[a]){for(var b=0;b<this.g.length&&(this.index[this.g[b]].remove(a,!0),!this.i||this.l);b++);if(this.A&&(!this.i||this.l))for(let d in this.h){b=this.h[d];const c=b.indexOf(a);-1!==c&&(1<b.length?b.splice(c,1):delete this.h[d])}this.store&&delete this.store[a];delete this.register[a]}return this};
|
|
|
|
u.remove=function(a){E(a)&&(a=a[this.key]);if(this.register[a]){for(var b=0;b<this.g.length&&(this.j[this.g[b]].remove(a,!0),!this.i||this.A);b++);if(this.C&&(!this.i||this.A))for(let c in this.h){b=this.h[c];const d=b.indexOf(a);-1!==d&&(1<b.length?b.splice(d,1):delete this.h[c])}this.store&&delete this.store[a];delete this.register[a]}return this};
|
|
|
|
t.search=function(a,b,d){const c=this;return aa(function*(){G(a)?(d=a,a=d.query):G(b)&&(d=b,b=0);let e=[];var f=[],g;let h;let k,l,r,q,u=0;if(d)if(d.constructor===Array){var m=d;d=null}else if(m=(g=d.pluck)||d.field||d.doc,l=d.tag,h=c.store&&d.enrich,r="and"===d.bool,b=d.limit||100,q=d.offset||0,m&&(E(m)?m=[m]:m.constructor!==Array&&(k=m,m=Object.keys(m))),l&&(E(l)&&(l=[l]),!a)){for(let w=0,n;w<l.length;w++){f=l[w];if((m=(g=c.h[f])&&g.length-q)&&0<m){if(m>b||q)g=g.slice(q,q+b);h&&(g=sa.call(c,g));
|
|
|
|
u.search=function(a,b,c,d){E(a)?(c=a,a=c.query):E(b)&&(c=b,b=0);let e=[],f=[],g,h,k,l,p,r,w,q=0;if(c)if(c.constructor===Array)k=c,c=null;else if(k=(g=c.pluck)||c.field||c.doc,p=c.tag,h=this.store&&c.enrich,r="and"===c.bool,b=c.limit||100,w=c.offset||0,k&&(D(k)?k=[k]:k.constructor!==Array&&(l=k,k=Object.keys(k))),p&&(D(p)&&(p=[p]),!a)){for(let m=0,n;m<p.length;m++)if(n=qa.call(this,p[m],b,w,h))e[e.length]=n,q++;return q?e:[]}k||(k=this.g);r=r&&(1<k.length||p&&1<p.length);if(!d&&(this.A||this.async)){d=
|
|
|
|
n={tag:f,result:g}}else n=void 0;n&&(e[e.length]=n,u++)}return u?e:[]}m||(m=c.g);r=r&&(1<m.length||l&&1<l.length);let x=[];if(c.l||c.async){for(let w=0,n;w<m.length;w++){var p=void 0;n=m[w];E(n)?k&&(p=k[n]):(p=n,n=n.field);x[w]=c.index[n].searchAsync(a,b,p||d)}x=yield Promise.all(x)}for(let w=0,n,B,K;w<m.length;w++){let X;B=m[w];E(B)?k&&(X=k[B]):(X=B,B=B.field);n=c.l||c.async?x[w]:c.index[B].search(a,b,X||d);K=n.length;if(l&&K){var z=[];p=0;r&&(z[0]=[n]);for(let F=0,L,C;F<l.length;F++)if(L=l[F],K=
|
|
|
|
[];for(let n=0,x;n<k.length;n++){var t=void 0;x=k[n];D(x)?l&&(t=l[x]):(t=x,x=x.field);d[n]=this.j[x].searchAsync(a,b,t||c)}const m=this;return Promise.all(d).then(function(n){m.search(a,b,c,n)})}for(let m=0,n,x,z;m<k.length;m++){let S;x=k[m];D(x)?l&&(S=l[x]):(S=x,x=x.field);n=d?d[m]:this.j[x].search(a,b,S||c);z=n.length;if(p&&z){t=[];let ja=0;r&&(t[0]=[n]);for(let T=0,ka,M;T<p.length;T++)if(ka=p[T],z=(M=this.h[ka])&&M.length)ja++,t[t.length]=r?[M]:M;ja&&(n=r?ea(t,b||100,w||0):fa(n,t),z=n.length)}if(z)f[q]=
|
|
|
|
(C=c.h[L])&&C.length)p++,z[z.length]=r?[C]:C;if(p){if(r)p=ka(z,b||100,q||0);else{p=n;const F=A(),L=A(),C=[];for(let D=0;D<p.length;D++)F[p[D]]=1;for(let D=0,Y;D<z.length;D++){Y=z[D];for(let Z=0,M;Z<Y.length;Z++)M=Y[Z],F[M]&&!L[M]&&(L[M]=1,C[C.length]=M)}p=C}n=p;K=n.length}}if(K)f[u]=B,e[u++]=n;else if(r)return[]}if(!u)return[];if(g&&(!h||!c.store))return e[0];for(let w=0,n;w<f.length;w++){n=e[w];n.length&&h&&(n=sa.call(c,n));if(g)return n;e[w]={field:f[w],result:n}}return e}())};
|
|
|
|
x,e[q++]=n;else if(r)return[]}if(!q)return[];if(g&&(!h||!this.store))return e[0];for(let m=0,n;m<f.length;m++){n=e[m];n.length&&h&&(n=ra.call(this,n));if(g)return n;e[m]={field:f[m],result:n}}return e};function qa(a,b,c,d){let e=this.h[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=ra.call(this,e));return{tag:a,result:e}}}function ra(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};
|
|
|
|
function sa(a){const b=Array(a.length);for(let d=0,c;d<a.length;d++)c=a[d],b[d]={key:c,doc:this.store[c]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};t.set=function(a,b){this.store[a]=b;return this};t.searchCache=la;
|
|
|
|
u.get=function(a){return this.store[a]};u.set=function(a,b){this.store[a]=b;return this};u.searchCache=ha;u.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.g.length){const f=this.g[d],g=this.j[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.h;break;case 2:c="store";f=this.store;break;default:return}la(a,this,c,d,e,f)}};
|
|
|
|
t.export=function(a,b,d,c,e){e||(e=0);c||(c=0);if(c<this.g.length){const f=this.g[c],g=this.index[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",c,e++)||(c++,e=1,b.export(a,b,f,c,e))})}else{let f;switch(e){case 1:d="tag";f=this.h;break;case 2:d="store";f=this.store;break;default:return}na(a,this,d,c,e,f)}};
|
|
|
|
u.import=function(a,b){if(b)switch(D(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.i=!1;this.register=b;for(let d=0,e;d<this.g.length;d++)e=this.j[this.g[d]],e.register=b,e.i=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.j[c].import(a,b)}};da(R.prototype);const X=self||window,Y={Index:L,Document:R,WorkerAdapter:P,registerCharset:function(a,b){ca[a]=b},registerLanguage:function(a,b){H[a]=b}};let Z;(Z=X.define)&&Z.amd?Z([],function(){return Y}):X.exports?X.exports=Y:X.FlexSearch=Y;}(module));
|
|
|
|
t.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "tag":this.h=b;break;case "reg":this.i=!1;this.register=b;for(let c=0,e;c<this.g.length;c++)e=this.index[this.g[c]],e.register=b,e.i=!1;break;case "store":this.store=b;break;default:a=a.split(".");const d=a[0];a=a[1];d&&a&&this.index[d].import(a,b)}};ja(T.prototype);window.FlexSearch={Index:O,Document:T,registerCharset:function(a,b){ia[a]=b},registerLanguage:function(a,b){ha[a]=b}};}).call(this);
|
|
|
|
|
|
|
|