/** * Fuse.js v6.6.2 - Lightweight fuzzy-search (http://fusejs.io) * * Copyright (c) 2023 Kiro Risk (http://kiro.me) * All Rights Reserved. Apache Software License 2.0 * * http://www.apache.org/licenses/LICENSE-2.0 */ var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(_).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),a=parseFloat(Math.round(o*r)/r);return n.set(i,a),a},clear:function(){n.clear()}}}var j=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?S.getFn:n,o=t.fieldNormWeight,a=void 0===o?S.fieldNormWeight:o;r(this,e),this.norm=O(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,l(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();l(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?S.getFn:r,o=n.fieldNormWeight,a=void 0===o?S.fieldNormWeight:o,c=new j({getFn:i,fieldNormWeight:a});return c.setKeys(e.map(M)),c.setSources(t),c.create(),c}function E(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,a=t.expectedLocation,c=void 0===a?0:a,s=t.distance,h=void 0===s?S.distance:s,u=t.ignoreLocation,l=void 0===u?S.ignoreLocation:u,f=r/e.length;if(l)return f;var d=Math.abs(c-o);return h?f+d/h:d?1:f}function I(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:S.minMatchCharLength,n=[],r=-1,i=-1,o=0,a=e.length;o=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}var F=32;function C(e){for(var t={},n=0,r=e.length;n1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,a=void 0===o?S.location:o,c=i.threshold,s=void 0===c?S.threshold:c,h=i.distance,u=void 0===h?S.distance:h,l=i.includeMatches,f=void 0===l?S.includeMatches:l,d=i.findAllMatches,v=void 0===d?S.findAllMatches:d,g=i.minMatchCharLength,y=void 0===g?S.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?S.isCaseSensitive:p,b=i.ignoreLocation,k=void 0===b?S.ignoreLocation:b;if(r(this,e),this.options={location:a,threshold:s,distance:u,includeMatches:f,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:k},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var M=function(e,t){n.chunks.push({pattern:e,alphabet:C(e),startIndex:t})},w=this.pattern.length;if(w>F){for(var x=0,L=w%F,_=w-L;x<_;)M(this.pattern.substr(x,F),x),x+=F;if(L){var O=w-F;M(this.pattern.substr(O),O)}}else M(this.pattern,0)}}return o(e,[{key:"searchIn",value:function(e){var t=this.options,n=t.isCaseSensitive,r=t.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var i={isMatch:!0,score:0};return r&&(i.indices=[[0,e.length-1]]),i}var o=this.options,a=o.location,s=o.distance,h=o.threshold,u=o.findAllMatches,l=o.minMatchCharLength,f=o.ignoreLocation,d=[],v=0,g=!1;this.chunks.forEach((function(t){var n=t.pattern,i=t.alphabet,o=t.startIndex,y=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?S.location:i,a=r.distance,c=void 0===a?S.distance:a,s=r.threshold,h=void 0===s?S.threshold:s,u=r.findAllMatches,l=void 0===u?S.findAllMatches:u,f=r.minMatchCharLength,d=void 0===f?S.minMatchCharLength:f,v=r.includeMatches,g=void 0===v?S.includeMatches:v,y=r.ignoreLocation,p=void 0===y?S.ignoreLocation:y;if(t.length>F)throw new Error(m(F));for(var b,k=t.length,M=e.length,w=Math.max(0,Math.min(o,M)),x=h,L=w,_=d>1||g,O=_?Array(M):[];(b=e.indexOf(t,L))>-1;){var j=E(t,{currentLocation:b,expectedLocation:w,distance:c,ignoreLocation:p});if(x=Math.min(j,x),L=b+k,_)for(var A=0;A=K;R-=1){var U=R-1,B=n[e.charAt(U)];if(_&&(O[U]=+!!B),J[R]=(J[R+1]<<1|1)&B,T&&(J[R]|=(C[R+1]|C[R])<<1|1|C[R+1]),J[R]&W&&(N=E(t,{errors:T,currentLocation:U,expectedLocation:w,distance:c,ignoreLocation:p}))<=x){if(x=N,(L=U)<=w)break;K=Math.max(1,2*w-L)}}if(E(t,{errors:T+1,currentLocation:w,expectedLocation:w,distance:c,ignoreLocation:p})>x)break;C=J}var V={isMatch:L>=0,score:Math.max(.001,N)};if(_){var q=I(O,d);q.length?g&&(V.indices=q):V.isMatch=!1}return V}(e,n,i,{location:a+o,distance:s,threshold:h,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:f}),p=y.isMatch,b=y.score,k=y.indices;p&&(g=!0),v+=b,p&&k&&(d=[].concat(c(d),c(k)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=d),y}}]),e}(),P=[];function W(e,t){for(var n=0,r=P.length;n-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function D(e,t){t.score=e.score}function K(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?S.includeMatches:r,o=n.includeScore,a=void 0===o?S.includeScore:o,c=[];return i&&c.push($),a&&c.push(D),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return c.length&&c.forEach((function(t){t(e,r)})),r}))}var z=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(r(this,e),this.options=t(t({},S),i),this.options.useExtendedSearch)throw new Error(p);this._keyStore=new k(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof j))throw new Error("Incorrect 'index' type");this._myIndex=t||A(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){v(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n1&&void 0!==arguments[1]?arguments[1]:{},n=t.limit,r=void 0===n?-1:n,i=this.options,o=i.includeMatches,a=i.includeScore,c=i.shouldSort,s=i.sortFn,h=i.ignoreFieldNorm,u=l(e)?l(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return T(u,{ignoreFieldNorm:h}),c&&u.sort(s),f(r)&&r>-1&&(u=u.slice(0,r)),K(u,this._docs,{includeMatches:o,includeScore:a})}},{key:"_searchStringList",value:function(e){var t=W(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(v(n)){var a=t.searchIn(n),c=a.isMatch,s=a.score,h=a.indices;c&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:h}]})}})),r}},{key:"_searchLogical",value:function(e){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(e){var t=this,n=W(e,this.options),r=this._myIndex,i=r.keys,o=r.records,a=[];return o.forEach((function(e){var r=e.$,o=e.i;if(v(r)){var s=[];i.forEach((function(e,i){s.push.apply(s,c(t._findMatches({key:e,value:r[i],searcher:n})))})),s.length&&a.push({idx:o,item:r,matches:s})}})),a}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!v(n))return[];var i=[];if(u(n))n.forEach((function(e){var n=e.v,o=e.i,a=e.n;if(v(n)){var c=r.searchIn(n),s=c.isMatch,h=c.score,u=c.indices;s&&i.push({score:h,key:t,value:n,idx:o,norm:a,indices:u})}}));else{var o=n.v,a=n.n,c=r.searchIn(o),s=c.isMatch,h=c.score,l=c.indices;s&&i.push({score:h,key:t,value:o,norm:a,indices:l})}return i}}]),e}();return z.version="6.6.2",z.createIndex=A,z.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?S.getFn:n,i=t.fieldNormWeight,o=void 0===i?S.fieldNormWeight:i,a=e.keys,c=e.records,s=new j({getFn:r,fieldNormWeight:o});return s.setKeys(a),s.setIndexRecords(c),s},z.config=S,z},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t();