mirror of https://github.com/jpanther/congo.git
11 lines
27 KiB
JavaScript
11 lines
27 KiB
JavaScript
e=this,t=function(){"use strict";function V(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 h(n){for(var e,t=1;t<arguments.length;t++)e=null!=arguments[t]?arguments[t]:{},t%2?V(Object(e),!0).forEach(function(t){j(n,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):V(Object(e)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))});return n}function x(e){return x="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},x(e)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(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 n(e,t,n){return t&&H(e.prototype,t),n&&H(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(t,"prototype",{value:Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),writable:!1}),e&&b(t,e)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function eu(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,o,s=g(e);return t?(o=g(this).constructor,n=Reflect.construct(s,arguments,o)):n=s.apply(this,arguments),eu(this,n)}}function d(e){return function(e){if(Array.isArray(e))return v(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 v(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)?v(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 v(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 a(e){return Array.isArray?Array.isArray(e):"[object Array]"===T(e)}function o(e){return"string"==typeof e}function N(e){return"number"==typeof e}function ec(e){return!0===e||!1===e||function(e){return z(e)&&null!==e}(e)&&"[object Boolean]"==T(e)}function z(e){return"object"===x(e)}function s(e){return null!=e}function k(e){return!e.trim().length}function T(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var ea=function(e){return"Invalid value for key ".concat(e)},eo=function(e){return"Pattern length exceeds max of ".concat(e,".")},S=Object.prototype.hasOwnProperty,es=function(){function e(o){var n,s=this;t(this,e),this._keys=[],this._keyMap={},n=0,o.forEach(function(t){var e=A(t);n+=e.weight,s._keys.push(e),s._keyMap[e.id]=e,n+=e.weight}),this._keys.forEach(function(e){e.weight/=n})}return n(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 A(e){var t,n=null,s=null,i=null,r=1,c=null;if(o(e)||a(e))i=e,n=B(e),s=E(e);else{if(!S.call(e,"name"))throw new Error(function(e){return"Missing ".concat(e," property in key")}("name"));if(t=e.name,i=t,S.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=B(t),s=E(t),c=e.getFn}return{path:n,id:s,weight:r,src:i,getFn:c}}function B(e){return a(e)?e:e.split(".")}function E(e){return a(e)?e.join("."):e}var $={useExtendedSearch:!1,getFn:function(i,t){var e=[],n=!1;return function d(c,i,r){if(s(c))if(i[r]){if(t=c[i[r]],!s(t))return;if(r===i.length-1&&(o(t)||N(t)||ec(t)))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)}(t));else if(a(t)){n=!0;for(var t,l=0,u=t.length;l<u;l+=1)d(t[l],i,r+1)}else i.length&&d(t,i,r+1)}else e.push(c)}(i,o(t)?t.split("."):t,0),n?e:e[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},e=h(h(h(h({},{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}),$),Q=/[^ ]+/g;function X(){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(Q).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 i(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=n.getFn,a=void 0===s?e.getFn:s,o=n.fieldNormWeight,r=void 0===o?e.fieldNormWeight:o;t(this,i),this.norm=X(r,3),this.getFn=a,this.isCreated=!1,this.setIndexRecords()}return n(i,[{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,o(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();o(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,t){if(s(e)&&!k(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(n,i){var e=this,t={i,$:{}};this.keys.forEach(function(r,c){var l,i=r.getFn?r.getFn(n):e.getFn(n,r.path);s(i)&&(a(i)?!function(){for(l=[],r=[{nestedArrIndex:-1,value:i}];r.length;){var r,l,u,d=r.pop(),h=d.nestedArrIndex,n=d.value;s(n)&&(o(n)&&!k(n)?(u={v:n,i:h,n:e.norm.get(n)},l.push(u)):a(n)&&n.forEach(function(e,t){r.push({nestedArrIndex:t,value:e})}))}t.$[c]=l}():o(i)&&!k(i)&&(l={v:i,n:e.norm.get(i)},t.$[c]=l))}),this.records.push(t)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),i}();function D(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(A)),t.setSources(c),t.create(),t}function m(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 G(){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}l=32;function Y(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}y=function(){function s(j){var o,i,r,E=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},h=n.location,C=void 0===h?e.location:h,d=n.threshold,x=void 0===d?e.threshold:d,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,c=n.isCaseSensitive,b=void 0===c?e.isCaseSensitive:c,f=n.ignoreLocation,w=void 0===f?e.ignoreLocation:f;if(t(this,s),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:Y(e),startIndex:t})},o=this.pattern.length,o>l){for(var a=0,g=o%l,k=o-g;a<k;)i(this.pattern.substr(a,l),a),a+=l;g&&(r=o-l,i(this.pattern.substr(r),r))}else i(this.pattern,0)}return n(s,[{key:"searchIn",value:function(n){var u=this.options,g=u.isCaseSensitive,i=u.includeMatches;if(g||(n=n.toLowerCase()),this.pattern===n)return a={isMatch:!0,score:0},i&&(a.indices=[[0,n.length-1]]),a;var a,r,t=this.options,b=t.location,v=t.distance,j=t.threshold,h=t.findAllMatches,f=t.minMatchCharLength,p=t.ignoreLocation,o=[],c=0,s=!1;return this.chunks.forEach(function(t){var w=t.pattern,g=t.alphabet,y=t.startIndex,a=function(k,a,W){var t,s,h,f,j,w,C,E,M,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},R=i.location,V=void 0===R?e.location:R,L=i.distance,g=void 0===L?e.distance:L,N=i.threshold,$=void 0===N?e.threshold:N,I=i.findAllMatches,B=void 0===I?e.findAllMatches:I,D=i.minMatchCharLength,z=void 0===D?e.minMatchCharLength:D,T=i.includeMatches,F=void 0===T?e.includeMatches:T,H=i.ignoreLocation,y=void 0===H?e.ignoreLocation:H;if(a.length>l)throw new Error(eo(l));for(var _,u=a.length,p=k.length,n=Math.max(0,Math.min(V,p)),c=$,d=n,v=z>1||F,A=v?Array(p):[];(_=k.indexOf(a,d))>-1;)if(M=m(a,{currentLocation:_,expectedLocation:n,distance:g,ignoreLocation:y}),c=Math.min(M,c),d=_+u,v)for(w=0;w<u;)A[_+w]=1,w+=1;d=-1;for(var b=[],x=1,O=u+p,U=1<<u-1,o=0;o<u;o+=1){for(f=0,s=O;f<s;)m(a,{errors:o,currentLocation:n+s,expectedLocation:n,distance:g,ignoreLocation:y})<=c?f=s:O=s,s=Math.floor((O-f)/2+f);var O=s,P=Math.max(1,n-s+1),S=B?p:Math.min(n+s,p)+u,r=Array(S+2);r[S+1]=(1<<o)-1;for(t=S;t>=P;t-=1)if(h=t-1,C=W[k.charAt(h)],v&&(A[h]=+!!C),r[t]=(r[t+1]<<1|1)&C,o&&(r[t]|=(b[t+1]|b[t])<<1|1|b[t+1]),r[t]&U&&(x=m(a,{errors:o,currentLocation:h,expectedLocation:n,distance:g,ignoreLocation:y}))<=c){if(c=x,(d=h)<=n)break;P=Math.max(1,2*n-d)}if(m(a,{errors:o+1,currentLocation:n,expectedLocation:n,distance:g,ignoreLocation:y})>c)break;b=r}return j={isMatch:d>=0,score:Math.max(.001,x)},v&&(E=G(A,z),E.length?F&&(j.indices=E):j.isMatch=!1),j}(n,w,g,{location:b+y,distance:v,threshold:j,findAllMatches:h,minMatchCharLength:f,includeMatches:i,ignoreLocation:p}),u=a.isMatch,_=a.score,r=a.indices;u&&(s=!0),c+=_,u&&r&&(o=[].concat(d(o),d(r)))}),r={isMatch:s,score:s?c/this.chunks.length:1},s&&i&&(r.indices=o),r}}]),s}(),i=function(){function e(n){t(this,e),this.pattern=n}return n(e,[{key:"search",value:function(){}}],[{key:"isMultiMatch",value:function(e){return I(e,this.multiRegex)}},{key:"isSingleMatch",value:function(e){return I(e,this.singleRegex)}}]),e}();function I(t,n){var e=t.match(n);return e?e[1]:null}var i,l,u,f,y,e3=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(t){var e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"multiRegex",get:function(){return/^="(.*)"$/}},{key:"singleRegex",get:function(){return/^=(.*)$/}}]),e}(i),en=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(e){var t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"$/}},{key:"singleRegex",get:function(){return/^!(.*)$/}}]),e}(i),W=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(t){var e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"prefix-exact"}},{key:"multiRegex",get:function(){return/^\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^\^(.*)$/}}]),e}(i),U=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(e){var t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-prefix-exact"}},{key:"multiRegex",get:function(){return/^!\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^!\^(.*)$/}}]),e}(i),K=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(e){var t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}],[{key:"type",get:function(){return"suffix-exact"}},{key:"multiRegex",get:function(){return/^"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^(.*)\$$/}}]),e}(i),q=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(e){var t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-suffix-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^!(.*)\$$/}}]),e}(i),P=function(o){r(s,o);var i=c(s);function s(f){var a,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.location,w=void 0===r?e.location:r,l=n.threshold,j=void 0===l?e.threshold:l,u=n.distance,v=void 0===u?e.distance:u,m=n.includeMatches,p=void 0===m?e.includeMatches:m,o=n.findAllMatches,g=void 0===o?e.findAllMatches:o,h=n.minMatchCharLength,b=void 0===h?e.minMatchCharLength:h,d=n.isCaseSensitive,_=void 0===d?e.isCaseSensitive:d,c=n.ignoreLocation,O=void 0===c?e.ignoreLocation:c;return t(this,s),(a=i.call(this,f))._bitapSearch=new y(f,{location:w,threshold:j,distance:v,includeMatches:p,findAllMatches:g,minMatchCharLength:b,isCaseSensitive:_,ignoreLocation:O}),a}return n(s,[{key:"search",value:function(e){return this._bitapSearch.searchIn(e)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"multiRegex",get:function(){return/^"(.*)"$/}},{key:"singleRegex",get:function(){return/^(.*)$/}}]),s}(i),L=function(s){r(e,s);var o=c(e);function e(n){return t(this,e),o.call(this,n)}return n(e,[{key:"search",value:function(o){for(var e,s,t=0,n=[],i=this.pattern.length;(e=o.indexOf(this.pattern,t))>-1;)t=e+i,n.push([e,t-1]);return s=!!n.length,{isMatch:s,score:s?0:1,indices:n}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),e}(i),_=[e3,L,W,U,q,K,en,P],F=_.length,Z=/ +(?=(?:[^"]*"[^"]*")*[^"]*$)/;function J(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.split("|").map(function(u){for(var i,a,r,c,l=u.trim().split(Z).filter(function(e){return e&&!!e.trim()}),s=[],o=0,h=l.length;o<h;o+=1){for(var d=l[o],n=!1,t=-1;!n&&++t<F;)r=_[t],c=r.isMultiMatch(d),c&&(s.push(new r(c,e)),n=!0);if(!n)for(t=-1;++t<F;)if(i=_[t],a=i.isSingleMatch(d),a){s.push(new i(a,e));break}}return s})}var ee=new Set([P.type,L.type]),et=function(){function s(h){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isCaseSensitive,a=void 0===i?e.isCaseSensitive:i,r=n.includeMatches,j=void 0===r?e.includeMatches:r,l=n.minMatchCharLength,v=void 0===l?e.minMatchCharLength:l,u=n.ignoreLocation,f=void 0===u?e.ignoreLocation:u,m=n.findAllMatches,p=void 0===m?e.findAllMatches:m,o=n.location,g=void 0===o?e.location:o,d=n.threshold,b=void 0===d?e.threshold:d,c=n.distance,y=void 0===c?e.distance:c;t(this,s),this.query=null,this.options={isCaseSensitive:a,includeMatches:j,minMatchCharLength:v,findAllMatches:p,ignoreLocation:f,location:g,threshold:b,distance:y},this.pattern=a?h:h.toLowerCase(),this.query=J(this.pattern,this.options)}return n(s,[{key:"searchIn",value:function(o){if(s=this.query,!s)return{isMatch:!1,score:1};i=this.options,l=i.includeMatches,o=i.isCaseSensitive?o:o.toLowerCase();for(var n,s,i,l,u,h,m,p,t=0,e=[],a=0,r=0,v=s.length;r<v;r+=1){u=s[r],e.length=0,t=0;for(n=0,m=u.length;n<m;n+=1){var g=u[n],c=g.search(o),b=c.isMatch,f=c.indices,j=c.score;if(!b){a=0,t=0,e.length=0;break}t+=1,a+=j,l&&(p=g.constructor.type,ee.has(p)?e=[].concat(d(e),d(f)):e.push(f))}if(t)return h={isMatch:!0,score:a/t},l&&(h.indices=e),h}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(t,e){return e.useExtendedSearch}}]),s}(),p=[];function C(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 y(e,t)}var O="$and",ei="$or",M="$path",er="$val",w=function(e){return!!e[O]||!!e[ei]},el=function(e){return!!e[M]},ed=function(e){return!a(e)&&z(e)&&!w(e)},R=function(e){return j({},O,Object.keys(e).map(function(t){return j({},t,e[t])}))};function e1(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 e4(n,e){var t=n.matches;e.matches=[],s(t)&&t.forEach(function(t){if(s(t.indices)&&t.indices.length){var n={indices:t.indices,value:t.value};t.key&&(n.key=t.key.src),t.idx>-1&&(n.refIndex=t.idx),e.matches.push(n)}})}function e0(e,t){t.score=e.score}function e2(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(e4),r&&t.push(e0),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 u=function(){function i(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;t(this,i),this.options=h(h({},e),s),this.options.useExtendedSearch,this._keyStore=new es(this.options.keys),this.setCollection(n,o)}return n(i,[{key:"setCollection",value:function(t,e){if(this._docs=t,e&&!(e instanceof f))throw new Error("Incorrect 'index' type");this._myIndex=e||D(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){s(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,s=void 0===i?-1:i,e=this.options,r=e.includeMatches,c=e.includeScore,l=e.shouldSort,d=e.sortFn,u=e.ignoreFieldNorm,t=o(n)?o(this._docs[0])?this._searchStringList(n):this._searchObjectList(n):this._searchLogical(n);return e1(t,{ignoreFieldNorm:u}),l&&t.sort(d),N(s)&&s>-1&&(t=t.slice(0,s)),e2(t,this._docs,{includeMatches:r,includeScore:c})}},{key:"_searchStringList",value:function(t){var n=C(t,this.options),o=this._myIndex.records,e=[];return o.forEach(function(o){var t=o.v,a=o.i,r=o.n;if(s(t)){var i=n.searchIn(t),c=i.isMatch,l=i.score,d=i.indices;c&&e.push({item:t,idx:a,matches:[{score:l,value:t,norm:r,indices:d}]})}}),e}},{key:"_searchLogical",value:function(l){var t=this,i=function(e,n){var t=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).auto,s=void 0===t||t,i=function u(e){var i,r,c,d,t=Object.keys(e),l=el(e);if(!l&&t.length>1&&!w(e))return u(R(e));if(ed(e)){if(i=l?e[M]:t[0],r=l?e[er]:e[i],!o(r))throw new Error(ea(i));return c={keyId:E(i),pattern:r},s&&(c.searcher=C(r,n)),c}return d={children:[],operator:t[0]},t.forEach(function(n){var t=e[n];a(t)&&t.forEach(function(e){d.children.push(u(e))})}),d};return w(e)||(e=R(e)),i(e)}(l,this.options),r=function u(e,s,r){if(!e.children){var o,c=e.keyId,l=e.searcher,n=t._findMatches({key:t._keyStore.get(c),value:t._myIndex.getValueForItemAtKeyId(s,c),searcher:l});return n&&n.length?[{idx:r,item:s,matches:n}]:[]}for(var i=[],a=0,h=e.children.length;a<h;a+=1)if(o=u(e.children[a],s,r),o.length)i.push.apply(i,d(o));else if(e.operator===O)return[];return i},c=this._myIndex.records,e={},n=[];return c.forEach(function(c){var a,o=c.$,t=c.i;s(o)&&(a=r(i,o,t),a.length&&(e[t]||(e[t]={idx:t,item:o,matches:[]},n.push(e[t])),a.forEach(function(s){var n,o=s.matches;(n=e[t].matches).push.apply(n,d(o))})))}),n}},{key:"_searchObjectList",value:function(r){var n=this,o=C(r,this.options),t=this._myIndex,i=t.keys,a=t.records,e=[];return a.forEach(function(r){var t,a=r.$,c=r.i;s(a)&&(t=[],i.forEach(function(e,s){t.push.apply(t,d(n._findMatches({key:e,value:a[s],searcher:o})))}),t.length&&e.push({idx:c,item:a,matches:t}))}),e}},{key:"_findMatches",value:function(n){var c=n.key,e=n.value,i=n.searcher;if(!s(e))return[];if(t=[],a(e))e.forEach(function(e){var n=e.v,a=e.i,r=e.n;if(s(n)){var o=i.searchIn(n),l=o.isMatch,d=o.score,u=o.indices;l&&t.push({score:d,key:c,value:n,idx:a,norm:r,indices:u})}});else{var t,r=e.v,l=e.n,o=i.searchIn(r),d=o.isMatch,u=o.score,h=o.indices;d&&t.push({score:u,key:c,value:r,norm:l,indices:h})}return t}}]),i}(),u.version="6.6.2",u.createIndex=D,u.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},u.config=e,function(){p.push.apply(p,arguments)}(et),u},"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,t,fuse,showButton=document.getElementById("search-button"),scriptBundle,copyText,copiedText,hideButton=document.getElementById("close-search-button"),wrapper=document.getElementById("search-wrapper"),modal=document.getElementById("search-modal"),input=document.getElementById("search-query"),output=document.getElementById("search-results"),first=output.firstChild,last=output.lastChild,searchVisible=!1,indexed=!1,hasResults=!1;showButton.addEventListener("click",displaySearch),hideButton.addEventListener("click",hideSearch),wrapper.addEventListener("click",hideSearch),modal.addEventListener("click",function(e){return e.stopPropagation(),e.stopImmediatePropagation(),!1}),document.addEventListener("keydown",function(e){e.key=="/"&&(searchVisible||(e.preventDefault(),displaySearch())),e.key=="Escape"&&hideSearch(),e.key=="ArrowDown"&&searchVisible&&hasResults&&(e.preventDefault(),document.activeElement==input?first.focus():document.activeElement==last?last.focus():document.activeElement.parentElement.nextSibling.firstElementChild.focus()),e.key=="ArrowUp"&&searchVisible&&hasResults&&(e.preventDefault(),document.activeElement==input?input.focus():document.activeElement==first?input.focus():document.activeElement.parentElement.previousSibling.firstElementChild.focus())}),input.onkeyup=function(){executeQuery(this.value)};function displaySearch(){indexed||buildIndex(),searchVisible||(document.body.style.overflow="hidden",wrapper.style.visibility="visible",input.focus(),searchVisible=!0)}function hideSearch(){searchVisible&&(document.body.style.overflow="visible",wrapper.style.visibility="hidden",input.value="",output.innerHTML="",document.activeElement.blur(),searchVisible=!1)}function fetchJSON(n,t){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState===4&&e.status===200){var n=JSON.parse(e.responseText);t&&t(n)}},e.open("GET",n),e.send()}function buildIndex(){var e=wrapper.getAttribute("data-url");fetchJSON(e+"index.json",function(e){var t={shouldSort:!0,ignoreLocation:!0,threshold:0,includeMatches:!0,keys:[{name:"title",weight:.8},{name:"section",weight:.2},{name:"summary",weight:.6},{name:"content",weight:.4}]};fuse=new Fuse(e,t),indexed=!0})}function executeQuery(n){let t=fuse.search(n),e="";t.length>0?(t.forEach(function(t){e=e+`<li class="mb-2">
|
|
<a class="flex items-center px-3 py-2 rounded-md appearance-none bg-neutral-100 dark:bg-neutral-700 focus:bg-primary-100 hover:bg-primary-100 dark:hover:bg-primary-900 dark:focus:bg-primary-900 focus:outline-dotted focus:outline-transparent focus:outline-2" href="${t.item.permalink}" tabindex="0">
|
|
<div class="grow">
|
|
<div class="-mb-1 text-lg font-bold">${t.item.title}</div>
|
|
<div class="text-sm text-neutral-500 dark:text-neutral-400">${t.item.section}<span class="px-2 text-primary-500">·</span>${t.item.date}</span></div>
|
|
<div class="text-sm italic">${t.item.summary}</div>
|
|
</div>
|
|
<div class="ml-2 ltr:block rtl:hidden text-neutral-500">→</div>
|
|
<div class="mr-2 ltr:hidden rtl:block text-neutral-500">←</div>
|
|
</a>
|
|
</li>`}),hasResults=!0):(e="",hasResults=!1),output.innerHTML=e,t.length>0&&(first=output.firstChild.firstElementChild,last=output.lastChild.firstElementChild)}scriptBundle=document.getElementById("script-bundle"),copyText=scriptBundle?scriptBundle.getAttribute("data-copy"):"Copy",copiedText=scriptBundle?scriptBundle.getAttribute("data-copied"):"Copied";function createCopyButton(t){const e=document.createElement("button");e.className="copy-button",e.type="button",e.ariaLabel=copyText,e.innerText=copyText,e.addEventListener("click",()=>copyCodeToClipboard(e,t)),addCopyButtonToDom(e,t)}async function copyCodeToClipboard(n,e){const t=e.querySelector(":last-child > .chroma > code").innerText;try{result=await navigator.permissions.query({name:"clipboard-write"}),result.state=="granted"||result.state=="prompt"?await navigator.clipboard.writeText(t):copyCodeBlockExecCommand(t,e)}catch(n){copyCodeBlockExecCommand(t,e)}finally{codeWasCopied(n)}}function copyCodeBlockExecCommand(o,t){const e=document.createElement("textArea");e.contentEditable="true",e.readOnly="false",e.className="copy-textarea",e.value=o,t.insertBefore(e,t.firstChild);const n=document.createRange();n.selectNodeContents(e);const s=window.getSelection();s.removeAllRanges(),s.addRange(n),e.setSelectionRange(0,999999),document.execCommand("copy"),t.removeChild(e)}function codeWasCopied(e){e.blur(),e.innerText=copiedText,setTimeout(function(){e.innerText=copyText},2e3)}function addCopyButtonToDom(n,e){e.insertBefore(n,e.firstChild);const t=document.createElement("div");t.className="highlight-wrapper",e.parentNode.insertBefore(t,e),t.appendChild(e)}window.addEventListener("DOMContentLoaded",e=>{document.querySelectorAll(".highlight").forEach(e=>createCopyButton(e))}) |