hugo-theme-wondermod/assets/js/search.min.44919f7faa51ee430e35f2ae11a3f5c43ba1adb982b6f9f1c75ba66c7a0536d2.js
2022-04-15 15:51:05 +00:00

1 line
16 KiB
JavaScript

var e=this,t=function(){"use strict";function y(t,s){var e,n=Object.keys(t);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(t),s&&(e=e.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,e)),n}function a(n){for(var e,t=1;t<arguments.length;t++)e=null!=arguments[t]?arguments[t]:{},t%2?y(Object(e),!0).forEach(function(t){N(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):y(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))});return n}function h(e){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function j(s,n){for(var e,t=0;t<n.length;t++)e=n[t],e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(s,e.key,e)}function c(e,t,n){return t&&j(e.prototype,t),n&&j(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return m(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=n[t];return s}function o(e){return Array.isArray?Array.isArray(e):"[object Array]"===b(e)}function s(e){return"string"==typeof e}function x(e){return"number"==typeof e}function D(e){return!0===e||!1===e||function(e){return function(e){return"object"===h(e)}(e)&&null!==e}(e)&&"[object Boolean]"==b(e)}function t(e){return null!=e}function f(e){return!e.trim().length}function b(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var n,i,d,p,v,k="Extended search is not available",F=function(e){return"Pattern length exceeds max of ".concat(e,".")},g=Object.prototype.hasOwnProperty,S=function(){function e(s){var t,n=this;l(this,e),this._keys=[],this._keyMap={},t=0,s.forEach(function(s){var e=C(s);t+=e.weight,n._keys.push(e),n._keyMap[e.id]=e,t+=e.weight}),this._keys.forEach(function(e){e.weight/=t})}return c(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function C(e){var t,n=null,i=null,a=null,r=1;if(s(e)||o(e))a=e,n=_(e),i=w(e);else{if(!g.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));if(t=e.name,a=t,g.call(e,"weight")&&(r=e.weight)<=0)throw new Error(function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")}(t));n=_(t),i=w(t)}return{path:n,id:i,weight:r,src:a}}function _(e){return o(e)?e:e.split(".")}function w(e){return o(e)?e.join("."):e}var A={useExtendedSearch:!1,getFn:function(a,n){var e=[],i=!1;return function d(c,a,r){if(t(c))if(a[r]){if(n=c[a[r]],!t(n))return;if(r===a.length-1&&(s(n)||x(n)||D(n)))e.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(n));else if(o(n)){i=!0;for(var n,l=0,u=n.length;l<u;l+=1)d(n[l],a,r+1)}else a.length&&d(n,a,r+1)}else e.push(c)}(a,s(n)?n.split("."):n,0),i?e:e[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},e=a(a(a(a({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return 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}),A),z=/[^ ]+/g;function I(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,e=new Map,t=Math.pow(10,s);return{get:function(i){if(s=i.match(z).length,e.has(s))return e.get(s);var s,a=1/Math.pow(s,.5*n),o=parseFloat(Math.round(a*t)/t);return e.set(s,o),o},clear:function(){e.clear()}}}d=function(){function n(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=t.getFn,i=void 0===s?e.getFn:s,o=t.fieldNormWeight,a=void 0===o?e.fieldNormWeight:o;l(this,n),this.norm=I(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return c(n,[{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 t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=e,this._keysMap={},e.forEach(function(e,n){t._keysMap[e.id]=n})}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,s(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();s(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(t){this.records.splice(t,1);for(var e=t,n=this.size();e<n;e+=1)this.records[e].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,n){if(t(e)&&!f(e)){var s={v:e,i:n,n:this.norm.get(e)};this.records.push(s)}}},{key:"_addObject",value:function(i,a){var e=this,n={i:a,$:{}};this.keys.forEach(function(l,r){var c,a=e.getFn(i,l.path);t(a)&&(o(a)?!function(){for(l=[],c=[{nestedArrIndex:-1,value:a}];c.length;){var c,l,u,d=c.pop(),h=d.nestedArrIndex,i=d.value;t(i)&&(s(i)&&!f(i)?(u={v:i,i:h,n:e.norm.get(i)},l.push(u)):o(i)&&i.forEach(function(e,t){c.push({nestedArrIndex:t,value:e})}))}n.$[r]=l}():f(a)||(c={v:a,n:e.norm.get(a)},n.$[r]=c))}),this.records.push(n)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),n}();function O(i,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=n.getFn,a=void 0===s?e.getFn:s,o=n.fieldNormWeight,r=void 0===o?e.fieldNormWeight:o,t=new d({getFn:a,fieldNormWeight:r});return t.setKeys(i.map(C)),t.setSources(c),t.create(),t}function r(f){var s,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.errors,m=void 0===i?0:i,a=t.currentLocation,u=void 0===a?0:a,c=t.expectedLocation,d=void 0===c?0:c,l=t.distance,o=void 0===l?e.distance:l,r=t.ignoreLocation,h=void 0===r?e.ignoreLocation:r,n=m/f.length;return h?n:(s=Math.abs(d-u),o?n+s/o:s?1:n)}function M(){for(var o,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.minMatchCharLength,i=[],t=-1,a=-1,n=0,c=s.length;n<c;n+=1)o=s[n],o&&-1===t?t=n:o||-1===t||((a=n-1)-t+1>=r&&i.push([t,a]),t=-1);return s[n-1]&&n-t>=r&&i.push([t,n-1]),i}n=32;function T(s){for(var n,t={},e=0,o=s.length;e<o;e+=1)n=s.charAt(e),t[n]=(t[n]||0)|1<<o-e-1;return t}v=function(){function t(j){var o,i,r,E=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},h=s.location,C=void 0===h?e.location:h,d=s.threshold,x=void 0===d?e.threshold:d,u=s.distance,O=void 0===u?e.distance:u,m=s.includeMatches,_=void 0===m?e.includeMatches:m,p=s.findAllMatches,A=void 0===p?e.findAllMatches:p,v=s.minMatchCharLength,y=void 0===v?e.minMatchCharLength:v,c=s.isCaseSensitive,b=void 0===c?e.isCaseSensitive:c,f=s.ignoreLocation,w=void 0===f?e.ignoreLocation:f;if(l(this,t),this.options={location:C,threshold:x,distance:O,includeMatches:_,findAllMatches:A,minMatchCharLength:y,isCaseSensitive:b,ignoreLocation:w},this.pattern=b?j:j.toLowerCase(),this.chunks=[],this.pattern.length)if(i=function(e,t){E.chunks.push({pattern:e,alphabet:T(e),startIndex:t})},o=this.pattern.length,o>n){for(var a=0,g=o%n,k=o-g;a<k;)i(this.pattern.substr(a,n),a),a+=n;g&&(r=o-n,i(this.pattern.substr(r),r))}else i(this.pattern,0)}return c(t,[{key:"searchIn",value:function(s){var h=this.options,g=h.isCaseSensitive,a=h.includeMatches;if(g||(s=s.toLowerCase()),this.pattern===s)return c={isMatch:!0,score:0},a&&(c.indices=[[0,s.length-1]]),c;var c,l,t=this.options,b=t.location,v=t.distance,j=t.threshold,m=t.findAllMatches,f=t.minMatchCharLength,p=t.ignoreLocation,i=[],d=0,o=!1;return this.chunks.forEach(function(t){var w=t.pattern,g=t.alphabet,y=t.startIndex,c=function(k,c,K){var t,o,m,f,j,w,C,E,T,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},H=a.location,W=void 0===H?e.location:H,P=a.distance,g=void 0===P?e.distance:P,R=a.threshold,U=void 0===R?e.threshold:R,V=a.findAllMatches,$=void 0===V?e.findAllMatches:V,L=a.minMatchCharLength,N=void 0===L?e.minMatchCharLength:L,D=a.includeMatches,z=void 0===D?e.includeMatches:D,B=a.ignoreLocation,y=void 0===B?e.ignoreLocation:B;if(c.length>n)throw new Error(F(n));for(var _,h=c.length,p=k.length,s=Math.max(0,Math.min(W,p)),d=U,u=s,v=N>1||z,A=v?Array(p):[];(_=k.indexOf(c,u))>-1;)if(T=r(c,{currentLocation:_,expectedLocation:s,distance:g,ignoreLocation:y}),d=Math.min(T,d),u=_+h,v)for(w=0;w<h;)A[_+w]=1,w+=1;u=-1;for(var b=[],x=1,O=h+p,q=1<<h-1,i=0;i<h;i+=1){for(f=0,o=O;f<o;)r(c,{errors:i,currentLocation:s+o,expectedLocation:s,distance:g,ignoreLocation:y})<=d?f=o:O=o,o=Math.floor((O-f)/2+f);var O=o,I=Math.max(1,s-o+1),S=$?p:Math.min(s+o,p)+h,l=Array(S+2);l[S+1]=(1<<i)-1;for(t=S;t>=I;t-=1)if(m=t-1,C=K[k.charAt(m)],v&&(A[m]=+!!C),l[t]=(l[t+1]<<1|1)&C,i&&(l[t]|=(b[t+1]|b[t])<<1|1|b[t+1]),l[t]&q&&(x=r(c,{errors:i,currentLocation:m,expectedLocation:s,distance:g,ignoreLocation:y}))<=d){if(d=x,(u=m)<=s)break;I=Math.max(1,2*s-u)}if(r(c,{errors:i+1,currentLocation:s,expectedLocation:s,distance:g,ignoreLocation:y})>d)break;b=l}return j={isMatch:u>=0,score:Math.max(.001,x)},v&&(E=M(A,N),E.length?z&&(j.indices=E):j.isMatch=!1),j}(s,w,g,{location:b+y,distance:v,threshold:j,findAllMatches:m,minMatchCharLength:f,includeMatches:a,ignoreLocation:p}),h=c.isMatch,_=c.score,l=c.indices;h&&(o=!0),d+=_,h&&l&&(i=[].concat(u(i),u(l)))}),l={isMatch:o,score:o?d/this.chunks.length:1},o&&a&&(l.indices=i),l}}]),t}(),p=[];function E(e,t){for(var s,n=0,o=p.length;n<o;n+=1)if(s=p[n],s.condition(e,t))return new s(e,t);return new v(e,t)}function L(n,s){var t=s.ignoreFieldNorm,o=void 0===t?e.ignoreFieldNorm:t;n.forEach(function(e){var t=1;e.matches.forEach(function(e){var n=e.key,a=e.norm,s=e.score,i=n?n.weight:null;t*=Math.pow(0===s&&i?Number.EPSILON:s,(i||1)*(o?1:a))}),e.score=t})}function R(s,e){var n=s.matches;e.matches=[],t(n)&&n.forEach(function(n){if(t(n.indices)&&n.indices.length){var s={indices:n.indices,value:n.value};n.key&&(s.key=n.key.src),n.idx>-1&&(s.refIndex=n.idx),e.matches.push(s)}})}function P(e,t){t.score=e.score}function H(i,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=n.includeMatches,a=void 0===s?e.includeMatches:s,o=n.includeScore,r=void 0===o?e.includeScore:o,t=[];return a&&t.push(R),r&&t.push(P),i.map(function(e){var n=e.idx,s={item:c[n],refIndex:n};return t.length&&t.forEach(function(t){t(e,s)}),s})}return i=function(){function n(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(l(this,n),this.options=a(a({},e),s),this.options.useExtendedSearch)throw new Error(k);this._keyStore=new S(this.options.keys),this.setCollection(t,o)}return c(n,[{key:"setCollection",value:function(t,e){if(this._docs=t,e&&!(e instanceof d))throw new Error("Incorrect 'index' type");this._myIndex=e||O(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){t(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var t,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},n=[],e=0,s=this._docs.length;e<s;e+=1)t=this._docs[e],o(t,e)&&(this.removeAt(e),e-=1,s-=1,n.push(t));return n}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(n){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=a.limit,o=void 0===i?-1:i,e=this.options,r=e.includeMatches,c=e.includeScore,l=e.shouldSort,d=e.sortFn,u=e.ignoreFieldNorm,t=s(n)?s(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return L(t,{ignoreFieldNorm:u}),l&&t.sort(d),x(o)&&o>-1&&(t=t.slice(0,o)),H(t,this._docs,{includeMatches:r,includeScore:c})}},{key:"_searchStringList",value:function(n){var s=E(n,this.options),o=this._myIndex.records,e=[];return o.forEach(function(o){var n=o.v,a=o.i,r=o.n;if(t(n)){var i=s.searchIn(n),c=i.isMatch,l=i.score,d=i.indices;c&&e.push({item:n,idx:a,matches:[{score:l,value:n,norm:r,indices:d}]})}}),e}},{key:"_searchLogical",value:function(){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(r){var s=this,o=E(r,this.options),n=this._myIndex,i=n.keys,a=n.records,e=[];return a.forEach(function(r){var n,a=r.$,c=r.i;t(a)&&(n=[],i.forEach(function(e,t){n.push.apply(n,u(s._findMatches({key:e,value:a[t],searcher:o})))}),n.length&&e.push({idx:c,item:a,matches:n}))}),e}},{key:"_findMatches",value:function(s){var c=s.key,e=s.value,a=s.searcher;if(!t(e))return[];if(n=[],o(e))e.forEach(function(e){var s=e.v,i=e.i,r=e.n;if(t(s)){var o=a.searchIn(s),l=o.isMatch,d=o.score,u=o.indices;l&&n.push({score:d,key:c,value:s,idx:i,norm:r,indices:u})}});else{var n,r=e.v,l=e.n,i=a.searchIn(r),d=i.isMatch,u=i.score,h=i.indices;d&&n.push({score:u,key:c,value:r,norm:l,indices:h})}return n}}]),n}(),i.version="6.5.3",i.createIndex=O,i.parseIndex=function(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=s.getFn,a=void 0===i?e.getFn:i,o=s.fieldNormWeight,r=void 0===o?e.fieldNormWeight:o,c=n.keys,l=n.records,t=new d({getFn:a,fieldNormWeight:r});return t.setKeys(c),t.setIndexRecords(l),t},i.config=e,i};"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(),(()=>{var a,r,c,e=null,n=document.getElementById("searchResults"),t=document.getElementById("searchInput"),i=null,s=!1;window.onload=function(){var t=new XMLHttpRequest;t.onreadystatechange=function(){if(t.readyState===4)if(t.status===200){var n,s=JSON.parse(t.responseText);s&&(n={distance:100,threshold:.4,ignoreLocation:!0,keys:["title","permalink","summary","content"]},e&&(n={isCaseSensitive:!!e.iscasesensitive&&e.iscasesensitive,includeScore:!!e.includescore&&e.includescore,includeMatches:!!e.includematches&&e.includematches,minMatchCharLength:e.minmatchcharlength?e.minmatchcharlength:1,shouldSort:!e.shouldsort||e.shouldsort,findAllMatches:!!e.findallmatches&&e.findallmatches,keys:e.keys?e.keys:["title","permalink","summary","content"],location:e.location?e.location:0,threshold:e.threshold?e.threshold:.4,distance:e.distance?e.distance:100,ignoreLocation:!e.ignorelocation||e.ignorelocation}),a=new Fuse(s,n))}else console.log(t.responseText)},t.open("GET","../index.json"),t.send()};function o(e){document.querySelectorAll(".focus").forEach(function(e){e.classList.remove("focus")}),e?(e.focus(),document.activeElement=i=e,e.parentElement.classList.add("focus")):document.activeElement.parentElement.classList.add("focus")}function l(){s=!1,n.innerHTML=t.value="",t.focus()}t.onkeyup=function(){if(a){const e=a.search(this.value.trim());if(e.length!==0){let t="";for(let n in e)t+=`<li class="post-entry"><header class="entry-header">${e[n].item.title}&nbsp;\xBB</header><a href="${e[n].item.permalink}" aria-label="${e[n].item.title}"></a></li>`;n.innerHTML=t,s=!0,r=n.firstChild,c=n.lastChild}else s=!1,n.innerHTML=""}},t.addEventListener("search",function(){this.value||l()}),document.onkeydown=function(d){let a=d.key;var u,e=document.activeElement;let h=document.getElementById("searchbox").contains(e);if(e===t)for(u=document.getElementsByClassName("focus");u.length>0;)u[0].classList.remove("focus");else i&&(e=i);if(a==="Escape")l();else if(!s||!h)return;else a==="ArrowDown"?(d.preventDefault(),e==t?o(n.firstChild.lastChild):e.parentElement!=c&&o(e.parentElement.nextSibling.lastChild)):a==="ArrowUp"?(d.preventDefault(),e.parentElement==r?o(t):e!=t&&o(e.parentElement.previousSibling.lastChild)):a==="ArrowRight"&&e.click()}})()