9 lines
25 KiB
JavaScript
9 lines
25 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 i(e){return"number"==typeof e}function n(e){return!0===e||!1===e||function(e){return r(e)&&null!==e}(e)&&"[object Boolean]"==u(e)}function r(e){return"object"==typeof e}function o(e){return null!=e}function c(e){return!e.trim().length}function u(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const h="Invalid doc index: must be a non-negative integer within the bounds of the docs array",a=Object.prototype.hasOwnProperty;class l{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{const s=d(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 d(t){let i=null,n=null,r=null,o=1,c=null;if(s(t)||e(t))r=t,i=f(t),n=g(t);else{if(!a.call(t,"name"))throw new Error((e=>`Missing ${e} property in key`)("name"));const e=t.name;if(r=e,a.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`)(g(e)));i=f(e),n=g(e),c=t.getFn??null}return{path:i,id:n,weight:o,src:r,getFn:c}}function f(t){return e(t)?t:t.split(".")}function g(t){return e(t)?t.join("."):t}const m={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:function(r,c){const u=[];let h=!1;const a=(r,c,l,d)=>{if(o(r))if(c[l]){const f=r[c[l]];if(!o(f))return;if(l===c.length-1&&(s(f)||i(f)||n(f)||"bigint"==typeof f))u.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],c,l+1,e)}else c.length&&a(f,c,l+1,d)}else u.push(void 0!==d?{v:r,i:d}:r)};return a(r,s(c)?c.split("."):c,0),h?u:u[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},p=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,...m});class A{constructor({getFn:e=p.getFn,fieldNormWeight:t=p.fieldNormWeight}={}){this.norm=function(e=1,t=3){const s=new Map,i=Math.pow(10,t);return{get(t){let n=1,r=!1;for(let e=0;e<t.length;e++)32===t.charCodeAt(e)?r||(n++,r=!0):r=!1;if(s.has(n))return s.get(n);const o=Math.round(i/Math.pow(n,.5*e))/i;return s.set(n,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(h);if(s(e)){const s=this._createStringRecord(e,t);return s&&this.records.push(s),s}const i=this._createObjectRecord(e,t);return this.records.push(i),i}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(h);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,i=s.length;for(;t<i;){const n=t+i>>>1;s[n]<e.i?t=n+1:i=n}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return
|