9 lines
19 KiB
JavaScript
9 lines
19 KiB
JavaScript
/**
|
|
* Fuse.js v7.4.0 - Lightweight fuzzy-search (http://fusejs.io)
|
|
*
|
|
* Copyright (c) 2026 Kiro Risk (http://kiro.me)
|
|
* All Rights Reserved. Apache Software License 2.0
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*/
|
|
function e(e){return Array.isArray?Array.isArray(e):"[object Array]"===u(e)}function t(e){return null==e?"":function(e){if("string"==typeof e)return e;if("bigint"==typeof e)return e.toString();const t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}function s(e){return"string"==typeof e}function n(e){return"number"==typeof e}function i(e){return!0===e||!1===e||function(e){return function(e){return"object"==typeof e}(e)&&null!==e}(e)&&"[object Boolean]"==u(e)}function r(e){return null!=e}function o(e){return!e.trim().length}function u(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const c="Invalid doc index: must be a non-negative integer within the bounds of the docs array",h=Object.prototype.hasOwnProperty;class a{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{const s=l(e);this._keys.push(s),this._keyMap[s.id]=s,t+=s.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function l(t){let n=null,i=null,r=null,o=1,u=null;if(s(t)||e(t))r=t,n=d(t),i=f(t);else{if(!h.call(t,"name"))throw new Error((e=>`Missing ${e} property in key`)("name"));const e=t.name;if(r=e,h.call(t,"weight")&&void 0!==t.weight&&(o=t.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(f(e)));n=d(e),i=f(e),u=t.getFn??null}return{path:n,id:i,weight:o,src:r,getFn:u}}function d(t){return e(t)?t:t.split(".")}function f(t){return e(t)?t.join("."):t}const g={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:function(o,u){const c=[];let h=!1;const a=(o,u,l,d)=>{if(r(o))if(u[l]){const f=o[u[l]];if(!r(f))return;if(l===u.length-1&&(s(f)||n(f)||i(f)||"bigint"==typeof f))c.push(void 0!==d?{v:t(f),i:d}:t(f));else if(e(f)){h=!0;for(let e=0,t=f.length;e<t;e+=1)a(f[e],u,l+1,e)}else u.length&&a(f,u,l+1,d)}else c.push(void 0!==d?{v:o,i:d}:o)};return a(o,s(u)?u.split("."):u,0),h?c:c[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},A=Object.freeze({isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...g});class m{constructor({getFn:e=A.getFn,fieldNormWeight:t=A.fieldNormWeight}={}){this.norm=function(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(t){let i=1,r=!1;for(let e=0;e<t.length;e++)32===t.charCodeAt(e)?r||(i++,r=!0):r=!1;if(s.has(i))return s.get(i);const o=Math.round(n/Math.pow(i,.5*e))/n;return s.set(i,o),o},clear(){s.clear()}}}(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(s(this.docs[0]))for(let s=0;s<e;s++){const e=this._createStringRecord(this.docs[s],s);e&&(this.records[t++]=e)}else for(let s=0;s<e;s++)this.records[t++]=this._createObjectRecord(this.docs[s],s);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(c);if(s(e)){const s=this._createStringRecord(e,t);return s&&this.records.push(s),s}const n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(c);for(let t=0,s=this.records.length;t<s;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,s=this.records.length;t<s;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const s of e)Number.isInteger(s)&&s>=0&&t.add(s);if(0===t.size)return;this.records=this.records.filter(e=>!t.has(e.i));const s=Array.from(t).sort((e,t)=>e-t);for(const e of this.records){let t=0,n=s.length;for(;t<n;){const i=t+n>>>1;s[i]<e.i?t=i+1:n=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!r(e)||o(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(n,i){const u={i:i,$:{}};for(let i=0,c=this.keys.length;i<c;i++){const c=this.keys[i],h=c.getFn?c.getFn(n):this.getFn(n,c.path);if(r(h))if(e(h)){const e=[];for(let n=0,i=h.length;n<i;n+=1){const i=h[n];if(r(i))if(s(i)){if(!o(i)){const t={v:i,i:n,n:this.norm.get(i)};e.push(t)}}else if(r(i.v)){const n=s(i.v)?i.v:t(i.v);if(!o(n)){const t={v:n,i:i.i,n:this.norm.get(n)};e.push(t)}}}u.$[i]=e}else if(s(h)&&!o(h)){const e={v:h,n:this.norm.get(h)};u.$[i]=e}}return u}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}}function C(e,t,{getFn:s=A.getFn,fieldNormWeight:n=A.fieldNormWeight}={}){const i=new m({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(l)),i.setSources(t),i.create(),i}const p=32;function F(e,t,s,{location:n=A.location,distance:i=A.distance,threshold:r=A.threshold,findAllMatches:o=A.findAllMatches,minMatchCharLength:u=A.minMatchCharLength,includeMatches:c=A.includeMatches,ignoreLocation:h=A.ignoreLocation}={}){if(t.length>p)throw new Error(`Pattern length exceeds max of ${p}.`);const a=t.length,l=e.length,d=Math.max(0,Math.min(n,l));let f=r,g=d;const m=(e,t)=>{const s=e/a;if(h)return s;const n=Math.abs(d-t);return i?s+n/i:n?1:s},C=u>1||c,F=C?Array(l):[];let E;for(;(E=e.indexOf(t,g))>-1;){const e=m(0,E);if(f=Math.min(e,f),g=E+a,C){let e=0;for(;e<a;)F[E+e]=1,e+=1}}g=-1;let _=[],D=1,y=0,B=a+l;const v=1<<a-1;for(let t=0;t<a;t+=1){let n=0,i=B;for(;n<i;){m(t,d+i)<=f?n=i:B=i,i=Math.floor((B-n)/2+n)}B=i;let r=Math.max(1,d-i+1);const u=o?l:Math.min(d+i,l)+a,c=Array(u+2);c[u+1]=(1<<t)-1;for(let n=u;n>=r;n-=1){const i=n-1,o=s[e[i]];if(c[n]=(c[n+1]<<1|1)&o,t&&(c[n]|=(_[n+1]|_[n])<<1|1|_[n+1]),c[n]&v&&(D=m(t,i),D<=f)){if(f=D,g=i,y=t,g<=d)break;r=Math.max(1,2*d-g)}}if(m(t+1,d)>f)break;_=c}if(C&&g>=0){const t=Math.min(l-1,g+a-1+y);for(let n=g;n<=t;n+=1)s[e[n]]&&(F[n]=1)}const M={isMatch:g>=0,score:Math.max(.001,D)};if(C){const e=function(e=[],t=A.minMatchCharLength){const s=[];let n=-1,i=-1,r=0;for(let o=e.length;r<o;r+=1){const o=e[r];o&&-1===n?n=r:o||-1===n||(i=r-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[r-1]&&r-n>=t&&s.push([n,r-1]),s}(F,u);e.length?c&&(M.indices=e):M.isMatch=!1}return M}function E(e){const t={};for(let s=0,n=e.length;s<n;s+=1){const i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}const _={"\u0142":"l","\u0141":"L","\u0111":"d","\u0110":"D","\xf8":"o","\xd8":"O","\u0127":"h","\u0126":"H","\u0167":"t","\u0166":"T","\u0131":"i","\xdf":"ss"},D=new RegExp("["+Object.keys(_).join("")+"]","g"),y="function"==typeof String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(D,e=>_[e]):e=>e;class B{constructor(e,{location:t=A.location,threshold:s=A.threshold,distance:n=A.distance,includeMatches:i=A.includeMatches,findAllMatches:r=A.findAllMatches,minMatchCharLength:o=A.minMatchCharLength,isCaseSensitive:u=A.isCaseSensitive,ignoreDiacritics:c=A.ignoreDiacritics,ignoreLocation:h=A.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:n,includeMatches:i,findAllMatches:r,minMatchCharLength:o,isCaseSensitive:u,ignoreDiacritics:c,ignoreLocation:h},e=u?e:e.toLowerCase(),e=c?y(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const a=(e,t)=>{this.chunks.push({pattern:e,alphabet:E(e),startIndex:t})},l=this.pattern.length;if(l>p){let e=0;const t=l%p,s=l-t;for(;e<s;)a(this.pattern.substr(e,p),e),e+=p;if(t){const e=l-p;a(this.pattern.substr(e),e)}}else a(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:s,includeMatches:n}=this.options;if(e=t?e:e.toLowerCase(),e=s?y(e):e,this.pattern===e){const t={isMatch:!0,score:0};return n&&(t.indices=[[0,e.length-1]]),t}const{location:i,distance:r,threshold:o,findAllMatches:u,minMatchCharLength:c,ignoreLocation:h}=this.options,a=[];let l=0,d=!1;this.chunks.forEach(({pattern:t,alphabet:s,startIndex:f})=>{const{isMatch:g,score:A,indices:m}=F(e,t,s,{location:i+f,distance:r,threshold:o,findAllMatches:u,minMatchCharLength:c,includeMatches:n,ignoreLocation:h});g&&(d=!0),l+=A,g&&m&&a.push(...m)});const f={isMatch:d,score:d?l/this.chunks.length:1};return d&&n&&(f.indices=function(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);const t=[e[0]];for(let s=1,n=e.length;s<n;s+=1){const n=t[t.length-1],i=e[s];i[0]<=n[1]+1?n[1]=Math.max(n[1],i[1]):t.push(i)}return t}(a)),f}}const v=[];function M(e,t){for(let s=0,n=v.length;s<n;s+=1){const n=v[s];if(n.condition(e,t))return new n(e,t)}return new B(e,t)}function k(e,{ignoreFieldNorm:t=A.ignoreFieldNorm}){let s=1;return e.forEach(({key:e,norm:n,score:i})=>{const r=e?e.weight:null;s*=Math.pow(0===i&&r?Number.EPSILON:i,(r||1)*(t?1:n))}),s}class w{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){const t=this.heap;for(;e>0;){const s=e-1>>1;if(t[e].score<=t[s].score)break;const n=t[e];t[e]=t[s],t[s]=n,e=s}}_sinkDown(e){const t=this.heap,s=t.length;let n=e;do{const i=2*(e=n)+1,r=2*e+2;if(i<s&&t[i].score>t[n].score&&(n=i),r<s&&t[r].score>t[n].score&&(n=r),n!==e){const s=t[e];t[e]=t[n],t[n]=s}}while(n!==e)}}function S(e,t,{includeMatches:s=A.includeMatches,includeScore:n=A.includeScore}={}){return e.map(e=>{const{idx:i}=e,o={item:t[i],refIndex:i};return s&&(o.matches=function(e){const t=[];return e.matches.forEach(e=>{if(!r(e.indices)||!e.indices.length)return;const s={indices:e.indices,value:e.value};e.key&&(s.key=e.key.id),e.idx>-1&&(s.refIndex=e.idx),t.push(s)}),t}(e)),n&&(o.score=e.score),o})}const x=/[\p{L}\p{M}\p{N}_]+/gu;function I({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const n=function(e){return"function"==typeof e?t=>e(t):e instanceof RegExp?(e.global,t=>t.match(e)||[]):e=>e.match(x)||[]}(s);return{tokenize:s=>(e||(s=s.toLowerCase()),t&&(s=y(s)),n(s))}}function b(e,t,s,n){const i=n.tokenize(t);if(!i.length)return;e.fieldCount++,e.docFieldCount.set(s,(e.docFieldCount.get(s)||0)+1);const r=new Set(i);let o=e.docTermFieldHits.get(s);o||(o=new Map,e.docTermFieldHits.set(s,o));for(const t of r)o.set(t,(o.get(t)||0)+1),e.df.set(t,(e.df.get(t)||0)+1)}function N(e,t,s,n){const{i:i,v:r,$:o}=t;if(void 0===r){if(o)for(let t=0;t<s;t++){const s=o[t];if(s)if(Array.isArray(s))for(const t of s)b(e,t.v,i,n);else b(e,s.v,i,n)}}else b(e,r,i,n)}function L(e,t){const s=e.docFieldCount.get(t);if(void 0===s)return;e.fieldCount-=s,e.docFieldCount.delete(t);const n=e.docTermFieldHits.get(t);if(n){for(const[t,s]of n){const n=(e.df.get(t)||0)-s;n<=0?e.df.delete(t):e.df.set(t,n)}e.docTermFieldHits.delete(t)}}function T(e,t){if(0===t.length)return;const s=Array.from(new Set(t)).sort((e,t)=>e-t);for(const t of s)L(e,t);const n=e=>{let t=0,n=s.length;for(;t<n;){const i=t+n>>>1;s[i]<e?t=i+1:n=i}return e-t},i=s[0],r=new Map;for(const[t,s]of e.docFieldCount)r.set(t>i?n(t):t,s);e.docFieldCount=r;const o=new Map;for(const[t,s]of e.docTermFieldHits)o.set(t>i?n(t):t,s);e.docTermFieldHits=o}class z{constructor(e,t,s){if(this.options={...A,...t},this.options.useExtendedSearch)throw new Error("Extended search is not available");if(this.options.useTokenSearch)throw new Error("Token search is not available");this._keyStore=new a(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,s),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=M(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof m))throw new Error("Incorrect 'index' type");if(this._myIndex=t||C(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const e=I({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=function(e,t,s){const n={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of e)N(n,i,t,s);return n}(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!r(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const e=I({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});!function(e,t,s,n){N(e,t,s,n)}(this._invertedIndex,t,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}remove(e=()=>!1){const t=[],s=[];for(let n=0,i=this._docs.length;n<i;n+=1)e(this._docs[n],n)&&(t.push(this._docs[n]),s.push(n));if(s.length){this._invertedIndex&&T(this._invertedIndex,s);const e=new Set(s);this._docs=this._docs.filter((t,s)=>!e.has(s)),this._myIndex.removeAll(s),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error(c);this._invertedIndex&&T(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(e,t){const{limit:i=-1}=t||{},{includeMatches:r,includeScore:o,shouldSort:u,sortFn:c,ignoreFieldNorm:h}=this.options;if(s(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return n(i)&&i>-1&&(e=e.slice(0,i)),e}let a;if(n(i)&&i>0&&s(e)){const t=new w(i);s(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:h}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:h}),a=t.extractSorted(c)}else a=s(e)?s(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),function(e,{ignoreFieldNorm:t=A.ignoreFieldNorm}){e.forEach(e=>{e.score=k(e.matches,{ignoreFieldNorm:t})})}(a,{ignoreFieldNorm:h}),u&&a.sort(c),n(i)&&i>-1&&(a=a.slice(0,i));return S(a,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e,{heap:t,ignoreFieldNorm:s}={}){const n=this._getSearcher(e),i=this.options.useTokenSearch&&"all"===this.options.tokenMatch,{records:o}=this._myIndex,u=t?null:[];return o.forEach(({v:e,i:o,n:c})=>{if(!r(e))return;const h=n.searchIn(e);if(h.isMatch){const n={score:h.score,value:e,norm:c,indices:h.indices};i&&(n.matchedMask=h.matchedMask,n.matchedTerms=h.matchedTerms,n.termCount=h.termCount);const r=[n];if(!i||this._coversAllTokens(r)){const n={item:e,idx:o,matches:r};t?(n.score=k(n.matches,{ignoreFieldNorm:s}),t.shouldInsert(n.score)&&t.insert(n)):u.push(n)}}}),u}_searchLogical(e){throw new Error("Logical search is not available")}_searchObjectList(e,{heap:t,ignoreFieldNorm:s}={}){const n=this._getSearcher(e),i=this.options.useTokenSearch&&"all"===this.options.tokenMatch,{keys:o,records:u}=this._myIndex,c=t?null:[];return u.forEach(({$:e,i:u})=>{if(!r(e))return;const h=[];let a=!1,l=!1;if(o.forEach((t,s)=>{const i=this._findMatches({key:t,value:e[s],searcher:n});i.length?(h.push(...i),i[0].hasInverse&&(l=!0)):a=!0}),(!l||!a)&&h.length&&(!i||this._coversAllTokens(h))){const n={idx:u,item:e,matches:h};t?(n.score=k(n.matches,{ignoreFieldNorm:s}),t.shouldInsert(n.score)&&t.insert(n)):c.push(n)}}),c}_findMatches({key:t,value:s,searcher:n}){if(!r(s))return[];const i=[];if(e(s))s.forEach(({v:e,i:s,n:o})=>{if(!r(e))return;const u=n.searchIn(e);if(u.isMatch){const n={score:u.score,key:t,value:e,idx:s,norm:o,indices:u.indices,hasInverse:u.hasInverse};void 0!==u.termCount&&(n.matchedMask=u.matchedMask,n.matchedTerms=u.matchedTerms,n.termCount=u.termCount),i.push(n)}});else{const{v:e,n:r}=s,o=n.searchIn(e);if(o.isMatch){const s={score:o.score,key:t,value:e,norm:r,indices:o.indices,hasInverse:o.hasInverse};void 0!==o.termCount&&(s.matchedMask=o.matchedMask,s.matchedTerms=o.matchedTerms,s.termCount=o.termCount),i.push(s)}}return i}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(void 0===t)return!0;if(t<=31){let s=0;for(let t=0;t<e.length;t++)s|=e[t].matchedMask||0;return s===2**t-1}const s=new Set;for(let t=0;t<e.length;t++){const n=e[t].matchedTerms;if(n)for(const e of n)s.add(e)}return s.size===t}}z.version="7.4.0",z.createIndex=C,z.parseIndex=function(e,{getFn:t=A.getFn,fieldNormWeight:s=A.fieldNormWeight}={}){const{keys:n,records:i}=e,r=new m({getFn:t,fieldNormWeight:s});return r.setKeys(n),r.setIndexRecords(i),r},z.config=A,z.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error("Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.");return M(e,{...A,...s}).searchIn(t)},z.use=function(...e){e.forEach(e=>function(...e){v.push(...e)}(e))};export{z as default}; |