(function(global,factory){typeof exports==='object'&&typeof module!=='undefined'?module.exports=factory():typeof define==='function'&&define.amd?define(factory):(global=global||self,global.Fuse=factory());}(this,(function(){'use strict';function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function(obj){return typeof obj;};}else{_typeof=function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};} return _typeof(obj);} function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}} function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0&&arguments[0]!==undefined?arguments[0]:3;var cache=new Map();return{get:function get(value){var numTokens=value.match(SPACE).length;if(cache.has(numTokens)){return cache.get(numTokens);} var n=parseFloat((1/Math.sqrt(numTokens)).toFixed(mantissa));cache.set(numTokens,n);return n;},clear:function clear(){cache.clear();}};} var FuseIndex=function(){function FuseIndex(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$getFn=_ref.getFn,getFn=_ref$getFn===void 0?Config.getFn:_ref$getFn;_classCallCheck(this,FuseIndex);this.norm=norm(3);this.getFn=getFn;this.isCreated=false;this.setIndexRecords();} _createClass(FuseIndex,[{key:"setSources",value:function setSources(){var docs=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.docs=docs;}},{key:"setIndexRecords",value:function setIndexRecords(){var records=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.records=records;}},{key:"setKeys",value:function setKeys(){var _this=this;var keys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.keys=keys;this._keysMap={};keys.forEach(function(key,idx){_this._keysMap[key.id]=idx;});}},{key:"create",value:function create(){var _this2=this;if(this.isCreated||!this.docs.length){return;} this.isCreated=true;if(isString(this.docs[0])){this.docs.forEach(function(doc,docIndex){_this2._addString(doc,docIndex);});}else{this.docs.forEach(function(doc,docIndex){_this2._addObject(doc,docIndex);});} this.norm.clear();}},{key:"add",value:function add(doc){var idx=this.size();if(isString(doc)){this._addString(doc,idx);}else{this._addObject(doc,idx);}}},{key:"removeAt",value:function removeAt(idx){this.records.splice(idx,1);for(var i=idx,len=this.size();i2&&arguments[2]!==undefined?arguments[2]:{},_ref2$getFn=_ref2.getFn,getFn=_ref2$getFn===void 0?Config.getFn:_ref2$getFn;var myIndex=new FuseIndex({getFn:getFn});myIndex.setKeys(keys.map(createKey));myIndex.setSources(docs);myIndex.create();return myIndex;} function parseIndex(data){var _ref3=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref3$getFn=_ref3.getFn,getFn=_ref3$getFn===void 0?Config.getFn:_ref3$getFn;var keys=data.keys,records=data.records;var myIndex=new FuseIndex({getFn:getFn});myIndex.setKeys(keys);myIndex.setIndexRecords(records);return myIndex;} function transformMatches(result,data){var matches=result.matches;data.matches=[];if(!isDefined(matches)){return;} matches.forEach(function(match){if(!isDefined(match.indices)||!match.indices.length){return;} var indices=match.indices,value=match.value;var obj={indices:indices,value:value};if(match.key){obj.key=match.key.src;} if(match.idx>-1){obj.refIndex=match.idx;} data.matches.push(obj);});} function transformScore(result,data){data.score=result.score;} function computeScore(pattern){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref$errors=_ref.errors,errors=_ref$errors===void 0?0:_ref$errors,_ref$currentLocation=_ref.currentLocation,currentLocation=_ref$currentLocation===void 0?0:_ref$currentLocation,_ref$expectedLocation=_ref.expectedLocation,expectedLocation=_ref$expectedLocation===void 0?0:_ref$expectedLocation,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation;var accuracy=errors/pattern.length;if(ignoreLocation){return accuracy;} var proximity=Math.abs(expectedLocation-currentLocation);if(!distance){return proximity?1.0:accuracy;} return accuracy+proximity/distance;} function convertMaskToIndices(){var matchmask=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var minMatchCharLength=arguments.length>1&&arguments[1]!==undefined?arguments[1]:Config.minMatchCharLength;var indices=[];var start=-1;var end=-1;var i=0;for(var len=matchmask.length;i=minMatchCharLength){indices.push([start,end]);} start=-1;}} if(matchmask[i-1]&&i-start>=minMatchCharLength){indices.push([start,i-1]);} return indices;} var MAX_BITS=32;function search(text,pattern,patternAlphabet){var _ref=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref$location=_ref.location,location=_ref$location===void 0?Config.location:_ref$location,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance,_ref$threshold=_ref.threshold,threshold=_ref$threshold===void 0?Config.threshold:_ref$threshold,_ref$findAllMatches=_ref.findAllMatches,findAllMatches=_ref$findAllMatches===void 0?Config.findAllMatches:_ref$findAllMatches,_ref$minMatchCharLeng=_ref.minMatchCharLength,minMatchCharLength=_ref$minMatchCharLeng===void 0?Config.minMatchCharLength:_ref$minMatchCharLeng,_ref$includeMatches=_ref.includeMatches,includeMatches=_ref$includeMatches===void 0?Config.includeMatches:_ref$includeMatches,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation;if(pattern.length>MAX_BITS){throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));} var patternLen=pattern.length;var textLen=text.length;var expectedLocation=Math.max(0,Math.min(location,textLen));var currentThreshold=threshold;var bestLocation=expectedLocation;var computeMatches=minMatchCharLength>1||includeMatches;var matchMask=computeMatches?Array(textLen):[];var index;while((index=text.indexOf(pattern,bestLocation))>-1){var score=computeScore(pattern,{currentLocation:index,expectedLocation:expectedLocation,distance:distance,ignoreLocation:ignoreLocation});currentThreshold=Math.min(score,currentThreshold);bestLocation=index+patternLen;if(computeMatches){var i=0;while(i=start;j-=1){var currentLocation=j-1;var charMatch=patternAlphabet[text.charAt(currentLocation)];if(computeMatches){matchMask[currentLocation]=+!!charMatch;} bitArr[j]=(bitArr[j+1]<<1|1)&charMatch;if(_i){bitArr[j]|=(lastBitArr[j+1]|lastBitArr[j])<<1|1|lastBitArr[j+1];} if(bitArr[j]&mask){finalScore=computeScore(pattern,{errors:_i,currentLocation:currentLocation,expectedLocation:expectedLocation,distance:distance,ignoreLocation:ignoreLocation});if(finalScore<=currentThreshold){currentThreshold=finalScore;bestLocation=currentLocation;if(bestLocation<=expectedLocation){break;} start=Math.max(1,2*expectedLocation-bestLocation);}}} var _score=computeScore(pattern,{errors:_i+1,currentLocation:expectedLocation,expectedLocation:expectedLocation,distance:distance,ignoreLocation:ignoreLocation});if(_score>currentThreshold){break;} lastBitArr=bitArr;} var result={isMatch:bestLocation>=0,score:Math.max(0.001,finalScore)};if(computeMatches){var indices=convertMaskToIndices(matchMask,minMatchCharLength);if(!indices.length){result.isMatch=false;}else if(includeMatches){result.indices=indices;}} return result;} function createPatternAlphabet(pattern){var mask={};for(var i=0,len=pattern.length;i1&&arguments[1]!==undefined?arguments[1]:{},_ref$location=_ref.location,location=_ref$location===void 0?Config.location:_ref$location,_ref$threshold=_ref.threshold,threshold=_ref$threshold===void 0?Config.threshold:_ref$threshold,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance,_ref$includeMatches=_ref.includeMatches,includeMatches=_ref$includeMatches===void 0?Config.includeMatches:_ref$includeMatches,_ref$findAllMatches=_ref.findAllMatches,findAllMatches=_ref$findAllMatches===void 0?Config.findAllMatches:_ref$findAllMatches,_ref$minMatchCharLeng=_ref.minMatchCharLength,minMatchCharLength=_ref$minMatchCharLeng===void 0?Config.minMatchCharLength:_ref$minMatchCharLeng,_ref$isCaseSensitive=_ref.isCaseSensitive,isCaseSensitive=_ref$isCaseSensitive===void 0?Config.isCaseSensitive:_ref$isCaseSensitive,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation;_classCallCheck(this,BitapSearch);this.options={location:location,threshold:threshold,distance:distance,includeMatches:includeMatches,findAllMatches:findAllMatches,minMatchCharLength:minMatchCharLength,isCaseSensitive:isCaseSensitive,ignoreLocation:ignoreLocation};this.pattern=isCaseSensitive?pattern:pattern.toLowerCase();this.chunks=[];if(!this.pattern.length){return;} var addChunk=function addChunk(pattern,startIndex){_this.chunks.push({pattern:pattern,alphabet:createPatternAlphabet(pattern),startIndex:startIndex});};var len=this.pattern.length;if(len>MAX_BITS){var i=0;var remainder=len%MAX_BITS;var end=len-remainder;while(i1&&arguments[1]!==undefined?arguments[1]:{},_ref$location=_ref.location,location=_ref$location===void 0?Config.location:_ref$location,_ref$threshold=_ref.threshold,threshold=_ref$threshold===void 0?Config.threshold:_ref$threshold,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance,_ref$includeMatches=_ref.includeMatches,includeMatches=_ref$includeMatches===void 0?Config.includeMatches:_ref$includeMatches,_ref$findAllMatches=_ref.findAllMatches,findAllMatches=_ref$findAllMatches===void 0?Config.findAllMatches:_ref$findAllMatches,_ref$minMatchCharLeng=_ref.minMatchCharLength,minMatchCharLength=_ref$minMatchCharLeng===void 0?Config.minMatchCharLength:_ref$minMatchCharLeng,_ref$isCaseSensitive=_ref.isCaseSensitive,isCaseSensitive=_ref$isCaseSensitive===void 0?Config.isCaseSensitive:_ref$isCaseSensitive,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation;_classCallCheck(this,FuzzyMatch);_this=_super.call(this,pattern);_this._bitapSearch=new BitapSearch(pattern,{location:location,threshold:threshold,distance:distance,includeMatches:includeMatches,findAllMatches:findAllMatches,minMatchCharLength:minMatchCharLength,isCaseSensitive:isCaseSensitive,ignoreLocation:ignoreLocation});return _this;} _createClass(FuzzyMatch,[{key:"search",value:function search(text){return this._bitapSearch.searchIn(text);}}],[{key:"type",get:function get(){return 'fuzzy';}},{key:"multiRegex",get:function get(){return /^"(.*)"$/;}},{key:"singleRegex",get:function get(){return /^(.*)$/;}}]);return FuzzyMatch;}(BaseMatch);var IncludeMatch=function(_BaseMatch){_inherits(IncludeMatch,_BaseMatch);var _super=_createSuper(IncludeMatch);function IncludeMatch(pattern){_classCallCheck(this,IncludeMatch);return _super.call(this,pattern);} _createClass(IncludeMatch,[{key:"search",value:function search(text){var location=0;var index;var indices=[];var patternLen=this.pattern.length;while((index=text.indexOf(this.pattern,location))>-1){location=index+patternLen;indices.push([index,location-1]);} var isMatch=!!indices.length;return{isMatch:isMatch,score:isMatch?1:0,indices:indices};}}],[{key:"type",get:function get(){return 'include';}},{key:"multiRegex",get:function get(){return /^'"(.*)"$/;}},{key:"singleRegex",get:function get(){return /^'(.*)$/;}}]);return IncludeMatch;}(BaseMatch);var searchers=[ExactMatch,IncludeMatch,PrefixExactMatch,InversePrefixExactMatch,InverseSuffixExactMatch,SuffixExactMatch,InverseExactMatch,FuzzyMatch];var searchersLen=searchers.length;var SPACE_RE=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;var OR_TOKEN='|';function parseQuery(pattern){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return pattern.split(OR_TOKEN).map(function(item){var query=item.trim().split(SPACE_RE).filter(function(item){return item&&!!item.trim();});var results=[];for(var i=0,len=query.length;i1&&arguments[1]!==undefined?arguments[1]:{},_ref$isCaseSensitive=_ref.isCaseSensitive,isCaseSensitive=_ref$isCaseSensitive===void 0?Config.isCaseSensitive:_ref$isCaseSensitive,_ref$includeMatches=_ref.includeMatches,includeMatches=_ref$includeMatches===void 0?Config.includeMatches:_ref$includeMatches,_ref$minMatchCharLeng=_ref.minMatchCharLength,minMatchCharLength=_ref$minMatchCharLeng===void 0?Config.minMatchCharLength:_ref$minMatchCharLeng,_ref$ignoreLocation=_ref.ignoreLocation,ignoreLocation=_ref$ignoreLocation===void 0?Config.ignoreLocation:_ref$ignoreLocation,_ref$findAllMatches=_ref.findAllMatches,findAllMatches=_ref$findAllMatches===void 0?Config.findAllMatches:_ref$findAllMatches,_ref$location=_ref.location,location=_ref$location===void 0?Config.location:_ref$location,_ref$threshold=_ref.threshold,threshold=_ref$threshold===void 0?Config.threshold:_ref$threshold,_ref$distance=_ref.distance,distance=_ref$distance===void 0?Config.distance:_ref$distance;_classCallCheck(this,ExtendedSearch);this.query=null;this.options={isCaseSensitive:isCaseSensitive,includeMatches:includeMatches,minMatchCharLength:minMatchCharLength,findAllMatches:findAllMatches,ignoreLocation:ignoreLocation,location:location,threshold:threshold,distance:distance};this.pattern=isCaseSensitive?pattern:pattern.toLowerCase();this.query=parseQuery(this.pattern,this.options);} _createClass(ExtendedSearch,[{key:"searchIn",value:function searchIn(text){var query=this.query;if(!query){return{isMatch:false,score:1};} var _this$options=this.options,includeMatches=_this$options.includeMatches,isCaseSensitive=_this$options.isCaseSensitive;text=isCaseSensitive?text:text.toLowerCase();var numMatches=0;var allIndices=[];var totalScore=0;for(var i=0,qLen=query.length;i2&&arguments[2]!==undefined?arguments[2]:{},_ref3$auto=_ref3.auto,auto=_ref3$auto===void 0?true:_ref3$auto;var next=function next(query){var keys=Object.keys(query);var isQueryPath=isPath(query);if(!isQueryPath&&keys.length>1&&!isExpression(query)){return next(convertToExplicit(query));} if(isLeaf(query)){var key=isQueryPath?query[KeyType.PATH]:keys[0];var pattern=isQueryPath?query[KeyType.PATTERN]:query[key];if(!isString(pattern)){throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));} var obj={keyId:createKeyId(key),pattern:pattern};if(auto){obj.searcher=createSearcher(pattern,options);} return obj;} var node={children:[],operator:keys[0]};keys.forEach(function(key){var value=query[key];if(isArray(value)){value.forEach(function(item){node.children.push(next(item));});}});return node;};if(!isExpression(query)){query=convertToExplicit(query);} return next(query);} var Fuse=function(){function Fuse(docs){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var index=arguments.length>2?arguments[2]:undefined;_classCallCheck(this,Fuse);this.options=_objectSpread2({},Config,{},options);if(this.options.useExtendedSearch&&!true){throw new Error(EXTENDED_SEARCH_UNAVAILABLE);} this._keyStore=new KeyStore(this.options.keys);this.setCollection(docs,index);} _createClass(Fuse,[{key:"setCollection",value:function setCollection(docs,index){this._docs=docs;if(index&&!(index instanceof FuseIndex)){throw new Error(INCORRECT_INDEX_TYPE);} this._myIndex=index||createIndex(this.options.keys,this._docs,{getFn:this.options.getFn});}},{key:"add",value:function add(doc){if(!isDefined(doc)){return;} this._docs.push(doc);this._myIndex.add(doc);}},{key:"remove",value:function remove(){var predicate=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){return(false);};var results=[];for(var i=0,len=this._docs.length;i1&&arguments[1]!==undefined?arguments[1]:{},_ref$limit=_ref.limit,limit=_ref$limit===void 0?-1:_ref$limit;var _this$options=this.options,includeMatches=_this$options.includeMatches,includeScore=_this$options.includeScore,shouldSort=_this$options.shouldSort,sortFn=_this$options.sortFn,ignoreFieldNorm=_this$options.ignoreFieldNorm;var results=isString(query)?isString(this._docs[0])?this._searchStringList(query):this._searchObjectList(query):this._searchLogical(query);computeScore$1(results,{ignoreFieldNorm:ignoreFieldNorm});if(shouldSort){results.sort(sortFn);} if(isNumber(limit)&&limit>-1){results=results.slice(0,limit);} return format(results,this._docs,{includeMatches:includeMatches,includeScore:includeScore});}},{key:"_searchStringList",value:function _searchStringList(query){var searcher=createSearcher(query,this.options);var records=this._myIndex.records;var results=[];records.forEach(function(_ref2){var text=_ref2.v,idx=_ref2.i,norm=_ref2.n;if(!isDefined(text)){return;} var _searcher$searchIn=searcher.searchIn(text),isMatch=_searcher$searchIn.isMatch,score=_searcher$searchIn.score,indices=_searcher$searchIn.indices;if(isMatch){results.push({item:text,idx:idx,matches:[{score:score,value:text,norm:norm,indices:indices}]});}});return results;}},{key:"_searchLogical",value:function _searchLogical(query){var _this=this;var expression=parse(query,this.options);var evaluate=function evaluate(node,item,idx){if(!node.children){var keyId=node.keyId,searcher=node.searcher;var matches=_this._findMatches({key:_this._keyStore.get(keyId),value:_this._myIndex.getValueForItemAtKeyId(item,keyId),searcher:searcher});if(matches&&matches.length){return[{idx:idx,item:item,matches:matches}];} return[];} switch(node.operator){case LogicalOperator.AND:{var res=[];for(var i=0,len=node.children.length;i2&&arguments[2]!==undefined?arguments[2]:{},_ref10$includeMatches=_ref10.includeMatches,includeMatches=_ref10$includeMatches===void 0?Config.includeMatches:_ref10$includeMatches,_ref10$includeScore=_ref10.includeScore,includeScore=_ref10$includeScore===void 0?Config.includeScore:_ref10$includeScore;var transformers=[];if(includeMatches)transformers.push(transformMatches);if(includeScore)transformers.push(transformScore);return results.map(function(result){var idx=result.idx;var data={item:docs[idx],refIndex:idx};if(transformers.length){transformers.forEach(function(transformer){transformer(result,data);});} return data;});} Fuse.version='6.4.3';Fuse.createIndex=createIndex;Fuse.parseIndex=parseIndex;Fuse.config=Config;{Fuse.parseQuery=parse;} {register(ExtendedSearch);} return Fuse;})));;var fuse;var resList=document.getElementById('searchResults');var sInput=document.getElementById('searchInput');var first,last=null var resultsAvailable=false;function loadSearch(){var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState===4){if(xhr.status===200){var data=JSON.parse(xhr.responseText);if(data){var options={isCaseSensitive:false,shouldSort:true,location:0,distance:100,threshold:0.4,minMatchCharLength:0,keys:['title','permalink','summary','content']};fuse=new Fuse(data,options);}}else{console.log(xhr.responseText);}}};xhr.open('GET',"../index.json");xhr.send();} function itemGen(name,link){return `
  • ${name} ยป
  • `} function activeToggle(){document.activeElement.parentElement.classList.toggle("active")} document.getElementById("searchInput").onkeyup=function(e){const results=fuse.search(this.value);if(results.length!==0){let resultSet='';for(let item in results){resultSet=resultSet+itemGen(results[item].item.title,results[item].item.permalink)} document.getElementById("searchResults").innerHTML=resultSet;resultsAvailable=true;first=resList.firstChild;last=resList.lastChild;}else{resultsAvailable=false;document.getElementById("searchResults").innerHTML='';}} document.onkeydown=function(e){let key=e.key;let ae=document.activeElement;if(key==="ArrowDown"&&resultsAvailable){e.preventDefault();if(ae==sInput){activeToggle();resList.firstChild.lastChild.focus();activeToggle();}else if(ae.parentElement==last){}else{activeToggle();ae.parentElement.nextSibling.lastChild.focus();activeToggle();}}else if(key==="ArrowUp"&&resultsAvailable){e.preventDefault();if(ae==sInput){}else if(ae.parentElement==first){activeToggle();sInput.focus();}else{activeToggle();ae.parentElement.previousSibling.lastChild.focus();activeToggle();}}else if(key==="ArrowRight"&&resultsAvailable){ae.click();}else if(key==="Escape"){resultsAvailable=false;document.getElementById("searchResults").innerHTML=sInput.value='';sInput.focus();}} document.onmousedown=function(e){if(e.type==="mousedown"){e.preventDefault();}}