"use strict";(()=>{var ge=Object.create;var K=Object.defineProperty,me=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,ye=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertyNames,W=Object.getOwnPropertySymbols,we=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var B=(e,t,n)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||(t={}))Y.call(t,n)&&B(e,n,t[n]);if(W)for(var n of W(t))Te.call(t,n)&&B(e,n,t[n]);return e},Q=(e,t)=>me(e,ye(t));var be=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ee=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of ve(t))!Y.call(e,l)&&l!==n&&K(e,l,{get:()=>t[l],enumerable:!(r=xe(t,l))||r.enumerable});return e};var Me=(e,t,n)=>(n=e!=null?ge(we(e)):{},Ee(t||!e||!e.__esModule?K(n,"default",{value:e,enumerable:!0}):n,e));var L=(e,t,n)=>B(e,typeof t!="symbol"?t+"":t,n);var k=(e,t,n)=>new Promise((r,l)=>{var a=i=>{try{s(n.next(i))}catch(u){l(u)}},o=i=>{try{s(n.throw(i))}catch(u){l(u)}},s=i=>i.done?r(i.value):Promise.resolve(i.value).then(a,o);s((n=n.apply(e,t)).next())});var he=be(de=>{"use strict";function j(e,t,n={}){return{name:e,from:t,meta:n}}function H(e,t){let n=[{value:e,depth:0}];for(let r=0,l=-1,a=0;r>=0;){let{value:o,depth:s}=n[r];if(l<=s&&o.type==="operator"&&o.data.operands.length>0)for(let i=o.data.operands.length;i>0;)n[++r]={value:o.data.operands[--i],depth:s+1};else{let i=t(o,a++,s);if(typeof i<"u")return i;--r}l=s}}var C=class extends Error{constructor(e,t){super(t),this.code=e}};function $(e,t){let n=ke(e);for(let r=0;r{let{matches:r}=n;for(let l=0;l{let l=t.get(n);return typeof l>"u"&&t.set(n,l=e(n,...r)),l}}function P(e,t){return Object.defineProperty(t,"name",{value:e}),t}function ee(e){return k(this,null,function*(){let t=[];if(typeof e.plugins<"u")for(let n=0;n32)throw new RangeError("Bit format exceeds 32 bits");return e}function ne(e,t,n){let r=N(e),l=N(t),a=typeof n<"u"?N(n):32-r-l;return ze({d:r,f:l,x:a})}var b=[0];for(let e=0;e<32;e++)b.push(b[e]|1<=n&&e{t+=r*r}),Math.sqrt(t)}function Ae(e,t){e instanceof J?e.data.forEach((n,r)=>{t(n,r)}):e.forEach((n,r)=>{t({start:n,end:n+1,value:1},r)})}var S=class{constructor(e,t=Qe(Math.ceil(e/32))){this.size=e,this.data=t}get(e){return this.data[e>>>5]>>>e&1}set(e){this.data[e>>>5]|=1<<(e&31)}forEach(e){let t=this.size&31;for(let n=0;n>>0;for(let n=0;n0;l++){let{value:a,depth:o}=n[--r],s=t(a,l,o);if(typeof s<"u")return s;for(let i=a.children.length;i>0;)n[r++]={value:a.children[--i],depth:o+1}}}function Se(e,t){return k(this,null,function*(){let{fields:n,plugins:r=[]}=t,l=ne(e.length,n.length),a=[];for(let i=0;i"u")continue;let f=i<{var m;return(m=g.onFilterInput)==null?void 0:m.call(g,p,f,l)},d);let c=a[u],h=M();d=Array.isArray(d)?d:[d];for(let p=0;p{let v=c.index.get(m.node);typeof v>"u"&&c.index.set(m.node,v=M());let w=c.terms.length;for(let T=0;T{var u;return(u=i.onFilterStore)==null?void 0:u.call(i,s,t,e)}),s})}function je(e,t,n,r={}){let l=[];if(t<0||t>=e.count.fields)return l;let a=e.shards[t],o=new Map,{count:s=1/0,depth:i=1/0}=r;for(let u=0;ui)continue;let p=o.get(d);typeof p>"u"&&o.set(d,p={node:f,children:[]});let g=l;h>0&&(g=o.get(a.terms[c]).children),g.length=e.count.fields)return{documents:r,terms:l};let a=e.shards[n];return t.forEach(o=>{let{occurrences:s}=a.terms[o];for(let i=0;i>>e.space.x>>>e.space.f;r.set(u)}l[n].set(o)}),{documents:r,terms:l}}function Pe(e){let{documents:t,terms:n}=U(e);z(t,1);for(let r=0;rnew S(t.length))}}function De(e,t,n){let{compiler:r,fields:l,plugins:a=[]}=n,{input:o,scope:s,abort:i=!1}=q(a,(f,c)=>{var h;return(h=c.onFilterQuery)==null?void 0:h.call(c,f,e,n)},t),u={items:[],query:{select:U(e),values:[]}},d=new Map;if(i===!1){let f=r(n),{select:c,values:h}=f(o,e);typeof s<"u"&&V(c.documents,s);let p=new Map;u.query={select:c,values:h},c.terms.forEach((g,m)=>{g.forEach(y=>{let x=e.shards[m],{occurrences:v}=x.terms[y];for(let w=0;w>>e.space.x,F=T>>>e.space.f;if(!c.documents.get(F))continue;let I=p.get(T);typeof I>"u"&&p.set(T,I=new D(M()));let pe=E&b[e.space.x];I.add(pe,y)}})}),c.documents.forEach(g=>{let m={id:g,matches:[]};u.items.push(m),d.set(g,m)}),p.forEach((g,m)=>{let y=m>>>e.space.f,x=m&b[e.space.f];d.get(y).matches.push({id:m,field:l[x].name,value:{filter:g},score:0})})}return q(a,(f,c)=>{var h;return(h=c.onFilterResult)==null?void 0:h.call(c,f,e,n)},u)}function oe(e){let{fields:t}=e;return(n,r)=>{if(qe(n))return n;let l=[Pe(r)],a=[],o=0;return H(n,({type:s,data:i})=>{switch(s){case"value":let u=t.findIndex(({name:c})=>c===i.field);if(u===-1){l[o++]=U(r);break}let d=i.value;if(typeof d!="object"){let c=new D(M()),h=r.shards[u],p=h.index.get(d);if(typeof p<"u")for(let g=0;gf+1&&o--;){A(l[f].documents,l[o].documents);for(let c=0;cf+1&&o--;){V(l[f].documents,l[o].documents);for(let c=0;cf+1&&o--;)le(l[f].documents,l[o].documents)}}}),{select:l[0],values:a}}}function Ve(e){return{name:e.name,data:e.data,onFilterOptions:e.onFilterOptions,onFilterInput:e.onFilterInput,onFilterStore:e.onFilterStore,onFilterQuery:e.onFilterQuery,onFilterResult:e.onFilterResult}}function Ue(e){return typeof e=="object"&&e!==null&&"type"in e&&"data"in e}function _e(e){return typeof e=="object"&&e!==null&&"select"in e&&"values"in e}function Be(e){return e.normalize("NFKD").toLowerCase()}function Ke(e,t){let n=Math.min(e.length,t.length);for(let r=0;r65535)){let a=t(l=e.codePointAt(n),n);if(typeof a<"u")return a}}function se(e,t,n=0,r=e.length){let l=M();return Le(e,a=>{l.push(a);let o=t(String.fromCodePoint(...l),l.length);if(typeof o<"u")return o},n,r)}function Ne(e,t,n=0,r=e.length){let l=n;for(let a=0;ln&&t(n,n=l);continue;case 62:n=l+1}l>n&&t(n,l)}function ie(e,t,n,r=0){return Ne(e,(l,a)=>t(e,(o,s)=>{r=n({value:e.slice(o,s),index:r,start:o,end:s})},l,a)),r}function Ge(e,t,n,r=0){for(let l=0,a=0;l(o.start+=a,o.end+=a,n(o)),r);return r}function He(e){let t=new RegExp(e,"gu");return(n,r,l=0,a=n.length)=>{var i;t.lastIndex=l;let o,s=0;do{o=t.exec(n);let u=(i=o==null?void 0:o.index)!=null?i:a;l"u")continue;let p=f<{var y;return(y=m.onTextInput)==null?void 0:y.call(m,g,p,o)},h),h=Array.isArray(h)?h:[h],Ge(h,n,g=>{let m=q(a,(y,x)=>{var v;return(v=x.onTextTokens)==null?void 0:v.call(x,y)},[g]);for(let y=0;y"u"?s.set(x,[p<{var c;return(c=f.onTextStore)==null?void 0:c.call(f,u,t,e)}),u})}function We(e,t,n){let{documents:r,terms:l}=_(e);return n<0||n>=e.count.fields?{documents:r,terms:l}:(t.forEach(a=>{let{occurrences:o}=e.terms[a];for(let s=0;s>>e.space.x;if((i&b[e.space.f])!==n)continue;let u=i>>>e.space.f;r.set(u)}l.set(a)}),{documents:r,terms:l})}function Ye(e,t){let{documents:n,terms:r}=_(e),l=e.space.f+e.space.x;return t.forEach(a=>{let{occurrences:o}=e.terms[a];for(let s=0;s>>l);r.set(a)}),{documents:n,terms:r}}function _(e){return{documents:new S(e.count.documents),terms:new S(e.terms.length)}}function Ze(e,t,n){let{compiler:r,fields:l,plugins:a=[]}=n,{input:o,scope:s,abort:i=!1}=q(a,(f,c)=>{var h;return(h=c.onTextQuery)==null?void 0:h.call(c,f,e,n)},t),u={items:[],query:{select:_(e),values:[]}},d=new Map;if(i===!1){let f=r(n),{select:c,values:h}=f(o,e);typeof s<"u"&&V(c.documents,s);let p=new S(l.length),g=new Map;u.query={select:c,values:h},c.terms.forEach(m=>{z(p,0);for(let x=0;x>>e.space.x,E=w>>>e.space.f;if(!c.documents.get(E))continue;let T=w&b[e.space.f];if(!p.get(T))continue;let F=g.get(w);typeof F>"u"&&g.set(w,F=new D(M()));let I=v&b[e.space.x];F.add(I,m)}}),c.documents.forEach(m=>{let y={id:m,matches:[]};u.items.push(y),d.set(m,y)}),g.forEach((m,y)=>{let x=y>>>e.space.f,v=y&b[e.space.f];d.get(x).matches.push({id:y,field:l[v].name,value:{text:m},score:0})})}return q(a,(f,c)=>{var h;return(h=c.onTextResult)==null?void 0:h.call(c,f,e,n)},u)}function $e(e,t=10){return e.length>1?1+e[e.length-1]-e[0]:t}function Xe(e,t,n,r=10){let l=[];e.value.text.forEach((s,i)=>{for(let u=0;us.index-i.index);let a=l.slice(0,1),o=0;for(let s=0;sr||u.value===i.value)d=a.map(({index:f})=>f),a=[l[s+1]];else{for(let f=0;fu.index-i.index){let h=a.splice(f+1);d=a.map(({index:p})=>p),a=[...h,l[s+1]]}else d=a.map(({index:h})=>h),a=[l[s+1]];break}}typeof d>"u"&&a.push(l[s+1])}if(typeof d<"u"){let f=n(d,o++);if(typeof f<"u")return f}}if(a.length)return n(a.map(({index:s})=>s),o)}function et(e){let{transform:t,parser:n,fields:r}=e,l=n(e);return(a,o)=>{if(_e(a))return a;typeof a=="string"&&(a=l(a));let s=[_(o)],i=[],u=0;return H(a,({type:d,data:f})=>{switch(d){case"value":let c=f.value;if(typeof c=="string"){let p=new D(M()),g=o.index.get(t(c));typeof g<"u"&&p.add(g,1),c=p}if(f.field==="*")s[u++]=Ye(o,c);else{let p=r.findIndex(({name:g})=>g===f.field);s[u++]=We(o,c,p)}i.push(Q(R({},f),{value:c}));break;case"operator":let h=u-f.operands.length;switch(f.operator){case"or":for(;u>h+1&&u--;)A(s[h].documents,s[u].documents),A(s[h].terms,s[u].terms);break;case"and":for(;u>h+1&&u--;)V(s[h].documents,s[u].documents),A(s[h].terms,s[u].terms);break;case"not":for(ae(s[h].documents),z(s[h].terms,0);u>h+1&&u--;)le(s[h].documents,s[u].documents)}}}),{select:s[0],values:i}}}function tt(e,t){return H(e,(n,r,l)=>{if(n.type!=="value")return;let a=t(n.data,r,l);if(typeof a<"u")return a})}function ue(e){if(e.length===0)return[];let t=[],n=[];for(let a=0;aa.index-o.index);let r=new Set([n[0].value]),l=n[0].index;for(let a=1;a{e[u].start>l||e[u].end{t.push({start:l,end:a,value:n})})}return new J(ue(t))}function nt(e,t="or",n){let{separator:r}=e;return n!=null||(n=l=>({field:"*",value:l.value})),l=>{let a=[];return ie(l,r,o=>{let s=n(o);typeof s<"u"&&a.push({type:"value",data:s})}),{type:"operator",data:{operator:t,operands:a}}}}function rt(e,t){return k(this,null,function*(){let n=yield ee(t),r=yield Fe(n,(a,o)=>{var s;return(s=o.onTextOptions)==null?void 0:s.call(o,a,e)},Q(R({},t),{plugins:n})),l=yield Je(e,r);return P("text",a=>{if(a.type!=="text")throw new C("unsupported");return{type:a.type,data:Ze(l,a.data,r)}})})}function O(e){return{name:e.name,data:e.data,onTextOptions:e.onTextOptions,onTextInput:e.onTextInput,onTextTokens:e.onTextTokens,onTextStore:e.onTextStore,onTextQuery:e.onTextQuery,onTextResult:e.onTextResult}}function lt(e){let{handlers:t}=e,n,r=new Map;return Ve({name:"aggregation",onFilterStore(l,a){for(let o=0;o"u")continue;let i=!0;a.documents.forEach(u=>{i=!1}),i&&z(a.documents,1),l.aggregations.push(s(o,a))}}})}function at(e={}){let{empty:t=!1,limit:n}=e;return(r,{fields:l})=>{let a=r.space.f+r.space.x;return P("term",({type:o,data:s},{documents:i})=>{if(o!=="term")throw new C("unsupported");let u=l.findIndex(({name:f})=>f===s.field),d=je(r,u,f=>{let c=0,{occurrences:h}=f;for(let p=0;p>>a)&&c++;if(!(t===!1&&c===0))return{value:f.value,count:c}},R(R({},n),s.limit));return{type:o,data:{field:s.field,value:d}}})}}function ot(e,t="prefix"){return{type:t,data:e}}function st(e){return typeof e=="object"&&"type"in e&&typeof e.type=="string"&&"data"in e&&typeof e.data=="string"}function it(e,t={}){var i;let{prefix:n=2,filter:r=[]}=t,l=e.terms,a=new Map,o=Oe(l.length),s=M();for(let u=0;u{var p;return a.set(c,(p=a.get(c))!=null?p:u),h===n||void 0});let f=u?l[u-1]:"";o[u]=Ke(f,d)}for(let u=0;uu-d),{terms:l,index:a,cover:o,exact:s}}function ut(e,t){let n="",r=-1,l=-1;if(se(t,s=>{let i=e.index.get(s);if(typeof i>"u")return!0;n=s,r=i}),r!==-1)for(let s=n.length;ss>r&&so),index:t.index},{prefix:e.prefix,filter:(l=e.filter)==null?void 0:l.map(r)}))},onTextQuery(t,n,r){let{transform:l,parser:a}=r;if(typeof t.input=="string")t.input=a(r)(t.input);else if(!Ue(t.input))return;tt(t.input,o=>{var i;let s=o.value;if(st(s))s=l(s.data);else return;o.value=(i=ut(this.data,s))!=null?i:s})}})}function ct(e){let t=Q(R({},e),{plugins:[]}),n,r,l;return O({name:"filter",onTextOptions(o,s){return k(this,null,function*(){t.plugins=yield ee(e),l=yield Se(s,t)})},onTextQuery(o){typeof o.filter<"u"&&(n=o.filter,r!=null||(r=oe(t)),n.input=r(n.input,l),o.scope=n.input.select.documents)},onTextResult(o){if(typeof n<"u"){let s=!0;o.query.select.documents.forEach(u=>{s=!1}),s||(n.scope=o.query.select.documents);let i=De(l,n,t);o.aggregations=i.aggregations,n=void 0}}})}function dt(){return{tables:new Map}}function ht(e,t={}){let{count:n}=t;return P("term",r=>{let l=fe(r);return(a,o)=>{let s=[];return a.value.text.forEach((i,u)=>{let d=o[i]>>>10,f=o[i]&b[10];for(let p=0;pi.start-u.start),{ranges:ue(s).slice(0,n)}}})}function pt(e){let t,n;return O({name:"highlight",data:dt(),onTextInput(r,l){let{tables:a}=this.data;a.set(l,n=M())},onTextTokens(r){for(let l=0;l{let s=l.get(o.id);if(o.value.highlight)return;let i=a(o,s);o.value=Q(R({},o.value),{highlight:i})})}})}function gt(){return{directives:[]}}function ce(...e){return(t,n)=>{for(let r=0;r{if(r!=="match")throw new C("unsupported");let a=xt(e),o=ce(...t.map(s=>s(n)));return $(n,({matches:s})=>void s.sort(a)),(s,i)=>{let u=Math.min(s.matches.length,i.matches.length);for(let d=0,f=0;dr*(l.get(o.field)-l.get(s.field))}function yt(e,t={}){let n=fe(e.query),r=G(Xe),l=G($e);return(a,o)=>{let s=r(a,n,f=>f),i=r(o,n,f=>f);if(s.length!==i.length)return i.length-s.length;let u=l(s),d=l(i);return u!==d?u-d:s[0]!==i[0]?s[0]-i[0]:0}}function vt(e){let t=new Map;return O({name:"order",data:gt(),onTextOptions(r,l){return k(this,null,function*(){for(let a=0;a"u")throw new C("unknown");a.push(i(r,s))}r.items.sort(ce(...a))}})}function wt(e){let t=e.handler();return O({name:"pagination",onTextQuery(n){return t.onQuery(n,e)},onTextResult(n){return t.onResult(n,e)}})}function Tt(e){let{id:t,size:n=10,from:r=0}=e;if(r-n>=0)return{id:t,size:n,from:r-n}}function bt(e,t){let{id:n,size:r=10,from:l=0}=e;if(l+rk(null,null,function*(){let t=e.data;switch(t.type){case 0:Z=yield rt(t.data.items,{separator:He(t.data.config.separator),transform:G(Be),parser:r=>nt(r,"and",l=>({field:"*",value:ot(l.value),range:{start:l.start,end:l.end,value:l.index}})),compiler:et,fields:[j("title",r=>r.title,{weight:3}),j("text",r=>r.text),j("path",r=>r.path,{weight:2})],plugins:[ft(),ct({compiler:oe,fields:[j("tags",r=>r.tags)],plugins:[lt({handlers:[at()]})]}),vt({handlers:[r=>mt({fields:r.fields,comparators:[yt]})],defaults:{order:[{type:"match",data:{field:"*"}}]}}),()=>O({onTextResult(r){r.total=r.items.length}}),wt({handler:Mt,size:10}),pt({handler:r=>ht(r)}),()=>O({onTextResult(r){let{query:l}=r,a=l.values.map(({range:o})=>{var s,i;return((s=o==null?void 0:o.end)!=null?s:0)-((i=o==null?void 0:o.start)!=null?i:0)});X(r,o=>{var s;(s=o.value.highlight)==null||s.ranges.forEach(i=>{i.value=a[i.value]})})}})]}),self.postMessage({type:1});break;case 2:let n=Z({type:"text",data:t.data});self.postMessage({type:3,data:n.data});break}})});var At=Me(he());})();