| 12 |
- "use strict";(()=>{var vt=Object.create;var K=Object.defineProperty,wt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertyNames,J=Object.getOwnPropertySymbols,Mt=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var V=(t,e,n)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,F=(t,e)=>{for(var n in e||(e={}))Y.call(e,n)&&V(t,n,e[n]);if(J)for(var n of J(e))Et.call(e,n)&&V(t,n,e[n]);return t},q=(t,e)=>wt(t,bt(e));var Ft=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var Rt=(t,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kt(e))!Y.call(t,r)&&r!==n&&K(t,r,{get:()=>e[r],enumerable:!(l=Tt(e,r))||l.enumerable});return t};var St=(t,e,n)=>(n=t!=null?vt(Mt(t)):{},Rt(e||!t||!t.__esModule?K(n,"default",{value:t,enumerable:!0}):n,t));var U=(t,e,n)=>V(t,typeof e!="symbol"?e+"":e,n);var E=(t,e,n)=>new Promise((l,r)=>{var a=i=>{try{s(n.next(i))}catch(u){r(u)}},o=i=>{try{s(n.throw(i))}catch(u){r(u)}},s=i=>i.done?l(i.value):Promise.resolve(i.value).then(a,o);s((n=n.apply(t,e)).next())});var xt=Ft(mt=>{"use strict";function C(t,e,n={}){return{name:t,from:e,meta:n}}function W(t,e){let n=[{value:t,depth:0}];for(let l=0,r=-1,a=0;l>=0;){let{value:o,depth:s}=n[l];if(r<=s&&o.type==="operator"&&o.data.operands.length>0)for(let i=o.data.operands.length;i>0;)n[++l]={value:o.data.operands[--i],depth:s+1};else{let i=e(o,a++,s);if(typeof i<"u")return i;--l}r=s}}var P=class extends Error{constructor(t,e){super(e),this.code=t}};function $(t,e){let n=qt(t);for(let l=0;l<n.length;l++){let r=e(n[l]);if(typeof r<"u")return r}}function qt(t){return t.items}function X(t,e){return $(t,n=>{let{matches:l}=n;for(let r=0;r<l.length;r++){let a=e(l[r],n);if(typeof a<"u")return a}})}function N(t,e=new Map){return(n,...l)=>{let r=e.get(n);return typeof r>"u"&&e.set(n,r=t(n,...l)),r}}function D(t,e){return Object.defineProperty(e,"name",{value:t}),e}function tt(t){return E(this,null,function*(){let e=[];if(typeof t.plugins<"u")for(let n=0;n<t.plugins.length;n++){let l=t.plugins[n];e.push(typeof l=="function"?yield l(t):l)}return e})}function et(t,e){return E(this,null,function*(){for(let n=0;n<t.length;n++){let l=e(t[n]);l instanceof Promise&&(yield l)}})}function z(t,e,n){for(let l=0;l<t.length;l++){let r=e(n,t[l]);typeof r<"u"&&(n=r)}return n}function zt(t,e,n){return E(this,null,function*(){var l;for(let r=0;r<t.length;r++){let a=e(n,t[r]);typeof a<"u"&&(n=a instanceof Promise?(l=yield a)!=null?l:n:a)}return n})}function At(t){return typeof t!="object"?{node:t,children:[]}:t}function Qt(t){return typeof t=="object"&&t!==null&&"select"in t&&"values"in t}function B(t){return Math.max(1,Math.ceil(Math.log2(t)))}function It(t){if(t.d+t.f+t.x>32)throw new RangeError("Bit format exceeds 32 bits");return t}function nt(t,e,n){let l=B(t),r=B(e),a=typeof n<"u"?B(n):32-l-r;return It({d:l,f:r,x:a})}var b=[0];for(let t=0;t<32;t++)b.push(b[t]|1<<t);function Ot(t){return new Uint8Array(t)}function jt(t){return new Uint32Array(t)}function M(){return[0].slice(0,0)}function Ct(){return[1/0].slice(0,0)}var G=class{constructor(t=[]){U(this,"magnitude",0);this.data=t}add(t,e,n){this.data.push({start:t,end:e,value:n}),this.magnitude=0}get(t){for(let e=0;e<this.data.length;e++){let{start:n,end:l,value:r}=this.data[e];if(t>=n&&t<l)return r}return 0}forEach(t){for(let e=0;e<this.data.length;e++){let{start:n,end:l,value:r}=this.data[e];for(let a=n;a<l;a++)t(a,r)}}get length(){return this.magnitude||(this.magnitude=rt(this))}},j=class{constructor(t,e=M()){U(this,"magnitude",0);this.data=t,this.cols=e}add(t,e){this.cols.push(t),this.data.push(e),this.magnitude=0}get(t){for(let e=0;e<this.cols.length;e++)if(this.cols[e]===t)return this.data[e];return 0}forEach(t){for(let e=0;e<this.cols.length;e++)t(this.cols[e],this.data[e])}get length(){return this.magnitude||(this.magnitude=rt(this))}};function rt(t){let e=0;return t.forEach((n,l)=>{e+=l*l}),Math.sqrt(e)}function Pt(t,e){t instanceof G?t.data.forEach((n,l)=>{e(n,l)}):t.forEach((n,l)=>{e({start:n,end:n+1,value:1},l)})}var O=class{constructor(t,e=jt(Math.ceil(t/32))){this.size=t,this.data=e}get(t){return this.data[t>>>5]>>>t&1}set(t){this.data[t>>>5]|=1<<(t&31)}forEach(t){let e=this.size&31;for(let n=0;n<this.data.length;n++){if(this.data[n]===0)continue;let l=this.data[n];e&&n===this.data.length-1&&(l=l&b[e]);for(let r=0,a=32-Math.clz32(l);r<a;r++)l&1<<r&&t((n<<5)+r)}}};function lt(t,e){for(let n=0;n<t.data.length;n++)t.data[n]&=~e.data[n]}function A(t,e){e*=b[32]>>>0;for(let n=0;n<t.data.length;n++)t.data.fill(e)}function _(t,e){for(let n=0;n<t.data.length;n++)t.data[n]&=e.data[n]}function ot(t){for(let e=0;e<t.data.length;e++)t.data[e]^=b[31]}function Q(t,e){for(let n=0;n<t.data.length;n++)t.data[n]|=e.data[n]}function Dt(t,e){let n=[{value:t,depth:0}];for(let l=1,r=0;l>0;r++){let{value:a,depth:o}=n[--l],s=e(a,r,o);if(typeof s<"u")return s;for(let i=a.children.length;i>0;)n[l++]={value:a.children[--i],depth:o+1}}}function _t(t,e){return E(this,null,function*(){let{fields:n,plugins:l=[]}=e,r=nt(t.length,n.length),a=[];for(let i=0;i<n.length;i++)a.push({terms:[],index:new Map});for(let i=0;i<t.length;i++)for(let u=0;u<n.length;u++){let d=n[u].from(t[i]);if(typeof d>"u")continue;let f=i<<r.f|u;d=z(l,(p,g)=>{var m;return(m=g.onFilterInput)==null?void 0:m.call(g,p,f,r)},d);let c=a[u],h=M();d=Array.isArray(d)?d:[d];for(let p=0;p<d.length;p++){let g=At(d[p]);Dt(g,(m,y,x)=>{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<v.length;T++){let S=c.terms[v[T]];if(S.position.depth===x){if(x&&h[x-1]!==S.position.prior)continue;w=v[T];break}}w===c.terms.length&&c.terms.push({value:m.node,occurrences:M(),position:{prior:x?h[x-1]:w,depth:x}});let{occurrences:k}=c.terms[w];k.push(f<<r.x|y),h[x]=w;for(let T=0;T<v.length;T++)if(v[T]===w)return;v.push(w)})}}let o={documents:t.length,fields:n.length},s={shards:a,space:r,count:o};return yield et(l,i=>{var u;return(u=i.onFilterStore)==null?void 0:u.call(i,s,e,t)}),s})}function Ht(t,e,n,l={}){let r=[];if(e<0||e>=t.count.fields)return r;let a=t.shards[e],o=new Map,{count:s=1/0,depth:i=1/0}=l;for(let u=0;u<a.terms.length;u++){let d=a.terms[u],f=n(d,u);if(typeof f<"u"){let{prior:c,depth:h}=d.position;if(h>i)continue;let p=o.get(d);typeof p>"u"&&o.set(d,p={node:f,children:[]});let g=r;h>0&&(g=o.get(a.terms[c]).children),g.length<s&&g.push(p)}}return r}function Lt(t,e,n){let{documents:l,terms:r}=H(t);if(n<0||n>=t.count.fields)return{documents:l,terms:r};let a=t.shards[n];return e.forEach(o=>{let{occurrences:s}=a.terms[o];for(let i=0;i<s.length;i++){let u=s[i]>>>t.space.x>>>t.space.f;l.set(u)}r[n].set(o)}),{documents:l,terms:r}}function Vt(t){let{documents:e,terms:n}=H(t);A(e,1);for(let l=0;l<n.length;l++)A(n[l],1);return{documents:e,terms:n}}function H(t){return{documents:new O(t.count.documents),terms:t.shards.map(({terms:e})=>new O(e.length))}}function Kt(t,e,n){let{compiler:l,fields:r,plugins:a=[]}=n,{input:o,scope:s,abort:i=!1}=z(a,(f,c)=>{var h;return(h=c.onFilterQuery)==null?void 0:h.call(c,f,t,n)},e),u={items:[],query:{select:H(t),values:[]}},d=new Map;if(i===!1){let f=l(n),{select:c,values:h}=f(o,t);typeof s<"u"&&_(c.documents,s);let p=new Map;u.query={select:c,values:h},c.terms.forEach((g,m)=>{g.forEach(y=>{let x=t.shards[m],{occurrences:v}=x.terms[y];for(let w=0;w<v.length;w++){let k=v[w],T=k>>>t.space.x,S=T>>>t.space.f;if(!c.documents.get(S))continue;let I=p.get(T);typeof I>"u"&&p.set(T,I=new j(M()));let yt=k&b[t.space.x];I.add(yt,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>>>t.space.f,x=m&b[t.space.f];d.get(y).matches.push({id:m,field:r[x].name,value:{filter:g},score:0})})}return z(a,(f,c)=>{var h;return(h=c.onFilterResult)==null?void 0:h.call(c,f,t,n)},u)}function at(t){let{fields:e}=t;return(n,l)=>{if(Qt(n))return n;let r=[Vt(l)],a=[],o=0;return W(n,({type:s,data:i})=>{switch(s){case"value":let u=e.findIndex(({name:c})=>c===i.field);if(u===-1){r[o++]=H(l);break}let d=i.value;if(typeof d!="object"){let c=new j(M()),h=l.shards[u],p=h.index.get(d);if(typeof p<"u")for(let g=0;g<p.length;g++){let m=p[g];if(typeof i.depth<"u"){let{position:y}=h.terms[m];if(y.depth!==i.depth)continue}c.add(m,1)}d=c}r[o++]=Lt(l,d,u),a.push(q(F({},i),{value:d}));break;case"operator":let f=o-i.operands.length;switch(i.operator){case"or":for(;o>f+1&&o--;){Q(r[f].documents,r[o].documents);for(let c=0;c<e.length;c++)Q(r[f].terms[c],r[o].terms[c])}break;case"and":for(;o>f+1&&o--;){_(r[f].documents,r[o].documents);for(let c=0;c<e.length;c++)Q(r[f].terms[c],r[o].terms[c])}break;case"not":ot(r[f].documents);for(let c=0;c<e.length;c++)A(r[f].terms[c],0);for(;o>f+1&&o--;)lt(r[f].documents,r[o].documents)}}}),{select:r[0],values:a}}}function Ut(t){return{name:t.name,data:t.data,onFilterOptions:t.onFilterOptions,onFilterInput:t.onFilterInput,onFilterStore:t.onFilterStore,onFilterQuery:t.onFilterQuery,onFilterResult:t.onFilterResult}}function st(t){return typeof t=="object"&&t!==null&&"type"in t&&"data"in t}function Bt(t){return typeof t=="object"&&t!==null&&"select"in t&&"values"in t}function Nt(t){return t.normalize("NFKD").toLowerCase()}function Wt(t,e){let n=Math.min(t.length,e.length);for(let l=0;l<n;l++)if(t.charCodeAt(l)!==e.charCodeAt(l))return l;return n}function Gt(t,e,n=0,l=t.length){for(let r=0;n<l;n+=1+ +(r>65535)){let a=e(r=t.codePointAt(n),n);if(typeof a<"u")return a}}function it(t,e,n=0,l=t.length){let r=M();return Gt(t,a=>{r.push(a);let o=e(String.fromCodePoint(...r),r.length);if(typeof o<"u")return o},n,l)}function Jt(t,e,n=0,l=t.length){let r=n;for(let a=0;r<l;r++)switch(a=t.charCodeAt(r),a){case 60:r>n&&e(n,n=r);continue;case 62:n=r+1}r>n&&e(n,r)}function ut(t,e,n,l=0){return Jt(t,(r,a)=>e(t,(o,s)=>{l=n({value:t.slice(o,s),index:l,start:o,end:s})},r,a)),l}function Yt(t,e,n,l=0){for(let r=0,a=0;r<t.length;a+=t[r++].length)l=ut(t[r],e,o=>(o.start+=a,o.end+=a,n(o)),l);return l}function Zt(t){let e=new RegExp(t,"gu");return(n,l,r=0,a=n.length)=>{var i;e.lastIndex=r;let o,s=0;do{o=e.exec(n);let u=(i=o==null?void 0:o.index)!=null?i:a;r<u&&l(r,Math.min(u,a)),o&&(s=o[0].length,r=o.index+s,s===0&&(e.lastIndex=o.index+1))}while(o&&r<a)}}function $t(t,e){return E(this,null,function*(){let{separator:n,transform:l,fields:r,plugins:a=[]}=e,o=nt(t.length,r.length),s=new Map;for(let f=0;f<t.length;f++)for(let c=0;c<r.length;c++){let h=r[c].from(t[f]);if(typeof h>"u")continue;let p=f<<o.f|c;h=z(a,(g,m)=>{var y;return(y=m.onTextInput)==null?void 0:y.call(m,g,p,o)},h),h=Array.isArray(h)?h:[h],Yt(h,n,g=>{let m=z(a,(y,x)=>{var v;return(v=x.onTextTokens)==null?void 0:v.call(x,y)},[g]);for(let y=0;y<m.length;y++){g=m[y];let x=l(g.value),v=s.get(x);typeof v>"u"?s.set(x,[p<<o.x|g.index]):v.push(p<<o.x|g.index)}return m.length?g.index+1:g.index})}let i={documents:t.length,fields:r.length},u={terms:[],index:new Map,space:o,count:i},d=[...s.keys()].sort();for(let f=0;f<d.length;f++)u.index.set(d[f],f),u.terms.push({value:d[f],occurrences:s.get(d[f])});return yield et(a,f=>{var c;return(c=f.onTextStore)==null?void 0:c.call(f,u,e,t)}),u})}function Xt(t,e,n){let{documents:l,terms:r}=L(t);return n<0||n>=t.count.fields?{documents:l,terms:r}:(e.forEach(a=>{let{occurrences:o}=t.terms[a];for(let s=0;s<o.length;s++){let i=o[s]>>>t.space.x;if((i&b[t.space.f])!==n)continue;let u=i>>>t.space.f;l.set(u)}r.set(a)}),{documents:l,terms:r})}function te(t,e){let{documents:n,terms:l}=L(t),r=t.space.f+t.space.x;return e.forEach(a=>{let{occurrences:o}=t.terms[a];for(let s=0;s<o.length;s++)n.set(o[s]>>>r);l.set(a)}),{documents:n,terms:l}}function L(t){return{documents:new O(t.count.documents),terms:new O(t.terms.length)}}function ee(t,e,n){let{compiler:l,fields:r,plugins:a=[]}=n,{input:o,scope:s,abort:i=!1}=z(a,(f,c)=>{var h;return(h=c.onTextQuery)==null?void 0:h.call(c,f,t,n)},e),u={items:[],query:{select:L(t),values:[]}},d=new Map;if(i===!1){let f=l(n),{select:c,values:h}=f(o,t);typeof s<"u"&&_(c.documents,s);let p=new O(r.length),g=new Map;u.query={select:c,values:h},c.terms.forEach(m=>{A(p,0);for(let x=0;x<h.length;x++){let{field:v,value:w}=h[x];if(v==="*"){A(p,1);break}else if(w.get(m)){for(let k=0;k<r.length;k++)if(r[k].name===v){p.set(k);break}}}let{occurrences:y}=t.terms[m];for(let x=0;x<y.length;x++){let v=y[x],w=v>>>t.space.x,k=w>>>t.space.f;if(!c.documents.get(k))continue;let T=w&b[t.space.f];if(!p.get(T))continue;let S=g.get(w);typeof S>"u"&&g.set(w,S=new j(M()));let I=v&b[t.space.x];S.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>>>t.space.f,v=y&b[t.space.f];d.get(x).matches.push({id:y,field:r[v].name,value:{text:m},score:0})})}return z(a,(f,c)=>{var h;return(h=c.onTextResult)==null?void 0:h.call(c,f,t,n)},u)}function ne(t,e=10){return t.length>1?1+t[t.length-1]-t[0]:e}function re(t,e,n,l=10){let r=[];t.value.text.forEach((s,i)=>{for(let u=0;u<e.data.length;u++){let{start:d,end:f}=e.data[u];d<=i&&i<f&&r.push({index:s,value:u})}}),r.sort((s,i)=>s.index-i.index);let a=r.slice(0,1),o=0;for(let s=0;s<r.length-1;s++){let i=r[s],u=r[s+1],d;if(u.index-i.index>l||u.value===i.value)d=a.map(({index:f})=>f),a=[r[s+1]];else{for(let f=0;f<a.length;f++){let c=a[f];if(c.value===u.value){if(i.index-c.index>u.index-i.index){let h=a.splice(f+1);d=a.map(({index:p})=>p),a=[...h,r[s+1]]}else d=a.map(({index:h})=>h),a=[r[s+1]];break}}typeof d>"u"&&a.push(r[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 le(t){let{transform:e,parser:n,fields:l}=t,r=n(t);return(a,o)=>{if(Bt(a))return a;typeof a=="string"&&(a=r(a));let s=[L(o)],i=[],u=0;return W(a,({type:d,data:f})=>{switch(d){case"value":let c=f.value;if(typeof c=="string"){let p=new j(M()),g=o.index.get(e(c));typeof g<"u"&&p.add(g,1),c=p}if(f.field==="*")s[u++]=te(o,c);else{let p=l.findIndex(({name:g})=>g===f.field);s[u++]=Xt(o,c,p)}i.push(q(F({},f),{value:c}));break;case"operator":let h=u-f.operands.length;switch(f.operator){case"or":for(;u>h+1&&u--;)Q(s[h].documents,s[u].documents),Q(s[h].terms,s[u].terms);break;case"and":for(;u>h+1&&u--;)_(s[h].documents,s[u].documents),Q(s[h].terms,s[u].terms);break;case"not":for(ot(s[h].documents),A(s[h].terms,0);u>h+1&&u--;)lt(s[h].documents,s[u].documents)}}}),{select:s[0],values:i}}}function ft(t,e){return W(t,(n,l,r)=>{if(n.type!=="value")return;let a=e(n.data,l,r);if(typeof a<"u")return a})}function ct(t){if(t.length===0)return[];let e=[],n=[];for(let a=0;a<t.length;a++){let{start:o,end:s}=t[a];n.push({index:o,value:a}),n.push({index:s,value:a})}n.sort((a,o)=>a.index-o.index);let l=new Set([n[0].value]),r=n[0].index;for(let a=1;a<n.length;a++){let{index:o,value:s}=n[a];if(l.size&&r<o){let i=s;l.forEach(u=>{t[u].start>r||t[u].end<o||t[i].start!==t[u].start&&t[i].end!==t[u].end&&(i=u)}),e.push({start:r,end:o,value:t[i].value})}r=o,l.has(s)?l.delete(s):l.add(s)}return e}function dt(t){let e=[];for(let n=0;n<t.values.length;n++){let{value:l}=t.values[n];Pt(l,({start:r,end:a})=>{e.push({start:r,end:a,value:n})})}return new G(ct(e))}function oe(t,e="or",n){let{separator:l}=t;return n!=null||(n=r=>({field:"*",value:r.value})),r=>{let a=[];return ut(r,l,o=>{let s=n(o);typeof s<"u"&&a.push({type:"value",data:s})}),{type:"operator",data:{operator:e,operands:a}}}}function ae(t,e){return E(this,null,function*(){let n=yield tt(e),l=yield zt(n,(a,o)=>{var s;return(s=o.onTextOptions)==null?void 0:s.call(o,a,t)},q(F({},e),{plugins:n})),r=yield $t(t,l);return D("text",a=>{if(a.type!=="text")throw new P("unsupported");return{type:a.type,data:ee(r,a.data,l)}})})}function R(t){return{name:t.name,data:t.data,onTextOptions:t.onTextOptions,onTextInput:t.onTextInput,onTextTokens:t.onTextTokens,onTextStore:t.onTextStore,onTextQuery:t.onTextQuery,onTextResult:t.onTextResult}}function se(t){let{handlers:e}=t,n,l=new Map;return Ut({name:"aggregation",onFilterStore(r,a){for(let o=0;o<e.length;o++){let s=e[o](r,a);l.set(s.name,s)}},onFilterQuery(r){var a,o;n=(o=(a=r.aggregation)==null?void 0:a.input)!=null?o:[]},onFilterResult(r){let{select:a}=r.query;r.aggregations=[];for(let o of n){let s=l.get(o.type);if(typeof s>"u")continue;let i=!0;a.documents.forEach(u=>{i=!1}),i&&A(a.documents,1),r.aggregations.push(s(o,a))}}})}function ie(t={}){let{empty:e=!1,limit:n}=t;return(l,{fields:r})=>{let a=l.space.f+l.space.x;return D("term",({type:o,data:s},{documents:i})=>{if(o!=="term")throw new P("unsupported");let u=r.findIndex(({name:f})=>f===s.field),d=Ht(l,u,f=>{let c=0,{occurrences:h}=f;for(let p=0;p<h.length;p++)i.get(h[p]>>>a)&&c++;if(!(e===!1&&c===0))return{value:f.value,count:c}},F(F({},n),s.limit));return{type:o,data:{field:s.field,value:d}}})}}function ue(t,e="prefix"){return{type:e,data:t}}function fe(t){return typeof t=="object"&&"type"in t&&typeof t.type=="string"&&"data"in t&&typeof t.data=="string"}function ce(t,e={}){var i;let{prefix:n=2,filter:l=[]}=e,r=t.terms,a=new Map,o=Ot(r.length),s=M();for(let u=0;u<r.length;u++){let d=r[u];it(d,(c,h)=>{var p;return a.set(c,(p=a.get(c))!=null?p:u),h===n||void 0});let f=u?r[u-1]:"";o[u]=Wt(f,d)}for(let u=0;u<l.length;u++){let d=l[u],f=(i=t.index)==null?void 0:i.get(d);typeof f<"u"&&s.push(f)}return s.sort((u,d)=>u-d),{terms:r,index:a,cover:o,exact:s}}function de(t,e){let n="",l=-1,r=-1;if(it(e,s=>{let i=t.index.get(s);if(typeof i>"u")return!0;n=s,l=i}),l!==-1)for(let s=n.length;s<e.length;){let i=t.terms[l];if(i.length===s)if(++l===t.terms.length){l=-1;break}else continue;if(i.charCodeAt(s)===e.charCodeAt(s))s++;else if(t.terms.length===++l||t.cover[l]<s){l=-1;break}}if(l===-1)return;for(r=l+1;r<t.terms.length&&!(t.cover[r]<e.length);r++);let a=[],o=t.exact.filter(s=>s>l&&s<r);for(let s=0;s<o.length;s++)l<o[s]&&a.push({start:l,end:o[s]-1,value:1}),l=o[s]+1;return l<=r&&a.push({start:l,end:r,value:1}),new G(a)}function he(t={}){return R({name:"expansion",onTextStore(e,n){var r,a;let{transform:l}=n;(a=this.data)!=null||(this.data=ce({terms:e.terms.map(({value:o})=>o),index:e.index},{prefix:t.prefix,filter:(r=t.filter)==null?void 0:r.map(l)}))},onTextQuery(e,n,l){let{transform:r,parser:a}=l;if(typeof e.input=="string")e.input=a(l)(e.input);else if(!st(e.input))return;ft(e.input,o=>{var i;let s=o.value;if(fe(s))s=r(s.data);else return;o.value=(i=de(this.data,s))!=null?i:s})}})}function pe(t){let e=q(F({},t),{plugins:[]}),n,l,r;return R({name:"filter",onTextOptions(o,s){return E(this,null,function*(){e.plugins=yield tt(t),r=yield _t(s,e)})},onTextQuery(o){typeof o.filter<"u"&&(n=o.filter,l!=null||(l=at(e)),n.input=l(n.input,r),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=Kt(r,n,e);o.aggregations=i.aggregations,n=void 0}}})}function ht(t,e){let n=[],l=t/e>>>0,r=t%e,a=0;if(l)for(let o=0;o<e-r;o++,a+=l)n.push(a);if(r)for(let o=0;o<r;o++,a+=l+1)n.push(a);return n.push(a),n}function ge(t,e){let n=ht(t.length,e),l=[];for(let r=0;r<n.length-1;r++)l.push(t.slice(n[r],n[r+1]));return l}function me(t,e,n){let l=ht(e,n+1),r=t.length-e,a=[];for(let o=0;o<l.length-1;o++){let s=l[o+1]-l[o],i=1+l[o],u=Math.max(i-o,i+r-(n-o),1),d=Math.min(i+o,i+r+(n-o),1+t.length-s);a[o]=[];for(let f=u-1;f<d;f++)a[o].push(t.slice(f,f+s))}return a}function xe(t,e={}){let{threshold:n=2}=e,l=t.terms.map((o,s)=>s);l.sort((o,s)=>t.terms[o].length-t.terms[s].length||t.terms[o].localeCompare(t.terms[s]));let r=0;for(let o=0;o<t.terms.length;o++)t.terms[o].length>r&&(r=t.terms[o].length);let a=[];for(let o=0;o<r+1;o++){let s=[];a.push(s);for(let i=0;i<n+1;i++)s.push(new Map)}for(let o=0;o<l.length;o++){let s=t.terms[l[o]],i=a[s.length],u=ge(s,n+1);for(let d=0;d<u.length;d++){let f=u[d],c=i[d].get(f);typeof c>"u"?i[d].set(f,[l[o]]):c.push(l[o])}}return{index:a,terms:t.terms,idxmp:l}}var ye=[["id","di","rr"],["dr","rd"],["dd"]];function pt(t,e,n=2){if(t.length<e.length)return pt(e,t,n);let l=t.length,r=e.length,a=l-r;if(a>n)return;let o,s,i,u=n+1;for(let d of ye[a]){for(i=o=s=0;o<l&&s<r;)if(t[o]!==e[s]){if(++i>n)break;switch(d[i-1]){case"d":o++;break;case"i":s++;break;case"r":o++,s++;break}}else o++,s++;i+=l-o+(r-s),i<u&&(u=i)}return u<n+1?u:void 0}function ve(t,e,n=pt){let l=new j(Ct());for(let r=-2;r<3;r++){let a=e.length+r;if(typeof t.index[a]>"u")continue;let o=me(e,a,2);for(let s=0;s<o.length;s++){let i=t.index[a][s],u=o[s];for(let d=0;d<u.length;d++){let f=i.get(u[d]);if(!(typeof f>"u"))for(let c of f){let h=t.terms[c].length,p=n(t.terms[c],e);typeof p<"u"&&l.add(c,(h-p)/h)}}}}if(l.data.length)return l}function we(t={}){return R({name:"fuzzy",onTextStore(e){var n;(n=this.data)!=null||(this.data=xe({terms:e.terms.map(({value:l})=>l)},t))},onTextQuery(e,n,l){let{transform:r,parser:a}=l;if(typeof e.input=="string")e.input=a(l)(e.input);else if(!st(e.input))return;ft(e.input,o=>{var i;let s=o.value;if(typeof s=="string")s=r(s);else return;n.index.get(s)||(o.value=(i=ve(this.data,s))!=null?i:s)})}})}function Te(){return{tables:new Map}}function be(t,e={}){let{count:n}=e;return D("term",l=>{let r=dt(l);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;p<r.data.length;p++){let{start:g,end:m}=r.data[p];if(g<=u&&u<m){u=r.data[p].value;break}}let c=d,h=d+f;s.push({start:c,end:h,value:u})}),s.sort((i,u)=>i.start-u.start),{ranges:ct(s).slice(0,n)}}})}function ke(t){let e,n;return R({name:"highlight",data:Te(),onTextInput(l,r){let{tables:a}=this.data;a.set(r,n=M())},onTextTokens(l){for(let r=0;r<l.length;r++){let{index:a,start:o,end:s}=l[r];n[a]=o<<10|s-o}},onTextStore(l){e=t.handler(l)},onTextResult(l){let{tables:r}=this.data,a=e(l.query);X(l,o=>{let s=r.get(o.id);if(o.value.highlight)return;let i=a(o,s);o.value=q(F({},o.value),{highlight:i})})}})}function Me(){return{directives:[]}}function gt(...t){return(e,n)=>{for(let l=0;l<t.length;l++){let r=t[l](e,n);if(r!==0)return r}return 0}}function Ee(t){let{comparators:e}=t;return D("match",(n,{type:l,data:r})=>{if(l!=="match")throw new P("unsupported");let a=Fe(t),o=gt(...e.map(s=>s(n)));return $(n,({matches:s})=>{s.sort(a)}),(s,i)=>{let u=Math.min(s.matches.length,i.matches.length);for(let d=0,f=0;d<u;d++)if(f=a(s.matches[d],i.matches[d]),f!==0||(f=o(s.matches[d],i.matches[d]),f!==0))return f;return i.matches.length-s.matches.length}})}function Fe(t){var a;let{fields:e,direction:n}=t,l=n==="ascending"?1:-1,r=new Map;for(let o=0;o<e.length;o++){let{name:s,meta:i}=e[o];r.set(s,(a=i.weight)!=null?a:1)}return(o,s)=>l*(r.get(o.field)-r.get(s.field))}function Re(t,e={}){let n=dt(t.query),l=N(re),r=N(ne);return(a,o)=>{let s=l(a,n,f=>f),i=l(o,n,f=>f);if(s.length!==i.length)return i.length-s.length;let u=r(s),d=r(i);return u!==d?u-d:s[0]!==i[0]?s[0]-i[0]:0}}function Se(t){let e=new Map;return R({name:"order",data:Me(),onTextOptions(l,r){return E(this,null,function*(){for(let a=0;a<t.handlers.length;a++){let o=yield t.handlers[a](l,r);e.set(o.name,o)}})},onTextQuery(l){var r,a,o;this.data.directives=(o=(a=l.order)!=null?a:(r=t.defaults)==null?void 0:r.order)!=null?o:[]},onTextResult(l){let{directives:r}=this.data,a=[];for(let o=0;o<r.length;o++){let s=r[o],i=e.get(s.type);if(typeof i>"u")throw new P("unknown");a.push(i(l,s))}l.items.sort(gt(...a))}})}function qe(t){let e=t.handler();return R({name:"pagination",onTextQuery(n){return e.onQuery(n,t)},onTextResult(n){return e.onResult(n,t)}})}function ze(t){let{id:e,size:n=10,from:l=0}=t;if(l-n>=0)return{id:e,size:n,from:l-n}}function Ae(t,e){let{id:n,size:l=10,from:r=0}=t;if(r+l<e)return{id:n,size:l,from:r+l}}function Qe(){return{query:null,result:null}}function Ie(t={}){let{cache:e=Qe(),expires:n=1/0}=t;return{data:e,onQuery(l,{size:r=10}){var s,i,u,d;let a=(u=(i=(s=e.query)==null?void 0:s.page)==null?void 0:i.id)!=null?u:0,o=Date.now()-a<n;e.query=Object.assign({},l),e.result&&((d=l.page)==null?void 0:d.id)===a&&o?l.abort=!0:(e.query.page={id:Date.now(),size:r,from:0},e.result=null)},onResult(l){var o;let r=e.query.page;(o=e.result)!=null||(e.result=l),l=Object.assign({},e.result);let a=e.result.items.length;return l.pagination={total:a,prev:ze(r),next:Ae(r,a)},l.items=e.result.items.slice(r.from,r.from+r.size),l}}}var Oe=new RegExp("[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Hangul}]","u");function je(t){return["zh","ja","ko"].includes(t.toLowerCase().split(/[-_]/,1)[0])}function Ce(t){let e=Intl.Segmenter,n=typeof e=="function"?new e(t.replaceAll("_","-"),{granularity:"word"}):void 0,l=r=>(a,o,s,i)=>{r(a,(u,d)=>{let f=a.slice(u,d);if(!n||!Oe.test(f)){o(u,d);return}let c=0;for(let h of n.segment(f))if(h.isWordLike){let p=u+h.index;o(p,p+h.segment.length),c++}c||o(u,d)},s,i)};return R({name:"segmentation",onTextOptions(r){if(n)return q(F({},r),{separator:l(r.separator)})}})}var Z=null;self.onmessage=t=>E(null,null,function*(){var n;let e=t.data;switch(e.type){case 0:let l=(n=e.data.config.lang)==null?void 0:n.find(je);Z=yield ae(e.data.items,{separator:Zt(e.data.config.separator),transform:N(Nt),parser:a=>oe(a,"and",o=>({field:"*",value:ue(o.value),range:{start:o.start,end:o.end,value:o.index}})),compiler:le,fields:[C("title",a=>a.title,{weight:3}),C("text",a=>a.text),C("path",a=>a.path,{weight:2})],plugins:[...l?[Ce(l)]:[],he(),we(),pe({compiler:at,fields:[C("tags",a=>a.tags)],plugins:[se({handlers:[ie()]})]}),Se({handlers:[a=>Ee({fields:a.fields,comparators:[Re]})],defaults:{order:[{type:"match",data:{field:"*"}}]}}),()=>R({onTextResult(a){a.total=a.items.length}}),qe({handler:Ie,size:10}),ke({handler:a=>be(a)}),()=>R({onTextResult(a){let{query:o}=a,s=o.values.map(({range:i,value:u})=>{var f,c;let d=!1;return u.forEach((h,p)=>{!d&&p<1&&(d=!0)}),d?-1:((f=i==null?void 0:i.end)!=null?f:0)-((c=i==null?void 0:i.start)!=null?c:0)});X(a,i=>{var u;(u=i.value.highlight)==null||u.ranges.forEach(d=>{d.value=s[d.value]})})}})]}),self.postMessage({type:1});break;case 2:let r=Z({type:"text",data:e.data});self.postMessage({type:3,data:r.data});break}})});var Ue=St(xt());})();
|