zensical 0.0.9__cp310-abi3-musllinux_1_2_i686.whl → 0.0.12__cp310-abi3-musllinux_1_2_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of zensical might be problematic. Click here for more details.

zensical/main.py CHANGED
@@ -23,13 +23,15 @@
23
23
 
24
24
  from __future__ import annotations
25
25
 
26
- import click
27
26
  import os
28
27
  import shutil
28
+ from pathlib import Path
29
+ from typing import Any
29
30
 
31
+ import click
30
32
  from click import ClickException
31
- from zensical import build, serve, version
32
33
 
34
+ from zensical import build, serve, version
33
35
 
34
36
  # ----------------------------------------------------------------------------
35
37
  # Commands
@@ -38,8 +40,8 @@ from zensical import build, serve, version
38
40
 
39
41
  @click.version_option(version=version(), message="%(version)s")
40
42
  @click.group()
41
- def cli():
42
- """Zensical - A modern static site generator"""
43
+ def cli() -> None:
44
+ """Zensical - A modern static site generator."""
43
45
 
44
46
 
45
47
  @cli.command(name="build")
@@ -64,10 +66,8 @@ def cli():
64
66
  is_flag=True,
65
67
  help="Strict mode (currently unsupported).",
66
68
  )
67
- def execute_build(config_file: str | None, **kwargs):
68
- """
69
- Build a project.
70
- """
69
+ def execute_build(config_file: str | None, **kwargs: Any) -> None:
70
+ """Build a project."""
71
71
  if config_file is None:
72
72
  for file in ["zensical.toml", "mkdocs.yml", "mkdocs.yaml"]:
73
73
  if os.path.exists(file):
@@ -80,7 +80,7 @@ def execute_build(config_file: str | None, **kwargs):
80
80
 
81
81
  # Build project in Rust runtime, calling back into Python when necessary,
82
82
  # e.g., to parse MkDocs configuration format or render Markdown
83
- build(os.path.abspath(config_file), kwargs.get("clean"))
83
+ build(os.path.abspath(config_file), kwargs.get("clean", False))
84
84
 
85
85
 
86
86
  @cli.command(name="serve")
@@ -111,10 +111,8 @@ def execute_build(config_file: str | None, **kwargs):
111
111
  is_flag=True,
112
112
  help="Strict mode (currently unsupported).",
113
113
  )
114
- def execute_serve(config_file: str | None, **kwargs):
115
- """
116
- Build and serve a project.
117
- """
114
+ def execute_serve(config_file: str | None, **kwargs: Any) -> None:
115
+ """Build and serve a project."""
118
116
  if config_file is None:
119
117
  for file in ["zensical.toml", "mkdocs.yml", "mkdocs.yaml"]:
120
118
  if os.path.exists(file):
@@ -136,45 +134,34 @@ def execute_serve(config_file: str | None, **kwargs):
136
134
  type=click.Path(file_okay=False, dir_okay=True, writable=True),
137
135
  required=False,
138
136
  )
139
- def new_project(directory: str | None, **kwargs):
140
- """
141
- Create a new template project in the current directory or in the given
142
- directory.
137
+ def new_project(directory: str | None, **kwargs: Any) -> None: # noqa: ARG001
138
+ """Create a new template project in the current directory or in the given directory.
143
139
 
144
140
  Raises:
145
141
  ClickException: if the directory already contains a zensical.toml or a
146
142
  docs directory that is not empty, as well as when the path provided
147
143
  points to something that is not a directory.
