var y;function J(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(l){return t(e(l))};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 G(t,i){return typeof t>"u"?i:t}function O(){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=Ht?t.normalize("NFKD").replace(Ht,"").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=O(),r,h,l=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 o=this.D.get(u);if(o||o===""){o&&s.push(o);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)){o="";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(o=0;u&&othis.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 U);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 U(t){this.limit=t&&t!==!0?t:1e3,this.cache=new Map,this.h=""}U.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)};U.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};U.prototype.remove=function(t){for(const i of this.cache){const e=i[0];i[1].includes(t)&&this.cache.delete(e)}};U.prototype.clear=function(){this.cache.clear(),this.h=""};const Wt={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"]]),Kt=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Zt=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],Qt={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:Wt,Default:pt,Normalize:pt,LatinBalance:{mapper:St},LatinAdvanced:{mapper:St,matcher:Kt,replacer:Zt},LatinExtra:{mapper:St,replacer:Zt.concat([/(?!^)[aeo]/g,""]),matcher:Kt},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 l=i.length;if(l&&(n=n.length?n.concat(i):i,e-=l,s&&(t.length-=l),!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,l,o;h=0)return r+o;r+=l.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)}F.prototype.get=function(t){const i=this.index[this.B(t)];return i&&i.get(t)};F.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 H(t=8){if(!this||this.constructor!==H)return new H(t);this.index=O(),this.h=[],this.size=0,t>32?(this.B=te,this.A=BigInt(t)):(this.B=qt,this.A=t)}H.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=F.prototype;y.has=H.prototype.has=function(t){const i=this.index[this.B(t)];return i&&i.has(t)};y.delete=H.prototype.delete=function(t){const i=this.index[this.B(t)];i&&i.delete(t)&&this.size--};y.clear=H.prototype.clear=function(){this.index=O(),this.h=[],this.size=0};y.values=H.prototype.values=function*(){for(let t=0;t=this.priority*this.priority*3):(zt=setTimeout(de,0),Xt=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 Q=0;function it(t={},i){function e(l){function o(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=l,this.h=O(),this.worker)return n?this.worker.on("message",o):this.worker.onmessage=o,t.config?new Promise(function(f){Q>1e9&&(Q=0),r.h[++Q]=function(){f(r)},r.worker.postMessage({id:Q,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(l){return e.call(r,l)}):e.call(this,h)}V("add");V("append");V("search");V("update");V("remove");V("clear");V("export");V("import");it.prototype.searchCache=Pt;$t(it.prototype);function V(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),Q>1e9&&(Q=0),i.h[++Q]=r,i.worker.postMessage({task:t,id:Q,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"),{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 l=0,o;li?t.slice(e,e+i):t,s?tt.call(this,t):t;let n=[];for(let r=0,h,l;r=l){e-=l;continue}h=h.slice(e,e+i),l=h.length,e=0}if(l>i&&(h=h.slice(0,i),l=i),!n.length&&l>=i)return s?tt.call(this,h):h;if(n.push(h),i-=l,!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,l=0,o,f,u,g,m;for(i=0;i1&&(e=e[i].apply(e,t.slice(1))),e}B.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}B.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 l;if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{let o=0;for(let f=0,u,g;f1?k.join(" "):k[0];let v;if(k&&j){for(var M=j.length,I=(Y.split?j.replace(Y.split,""):j).length-k.length,A="",$=0,R=0;R-1&&(A=(T?j.substring(0,T):"")+h+j.substring(T,T+P)+l+(T+P=o)break}if(z=gt.length*(r.length-2),d||a||o&&p.length-z>o)if(z=o+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(C>=w.length){S[v+1]=1,C>=x.length&&(z[v+1]=1);continue}M-=m}if(p=w[C].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<=o)p=" "+p,_[v]+=p;else if(f)K=o-M-1,K>0&&(p=" "+p.substring(0,K),_[v]+=p),S[v+1]=1;else{S[v+1]=1;continue}}else{if(S[v])continue;if(C-=I,b[C]){M-=m,S[v]=1,z[v]=1;continue}if(C<=0){if(C<0){S[v]=1,z[v]=1;continue}M-=m}if(p=w[C].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<=o)p+=" ",_[v]=p+_[v];else if(f)K=p.length+1-(o-M),K>=0&&K=x.length-1||C1?ee(o,e,s,h,r):(o=o[0])&&e&&o.length>e||s?o.slice(s,e+s):o;else{if(te||s)&&(o=o.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}o=n}}return o}function ee(t,i,e,s,n){const r=[],h=O();let l;var o=t.length;let f;if(s){for(n=o-1;n>=0;n--)if(f=(s=t[n])&&s.length){for(o=0;o=0;u--){g=t[u];for(let d=0;d1?yt(n,1,0,0,o,f):n[0],j)})}return d?n:new B(n.length>1?yt(n,1,0,0,o,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,I;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 B(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 Tt(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,l;n=0){if(r.length>1)return r.splice(h,1),1;if(delete t[n],e)return 1;l=1}else{if(l)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}}};W.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=O(),g=O(),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 l=this.score?this.score(i,a,d,h,p):at(m,f,d,n,p);Z(this,g,h,l,t,e)}break}case"bidirectional":case"reverse":if(n>1){for(l=n-1;l>0;l--){h=a[this.rtl?n-1-l:l]+h;var o=this.score?this.score(i,a,d,h,l):at(m,f,d,n,l);Z(this,g,h,o,t,e)}h=""}case"forward":if(n>1){for(l=0;l1&&dh;const c=this.score?this.score(i,h,d,a,l-1):at(n+(f/2>n?0:1),f,d,r-1,l-1);Z(this,u,o?h:a,c,t,e,o?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 Z(t,i,e,s,n,r,h){let l,o;if(!(l=i[e])||h&&!l[h]){if(h?(i=l||(i[e]=O()),i[h]=1,o=t.ctx,(l=o.get(h))?o=l:o.set(h,o=t.keystore?new F(t.keystore):new Map)):(o=t.map,i[e]=1),(l=o.get(e))?o=l:o.set(e,o=l=[]),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}W.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,l=0,o,f,u,g,m;e&&(t=e.query||t,i=e.limit||i,l=e.offset||0,r=e.context,h=e.suggest,m=(o=e.resolve)&&e.enrich,u=e.boost,g=e.resolution,f=this.db&&e.tag),typeof o>"u"&&(o=this.resolve),r=this.depth&&r!==!1;let d=this.encoder.encode(t,!r);if(n=d.length,i=i||(o?100:0),n===1)return Ut.call(this,d[0],"",i,l,o,m,f);if(n===2&&r&&!h)return Ut.call(this,d[1],d[0],i,l,o,m,f);let a=O(),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,l,h,o,m,f),e!==!1))return e;const x=this;return async function(){for(let w,b;c1)o=yt(t,i,e,s,n,r,h);else if(l===1)return h?Jt.call(null,t[0],e,s):new B(t[0],this);return h?o:new B(o,this)}function Ut(t,i,e,s,n,r,h){return t=Ot(this,t,i,e,s,n,r,h),this.db?t.then(function(l){return n?l||[]:new B(l,this)}):t&&t.length?n?Jt.call(this,t,e,s):new B(t,this):n?[]:new B([],this)}function Gt(t,i,e,s){let n=[];if(t&&t.length){if(t.length<=s){i.push(t);return}for(let r=0,h;re)&&(o=e,e=i,i=o),t.db?t.db.get(i,e,s,n,r,h,l):(t=e?(t=t.ctx.get(e))&&t.get(i):t.map.get(i),t)}function W(t,i){if(!this||this.constructor!==W)return new W(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 F(e):new Map,this.ctx=e?new F(e):new Map,this.reg=i||(this.fastupdate?e?new F(e):new Map:e?new H(e):new Set),this.N=s.resolution||3,this.rtl=n.rtl||t.rtl||!1,this.cache=(e=t.cache||null)&&new U(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=W.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=Tt(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=Lt(this.map,r),e="index.map=new Map(["+e+"]);";for(const h of this.ctx.entries()){n=h[0];let l=Lt(h[1],r);l="new Map(["+l+"])",l='["'+n+'",'+l+"]",s+=(s?",":"")+l}s="index.ctx=new Map(["+s+"]);"}return t?"function inject(index){"+i+e+s+"}":i+e+s};$t(W.prototype);const le=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),vt=["map","ctx","tag","reg","cfg"],L=O();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(),L[t.id]||(L[t.id]=[]),L[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,l.length>1)l.splice(f,1);else{s[h]=[];break}r+=l.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=W;let At=new oe;self.onmessage=t=>{switch(t.data.type){case"clear":At=new oe,postMessage({identifier:t.data.identifier});break;case"points":for(let e of t.data.points)At.add(e.id,e.text);postMessage({identifier:t.data.identifier});break;case"query":let i=At.search(t.data.query,{limit:t.data.limit});postMessage({identifier:t.data.identifier,result:i});break}};var _e=Object.freeze({__proto__:null});