Files
inventree-website/assets/javascripts/workers/search.719e0d91.min.js
T
2026-11-22 11:40:43 +00:00

2 lines
25 KiB
JavaScript

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