148
144
  """
149
-
150
- if directory is None:
151
- directory = "."
152
- docs_dir = os.path.join(directory, "docs")
153
- config_file = os.path.join(directory, "zensical.toml")
154
- github_dir = os.path.join(directory, ".github")
155
-
156
- if os.path.exists(directory):
157
- if not os.path.isdir(directory):
158
- raise (ClickException("Path provided is not a directory."))
159
- if os.path.exists(config_file):
160
- raise (ClickException(f"{config_file} already exists."))
161
- if os.path.exists(docs_dir):
162
- raise (ClickException(f"{docs_dir} already exists."))
163
- if os.path.exists(github_dir):
164
- raise (ClickException(f"{github_dir} already exists."))
165
- else:
166
- os.makedirs(directory)
167
-
168
- package_dir = os.path.dirname(os.path.abspath(__file__))
169
- shutil.copy(os.path.join(package_dir, "bootstrap/zensical.toml"), directory)
170
- shutil.copytree(
171
- os.path.join(package_dir, "bootstrap/docs"),
172
- os.path.join(directory, "docs"),
173
- )
174
- shutil.copytree(
175
- os.path.join(package_dir, "bootstrap/.github"),
176
- os.path.join(directory, ".github"),
177
- )
145
+ working_dir = Path.cwd() if directory is None else Path(directory).resolve()
146
+ if working_dir.is_file():
147
+ raise ClickException(f"{working_dir} must be a directory, not a file.")
148
+
149
+ config_file = working_dir / "zensical.toml"
150
+ if config_file.exists():
151
+ raise ClickException(f"{config_file} already exists.")
152
+
153
+ working_dir.mkdir(parents=True, exist_ok=True)
154
+
155
+ package_dir = Path(__file__).resolve().parent
156
+ bootstrap = package_dir / "bootstrap"
157
+
158
+ for src_file in bootstrap.rglob("*"):
159
+ if src_file.is_file():
160
+ rel_path = src_file.relative_to(bootstrap)
161
+ dest_file = working_dir / rel_path
162
+ if not dest_file.exists():
163
+ dest_file.parent.mkdir(parents=True, exist_ok=True)
164
+ shutil.copyfile(src_file, dest_file)
178
165
 
179
166
 
180
167
  # ----------------------------------------------------------------------------
zensical/markdown.py CHANGED
@@ -24,15 +24,19 @@
24
24
  from __future__ import annotations
25
25
 
26
26
  import re
27
- import yaml
28
-
29
27
  from datetime import date, datetime
28
+ from typing import TYPE_CHECKING, Any
29
+
30
+ import yaml
30
31
  from markdown import Markdown
31
32
  from yaml import SafeLoader
32
33
 
33
- from .config import get_config
34
- from .extensions.links import LinksExtension
35
- from .extensions.search import SearchExtension
34
+ from zensical.config import get_config
35
+ from zensical.extensions.links import LinksExtension
36
+ from zensical.extensions.search import SearchExtension
37
+
38
+ if TYPE_CHECKING:
39
+ from zensical.extensions.search import SearchProcessor
36
40
 
37
41
  # ----------------------------------------------------------------------------
38
42
  # Constants
@@ -53,8 +57,7 @@ Regex pattern to extract front matter.
53
57
 
54
58
 
55
59
  def render(content: str, path: str) -> dict:
56
- """
57
- Render Markdown and return HTML.
60
+ """Render Markdown and return HTML.
58
61
 
59
62
  This function returns rendered HTML as well as the table of contents and
60
63
  metadata. Now, this is the part where Zensical needs to call into Python,
@@ -77,8 +80,8 @@ def render(content: str, path: str) -> dict:
77
80
  links.extendMarkdown(md)
78
81
 
79
82
  # Register search extension, which extracts text for search indexing
80
- search = SearchExtension()
81
- search.extendMarkdown(md)
83
+ search_extension = SearchExtension()
84
+ search_extension.extendMarkdown(md)
82
85
 
83
86
  # First, extract metadata - the Python Markdown parser brings a metadata
84
87
  # extension, but the implementation is broken, as it does not support full
@@ -91,7 +94,7 @@ def render(content: str, path: str) -> dict:
91
94
  content = content[match.end() :].lstrip("\n")
92
95
  else:
93
96
  meta = {}
94
- except Exception:
97
+ except Exception: # noqa: BLE001
95
98
  pass
96
99
 
97
100
  # Convert Markdown and set nullish metadata to empty string, since we
@@ -106,24 +109,22 @@ def render(content: str, path: str) -> dict:
106
109
  meta[key] = value.isoformat()
107
110
 
108
111
  # Obtain search index data, unless page is excluded
109
- search = md.postprocessors["search"]
112
+ search_processor: SearchProcessor = md.postprocessors["search"] # type: ignore[assignment]
110
113
  if meta.get("search", {}).get("exclude", False):
111
- search.data = []
114
+ search_processor.data = []
112
115
 
113
116
  # Return Markdown with metadata
114
117
  return {
115
118
  "meta": meta,
116
119
  "content": content,
117
- "search": search.data,
120
+ "search": search_processor.data,
118
121
  "title": "",
119
122
  "toc": [_convert_toc(item) for item in getattr(md, "toc_tokens", [])],
120
123
  }
121
124
 
122
125
 
123
- def _convert_toc(item: any):
124
- """
125
- Convert a table of contents item to navigation item format.
126
- """
126
+ def _convert_toc(item: Any) -> dict:
127
+ """Convert a table of contents item to navigation item format."""
127
128
  toc_item = {
128
129
  "title": item["data-toc-label"] or item["name"],
129
130
  "id": item["id"],
@@ -1 +1 @@
1
- "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,X=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={}))X.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))!X.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 Z(e,t){let n=ke(e);for(let r=0;r<n.length;r++){let l=t(n[r]);if(typeof l<"u")return l}}function ke(e){return e.items}function $(e,t){return Z(e,n=>{let{matches:r}=n;for(let l=0;l<r.length;l++){let a=t(r[l],n);if(typeof a<"u")return a}})}function G(e,t=new Map){return(n,...r)=>{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;n<e.plugins.length;n++){let r=e.plugins[n];t.push(typeof r=="function"?yield r(e):r)}return t})}function te(e,t){return k(this,null,function*(){for(let n=0;n<e.length;n++){let r=t(e[n]);r instanceof Promise&&(yield r)}})}function q(e,t,n){for(let r=0;r<e.length;r++){let l=t(n,e[r]);typeof l<"u"&&(n=l)}return n}function Fe(e,t,n){return k(this,null,function*(){var r;for(let l=0;l<e.length;l++){let a=t(n,e[l]);typeof a<"u"&&(n=a instanceof Promise?(r=yield a)!=null?r:n:a)}return n})}function Re(e){return typeof e!="object"?{node:e,children:[]}:e}function qe(e){return typeof e=="object"&&e!==null&&"select"in e&&"values"in e}function N(e){return Math.max(1,Math.ceil(Math.log2(e)))}function ze(e){if(e.d+e.f+e.x>32)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<<e);function Oe(e){return new Uint8Array(e)}function Qe(e){return new Uint32Array(e)}function M(){return[0].slice(0,0)}var J=class{constructor(e=[]){L(this,"magnitude",0);this.data=e}add(e,t,n){this.data.push({start:e,end:t,value:n}),this.magnitude=0}get(e){for(let t=0;t<this.data.length;t++){let{start:n,end:r,value:l}=this.data[t];if(e>=n&&e<r)return l}return 0}forEach(e){for(let t=0;t<this.data.length;t++){let{start:n,end:r,value:l}=this.data[t];for(let a=n;a<r;a++)e(a,l)}}get length(){return this.magnitude||(this.magnitude=re(this))}},D=class{constructor(e,t=M()){L(this,"magnitude",0);this.data=e,this.cols=t}add(e,t){this.cols.push(e),this.data.push(t),this.magnitude=0}get(e){for(let t=0;t<this.cols.length;t++)if(this.cols[t]===e)return this.data[t];return 0}forEach(e){for(let t=0;t<this.cols.length;t++)e(this.cols[t],this.data[t])}get length(){return this.magnitude||(this.magnitude=re(this))}};function re(e){let t=0;return e.forEach((n,r)=>{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<this.data.length;n++){if(this.data[n]===0)continue;let r=this.data[n];t&&n===this.data.length-1&&(r=r&b[t]);for(let l=0,a=32-Math.clz32(r);l<a;l++)r&1<<l&&e((n<<5)+l)}}};function le(e,t){for(let n=0;n<e.data.length;n++)e.data[n]&=~t.data[n]}function z(e,t){t*=b[32]>>>0;for(let n=0;n<e.data.length;n++)e.data.fill(t)}function V(e,t){for(let n=0;n<e.data.length;n++)e.data[n]&=t.data[n]}function ae(e){for(let t=0;t<e.data.length;t++)e.data[t]^=b[31]}function A(e,t){for(let n=0;n<e.data.length;n++)e.data[n]|=t.data[n]}function Ie(e,t){let n=[{value:e,depth:0}];for(let r=1,l=0;r>0;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<n.length;i++)a.push({terms:[],index:new Map});for(let i=0;i<e.length;i++)for(let u=0;u<n.length;u++){let d=n[u].from(e[i]);if(typeof d>"u")continue;let f=i<<l.f|u;d=q(r,(p,g)=>{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<d.length;p++){let g=Re(d[p]);Ie(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 F=c.terms[v[T]];if(F.position.depth===x){if(x&&h[x-1]!==F.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:E}=c.terms[w];E.push(f<<l.x|y),h[x]=w;for(let T=0;T<v.length;T++)if(v[T]===w)return;v.push(w)})}}let o={documents:e.length,fields:n.length},s={shards:a,space:l,count:o};return yield te(r,i=>{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;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=l;h>0&&(g=o.get(a.terms[c]).children),g.length<s&&g.push(p)}}return l}function Ce(e,t,n){let{documents:r,terms:l}=U(e);if(n<0||n>=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<s.length;i++){let u=s[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;r<n.length;r++)z(n[r],1);return{documents:t,terms:n}}function U(e){return{documents:new S(e.count.documents),terms:e.shards.map(({terms:t})=>new 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<v.length;w++){let E=v[w],T=E>>>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;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}l[o++]=Ce(r,d,u),a.push(Q(R({},i),{value:d}));break;case"operator":let f=o-i.operands.length;switch(i.operator){case"or":for(;o>f+1&&o--;){A(l[f].documents,l[o].documents);for(let c=0;c<t.length;c++)A(l[f].terms[c],l[o].terms[c])}break;case"and":for(;o>f+1&&o--;){V(l[f].documents,l[o].documents);for(let c=0;c<t.length;c++)A(l[f].terms[c],l[o].terms[c])}break;case"not":ae(l[f].documents);for(let c=0;c<t.length;c++)z(l[f].terms[c],0);for(;o>f+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;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return n}function Le(e,t,n=0,r=e.length){for(let l=0;n<r;n+=1+ +(l>65535)){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;l<r;l++)switch(a=e.charCodeAt(l),a){case 60:l>n&&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<e.length;a+=e[l++].length)r=ie(e[l],t,o=>(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&&r(l,Math.min(u,a)),o&&(s=o[0].length,l=o.index+s,s===0&&(t.lastIndex=o.index+1))}while(o&&l<a)}}function Je(e,t){return k(this,null,function*(){let{separator:n,transform:r,fields:l,plugins:a=[]}=t,o=ne(e.length,l.length),s=new Map;for(let f=0;f<e.length;f++)for(let c=0;c<l.length;c++){let h=l[c].from(e[f]);if(typeof h>"u")continue;let p=f<<o.f|c;h=q(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],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<m.length;y++){g=m[y];let x=r(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:e.length,fields:l.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 te(a,f=>{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<o.length;s++){let i=o[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 Xe(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<o.length;s++)n.set(o[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 Ye(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<h.length;x++){let{field:v,value:w}=h[x];if(v==="*"){z(p,1);break}else if(w.get(m)){for(let E=0;E<l.length;E++)if(l[E].name===v){p.set(E);break}}}let{occurrences:y}=e.terms[m];for(let x=0;x<y.length;x++){let v=y[x],w=v>>>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 Ze(e,t=10){return e.length>1?1+e[e.length-1]-e[0]:t}function $e(e,t,n,r=10){let l=[];e.value.text.forEach((s,i)=>{for(let u=0;u<t.data.length;u++){let{start:d,end:f}=t.data[u];d<=i&&i<f&&l.push({index:s,value:u})}}),l.sort((s,i)=>s.index-i.index);let a=l.slice(0,1),o=0;for(let s=0;s<l.length-1;s++){let i=l[s],u=l[s+1],d;if(u.index-i.index>r||u.value===i.value)d=a.map(({index:f})=>f),a=[l[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,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++]=Xe(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;a<e.length;a++){let{start:o,end:s}=e[a];n.push({index:o,value:a}),n.push({index:s,value:a})}n.sort((a,o)=>a.index-o.index);let r=new Set([n[0].value]),l=n[0].index;for(let a=1;a<n.length;a++){let{index:o,value:s}=n[a];if(r.size&&l<o){let i=s;r.forEach(u=>{e[u].start>l||e[u].end<o||e[i].start!==e[u].start&&e[i].end!==e[u].end&&(i=u)}),t.push({start:l,end:o,value:e[i].value})}l=o,r.has(s)?r.delete(s):r.add(s)}return t}function fe(e){let t=[];for(let n=0;n<e.values.length;n++){let{value:r}=e.values[n];Ae(r,({start:l,end:a})=>{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:Ye(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<t.length;o++){let s=t[o](l,a);r.set(s.name,s)}},onFilterQuery(l){var a,o;n=(o=(a=l.aggregation)==null?void 0:a.input)!=null?o:[]},onFilterResult(l){let{select:a}=l.query;l.aggregations=[];for(let o of n){let s=r.get(o.type);if(typeof s>"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<h.length;p++)i.get(h[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<l.length;u++){let d=l[u];se(d,(c,h)=>{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;u<r.length;u++){let d=r[u],f=(i=e.index)==null?void 0:i.get(d);typeof f<"u"&&s.push(f)}return s.sort((u,d)=>u-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;s<t.length;){let i=e.terms[r];if(i.length===s)if(++r===e.terms.length){r=-1;break}else continue;if(i.charCodeAt(s)===t.charCodeAt(s))s++;else if(e.terms.length===++r||e.cover[r]<s){r=-1;break}}if(r===-1)return;for(l=r+1;l<e.terms.length&&!(e.cover[l]<t.length);l++);let a=[],o=e.exact.filter(s=>s>r&&s<l);for(let s=0;s<o.length;s++)r<o[s]&&a.push({start:r,end:o[s]-1,value:1}),r=o[s]+1;return r<=l&&a.push({start:r,end:l,value:1}),new J(a)}function ft(e={}){return O({name:"expansion",onTextStore(t,n){var l,a;let{transform:r}=n;(a=this.data)!=null||(this.data=it({terms:t.terms.map(({value:o})=>o),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;p<l.data.length;p++){let{start:g,end:m}=l.data[p];if(g<=u&&u<m){u=l.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: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<r.length;l++){let{index:a,start:o,end:s}=r[l];n[a]=o<<10|s-o}},onTextStore(r){t=e.handler(r)},onTextResult(r){let{tables:l}=this.data,a=t(r.query);$(r,o=>{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<e.length;r++){let l=e[r](t,n);if(l!==0)return l}return 0}}function mt(e){let{comparators:t}=e;return P("match",(n,{type:r,data:l})=>{if(r!=="match")throw new C("unsupported");let a=xt(e),o=ce(...t.map(s=>s(n)));return Z(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;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 xt(e){var a;let{fields:t,direction:n}=e,r=n==="ascending"?1:-1,l=new Map;for(let o=0;o<t.length;o++){let{name:s,meta:i}=t[o];l.set(s,(a=i.weight)!=null?a:1)}return(o,s)=>r*(l.get(o.field)-l.get(s.field))}function yt(e,t={}){let n=fe(e.query),r=G($e),l=G(Ze);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<e.handlers.length;a++){let o=yield e.handlers[a](r,l);t.set(o.name,o)}})},onTextQuery(r){var l,a,o;this.data.directives=(o=(a=r.order)!=null?a:(l=e.defaults)==null?void 0:l.order)!=null?o:[]},onTextResult(r){let{directives:l}=this.data,a=[];for(let o=0;o<l.length;o++){let s=l[o],i=t.get(s.type);if(typeof i>"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+r<t)return{id:n,size:r,from:l+r}}function Et(){return{query:null,result:null}}function Mt(e={}){let{cache:t=Et(),expires:n=1/0}=e;return{data:t,onQuery(r,{size:l=10}){var s,i,u,d;let a=(u=(i=(s=t.query)==null?void 0:s.page)==null?void 0:i.id)!=null?u:0,o=Date.now()-a<n;t.query=Object.assign({},r),t.result&&((d=r.page)==null?void 0:d.id)===a&&o?t.query.abort=!0:(t.query.page={id:Date.now(),size:l,from:0},t.result=null)},onResult(r){var o;let l=t.query.page;(o=t.result)!=null||(t.result=r),r=Object.assign({},t.result);let a=t.result.items.length;return r.pagination={total:a,prev:Tt(l),next:bt(l,a)},r.items=t.result.items.slice(l.from,l.from+l.size),r}}}var Y=null;self.onmessage=e=>k(null,null,function*(){let t=e.data;switch(t.type){case 0:Y=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()]})]}),pt({handler:r=>ht(r)}),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}),()=>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)});$(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=Y({type:"text",data:t.data});self.postMessage({type:3,data:n.data});break}})});var At=Me(he());})();
1
+ "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<n.length;r++){let l=t(n[r]);if(typeof l<"u")return l}}function ke(e){return e.items}function X(e,t){return $(e,n=>{let{matches:r}=n;for(let l=0;l<r.length;l++){let a=t(r[l],n);if(typeof a<"u")return a}})}function G(e,t=new Map){return(n,...r)=>{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;n<e.plugins.length;n++){let r=e.plugins[n];t.push(typeof r=="function"?yield r(e):r)}return t})}function te(e,t){return k(this,null,function*(){for(let n=0;n<e.length;n++){let r=t(e[n]);r instanceof Promise&&(yield r)}})}function q(e,t,n){for(let r=0;r<e.length;r++){let l=t(n,e[r]);typeof l<"u"&&(n=l)}return n}function Fe(e,t,n){return k(this,null,function*(){var r;for(let l=0;l<e.length;l++){let a=t(n,e[l]);typeof a<"u"&&(n=a instanceof Promise?(r=yield a)!=null?r:n:a)}return n})}function Re(e){return typeof e!="object"?{node:e,children:[]}:e}function qe(e){return typeof e=="object"&&e!==null&&"select"in e&&"values"in e}function N(e){return Math.max(1,Math.ceil(Math.log2(e)))}function ze(e){if(e.d+e.f+e.x>32)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<<e);function Oe(e){return new Uint8Array(e)}function Qe(e){return new Uint32Array(e)}function M(){return[0].slice(0,0)}var J=class{constructor(e=[]){L(this,"magnitude",0);this.data=e}add(e,t,n){this.data.push({start:e,end:t,value:n}),this.magnitude=0}get(e){for(let t=0;t<this.data.length;t++){let{start:n,end:r,value:l}=this.data[t];if(e>=n&&e<r)return l}return 0}forEach(e){for(let t=0;t<this.data.length;t++){let{start:n,end:r,value:l}=this.data[t];for(let a=n;a<r;a++)e(a,l)}}get length(){return this.magnitude||(this.magnitude=re(this))}},D=class{constructor(e,t=M()){L(this,"magnitude",0);this.data=e,this.cols=t}add(e,t){this.cols.push(e),this.data.push(t),this.magnitude=0}get(e){for(let t=0;t<this.cols.length;t++)if(this.cols[t]===e)return this.data[t];return 0}forEach(e){for(let t=0;t<this.cols.length;t++)e(this.cols[t],this.data[t])}get length(){return this.magnitude||(this.magnitude=re(this))}};function re(e){let t=0;return e.forEach((n,r)=>{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<this.data.length;n++){if(this.data[n]===0)continue;let r=this.data[n];t&&n===this.data.length-1&&(r=r&b[t]);for(let l=0,a=32-Math.clz32(r);l<a;l++)r&1<<l&&e((n<<5)+l)}}};function le(e,t){for(let n=0;n<e.data.length;n++)e.data[n]&=~t.data[n]}function z(e,t){t*=b[32]>>>0;for(let n=0;n<e.data.length;n++)e.data.fill(t)}function V(e,t){for(let n=0;n<e.data.length;n++)e.data[n]&=t.data[n]}function ae(e){for(let t=0;t<e.data.length;t++)e.data[t]^=b[31]}function A(e,t){for(let n=0;n<e.data.length;n++)e.data[n]|=t.data[n]}function Ie(e,t){let n=[{value:e,depth:0}];for(let r=1,l=0;r>0;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<n.length;i++)a.push({terms:[],index:new Map});for(let i=0;i<e.length;i++)for(let u=0;u<n.length;u++){let d=n[u].from(e[i]);if(typeof d>"u")continue;let f=i<<l.f|u;d=q(r,(p,g)=>{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<d.length;p++){let g=Re(d[p]);Ie(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 F=c.terms[v[T]];if(F.position.depth===x){if(x&&h[x-1]!==F.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:E}=c.terms[w];E.push(f<<l.x|y),h[x]=w;for(let T=0;T<v.length;T++)if(v[T]===w)return;v.push(w)})}}let o={documents:e.length,fields:n.length},s={shards:a,space:l,count:o};return yield te(r,i=>{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;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=l;h>0&&(g=o.get(a.terms[c]).children),g.length<s&&g.push(p)}}return l}function Ce(e,t,n){let{documents:r,terms:l}=U(e);if(n<0||n>=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<s.length;i++){let u=s[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;r<n.length;r++)z(n[r],1);return{documents:t,terms:n}}function U(e){return{documents:new S(e.count.documents),terms:e.shards.map(({terms:t})=>new 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<v.length;w++){let E=v[w],T=E>>>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;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}l[o++]=Ce(r,d,u),a.push(Q(R({},i),{value:d}));break;case"operator":let f=o-i.operands.length;switch(i.operator){case"or":for(;o>f+1&&o--;){A(l[f].documents,l[o].documents);for(let c=0;c<t.length;c++)A(l[f].terms[c],l[o].terms[c])}break;case"and":for(;o>f+1&&o--;){V(l[f].documents,l[o].documents);for(let c=0;c<t.length;c++)A(l[f].terms[c],l[o].terms[c])}break;case"not":ae(l[f].documents);for(let c=0;c<t.length;c++)z(l[f].terms[c],0);for(;o>f+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;r<n;r++)if(e.charCodeAt(r)!==t.charCodeAt(r))return r;return n}function Le(e,t,n=0,r=e.length){for(let l=0;n<r;n+=1+ +(l>65535)){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;l<r;l++)switch(a=e.charCodeAt(l),a){case 60:l>n&&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<e.length;a+=e[l++].length)r=ie(e[l],t,o=>(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&&r(l,Math.min(u,a)),o&&(s=o[0].length,l=o.index+s,s===0&&(t.lastIndex=o.index+1))}while(o&&l<a)}}function Je(e,t){return k(this,null,function*(){let{separator:n,transform:r,fields:l,plugins:a=[]}=t,o=ne(e.length,l.length),s=new Map;for(let f=0;f<e.length;f++)for(let c=0;c<l.length;c++){let h=l[c].from(e[f]);if(typeof h>"u")continue;let p=f<<o.f|c;h=q(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],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<m.length;y++){g=m[y];let x=r(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:e.length,fields:l.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 te(a,f=>{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<o.length;s++){let i=o[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<o.length;s++)n.set(o[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<h.length;x++){let{field:v,value:w}=h[x];if(v==="*"){z(p,1);break}else if(w.get(m)){for(let E=0;E<l.length;E++)if(l[E].name===v){p.set(E);break}}}let{occurrences:y}=e.terms[m];for(let x=0;x<y.length;x++){let v=y[x],w=v>>>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;u<t.data.length;u++){let{start:d,end:f}=t.data[u];d<=i&&i<f&&l.push({index:s,value:u})}}),l.sort((s,i)=>s.index-i.index);let a=l.slice(0,1),o=0;for(let s=0;s<l.length-1;s++){let i=l[s],u=l[s+1],d;if(u.index-i.index>r||u.value===i.value)d=a.map(({index:f})=>f),a=[l[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,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;a<e.length;a++){let{start:o,end:s}=e[a];n.push({index:o,value:a}),n.push({index:s,value:a})}n.sort((a,o)=>a.index-o.index);let r=new Set([n[0].value]),l=n[0].index;for(let a=1;a<n.length;a++){let{index:o,value:s}=n[a];if(r.size&&l<o){let i=s;r.forEach(u=>{e[u].start>l||e[u].end<o||e[i].start!==e[u].start&&e[i].end!==e[u].end&&(i=u)}),t.push({start:l,end:o,value:e[i].value})}l=o,r.has(s)?r.delete(s):r.add(s)}return t}function fe(e){let t=[];for(let n=0;n<e.values.length;n++){let{value:r}=e.values[n];Ae(r,({start:l,end:a})=>{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<t.length;o++){let s=t[o](l,a);r.set(s.name,s)}},onFilterQuery(l){var a,o;n=(o=(a=l.aggregation)==null?void 0:a.input)!=null?o:[]},onFilterResult(l){let{select:a}=l.query;l.aggregations=[];for(let o of n){let s=r.get(o.type);if(typeof s>"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<h.length;p++)i.get(h[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<l.length;u++){let d=l[u];se(d,(c,h)=>{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;u<r.length;u++){let d=r[u],f=(i=e.index)==null?void 0:i.get(d);typeof f<"u"&&s.push(f)}return s.sort((u,d)=>u-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;s<t.length;){let i=e.terms[r];if(i.length===s)if(++r===e.terms.length){r=-1;break}else continue;if(i.charCodeAt(s)===t.charCodeAt(s))s++;else if(e.terms.length===++r||e.cover[r]<s){r=-1;break}}if(r===-1)return;for(l=r+1;l<e.terms.length&&!(e.cover[l]<t.length);l++);let a=[],o=e.exact.filter(s=>s>r&&s<l);for(let s=0;s<o.length;s++)r<o[s]&&a.push({start:r,end:o[s]-1,value:1}),r=o[s]+1;return r<=l&&a.push({start:r,end:l,value:1}),new J(a)}function ft(e={}){return O({name:"expansion",onTextStore(t,n){var l,a;let{transform:r}=n;(a=this.data)!=null||(this.data=it({terms:t.terms.map(({value:o})=>o),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;p<l.data.length;p++){let{start:g,end:m}=l.data[p];if(g<=u&&u<m){u=l.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: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<r.length;l++){let{index:a,start:o,end:s}=r[l];n[a]=o<<10|s-o}},onTextStore(r){t=e.handler(r)},onTextResult(r){let{tables:l}=this.data,a=t(r.query);X(r,o=>{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<e.length;r++){let l=e[r](t,n);if(l!==0)return l}return 0}}function mt(e){let{comparators:t}=e;return P("match",(n,{type:r,data:l})=>{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;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 xt(e){var a;let{fields:t,direction:n}=e,r=n==="ascending"?1:-1,l=new Map;for(let o=0;o<t.length;o++){let{name:s,meta:i}=t[o];l.set(s,(a=i.weight)!=null?a:1)}return(o,s)=>r*(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<e.handlers.length;a++){let o=yield e.handlers[a](r,l);t.set(o.name,o)}})},onTextQuery(r){var l,a,o;this.data.directives=(o=(a=r.order)!=null?a:(l=e.defaults)==null?void 0:l.order)!=null?o:[]},onTextResult(r){let{directives:l}=this.data,a=[];for(let o=0;o<l.length;o++){let s=l[o],i=t.get(s.type);if(typeof i>"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+r<t)return{id:n,size:r,from:l+r}}function Et(){return{query:null,result:null}}function Mt(e={}){let{cache:t=Et(),expires:n=1/0}=e;return{data:t,onQuery(r,{size:l=10}){var s,i,u,d;let a=(u=(i=(s=t.query)==null?void 0:s.page)==null?void 0:i.id)!=null?u:0,o=Date.now()-a<n;t.query=Object.assign({},r),t.result&&((d=r.page)==null?void 0:d.id)===a&&o?r.abort=!0:(t.query.page={id:Date.now(),size:l,from:0},t.result=null)},onResult(r){var o;let l=t.query.page;(o=t.result)!=null||(t.result=r),r=Object.assign({},t.result);let a=t.result.items.length;return r.pagination={total:a,prev:Tt(l),next:bt(l,a)},r.items=t.result.items.slice(l.from,l.from+l.size),r}}}var Z=null;self.onmessage=e=>k(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());})();