var y;function R(t,i,e){const s=typeof e,n=typeof t;if(s!=="undefined"){if(n!=="undefined"){if(e){if(n==="function"&&s===n)return function(o){return t(e(o))};if(i=t.constructor,i===e.constructor){if(i===Array)return e.concat(t);if(i===Map){var r=new Map(e);for(var h of t)r.set(h[0],h[1]);return r}if(i===Set){h=new Set(e);for(r of t.values())h.add(r);return h}}}return t}return e}return n==="undefined"?i:t}function U(t,i){return typeof t>"u"?i:t}function I(){return Object.create(null)}function N(t){return typeof t=="string"}function lt(t){return typeof t=="object"}function ot(t,i){if(N(i))t=t[i];else for(let e=0;t&&e1?this.addMatcher(t,i):(this.mapper||(this.mapper=new Map),this.mapper.set(t,i),this.cache&&D(this),this)};y.addMatcher=function(t,i){return typeof t=="object"?this.addReplacer(t,i):t.length<2&&(this.dedupe||this.mapper)?this.addMapper(t,i):(this.matcher||(this.matcher=new Map),this.matcher.set(t,i),this.h+=(this.h?"|":"")+t,this.J=null,this.cache&&D(this),this)};y.addReplacer=function(t,i){return typeof t=="string"?this.addMatcher(t,i):(this.replacer||(this.replacer=[]),this.replacer.push(t,i),this.cache&&D(this),this)};y.encode=function(t,i){if(this.cache&&t.length<=this.H)if(this.F){if(this.B.has(t))return this.B.get(t)}else this.F=setTimeout(D,50,this);this.normalize&&(typeof this.normalize=="function"?t=this.normalize(t):t=Wt?t.normalize("NFKD").replace(Wt,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace(ce,"$1 $2").replace(ge,"$1 $2").replace(ue,"$1 "));const e=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let s=[],n=I(),r,h,o=this.split||this.split===""?t.split(this.split):[t];for(let f=0,u,g;fthis.maxlength)){if(i){if(n[u])continue;n[u]=1}else{if(r===u)continue;r=u}if(e)s.push(u);else if(!this.filter||(typeof this.filter=="function"?this.filter(u):!this.filter.has(u))){if(this.cache&&u.length<=this.I)if(this.F){var l=this.D.get(u);if(l||l===""){l&&s.push(l);continue}}else this.F=setTimeout(D,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));let m;for(;m!==u&&u.length>2;)m=u,u=u.replace(this.K,d=>this.stemmer.get(d))}if(u&&(this.mapper||this.dedupe&&u.length>1)){l="";for(let m=0,d="",a,c;m1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),u=u.replace(this.J,m=>this.matcher.get(m))),u&&this.replacer)for(l=0;u&&lthis.L&&(this.D.clear(),this.I=this.I/1.1|0)),u){if(u!==g)if(i){if(n[u])continue;n[u]=1}else{if(h===u)continue;h=u}s.push(u)}}}return this.finalize&&(s=this.finalize(s)||s),this.cache&&t.length<=this.H&&(this.B.set(t,s),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),s};function D(t){t.F=null,t.B.clear(),t.D.clear()}function Pt(t,i,e){e||(i||typeof t!="object"?typeof i=="object"&&(e=i,i=0):e=t),e&&(t=e.query||t,i=e.limit||i);let s=""+(i||0);e&&(s+=(e.offset||0)+!!e.context+!!e.suggest+(e.resolve!==!1)+(e.resolution||this.resolution)+(e.boost||0)),t=(""+t).toLowerCase(),this.cache||(this.cache=new G);let n=this.cache.get(t+s);if(!n){const r=e&&e.cache;r&&(e.cache=!1),n=this.search(t,i,e),r&&(e.cache=r),this.cache.set(t+s,n)}return n}function G(t){this.limit=t&&t!==!0?t:1e3,this.cache=new Map,this.h=""}G.prototype.set=function(t,i){this.cache.set(this.h=t,i),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)};G.prototype.get=function(t){const i=this.cache.get(t);return i&&this.h!==t&&(this.cache.delete(t),this.cache.set(this.h=t,i)),i};G.prototype.remove=function(t){for(const i of this.cache){const e=i[0];i[1].includes(t)&&this.cache.delete(e)}};G.prototype.clear=function(){this.cache.clear(),this.h=""};const Jt={normalize:!1,numeric:!1,dedupe:!1},pt={},St=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]),Zt=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Qt=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],Vt={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,ß:2,d:3,t:3,l:4,m:5,n:5,r:6};var Et={Exact:Jt,Default:pt,Normalize:pt,LatinBalance:{mapper:St},LatinAdvanced:{mapper:St,matcher:Zt,replacer:Qt},LatinExtra:{mapper:St,replacer:Qt.concat([/(?!^)[aeo]/g,""]),matcher:Zt},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(t){for(let e=0;e=h.length)i-=h.length;else{i=h[s?"splice":"slice"](i,e);const o=i.length;if(o&&(n=n.length?n.concat(i):i,e-=o,s&&(t.length-=o),!e))break;i=0}return n}function et(t){if(!this||this.constructor!==et)return new et(t);this.index=t?[t]:[],this.length=t?t.length:0;const i=this;return new Proxy([],{get(e,s){if(s==="length")return i.length;if(s==="push")return function(n){i.index[i.index.length-1].push(n),i.length++};if(s==="pop")return function(){if(i.length)return i.length--,i.index[i.index.length-1].pop()};if(s==="indexOf")return function(n){let r=0;for(let h=0,o,l;h=0)return r+l;r+=o.length}return-1};if(s==="includes")return function(n){for(let r=0;r32?(this.B=te,this.A=BigInt(t)):(this.B=qt,this.A=t)}H.prototype.get=function(t){const i=this.index[this.B(t)];return i&&i.get(t)};H.prototype.set=function(t,i){var e=this.B(t);let s=this.index[e];s?(e=s.size,s.set(t,i),(e-=s.size)&&this.size++):(this.index[e]=s=new Map([[t,i]]),this.h.push(s),this.size++)};function W(t=8){if(!this||this.constructor!==W)return new W(t);this.index=I(),this.h=[],this.size=0,t>32?(this.B=te,this.A=BigInt(t)):(this.B=qt,this.A=t)}W.prototype.add=function(t){var i=this.B(t);let e=this.index[i];e?(i=e.size,e.add(t),(i-=e.size)&&this.size++):(this.index[i]=e=new Set([t]),this.h.push(e),this.size++)};y=H.prototype;y.has=W.prototype.has=function(t){const i=this.index[this.B(t)];return i&&i.has(t)};y.delete=W.prototype.delete=function(t){const i=this.index[this.B(t)];i&&i.delete(t)&&this.size--};y.clear=W.prototype.clear=function(){this.index=I(),this.h=[],this.size=0};y.values=W.prototype.values=function*(){for(let t=0;t=this.priority*this.priority*3):(Bt=setTimeout(de,0),Yt=Date.now()),mt){const r=this;return new Promise(h=>{setTimeout(function(){h(r[t+"Async"].apply(r,i))},0)})}const n=this[t].apply(this,i);return e=n.then?n:new Promise(r=>r(n)),s&&e.then(s),e}}let V=0;function it(t={},i){function e(o){function l(f){f=f.data||f;const u=f.id,g=u&&r.h[u];g&&(g(f.msg),delete r.h[u])}if(this.worker=o,this.h=I(),this.worker)return n?this.worker.on("message",l):this.worker.onmessage=l,t.config?new Promise(function(f){V>1e9&&(V=0),r.h[++V]=function(){f(r)},r.worker.postMessage({id:V,task:"init",factory:s,options:t})}):(this.priority=t.priority||4,this.encoder=i||null,this.worker.postMessage({task:"init",factory:s,options:t}),this)}if(!this||this.constructor!==it)return new it(t);let s=typeof self<"u"?self._factory:typeof window<"u"?window._factory:null;s&&(s=s.toString());const n=typeof window>"u",r=this,h=ae(s,n,t.worker);return h.then?h.then(function(o){return e.call(r,o)}):e.call(this,h)}X("add");X("append");X("search");X("update");X("remove");X("clear");X("export");X("import");it.prototype.searchCache=Pt;$t(it.prototype);function X(t){it.prototype[t]=function(){const i=this,e=[].slice.call(arguments);var s=e[e.length-1];let n;return typeof s=="function"&&(n=s,e.pop()),s=new Promise(function(r){t==="export"&&typeof e[0]=="function"&&(e[0]=null),V>1e9&&(V=0),i.h[++V]=r,i.worker.postMessage({task:t,id:V,args:e})}),n?(s.then(n),this):s}}function ae(t,i,e){return i?typeof module<"u"?new(require("worker_threads")).Worker(__dirname+"/worker/node.js"):Promise.resolve().then(function(){return _e}).then(function(s){return new s.Worker(import.meta.dirname+"/node/node.mjs")}):t?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+pe.toString()],{type:"text/javascript"}))):new window.Worker(typeof e=="string"?e:import.meta.url.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js","module/worker/worker.js").replace("flexsearch.bundle.module.min.mjs","module/worker/worker.js"),{type:"module"})}nt.prototype.add=function(t,i,e){if(lt(t)&&(i=t,t=ot(i,this.key)),i&&(t||t===0)){if(!e&&this.reg.has(t))return this.update(t,i);for(let o=0,l;oi?t.slice(e,e+i):t,s?tt.call(this,t):t;let n=[];for(let r=0,h,o;r=o){e-=o;continue}h=h.slice(e,e+i),o=h.length,e=0}if(o>i&&(h=h.slice(0,i),o=i),!n.length&&o>=i)return s?tt.call(this,h):h;if(n.push(h),i-=o,!i)break}return n=n.length>1?[].concat.apply([],n):n[0],s?tt.call(this,n):n}function bt(t,i,e,s){var n=s[0];if(n[0]&&n[0].query)return t[i].apply(t,n);if(!(i!=="and"&&i!=="not"||t.result.length||t.await||n.suggest))return s.length>1&&(n=s[s.length-1]),(s=n.resolve)?t.await||t.result:t;let r=[],h=0,o=0,l,f,u,g,m;for(i=0;i1&&(e=e[i].apply(e,t.slice(1))),e}A.prototype.or=function(){return bt(this,"or",me,arguments)};function me(t,i,e,s,n,r,h){return t.length&&(this.result.length&&t.push(this.result),t.length<2?this.result=t[0]:(this.result=ee(t,i,e,!1,this.h),e=0)),n&&(this.await=null),n?this.resolve(i,e,s,h):this}A.prototype.and=function(){return bt(this,"and",we,arguments)};function we(t,i,e,s,n,r,h){if(!r&&!this.result.length)return n?this.result:this;let o;if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{let l=0;for(let f=0,u,g;f1?k.join(" "):k[0];let v;if(k&&j){for(var M=j.length,C=(L.split?j.replace(L.split,""):j).length-k.length,B="",$=0,T=0;T-1&&(B=(K?j.substring(0,K):"")+h+j.substring(K,K+P)+o+(K+P=l)break}if(z=gt.length*(r.length-2),d||a||l&&p.length-z>l)if(z=l+z-m*2,S=_-b,d>0&&(S+=d),a>0&&(S+=a),S<=z)x=d?b-(d>0?d:0):b-((z-S)/2|0),w=a?_+(a>0?a:0):x+z,f||(x>0&&p.charAt(x)!==" "&&p.charAt(x-1)!==" "&&(x=p.indexOf(" ",x),x<0&&(x=0)),w=w.length-1){if(O>=w.length){S[v+1]=1,O>=x.length&&(z[v+1]=1);continue}M-=m}if(p=w[O].text,P=a&&k[v])if(P>0){if(p.length>P)if(S[v+1]=1,f)p=p.substring(0,P);else continue;(P-=p.length)||(P=-1),k[v]=P}else{S[v+1]=1;continue}if(M+p.length+1<=l)p=" "+p,_[v]+=p;else if(f)Z=l-M-1,Z>0&&(p=" "+p.substring(0,Z),_[v]+=p),S[v+1]=1;else{S[v+1]=1;continue}}else{if(S[v])continue;if(O-=C,b[O]){M-=m,S[v]=1,z[v]=1;continue}if(O<=0){if(O<0){S[v]=1,z[v]=1;continue}M-=m}if(p=w[O].text,P=d&&j[v])if(P>0){if(p.length>P)if(S[v]=1,f)p=p.substring(p.length-P);else continue;(P-=p.length)||(P=-1),j[v]=P}else{S[v]=1;continue}if(M+p.length+1<=l)p+=" ",_[v]=p+_[v];else if(f)Z=p.length+1-(l-M),Z>=0&&Z=x.length-1||O1?ee(l,e,s,h,r):(l=l[0])&&e&&l.length>e||s?l.slice(s,e+s):l;else{if(te||s)&&(l=l.slice(s,e+s));else{n=[];for(let g=0,m;gs)s-=m.length;else if((e&&m.length>e||s)&&(m=m.slice(s,e+s),e-=m.length,s&&(s-=m.length)),n.push(m),!e)break}l=n}}return l}function ee(t,i,e,s,n){const r=[],h=I();let o;var l=t.length;let f;if(s){for(n=l-1;n>=0;n--)if(f=(s=t[n])&&s.length){for(l=0;l=0;u--){g=t[u];for(let d=0;d1?yt(n,1,0,0,l,f):n[0],j)})}return d?n:new A(n.length>1?yt(n,1,0,0,l,f):n[0],this)}}d||h||!(g=g||this.field)||(N(g)?h=g:(g.constructor===Array&&g.length===1&&(g=g[0]),h=g.field||g.index)),g&&g.constructor!==Array&&(g=[g])}g||(g=this.field);let z;w=(this.worker||this.db)&&!s&&[];for(let j=0,k,M,C;j"u"&&(this.db?w.push(c=this.index.get(this.field[0]).db.enrich(c)):c=tt.call(this,c)),h)return d?a?wt(t,c,this.index,h,a):c:new A(c,this);n[x]={field:r[x],result:c}}if(p&&this.db&&w.length){const j=this;return Promise.all(w).then(function(k){for(let M=0;M0&&((e&&i>e||s)&&(t=t.slice(s,s+e)),n&&(t=tt.call(this,t))),t):[]):[]}function tt(t){if(!this||!this.store)return t;if(this.db)return this.index.get(this.field[0]).db.enrich(t);const i=Array(t.length);for(let e=0,s;e1?e:e[0]}y.append=function(t,i){return this.add(t,i,!0)};y.update=function(t,i){return this.remove(t).add(t,i)};y.remove=function(t){lt(t)&&(t=ot(t,this.key));for(var i of this.index.values())i.remove(t,!0);if(this.reg.has(t)){if(this.tag&&!this.fastupdate)for(let e of this.tag.values())for(let s of e){i=s[0];const n=s[1],r=n.indexOf(t);r>-1&&(n.length>1?n.splice(r,1):e.delete(i))}this.store&&this.store.delete(t),this.reg.delete(t)}return this.cache&&this.cache.remove(t),this};y.clear=function(){const t=[];for(const i of this.index.values()){const e=i.clear();e.then&&t.push(e)}if(this.tag)for(const i of this.tag.values())i.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),t.length?Promise.all(t):this};y.contain=function(t){return this.db?this.index.get(this.field[0]).db.has(t):this.reg.has(t)};y.cleanup=function(){for(const t of this.index.values())t.cleanup();return this};y.get=function(t){return this.db?this.index.get(this.field[0]).db.enrich(t).then(function(i){return i[0]&&i[0].doc||null}):this.store.get(t)||null};y.set=function(t,i){return typeof t=="object"&&(i=t,t=ot(i,this.key)),this.store.set(t,i),this};y.searchCache=Pt;y.export=je;y.import=Me;$t(nt.prototype);function Kt(t,i=0){let e=[],s=[];i&&(i=25e4/i*5e3|0);for(const n of t.entries())s.push(n),s.length===i&&(e.push(s),s=[]);return s.length&&e.push(s),e}function Nt(t,i){i||(i=new Map);for(let e=0,s;e2?e[0]:"";if(e=e.length>2?e[2]:e[1],this.worker&&s)return this.index.get(s).import(t);if(i){if(typeof i=="string"&&(i=JSON.parse(i)),s)return this.index.get(s).import(e,i);switch(e){case"reg":this.fastupdate=!1,this.reg=re(i,this.reg);for(let n=0,r;n=0&&n.splice(h,1)}}else ut(this.map,t),this.depth&&ut(this.ctx,t);i||this.reg.delete(t)}return this.db&&(this.commit_task.push({del:t}),this.M&&he(this)),this.cache&&this.cache.remove(t),this};function ut(t,i){let e=0;var s=typeof i>"u";if(t.constructor===Array){for(let n=0,r,h,o;n=0){if(r.length>1)return r.splice(h,1),1;if(delete t[n],e)return 1;o=1}else{if(o)return 1;e++}}}else for(let n of t.entries())s=n[0],ut(n[1],i)?e++:t.delete(s);return e}const Se={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(t,i,e,s){if(i&&(t||t===0)){if(!s&&!e&&this.reg.has(t))return this.update(t,i);s=this.depth,i=this.encoder.encode(i,!s);const f=i.length;if(f){const u=I(),g=I(),m=this.resolution;for(let d=0;d2){for(let c=1,p,x,w,b;c2){for(let c=0,p;cc;r--){h=a.substring(c,r),p=this.rtl?n-1-c:c;var o=this.score?this.score(i,a,d,h,p):at(m,f,d,n,p);Q(this,g,h,o,t,e)}break}case"bidirectional":case"reverse":if(n>1){for(o=n-1;o>0;o--){h=a[this.rtl?n-1-o:o]+h;var l=this.score?this.score(i,a,d,h,o):at(m,f,d,n,o);Q(this,g,h,l,t,e)}h=""}case"forward":if(n>1){for(o=0;o1&&dh;const c=this.score?this.score(i,h,d,a,o-1):at(n+(f/2>n?0:1),f,d,r-1,o-1);Q(this,u,l?h:a,c,t,e,l?a:h)}}}}this.fastupdate||this.reg.add(t)}}return this.db&&(this.commit_task.push(e?{ins:t}:{del:t}),this.M&&he(this)),this};function Q(t,i,e,s,n,r,h){let o,l;if(!(o=i[e])||h&&!o[h]){if(h?(i=o||(i[e]=I()),i[h]=1,l=t.ctx,(o=l.get(h))?l=o:l.set(h,l=t.keystore?new H(t.keystore):new Map)):(l=t.map,i[e]=1),(o=l.get(e))?l=o:l.set(e,l=o=[]),r){for(let f=0,u;f1?i+(s||0)<=t?e+(n||0):(t-1)/(i+(s||0))*(e+(n||0))+1|0:0}J.prototype.search=function(t,i,e){if(e||(i||typeof t!="object"?typeof i=="object"&&(e=i,i=0):(e=t,t="")),e&&e.cache)return e.cache=!1,t=this.searchCache(t,i,e),e.cache=!0,t;let s=[],n,r,h,o=0,l,f,u,g,m;e&&(t=e.query||t,i=e.limit||i,o=e.offset||0,r=e.context,h=e.suggest,m=(l=e.resolve)&&e.enrich,u=e.boost,g=e.resolution,f=this.db&&e.tag),typeof l>"u"&&(l=this.resolve),r=this.depth&&r!==!1;let d=this.encoder.encode(t,!r);if(n=d.length,i=i||(l?100:0),n===1)return Gt.call(this,d[0],"",i,o,l,m,f);if(n===2&&r&&!h)return Gt.call(this,d[1],d[0],i,o,l,m,f);let a=I(),c=0,p;if(r&&(p=d[0],c=1),g||g===0||(g=p?this.N:this.resolution),this.db){if(this.db.search&&(e=this.db.search(this,d,i,o,h,l,m,f),e!==!1))return e;const x=this;return(async function(){for(let w,b;c1)l=yt(t,i,e,s,n,r,h);else if(o===1)return h?Rt.call(null,t[0],e,s):new A(t[0],this);return h?l:new A(l,this)}function Gt(t,i,e,s,n,r,h){return t=Ot(this,t,i,e,s,n,r,h),this.db?t.then(function(o){return n?o||[]:new A(o,this)}):t&&t.length?n?Rt.call(this,t,e,s):new A(t,this):n?[]:new A([],this)}function Ut(t,i,e,s){let n=[];if(t&&t.length){if(t.length<=s){i.push(t);return}for(let r=0,h;re)&&(l=e,e=i,i=l),t.db?t.db.get(i,e,s,n,r,h,o):(t=e?(t=t.ctx.get(e))&&t.get(i):t.map.get(i),t)}function J(t,i){if(!this||this.constructor!==J)return new J(t);if(t){var e=N(t)?t:t.preset;e&&(t=Object.assign({},Se[e],t))}else t={};e=t.context;const s=e===!0?{depth:1}:e||{},n=N(t.encoder)?Et[t.encoder]:t.encode||t.encoder||{};this.encoder=n.encode?n:typeof n=="object"?new ft(n):{encode:n},this.resolution=t.resolution||9,this.tokenize=e=(e=t.tokenize)&&e!=="default"&&e!=="exact"&&e||"strict",this.depth=e==="strict"&&s.depth||0,this.bidirectional=s.bidirectional!==!1,this.fastupdate=!!t.fastupdate,this.score=t.score||null,(e=t.keystore||0)&&(this.keystore=e),this.map=e?new H(e):new Map,this.ctx=e?new H(e):new Map,this.reg=i||(this.fastupdate?e?new H(e):new Map:e?new W(e):new Set),this.N=s.resolution||3,this.rtl=n.rtl||t.rtl||!1,this.cache=(e=t.cache||null)&&new G(e),this.resolve=t.resolve!==!1,(e=t.db)&&(this.db=this.mount(e)),this.M=t.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=t.priority||4}y=J.prototype;y.mount=function(t){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),t.mount(this)};y.commit=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this)};y.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};function he(t){t.commit_timer||(t.commit_timer=setTimeout(function(){t.commit_timer=null,t.db.commit(t)},1))}y.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this};y.append=function(t,i){return this.add(t,i,!0)};y.contain=function(t){return this.db?this.db.has(t):this.reg.has(t)};y.update=function(t,i){const e=this,s=this.remove(t);return s&&s.then?s.then(()=>e.add(t,i)):this.add(t,i)};y.cleanup=function(){return this.fastupdate?(ut(this.map),this.depth&&ut(this.ctx),this):this};y.searchCache=Pt;y.export=function(t,i,e=0,s=0){let n,r;switch(s){case 0:n="reg",r=se(this.reg);break;case 1:n="cfg",r=null;break;case 2:n="map",r=Kt(this.map,this.reg.size);break;case 3:n="ctx",r=ie(this.ctx,this.reg.size);break;default:return}return kt.call(this,t,i,n,r,e,s)};y.import=function(t,i){if(i)switch(typeof i=="string"&&(i=JSON.parse(i)),t=t.split("."),t[t.length-1]==="json"&&t.pop(),t.length===3&&t.shift(),t=t.length>1?t[1]:t[0],t){case"reg":this.fastupdate=!1,this.reg=re(i,this.reg);break;case"map":this.map=Nt(i,this.map);break;case"ctx":this.ctx=ne(i,this.ctx)}};y.serialize=function(t=!0){let i="",e="",s="";if(this.reg.size){let r;for(var n of this.reg.keys())r||(r=typeof n),i+=(i?",":"")+(r==="string"?'"'+n+'"':n);i="index.reg=new Set(["+i+"]);",e=Ft(this.map,r),e="index.map=new Map(["+e+"]);";for(const h of this.ctx.entries()){n=h[0];let o=Ft(h[1],r);o="new Map(["+o+"])",o='["'+n+'",'+o+"]",s+=(s?",":"")+o}s="index.ctx=new Map(["+s+"]);"}return t?"function inject(index){"+i+e+s+"}":i+e+s};$t(J.prototype);const le=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),vt=["map","ctx","tag","reg","cfg"],F=I();function It(t,i={}){if(!this||this.constructor!==It)return new It(t,i);typeof t=="object"&&(i=t,t=t.name),t||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(t?":"+t.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=i.field?i.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=i.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}y=It.prototype;y.mount=function(t){return t.index?t.mount(this):(t.db=this,this.open())};y.open=function(){if(this.db)return this.db;let t=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),F[t.id]||(F[t.id]=[]),F[t.id].push(t.field);const i=le.open(t.id,1);return i.onupgradeneeded=function(){const e=t.db=this.result;for(let s=0,n;s=u.length){s-=u.length;continue}const g=e?s+Math.min(u.length-s,e):u.length;for(let m=s;m=r.length?[]:!i&&!e?r:(r=r.slice(e,e+i),s?n.enrich(r):r)})};y.enrich=function(t){typeof t!="object"&&(t=[t]);const i=this.db.transaction("reg","readonly").objectStore("reg"),e=[];for(let s=0;s=0)if(n=1,o.length>1)o.splice(f,1);else{s[h]=[];break}r+=o.length}if(e)break}r?n&&t.update(s):t.delete(),t.continue()}y.remove=function(t){return typeof t!="object"&&(t=[t]),Promise.all([this.transaction("map","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&_t(e,t)}}),this.transaction("ctx","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&_t(e,t)}}),this.transaction("tag","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&_t(e,t,!0)}}),this.transaction("reg","readwrite",function(i){for(let e=0;e{t.onsuccess=t.oncomplete=function(){i&&i(this.result),i=null,e(this.result)},t.onerror=t.onblocked=s,t=null})}const oe=J;let zt=new oe;self.onmessage=t=>{switch(t.data.type){case"clear":zt=new oe,postMessage({identifier:t.data.identifier});break;case"points":for(let e of t.data.points)zt.add(e.id,e.text);postMessage({identifier:t.data.identifier});break;case"query":let i=zt.search(t.data.query,{limit:t.data.limit});postMessage({identifier:t.data.identifier,result:i});break}};var _e=Object.freeze({__proto__:null});