@reqvire-org/reqvire 1.0.0 → 1.2.0

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.
Files changed (32) hide show
  1. package/artifacts/reqvire-darwin-arm64.tar.gz +0 -0
  2. package/artifacts/reqvire-darwin-x86_64.tar.gz +0 -0
  3. package/artifacts/reqvire-linux-x86_64.tar.gz +0 -0
  4. package/explorer-dist/assets/explorer-architectureDiagram-3BPJPVTR.js +1 -1
  5. package/explorer-dist/assets/explorer-blockDiagram-GPEHLZMM.js +4 -4
  6. package/explorer-dist/assets/explorer-chunk-727SXJPM.js +1 -1
  7. package/explorer-dist/assets/explorer-chunk-AQP2D5EJ.js +1 -1
  8. package/explorer-dist/assets/explorer-cose-bilkent-S5V4N54A.js +1 -1
  9. package/explorer-dist/assets/explorer-dagre-BM42HDAG.js +1 -1
  10. package/explorer-dist/assets/explorer-defaultLocale.js +1 -0
  11. package/explorer-dist/assets/explorer-diagram-2AECGRRQ.js +1 -1
  12. package/explorer-dist/assets/explorer-diagram-KO2AKTUF.js +1 -1
  13. package/explorer-dist/assets/explorer-diagram-OG6HWLK6.js +4 -4
  14. package/explorer-dist/assets/explorer-ganttDiagram-6RSMTGT7.js +7 -7
  15. package/explorer-dist/assets/explorer-ishikawaDiagram-YF4QCWOH.js +1 -1
  16. package/explorer-dist/assets/explorer-kanban-definition-UN3LZRKU.js +1 -1
  17. package/explorer-dist/assets/explorer-linear.js +1 -0
  18. package/explorer-dist/assets/explorer-mermaid.core.js +123 -123
  19. package/explorer-dist/assets/explorer-mindmap-definition-RKZ34NQL.js +1 -1
  20. package/explorer-dist/assets/explorer-pieDiagram-4H26LBE5.js +3 -3
  21. package/explorer-dist/assets/explorer-quadrantDiagram-W4KKPZXB.js +2 -2
  22. package/explorer-dist/assets/explorer-sankeyDiagram-5OEKKPKP.js +13 -13
  23. package/explorer-dist/assets/explorer-sequenceDiagram-3UESZ5HK.js +1 -1
  24. package/explorer-dist/assets/explorer-stateDiagram-AJRCARHV.js +1 -1
  25. package/explorer-dist/assets/explorer-timeline-definition-PNZ67QCA.js +1 -1
  26. package/explorer-dist/assets/explorer-vennDiagram-CIIHVFJN.js +5 -5
  27. package/explorer-dist/assets/explorer-wardleyDiagram-YWT4CUSO.js +1 -1
  28. package/explorer-dist/assets/explorer-xychartDiagram-2RQKCTM6.js +7 -7
  29. package/explorer-dist/assets/explorer.css +1 -1
  30. package/explorer-dist/assets/explorer.js +157 -132
  31. package/explorer-dist/assets/{searchIndex.worker-BWOUMmPT.js → searchIndex.worker-5M-mJr2P.js} +1 -1
  32. package/package.json +1 -1
