1import{a as T,t as N,e as Qe}from"../chunks/BADCMPAa.js";import{y as Be,aC as Ge,ab as Ue,e as qe,ai as Ke,z as ae,E as Ye,p as Fe,t as se,a as Oe,c as O,s as W,g as D,r as I,$ as He,n as Ze}from"../chunks/BTU_w0dp.js";import{h as Xe}from"../chunks/CZ11VWqb.js";import{o as Ce}from"../chunks/CvTnqAea.js";import"../chunks/xwhzQQ8y.js";import{d as et,e as tt,s as Q}from"../chunks/CdnhGxty.js";import{i as _e}from"../chunks/BaUnd-GZ.js";import{r as st,e as we,i as ve,s as nt,a as it}from"../chunks/87hMS0rr.js";import{s as ot,a as j}from"../chunks/BQWHu-rt.js";import{w as C}from"../chunks/BwOyH-nU.js";import{s as rt,a as ct}from"../chunks/B4BBpe7x.js";function at(i,e,...t){var s=i,n=qe,o;Be(()=>{n!==(n=e())&&(o&&(Ke(o),o=null),o=Ue(()=>n(s,...t)))},Ge),ae&&(s=Ye)}function ye(i,e,t){var s=i.__className,n=dt(e);ae&&i.className===n?i.__className=n:(s!==n||ae&&i.className!==n)&&(e==null?i.removeAttribute("class"):i.className=n,i.__className=n)}function dt(i,e){return(i??"")+""}var ut=N('<header class="py-4 font-semibold text-black dark:text-white sm:py-4 print:hidden"><nav class="flex items-center justify-between"><div class="flex flex-row items-center"><h1 class="text-2xl"><a class="decoration-primary-500 hover:underline hover:decoration-2 hover:underline-offset-2" rel="me" href="/">ChineseDict</a></h1></div> <ul class="flex list-none flex-row items-center text-end text-base"><li class="group me-7 last:me-0.5"><a href="/random"><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">🍀 Random</span></a></li> <li class="group me-7 last:me-0.5"><a href="/about"><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">❓ About</span></a></li> <li class="group me-7 last:me-0.5"><a href="https://github.com/jeffcarp/chinesedict/issues/new"><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">📝 Feedback</span></a></li></ul></nav></header>');function lt(i){var e=ut();T(i,e)}const ht=C([]),be=C(!0),ft=C([]),B=C(!0),mt=async()=>[],gt=async()=>{{const e=await(await fetch(new URL("/full_search_index.json",window.location.origin))).json();return ft.set(e),B.set(!1),e}};function K(i,e,t,s){function n(o){return o instanceof t?o:new t(function(r){r(o)})}return new(t||(t=Promise))(function(o,r){function c(u){try{d(s.next(u))}catch(f){r(f)}}function a(u){try{d(s.throw(u))}catch(f){r(f)}}function d(u){u.done?o(u.value):n(u.value).then(c,a)}d((s=s.apply(i,[])).next())})}const pt="ENTRIES",Me="KEYS",ke="VALUES",z="";
1class ne{constructor(e,t){const s=e._tree,n=Array.from(s.keys());this.set=e,this._type=t,this._path=n.length>0?[{node:s,keys:n}]:[]}next(){const e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:e,keys:t}=P(this._path);if(P(t)===z)return{done:!1,value:this.result()};const s=e.get(P(t));return this._path.push({node:s,keys:Array.from(s.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const e=P(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>P(e)).filter(e=>e!==z).join("")}value(){return P(this._path).node.get(z)}result(){switch(this._type){case ke:return this.value();case Me:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const P=i=>i[i.length-1],_t=(i,e,t)=>{const s=new Map;if(e===void 0)return s;const n=e.length+1,o=n+t,r=new Uint8Array(o*n).fill(t+1);for(let c=0;c<n;++c)r[c]=c;for(let c=1;c<o;++c)r[c*n]=c;return je(i,e,t,s,r,1,n,""),s},je=(i,e,t,s,n,o,r,c)=>{const a=o*r;e:for(const d of i.keys())if(d===z){const u=n[a-1];u<=t&&s.set(c,[i.get(d),u])}else{let u=o;for(let f=0;f<d.length;++f,++u){const l=d[f],_=r*u,w=_-r;let m=n[_];const v=Math.max(0,u-t-1),F=Math.min(r-1,u+t);for(let S=v;S<F;++S){const L=l!==e[S],E=n[w+S]+ +L,$=n[w+S+1]+1,k=n[_+S]+1,A=n[_+S+1]=Math.min(E,$,k);A<m&&(m=A)}if(m>t)continue e}je(i.get(d),e,t,s,n,u,r,c+d)}};class V{constructor(e=new Map,t=""){this._size=void 0,this._tree=e,this._prefix=t}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");const[t,s]=Y(this._tree,e.slice(this._prefix.length));if(t===void 0){const[n,o]=he(s);for(const r of n.keys())if(r!==z&&r.startsWith(o)){const c=new Map;return c.set(r.slice(o.length),n.get(r)),new V(c,e)}}return new V(t,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,wt(this._tree,e)}entries(){return new ne(this,pt)}forEach(e){for(const[t,s]of this)e(t,s,this)}fuzzyGet(e,t){return _t(this._tree,e,t)}get(e){const t=de(this._tree,e);return t!==void 0?t.get(z):void 0}has(e){const t=de(this._tree,e);return t!==void 0&&t.has(z)}keys(){return new ne(this,Me)}set(e,t){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,ie(this._tree,e).set(z,t),this}get size(){if(this._size)return this._size;this._size=0;const e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const s=ie(this._tree,e);return s.set(z,t(s.get(z))),this}fetch(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const s=ie(this._tree,e);let n=s.get(z);return n===void 0&&s.set(z,n=t()),n}values(){return new ne(this,ke)}[Symbol.iterator](){return this.entries()}static from(e){const t=new V;for(const[s,n]of e)t.set(s,n);return t}static fromObject(e){return V.from(Object.entries(e))}}const Y=(i,e,t=[])=>{if(e.length===0||i==null)return[i,t];for(const s of i.keys())if(s!==z&&e.startsWith(s))return t.push([i,s]),Y(i.get(s),e.slice(s.length),t);return t.push([i,e]),Y(void 0,"",t)},de=(i,e)=>{if(e.length===0||i==null)return i;for(const t of i.keys())if(t!==z&&e.startsWith(t))return de(i.get(t),e.slice(t.length))},ie=(i,e)=>{const t=e.length;e:for(let s=0;i&&s<t;){for(const o of i.keys())if(o!==z&&e[s]===o[0]){const r=Math.min(t-s,o.length);let c=1;for(;c<r&&e[s+c]===o[c];)++c;const a=i.get(o);if(c===o.length)i=a;else{const d=new Map;d.set(o.slice(c),a),i.set(e.slice(s,s+c),d),i.delete(o),i=d}s+=c;continue e}const n=new Map;return i.set(e.slice(s),n),n}return i},wt=(i,e)=>{const[t,s]=Y(i,e);if(t!==void 0){if(t.delete(z),t.size===0)Le(s);else if(t.size===1){const[n,o]=t.entries().next().value;Te(s,n,o)}}},Le=i=>{if(i.length===0)return;const[e,t]=he(i);if(e.delete(t),e.size===0)Le(i.slice(0,-1));else if(e.size===1){const[s,n]=e.entries().next().value;s!==z&&Te(i.slice(0,-1),s,n)}},Te=(i,e,t)=>{if(i.length===0)return;const[s,n]=he(i);s.set(n+e,t),s.delete(n)},he=i=>i[i.length-1],fe="or",Ve="and",vt="and_not";class J{constructor(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');const t=e.autoVacuum==null||e.autoVacuum===!0?ce:e.autoVacuum;this._options=Object.assign(Object.assign(Object.assign({},re),e),{autoVacuum:t,searchOptions:Object.assign(Object.assign({},xe),e.searchOptions||{}),autoSuggestOptions:Object.assign(Object.assign({},zt),e.autoSuggestOptions||{})}),this._index=new V,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=le,this.addFields(this._options.fields)}add(e){const{extractField:t,tokenize:s,processTerm:n,fields:o,idField:r}=this._options,c=t(e,r);if(c==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);if(this._idToShortId.has(c))throw new Error(`MiniSearch: duplicate ID ${c}`);const a=this.addDocumentId(c);this.saveStoredFields(a,e);for(const d of o){const u=t(e,d);if(u==null)continue;const f=s(u.toString(),d),l=this._fieldIds[d],_=new Set(f).size;this.addFieldLength(a,l,this._documentCount-1,_);for(const w of f){const m=n(w,d);if(Array.isArray(m))for(const v of m)this.addTerm(l,a,v);else m&&this.addTerm(l,a,m)}}}addAll(e){for(const t of e)this.add(t)}addAllAsync(e,t={}){const{chunkSize:s=10}=t,n={chunk:[],promise:Promise.resolve()},{chunk:o,promise:r}=e.reduce(({chunk:c,promise:a},d,u)=>(c.push(d),(u+1)%s===0?{chunk:[],promise:a.then(()=>new Promise(f=>setTimeout(f,0))).then(()=>this.addAll(c))}:{chunk:c,promise:a}),n);return r.then(()=>this.addAll(o))}remove(e){const{tokenize:t,processTerm:s,extractField:n,fields:o,idField:r}=this._options,c=n(e,r);if(c==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);const a=this._idToShortId.get(c);if(a==null)throw new Error(`MiniSearch: cannot remove document with ID ${c}: it is not in the index`);for(const d of o){const u=n(e,d);if(u==null)continue;const f=t(u.toString(),d),l=this._fieldIds[d],_=new Set(f).size;this.removeFieldLength(a,l,this._documentCount,_);for(const w of f){const m=s(w,d);if(Array.isArray(m))for(const v of m)this.removeTerm(l,a,v);else m&&this.removeTerm(l,a,m)}}this._storedFields.delete(a),this._documentIds.delete(a),this._idToShortId.delete(c),this._fieldLength.delete(a),this._documentCount-=1}removeAll(e){if(e)for(const t of e)this.remove(t);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new V,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(e){const t=this._idToShortId.get(e);if(t==null)throw new Error(`MiniSearch: cannot discard document with ID ${e}: it is not in the index`);this._idToShortId.delete(e),this._documentIds.delete(t),this._storedFields.delete(t),(this._fieldLength.get(t)||[]).forEac
1h((s,n)=>{this.removeFieldLength(t,n,this._documentCount,s)}),this._fieldLength.delete(t),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:e,minDirtCount:t,batchSize:s,batchWait:n}=this._options.autoVacuum;this.conditionalVacuum({batchSize:s,batchWait:n},{minDirtCount:t,minDirtFactor:e})}discardAll(e){const t=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const s of e)this.discard(s)}finally{this._options.autoVacuum=t}this.maybeAutoVacuum()}replace(e){const{idField:t,extractField:s}=this._options,n=s(e,t);this.discard(n),this.add(e)}vacuum(e={}){return this.conditionalVacuum(e)}conditionalVacuum(e,t){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const s=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=le,this.performVacuuming(e,s)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}performVacuuming(e,t){return K(this,void 0,void 0,function*(){const s=this._dirtCount;if(this.vacuumConditionsMet(t)){const n=e.batchSize||ue.batchSize,o=e.batchWait||ue.batchWait;let r=1;for(const[c,a]of this._index){for(const[d,u]of a)for(const[f]of u)this._documentIds.has(f)||(u.size<=1?a.delete(d):u.delete(f));this._index.get(c).size===0&&this._index.delete(c),r%n===0&&(yield new Promise(d=>setTimeout(d,o))),r+=1}this._dirtCount-=s}yield null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null})}vacuumConditionsMet(e){if(e==null)return!0;let{minDirtCount:t,minDirtFactor:s}=e;return t=t||ce.minDirtCount,s=s||ce.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=s}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(e){return this._idToShortId.has(e)}getStoredFields(e){const t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)}search(e,t={}){const{searchOptions:s}=this._options,n=Object.assign(Object.assign({},s),t),o=this.executeQuery(e,t),r=[];for(const[c,{score:a,terms:d,match:u}]of o){const f=d.length||1,l={id:this._documentIds.get(c),score:a*f,terms:Object.keys(u),queryTerms:d,match:u};Object.assign(l,this._storedFields.get(c)),(n.filter==null||n.filter(l))&&r.push(l)}return e===J.wildcard&&n.boostDocument==null||r.sort(ze),r}autoSuggest(e,t={}){t=Object.assign(Object.assign({},this._options.autoSuggestOptions),t);const s=new Map;for(const{score:o,terms:r}of this.search(e,t)){const c=r.join(" "),a=s.get(c);a!=null?(a.score+=o,a.count+=1):s.set(c,{score:o,terms:r,count:1})}const n=[];for(const[o,{score:r,terms:c,count:a}]of s)n.push({suggestion:o,terms:c,score:r/a});return n.sort(ze),n}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),t)}static loadJSONAsync(e,t){return K(this,void 0,void 0,function*(){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(e),t)})}static getDefault(e){if(re.hasOwnProperty(e))return oe(re,e);throw new Error(`MiniSearch: unknown option "${e}"`)}static loadJS(e,t){const{index:s,documentIds:n,fieldLength:o,storedFields:r,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=U(n),a._fieldLength=U(o),a._storedFields=U(r);for(const[d,u]of a._documentIds)a._idToShortId.set(u,d);for(const[d,u]of s){const f=new Map;for(const l of Object.keys(u)){let _=u[l];c===1&&(_=_.ds),f.set(parseInt(l,10),U(_))}a._index.set(d,f)}return a}static loadJSAsync(e,t){return K(this,void 0,void 0,function*(){const{index:s,documentIds:n,fieldLength:o,storedFields:r,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=yield q(n),a._fieldLength=yield q(o),a._storedFields=yield q(r);for(const[u,f]of a._documentIds)a._idToShortId.set(f,u);let d=0;for(const[u,f]of s){const l=new Map;for(const _ of Object.keys(f)){let w=f[_];c===1&&(w=w.ds),l.set(parseInt(_,10),yield q(w))}++d%1e3===0&&(yield Ee(0)),a._index.set(u,l)}return a})}static instantiateMiniSearch(e,t){const{documentCount:s,nextId:n,fieldIds:o,averageFieldLength:r,dirtCount:c,seri
1alizationVersion:a}=e;if(a!==1&&a!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const d=new J(t);return d._documentCount=s,d._nextId=n,d._idToShortId=new Map,d._fieldIds=o,d._avgFieldLength=r,d._dirtCount=c||0,d._index=new V,d}executeQuery(e,t={}){if(e===J.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){const l=Object.assign(Object.assign(Object.assign({},t),e),{queries:void 0}),_=e.queries.map(w=>this.executeQuery(w,l));return this.combineResults(_,l.combineWith)}const{tokenize:s,processTerm:n,searchOptions:o}=this._options,r=Object.assign(Object.assign({tokenize:s,processTerm:n},o),t),{tokenize:c,processTerm:a}=r,f=c(e).flatMap(l=>a(l)).filter(l=>!!l).map(St(r)).map(l=>this.executeQuerySpec(l,r));return this.combineResults(f,r.combineWith)}executeQuerySpec(e,t){const s=Object.assign(Object.assign({},this._options.searchOptions),t),n=(s.fields||this._options.fields).reduce((m,v)=>Object.assign(Object.assign({},m),{[v]:oe(s.boost,v)||1}),{}),{boostDocument:o,weights:r,maxFuzzy:c,bm25:a}=s,{fuzzy:d,prefix:u}=Object.assign(Object.assign({},xe.weights),r),f=this._index.get(e.term),l=this.termResults(e.term,e.term,1,e.termBoost,f,n,o,a);let _,w;if(e.prefix&&(_=this._index.atPrefix(e.term)),e.fuzzy){const m=e.fuzzy===!0?.2:e.fuzzy,v=m<1?Math.min(c,Math.round(e.term.length*m)):m;v&&(w=this._index.fuzzyGet(e.term,v))}if(_)for(const[m,v]of _){const F=m.length-e.term.length;if(!F)continue;w==null||w.delete(m);const S=u*m.length/(m.length+.3*F);this.termResults(e.term,m,S,e.termBoost,v,n,o,a,l)}if(w)for(const m of w.keys()){const[v,F]=w.get(m);if(!F)continue;const S=d*m.length/(m.length+F);this.termResults(e.term,m,S,e.termBoost,v,n,o,a,l)}return l}executeWildcardQuery(e){const t=new Map,s=Object.assign(Object.assign({},this._options.searchOptions),e);for(const[n,o]of this._documentIds){const r=s.boostDocument?s.boostDocument(o,"",this._storedFields.get(n)):1;t.set(n,{score:r,terms:[],match:{}})}return t}combineResults(e,t=fe){if(e.length===0)return new Map;const s=t.toLowerCase(),n=yt[s];if(!n)throw new Error(`Invalid combination operator: ${t}`);return e.reduce(n)||new Map}toJSON(){const e=[];for(const[t,s]of this._index){const n={};for(const[o,r]of s)n[o]=Object.fromEntries(r);e.push([t,n])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,serializationVersion:2}}termResults(e,t,s,n,o,r,c,a,d=new Map){if(o==null)return d;for(const u of Object.keys(r)){const f=r[u],l=this._fieldIds[u],_=o.get(l);if(_==null)continue;let w=_.size;const m=this._avgFieldLength[l];for(const v of _.keys()){if(!this._documentIds.has(v)){this.removeTerm(l,v,t),w-=1;continue}const F=c?c(this._documentIds.get(v),t,this._storedFields.get(v)):1;if(!F)continue;const S=_.get(v),L=this._fieldLength.get(v)[l],E=xt(S,w,this._documentCount,L,m,a),$=s*n*f*F*E,k=d.get(v);if(k){k.score+=$,It(k.terms,e);const A=oe(k.match,t);A?A.push(u):k.match[t]=[u]}else d.set(v,{score:$,terms:[e],match:{[t]:[u]}})}}return d}addTerm(e,t,s){const n=this._index.fetch(s,Ie);let o=n.get(e);if(o==null)o=new Map,o.set(t,1),n.set(e,o);else{const r=o.get(t);o.set(t,(r||0)+1)}}removeTerm(e,t,s){if(!this._index.has(s)){this.warnDocumentChanged(t,e,s);return}const n=this._index.fetch(s,Ie),o=n.get(e);o==null||o.get(t)==null?this.warnDocumentChanged(t,e,s):o.get(t)<=1?o.size<=1?n.delete(e):o.delete(t):o.set(t,o.get(t)-1),this._index.get(s).size===0&&this._index.delete(s)}warnDocumentChanged(e,t,s){for(const n of Object.keys(this._fieldIds))if(this._fieldIds[n]===t){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(e)} has changed before removal: term "${s}" was not present in field "${n}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(e){const t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t}addFields(e){for(let t=0;t<e.length;t++)this._fieldIds[e[t]]=t}addFieldLength(e,t,s,n){let o=this._fieldLength.get(e);o==null&&this._fieldLength.set(e,o=[]),o[t]=n;const c=(this._avgFieldLength[t]||0)*s+n;this._avgFieldLength[t]=c/(s+1)}removeFieldLength(e,t,s,n){if(s===1){this._avgFieldLength[t]=0;return}const o=this._avgFieldLength[t]*s-n;this._avgFieldLength[t]=o/(s-1)}saveStoredFields(e,t){const{storeFields:s,extractField:n}=this._options;if(s==null||s.length===0)return;let o=this._storedFields.get(e);o==null&&this._storedFields.set(e,o={});for(const r of s){const c=n(t,r);c!==void 0&&(o[r]=c)}}}J.wildcard=Symbol("*");const oe=(i,e)=>Object.prototype.hasOwnProperty.call(i,e)?i[e]:void 0,yt={[fe]:(i,e)=>{for(const t of e.keys()){const s=i.get(t);if(s==null)i.set(t,e.get(t));else{const{score:n,terms:o,match:r}=e.get(t);s.score=s.score+n,s.match=Object.assign(s.match,r),Se(s.terms,o)}}return i},[Ve]:(i,e)=>{const t=new Map;for(const s of e.keys()){const n=i.get(s);if(n==null)continue;const{score:o,terms:r,match:c}=e.get(s);Se(n.terms,r),t.set(s,{score:n.score+o,terms:n.terms,match:Object.assign(n.match,c
1)})}return t},[vt]:(i,e)=>{for(const t of e.keys())i.delete(t);return i}},bt={k:1.2,b:.7,d:.5},xt=(i,e,t,s,n,o)=>{const{k:r,b:c,d:a}=o;return Math.log(1+(t-e+.5)/(e+.5))*(a+i*(r+1)/(i+r*(1-c+c*s/n)))},St=i=>(e,t,s)=>{const n=typeof i.fuzzy=="function"?i.fuzzy(e,t,s):i.fuzzy||!1,o=typeof i.prefix=="function"?i.prefix(e,t,s):i.prefix===!0,r=typeof i.boostTerm=="function"?i.boostTerm(e,t,s):1;return{term:e,fuzzy:n,prefix:o,termBoost:r}},re={idField:"id",extractField:(i,e)=>i[e],tokenize:i=>i.split(Ft),processTerm:i=>i.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(i,e)=>{typeof(console==null?void 0:console[i])=="function"&&console[i](e)},autoVacuum:!0},xe={combineWith:fe,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:bt},zt={combineWith:Ve,prefix:(i,e,t)=>e===t.length-1},ue={batchSize:1e3,batchWait:10},le={minDirtFactor:.1,minDirtCount:20},ce=Object.assign(Object.assign({},ue),le),It=(i,e)=>{i.includes(e)||i.push(e)},Se=(i,e)=>{for(const t of e)i.includes(t)||i.push(t)},ze=({score:i},{score:e})=>e-i,Ie=()=>new Map,U=i=>{const e=new Map;for(const t of Object.keys(i))e.set(parseInt(t,10),i[t]);return e},q=i=>K(void 0,void 0,void 0,function*(){const e=new Map;let t=0;for(const s of Object.keys(i))e.set(parseInt(s,10),i[s]),++t%1e3===0&&(yield Ee(0));return e}),Ee=i=>new Promise(e=>setTimeout(e,i)),Ft=/[\n\r\p{Z}\p{P}]+/u,Ot=()=>{const i=rt;return{page:{subscribe:i.page.subscribe},navigating:{subscribe:i.navigating.subscribe},updated:i.updated}},Ct={subscribe(i){return Ot().page.subscribe(i)}};var Mt=N("<button> </button>"),kt=N('<p class="text-sm text-gray-600 p-2"></p>'),jt=N('<li class="block"><a class="block py-2 px-2 hover:bg-gray-50/50"><p class="text-xs text-gray-300 float-right"> </p> <h2 class="text-2xl text-normal text-gray-900"> </h2> <p class="text-sm text-gray-600"> </p> <p class="text-base text-gray-700"> </p></a></li>'),Lt=N('<ul class="divide-y divide-gray-300"></ul>'),Tt=N('<div class="w-full pb-4 mb-4"><div class="relative"><input type="search" placeholder="Search for words..." class="w-full px-4 py-3 text-gray-900 bg-gray-50 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"> <button class="absolute right-3 top-1/2 -translate-y-1/2" aria-label="Search"><svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd"></path></svg></button> <div><!> <!></div></div></div>');function Vt(i,e){Fe(e,!0);const[t,s]=ot(),n=()=>j(Ct,"$page",t),o=()=>j(B,"$searchIndexLoading",t),r=()=>j(_,"$searchQuery",t),c=()=>j(w,"$activeSearchTerm",t),a=()=>j(v,"$showSearchResults",t),d=()=>j(L,"$isSegmentMode",t),u=()=>j(F,"$segmentedWords",t),f=()=>j(S,"$selectedWordIndex",t),l=()=>j(m,"$searchResults",t);let _=C(""),w=C(""),m=C([]),v=C(!1),F=C([]),S=C(0),L=C(!1),E,$;function k(h){const x={isWord:!1,children:new Map};for(const g of h){const p=g.simplified;let y=x;for(const b of p)y.children.has(b)||y.children.set(b,{isWord:!1,children:new Map}),y=y.children.get(b);y.isWord=!0}return x}function A(h){const x=[];let g=0;for(;g<h.length;){let p=g,y=g,b=$;for(;p<h.length&&b.children.has(h[p]);)b=b.children.get(h[p]),p++,b.isWord&&(y=p);y>g?(x.push(h.slice(g,y)),g=y):g++}return x}Ce(async()=>{try{const h=await gt();E=new J({fields:["simplified","traditional","pinyin","pinyinNormalized","pinyinJoined","definitions"],storeFields:["simplified","traditional","pinyin","definitions","percentile"],searchOptions:{boost:{percentile:20,simplified:5,traditional:5,pinyin:2,pinyinNormalized:2,pinyinJoined:2,definitions:1},fuzzy:.2},extractField:(g,p)=>p==="pinyinNormalized"?g.pinyin.map(y=>y.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/\d+/g,"")).join(""):p==="pinyinJoined"?g.pinyin.join(""):p==="definitions"?g.definitions.map(y=>y.definition).join(", "):g[p]}),E.addAll(h.map((g,p)=>({...g,id:p}))),$=k(h);const x=n().url.searchParams.get("q");x&&(_.set(x),H()),B.set(!1)}catch(h){console.error("Failed to load search index:",h),B.set(!1)}});function $e(h){const x=h.target.value;_.set(x),H()}async function H(){v.set(!0),o()&&(console.log("searchIndexLoading",o()),await new Promise(g=>{const p=B.subscribe(y=>{console.log("searchIndexLoading",y),y||(p(),g(!0))})}));const h=r().toLowerCase().trim();if(!h){m.set([]);return}if(/[\u4e00-\u9fff]/.test(h)){const g=A(h);g.length>1?(F.set(g),L.set(!0),c()===""&&(w.set(g[0]),S.set(0))):(L.set(!1),w.set(h))}else L.set(!1),w.set(h);console.log("activeSearchTerm",c());const x=E.search(c(),{prefix:!0,fuzzy:.2,boost:{percentile:50,pinyinNormalized:20,simplified:20}}).sort((g,p)=>{const y=g.simplified.toLowerCase()===h||g.definitions.split(", ").some(M=>M.toLowerCase()===h)||g.definitions.includes(` ${h}`)||g.definitions.includes(`${h} `)||g.definitions.includes(`${h},`),b=p.simplified.toLowerCase()===h||p.definitions.split(", ").some(M=>M.toLowerCase()===h)||p.definitions.includes(` ${h}`)||p.definitions.includes(`${h} `)||p.definitions.includes(`${h},`);if(y&&!b)return-1;if(!y&&b)return 1;if(!y&&!b){const ee=g.score+g.percentile*20;return p.score+p.percentile*20-ee}return p.score-g.score}).slice(0,10);m.set(x)}ct(()=>{v.set(!1)});var Z=Tt(),me=O(Z),R=O(me);st(R),R.__input=$e;var X=W(R,4),ge=O(X);{var Ae=h=>{var x=kt();we(x,5,u,ve,(g,p,y)=>{var b=Mt();b.__click=()=>{S.set(y),w.set(D(p)),H()};var M=O(b,!0);I(b),se(()=>{ye(b,`mr-1 px-2 py-1 rounded-md ${(y===f()?"bg-blue-500 text-white":"bg-white hover:bg-gray-100 text-gray-900 border border-gray-200")??""}`),Q(M,D(p))}),T(g,b)}),I(x),T(h,x)};_e(ge,h=>{d()&&h(Ae)})}var De=W(ge,2);{var We=h=>{var x=Lt();we(x,5,l,ve,(g,p)=>
1{var y=jt(),b=O(y),M=O(b),ee=O(M,!0);I(M);var G=W(M,2),Ne=O(G,!0);I(G);var te=W(G,2),Re=O(te,!0);I(te);var pe=W(te,2),Pe=O(pe,!0);I(pe),I(b),I(y),se(Je=>{nt(b,"href",`/word/${D(p).simplified??""}`),Q(ee,D(p).percentile),Q(Ne,D(p).simplified),Q(Re,Je),Q(Pe,D(p).definitions)},[()=>D(p).pinyin.join(" ")]),T(g,y)}),I(x),T(h,x)};_e(De,h=>{l().length>0&&h(We)})}I(X),I(me),I(Z),se(()=>{it(R,r()),R.disabled=o(),ye(X,`search-results ${(a()?"show":"")??""} bg-gray-100 bg-opacity-95 rounded-lg max-h-screen overscroll-auto overflow-hidden`)}),tt("focus",R,h=>h.target.select()),T(i,Z),Oe(),s()}et(["input","click"]);var Et=N('<meta name="description" content="Chinese-English Dictionary">'),$t=Qe(`<div class="min-h-screen flex flex-col"><!> <div class="flex-1"><!> <main><!></main></div> <footer class="text-xs text-gray-500 py-4 min-h-[5rem]"><p class="text-xs/5">Data via <a href="/about" class="decoration-1 decoration-gray-500 underline-offset-2 underline decoration-dashed">CC-EDICT and others</a>.<br> Provide feedback <a href="https://github.com/jeffcarp/chinesedict/issues/new" class="decoration-1 decoration-gray-500 underline-offset-2 underline decoration-dashed">here</a>.</p></footer> <script> 2 if (!window.location.origin.includes('localhost')) { 3 const GA_ID = 'G-JGWNGNWF35'; 4 const script = document.createElement('script'); 5 script.async = true; 6 script.src = \`https://www.googletagmanager.com/gtag/js?id=\${GA_ID}\`; 7 document.head.appendChild(script); 8 9 window.dataLayer = window.dataLayer || []; 10 function gtag(){dataLayer.push(arguments);} 11 gtag('js', new Date()); 12 gtag('config', GA_ID); 13 } 14 <\/script></div>`);function qt(i,e){Fe(e,!0),Ce(async()=>{try{const a=await mt();ht.set(a),be.set(!1)}catch(a){console.error("Failed to load dictionary:",a),be.set(!1)}});var t=$t();Xe(a=>{var d=Et();He.title="ChineseDict",T(a,d)});var s=O(t);lt(s);var n=W(s,2),o=O(n);Vt(o,{});var r=W(o,2),c=O(r);at(c,()=>e.children),I(r),I(n),Ze(4),I(t),T(i,t),Oe()}export{qt as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.