@mappedin/react-sdk 6.0.1-beta.34 → 6.0.1-beta.36

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.
@@ -1 +1 @@
1
- import{b as ne,d as oe,e as re,f as ce,g as ae}from"./chunk-6XCA2ED4.js";import{D as _,E as ve,k as ie}from"./chunk-DRDKJVYC.js";import"./chunk-UFHCKQ3M.js";import"./chunk-PU3YPNK6.js";import"./chunk-FBZOUVIR.js";import{a as E}from"./chunk-U67PM65J.js";import{a as h,e as Oe,f as A,g as ee,h as B,i as te,j as se}from"./chunk-J5IUISYU.js";E();E();function V(r,e,t,s){function i(n){return n instanceof t?n:new t(function(o){o(n)})}return h(i,"adopt"),new(t||(t=Promise))(function(n,o){function c(u){try{d(s.next(u))}catch(f){o(f)}}h(c,"fulfilled");function a(u){try{d(s.throw(u))}catch(f){o(f)}}h(a,"rejected");function d(u){u.done?n(u.value):i(u.value).then(c,a)}h(d,"step"),d((s=s.apply(r,e||[])).next())})}h(V,"__awaiter");var Fe="ENTRIES",fe="KEYS",pe="VALUES",b="",Z=class Z{constructor(e,t){let s=e._tree,i=Array.from(s.keys());this.set=e,this._type=t,this._path=i.length>0?[{node:s,keys:i}]:[]}next(){let e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};let{node:e,keys:t}=v(this._path);if(v(t)===b)return{done:!1,value:this.result()};let s=e.get(v(t));return this._path.push({node:s,keys:Array.from(s.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;let e=v(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>v(e)).filter(e=>e!==b).join("")}value(){return v(this._path).node.get(b)}result(){switch(this._type){case pe:return this.value();case fe:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}};h(Z,"TreeIterator");var M=Z,v=h(r=>r[r.length-1],"last$1"),Me=h((r,e,t)=>{let s=new Map;if(e===void 0)return s;let i=e.length+1,n=i+t,o=new Uint8Array(n*i).fill(t+1);for(let c=0;c<i;++c)o[c]=c;for(let c=1;c<n;++c)o[c*i]=c;return me(r,e,t,s,o,1,i,""),s},"fuzzySearch"),me=h((r,e,t,s,i,n,o,c)=>{let a=n*o;e:for(let d of r.keys())if(d===b){let u=i[a-1];u<=t&&s.set(c,[r.get(d),u])}else{let u=n;for(let f=0;f<d.length;++f,++u){let l=d[f],m=o*u,y=m-o,p=i[m],g=Math.max(0,u-t-1),w=Math.min(o-1,u+t);for(let S=g;S<w;++S){let P=l!==e[S],W=i[y+S]+ +P,k=i[y+S+1]+1,x=i[m+S]+1,F=i[m+S+1]=Math.min(W,k,x);F<p&&(p=F)}if(p>t)continue e}me(r.get(d),e,t,s,i,u,o,c+d)}},"recurse"),z=class z{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");let[t,s]=R(this._tree,e.slice(this._prefix.length));if(t===void 0){let[i,n]=K(s);for(let o of i.keys())if(o!==b&&o.startsWith(n)){let c=new Map;return c.set(o.slice(n.length),i.get(o)),new z(c,e)}}return new z(t,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,Ce(this._tree,e)}entries(){return new M(this,Fe)}forEach(e){for(let[t,s]of this)e(t,s,this)}fuzzyGet(e,t){return Me(this._tree,e,t)}get(e){let t=Q(this._tree,e);return t!==void 0?t.get(b):void 0}has(e){let t=Q(this._tree,e);return t!==void 0&&t.has(b)}keys(){return new M(this,fe)}set(e,t){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,N(this._tree,e).set(b,t),this}get size(){if(this._size)return this._size;this._size=0;let 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;let s=N(this._tree,e);return s.set(b,t(s.get(b))),this}fetch(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;let s=N(this._tree,e),i=s.get(b);return i===void 0&&s.set(b,i=t()),i}values(){return new M(this,pe)}[Symbol.iterator](){return this.entries()}static from(e){let t=new z;for(let[s,i]of e)t.set(s,i);return t}static fromObject(e){return z.from(Object.entries(e))}};h(z,"SearchableMap");var C=z,R=h((r,e,t=[])=>{if(e.length===0||r==null)return[r,t];for(let s of r.keys())if(s!==b&&e.startsWith(s))return t.push([r,s]),R(r.get(s),e.slice(s.length),t);return t.push([r,e]),R(void 0,"",t)},"trackDown"),Q=h((r,e)=>{if(e.length===0||r==null)return r;for(let t of r.keys())if(t!==b&&e.startsWith(t))return Q(r.get(t),e.slice(t.length))},"lookup"),N=h((r,e)=>{let t=e.length;e:for(let s=0;r&&s<t;){for(let n of r.keys())if(n!==b&&e[s]===n[0]){let o=Math.min(t-s,n.length),c=1;for(;c<o&&e[s+c]===n[c];)++c;let a=r.get(n);if(c===n.length)r=a;else{let d=new Map;d.set(n.slice(c),a),r.set(e.slice(s,s+c),d),r.delete(n),r=d}s+=c;continue e}let i=new Map;return r.set(e.slice(s),i),i}return r},"createPath"),Ce=h((r,e)=>{let[t,s]=R(r,e);if(t!==void 0){if(t.delete(b),t.size===0)ge(s);else if(t.size===1){let[i,n]=t.entries().next().value;_e(s,i,n)}}},"remove"),ge=h(r=>{if(r.length===0)return;let[e,t]=K(r);if(e.delete(t),e.size===0)ge(r.slice(0,-1));else if(e.size===1){let[s,i]=e.entries().next().value;s!==b&&_e(r.slice(0,-1),s,i)}},"cleanup"),_e=h((r,e,t)=>{if(r.length===0)return;let[s,i]=K(r);s.set(i+e,t),s.delete(i)},"merge"),K=h(r=>r[r.length-1],"last"),Y="or",ye="and",Le="and_not",I=class I{constructor(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');let t=e.autoVacuum==null||e.autoVacuum===!0?q:e.autoVacuum;this._options=Object.assign(Object.assign(Object.assign({},J),e),{autoVacuum:t,searchOptions:Object.assign(Object.assign({},ue),e.searchOptions||{}),autoSuggestOptions:Object.assign(Object.assign({},Te),e.autoSuggestOptions||{})}),this._index=new C,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=G,this.addFields(this._options.fields)}add(e){let{extractField:t,tokenize:s,processTerm:i,fields:n,idField:o}=this._options,c=t(e,o);if(c==null)throw new Error('MiniSearch: document does not have ID field "'.concat(o,'"'));if(this._idToShortId.has(c))throw new Error("MiniSearch: duplicate ID ".concat(c));let a=this.addDocumentId(c);this.saveStoredFields(a,e);for(let d of n){let u=t(e,d);if(u==null)continue;let f=s(u.toString(),d),l=this._fieldIds[d],m=new Set(f).size;this.addFieldLength(a,l,this._documentCount-1,m);for(let y of f){let p=i(y,d);if(Array.isArray(p))for(let g of p)this.addTerm(l,a,g);else p&&this.addTerm(l,a,p)}}}addAll(e){for(let t of e)this.add(t)}addAllAsync(e,t={}){let{chunkSize:s=10}=t,i={chunk:[],promise:Promise.resolve()},{chunk:n,promise:o}=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}),i);return o.then(()=>this.addAll(n))}remove(e){let{tokenize:t,processTerm:s,extractField:i,fields:n,idField:o}=this._options,c=i(e,o);if(c==null)throw new Error('MiniSearch: document does not have ID field "'.concat(o,'"'));let a=this._idToShortId.get(c);if(a==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(c,": it is not in the index"));for(let d of n){let u=i(e,d);if(u==null)continue;let f=t(u.toString(),d),l=this._fieldIds[d],m=new Set(f).size;this.removeFieldLength(a,l,this._documentCount,m);for(let y of f){let p=s(y,d);if(Array.isArray(p))for(let g of p)this.removeTerm(l,a,g);else p&&this.removeTerm(l,a,p)}}this._storedFields.delete(a),this._documentIds.delete(a),this._idToShortId.delete(c),this._fieldLength.delete(a),this._documentCount-=1}removeAll(e){if(e)for(let 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 C,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){let t=this._idToShortId.get(e);if(t==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(t),this._storedFields.delete(t),(this._fieldLength.get(t)||[]).forEach((s,i)=>{this.removeFieldLength(t,i,this._documentCount,s)}),this._fieldLength.delete(t),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;let{minDirtFactor:e,minDirtCount:t,batchSize:s,batchWait:i}=this._options.autoVacuum;this.conditionalVacuum({batchSize:s,batchWait:i},{minDirtCount:t,minDirtFactor:e})}discardAll(e){let t=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(let s of e)this.discard(s)}finally{this._options.autoVacuum=t}this.maybeAutoVacuum()}replace(e){let{idField:t,extractField:s}=this._options,i=s(e,t);this.discard(i),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(()=>{let s=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=G,this.performVacuuming(e,s)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}performVacuuming(e,t){return V(this,void 0,void 0,function*(){let s=this._dirtCount;if(this.vacuumConditionsMet(t)){let i=e.batchSize||U.batchSize,n=e.batchWait||U.batchWait,o=1;for(let[c,a]of this._index){for(let[d,u]of a)for(let[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),o%i===0&&(yield new Promise(d=>setTimeout(d,n))),o+=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||q.minDirtCount,s=s||q.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){let t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)}search(e,t={}){let s=this.executeQuery(e,t),i=[];for(let[n,{score:o,terms:c,match:a}]of s){let d=c.length||1,u={id:this._documentIds.get(n),score:o*d,terms:Object.keys(a),queryTerms:c,match:a};Object.assign(u,this._storedFields.get(n)),(t.filter==null||t.filter(u))&&i.push(u)}return e===I.wildcard&&t.boostDocument==null&&this._options.searchOptions.boostDocument==null||i.sort(le),i}autoSuggest(e,t={}){t=Object.assign(Object.assign({},this._options.autoSuggestOptions),t);let s=new Map;for(let{score:n,terms:o}of this.search(e,t)){let c=o.join(" "),a=s.get(c);a!=null?(a.score+=n,a.count+=1):s.set(c,{score:n,terms:o,count:1})}let i=[];for(let[n,{score:o,terms:c,count:a}]of s)i.push({suggestion:n,terms:c,score:o/a});return i.sort(le),i}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 V(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(J.hasOwnProperty(e))return $(J,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))}static loadJS(e,t){let{index:s,documentIds:i,fieldLength:n,storedFields:o,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=j(i),a._fieldLength=j(n),a._storedFields=j(o);for(let[d,u]of a._documentIds)a._idToShortId.set(u,d);for(let[d,u]of s){let f=new Map;for(let l of Object.keys(u)){let m=u[l];c===1&&(m=m.ds),f.set(parseInt(l,10),j(m))}a._index.set(d,f)}return a}static loadJSAsync(e,t){return V(this,void 0,void 0,function*(){let{index:s,documentIds:i,fieldLength:n,storedFields:o,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=yield T(i),a._fieldLength=yield T(n),a._storedFields=yield T(o);for(let[u,f]of a._documentIds)a._idToShortId.set(f,u);let d=0;for(let[u,f]of s){let l=new Map;for(let m of Object.keys(f)){let y=f[m];c===1&&(y=y.ds),l.set(parseInt(m,10),yield T(y))}++d%1e3===0&&(yield be(0)),a._index.set(u,l)}return a})}static instantiateMiniSearch(e,t){let{documentCount:s,nextId:i,fieldIds:n,averageFieldLength:o,dirtCount:c,serializationVersion:a}=e;if(a!==1&&a!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");let d=new I(t);return d._documentCount=s,d._nextId=i,d._idToShortId=new Map,d._fieldIds=n,d._avgFieldLength=o,d._dirtCount=c||0,d._index=new C,d}executeQuery(e,t={}){if(e===I.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){let l=Object.assign(Object.assign(Object.assign({},t),e),{queries:void 0}),m=e.queries.map(y=>this.executeQuery(y,l));return this.combineResults(m,l.combineWith)}let{tokenize:s,processTerm:i,searchOptions:n}=this._options,o=Object.assign(Object.assign({tokenize:s,processTerm:i},n),t),{tokenize:c,processTerm:a}=o,f=c(e).flatMap(l=>a(l)).filter(l=>!!l).map(je(o)).map(l=>this.executeQuerySpec(l,o));return this.combineResults(f,o.combineWith)}executeQuerySpec(e,t){let s=Object.assign(Object.assign({},this._options.searchOptions),t),i=(s.fields||this._options.fields).reduce((p,g)=>Object.assign(Object.assign({},p),{[g]:$(s.boost,g)||1}),{}),{boostDocument:n,weights:o,maxFuzzy:c,bm25:a}=s,{fuzzy:d,prefix:u}=Object.assign(Object.assign({},ue.weights),o),f=this._index.get(e.term),l=this.termResults(e.term,e.term,1,e.termBoost,f,i,n,a),m,y;if(e.prefix&&(m=this._index.atPrefix(e.term)),e.fuzzy){let p=e.fuzzy===!0?.2:e.fuzzy,g=p<1?Math.min(c,Math.round(e.term.length*p)):p;g&&(y=this._index.fuzzyGet(e.term,g))}if(m)for(let[p,g]of m){let w=p.length-e.term.length;if(!w)continue;y==null||y.delete(p);let S=u*p.length/(p.length+.3*w);this.termResults(e.term,p,S,e.termBoost,g,i,n,a,l)}if(y)for(let p of y.keys()){let[g,w]=y.get(p);if(!w)continue;let S=d*p.length/(p.length+w);this.termResults(e.term,p,S,e.termBoost,g,i,n,a,l)}return l}executeWildcardQuery(e){let t=new Map,s=Object.assign(Object.assign({},this._options.searchOptions),e);for(let[i,n]of this._documentIds){let o=s.boostDocument?s.boostDocument(n,"",this._storedFields.get(i)):1;t.set(i,{score:o,terms:[],match:{}})}return t}combineResults(e,t=Y){if(e.length===0)return new Map;let s=t.toLowerCase(),i=ke[s];if(!i)throw new Error("Invalid combination operator: ".concat(t));return e.reduce(i)||new Map}toJSON(){let e=[];for(let[t,s]of this._index){let i={};for(let[n,o]of s)i[n]=Object.fromEntries(o);e.push([t,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:e,serializationVersion:2}}termResults(e,t,s,i,n,o,c,a,d=new Map){if(n==null)return d;for(let u of Object.keys(o)){let f=o[u],l=this._fieldIds[u],m=n.get(l);if(m==null)continue;let y=m.size,p=this._avgFieldLength[l];for(let g of m.keys()){if(!this._documentIds.has(g)){this.removeTerm(l,g,t),y-=1;continue}let w=c?c(this._documentIds.get(g),t,this._storedFields.get(g)):1;if(!w)continue;let S=m.get(g),P=this._fieldLength.get(g)[l],W=Ee(S,y,this._documentCount,P,p,a),k=s*i*f*w*W,x=d.get(g);if(x){x.score+=k,Ve(x.terms,e);let F=$(x.match,t);F?F.push(u):x.match[t]=[u]}else d.set(g,{score:k,terms:[e],match:{[t]:[u]}})}}return d}addTerm(e,t,s){let i=this._index.fetch(s,he),n=i.get(e);if(n==null)n=new Map,n.set(t,1),i.set(e,n);else{let o=n.get(t);n.set(t,(o||0)+1)}}removeTerm(e,t,s){if(!this._index.has(s)){this.warnDocumentChanged(t,e,s);return}let i=this._index.fetch(s,he),n=i.get(e);n==null||n.get(t)==null?this.warnDocumentChanged(t,e,s):n.get(t)<=1?n.size<=1?i.delete(e):n.delete(t):n.set(t,n.get(t)-1),this._index.get(s).size===0&&this._index.delete(s)}warnDocumentChanged(e,t,s){for(let i of Object.keys(this._fieldIds))if(this._fieldIds[i]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(s,'" was not present in field "').concat(i,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}addDocumentId(e){let 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,i){let n=this._fieldLength.get(e);n==null&&this._fieldLength.set(e,n=[]),n[t]=i;let c=(this._avgFieldLength[t]||0)*s+i;this._avgFieldLength[t]=c/(s+1)}removeFieldLength(e,t,s,i){if(s===1){this._avgFieldLength[t]=0;return}let n=this._avgFieldLength[t]*s-i;this._avgFieldLength[t]=n/(s-1)}saveStoredFields(e,t){let{storeFields:s,extractField:i}=this._options;if(s==null||s.length===0)return;let n=this._storedFields.get(e);n==null&&this._storedFields.set(e,n={});for(let o of s){let c=i(t,o);c!==void 0&&(n[o]=c)}}};h(I,"MiniSearch");var O=I;O.wildcard=Symbol("*");var $=h((r,e)=>Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0,"getOwnProperty"),ke={[Y]:(r,e)=>{for(let t of e.keys()){let s=r.get(t);if(s==null)r.set(t,e.get(t));else{let{score:i,terms:n,match:o}=e.get(t);s.score=s.score+i,s.match=Object.assign(s.match,o),de(s.terms,n)}}return r},[ye]:(r,e)=>{let t=new Map;for(let s of e.keys()){let i=r.get(s);if(i==null)continue;let{score:n,terms:o,match:c}=e.get(s);de(i.terms,o),t.set(s,{score:i.score+n,terms:i.terms,match:Object.assign(i.match,c)})}return t},[Le]:(r,e)=>{for(let t of e.keys())r.delete(t);return r}},Ae={k:1.2,b:.7,d:.5},Ee=h((r,e,t,s,i,n)=>{let{k:o,b:c,d:a}=n;return Math.log(1+(t-e+.5)/(e+.5))*(a+r*(o+1)/(r+o*(1-c+c*s/i)))},"calcBM25Score"),je=h(r=>(e,t,s)=>{let i=typeof r.fuzzy=="function"?r.fuzzy(e,t,s):r.fuzzy||!1,n=typeof r.prefix=="function"?r.prefix(e,t,s):r.prefix===!0,o=typeof r.boostTerm=="function"?r.boostTerm(e,t,s):1;return{term:e,fuzzy:i,prefix:n,termBoost:o}},"termToQuerySpec"),J={idField:"id",extractField:(r,e)=>r[e],tokenize:r=>r.split(Re),processTerm:r=>r.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(r,e)=>{typeof(console==null?void 0:console[r])=="function"&&console[r](e)},autoVacuum:!0},ue={combineWith:Y,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Ae},Te={combineWith:ye,prefix:(r,e,t)=>e===t.length-1},U={batchSize:1e3,batchWait:10},G={minDirtFactor:.1,minDirtCount:20},q=Object.assign(Object.assign({},U),G),Ve=h((r,e)=>{r.includes(e)||r.push(e)},"assignUniqueTerm"),de=h((r,e)=>{for(let t of e)r.includes(t)||r.push(t)},"assignUniqueTerms"),le=h(({score:r},{score:e})=>e-r,"byScore"),he=h(()=>new Map,"createMap"),j=h(r=>{let e=new Map;for(let t of Object.keys(r))e.set(parseInt(t,10),r[t]);return e},"objectToNumericMap"),T=h(r=>V(void 0,void 0,void 0,function*(){let e=new Map,t=0;for(let s of Object.keys(r))e.set(parseInt(s,10),r[s]),++t%1e3===0&&(yield be(0));return e}),"objectToNumericMapAsync"),be=h(r=>new Promise(e=>setTimeout(e,r)),"wait"),Re=/[\n\r\p{Z}\p{P}]+/u;var xe=Oe(ve(),1);var L,D,ze,X=class X{constructor(e){B(this,D);A(this,"mapData");A(this,"indexes");A(this,"ready");B(this,L,void 0);this.mapData=e,this.indexes=We(e),this.ready=this.populate(),te(this,L,ie(se(this,D,ze).bind(this),2e3))}async populate(){let{places:e,enterpriseLocations:t,enterpriseCategories:s}=this.indexes,i=this.mapData,n=[];return e.removeAll(),n=n.concat([e.addAllAsync(i.getByType("space")),e.addAllAsync(i.getByType("point-of-interest")),e.addAllAsync(i.getByType("connection")),e.addAllAsync(i.getByType("floor")),e.addAllAsync(i.getByType("door")),e.addAllAsync(i.getByType("annotation")),e.addAllAsync(i.getByType("area"))]),t&&(t==null||t.removeAll(),n.push(t.addAllAsync(i.getByType("enterprise-location")))),s&&(s==null||s.removeAll(),n.push(s.addAllAsync(i.getByType("enterprise-category")))),Promise.all(n)}async search(e,t={}){var a,d;await this.ready,Be.parse(t);let s=(0,xe.default)({},t,Pe),i=this.indexes.places.search(e,{fields:Object.keys(s.places.fields).filter(u=>s.places.fields[u])});s.places.limit&&(i=i.slice(0,s.places.limit));let n=(a=this.indexes.enterpriseLocations)==null?void 0:a.search(e,{fields:Object.keys(s.enterpriseLocations.fields).filter(u=>s.enterpriseLocations.fields[u])});n&&s.enterpriseLocations.limit&&(n=n.slice(0,s.enterpriseLocations.limit));let o=(d=this.indexes.enterpriseCategories)==null?void 0:d.search(e,{fields:Object.keys(s.enterpriseCategories.fields).filter(u=>s.enterpriseCategories.fields[u])});o&&s.enterpriseCategories.limit&&(o=o.slice(0,s.enterpriseCategories.limit));let c=De(this.mapData,{placesResult:i,locationsResult:n,categoriesResult:o});return ee(this,L).call(this,e),c}async suggest(e,t={}){await this.ready,Ne.parse(t);let s=[],{places:{enabled:i=!0}={},enterpriseLocations:{enabled:n=!0}={}}=t;return n&&this.indexes.enterpriseLocations&&this.indexes.enterpriseLocations.autoSuggest(e,{fields:["name","tags"],combineWith:"AND",prefix:!0,boost:{name:2,tags:1}}).forEach(o=>s.push(o)),i&&this.indexes.places.autoSuggest(e,{fields:["name"],combineWith:"AND",prefix:!0}).forEach(o=>s.push(o)),s.sort((o,c)=>c.score-o.score),this.mapData.Analytics.capture("$query-suggest",{query:e,suggestions:s.map(o=>o.suggestion)}),s}};L=new WeakMap,D=new WeakSet,ze=h(function(e){this.mapData.Analytics.capture("$query-search",{query:e})},"#trackSearch"),h(X,"InternalSearch");var Se=X;function De(r,{placesResult:e,locationsResult:t,categoriesResult:s}){let i=e.reduce((c,{id:a,match:d,score:u,__type:f})=>{let l=r.getById(f,a);return l!=null&&!ne.is(l)&&!oe.is(l)&&!re.is(l)&&!ce.is(l)&&!ae.is(l)&&c.push({type:l.__type,match:d,score:u,item:l}),c},[]),n;if(t){n=[];for(let{id:c,match:a,score:d}of t){let u=r.getById("enterprise-location",c);u&&n.push({type:u.__type,match:a,score:d,item:u})}}let o;if(s){o=[];for(let{id:c,match:a,score:d}of s){let u=r.getById("enterprise-category",c);u&&o.push({type:u.__type,match:a,score:d,item:u})}}return{places:i,enterpriseLocations:n,enterpriseCategories:o}}h(De,"processSearchResult");var Pe={places:{fields:{name:!0,description:!0}},enterpriseCategories:{fields:{name:!0,description:!1,"locations.name":!0}},enterpriseLocations:{fields:{name:!0,tags:!0,description:!0}}};function H(r){return r.normalize("NFD").replace(/[\u0300-\u036f|\u2019|\u0027|\']/g,"").toLowerCase()}h(H,"removeAccents");function We(r){let e=new O({fields:["name","description"],storeFields:["id","__type"],searchOptions:{fuzzy:.2,prefix:!0,boost:{name:2},combineWith:"AND"},extractField:(o,c)=>{let a=o[c];return typeof a=="string"?H(a):o[c]},processTerm:o=>$e.has(o)?"":o.toLowerCase()}),t=r.getByType("enterprise-location"),s;t&&(s=new O({fields:["name","tags","description"],storeFields:["id","__type"],searchOptions:{combineWith:"OR",prefix:!0,fuzzy:.2,boost:{name:3,tags:2,description:1}},extractField:(o,c)=>Array.isArray(o[c])?o[c].join(" "):typeof o[c]=="string"?H(o[c]):o[c]}));let i=r.getByType("enterprise-category"),n;return i&&(n=new O({fields:["name","description","locations.name"],storeFields:["id","__type"],extractField(o,c){return c==="locations.name"?o.locations.reduce((d,u)=>d+" ".concat(we," ")+u.name,"")+" ".concat(we):typeof o[c]=="string"?H(o[c]):o[c]},searchOptions:{combineWith:"OR",prefix:!0,fuzzy:.2,boost:{name:2,"locations.name":2}}})),{enterpriseCategories:n,enterpriseLocations:s,places:e}}h(We,"buildIndexes");var Be=_.object({places:_.object({fields:_.object({name:_.boolean().optional(),description:_.boolean().optional()}).optional(),limit:_.number().positive().optional()}).optional(),enterpriseCategories:_.object({fields:_.object({name:_.boolean().optional(),description:_.boolean().optional(),"locations.name":_.boolean().optional()}).optional(),limit:_.number().positive().optional()}).optional(),enterpriseLocations:_.object({fields:_.object({name:_.boolean().optional(),tags:_.boolean().optional(),description:_.boolean().optional()}).optional(),limit:_.number().positive().optional()}).optional()}),Ne=_.object({places:_.object({enabled:_.boolean().optional()}).optional(),enterpriseLocations:_.object({enabled:_.boolean().optional()}).optional()}),$e=new Set(["the","an","and","or","of","in","on","at","to","from","with","by","for"]),we="";export{Se as InternalSearch,H as removeAccents};
1
+ import{b as ne,d as oe,e as re,f as ce,g as ae}from"./chunk-LVTFVANX.js";import{E as _,F as ve,k as ie}from"./chunk-2EQDUMYU.js";import"./chunk-YW4KFTPW.js";import"./chunk-OL3PKM5U.js";import"./chunk-B7B5GI4U.js";import{a as E}from"./chunk-VQGFL42S.js";import{a as h,e as Oe,f as A,g as ee,h as B,i as te,j as se}from"./chunk-J5IUISYU.js";E();E();function V(r,e,t,s){function i(n){return n instanceof t?n:new t(function(o){o(n)})}return h(i,"adopt"),new(t||(t=Promise))(function(n,o){function c(u){try{d(s.next(u))}catch(f){o(f)}}h(c,"fulfilled");function a(u){try{d(s.throw(u))}catch(f){o(f)}}h(a,"rejected");function d(u){u.done?n(u.value):i(u.value).then(c,a)}h(d,"step"),d((s=s.apply(r,e||[])).next())})}h(V,"__awaiter");var Fe="ENTRIES",fe="KEYS",pe="VALUES",b="",Z=class Z{constructor(e,t){let s=e._tree,i=Array.from(s.keys());this.set=e,this._type=t,this._path=i.length>0?[{node:s,keys:i}]:[]}next(){let e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};let{node:e,keys:t}=v(this._path);if(v(t)===b)return{done:!1,value:this.result()};let s=e.get(v(t));return this._path.push({node:s,keys:Array.from(s.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;let e=v(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>v(e)).filter(e=>e!==b).join("")}value(){return v(this._path).node.get(b)}result(){switch(this._type){case pe:return this.value();case fe:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}};h(Z,"TreeIterator");var M=Z,v=h(r=>r[r.length-1],"last$1"),Me=h((r,e,t)=>{let s=new Map;if(e===void 0)return s;let i=e.length+1,n=i+t,o=new Uint8Array(n*i).fill(t+1);for(let c=0;c<i;++c)o[c]=c;for(let c=1;c<n;++c)o[c*i]=c;return me(r,e,t,s,o,1,i,""),s},"fuzzySearch"),me=h((r,e,t,s,i,n,o,c)=>{let a=n*o;e:for(let d of r.keys())if(d===b){let u=i[a-1];u<=t&&s.set(c,[r.get(d),u])}else{let u=n;for(let f=0;f<d.length;++f,++u){let l=d[f],m=o*u,y=m-o,p=i[m],g=Math.max(0,u-t-1),w=Math.min(o-1,u+t);for(let S=g;S<w;++S){let P=l!==e[S],W=i[y+S]+ +P,k=i[y+S+1]+1,x=i[m+S]+1,F=i[m+S+1]=Math.min(W,k,x);F<p&&(p=F)}if(p>t)continue e}me(r.get(d),e,t,s,i,u,o,c+d)}},"recurse"),z=class z{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");let[t,s]=R(this._tree,e.slice(this._prefix.length));if(t===void 0){let[i,n]=K(s);for(let o of i.keys())if(o!==b&&o.startsWith(n)){let c=new Map;return c.set(o.slice(n.length),i.get(o)),new z(c,e)}}return new z(t,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,Ce(this._tree,e)}entries(){return new M(this,Fe)}forEach(e){for(let[t,s]of this)e(t,s,this)}fuzzyGet(e,t){return Me(this._tree,e,t)}get(e){let t=Q(this._tree,e);return t!==void 0?t.get(b):void 0}has(e){let t=Q(this._tree,e);return t!==void 0&&t.has(b)}keys(){return new M(this,fe)}set(e,t){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,N(this._tree,e).set(b,t),this}get size(){if(this._size)return this._size;this._size=0;let 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;let s=N(this._tree,e);return s.set(b,t(s.get(b))),this}fetch(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;let s=N(this._tree,e),i=s.get(b);return i===void 0&&s.set(b,i=t()),i}values(){return new M(this,pe)}[Symbol.iterator](){return this.entries()}static from(e){let t=new z;for(let[s,i]of e)t.set(s,i);return t}static fromObject(e){return z.from(Object.entries(e))}};h(z,"SearchableMap");var C=z,R=h((r,e,t=[])=>{if(e.length===0||r==null)return[r,t];for(let s of r.keys())if(s!==b&&e.startsWith(s))return t.push([r,s]),R(r.get(s),e.slice(s.length),t);return t.push([r,e]),R(void 0,"",t)},"trackDown"),Q=h((r,e)=>{if(e.length===0||r==null)return r;for(let t of r.keys())if(t!==b&&e.startsWith(t))return Q(r.get(t),e.slice(t.length))},"lookup"),N=h((r,e)=>{let t=e.length;e:for(let s=0;r&&s<t;){for(let n of r.keys())if(n!==b&&e[s]===n[0]){let o=Math.min(t-s,n.length),c=1;for(;c<o&&e[s+c]===n[c];)++c;let a=r.get(n);if(c===n.length)r=a;else{let d=new Map;d.set(n.slice(c),a),r.set(e.slice(s,s+c),d),r.delete(n),r=d}s+=c;continue e}let i=new Map;return r.set(e.slice(s),i),i}return r},"createPath"),Ce=h((r,e)=>{let[t,s]=R(r,e);if(t!==void 0){if(t.delete(b),t.size===0)ge(s);else if(t.size===1){let[i,n]=t.entries().next().value;_e(s,i,n)}}},"remove"),ge=h(r=>{if(r.length===0)return;let[e,t]=K(r);if(e.delete(t),e.size===0)ge(r.slice(0,-1));else if(e.size===1){let[s,i]=e.entries().next().value;s!==b&&_e(r.slice(0,-1),s,i)}},"cleanup"),_e=h((r,e,t)=>{if(r.length===0)return;let[s,i]=K(r);s.set(i+e,t),s.delete(i)},"merge"),K=h(r=>r[r.length-1],"last"),Y="or",ye="and",Le="and_not",I=class I{constructor(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');let t=e.autoVacuum==null||e.autoVacuum===!0?q:e.autoVacuum;this._options=Object.assign(Object.assign(Object.assign({},J),e),{autoVacuum:t,searchOptions:Object.assign(Object.assign({},ue),e.searchOptions||{}),autoSuggestOptions:Object.assign(Object.assign({},Te),e.autoSuggestOptions||{})}),this._index=new C,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=G,this.addFields(this._options.fields)}add(e){let{extractField:t,tokenize:s,processTerm:i,fields:n,idField:o}=this._options,c=t(e,o);if(c==null)throw new Error('MiniSearch: document does not have ID field "'.concat(o,'"'));if(this._idToShortId.has(c))throw new Error("MiniSearch: duplicate ID ".concat(c));let a=this.addDocumentId(c);this.saveStoredFields(a,e);for(let d of n){let u=t(e,d);if(u==null)continue;let f=s(u.toString(),d),l=this._fieldIds[d],m=new Set(f).size;this.addFieldLength(a,l,this._documentCount-1,m);for(let y of f){let p=i(y,d);if(Array.isArray(p))for(let g of p)this.addTerm(l,a,g);else p&&this.addTerm(l,a,p)}}}addAll(e){for(let t of e)this.add(t)}addAllAsync(e,t={}){let{chunkSize:s=10}=t,i={chunk:[],promise:Promise.resolve()},{chunk:n,promise:o}=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}),i);return o.then(()=>this.addAll(n))}remove(e){let{tokenize:t,processTerm:s,extractField:i,fields:n,idField:o}=this._options,c=i(e,o);if(c==null)throw new Error('MiniSearch: document does not have ID field "'.concat(o,'"'));let a=this._idToShortId.get(c);if(a==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(c,": it is not in the index"));for(let d of n){let u=i(e,d);if(u==null)continue;let f=t(u.toString(),d),l=this._fieldIds[d],m=new Set(f).size;this.removeFieldLength(a,l,this._documentCount,m);for(let y of f){let p=s(y,d);if(Array.isArray(p))for(let g of p)this.removeTerm(l,a,g);else p&&this.removeTerm(l,a,p)}}this._storedFields.delete(a),this._documentIds.delete(a),this._idToShortId.delete(c),this._fieldLength.delete(a),this._documentCount-=1}removeAll(e){if(e)for(let 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 C,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){let t=this._idToShortId.get(e);if(t==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(t),this._storedFields.delete(t),(this._fieldLength.get(t)||[]).forEach((s,i)=>{this.removeFieldLength(t,i,this._documentCount,s)}),this._fieldLength.delete(t),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;let{minDirtFactor:e,minDirtCount:t,batchSize:s,batchWait:i}=this._options.autoVacuum;this.conditionalVacuum({batchSize:s,batchWait:i},{minDirtCount:t,minDirtFactor:e})}discardAll(e){let t=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(let s of e)this.discard(s)}finally{this._options.autoVacuum=t}this.maybeAutoVacuum()}replace(e){let{idField:t,extractField:s}=this._options,i=s(e,t);this.discard(i),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(()=>{let s=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=G,this.performVacuuming(e,s)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}performVacuuming(e,t){return V(this,void 0,void 0,function*(){let s=this._dirtCount;if(this.vacuumConditionsMet(t)){let i=e.batchSize||U.batchSize,n=e.batchWait||U.batchWait,o=1;for(let[c,a]of this._index){for(let[d,u]of a)for(let[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),o%i===0&&(yield new Promise(d=>setTimeout(d,n))),o+=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||q.minDirtCount,s=s||q.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){let t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)}search(e,t={}){let s=this.executeQuery(e,t),i=[];for(let[n,{score:o,terms:c,match:a}]of s){let d=c.length||1,u={id:this._documentIds.get(n),score:o*d,terms:Object.keys(a),queryTerms:c,match:a};Object.assign(u,this._storedFields.get(n)),(t.filter==null||t.filter(u))&&i.push(u)}return e===I.wildcard&&t.boostDocument==null&&this._options.searchOptions.boostDocument==null||i.sort(le),i}autoSuggest(e,t={}){t=Object.assign(Object.assign({},this._options.autoSuggestOptions),t);let s=new Map;for(let{score:n,terms:o}of this.search(e,t)){let c=o.join(" "),a=s.get(c);a!=null?(a.score+=n,a.count+=1):s.set(c,{score:n,terms:o,count:1})}let i=[];for(let[n,{score:o,terms:c,count:a}]of s)i.push({suggestion:n,terms:c,score:o/a});return i.sort(le),i}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 V(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(J.hasOwnProperty(e))return $(J,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))}static loadJS(e,t){let{index:s,documentIds:i,fieldLength:n,storedFields:o,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=j(i),a._fieldLength=j(n),a._storedFields=j(o);for(let[d,u]of a._documentIds)a._idToShortId.set(u,d);for(let[d,u]of s){let f=new Map;for(let l of Object.keys(u)){let m=u[l];c===1&&(m=m.ds),f.set(parseInt(l,10),j(m))}a._index.set(d,f)}return a}static loadJSAsync(e,t){return V(this,void 0,void 0,function*(){let{index:s,documentIds:i,fieldLength:n,storedFields:o,serializationVersion:c}=e,a=this.instantiateMiniSearch(e,t);a._documentIds=yield T(i),a._fieldLength=yield T(n),a._storedFields=yield T(o);for(let[u,f]of a._documentIds)a._idToShortId.set(f,u);let d=0;for(let[u,f]of s){let l=new Map;for(let m of Object.keys(f)){let y=f[m];c===1&&(y=y.ds),l.set(parseInt(m,10),yield T(y))}++d%1e3===0&&(yield be(0)),a._index.set(u,l)}return a})}static instantiateMiniSearch(e,t){let{documentCount:s,nextId:i,fieldIds:n,averageFieldLength:o,dirtCount:c,serializationVersion:a}=e;if(a!==1&&a!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");let d=new I(t);return d._documentCount=s,d._nextId=i,d._idToShortId=new Map,d._fieldIds=n,d._avgFieldLength=o,d._dirtCount=c||0,d._index=new C,d}executeQuery(e,t={}){if(e===I.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){let l=Object.assign(Object.assign(Object.assign({},t),e),{queries:void 0}),m=e.queries.map(y=>this.executeQuery(y,l));return this.combineResults(m,l.combineWith)}let{tokenize:s,processTerm:i,searchOptions:n}=this._options,o=Object.assign(Object.assign({tokenize:s,processTerm:i},n),t),{tokenize:c,processTerm:a}=o,f=c(e).flatMap(l=>a(l)).filter(l=>!!l).map(je(o)).map(l=>this.executeQuerySpec(l,o));return this.combineResults(f,o.combineWith)}executeQuerySpec(e,t){let s=Object.assign(Object.assign({},this._options.searchOptions),t),i=(s.fields||this._options.fields).reduce((p,g)=>Object.assign(Object.assign({},p),{[g]:$(s.boost,g)||1}),{}),{boostDocument:n,weights:o,maxFuzzy:c,bm25:a}=s,{fuzzy:d,prefix:u}=Object.assign(Object.assign({},ue.weights),o),f=this._index.get(e.term),l=this.termResults(e.term,e.term,1,e.termBoost,f,i,n,a),m,y;if(e.prefix&&(m=this._index.atPrefix(e.term)),e.fuzzy){let p=e.fuzzy===!0?.2:e.fuzzy,g=p<1?Math.min(c,Math.round(e.term.length*p)):p;g&&(y=this._index.fuzzyGet(e.term,g))}if(m)for(let[p,g]of m){let w=p.length-e.term.length;if(!w)continue;y==null||y.delete(p);let S=u*p.length/(p.length+.3*w);this.termResults(e.term,p,S,e.termBoost,g,i,n,a,l)}if(y)for(let p of y.keys()){let[g,w]=y.get(p);if(!w)continue;let S=d*p.length/(p.length+w);this.termResults(e.term,p,S,e.termBoost,g,i,n,a,l)}return l}executeWildcardQuery(e){let t=new Map,s=Object.assign(Object.assign({},this._options.searchOptions),e);for(let[i,n]of this._documentIds){let o=s.boostDocument?s.boostDocument(n,"",this._storedFields.get(i)):1;t.set(i,{score:o,terms:[],match:{}})}return t}combineResults(e,t=Y){if(e.length===0)return new Map;let s=t.toLowerCase(),i=ke[s];if(!i)throw new Error("Invalid combination operator: ".concat(t));return e.reduce(i)||new Map}toJSON(){let e=[];for(let[t,s]of this._index){let i={};for(let[n,o]of s)i[n]=Object.fromEntries(o);e.push([t,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:e,serializationVersion:2}}termResults(e,t,s,i,n,o,c,a,d=new Map){if(n==null)return d;for(let u of Object.keys(o)){let f=o[u],l=this._fieldIds[u],m=n.get(l);if(m==null)continue;let y=m.size,p=this._avgFieldLength[l];for(let g of m.keys()){if(!this._documentIds.has(g)){this.removeTerm(l,g,t),y-=1;continue}let w=c?c(this._documentIds.get(g),t,this._storedFields.get(g)):1;if(!w)continue;let S=m.get(g),P=this._fieldLength.get(g)[l],W=Ee(S,y,this._documentCount,P,p,a),k=s*i*f*w*W,x=d.get(g);if(x){x.score+=k,Ve(x.terms,e);let F=$(x.match,t);F?F.push(u):x.match[t]=[u]}else d.set(g,{score:k,terms:[e],match:{[t]:[u]}})}}return d}addTerm(e,t,s){let i=this._index.fetch(s,he),n=i.get(e);if(n==null)n=new Map,n.set(t,1),i.set(e,n);else{let o=n.get(t);n.set(t,(o||0)+1)}}removeTerm(e,t,s){if(!this._index.has(s)){this.warnDocumentChanged(t,e,s);return}let i=this._index.fetch(s,he),n=i.get(e);n==null||n.get(t)==null?this.warnDocumentChanged(t,e,s):n.get(t)<=1?n.size<=1?i.delete(e):n.delete(t):n.set(t,n.get(t)-1),this._index.get(s).size===0&&this._index.delete(s)}warnDocumentChanged(e,t,s){for(let i of Object.keys(this._fieldIds))if(this._fieldIds[i]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(s,'" was not present in field "').concat(i,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}addDocumentId(e){let 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,i){let n=this._fieldLength.get(e);n==null&&this._fieldLength.set(e,n=[]),n[t]=i;let c=(this._avgFieldLength[t]||0)*s+i;this._avgFieldLength[t]=c/(s+1)}removeFieldLength(e,t,s,i){if(s===1){this._avgFieldLength[t]=0;return}let n=this._avgFieldLength[t]*s-i;this._avgFieldLength[t]=n/(s-1)}saveStoredFields(e,t){let{storeFields:s,extractField:i}=this._options;if(s==null||s.length===0)return;let n=this._storedFields.get(e);n==null&&this._storedFields.set(e,n={});for(let o of s){let c=i(t,o);c!==void 0&&(n[o]=c)}}};h(I,"MiniSearch");var O=I;O.wildcard=Symbol("*");var $=h((r,e)=>Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0,"getOwnProperty"),ke={[Y]:(r,e)=>{for(let t of e.keys()){let s=r.get(t);if(s==null)r.set(t,e.get(t));else{let{score:i,terms:n,match:o}=e.get(t);s.score=s.score+i,s.match=Object.assign(s.match,o),de(s.terms,n)}}return r},[ye]:(r,e)=>{let t=new Map;for(let s of e.keys()){let i=r.get(s);if(i==null)continue;let{score:n,terms:o,match:c}=e.get(s);de(i.terms,o),t.set(s,{score:i.score+n,terms:i.terms,match:Object.assign(i.match,c)})}return t},[Le]:(r,e)=>{for(let t of e.keys())r.delete(t);return r}},Ae={k:1.2,b:.7,d:.5},Ee=h((r,e,t,s,i,n)=>{let{k:o,b:c,d:a}=n;return Math.log(1+(t-e+.5)/(e+.5))*(a+r*(o+1)/(r+o*(1-c+c*s/i)))},"calcBM25Score"),je=h(r=>(e,t,s)=>{let i=typeof r.fuzzy=="function"?r.fuzzy(e,t,s):r.fuzzy||!1,n=typeof r.prefix=="function"?r.prefix(e,t,s):r.prefix===!0,o=typeof r.boostTerm=="function"?r.boostTerm(e,t,s):1;return{term:e,fuzzy:i,prefix:n,termBoost:o}},"termToQuerySpec"),J={idField:"id",extractField:(r,e)=>r[e],tokenize:r=>r.split(Re),processTerm:r=>r.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(r,e)=>{typeof(console==null?void 0:console[r])=="function"&&console[r](e)},autoVacuum:!0},ue={combineWith:Y,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Ae},Te={combineWith:ye,prefix:(r,e,t)=>e===t.length-1},U={batchSize:1e3,batchWait:10},G={minDirtFactor:.1,minDirtCount:20},q=Object.assign(Object.assign({},U),G),Ve=h((r,e)=>{r.includes(e)||r.push(e)},"assignUniqueTerm"),de=h((r,e)=>{for(let t of e)r.includes(t)||r.push(t)},"assignUniqueTerms"),le=h(({score:r},{score:e})=>e-r,"byScore"),he=h(()=>new Map,"createMap"),j=h(r=>{let e=new Map;for(let t of Object.keys(r))e.set(parseInt(t,10),r[t]);return e},"objectToNumericMap"),T=h(r=>V(void 0,void 0,void 0,function*(){let e=new Map,t=0;for(let s of Object.keys(r))e.set(parseInt(s,10),r[s]),++t%1e3===0&&(yield be(0));return e}),"objectToNumericMapAsync"),be=h(r=>new Promise(e=>setTimeout(e,r)),"wait"),Re=/[\n\r\p{Z}\p{P}]+/u;var xe=Oe(ve(),1);var L,D,ze,X=class X{constructor(e){B(this,D);A(this,"mapData");A(this,"indexes");A(this,"ready");B(this,L,void 0);this.mapData=e,this.indexes=We(e),this.ready=this.populate(),te(this,L,ie(se(this,D,ze).bind(this),2e3))}async populate(){let{places:e,enterpriseLocations:t,enterpriseCategories:s}=this.indexes,i=this.mapData,n=[];return e.removeAll(),n=n.concat([e.addAllAsync(i.getByType("space")),e.addAllAsync(i.getByType("point-of-interest")),e.addAllAsync(i.getByType("connection")),e.addAllAsync(i.getByType("floor")),e.addAllAsync(i.getByType("door")),e.addAllAsync(i.getByType("annotation")),e.addAllAsync(i.getByType("area"))]),t&&(t==null||t.removeAll(),n.push(t.addAllAsync(i.getByType("enterprise-location")))),s&&(s==null||s.removeAll(),n.push(s.addAllAsync(i.getByType("enterprise-category")))),Promise.all(n)}async search(e,t={}){var a,d;await this.ready,Be.parse(t);let s=(0,xe.default)({},t,Pe),i=this.indexes.places.search(e,{fields:Object.keys(s.places.fields).filter(u=>s.places.fields[u])});s.places.limit&&(i=i.slice(0,s.places.limit));let n=(a=this.indexes.enterpriseLocations)==null?void 0:a.search(e,{fields:Object.keys(s.enterpriseLocations.fields).filter(u=>s.enterpriseLocations.fields[u])});n&&s.enterpriseLocations.limit&&(n=n.slice(0,s.enterpriseLocations.limit));let o=(d=this.indexes.enterpriseCategories)==null?void 0:d.search(e,{fields:Object.keys(s.enterpriseCategories.fields).filter(u=>s.enterpriseCategories.fields[u])});o&&s.enterpriseCategories.limit&&(o=o.slice(0,s.enterpriseCategories.limit));let c=De(this.mapData,{placesResult:i,locationsResult:n,categoriesResult:o});return ee(this,L).call(this,e),c}async suggest(e,t={}){await this.ready,Ne.parse(t);let s=[],{places:{enabled:i=!0}={},enterpriseLocations:{enabled:n=!0}={}}=t;return n&&this.indexes.enterpriseLocations&&this.indexes.enterpriseLocations.autoSuggest(e,{fields:["name","tags"],combineWith:"AND",prefix:!0,boost:{name:2,tags:1}}).forEach(o=>s.push(o)),i&&this.indexes.places.autoSuggest(e,{fields:["name"],combineWith:"AND",prefix:!0}).forEach(o=>s.push(o)),s.sort((o,c)=>c.score-o.score),this.mapData.Analytics.capture("$query-suggest",{query:e,suggestions:s.map(o=>o.suggestion)}),s}};L=new WeakMap,D=new WeakSet,ze=h(function(e){this.mapData.Analytics.capture("$query-search",{query:e})},"#trackSearch"),h(X,"InternalSearch");var Se=X;function De(r,{placesResult:e,locationsResult:t,categoriesResult:s}){let i=e.reduce((c,{id:a,match:d,score:u,__type:f})=>{let l=r.getById(f,a);return l!=null&&!ne.is(l)&&!oe.is(l)&&!re.is(l)&&!ce.is(l)&&!ae.is(l)&&c.push({type:l.__type,match:d,score:u,item:l}),c},[]),n;if(t){n=[];for(let{id:c,match:a,score:d}of t){let u=r.getById("enterprise-location",c);u&&n.push({type:u.__type,match:a,score:d,item:u})}}let o;if(s){o=[];for(let{id:c,match:a,score:d}of s){let u=r.getById("enterprise-category",c);u&&o.push({type:u.__type,match:a,score:d,item:u})}}return{places:i,enterpriseLocations:n,enterpriseCategories:o}}h(De,"processSearchResult");var Pe={places:{fields:{name:!0,description:!0}},enterpriseCategories:{fields:{name:!0,description:!1,"locations.name":!0}},enterpriseLocations:{fields:{name:!0,tags:!0,description:!0}}};function H(r){return r.normalize("NFD").replace(/[\u0300-\u036f|\u2019|\u0027|\']/g,"").toLowerCase()}h(H,"removeAccents");function We(r){let e=new O({fields:["name","description"],storeFields:["id","__type"],searchOptions:{fuzzy:.2,prefix:!0,boost:{name:2},combineWith:"AND"},extractField:(o,c)=>{let a=o[c];return typeof a=="string"?H(a):o[c]},processTerm:o=>$e.has(o)?"":o.toLowerCase()}),t=r.getByType("enterprise-location"),s;t&&(s=new O({fields:["name","tags","description"],storeFields:["id","__type"],searchOptions:{combineWith:"OR",prefix:!0,fuzzy:.2,boost:{name:3,tags:2,description:1}},extractField:(o,c)=>Array.isArray(o[c])?o[c].join(" "):typeof o[c]=="string"?H(o[c]):o[c]}));let i=r.getByType("enterprise-category"),n;return i&&(n=new O({fields:["name","description","locations.name"],storeFields:["id","__type"],extractField(o,c){return c==="locations.name"?o.locations.reduce((d,u)=>d+" ".concat(we," ")+u.name,"")+" ".concat(we):typeof o[c]=="string"?H(o[c]):o[c]},searchOptions:{combineWith:"OR",prefix:!0,fuzzy:.2,boost:{name:2,"locations.name":2}}})),{enterpriseCategories:n,enterpriseLocations:s,places:e}}h(We,"buildIndexes");var Be=_.object({places:_.object({fields:_.object({name:_.boolean().optional(),description:_.boolean().optional()}).optional(),limit:_.number().positive().optional()}).optional(),enterpriseCategories:_.object({fields:_.object({name:_.boolean().optional(),description:_.boolean().optional(),"locations.name":_.boolean().optional()}).optional(),limit:_.number().positive().optional()}).optional(),enterpriseLocations:_.object({fields:_.object({name:_.boolean().optional(),tags:_.boolean().optional(),description:_.boolean().optional()}).optional(),limit:_.number().positive().optional()}).optional()}),Ne=_.object({places:_.object({enabled:_.boolean().optional()}).optional(),enterpriseLocations:_.object({enabled:_.boolean().optional()}).optional()}),$e=new Set(["the","an","and","or","of","in","on","at","to","from","with","by","for"]),we="";export{Se as InternalSearch,H as removeAccents};
@@ -1 +1 @@
1
- import{$,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,a,aa,b,ba,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-UFHCKQ3M.js";import"./chunk-U67PM65J.js";import"./chunk-J5IUISYU.js";var export_Point=T.default;export{d as AJAXError,J as AttributionControl,y as BoxZoomHandler,q as CanvasSource,I as CooperativeGesturesHandler,E as DoubleClickZoomHandler,F as DragPanHandler,G as DragRotateHandler,t as EdgeInsets,e as Evented,Q as FullscreenControl,n as GeoJSONSource,O as GeolocateControl,u as Hash,o as ImageSource,C as KeyboardHandler,h as LngLat,i as LngLatBounds,K as LogoControl,L as Map,v as MapMouseEvent,w as MapTouchEvent,x as MapWheelEvent,N as Marker,j as MercatorCoordinate,M as NavigationControl,export_Point as Point,S as Popup,m as RasterDEMTileSource,l as RasterTileSource,P as ScaleControl,D as ScrollZoomHandler,s as Style,R as TerrainControl,B as TwoFingersTouchPitchHandler,A as TwoFingersTouchRotateHandler,z as TwoFingersTouchZoomHandler,H as TwoFingersTouchZoomRotateHandler,k as VectorTileSource,p as VideoSource,b as addProtocol,r as addSourceType,g as clearPrewarmedResources,a as config,Z as getMaxParallelImageRequests,V as getRTLTextPluginStatus,W as getVersion,X as getWorkerCount,$ as getWorkerUrl,ba as importScriptInWorkers,f as prewarm,c as removeProtocol,_ as setMaxParallelImageRequests,U as setRTLTextPlugin,Y as setWorkerCount,aa as setWorkerUrl};
1
+ import{$,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,a,aa,b,ba,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-YW4KFTPW.js";import"./chunk-VQGFL42S.js";import"./chunk-J5IUISYU.js";var export_Point=T.default;export{d as AJAXError,J as AttributionControl,y as BoxZoomHandler,q as CanvasSource,I as CooperativeGesturesHandler,E as DoubleClickZoomHandler,F as DragPanHandler,G as DragRotateHandler,t as EdgeInsets,e as Evented,Q as FullscreenControl,n as GeoJSONSource,O as GeolocateControl,u as Hash,o as ImageSource,C as KeyboardHandler,h as LngLat,i as LngLatBounds,K as LogoControl,L as Map,v as MapMouseEvent,w as MapTouchEvent,x as MapWheelEvent,N as Marker,j as MercatorCoordinate,M as NavigationControl,export_Point as Point,S as Popup,m as RasterDEMTileSource,l as RasterTileSource,P as ScaleControl,D as ScrollZoomHandler,s as Style,R as TerrainControl,B as TwoFingersTouchPitchHandler,A as TwoFingersTouchRotateHandler,z as TwoFingersTouchZoomHandler,H as TwoFingersTouchZoomRotateHandler,k as VectorTileSource,p as VideoSource,b as addProtocol,r as addSourceType,g as clearPrewarmedResources,a as config,Z as getMaxParallelImageRequests,V as getRTLTextPluginStatus,W as getVersion,X as getWorkerCount,$ as getWorkerUrl,ba as importScriptInWorkers,f as prewarm,c as removeProtocol,_ as setMaxParallelImageRequests,U as setRTLTextPlugin,Y as setWorkerCount,aa as setWorkerUrl};