@@ -1 +1 @@
1
- (function(){"use strict";const et="ENTRIES",W="KEYS",J="VALUES";class M{constructor(t,e){const s=t._tree,i=Array.from(s.keys());this.set=t,this._type=e,this._path=i.length>0?[{node:s,keys:i}]:[]}next(){const t=this.dive();return this.backtrack(),t}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:t,keys:e}=F(this._path);if(F(e)==="")return{done:!1,value:this.result()};const s=t.get(F(e));return this._path.push({node:s,keys:Array.from(s.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const t=F(this._path).keys;t.pop(),!(t.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:t})=>F(t)).filter(t=>t!=="").join("")}value(){return F(this._path).node.get("")}result(){switch(this._type){case J:return this.value();case W:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const F=n=>n[n.length-1],st=(n,t,e)=>{const s=new Map;if(t===void 0)return s;const i=t.length+1,o=i+e,c=new Uint8Array(o*i).fill(e+1);for(let r=0;r<i;++r)c[r]=r;for(let r=1;r<o;++r)c[r*i]=r;return q(n,t,e,s,c,1,i,""),s},q=(n,t,e,s,i,o,c,r)=>{const d=o*c;t:for(const u of n.keys())if(u===""){const a=i[d-1];a<=e&&s.set(r,[n.get(u),a])}else{let a=o;for(let l=0;l<u.length;++l,++a){const h=u[l],f=c*a,_=f-c;let g=i[f];const m=Math.max(0,a-e-1),p=Math.min(c-1,a+e);for(let w=m;w<p;++w){const R=h!==t[w],$=i[_+w]+ +R,k=i[_+w+1]+1,z=i[f+w]+1,x=i[f+w+1]=Math.min($,k,z);x<g&&(g=x)}if(g>e)continue t}q(n.get(u),t,e,s,i,a,c,r+u)}};class y{constructor(t=new Map,e=""){this._size=void 0,this._tree=t,this._prefix=e}atPrefix(t){if(!t.startsWith(this._prefix))throw new Error("Mismatched prefix");const[e,s]=S(this._tree,t.slice(this._prefix.length));if(e===void 0){const[i,o]=E(s);for(const c of i.keys())if(c!==""&&c.startsWith(o)){const r=new Map;return r.set(c.slice(o.length),i.get(c)),new y(r,t)}}return new y(e,t)}clear(){this._size=void 0,this._tree.clear()}delete(t){return this._size=void 0,nt(this._tree,t)}entries(){return new M(this,et)}forEach(t){for(const[e,s]of this)t(e,s,this)}fuzzyGet(t,e){return st(this._tree,t,e)}get(t){const e=T(this._tree,t);return e!==void 0?e.get(""):void 0}has(t){const e=T(this._tree,t);return e!==void 0&&e.has("")}keys(){return new M(this,W)}set(t,e){if(typeof t!="string")throw new Error("key must be a string");return this._size=void 0,C(this._tree,t).set("",e),this}get size(){if(this._size)return this._size;this._size=0;const t=this.entries();for(;!t.next().done;)this._size+=1;return this._size}update(t,e){if(typeof t!="string")throw new Error("key must be a string");this._size=void 0;const s=C(this._tree,t);return s.set("",e(s.get(""))),this}fetch(t,e){if(typeof t!="string")throw new Error("key must be a string");this._size=void 0;const s=C(this._tree,t);let i=s.get("");return i===void 0&&s.set("",i=e()),i}values(){return new M(this,J)}[Symbol.iterator](){return this.entries()}static from(t){const e=new y;for(const[s,i]of t)e.set(s,i);return e}static fromObject(t){return y.from(Object.entries(t))}}const S=(n,t,e=[])=>{if(t.length===0||n==null)return[n,e];for(const s of n.keys())if(s!==""&&t.startsWith(s))return e.push([n,s]),S(n.get(s),t.slice(s.length),e);return e.push([n,t]),S(void 0,"",e)},T=(n,t)=>{if(t.length===0||n==null)return n;for(const e of n.keys())if(e!==""&&t.startsWith(e))return T(n.get(e),t.slice(e.length))},C=(n,t)=>{const e=t.length;t:for(let s=0;n&&s<e;){for(const o of n.keys())if(o!==""&&t[s]===o[0]){const c=Math.min(e-s,o.length);let r=1;for(;r<c&&t[s+r]===o[r];)++r;const d=n.get(o);if(r===o.length)n=d;else{const u=new Map;u.set(o.slice(r),d),n.set(t.slice(s,s+r),u),n.delete(o),n=u}s+=r;continue t}const i=new Map;return n.set(t.slice(s),i),i}return n},nt=(n,t)=>{const[e,s]=S(n,t);if(e!==void 0){if(e.delete(""),e.size===0)K(s);else if(e.size===1){const[i,o]=e.entries().next().value;Q(s,i,o)}}},K=n=>{if(n.length===0)return;const[t,e]=E(n);if(t.delete(e),t.size===0)K(n.slice(0,-1));else if(t.size===1){const[s,i]=t.entries().next().value;s!==""&&Q(n.slice(0,-1),s,i)}},Q=(n,t,e)=>{if(n.length===0)return;const[s,i]=E(n);s.set(i+t,e),s.delete(i)},E=n=>n[n.length-1],A="or",U="and",it="and_not";class I{constructor(t){if((t==null?void 0:t.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');const e=t.autoVacuum==null||t.autoVacuum===!0?N:t.autoVacuum;this._options={...O,...t,autoVacuum:e,searchOptions:{...B,...t.searchOptions||{}},autoSuggestOptions:{...ut,...t.autoSuggestOptions||{}}},this._index=new y,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=j,this.addFields(this._options.fields)}add(t){const{extractField:e,stringifyField:s,tokenize:i,processTerm:o,fields:c,idField:r}=this._options,d=e(t,r);if(d==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);if(this._idToShortId.has(d))throw new Error(`MiniSearch: duplicate ID ${d}`);const u=this.addDocumentId(d);this.saveStoredFields(u,t);for(const a of c){const l=e(t,a);if(l==null)continue;const h=i(s(l,a),a),f=this._fieldIds[a],_=new Set(h).size;this.addFieldLength(u,f,this._documentCount-1,_);for(const g of h){const m=o(g,a);if(Array.isArray(m))for(const p of m)this.addTerm(f,u,p);else m&&this.addTerm(f,u,m)}}}addAll(t){for(const e of t)this.add(e)}addAllAsync(t,e={}){const{chunkSize:s=10}=e,i={chunk:[],promise:Promise.resolve()},{chunk:o,promise:c}=t.reduce(({chunk:r,promise:d},u,a)=>(r.push(u),(a+1)%s===0?{chunk:[],promise:d.then(()=>new Promise(l=>setTimeout(l,0))).then(()=>this.addAll(r))}:{chunk:r,promise:d}),i);return c.then(()=>this.addAll(o))}remove(t){const{tokenize:e,processTerm:s,extractField:i,stringifyField:o,fields:c,idField:r}=this._options,d=i(t,r);if(d==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);const u=this._idToShortId.get(d);if(u==null)throw new Error(`MiniSearch: cannot remove document with ID ${d}: it is not in the index`);for(const a of c){const l=i(t,a);if(l==null)continue;const h=e(o(l,a),a),f=this._fieldIds[a],_=new Set(h).size;this.removeFieldLength(u,f,this._documentCount,_);for(const g of h){const m=s(g,a);if(Array.isArray(m))for(const p of m)this.removeTerm(f,u,p);else m&&this.removeTerm(f,u,m)}}this._storedFields.delete(u),this._documentIds.delete(u),this._idToShortId.delete(d),this._fieldLength.delete(u),this._documentCount-=1}removeAll(t){if(t)for(const e of t)this.remove(e);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new y,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(t){const e=this._idToShortId.get(t);if(e==null)throw new Error(`MiniSearch: cannot discard document with ID ${t}: it is not in the index`);this._idToShortId.delete(t),this._documentIds.delete(e),this._storedFields.delete(e),(this._fieldLength.get(e)||[]).forEach((s,i)=>{this.removeFieldLength(e,i,this._documentCount,s)}),this._fieldLength.delete(e),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:t,minDirtCount:e,batchSize:s,batchWait:i}=this._options.autoVacuum;this.conditionalVacuum({batchSize:s,batchWait:i},{minDirtCount:e,minDirtFactor:t})}discardAll(t){const e=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const s of t)this.discard(s)}finally{this._options.autoVacuum=e}this.maybeAutoVacuum()}replace(t){const{idField:e,extractField:s}=this._options,i=s(t,e);this.discard(i),this.add(t)}vacuum(t={}){return this.conditionalVacuum(t)}conditionalVacuum(t,e){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&e,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const s=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=j,this.performVacuuming(t,s)}),this._enqueuedVacuum)):this.vacuumConditionsMet(e)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(t),this._currentVacuum)}async performVacuuming(t,e){const s=this._dirtCount;if(this.vacuumConditionsMet(e)){const i=t.batchSize||D.batchSize,o=t.batchWait||D.batchWait;let c=1;for(const[r,d]of this._index){for(const[u,a]of d)for(const[l]of a)this._documentIds.has(l)||(a.size<=1?d.delete(u):a.delete(l));this._index.get(r).size===0&&this._index.delete(r),c%i===0&&await new Promise(u=>setTimeout(u,o)),c+=1}this._dirtCount-=s}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(t){if(t==null)return!0;let{minDirtCount:e,minDirtFactor:s}=t;return e=e||N.minDirtCount,s=s||N.minDirtFactor,this.dirtCount>=e&&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(t){return this._idToShortId.has(t)}getStoredFields(t){const e=this._idToShortId.get(t);if(e!=null)return this._storedFields.get(e)}search(t,e={}){const{searchOptions:s}=this._options,i={...s,...e},o=this.executeQuery(t,e),c=[];for(const[r,{score:d,terms:u,match:a}]of o){const l=u.length||1,h={id:this._documentIds.get(r),score:d*l,terms:Object.keys(a),queryTerms:u,match:a};Object.assign(h,this._storedFields.get(r)),(i.filter==null||i.filter(h))&&c.push(h)}return t===I.wildcard&&i.boostDocument==null||c.sort(Y),c}autoSuggest(t,e={}){e={...this._options.autoSuggestOptions,...e};const s=new Map;for(const{score:o,terms:c}of this.search(t,e)){const r=c.join(" "),d=s.get(r);d!=null?(d.score+=o,d.count+=1):s.set(r,{score:o,terms:c,count:1})}const i=[];for(const[o,{score:c,terms:r,count:d}]of s)i.push({suggestion:o,terms:r,score:c/d});return i.sort(Y),i}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(t,e){if(e==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(t),e)}static async loadJSONAsync(t,e){if(e==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(t),e)}static getDefault(t){if(O.hasOwnProperty(t))return V(O,t);throw new Error(`MiniSearch: unknown option "${t}"`)}static loadJS(t,e){const{index:s,documentIds:i,fieldLength:o,storedFields:c,serializationVersion:r}=t,d=this.instantiateMiniSearch(t,e);d._documentIds=L(i),d._fieldLength=L(o),d._storedFields=L(c);for(const[u,a]of d._documentIds)d._idToShortId.set(a,u);for(const[u,a]of s){const l=new Map;for(const h of Object.keys(a)){let f=a[h];r===1&&(f=f.ds),l.set(parseInt(h,10),L(f))}d._index.set(u,l)}return d}static async loadJSAsync(t,e){const{index:s,documentIds:i,fieldLength:o,storedFields:c,serializationVersion:r}=t,d=this.instantiateMiniSearch(t,e);d._documentIds=await b(i),d._fieldLength=await b(o),d._storedFields=await b(c);for(const[a,l]of d._documentIds)d._idToShortId.set(l,a);let u=0;for(const[a,l]of s){const h=new Map;for(const f of Object.keys(l)){let _=l[f];r===1&&(_=_.ds),h.set(parseInt(f,10),await b(_))}++u%1e3===0&&await H(0),d._index.set(a,h)}return d}static instantiateMiniSearch(t,e){const{documentCount:s,nextId:i,fieldIds:o,averageFieldLength:c,dirtCount:r,serializationVersion:d}=t;if(d!==1&&d!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const u=new I(e);return u._documentCount=s,u._nextId=i,u._idToShortId=new Map,u._fieldIds=o,u._avgFieldLength=c,u._dirtCount=r||0,u._index=new y,u}executeQuery(t,e={}){if(t===I.wildcard)return this.executeWildcardQuery(e);if(typeof t!="string"){const h={...e,...t,queries:void 0},f=t.queries.map(_=>this.executeQuery(_,h));return this.combineResults(f,h.combineWith)}const{tokenize:s,processTerm:i,searchOptions:o}=this._options,c={tokenize:s,processTerm:i,...o,...e},{tokenize:r,processTerm:d}=c,l=r(t).flatMap(h=>d(h)).filter(h=>!!h).map(dt(c)).map(h=>this.executeQuerySpec(h,c));return this.combineResults(l,c.combineWith)}executeQuerySpec(t,e){const s={...this._options.searchOptions,...e},i=(s.fields||this._options.fields).reduce((g,m)=>({...g,[m]:V(s.boost,m)||1}),{}),{boostDocument:o,weights:c,maxFuzzy:r,bm25:d}=s,{fuzzy:u,prefix:a}={...B.weights,...c},l=this._index.get(t.term),h=this.termResults(t.term,t.term,1,t.termBoost,l,i,o,d);let f,_;if(t.prefix&&(f=this._index.atPrefix(t.term)),t.fuzzy){const g=t.fuzzy===!0?.2:t.fuzzy,m=g<1?Math.min(r,Math.round(t.term.length*g)):g;m&&(_=this._index.fuzzyGet(t.term,m))}if(f)for(const[g,m]of f){const p=g.length-t.term.length;if(!p)continue;_==null||_.delete(g);const w=a*g.length/(g.length+.3*p);this.termResults(t.term,g,w,t.termBoost,m,i,o,d,h)}if(_)for(const g of _.keys()){const[m,p]=_.get(g);if(!p)continue;const w=u*g.length/(g.length+p);this.termResults(t.term,g,w,t.termBoost,m,i,o,d,h)}return h}executeWildcardQuery(t){const e=new Map,s={...this._options.searchOptions,...t};for(const[i,o]of this._documentIds){const c=s.boostDocument?s.boostDocument(o,"",this._storedFields.get(i)):1;e.set(i,{score:c,terms:[],match:{}})}return e}combineResults(t,e=A){if(t.length===0)return new Map;const s=e.toLowerCase(),i=ot[s];if(!i)throw new Error(`Invalid combination operator: ${e}`);return t.reduce(i)||new Map}toJSON(){const t=[];for(const[e,s]of this._index){const i={};for(const[o,c]of s)i[o]=Object.fromEntries(c);t.push([e,i])}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:t,serializationVersion:2}}termResults(t,e,s,i,o,c,r,d,u=new Map){if(o==null)return u;for(const a of Object.keys(c)){const l=c[a],h=this._fieldIds[a],f=o.get(h);if(f==null)continue;let _=f.size;const g=this._avgFieldLength[h];for(const m of f.keys()){if(!this._documentIds.has(m)){this.removeTerm(h,m,e),_-=1;continue}const p=r?r(this._documentIds.get(m),e,this._storedFields.get(m)):1;if(!p)continue;const w=f.get(m),R=this._fieldLength.get(m)[h],$=ct(w,_,this._documentCount,R,g,d),k=s*i*l*p*$,z=u.get(m);if(z){z.score+=k,at(z.terms,t);const x=V(z.match,e);x?x.push(a):z.match[e]=[a]}else u.set(m,{score:k,terms:[t],match:{[e]:[a]}})}}return u}addTerm(t,e,s){const i=this._index.fetch(s,G);let o=i.get(t);if(o==null)o=new Map,o.set(e,1),i.set(t,o);else{const c=o.get(e);o.set(e,(c||0)+1)}}removeTerm(t,e,s){if(!this._index.has(s)){this.warnDocumentChanged(e,t,s);return}const i=this._index.fetch(s,G),o=i.get(t);o==null||o.get(e)==null?this.warnDocumentChanged(e,t,s):o.get(e)<=1?o.size<=1?i.delete(t):o.delete(e):o.set(e,o.get(e)-1),this._index.get(s).size===0&&this._index.delete(s)}warnDocumentChanged(t,e,s){for(const i of Object.keys(this._fieldIds))if(this._fieldIds[i]===e){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(t)} has changed before removal: term "${s}" was not present in field "${i}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(t){const e=this._nextId;return this._idToShortId.set(t,e),this._documentIds.set(e,t),this._documentCount+=1,this._nextId+=1,e}addFields(t){for(let e=0;e<t.length;e++)this._fieldIds[t[e]]=e}addFieldLength(t,e,s,i){let o=this._fieldLength.get(t);o==null&&this._fieldLength.set(t,o=[]),o[e]=i;const r=(this._avgFieldLength[e]||0)*s+i;this._avgFieldLength[e]=r/(s+1)}removeFieldLength(t,e,s,i){if(s===1){this._avgFieldLength[e]=0;return}const o=this._avgFieldLength[e]*s-i;this._avgFieldLength[e]=o/(s-1)}saveStoredFields(t,e){const{storeFields:s,extractField:i}=this._options;if(s==null||s.length===0)return;let o=this._storedFields.get(t);o==null&&this._storedFields.set(t,o={});for(const c of s){const r=i(e,c);r!==void 0&&(o[c]=r)}}}I.wildcard=Symbol("*");const V=(n,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,ot={[A]:(n,t)=>{for(const e of t.keys()){const s=n.get(e);if(s==null)n.set(e,t.get(e));else{const{score:i,terms:o,match:c}=t.get(e);s.score=s.score+i,s.match=Object.assign(s.match,c),Z(s.terms,o)}}return n},[U]:(n,t)=>{const e=new Map;for(const s of t.keys()){const i=n.get(s);if(i==null)continue;const{score:o,terms:c,match:r}=t.get(s);Z(i.terms,c),e.set(s,{score:i.score+o,terms:i.terms,match:Object.assign(i.match,r)})}return e},[it]:(n,t)=>{for(const e of t.keys())n.delete(e);return n}},rt={k:1.2,b:.7,d:.5},ct=(n,t,e,s,i,o)=>{const{k:c,b:r,d}=o;return Math.log(1+(e-t+.5)/(t+.5))*(d+n*(c+1)/(n+c*(1-r+r*s/i)))},dt=n=>(t,e,s)=>{const i=typeof n.fuzzy=="function"?n.fuzzy(t,e,s):n.fuzzy||!1,o=typeof n.prefix=="function"?n.prefix(t,e,s):n.prefix===!0,c=typeof n.boostTerm=="function"?n.boostTerm(t,e,s):1;return{term:t,fuzzy:i,prefix:o,termBoost:c}},O={idField:"id",extractField:(n,t)=>n[t],stringifyField:(n,t)=>n.toString(),tokenize:n=>n.split(ht),processTerm:n=>n.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(n,t)=>{typeof(console==null?void 0:console[n])=="function"&&console[n](t)},autoVacuum:!0},B={combineWith:A,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:rt},ut={combineWith:U,prefix:(n,t,e)=>t===e.length-1},D={batchSize:1e3,batchWait:10},j={minDirtFactor:.1,minDirtCount:20},N={...D,...j},at=(n,t)=>{n.includes(t)||n.push(t)},Z=(n,t)=>{for(const e of t)n.includes(e)||n.push(e)},Y=({score:n},{score:t})=>t-n,G=()=>new Map,L=n=>{const t=new Map;for(const e of Object.keys(n))t.set(parseInt(e,10),n[e]);return t},b=async n=>{const t=new Map;let e=0;for(const s of Object.keys(n))t.set(parseInt(s,10),n[s]),++e%1e3===0&&await H(0);return t},H=n=>new Promise(t=>setTimeout(t,n)),ht=/[\n\r\p{Z}\p{P}]+/u,lt=50,ft=100;function mt(n){const t=n.map((s,i)=>({...s,searchId:`${s.displayKind}:${s.kind}:${s.id}:${i}`,pathText:pt(s),ordinal:i})),e=new I({idField:"searchId",fields:["title","pathText","displayKind","text"],storeFields:["id","kind","title","route","text","displayKind","elementType","pathText","ordinal"],searchOptions:{boost:{title:7,pathText:4,displayKind:2,text:1},prefix:!0,fuzzy:.18},tokenize:_t,processTerm:s=>s.toLowerCase()});return e.addAll(t),{index:e,documents:t}}function gt(n,t,e,s=new Set){const i=r=>{const d=yt(r.displayKind);return d&&!e.has(d)?!1:d==="element"&&s.size>0?!!(r.elementType&&s.has(r.elementType)):!0},o=t.trim();return o?n.index.search(o,{filter:r=>i(r)}).sort((r,d)=>wt(r,d,o)).slice(0,ft).map(tt):n.documents.filter(i).slice(0,lt).map(tt)}function _t(n){return n.replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(t=>t.trim().toLowerCase()).filter(Boolean)}function pt(n){return[n.id,n.route,n.route.replace(/^#\/(?:content|elements|resources)\//,"")].join(" ")}function wt(n,t,e){const s=X(n,e),i=X(t,e);return s!==i?i-s:n.ordinal-t.ordinal}function X(n,t){const e=t.toLowerCase(),s=n.title.toLowerCase(),i=n.pathText.toLowerCase();let o=Number(n.score??0);return s===e&&(o+=50),s.startsWith(e)&&(o+=25),s.includes(e)&&(o+=15),i.includes(e)&&(o+=6),o}function tt(n){return{id:n.id,kind:n.kind,title:n.title,route:n.route,text:n.text}}function yt(n){const t=n.toLowerCase();return t==="element"||t==="file"||t==="resource"||t==="ontology"?t:null}let P=null;self.onmessage=n=>{try{const t=n.data;if(t.type==="build"){P=mt(t.documents),v({type:"ready",documentCount:t.documents.length});return}if(!P){v({type:"error",requestId:t.requestId,message:"Search index is not ready."});return}const e=gt(P,t.query,new Set(t.enabledKinds),new Set(t.enabledElementTypes));v({type:"results",requestId:t.requestId,results:e})}catch(t){v({type:"error",requestId:n.data.type==="search"?n.data.requestId:void 0,message:t instanceof Error?t.message:String(t)})}};function v(n){self.postMessage(n)}})();
1
+ (function(){"use strict";const et="ENTRIES",$="KEYS",J="VALUES";class M{constructor(t,e){const s=t._tree,i=Array.from(s.keys());this.set=t,this._type=e,this._path=i.length>0?[{node:s,keys:i}]:[]}next(){const t=this.dive();return this.backtrack(),t}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:t,keys:e}=F(this._path);if(F(e)==="")return{done:!1,value:this.result()};const s=t.get(F(e));return this._path.push({node:s,keys:Array.from(s.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const t=F(this._path).keys;t.pop(),!(t.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:t})=>F(t)).filter(t=>t!=="").join("")}value(){return F(this._path).node.get("")}result(){switch(this._type){case J:return this.value();case $:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const F=n=>n[n.length-1],st=(n,t,e)=>{const s=new Map;if(t===void 0)return s;const i=t.length+1,o=i+e,c=new Uint8Array(o*i).fill(e+1);for(let r=0;r<i;++r)c[r]=r;for(let r=1;r<o;++r)c[r*i]=r;return q(n,t,e,s,c,1,i,""),s},q=(n,t,e,s,i,o,c,r)=>{const d=o*c;t:for(const u of n.keys())if(u===""){const a=i[d-1];a<=e&&s.set(r,[n.get(u),a])}else{let a=o;for(let l=0;l<u.length;++l,++a){const h=u[l],f=c*a,_=f-c;let g=i[f];const m=Math.max(0,a-e-1),p=Math.min(c-1,a+e);for(let w=m;w<p;++w){const R=h!==t[w],W=i[_+w]+ +R,k=i[_+w+1]+1,z=i[f+w]+1,x=i[f+w+1]=Math.min(W,k,z);x<g&&(g=x)}if(g>e)continue t}q(n.get(u),t,e,s,i,a,c,r+u)}};class y{constructor(t=new Map,e=""){this._size=void 0,this._tree=t,this._prefix=e}atPrefix(t){if(!t.startsWith(this._prefix))throw new Error("Mismatched prefix");const[e,s]=S(this._tree,t.slice(this._prefix.length));if(e===void 0){const[i,o]=E(s);for(const c of i.keys())if(c!==""&&c.startsWith(o)){const r=new Map;return r.set(c.slice(o.length),i.get(c)),new y(r,t)}}return new y(e,t)}clear(){this._size=void 0,this._tree.clear()}delete(t){return this._size=void 0,nt(this._tree,t)}entries(){return new M(this,et)}forEach(t){for(const[e,s]of this)t(e,s,this)}fuzzyGet(t,e){return st(this._tree,t,e)}get(t){const e=T(this._tree,t);return e!==void 0?e.get(""):void 0}has(t){const e=T(this._tree,t);return e!==void 0&&e.has("")}keys(){return new M(this,$)}set(t,e){if(typeof t!="string")throw new Error("key must be a string");return this._size=void 0,C(this._tree,t).set("",e),this}get size(){if(this._size)return this._size;this._size=0;const t=this.entries();for(;!t.next().done;)this._size+=1;return this._size}update(t,e){if(typeof t!="string")throw new Error("key must be a string");this._size=void 0;const s=C(this._tree,t);return s.set("",e(s.get(""))),this}fetch(t,e){if(typeof t!="string")throw new Error("key must be a string");this._size=void 0;const s=C(this._tree,t);let i=s.get("");return i===void 0&&s.set("",i=e()),i}values(){return new M(this,J)}[Symbol.iterator](){return this.entries()}static from(t){const e=new y;for(const[s,i]of t)e.set(s,i);return e}static fromObject(t){return y.from(Object.entries(t))}}const S=(n,t,e=[])=>{if(t.length===0||n==null)return[n,e];for(const s of n.keys())if(s!==""&&t.startsWith(s))return e.push([n,s]),S(n.get(s),t.slice(s.length),e);return e.push([n,t]),S(void 0,"",e)},T=(n,t)=>{if(t.length===0||n==null)return n;for(const e of n.keys())if(e!==""&&t.startsWith(e))return T(n.get(e),t.slice(e.length))},C=(n,t)=>{const e=t.length;t:for(let s=0;n&&s<e;){for(const o of n.keys())if(o!==""&&t[s]===o[0]){const c=Math.min(e-s,o.length);let r=1;for(;r<c&&t[s+r]===o[r];)++r;const d=n.get(o);if(r===o.length)n=d;else{const u=new Map;u.set(o.slice(r),d),n.set(t.slice(s,s+r),u),n.delete(o),n=u}s+=r;continue t}const i=new Map;return n.set(t.slice(s),i),i}return n},nt=(n,t)=>{const[e,s]=S(n,t);if(e!==void 0){if(e.delete(""),e.size===0)K(s);else if(e.size===1){const[i,o]=e.entries().next().value;Q(s,i,o)}}},K=n=>{if(n.length===0)return;const[t,e]=E(n);if(t.delete(e),t.size===0)K(n.slice(0,-1));else if(t.size===1){const[s,i]=t.entries().next().value;s!==""&&Q(n.slice(0,-1),s,i)}},Q=(n,t,e)=>{if(n.length===0)return;const[s,i]=E(n);s.set(i+t,e),s.delete(i)},E=n=>n[n.length-1],A="or",U="and",it="and_not";class I{constructor(t){if((t==null?void 0:t.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');const e=t.autoVacuum==null||t.autoVacuum===!0?N:t.autoVacuum;this._options={...O,...t,autoVacuum:e,searchOptions:{...B,...t.searchOptions||{}},autoSuggestOptions:{...ut,...t.autoSuggestOptions||{}}},this._index=new y,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=j,this.addFields(this._options.fields)}add(t){const{extractField:e,stringifyField:s,tokenize:i,processTerm:o,fields:c,idField:r}=this._options,d=e(t,r);if(d==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);if(this._idToShortId.has(d))throw new Error(`MiniSearch: duplicate ID ${d}`);const u=this.addDocumentId(d);this.saveStoredFields(u,t);for(const a of c){const l=e(t,a);if(l==null)continue;const h=i(s(l,a),a),f=this._fieldIds[a],_=new Set(h).size;this.addFieldLength(u,f,this._documentCount-1,_);for(const g of h){const m=o(g,a);if(Array.isArray(m))for(const p of m)this.addTerm(f,u,p);else m&&this.addTerm(f,u,m)}}}addAll(t){for(const e of t)this.add(e)}addAllAsync(t,e={}){const{chunkSize:s=10}=e,i={chunk:[],promise:Promise.resolve()},{chunk:o,promise:c}=t.reduce(({chunk:r,promise:d},u,a)=>(r.push(u),(a+1)%s===0?{chunk:[],promise:d.then(()=>new Promise(l=>setTimeout(l,0))).then(()=>this.addAll(r))}:{chunk:r,promise:d}),i);return c.then(()=>this.addAll(o))}remove(t){const{tokenize:e,processTerm:s,extractField:i,stringifyField:o,fields:c,idField:r}=this._options,d=i(t,r);if(d==null)throw new Error(`MiniSearch: document does not have ID field "${r}"`);const u=this._idToShortId.get(d);if(u==null)throw new Error(`MiniSearch: cannot remove document with ID ${d}: it is not in the index`);for(const a of c){const l=i(t,a);if(l==null)continue;const h=e(o(l,a),a),f=this._fieldIds[a],_=new Set(h).size;this.removeFieldLength(u,f,this._documentCount,_);for(const g of h){const m=s(g,a);if(Array.isArray(m))for(const p of m)this.removeTerm(f,u,p);else m&&this.removeTerm(f,u,m)}}this._storedFields.delete(u),this._documentIds.delete(u),this._idToShortId.delete(d),this._fieldLength.delete(u),this._documentCount-=1}removeAll(t){if(t)for(const e of t)this.remove(e);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new y,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(t){const e=this._idToShortId.get(t);if(e==null)throw new Error(`MiniSearch: cannot discard document with ID ${t}: it is not in the index`);this._idToShortId.delete(t),this._documentIds.delete(e),this._storedFields.delete(e),(this._fieldLength.get(e)||[]).forEach((s,i)=>{this.removeFieldLength(e,i,this._documentCount,s)}),this._fieldLength.delete(e),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:t,minDirtCount:e,batchSize:s,batchWait:i}=this._options.autoVacuum;this.conditionalVacuum({batchSize:s,batchWait:i},{minDirtCount:e,minDirtFactor:t})}discardAll(t){const e=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const s of t)this.discard(s)}finally{this._options.autoVacuum=e}this.maybeAutoVacuum()}replace(t){const{idField:e,extractField:s}=this._options,i=s(t,e);this.discard(i),this.add(t)}vacuum(t={}){return this.conditionalVacuum(t)}conditionalVacuum(t,e){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&e,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const s=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=j,this.performVacuuming(t,s)}),this._enqueuedVacuum)):this.vacuumConditionsMet(e)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(t),this._currentVacuum)}async performVacuuming(t,e){const s=this._dirtCount;if(this.vacuumConditionsMet(e)){const i=t.batchSize||D.batchSize,o=t.batchWait||D.batchWait;let c=1;for(const[r,d]of this._index){for(const[u,a]of d)for(const[l]of a)this._documentIds.has(l)||(a.size<=1?d.delete(u):a.delete(l));this._index.get(r).size===0&&this._index.delete(r),c%i===0&&await new Promise(u=>setTimeout(u,o)),c+=1}this._dirtCount-=s}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(t){if(t==null)return!0;let{minDirtCount:e,minDirtFactor:s}=t;return e=e||N.minDirtCount,s=s||N.minDirtFactor,this.dirtCount>=e&&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(t){return this._idToShortId.has(t)}getStoredFields(t){const e=this._idToShortId.get(t);if(e!=null)return this._storedFields.get(e)}search(t,e={}){const{searchOptions:s}=this._options,i={...s,...e},o=this.executeQuery(t,e),c=[];for(const[r,{score:d,terms:u,match:a}]of o){const l=u.length||1,h={id:this._documentIds.get(r),score:d*l,terms:Object.keys(a),queryTerms:u,match:a};Object.assign(h,this._storedFields.get(r)),(i.filter==null||i.filter(h))&&c.push(h)}return t===I.wildcard&&i.boostDocument==null||c.sort(Y),c}autoSuggest(t,e={}){e={...this._options.autoSuggestOptions,...e};const s=new Map;for(const{score:o,terms:c}of this.search(t,e)){const r=c.join(" "),d=s.get(r);d!=null?(d.score+=o,d.count+=1):s.set(r,{score:o,terms:c,count:1})}const i=[];for(const[o,{score:c,terms:r,count:d}]of s)i.push({suggestion:o,terms:r,score:c/d});return i.sort(Y),i}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(t,e){if(e==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(t),e)}static async loadJSONAsync(t,e){if(e==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(t),e)}static getDefault(t){if(O.hasOwnProperty(t))return V(O,t);throw new Error(`MiniSearch: unknown option "${t}"`)}static loadJS(t,e){const{index:s,documentIds:i,fieldLength:o,storedFields:c,serializationVersion:r}=t,d=this.instantiateMiniSearch(t,e);d._documentIds=L(i),d._fieldLength=L(o),d._storedFields=L(c);for(const[u,a]of d._documentIds)d._idToShortId.set(a,u);for(const[u,a]of s){const l=new Map;for(const h of Object.keys(a)){let f=a[h];r===1&&(f=f.ds),l.set(parseInt(h,10),L(f))}d._index.set(u,l)}return d}static async loadJSAsync(t,e){const{index:s,documentIds:i,fieldLength:o,storedFields:c,serializationVersion:r}=t,d=this.instantiateMiniSearch(t,e);d._documentIds=await b(i),d._fieldLength=await b(o),d._storedFields=await b(c);for(const[a,l]of d._documentIds)d._idToShortId.set(l,a);let u=0;for(const[a,l]of s){const h=new Map;for(const f of Object.keys(l)){let _=l[f];r===1&&(_=_.ds),h.set(parseInt(f,10),await b(_))}++u%1e3===0&&await H(0),d._index.set(a,h)}return d}static instantiateMiniSearch(t,e){const{documentCount:s,nextId:i,fieldIds:o,averageFieldLength:c,dirtCount:r,serializationVersion:d}=t;if(d!==1&&d!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const u=new I(e);return u._documentCount=s,u._nextId=i,u._idToShortId=new Map,u._fieldIds=o,u._avgFieldLength=c,u._dirtCount=r||0,u._index=new y,u}executeQuery(t,e={}){if(t===I.wildcard)return this.executeWildcardQuery(e);if(typeof t!="string"){const h={...e,...t,queries:void 0},f=t.queries.map(_=>this.executeQuery(_,h));return this.combineResults(f,h.combineWith)}const{tokenize:s,processTerm:i,searchOptions:o}=this._options,c={tokenize:s,processTerm:i,...o,...e},{tokenize:r,processTerm:d}=c,l=r(t).flatMap(h=>d(h)).filter(h=>!!h).map(dt(c)).map(h=>this.executeQuerySpec(h,c));return this.combineResults(l,c.combineWith)}executeQuerySpec(t,e){const s={...this._options.searchOptions,...e},i=(s.fields||this._options.fields).reduce((g,m)=>({...g,[m]:V(s.boost,m)||1}),{}),{boostDocument:o,weights:c,maxFuzzy:r,bm25:d}=s,{fuzzy:u,prefix:a}={...B.weights,...c},l=this._index.get(t.term),h=this.termResults(t.term,t.term,1,t.termBoost,l,i,o,d);let f,_;if(t.prefix&&(f=this._index.atPrefix(t.term)),t.fuzzy){const g=t.fuzzy===!0?.2:t.fuzzy,m=g<1?Math.min(r,Math.round(t.term.length*g)):g;m&&(_=this._index.fuzzyGet(t.term,m))}if(f)for(const[g,m]of f){const p=g.length-t.term.length;if(!p)continue;_==null||_.delete(g);const w=a*g.length/(g.length+.3*p);this.termResults(t.term,g,w,t.termBoost,m,i,o,d,h)}if(_)for(const g of _.keys()){const[m,p]=_.get(g);if(!p)continue;const w=u*g.length/(g.length+p);this.termResults(t.term,g,w,t.termBoost,m,i,o,d,h)}return h}executeWildcardQuery(t){const e=new Map,s={...this._options.searchOptions,...t};for(const[i,o]of this._documentIds){const c=s.boostDocument?s.boostDocument(o,"",this._storedFields.get(i)):1;e.set(i,{score:c,terms:[],match:{}})}return e}combineResults(t,e=A){if(t.length===0)return new Map;const s=e.toLowerCase(),i=ot[s];if(!i)throw new Error(`Invalid combination operator: ${e}`);return t.reduce(i)||new Map}toJSON(){const t=[];for(const[e,s]of this._index){const i={};for(const[o,c]of s)i[o]=Object.fromEntries(c);t.push([e,i])}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:t,serializationVersion:2}}termResults(t,e,s,i,o,c,r,d,u=new Map){if(o==null)return u;for(const a of Object.keys(c)){const l=c[a],h=this._fieldIds[a],f=o.get(h);if(f==null)continue;let _=f.size;const g=this._avgFieldLength[h];for(const m of f.keys()){if(!this._documentIds.has(m)){this.removeTerm(h,m,e),_-=1;continue}const p=r?r(this._documentIds.get(m),e,this._storedFields.get(m)):1;if(!p)continue;const w=f.get(m),R=this._fieldLength.get(m)[h],W=ct(w,_,this._documentCount,R,g,d),k=s*i*l*p*W,z=u.get(m);if(z){z.score+=k,at(z.terms,t);const x=V(z.match,e);x?x.push(a):z.match[e]=[a]}else u.set(m,{score:k,terms:[t],match:{[e]:[a]}})}}return u}addTerm(t,e,s){const i=this._index.fetch(s,G);let o=i.get(t);if(o==null)o=new Map,o.set(e,1),i.set(t,o);else{const c=o.get(e);o.set(e,(c||0)+1)}}removeTerm(t,e,s){if(!this._index.has(s)){this.warnDocumentChanged(e,t,s);return}const i=this._index.fetch(s,G),o=i.get(t);o==null||o.get(e)==null?this.warnDocumentChanged(e,t,s):o.get(e)<=1?o.size<=1?i.delete(t):o.delete(e):o.set(e,o.get(e)-1),this._index.get(s).size===0&&this._index.delete(s)}warnDocumentChanged(t,e,s){for(const i of Object.keys(this._fieldIds))if(this._fieldIds[i]===e){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(t)} has changed before removal: term "${s}" was not present in field "${i}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(t){const e=this._nextId;return this._idToShortId.set(t,e),this._documentIds.set(e,t),this._documentCount+=1,this._nextId+=1,e}addFields(t){for(let e=0;e<t.length;e++)this._fieldIds[t[e]]=e}addFieldLength(t,e,s,i){let o=this._fieldLength.get(t);o==null&&this._fieldLength.set(t,o=[]),o[e]=i;const r=(this._avgFieldLength[e]||0)*s+i;this._avgFieldLength[e]=r/(s+1)}removeFieldLength(t,e,s,i){if(s===1){this._avgFieldLength[e]=0;return}const o=this._avgFieldLength[e]*s-i;this._avgFieldLength[e]=o/(s-1)}saveStoredFields(t,e){const{storeFields:s,extractField:i}=this._options;if(s==null||s.length===0)return;let o=this._storedFields.get(t);o==null&&this._storedFields.set(t,o={});for(const c of s){const r=i(e,c);r!==void 0&&(o[c]=r)}}}I.wildcard=Symbol("*");const V=(n,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,ot={[A]:(n,t)=>{for(const e of t.keys()){const s=n.get(e);if(s==null)n.set(e,t.get(e));else{const{score:i,terms:o,match:c}=t.get(e);s.score=s.score+i,s.match=Object.assign(s.match,c),Z(s.terms,o)}}return n},[U]:(n,t)=>{const e=new Map;for(const s of t.keys()){const i=n.get(s);if(i==null)continue;const{score:o,terms:c,match:r}=t.get(s);Z(i.terms,c),e.set(s,{score:i.score+o,terms:i.terms,match:Object.assign(i.match,r)})}return e},[it]:(n,t)=>{for(const e of t.keys())n.delete(e);return n}},rt={k:1.2,b:.7,d:.5},ct=(n,t,e,s,i,o)=>{const{k:c,b:r,d}=o;return Math.log(1+(e-t+.5)/(t+.5))*(d+n*(c+1)/(n+c*(1-r+r*s/i)))},dt=n=>(t,e,s)=>{const i=typeof n.fuzzy=="function"?n.fuzzy(t,e,s):n.fuzzy||!1,o=typeof n.prefix=="function"?n.prefix(t,e,s):n.prefix===!0,c=typeof n.boostTerm=="function"?n.boostTerm(t,e,s):1;return{term:t,fuzzy:i,prefix:o,termBoost:c}},O={idField:"id",extractField:(n,t)=>n[t],stringifyField:(n,t)=>n.toString(),tokenize:n=>n.split(ht),processTerm:n=>n.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(n,t)=>{typeof(console==null?void 0:console[n])=="function"&&console[n](t)},autoVacuum:!0},B={combineWith:A,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:rt},ut={combineWith:U,prefix:(n,t,e)=>t===e.length-1},D={batchSize:1e3,batchWait:10},j={minDirtFactor:.1,minDirtCount:20},N={...D,...j},at=(n,t)=>{n.includes(t)||n.push(t)},Z=(n,t)=>{for(const e of t)n.includes(e)||n.push(e)},Y=({score:n},{score:t})=>t-n,G=()=>new Map,L=n=>{const t=new Map;for(const e of Object.keys(n))t.set(parseInt(e,10),n[e]);return t},b=async n=>{const t=new Map;let e=0;for(const s of Object.keys(n))t.set(parseInt(s,10),n[s]),++e%1e3===0&&await H(0);return t},H=n=>new Promise(t=>setTimeout(t,n)),ht=/[\n\r\p{Z}\p{P}]+/u,lt=50,ft=100;function mt(n){const t=n.map((s,i)=>({...s,searchId:`${s.displayKind}:${s.kind}:${s.id}:${i}`,pathText:pt(s),ordinal:i})),e=new I({idField:"searchId",fields:["title","pathText","displayKind","text"],storeFields:["id","kind","title","route","text","displayKind","elementType","pathText","ordinal"],searchOptions:{boost:{title:7,pathText:4,displayKind:2,text:1},combineWith:"AND",prefix:!0,fuzzy:.18},tokenize:_t,processTerm:s=>s.toLowerCase()});return e.addAll(t),{index:e,documents:t}}function gt(n,t,e,s=new Set){const i=r=>{const d=yt(r.displayKind);return d&&!e.has(d)?!1:d==="element"&&s.size>0?!!(r.elementType&&s.has(r.elementType)):!0},o=t.trim();return o?n.index.search(o,{filter:r=>i(r)}).sort((r,d)=>wt(r,d,o)).slice(0,ft).map(tt):n.documents.filter(i).slice(0,lt).map(tt)}function _t(n){return n.replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).map(t=>t.trim().toLowerCase()).filter(Boolean)}function pt(n){return[n.id,n.route,n.route.replace(/^#\/(?:content|elements|resources)\//,"")].join(" ")}function wt(n,t,e){const s=X(n,e),i=X(t,e);return s!==i?i-s:n.ordinal-t.ordinal}function X(n,t){const e=t.toLowerCase(),s=n.title.toLowerCase(),i=n.pathText.toLowerCase();let o=Number(n.score??0);return s===e&&(o+=50),s.startsWith(e)&&(o+=25),s.includes(e)&&(o+=15),i.includes(e)&&(o+=6),o}function tt(n){return{id:n.id,kind:n.kind,title:n.title,route:n.route,text:n.text}}function yt(n){const t=n.toLowerCase();return t==="element"||t==="file"||t==="resource"||t==="ontology"?t:null}let P=null;self.onmessage=n=>{try{const t=n.data;if(t.type==="build"){P=mt(t.documents),v({type:"ready",documentCount:t.documents.length});return}if(!P){v({type:"error",requestId:t.requestId,message:"Search index is not ready."});return}const e=gt(P,t.query,new Set(t.enabledKinds),new Set(t.enabledElementTypes));v({type:"results",requestId:t.requestId,results:e})}catch(t){v({type:"error",requestId:n.data.type==="search"?n.data.requestId:void 0,message:t instanceof Error?t.message:String(t)})}};function v(n){self.postMessage(n)}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvire-org/reqvire",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Semantic engineering graph for building verifiable and traceable systems.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://www.reqvire.org",