Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["1852"],{58291(e){!function(){var t,r,i,n,s,o,a,l,u,c,d,h,f,p,y,m,g,v,x,w,E,Q,b,k,S,L,T,P,I,O,R=function(e){var t=new R.Builder;return t.pipeline.add(R.trimmer,R.stopWordFilter,R.stemmer),t.searchPipeline.add(R.stemmer),e.call(t,t),t.build()};R.version="2.3.9",R.utils={},R.utils.warn=(t=this,function(e){t.console&&console.warn&&console.warn(e)}),R.utils.asString=function(e){return null==e?"":e.toString()},R.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],s=e[n];if(Array.isArray(s)){t[n]=s.slice();continue}if("string"==typeof s||"number"==typeof s||"boolean"==typeof s){t[n]=s;continue}throw TypeError("clone is not deep and does not support nested objects")}return t},R.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},R.FieldRef.joiner="/",R.FieldRef.fromString=function(e){var t=e.indexOf(R.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),i=e.slice(t+1);return new R.FieldRef(i,r,e)},R.FieldRef.prototype.toString=function(){return void 0==this._stringValue&&(this._stringValue=this.fieldName+R.FieldRef.joiner+this.docRef),this._stringValue},R.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},R.Set.complete={intersect:function(e){return e},union:function(){return this},contains:function(){return!0}},R.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},R.Set.prototype.contains=function(e){return!!this.elements[e]},R.Set.prototype.intersect=function(e){var t,r,i,n=[];if(e===R.Set.complete)return this;if(e===R.Set.empty)return e;this.length<e.length?(t=this,r=e):(t=e,r=this),i=Object.keys(t.elements);for(var s=0;s<i.length;s++){var o=i[s];o in r.elements&&n.push(o)}return new R.Set(n)},R.Set.prototype.union=function(e){return e===R.Set.complete?R.Set.complete:e===R.Set.empty?this:new R.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},R.idf=function(e,t){var r=0;for(var i in e)"_index"!=i&&(r+=Object.keys(e[i]).length);return Math.log(1+Math.abs((t-r+.5)/(r+.5)))},R.Token=function(e,t){this.str=e||"",this.metadata=t||{}},R.Token.prototype.toString=function(){return this.str},R.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},R.Token.prototype.clone=function(e){return e=e||function(e){return e},new R.Token(e(this.str,this.metadata),this.metadata)},R.tokenizer=function(e,t){if(null==e||void 0==e)return[];if(Array.isArray(e))return e.map(function(e){return new R.Token(R.utils.asString(e).toLowerCase(),R.utils.clone(t))});for(var r=e.toString().toLowerCase(),i=r.length,n=[],s=0,o=0;s<=i;s++){var a=r.charAt(s),l=s-o;if(a.match(R.tokenizer.separator)||s==i){if(l>0){var u=R.utils.clone(t)||{};u.position=[o,l],u.index=n.length,n.push(new R.Token(r.slice(o,s),u))}o=s+1}}return n},R.tokenizer.separator=/[\s\-]+/,R.Pipeline=function(){this._stack=[]},R.Pipeline.registeredFunctions=Object.create(null),R.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&R.utils.warn("Overwriting existing registered function: "+t),e.label=t,R.Pipeline.registeredFunctions[e.label]=e},R.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||R.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},R.Pipeline.load=function(e){var t=new R.Pipeline;return e.forEach(function(e){var r=R.Pipeline.registeredFunctions[e];if(r)t.add(r);else throw Error("Cannot load unregistered function: "+e)}),t},R.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){R.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},R.Pipeline.prototype.after=function(e,t){R.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},R.Pipeline.prototype.before=function(e,t){R.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw Error("Cannot find existingFn");this._stack.splice(r,0,t)},R.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},R.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r<t;r++){for(var i=this._stack[r],n=[],s=0;s<e.length;s++){var o=i(e[s],s,e);if(null!=o&&""!==o)if(Array.isArray(o))for(var a=0;a<o.length;a++)n.push(o[a]);else n.push(o)}e=n}return e},R.Pipeline.prototype.runString=function(e,t){var r=new R.Token(e,t);return this.run([r]).map(function(e){return e.toString()})},R.Pipeline.prototype.reset=function(){this._stack=[]},R.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return R.Pipeline.warnIfFunctionNotRegistered(e),e.label})},R.Vector=function(e){this._magnitude=0,this.elements=e||[]},R.Vector.prototype.positionForIndex=function(e){if(0==this.elements.length)return 0;for(var t=0,r=this.elements.length/2,i=r-t,n=Math.floor(i/2),s=this.elements[2*n];i>1&&(s<e&&(t=n),s>e&&(r=n),s!=e);)i=r-t,n=t+Math.floor(i/2),s=this.elements[2*n];return s==e||s>e?2*n:s<e?(n+1)*2:void 0},R.Vector.prototype.insert=function(e,t){this.upsert(e,t,function(){throw"duplicate index"})},R.Vector.prototype.upsert=function(e,t,r){this._magnitude=0;var i=this.positionForIndex(e);this.elements[i]==e?this.elements[i+1]=r(this.elements[i+1],t):this.elements.splice(i,0,e,t)},R.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e=0,t=this.elements.length,r=1;r<t;r+=2){var i=this.elements[r];e+=i*i}return this._magnitude=Math.sqrt(e)},R.Vector.prototype.dot=function(e){for(var t=0,r=this.elements,i=e.elements,n=r.length,s=i.length,o=0,a=0,l=0,u=0;l<n&&u<s;)(o=r[l])<(a=i[u])?l+=2:o>a?u+=2:o==a&&(t+=r[l+1]*i[u+1],l+=2,u+=2);return t},R.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},R.Vector.prototype.toArray=function(){for(var e=Array(this.elements.length/2),t=1,r=0;t<this.elements.length;t+=2,r++)e[r]=this.elements[t];return e},R.Vector.prototype.toJSON=function(){return this.elements},r={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},i={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},a="^("+(s="[^aeiou][^aeiouy]*")+")?"+(o=(n="[aeiouy]")+"[aeiou]*")+s+"("+o+")?$",l="^("+s+")?"+o+s+o+s,u=RegExp("^("+s+")?"+o+s),c=new RegExp(l),d=new RegExp(a),h=RegExp("^("+s+")?"+n),f=/^(.+?)(ss|i)es$/,p=/^(.+?)([^s])s$/,y=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,g=/.$/,v=/(at|bl|iz)$/,x=RegExp("([^aeiouylsz])\\1$"),w=RegExp("^"+s+n+"[^aeiouwxy]$"),E=/^(.+?[^aeiou])y$/,Q=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,b=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,k=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,S=/^(.+?)(s|t)(ion)$/,L=/^(.+?)e$/,T=/ll$/,P=RegExp("^"+s+n+"[^aeiouwxy]$"),I=function(e){var t,n,s,o,a,l;if(e.length<3)return e;if("y"==(s=e.substr(0,1))&&(e=s.toUpperCase()+e.substr(1)),o=f,a=p,o.test(e)?e=e.replace(o,"$1$2"):a.test(e)&&(e=e.replace(a,"$1$2")),o=y,a=m,o.test(e)){var I=o.exec(e);(o=u).test(I[1])&&(o=g,e=e.replace(o,""))}else if(a.test(e)){var I=a.exec(e);t=I[1],(a=h).test(t)&&(e=t,a=v,l=x,a.test(e)?e+="e":l.test(e)?(o=g,e=e.replace(o,"")):w.test(e)&&(e+="e"))}if((o=E).test(e)){var I=o.exec(e);e=(t=I[1])+"i"}if((o=Q).test(e)){var I=o.exec(e);t=I[1],n=I[2],(o=u).test(t)&&(e=t+r[n])}if((o=b).test(e)){var I=o.exec(e);t=I[1],n=I[2],(o=u).test(t)&&(e=t+i[n])}if(o=k,a=S,o.test(e)){var I=o.exec(e);t=I[1],(o=c).test(t)&&(e=t)}else if(a.test(e)){var I=a.exec(e);t=I[1]+I[2],(a=c).test(t)&&(e=t)}if((o=L).test(e)){var I=o.exec(e);t=I[1],o=c,a=d,l=P,(o.test(t)||a.test(t)&&!l.test(t))&&(e=t)}return o=T,a=c,o.test(e)&&a.test(e)&&(o=g,e=e.replace(o,"")),"y"==s&&(e=s.toLowerCase()+e.substr(1)),e},R.stemmer=function(e){return e.update(I)},R.Pipeline.registerFunction(R.stemmer,"stemmer"),R.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){return e[t]=t,e},{});return function(e){if(e&&t[e.toString()]!==e.toString())return e}},R.stopWordFilter=R.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),R.Pipeline.registerFunction(R.stopWordFilter,"stopWordFilter"),R.trimmer=function(e){return e.update(function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")})},R.Pipeline.registerFunction(R.trimmer,"trimmer"),R.TokenSet=function(){this.final=!1,this.edges={},this.id=R.TokenSet._nextId,R.TokenSet._nextId+=1},R.TokenSet._nextId=1,R.TokenSet.fromArray=function(e){for(var t=new R.TokenSet.Builder,r=0,i=e.length;r<i;r++)t.insert(e[r]);return t.finish(),t.root},R.TokenSet.fromClause=function(e){return"editDistance"in e?R.TokenSet.fromFuzzyString(e.term,e.editDistance):R.TokenSet.fromString(e.term)},R.TokenSet.fromFuzzyString=function(e,t){for(var r=new R.TokenSet,i=[{node:r,editsRemaining:t,str:e}];i.length;){var n=i.pop();if(n.str.length>0){var s,o=n.str.charAt(0);o in n.node.edges?s=n.node.edges[o]:(s=new R.TokenSet,n.node.edges[o]=s),1==n.str.length&&(s.final=!0),i.push({node:s,editsRemaining:n.editsRemaining,str:n.str.slice(1)})}if(0!=n.editsRemaining){if("*"in n.node.edges)var a=n.node.edges["*"];else{var a=new R.TokenSet;n.node.edges["*"]=a}if(0==n.str.length&&(a.final=!0),i.push({node:a,editsRemaining:n.editsRemaining-1,str:n.str}),n.str.length>1&&i.push({node:n.node,editsRemaining:n.editsRemaining-1,str:n.str.slice(1)}),1==n.str.length&&(n.node.final=!0),n.str.length>=1){if("*"in n.node.edges)var l=n.node.edges["*"];else{var l=new R.TokenSet;n.node.edges["*"]=l}1==n.str.length&&(l.final=!0),i.push({node:l,editsRemaining:n.editsRemaining-1,str:n.str.slice(1)})}if(n.str.length>1){var u,c=n.str.charAt(0),d=n.str.charAt(1);d in n.node.edges?u=n.node.edges[d]:(u=new R.TokenSet,n.node.edges[d]=u),1==n.str.length&&(u.final=!0),i.push({node:u,editsRemaining:n.editsRemaining-1,str:c+n.str.slice(2)})}}}return r},R.TokenSet.fromString=function(e){for(var t=new R.TokenSet,r=t,i=0,n=e.length;i<n;i++){var s=e[i],o=i==n-1;if("*"==s)t.edges[s]=t,t.final=o;else{var a=new R.TokenSet;a.final=o,t.edges[s]=a,t=a}}return r},R.TokenSet.prototype.toArray=function(){for(var e=[],t=[{prefix:"",node:this}];t.length;){var r=t.pop(),i=Object.keys(r.node.edges),n=i.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(var s=0;s<n;s++){var o=i[s];t.push({prefix:r.prefix.concat(o),node:r.node.edges[o]})}}return e},R.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var e=this.final?"1":"0",t=Object.keys(this.edges).sort(),r=t.length,i=0;i<r;i++){var n=t[i],s=this.edges[n];e=e+n+s.id}return e},R.TokenSet.prototype.intersect=function(e){for(var t=new R.TokenSet,r=void 0,i=[{qNode:e,output:t,node:this}];i.length;)for(var n=Object.keys((r=i.pop()).qNode.edges),s=n.length,o=Object.keys(r.node.edges),a=o.length,l=0;l<s;l++)for(var u=n[l],c=0;c<a;c++){var d=o[c];if(d==u||"*"==u){var h=r.node.edges[d],f=r.qNode.edges[u],p=h.final&&f.final,y=void 0;d in r.output.edges?(y=r.output.edges[d]).final=y.final||p:((y=new R.TokenSet).final=p,r.output.edges[d]=y),i.push({qNode:f,output:y,node:h})}}return t},R.TokenSet.Builder=function(){this.previousWord="",this.root=new R.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},R.TokenSet.Builder.prototype.insert=function(e){var t,r=0;if(e<this.previousWord)throw Error("Out of order word insertion");for(var i=0;i<e.length&&i<this.previousWord.length&&e[i]==this.previousWord[i];i++)r++;this.minimize(r),t=0==this.uncheckedNodes.length?this.root:this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(var i=r;i<e.length;i++){var n=new R.TokenSet,s=e[i];t.edges[s]=n,this.uncheckedNodes.push({parent:t,char:s,child:n}),t=n}t.final=!0,this.previousWord=e},R.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},R.TokenSet.Builder.prototype.minimize=function(e){for(var t=this.uncheckedNodes.length-1;t>=e;t--){var r=this.uncheckedNodes[t],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}},R.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},R.Index.prototype.search=function(e){return this.query(function(t){new R.QueryParser(e,t).parse()})},R.Index.prototype.query=function(e){for(var t=new R.Query(this.fields),r=Object.create(null),i=Object.create(null),n=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a<this.fields.length;a++)i[this.fields[a]]=new R.Vector;e.call(t,t);for(var a=0;a<t.clauses.length;a++){var l=t.clauses[a],u=null,c=R.Set.empty;u=l.usePipeline?this.pipeline.runString(l.term,{fields:l.fields}):[l.term];for(var d=0;d<u.length;d++){l.term=u[d];var h=R.TokenSet.fromClause(l),f=this.tokenSet.intersect(h).toArray();if(0===f.length&&l.presence===R.Query.presence.REQUIRED){for(var p=0;p<l.fields.length;p++){var y=l.fields[p];s[y]=R.Set.empty}break}for(var m=0;m<f.length;m++)for(var g=f[m],v=this.invertedIndex[g],x=v._index,p=0;p<l.fields.length;p++){var y=l.fields[p],w=v[y],E=Object.keys(w),Q=g+"/"+y,b=new R.Set(E);if(l.presence==R.Query.presence.REQUIRED&&(c=c.union(b),void 0===s[y]&&(s[y]=R.Set.complete)),l.presence==R.Query.presence.PROHIBITED){void 0===o[y]&&(o[y]=R.Set.empty),o[y]=o[y].union(b);continue}if(i[y].upsert(x,l.boost,function(e,t){return e+t}),!n[Q]){for(var k=0;k<E.length;k++){var S,L=E[k],T=new R.FieldRef(L,y),P=w[L];void 0===(S=r[T])?r[T]=new R.MatchData(g,y,P):S.add(g,y,P)}n[Q]=!0}}}if(l.presence===R.Query.presence.REQUIRED)for(var p=0;p<l.fields.length;p++){var y=l.fields[p];s[y]=s[y].intersect(c)}}for(var I=R.Set.complete,O=R.Set.empty,a=0;a<this.fields.length;a++){var y=this.fields[a];s[y]&&(I=I.intersect(s[y])),o[y]&&(O=O.union(o[y]))}var F=Object.keys(r),C=[],N=Object.create(null);if(t.isNegated()){F=Object.keys(this.fieldVectors);for(var a=0;a<F.length;a++){var T=F[a],j=R.FieldRef.fromString(T);r[T]=new R.MatchData}}for(var a=0;a<F.length;a++){var j=R.FieldRef.fromString(F[a]),D=j.docRef;if(I.contains(D)&&!O.contains(D)){var _,A=this.fieldVectors[j],z=i[j.fieldName].similarity(A);if(void 0!==(_=N[D]))_.score+=z,_.matchData.combine(r[j]);else{var M={ref:D,score:z,matchData:r[j]};N[D]=M,C.push(M)}}}return C.sort(function(e,t){return t.score-e.score})},R.Index.prototype.toJSON=function(){var e=Object.keys(this.invertedIndex).sort().map(function(e){return[e,this.invertedIndex[e]]},this),t=Object.keys(this.fieldVectors).map(function(e){return[e,this.fieldVectors[e].toJSON()]},this);return{version:R.version,fields:this.fields,fieldVectors:t,invertedIndex:e,pipeline:this.pipeline.toJSON()}},R.Index.load=function(e){var t={},r={},i=e.fieldVectors,n=Object.create(null),s=e.invertedIndex,o=new R.TokenSet.Builder,a=R.Pipeline.load(e.pipeline);e.version!=R.version&&R.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+R.version+"' does not match serialized index '"+e.version+"'");for(var l=0;l<i.length;l++){var u=i[l],c=u[0],d=u[1];r[c]=new R.Vector(d)}for(var l=0;l<s.length;l++){var u=s[l],h=u[0],f=u[1];o.insert(h),n[h]=f}return o.finish(),t.fields=e.fields,t.fieldVectors=r,t.invertedIndex=n,t.tokenSet=o.root,t.pipeline=a,new R.Index(t)},R.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=R.tokenizer,this.pipeline=new R.Pipeline,this.searchPipeline=new R.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},R.Builder.prototype.ref=function(e){this._ref=e},R.Builder.prototype.field=function(e,t){if(/\//.test(e))throw RangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=t||{}},R.Builder.prototype.b=function(e){e<0?this._b=0:e>1?this._b=1:this._b=e},R.Builder.prototype.k1=function(e){this._k1=e},R.Builder.prototype.add=function(e,t){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=t||{},this.documentCount+=1;for(var n=0;n<i.length;n++){var s=i[n],o=this._fields[s].extractor,a=o?o(e):e[s],l=this.tokenizer(a,{fields:[s]}),u=this.pipeline.run(l),c=new R.FieldRef(r,s),d=Object.create(null);this.fieldTermFrequencies[c]=d,this.fieldLengths[c]=0,this.fieldLengths[c]+=u.length;for(var h=0;h<u.length;h++){var f=u[h];if(void 0==d[f]&&(d[f]=0),d[f]+=1,void 0==this.invertedIndex[f]){var p=Object.create(null);p._index=this.termIndex,this.termIndex+=1;for(var y=0;y<i.length;y++)p[i[y]]=Object.create(null);this.invertedIndex[f]=p}void 0==this.invertedIndex[f][s][r]&&(this.invertedIndex[f][s][r]=Object.create(null));for(var m=0;m<this.metadataWhitelist.length;m++){var g=this.metadataWhitelist[m],v=f.metadata[g];void 0==this.invertedIndex[f][s][r][g]&&(this.invertedIndex[f][s][r][g]=[]),this.invertedIndex[f][s][r][g].push(v)}}}},R.Builder.prototype.calculateAverageFieldLengths=function(){for(var e=Object.keys(this.fieldLengths),t=e.length,r={},i={},n=0;n<t;n++){var s=R.FieldRef.fromString(e[n]),o=s.fieldName;i[o]||(i[o]=0),i[o]+=1,r[o]||(r[o]=0),r[o]+=this.fieldLengths[s]}for(var a=Object.keys(this._fields),n=0;n<a.length;n++){var l=a[n];r[l]=r[l]/i[l]}this.averageFieldLength=r},R.Builder.prototype.createFieldVectors=function(){for(var e={},t=Object.keys(this.fieldTermFrequencies),r=t.length,i=Object.create(null),n=0;n<r;n++){for(var s=R.FieldRef.fromString(t[n]),o=s.fieldName,a=this.fieldLengths[s],l=new R.Vector,u=this.fieldTermFrequencies[s],c=Object.keys(u),d=c.length,h=this._fields[o].boost||1,f=this._documents[s.docRef].boost||1,p=0;p<d;p++){var y,m,g=c[p],v=u[g],x=this.invertedIndex[g]._index;void 0===i[g]?(y=R.idf(this.invertedIndex[g],this.documentCount),i[g]=y):y=i[g],m=Math.round(1e3*(y*((this._k1+1)*v)/(this._k1*(1-this._b+this._b*(a/this.averageFieldLength[o]))+v)*h*f))/1e3,l.insert(x,m)}e[s]=l}this.fieldVectors=e},R.Builder.prototype.createTokenSet=function(){this.tokenSet=R.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},R.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new R.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},R.Builder.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},R.MatchData=function(e,t,r){for(var i=Object.create(null),n=Object.keys(r||{}),s=0;s<n.length;s++){var o=n[s];i[o]=r[o].slice()}this.metadata=Object.create(null),void 0!==e&&(this.metadata[e]=Object.create(null),this.metadata[e][t]=i)},R.MatchData.prototype.combine=function(e){for(var t=Object.keys(e.metadata),r=0;r<t.length;r++){var i=t[r],n=Object.keys(e.metadata[i]);void 0==this.metadata[i]&&(this.metadata[i]=Object.create(null));for(var s=0;s<n.length;s++){var o=n[s],a=Object.keys(e.metadata[i][o]);void 0==this.metadata[i][o]&&(this.metadata[i][o]=Object.create(null));for(var l=0;l<a.length;l++){var u=a[l];void 0==this.metadata[i][o][u]?this.metadata[i][o][u]=e.metadata[i][o][u]:this.metadata[i][o][u]=this.metadata[i][o][u].concat(e.metadata[i][o][u])}}}},R.MatchData.prototype.add=function(e,t,r){if(!(e in this.metadata)){this.metadata[e]=Object.create(null),this.metadata[e][t]=r;return}if(!(t in this.metadata[e])){this.metadata[e][t]=r;return}for(var i=Object.keys(r),n=0;n<i.length;n++){var s=i[n];s in this.metadata[e][t]?this.metadata[e][t][s]=this.metadata[e][t][s].concat(r[s]):this.metadata[e][t][s]=r[s]}},R.Query=function(e){this.clauses=[],this.allFields=e},R.Query.wildcard=new String("*"),R.Query.wildcard.NONE=0,R.Query.wildcard.LEADING=1,R.Query.wildcard.TRAILING=2,R.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},R.Query.prototype.clause=function(e){return"fields"in e||(e.fields=this.allFields),"boost"in e||(e.boost=1),"usePipeline"in e||(e.usePipeline=!0),"wildcard"in e||(e.wildcard=R.Query.wildcard.NONE),e.wildcard&R.Query.wildcard.LEADING&&e.term.charAt(0)!=R.Query.wildcard&&(e.term="*"+e.term),e.wildcard&R.Query.wildcard.TRAILING&&e.term.slice(-1)!=R.Query.wildcard&&(e.term=""+e.term+"*"),"presence"in e||(e.presence=R.Query.presence.OPTIONAL),this.clauses.push(e),this},R.Query.prototype.isNegated=function(){for(var e=0;e<this.clauses.length;e++)if(this.clauses[e].presence!=R.Query.presence.PROHIBITED)return!1;return!0},R.Query.prototype.term=function(e,t){if(Array.isArray(e))return e.forEach(function(e){this.term(e,R.utils.clone(t))},this),this;var r=t||{};return r.term=e.toString(),this.clause(r),this},R.QueryParseError=function(e,t,r){this.name="QueryParseError",this.message=e,this.start=t,this.end=r},R.QueryParseError.prototype=Error(),R.QueryLexer=function(e){this.lexemes=[],this.str=e,this.length=e.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},R.QueryLexer.prototype.run=function(){for(var e=R.QueryLexer.lexText;e;)e=e(this)},R.QueryLexer.prototype.sliceString=function(){for(var e=[],t=this.start,r=this.pos,i=0;i<this.escapeCharPositions.length;i++)r=this.escapeCharPositions[i],e.push(this.str.slice(t,r)),t=r+1;return e.push(this.str.slice(t,this.pos)),this.escapeCharPositions.length=0,e.join("")},R.QueryLexer.prototype.emit=function(e){this.lexemes.push({type:e,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},R.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},R.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return R.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},R.QueryLexer.prototype.width=function(){return this.pos-this.start},R.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},R.QueryLexer.prototype.backup=function(){this.pos-=1},R.QueryLexer.prototype.acceptDigitRun=function(){var e,t;do t=(e=this.next()).charCodeAt(0);while(t>47&&t<58)e!=R.QueryLexer.EOS&&this.backup()},R.QueryLexer.prototype.more=function(){return this.pos<this.length},R.QueryLexer.EOS="EOS",R.QueryLexer.FIELD="FIELD",R.QueryLexer.TERM="TERM",R.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",R.QueryLexer.BOOST="BOOST",R.QueryLexer.PRESENCE="PRESENCE",R.QueryLexer.lexField=function(e){return e.backup(),e.emit(R.QueryLexer.FIELD),e.ignore(),R.QueryLexer.lexText},R.QueryLexer.lexTerm=function(e){if(e.width()>1&&(e.backup(),e.emit(R.QueryLexer.TERM)),e.ignore(),e.more())return R.QueryLexer.lexText},R.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(R.QueryLexer.EDIT_DISTANCE),R.QueryLexer.lexText},R.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(R.QueryLexer.BOOST),R.QueryLexer.lexText},R.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(R.QueryLexer.TERM)},R.QueryLexer.termSeparator=R.tokenizer.separator,R.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==R.QueryLexer.EOS)return R.QueryLexer.lexEOS;if(92==t.charCodeAt(0)){e.escapeCharacter();continue}if(":"==t)return R.QueryLexer.lexField;if("~"==t)return e.backup(),e.width()>0&&e.emit(R.QueryLexer.TERM),R.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),e.width()>0&&e.emit(R.QueryLexer.TERM),R.QueryLexer.lexBoost;if("+"==t&&1===e.width()||"-"==t&&1===e.width())return e.emit(R.QueryLexer.PRESENCE),R.QueryLexer.lexText;if(t.match(R.QueryLexer.termSeparator))return R.QueryLexer.lexTerm}},R.QueryParser=function(e,t){this.lexer=new R.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},R.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=R.QueryParser.parseClause;e;)e=e(this);return this.query},R.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},R.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},R.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},R.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(void 0!=t)switch(t.type){case R.QueryLexer.PRESENCE:return R.QueryParser.parsePresence;case R.QueryLexer.FIELD:return R.QueryParser.parseField;case R.QueryLexer.TERM:return R.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+t.type;throw t.str.length>=1&&(r+=" with value '"+t.str+"'"),new R.QueryParseError(r,t.start,t.end)}},R.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(void 0!=t){switch(t.str){case"-":e.currentClause.presence=R.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=R.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+t.str+"'";throw new R.QueryParseError(r,t.start,t.end)}var i=e.peekLexeme();if(void 0==i){var r="expecting term or field, found nothing";throw new R.QueryParseError(r,t.start,t.end)}switch(i.type){case R.QueryLexer.FIELD:return R.QueryParser.parseField;case R.QueryLexer.TERM:return R.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new R.QueryParseError(r,i.start,i.end)}}},R.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(void 0!=t){if(-1==e.query.allFields.indexOf(t.str)){var r=e.query.allFields.map(function(e){return"'"+e+"'"}).join(", "),i="unrecognised field '"+t.str+"', possible fields: "+r;throw new R.QueryParseError(i,t.start,t.end)}e.currentClause.fields=[t.str];var n=e.peekLexeme();if(void 0==n){var i="expecting term, found nothing";throw new R.QueryParseError(i,t.start,t.end)}if(n.type===R.QueryLexer.TERM)return R.QueryParser.parseTerm;var i="expecting term, found '"+n.type+"'";throw new R.QueryParseError(i,n.start,n.end)}},R.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(void 0!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(void 0==r)return void e.nextClause();switch(r.type){case R.QueryLexer.TERM:return e.nextClause(),R.QueryParser.parseTerm;case R.QueryLexer.FIELD:return e.nextClause(),R.QueryParser.parseField;case R.QueryLexer.EDIT_DISTANCE:return R.QueryParser.parseEditDistance;case R.QueryLexer.BOOST:return R.QueryParser.parseBoost;case R.QueryLexer.PRESENCE:return e.nextClause(),R.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new R.QueryParseError(i,r.start,r.end)}}},R.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(void 0!=t){var r=parseInt(t.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new R.QueryParseError(i,t.start,t.end)}e.currentClause.editDistance=r;var n=e.peekLexeme();if(void 0==n)return void e.nextClause();switch(n.type){case R.QueryLexer.TERM:return e.nextClause(),R.QueryParser.parseTerm;case R.QueryLexer.FIELD:return e.nextClause(),R.QueryParser.parseField;case R.QueryLexer.EDIT_DISTANCE:return R.QueryParser.parseEditDistance;case R.QueryLexer.BOOST:return R.QueryParser.parseBoost;case R.QueryLexer.PRESENCE:return e.nextClause(),R.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+n.type+"'";throw new R.QueryParseError(i,n.start,n.end)}}},R.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(void 0!=t){var r=parseInt(t.str,10);if(isNaN(r)){var i="boost must be numeric";throw new R.QueryParseError(i,t.start,t.end)}e.currentClause.boost=r;var n=e.peekLexeme();if(void 0==n)return void e.nextClause();switch(n.type){case R.QueryLexer.TERM:return e.nextClause(),R.QueryParser.parseTerm;case R.QueryLexer.FIELD:return e.nextClause(),R.QueryParser.parseField;case R.QueryLexer.EDIT_DISTANCE:return R.QueryParser.parseEditDistance;case R.QueryLexer.BOOST:return R.QueryParser.parseBoost;case R.QueryLexer.PRESENCE:return e.nextClause(),R.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+n.type+"'";throw new R.QueryParseError(i,n.start,n.end)}}},O=function(){return R},"function"==typeof define&&define.amd?define(O):e.exports=O()}()},95655(e,t,r){"use strict";let i=Symbol("Comlink.proxy"),n=Symbol("Comlink.endpoint"),s=Symbol("Comlink.releaseProxy"),o=Symbol("Comlink.finalizer"),a=Symbol("Comlink.thrown"),l=e=>"object"==typeof e&&null!==e||"function"==typeof e,u=new Map([["proxy",{canHandle:e=>l(e)&&e[i],serialize(e){let{port1:t,port2:r}=new MessageChannel;return c(e,t),[r,[r]]},deserialize:e=>{var t;let r;return e.start(),t=e,r=new Map,t.addEventListener("message",function(e){let{data:t}=e;if(!t||!t.id)return;let i=r.get(t.id);if(i)try{i(t)}finally{r.delete(t.id)}}),function e(t,r,i=[],o=function(){}){let a,l=!1,u=new Proxy(o,{get(n,o){if(h(l),o===s)return()=>{y&&y.unregister(u),f(t),r.clear(),l=!0};if("then"===o){if(0===i.length)return{then:()=>u};let e=w(t,r,{type:"GET",path:i.map(e=>e.toString())}).then(x);return e.then.bind(e)}return e(t,r,[...i,o])},set(e,n,s){h(l);let[o,a]=v(s);return w(t,r,{type:"SET",path:[...i,n].map(e=>e.toString()),value:o},a).then(x)},apply(s,o,a){h(l);let u=i[i.length-1];if(u===n)return w(t,r,{type:"ENDPOINT"}).then(x);if("bind"===u)return e(t,r,i.slice(0,-1));let[c,d]=m(a);return w(t,r,{type:"APPLY",path:i.map(e=>e.toString()),argumentList:c},d).then(x)},construct(e,n){h(l);let[s,o]=m(n);return w(t,r,{type:"CONSTRUCT",path:i.map(e=>e.toString()),argumentList:s},o).then(x)}});return a=(p.get(t)||0)+1,p.set(t,a),y&&y.register(u,t,u),u}(t,r,[],void 0)}}],["throw",{canHandle:e=>l(e)&&a in e,serialize:({value:e})=>[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]],deserialize(e){if(e.isError)throw Object.assign(Error(e.value.message),e.value);throw e.value}}]]);function c(e,t=globalThis,r=["*"]){t.addEventListener("message",function n(s){let l;if(!s||!s.data)return;if(!function(e,t){for(let r of e)if(t===r||"*"===r||r instanceof RegExp&&r.test(t))return!0;return!1}(r,s.origin))return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);let{id:u,type:h,path:f}=Object.assign({path:[]},s.data),p=(s.data.argumentList||[]).map(x);try{var y,m,w;let t=f.slice(0,-1).reduce((e,t)=>e[t],e),r=f.reduce((e,t)=>e[t],e);switch(h){case"GET":l=r;break;case"SET":t[f.slice(-1)[0]]=x(s.data.value),l=!0;break;case"APPLY":l=r.apply(t,p);break;case"CONSTRUCT":y=new r(...p),l=Object.assign(y,{[i]:!0});break;case"ENDPOINT":{let{port1:t,port2:r}=new MessageChannel;c(e,r),m=t,w=[t],g.set(m,w),l=m}break;case"RELEASE":l=void 0;break;default:return}}catch(e){l={value:e,[a]:0}}Promise.resolve(l).catch(e=>({value:e,[a]:0})).then(r=>{let[i,s]=v(r);t.postMessage(Object.assign(Object.assign({},i),{id:u}),s),"RELEASE"===h&&(t.removeEventListener("message",n),d(t),o in e&&"function"==typeof e[o]&&e[o]())}).catch(e=>{let[r,i]=v({value:TypeError("Unserializable return value"),[a]:0});t.postMessage(Object.assign(Object.assign({},r),{id:u}),i)})}),t.start&&t.start()}function d(e){"MessagePort"===e.constructor.name&&e.close()}function h(e){if(e)throw Error("Proxy has been released and is not useable")}function f(e){return w(e,new Map,{type:"RELEASE"}).then(()=>{d(e)})}let p=new WeakMap,y="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(p.get(e)||0)-1;p.set(e,t),0===t&&f(e)});function m(e){var t;let r=e.map(v);return[r.map(e=>e[0]),(t=r.map(e=>e[1]),Array.prototype.concat.apply([],t))]}let g=new WeakMap;function v(e){for(let[t,r]of u)if(r.canHandle(e)){let[i,n]=r.serialize(e);return[{type:"HANDLER",name:t,value:i},n]}return[{type:"RAW",value:e},g.get(e)||[]]}function x(e){switch(e.type){case"HANDLER":return u.get(e.name).deserialize(e.value);case"RAW":return e.value}}function w(e,t,r,i){return new Promise(n=>{let s=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(s,n),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),i)})}var E,Q,b=r(58291),k=r.n(b),S=r(86897);function L(e,t,r){return e.flatMap(e=>{let i={tokens:e.map(e=>e.value),term:e.map(e=>{let i=r?e.trailing||e.maybeTyping:e.trailing,n=t>0&&e.value.length>t?t:void 0;return{value:e.value,presence:k().Query.presence.REQUIRED,wildcard:i?k().Query.wildcard.TRAILING:k().Query.wildcard.NONE,editDistance:n}})};return t&&i.term.every(e=>!e.editDistance)?[]:i})}function T(e,t){return Array.from({length:t+1},(t,r)=>L(e,r).concat(L(e.filter(e=>{let t=e[e.length-1];return!t.trailing&&t.maybeTyping}),r,!0))).flat()}(E=Q||(Q={}))[E.Title=0]="Title",E[E.Heading=1]="Heading",E[E.Description=2]="Description",E[E.Keywords=3]="Keywords",E[E.Content=4]="Content",E[E.AskAI=5]="AskAI";let P=new Map;async function I(e,t){let r=`${e}${S.IH.replace("{dir}",t?`-${t.replace(/\//g,"-")}`:"")}`;if(new URL(r,location.origin).origin!==location.origin)throw Error("Unexpected version url");let i=await (await fetch(r)).json();return{wrappedIndexes:i.map(({documents:e,index:t},r)=>({type:r,documents:e,index:k().Index.load(t)})),zhDictionary:Array.from(i.reduce((e,t)=>{for(let r of t.index.invertedIndex)/\p{Unified_Ideograph}/u.test(r[0][0])&&e.add(r[0]);return e},new Set))}}c(class{async fetchIndexes(e,t){await this.lowLevelFetchIndexes(e,t)}async lowLevelFetchIndexes(e,t){let r=`${e}${t}`,i=P.get(r);return i||(i=I(e,t),P.set(r,i)),i}async search(e,t,r,i){let n=function(e,t){if(1===t.length&&["ja","jp","th"].includes(t[0]))return k()[t[0]].tokenizer(e).map(e=>e.toString());let r=/[^-\s]+/g;return t.includes("zh")&&(r=/\w+|\p{Unified_Ideograph}+/gu),e.toLowerCase().match(r)||[]}(r,S.BH);if(0===n.length)return[];let{wrappedIndexes:s,zhDictionary:o}=await this.lowLevelFetchIndexes(e,t),a=function(e,t){let r,i=function(e,t){let r=e.map(e=>{let r;if(!/\p{Unified_Ideograph}/u.test(e))return[{value:e}];return r=[],!function e(i,n){let s=0,o=!1;for(let a of t)if(i.substr(0,a.length)===a){let t={missed:n.missed,term:n.term.concat({value:a})};i.length>a.length?e(i.substr(a.length),t):r.push(t),o=!0}else for(let t=a.length-1;t>s;t-=1){let l=a.substr(0,t);if(i.substr(0,t)===l){s=t;let a={missed:n.missed,term:n.term.concat({value:l,trailing:!0})};i.length>t?e(i.substr(t),a):r.push(a),o=!0;break}}!o&&(i.length>0?e(i.substr(1),{missed:n.missed+1,term:n.term}):n.term.length>0&&r.push(n))}(e,{missed:0,term:[]}),r.sort((e,t)=>{let r=+(e.missed>0),i=+(t.missed>0);return r!==i?r-i:e.term.length-t.term.length}).map(e=>e.term)}).slice(0,12),i=r.filter(e=>e.length>1),n=1,s=!1;for(let e of i)if(s)e.splice(1,e.length-1);else{e.length>6&&e.splice(6,e.length-6);let t=n*e.length;if(t>=12){if(t>12){let t=Math.floor(12/n);e.splice(t,e.length-t),n*=t}else n=t;n>6&&(s=!0)}else n=t}let o=[];return!function e(t,i){if(t===r.length||i.length>=12)return void o.push(i.slice(0,12));for(let n of r[t])e(t+1,i.concat(n))}(0,[]),o}(e,t);if(0===i.length)return[{tokens:e,term:e.map(e=>({value:e,presence:k().Query.presence.REQUIRED,wildcard:k().Query.wildcard.LEADING|k().Query.wildcard.TRAILING}))}];for(let e of i)e[e.length-1].maybeTyping=!0;let n=[];for(let e of S.BH)if("en"===e)S.sx.includes(e)||n.unshift(k().stopWordFilter);else{let t=k()[e];t.stopWordFilter&&!S.sx.includes(e)&&n.unshift(t.stopWordFilter)}if(n.length>0){let e=e=>n.reduce((e,t)=>e.filter(e=>t(e.value)),e);r=[];let t=[];for(let n of i){let i=e(n);r.push(i),i.length<n.length&&i.length>0&&t.push(i)}i.push(...t)}else r=i.slice();let s=[];for(let e of r)if(e.length>2)for(let t=e.length-1;t>=0;t-=1)s.push(e.slice(0,t).concat(e.slice(t+1)));return T(i,1).concat(T(s,1))}(n,o),l=[];e:for(let{term:e,tokens:t}of a)for(let{documents:r,index:n,type:o}of s)if(l.push(...n.query(t=>{for(let r of e)t.term(r.value,{wildcard:r.wildcard,presence:r.presence,...r.editDistance?{editDistance:r.editDistance}:null})}).slice(0,i).filter(e=>!l.some(t=>t.document.i.toString()===e.ref)).slice(0,i-l.length).map(e=>{let i=r.find(t=>t.i.toString()===e.ref);return{document:i,type:o,page:o!==Q.Title&&s[0].documents.find(e=>e.i===i.p),metadata:e.matchData.metadata,tokens:t,score:e.score}})),l.length>=i)break e;return l.forEach((e,t)=>{e.index=t}),l.sort((e,t)=>{let r=(e.type===Q.Heading||e.type===Q.Content||e.type===Q.Description)&&e.page?l.findIndex(t=>t.document===e.page):e.index,i=(t.type===Q.Heading||t.type===Q.Content||t.type===Q.Description)&&t.page?l.findIndex(e=>e.document===t.page):t.index;if(-1===r&&(r=e.index),-1===i&&(i=t.index),r===i){let r=(0===t.type)-(0===e.type);return 0===r?e.index-t.index:r}return r-i}),l.forEach((e,t)=>{t>0&&e.page&&l.slice(0,t).some(t=>(t.type===Q.Keywords?t.page:t.document)===e.page)&&(t<l.length-1&&l[t+1].page===e.page?e.isInterOfTree=!0:e.isLastOfTree=!0)}),l}})}}]);