mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-26 20:41:37 +01:00
1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
var e=this,t=function(){"use strict";function v(e,s){var t=Object.keys(e),n;return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),s&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),t.push.apply(t,n)),t}function i(n){for(var e=1,t;e<arguments.length;e++)t=null!=arguments[e]?arguments[e]:{},e%2?v(Object(t),!0).forEach(function(e){N(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):v(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))});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 y(s,n){for(var t=0,e;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 r(e,t,n){return t&&y(e.prototype,t),n&&y(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 d(e){return function(e){if(Array.isArray(e))return u(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 u(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)?u(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 u(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 s(e){return Array.isArray?Array.isArray(e):"[object Array]"===p(e)}function n(e){return"string"==typeof e}function g(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]"==p(e)}function t(e){return null!=e}function m(e){return!e.trim().length}function p(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var F="Extended search is not available",S=function(e){return"Pattern length exceeds max of ".concat(e,".")},b=Object.prototype.hasOwnProperty,A=function(){function e(s){var n=this,t;l(this,e),this._keys=[],this._keyMap={},t=0,s.forEach(function(s){var e=x(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 r(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}(),f,o,E,O,a;function x(e){var o=null,i=null,a=null,r=1,t;if(n(e)||s(e))a=e,o=_(e),i=w(e);else{if(!b.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));if(t=e.name,a=t,b.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));o=_(t),i=w(t)}return{path:o,id:i,weight:r,src:a}}function _(e){return s(e)?e:e.split(".")}function w(e){return s(e)?e.join("."):e}var k={useExtendedSearch:!1,getFn:function(a,o){var e=[],i=!1;return function d(c,a,r){if(t(c))if(a[r]){if(o=c[a[r]],!t(o))return;if(r===a.length-1&&(n(o)||g(o)||D(o)))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)}(o));else if(s(o)){i=!0;for(var o,l=0,u=o.length;l<u;l+=1)d(o[l],a,r+1)}else a.length&&d(o,a,r+1)}else e.push(c)}(a,n(o)?o.split("."):o,0),i?e:e[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},e=i(i(i(i({},{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}),k),I=/[^ ]+/g;function z(){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(I).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()}}}f=function(){function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?e.getFn:n,s=t.fieldNormWeight,a=void 0===s?e.fieldNormWeight:s;l(this,o),this.norm=z(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return r(o,[{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,n(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();n(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)&&!m(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,o={i:a,$:{}};this.keys.forEach(function(c,r){var a=e.getFn(i,c.path),l;t(a)&&(s(a)?!function(){for(l=[],c=[{nestedArrIndex:-1,value:a}];c.length;){var l,c,d=c.pop(),u=d.nestedArrIndex,i=d.value,h;t(i)&&(n(i)&&!m(i)?(h={v:i,i:u,n:e.norm.get(i)},l.push(h)):s(i)&&i.forEach(function(e,t){c.push({nestedArrIndex:t,value:e})}))}o.$[r]=l}():m(a)||(l={v:a,n:e.norm.get(a)},o.$[r]=l))}),this.records.push(o)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),o}();function j(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 f({getFn:a,fieldNormWeight:r});return t.setKeys(i.map(x)),t.setSources(c),t.create(),t}function c(f){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.errors,m=void 0===o?0:o,i=t.currentLocation,u=void 0===i?0:i,r=t.expectedLocation,d=void 0===r?0:r,l=t.distance,s=void 0===l?e.distance:l,a=t.ignoreLocation,h=void 0===a?e.ignoreLocation:a,n=m/f.length,c;return h?n:(c=Math.abs(d-u),s?n+c/s:c?1:n)}function M(){for(var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.minMatchCharLength,o=[],t=-1,a=-1,n=0,c=s.length,r;n<c;n+=1)r=s[n],r&&-1===t?t=n:r||-1===t||((a=n-1)-t+1>=i&&o.push([t,a]),t=-1);return s[n-1]&&n-t>=i&&o.push([t,n-1]),o}o=32;function T(n){for(var t={},e=0,s=n.length,o;e<s;e+=1)o=n.charAt(e),t[o]=(t[o]||0)|1<<s-e-1;return t}E=function(){function t(g){var E=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=n.location,C=void 0===d?e.location:d,c=n.threshold,x=void 0===c?e.threshold:c,u=n.distance,O=void 0===u?e.distance:u,m=n.includeMatches,_=void 0===m?e.includeMatches:m,p=n.findAllMatches,A=void 0===p?e.findAllMatches:p,v=n.minMatchCharLength,y=void 0===v?e.minMatchCharLength:v,r=n.isCaseSensitive,b=void 0===r?e.isCaseSensitive:r,f=n.ignoreLocation,w=void 0===f?e.ignoreLocation:f,a,i,j;if(l(this,t),this.options={location:C,threshold:x,distance:O,includeMatches:_,findAllMatches:A,minMatchCharLength:y,isCaseSensitive:b,ignoreLocation:w},this.pattern=b?g:g.toLowerCase(),this.chunks=[],this.pattern.length)if(a=function(e,t){E.chunks.push({pattern:e,alphabet:T(e),startIndex:t})},i=this.pattern.length,i>o){for(var s=0,h=i%o,k=i-h;s<k;)a(this.pattern.substr(s,o),s),s+=o;h&&(j=i-o,a(this.pattern.substr(j),j))}else a(this.pattern,0)}return r(t,[{key:"searchIn",value:function(n){var u=this.options,b=u.isCaseSensitive,a=u.includeMatches;if(b||(n=n.toLowerCase()),this.pattern===n)return r={isMatch:!0,score:0},a&&(r.indices=[[0,n.length-1]]),r;var r,t=this.options,v=t.location,g=t.distance,j=t.threshold,m=t.findAllMatches,f=t.minMatchCharLength,p=t.ignoreLocation,i=[],l=0,s=!1,h;return this.chunks.forEach(function(t){var w=t.pattern,b=t.alphabet,y=t.startIndex,r=function(C,i,K){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},H=a.location,W=void 0===H?e.location:H,P=a.distance,b=void 0===P?e.distance:P,L=a.threshold,U=void 0===L?e.threshold:L,B=a.findAllMatches,$=void 0===B?e.findAllMatches:B,D=a.minMatchCharLength,z=void 0===D?e.minMatchCharLength:D,T=a.includeMatches,F=void 0===T?e.includeMatches:T,A=a.ignoreLocation,y=void 0===A?e.ignoreLocation:A,V,O,j,s,n,v,N,E,R;if(i.length>o)throw new Error(S(o));for(var _,h=i.length,m=C.length,t=Math.max(0,Math.min(W,m)),d=U,l=t,p=z>1||F,k=p?Array(m):[];(_=C.indexOf(i,l))>-1;)if(V=c(i,{currentLocation:_,expectedLocation:t,distance:b,ignoreLocation:y}),d=Math.min(V,d),l=_+h,p)for(O=0;O<h;)k[_+O]=1,O+=1;l=-1;for(var g=[],w=1,f=h+m,q=1<<h-1,r=0;r<h;r+=1){for(j=0,s=f;j<s;)c(i,{errors:r,currentLocation:t+s,expectedLocation:t,distance:b,ignoreLocation:y})<=d?j=s:f=s,s=Math.floor((f-j)/2+j);f=s;var I=Math.max(1,t-s+1),x=$?m:Math.min(t+s,m)+h,u=Array(x+2);u[x+1]=(1<<r)-1;for(n=x;n>=I;n-=1)if(v=n-1,N=K[C.charAt(v)],p&&(k[v]=+!!N),u[n]=(u[n+1]<<1|1)&N,r&&(u[n]|=(g[n+1]|g[n])<<1|1|g[n+1]),u[n]&q&&(w=c(i,{errors:r,currentLocation:v,expectedLocation:t,distance:b,ignoreLocation:y}))<=d){if(d=w,(l=v)<=t)break;I=Math.max(1,2*t-l)}if(c(i,{errors:r+1,currentLocation:t,expectedLocation:t,distance:b,ignoreLocation:y})>d)break;g=u}return E={isMatch:l>=0,score:Math.max(.001,w)},p&&(R=M(k,z),R.length?F&&(E.indices=R):E.isMatch=!1),E}(n,w,b,{location:v+y,distance:g,threshold:j,findAllMatches:m,minMatchCharLength:f,includeMatches:a,ignoreLocation:p}),h=r.isMatch,_=r.score,u=r.indices;h&&(s=!0),l+=_,h&&u&&(i=[].concat(d(i),d(u)))}),h={isMatch:s,score:s?l/this.chunks.length:1},s&&a&&(h.indices=i),h}}]),t}(),O=[];function C(e,t){for(var n=0,o=O.length,s;n<o;n+=1)if(s=O[n],s.condition(e,t))return new s(e,t);return new E(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 a=function(){function o(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(l(this,o),this.options=i(i({},e),n),this.options.useExtendedSearch)throw new Error(F);this._keyStore=new A(this.options.keys),this.setCollection(t,s)}return r(o,[{key:"setCollection",value:function(t,e){if(this._docs=t,e&&!(e instanceof f))throw new Error("Incorrect 'index' type");this._myIndex=e||j(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 o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],e=0,n=this._docs.length,s;e<n;e+=1)s=this._docs[e],o(s,e)&&(this.removeAt(e),e-=1,n-=1,t.push(s));return t}},{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(s){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=n(s)?n(this._docs[0])?this._searchStringList(s):this._searchObjectList(s):this._searchLogical(s);return L(t,{ignoreFieldNorm:u}),l&&t.sort(d),g(o)&&o>-1&&(t=t.slice(0,o)),H(t,this._docs,{includeMatches:r,includeScore:c})}},{key:"_searchStringList",value:function(n){var s=C(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=C(r,this.options),n=this._myIndex,i=n.keys,a=n.records,e=[];return a.forEach(function(r){var a=r.$,c=r.i,n;t(a)&&(n=[],i.forEach(function(e,t){n.push.apply(n,d(s._findMatches({key:e,value:a[t],searcher:o})))}),n.length&&e.push({idx:c,item:a,matches:n}))}),e}},{key:"_findMatches",value:function(n){var c=n.key,e=n.value,a=n.searcher;if(!t(e))return[];if(i=[],s(e))e.forEach(function(e){var n=e.v,o=e.i,r=e.n;if(t(n)){var s=a.searchIn(n),l=s.isMatch,d=s.score,u=s.indices;l&&i.push({score:d,key:c,value:n,idx:o,norm:r,indices:u})}});else{var i,r=e.v,l=e.n,o=a.searchIn(r),d=o.isMatch,u=o.score,h=o.indices;d&&i.push({score:u,key:c,value:r,norm:l,indices:h})}return i}}]),o}(),a.version="6.5.3",a.createIndex=j,a.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 f({getFn:a,fieldNormWeight:r});return t.setKeys(c),t.setIndexRecords(l),t},a.config=e,a};"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 e=null,a,r,c,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=JSON.parse(t.responseText),s;n&&(s={distance:100,threshold:.4,ignoreLocation:!0,keys:["title","permalink","summary","content"]},e&&(s={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(n,s))}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} \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 e=document.activeElement,u;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()}})() |