#80, Add search index configuration

This commit is contained in:
Alex Shpak 2019-10-27 11:58:58 +01:00
parent b4307e7c09
commit a5788d71fa
8 changed files with 88 additions and 74 deletions

View File

@ -163,6 +163,11 @@ disableKinds = ['taxonomy', 'taxonomyTerm']
# (Optional, default true) Enables search function with lunr.js,
# Index is built on fly, therefore it might slowdown your website.
BookSearch = true
# (Optional, default none) Search config for flexsearch index.
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
BookSearchConfig = '{ cache: true }'
```
### Page Configuration

View File

@ -1,30 +1,25 @@
'use strict';
(function() {
const pages = [
{{ range $index, $page := .Site.Pages }}
{{- if $index -}},{{- end }}
{
'idx': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "docs/title" $page) | jsonify }},
'content': {{ $page.Plain | jsonify }}
}
{{- end -}}
];
const indexCfg = {{ with .Site.Params.BookSearchConfig }}
{{ . }}
{{ end }};
var index = new FlexSearch({
cache: true,
encode: 'balance',
/* tokenize: function(str) {
return str.replace(/[\x00-\x7F]/g, ' ').split('');
} */
indexCfg.doc = {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href'],
};
const index = FlexSearch.create('balance', indexCfg);
window.bookSearchIndex = index;
{{ range $index, $page := .Site.Pages }}
index.add({
'id': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "docs/title" $page) | jsonify }},
'content': {{ $page.Plain | jsonify }}
});
pages.forEach(function(page, x) {
index.add(x, pages[x].content);
})
window.bookSearch = {
pages: pages,
index: index,
}
{{- end -}}
})();

View File

@ -1,5 +1,6 @@
{{- $searchData := resources.Get "search-data.js" | resources.ExecuteAsTemplate "search-data.js" . | resources.Minify | resources.Fingerprint }}
'use strict';
{{- $searchData := resources.Get "search-data.js" | resources.ExecuteAsTemplate "search-data.js" . | resources.Minify | resources.Fingerprint }}
(function() {
const input = document.querySelector('#book-search-input');
const results = document.querySelector('#book-search-results');
@ -8,10 +9,10 @@
input.addEventListener('keyup', search);
function init() {
input.removeEventListener('focus', init); //init once
input.removeEventListener('focus', init); // init once
input.required = true;
loadScript('{{ "flexsearch.light.js" | relURL }}');
loadScript('{{ "flexsearch.min.js" | relURL }}');
loadScript('{{ $searchData.RelPermalink }}', function() {
input.required = false;
search();
@ -27,9 +28,8 @@
return;
}
let searchHits = window.bookSearch.index.search(input.value, 10);
searchHits.forEach(function(hit) {
const page = window.bookSearch.pages[hit];
const searchHits = window.bookSearchIndex.search(input.value, 10);
searchHits.forEach(function(page) {
const li = document.createElement('li'),
a = li.appendChild(document.createElement('a'));
@ -47,6 +47,6 @@
script.src = src;
script.onload = callback;
document.head.append(script);
document.head.appendChild(script);
}
})();

View File

@ -1,10 +1,9 @@
# hugo server --minify --themesDir ... --baseURL=http://0.0.0.0:1313/example
# hugo server --minify --themesDir ... --baseURL=http://0.0.0.0:1313/theme/hugo-book/
baseURL = 'https://example.com/'
title = 'Hugo Book'
theme = 'hugo-book'
disableKinds = ['taxonomy', 'taxonomyTerm']
# themesDir = '../..'
# Book configuration
disablePathToLower = true
@ -49,3 +48,8 @@ pygmentsCodeFences = true
# (Optional, default true) Enables search function with lunr.js,
# Index is built on fly, therefore it might slowdown your website.
BookSearch = true
# (Optional, default none) Search config for flexsearch index.
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
BookSearchConfig = '{ cache: true }'

View File

@ -1,10 +1,9 @@
# hugo server --minify --themesDir ... --baseURL=http://0.0.0.0:1313/example
# hugo server --minify --themesDir ... --baseURL=http://0.0.0.0:1313/theme/hugo-book/
baseURL: https://example.com/
title: Hugo Book
theme: hugo-book
disableKinds: ['taxonomy', 'taxonomyTerm']
# themesDir: ../..
# Book configuration
disablePathToLower: true
@ -49,3 +48,9 @@ params:
# (Optional, default true) Enables search function with lunr.js,
# Index is built on fly, therefore it might slowdown your website.
BookSearch: true
# (Optional, default none) Search config for flexsearch index.
# Read documentation at https://github.com/nextapps-de/flexsearch#usage. By default 'balance' preset is used.
# This option allows to set specific configs for languages support. Must be valid JavaScript object.
BookSearchConfig: |
{ cache: true }

View File

@ -1,17 +0,0 @@
---
title: 結任了出興自園更市標告之絕
bookHidden: true
---
# 結任了出興自園更市標告之絕
問希和企一我……開父天營歡母不黨信現人發。
加你區然沒一破?感花好千現學稱好?計現生,響時加過法素種際說國……陸國教快這展四冷論機人語力減社,路調好……臉水不國清司的態已及力如未三團身;大力看國叫晚線不式。校精到過,個亞有可放世來年和於後。
功細能色,色是任金言!學門他應全品原表便家人大就。
牛生美服食方未問始沒害被般不……響具線?
而技爸技推立出少屋須?男才太西個輕明深應工、原而克說國快我檢為的單調請出消動教處負四無空、三電引,力二約說空表消字代!到人岸傳、著人野中活!
去一作情離論才,再男反整。設如大點重主理個故……面目定辦我些!的我頭來裡品生有適西管以依越同究民國自情以助受人:要家的受好客童把叫的通,預把工那子電作,根品行消……高華然片內聞員、有是老道世心,皮急結告,商這同給……遠蘭裡:化委長教人再;再的她適認是國有評都的城一識小廣分方提爾現馬多,數曾突為備長竟重深知舉書校母印的兒部竟法由念,學代品道量百著別旅!參還理登你下府意生有公生將題必今的用能從父人見動北死作國!

View File

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

42
static/flexsearch.min.js vendored Normal file
View File

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