"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6889],{66889:(e,t,r)=>{r.d(t,{search:()=>tp});var n=r(82263),o=r(84e3);let i={arabic:"ar",armenian:"am",bulgarian:"bg",czech:"cz",danish:"dk",dutch:"nl",english:"en",finnish:"fi",french:"fr",german:"de",greek:"gr",hungarian:"hu",indian:"in",indonesian:"id",irish:"ie",italian:"it",lithuanian:"lt",nepali:"np",norwegian:"no",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"rs",slovenian:"ru",spanish:"es",swedish:"se",tamil:"ta",turkish:"tr",ukrainian:"uk",sanskrit:"sk"},s={dutch:/[^A-Za-zàèéìòóù0-9_'-]+/gim,english:/[^A-Za-zàèéìòóù0-9_'-]+/gim,french:/[^a-z0-9äâàéèëêïîöôùüûœç-]+/gim,italian:/[^A-Za-zàèéìòóù0-9_'-]+/gim,norwegian:/[^a-z0-9_æøåÆØÅäÄöÖüÜ]+/gim,portuguese:/[^a-z0-9à-úÀ-Ú]/gim,russian:/[^a-z0-9а-яА-ЯёЁ]+/gim,spanish:/[^a-z0-9A-Zá-úÁ-ÚñÑüÜ]+/gim,swedish:/[^a-z0-9_åÅäÄöÖüÜ-]+/gim,german:/[^a-z0-9A-ZäöüÄÖÜß]+/gim,finnish:/[^a-z0-9äöÄÖ]+/gim,danish:/[^a-z0-9æøåÆØÅ]+/gim,hungarian:/[^a-z0-9áéíóöőúüűÁÉÍÓÖŐÚÜŰ]+/gim,romanian:/[^a-z0-9ăâîșțĂÂÎȘȚ]+/gim,serbian:/[^a-z0-9čćžšđČĆŽŠĐ]+/gim,turkish:/[^a-z0-9çÇğĞıİöÖşŞüÜ]+/gim,lithuanian:/[^a-z0-9ąčęėįšųūžĄČĘĖĮŠŲŪŽ]+/gim,arabic:/[^a-z0-9أ-ي]+/gim,nepali:/[^a-z0-9अ-ह]+/gim,irish:/[^a-z0-9áéíóúÁÉÍÓÚ]+/gim,indian:/[^a-z0-9अ-ह]+/gim,armenian:/[^a-z0-9ա-ֆ]+/gim,greek:/[^a-z0-9α-ωά-ώ]+/gim,indonesian:/[^a-z0-9]+/gim,ukrainian:/[^a-z0-9а-яА-ЯіїєІЇЄ]+/gim,slovenian:/[^a-z0-9螚ȎŠ]+/gim,bulgarian:/[^a-z0-9а-яА-Я]+/gim,tamil:/[^a-z0-9அ-ஹ]+/gim,sanskrit:/[^a-z0-9A-Zāīūṛḷṃṁḥśṣṭḍṇṅñḻḹṝ]+/gim,czech:/[^A-Z0-9a-zěščřžýáíéúůóťďĚŠČŘŽÝÁÍÉÓÚŮŤĎ-]+/gim},l=Object.keys(i);var a=r(95704);let u=Date.now().toString().slice(5),c=0,f=BigInt(1e3),d=BigInt(1e6),h=BigInt(1e9);function p(e,t){if(t.length<65535)Array.prototype.push.apply(e,t);else{let r=t.length;for(let n=0;n({...e,document:{...e.document,...t.reduce((e,t)=>{let r=t.split("."),n=r.pop(),o=e;for(let e of r)o[e]=o[e]??{},o=o[e];return o[n]=null,e},e.document)}}))}function _(e){return Array.isArray(e)?e.some(e=>_(e)):e?.constructor?.name==="AsyncFunction"}let D="intersection"in new Set;function A(...e){if(0===e.length)return new Set;if(1===e.length)return e[0];if(2===e.length){let t=e[0],r=e[1];if(D)return t.intersection(r);let n=new Set,o=t.size\d+)\$)?(?-?\d*\.?\d*)(?[dfs])/g,function(...e){let{width:r,type:n,position:o}=e[e.length-1],i=o?t[Number.parseInt(o)-1]:t.shift(),s=""===r?0:Number.parseInt(r);switch(n){case"d":return i.toString().padStart(s,"0");case"f":{let e=i,[t,n]=r.split(".").map(e=>Number.parseFloat(e));return"number"==typeof n&&n>=0&&(e=e.toFixed(n)),"number"==typeof t&&t>=0?e.toString().padStart(s,"0"):e.toString()}case"s":return s<0?i.toString().padEnd(-s," "):i.toString().padStart(s," ");default:return i}})}(R[e]??`Unsupported Orama Error code: ${e}`,...t));return r.code=e,"captureStackTrace"in Error.prototype&&Error.captureStackTrace(r),r}function x(e){return{raw:Number(e),formatted:m(e)}}function C(e){if(e.id){if("string"!=typeof e.id)throw M("DOCUMENT_ID_MUST_BE_STRING",typeof e.id);return e.id}return b()}let U={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},z={"string[]":"string","number[]":"number","boolean[]":"boolean","enum[]":"enum"};function L(e){return"string"==typeof e&&/^vector\[\d+\]$/.test(e)}function B(e){return"string"==typeof e&&U[e]}function V(e){let t=Number(e.slice(7,-1));switch(!0){case isNaN(t):throw M("INVALID_VECTOR_VALUE",e);case t<=0:throw M("INVALID_VECTOR_SIZE",e);default:return t}}function j(e){return{internalIdToId:e.internalIdToId}}function W(e,t){let{internalIdToId:r}=t;e.internalDocumentIDStore.idToInternalId.clear(),e.internalDocumentIDStore.internalIdToId=[];let n=r.length;for(let t=0;te.internalIdToId.length?F(e,t.toString()):t}function $(e,t){if(e.internalIdToId.length{for(let i of e)await i(t,r,n,o)})();for(let i of e)i(t,r,n,o)}function eo(e,t,r,n){if(e.some(_))return(async()=>{for(let o of e)await o(t,r,n)})();for(let o of e)o(t,r,n)}class ei{k;v;l=null;r=null;h=1;constructor(e,t){this.k=e,this.v=new Set(t)}updateHeight(){this.h=Math.max(ei.getHeight(this.l),ei.getHeight(this.r))+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return ei.getHeight(this.l)-ei.getHeight(this.r)}rotateLeft(){let e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){let e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(e){let t=new ei(e.k,e.v);return t.l=e.l?ei.fromJSON(e.l):null,t.r=e.r?ei.fromJSON(e.r):null,t.h=e.h,t}}class es{root=null;insertCount=0;constructor(e,t){void 0!==e&&void 0!==t&&(this.root=new ei(e,t))}insert(e,t,r=1e3){this.root=this.insertNode(this.root,e,t,r)}insertMultiple(e,t,r=1e3){for(let n of t)this.insert(e,n,r)}rebalance(){this.root&&(this.root=this.rebalanceNode(this.root))}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(e){let t=new es;return t.root=e.root?ei.fromJSON(e.root):null,t.insertCount=e.insertCount||0,t}insertNode(e,t,r,n){if(null===e)return new ei(t,[r]);let o=[],i=e,s=null;for(;null!==i;)if(o.push({parent:s,node:i}),ti.k))return i.v.add(r),e;else if(null===i.r){i.r=new ei(t,[r]),o.push({parent:i,node:i.r});break}else s=i,i=i.r;let l=!1;this.insertCount++%n==0&&(l=!0);for(let t=o.length-1;t>=0;t--){let{parent:r,node:n}=o[t];if(n.updateHeight(),l){let t=this.rebalanceNode(n);r?r.l===n?r.l=t:r.r===n&&(r.r=t):e=t}}return e}rebalanceNode(e){let t=e.getBalanceFactor();if(t>1){if(e.l&&e.l.getBalanceFactor()>=0)return e.rotateRight();else if(e.l)return e.l=e.l.rotateLeft(),e.rotateRight()}if(t<-1){if(e.r&&0>=e.r.getBalanceFactor())return e.rotateLeft();else if(e.r)return e.r=e.r.rotateRight(),e.rotateLeft()}return e}find(e){let t=this.findNodeByKey(e);return t?t.v:null}contains(e){return null!==this.find(e)}getSize(){let e=0,t=[],r=this.root;for(;r||t.length>0;){for(;r;)t.push(r),r=r.l;r=t.pop(),e++,r=r.r}return e}isBalanced(){if(!this.root)return!0;let e=[this.root];for(;e.length>0;){let t=e.pop();if(Math.abs(t.getBalanceFactor())>1)return!1;t.l&&e.push(t.l),t.r&&e.push(t.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,t){let r=this.findNodeByKey(e);r&&(1===r.v.size?this.root=this.removeNode(this.root,e):r.v=new Set([...r.v.values()].filter(e=>e!==t)))}findNodeByKey(e){let t=this.root;for(;t;)if(et.k))return t;t=t.r}return null}removeNode(e,t){if(null===e)return null;let r=[],n=e;for(;null!==n&&n.k!==t;)r.push(n),n=t=0;t--){let n=r[t];n.updateHeight();let o=this.rebalanceNode(n);if(t>0){let e=r[t-1];e.l===n?e.l=o:e.r===n&&(e.r=o)}else e=o}return e}rangeSearch(e,t){let r=new Set,n=[],o=this.root;for(;o||n.length>0;){for(;o;)n.push(o),o=o.l;if((o=n.pop()).k>=e&&o.k<=t)for(let e of o.v)r.add(e);if(o.k>t)break;o=o.r}return r}greaterThan(e,t=!1){let r=new Set,n=[],o=this.root;for(;o||n.length>0;){for(;o;)n.push(o),o=o.r;if(o=n.pop(),t&&o.k>=e||!t&&o.k>e)for(let e of o.v)r.add(e);else if(o.k<=e)break;o=o.l}return r}lessThan(e,t=!1){let r=new Set,n=[],o=this.root;for(;o||n.length>0;){for(;o;)n.push(o),o=o.l;if(o=n.pop(),t&&o.k<=e||!t&&o.ke)break;o=o.r}return r}}class el{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,t){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(t):this.numberToDocumentId.set(e,new Set([t]))}find(e){let t=this.numberToDocumentId.get(e);return t?Array.from(t):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,t){let r=this.numberToDocumentId.get(t);r&&(r.delete(e),0===r.size&&this.numberToDocumentId.delete(t))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(let t of this.numberToDocumentId.values())e+=t.size;return e}filter(e){let t=Object.keys(e);if(1!==t.length)throw Error("Invalid operation");let r=t[0];switch(r){case"eq":{let t=e[r],n=this.numberToDocumentId.get(t);return n?Array.from(n):[]}case"in":{let t=e[r],n=new Set;for(let e of t){let t=this.numberToDocumentId.get(e);if(t)for(let e of t)n.add(e)}return Array.from(n)}case"nin":{let t=new Set(e[r]),n=new Set;for(let[e,r]of this.numberToDocumentId.entries())if(!t.has(e))for(let e of r)n.add(e);return Array.from(n)}default:throw Error("Invalid operation")}}filterArr(e){let t=Object.keys(e);if(1!==t.length)throw Error("Invalid operation");let r=t[0];switch(r){case"containsAll":{let t=e[r].map(e=>this.numberToDocumentId.get(e)??new Set);if(0===t.length)return[];return Array.from(t.reduce((e,t)=>new Set([...e].filter(e=>t.has(e)))))}case"containsAny":{let t=e[r].map(e=>this.numberToDocumentId.get(e)??new Set);if(0===t.length)return[];return Array.from(t.reduce((e,t)=>new Set([...e,...t])))}default:throw Error("Invalid operation")}}static fromJSON(e){if(!e.numberToDocumentId)throw Error("Invalid Flat Tree JSON");let t=new el;for(let[r,n]of e.numberToDocumentId)t.numberToDocumentId.set(r,new Set(n));return t}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,t])=>[e,Array.from(t)])}}}function ea(e,t,r){let n=function(e,t,r){if(r<0)return -1;if(e===t)return 0;let n=e.length,o=t.length;if(0===n)return o<=r?o:-1;if(0===o)return n<=r?n:-1;let i=Math.abs(n-o);if(e.startsWith(t))return i<=r?i:-1;if(t.startsWith(e))return 0;if(i>r)return -1;let s=[];for(let e=0;e<=n;e++){s[e]=[e];for(let t=1;t<=o;t++)s[e][t]=0===e?t:0}for(let i=1;i<=n;i++){let n=1/0;for(let r=1;r<=o;r++)e[i-1]===t[r-1]?s[i][r]=s[i-1][r-1]:s[i][r]=Math.min(s[i-1][r]+1,s[i][r-1]+1,s[i-1][r-1]+1),n=Math.min(n,s[i][r]);if(n>r)return -1}return s[n][o]<=r?s[n][o]:-1}(e,t,r);return{distance:n,isBounded:n>=0}}class eu{k;s;c=new Map;d=new Set;e;w="";constructor(e,t,r){this.k=e,this.s=t,this.e=r}updateParent(e){this.w=e.w+this.s}addDocument(e){this.d.add(e)}removeDocument(e){return this.d.delete(e)}findAllWords(e,t,r,n){let o=[this];for(;o.length>0;){let i=o.pop();if(i.e){let{w:o,d:s}=i;if(r&&o!==t)continue;if(null!==S(e,o))if(n){if(!(Math.abs(t.length-o.length)<=n)||!ea(t,o,n).isBounded)continue;e[o]=[]}else e[o]=[];if(null!=S(e,o)&&s.size>0){let t=e[o];for(let e of s)t.includes(e)||t.push(e)}}i.c.size>0&&o.push(...i.c.values())}return e}insert(e,t){let r=this,n=0,o=e.length;for(;n0;){let{node:t,index:r,tolerance:s}=i.pop();if(t.w.startsWith(e)){t.findAllWords(o,e,!1,0);continue}if(s<0)continue;if(t.e){let{w:r,d:i}=t;if(r&&(ea(e,r,n).isBounded&&(o[r]=[]),void 0!==S(o,r)&&i.size>0)){let e=new Set(o[r]);for(let t of i)e.add(t);o[r]=Array.from(e)}}if(r>=e.length)continue;let l=e[r];if(t.c.has(l)){let e=t.c.get(l);i.push({node:e,index:r+1,tolerance:s})}for(let[e,n]of(i.push({node:t,index:r+1,tolerance:s-1}),t.c))i.push({node:n,index:r,tolerance:s-1}),e!==l&&i.push({node:n,index:r+1,tolerance:s-1})}}find(e){let{term:t,exact:r,tolerance:n}=e;if(n&&!r){let e={};return this._findLevenshtein(t,0,n,n,e),e}{let e=this,o=0,i=t.length;for(;o0&&0===t.c.size&&!t.e&&0===t.d.size;){let{parent:e,character:r}=n.pop();e.c.delete(r),t=e}return!0}removeDocumentByWord(e,t,r=!0){if(!e)return!0;let n=this,o=e.length;for(let i=0;i[e,t.toJSON()])}}static fromJSON(e){let t=new eu(e.k,e.s,e.e);return t.w=e.w,t.d=new Set(e.d),t.c=new Map(e?.c?.map(([e,t])=>[e,eu.fromJSON(t)])||[]),t}}class ec extends eu{constructor(){super("","",!1)}static fromJSON(e){let t=new ec;return t.w=e.w,t.s=e.s,t.e=e.e,t.k=e.k,t.d=new Set(e.d),t.c=new Map(e?.c?.map(([e,t])=>[e,eu.fromJSON(t)])||[]),t}toJSON(){return super.toJSON()}}class ef{point;docIDs;left;right;parent;constructor(e,t){this.point=e,this.docIDs=new Set(t),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(e,t=null){let r=new ef(e.point,e.docIDs);return r.parent=t,e.left&&(r.left=ef.fromJSON(e.left,r)),e.right&&(r.right=ef.fromJSON(e.right,r)),r}}class ed{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return`${e.lon},${e.lat}`}insert(e,t){let r=this.getPointKey(e),n=this.nodeMap.get(r);if(n)return void t.forEach(e=>n.docIDs.add(e));let o=new ef(e,t);if(this.nodeMap.set(r,o),null==this.root){this.root=o;return}let i=this.root,s=0;for(;;){if(0==s%2)if(e.lon0;){let{node:n,depth:o}=s.pop();if(null==n)continue;let a=i(e,n.point);(r?a<=t:a>t)&&l.push({point:n.point,docIDs:Array.from(n.docIDs)}),null!=n.left&&s.push({node:n.left,depth:o+1}),null!=n.right&&s.push({node:n.right,depth:o+1})}return n&&l.sort((t,r)=>{let o=i(e,t.point),s=i(e,r.point);return"asc"===n.toLowerCase()?o-s:s-o}),l}searchByPolygon(e,t=!0,r=null,n=!1){let o=[{node:this.root,depth:0}],i=[];for(;o.length>0;){let{node:r,depth:n}=o.pop();if(null==r)continue;null!=r.left&&o.push({node:r.left,depth:n+1}),null!=r.right&&o.push({node:r.right,depth:n+1});let s=ed.isPointInPolygon(e,r.point);(s&&t||!s&&!t)&&i.push({point:r.point,docIDs:Array.from(r.docIDs)})}let s=ed.calculatePolygonCentroid(e);if(r){let e=n?ed.vincentyDistance:ed.haversineDistance;i.sort((t,n)=>{let o=e(s,t.point),i=e(s,n.point);return"asc"===r.toLowerCase()?o-i:i-o})}return i}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(e){let t=new ed;return e.root&&(t.root=ef.fromJSON(e.root),t.buildNodeMap(t.root)),t}buildNodeMap(e){if(null==e)return;let t=this.getPointKey(e.point);this.nodeMap.set(t,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static calculatePolygonCentroid(e){let t=0,r=0,n=0,o=e.length;for(let i=0,s=o-1;io!=u>o&&n<(a-i)*(o-l)/(u-l)+i&&(r=!r)}return r}static haversineDistance(e,t){let r=Math.PI/180,n=e.lat*r,o=t.lat*r,i=(t.lat-e.lat)*r,s=(t.lon-e.lon)*r,l=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n)*Math.cos(o)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}static vincentyDistance(e,t){let r,n,o,i,s,l,a,u=1/298.257223563,c=(1-1/298.257223563)*6378137,f=Math.PI/180,d=e.lat*f,h=t.lat*f,p=(t.lon-e.lon)*f,g=Math.atan((1-u)*Math.tan(d)),m=Math.atan((1-u)*Math.tan(h)),y=Math.sin(g),b=Math.cos(g),S=Math.sin(m),I=Math.cos(m),O=p,w=1e3;do{let e=Math.sin(O),t=Math.cos(O);if(0===(n=Math.sqrt(I*e*(I*e)+(b*S-y*I*t)*(b*S-y*I*t))))return 0;i=Math.atan2(n,o=y*S+b*I*t),isNaN(a=o-2*y*S/(l=1-(s=b*I*e/n)*s))&&(a=0);let c=u/16*l*(4+u*(4-3*l));r=O,O=p+(1-c)*u*s*(i+c*n*(a+c*o*(-1+2*a*a)))}while(Math.abs(O-r)>1e-12&&--w>0);if(0===w)return NaN;let N=l*(0x24ffb2985f71-c*c)/(c*c),T=1+N/16384*(4096+N*(-768+N*(320-175*N))),v=N/1024*(256+N*(-128+N*(74-47*N)));return c*T*(i-v*n*(a+v/4*(o*(-1+2*a*a)-v/6*a*(-3+4*n*n)*(-3+4*a*a))))}}class eh{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,t){t?this.true.add(e):this.false.add(e)}delete(e,t){t?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(e){let t=new eh;return t.true=new Set(e.true),t.false=new Set(e.false),t}}class ep{size;vectors=new Map;constructor(e){this.size=e}add(e,t){t instanceof Float32Array||(t=new Float32Array(t));let r=eg(t,this.size);this.vectors.set(e,[r,t])}remove(e){this.vectors.delete(e)}find(e,t,r){return e instanceof Float32Array||(e=new Float32Array(e)),function(e,t,r,n,o){let i=eg(e,n),s=[];for(let l of t||r.keys()){let t=r.get(l);if(!t)continue;let a=t[0],u=t[1],c=0;for(let t=0;t=o&&s.push([l,f])}return s}(e,r,this.vectors,this.size,t)}toJSON(){let e=[];for(let[t,[r,n]]of this.vectors)e.push([t,[r,Array.from(n)]]);return{size:this.size,vectors:e}}static fromJSON(e){let t=new ep(e.size);for(let[r,[n,o]]of e.vectors)t.vectors.set(r,[n,new Float32Array(o)]);return t}}function eg(e,t){let r=0;for(let n=0;n1?e.avgFieldLength[t]=(e.avgFieldLength[t]*n-e.fieldLengths[t][o])/(n-1):e.avgFieldLength[t]=void 0,e.fieldLengths[t][o]=void 0,e.frequencies[t][o]=void 0}function eS(e,t,r){e.tokenOccurrences[t][r]--}function eI(e,t,r,n,o,i,s,l,a,u,c){if(L(s)){var f,d,h,p;return f=t,d=r,h=i,p=o,void f.vectorIndexes[d].node.add(p,h)}let g=n=>{let{type:i,node:s}=t.indexes[r];switch(i){case"Bool":s[n?"true":"false"].add(o);break;case"AVL":{let e=c?.avlRebalanceThreshold??1;s.insert(n,o,e);break}case"Radix":{let i=a.tokenize(n,l,r,!1);for(let n of(e.insertDocumentScoreParameters(t,r,o,i,u),i))e.insertTokenScoreParameters(t,r,o,i,n),s.insert(n,o);break}case"Flat":s.insert(n,o);break;case"BKD":s.insert(n,[o])}};if(!B(s))return g(i);let m=i.length;for(let e=0;e0&&g.set(o,!0);let y=h.length;for(let t=0;t[e,t]).sort((e,t)=>t[1]-e[1]);if(0===y.length)return[];if(1===f)return y;if(0===f){if(1===h)return y;for(let e of d)if(!g.get(e))return[];return y.filter(([e])=>{let t=p.get(e);return!!t&&Array.from(t.values()).some(e=>e===h)})}let b=y.filter(([e])=>{let t=p.get(e);return!!t&&Array.from(t.values()).some(e=>e===h)});if(b.length>0){let e=y.filter(([e])=>!b.some(([t])=>t===e)),t=Math.ceil(e.length*f);return[...b,...e.slice(0,t)]}return y}function ev(e){return e.searchableProperties}function e_(e){return e.searchablePropertiesWithTypes}function eD(e,t){let{indexes:r,vectorIndexes:n,searchableProperties:o,searchablePropertiesWithTypes:i,frequencies:s,tokenOccurrences:l,avgFieldLength:a,fieldLengths:u}=t,c={},f={};for(let e of Object.keys(r)){let{node:t,type:n,isArray:o}=r[e];switch(n){case"Radix":c[e]={type:"Radix",node:ec.fromJSON(t),isArray:o};break;case"Flat":c[e]={type:"Flat",node:el.fromJSON(t),isArray:o};break;case"AVL":c[e]={type:"AVL",node:es.fromJSON(t),isArray:o};break;case"BKD":c[e]={type:"BKD",node:ed.fromJSON(t),isArray:o};break;case"Bool":c[e]={type:"Bool",node:eh.fromJSON(t),isArray:o};break;default:c[e]=r[e]}}for(let e of Object.keys(n))f[e]={type:"Vector",isArray:!1,node:ep.fromJSON(n[e])};return{sharedInternalDocumentStore:e,indexes:c,vectorIndexes:f,searchableProperties:o,searchablePropertiesWithTypes:i,frequencies:s,tokenOccurrences:l,avgFieldLength:a,fieldLengths:u}}function eA(e){let{indexes:t,vectorIndexes:r,searchableProperties:n,searchablePropertiesWithTypes:o,frequencies:i,tokenOccurrences:s,avgFieldLength:l,fieldLengths:a}=e,u={};for(let e of Object.keys(r))u[e]=r[e].node.toJSON();let c={};for(let e of Object.keys(t)){let{type:r,node:n,isArray:o}=t[e];"Flat"===r||"Radix"===r||"AVL"===r||"BKD"===r||"Bool"===r?c[e]={type:r,node:n.toJSON(),isArray:o}:(c[e]=t[e],c[e].node=c[e].node.toJSON())}return{indexes:c,vectorIndexes:u,searchableProperties:n,searchablePropertiesWithTypes:o,frequencies:i,tokenOccurrences:s,avgFieldLength:l,fieldLengths:a}}function eE(e,t){e||(e=new Set);let r=t.length;for(let n=0;nt[1]-e[1]),o}function eP(e,t,r,n){return n?.enabled===!1?{disabled:!0}:function e(t,r,n,o,i){let s={language:t.tokenizer.language,sharedInternalDocumentStore:r,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(let[l,a]of Object.entries(n)){let n=`${i}${i?".":""}${l}`;if(!o.includes(n)){if("object"==typeof a&&!Array.isArray(a)){let i=e(t,r,a,o,n);p(s.sortableProperties,i.sortableProperties),s.sorts={...s.sorts,...i.sorts},s.sortablePropertiesWithTypes={...s.sortablePropertiesWithTypes,...i.sortablePropertiesWithTypes};continue}if(!L(a))switch(a){case"boolean":case"number":case"string":s.sortableProperties.push(n),s.sortablePropertiesWithTypes[n]=a,s.sorts[n]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:a};break;case"geopoint":case"enum":case"enum[]":case"boolean[]":case"number[]":case"string[]":continue;default:throw M("INVALID_SORT_SCHEMA_TYPE",Array.isArray(a)?"array":a,n)}}}return s}(e,t,r,(n||{}).unsortableProperties||[],"")}function eR(e,t,r,n){if(!e.enabled)return;e.isSorted=!1;let o=F(e.sharedInternalDocumentStore,r),i=e.sorts[t];i.orderedDocsToRemove.has(o)&&ez(e,t),i.docs.set(o,i.orderedDocs.length),i.orderedDocs.push([o,n])}function eM(e){if(!e.isSorted&&e.enabled){for(let t of Object.keys(e.sorts))!function(e,t){let r,n=e.sorts[t];switch(n.type){case"string":r=ex.bind(null,e.language);break;case"number":r=eC.bind(null);break;case"boolean":r=eU.bind(null)}n.orderedDocs.sort(r);let o=n.orderedDocs.length;for(let e=0;e!r.orderedDocsToRemove.has(e[0])),r.orderedDocsToRemove.clear())}function eL(e,t,r){if(!e.enabled)return;let n=e.sorts[t],o=F(e.sharedInternalDocumentStore,r);n.docs.get(o)&&(n.docs.delete(o),n.orderedDocsToRemove.set(o,!0))}function eB(e,t,r){if(!e.enabled)throw M("SORT_DISABLED");let n=r.property,o="DESC"===r.order,i=e.sorts[n];if(!i)throw M("UNABLE_TO_SORT_ON_UNKNOWN_FIELD",n,e.sortableProperties.join(", "));return ez(e,n),eM(e),t.sort((t,r)=>{let n=i.docs.get(F(e.sharedInternalDocumentStore,t[0])),s=i.docs.get(F(e.sharedInternalDocumentStore,r[0])),l=void 0!==n,a=void 0!==s;return l||a?l?a?o?s-n:n-s:-1:1:0}),t}function eV(e){return e.enabled?e.sortableProperties:[]}function ej(e){return e.enabled?e.sortablePropertiesWithTypes:{}}function eW(e,t){if(!t.enabled)return{enabled:!1};let r=Object.keys(t.sorts).reduce((e,r)=>{let{docs:n,orderedDocs:o,type:i}=t.sorts[r];return e[r]={docs:new Map(Object.entries(n).map(([e,t])=>[+e,t])),orderedDocsToRemove:new Map,orderedDocs:o,type:i},e},{});return{sharedInternalDocumentStore:e,language:t.language,sortableProperties:t.sortableProperties,sortablePropertiesWithTypes:t.sortablePropertiesWithTypes,sorts:r,enabled:!0,isSorted:t.isSorted}}function eF(e){if(!e.enabled)return{enabled:!1};for(let t of Object.keys(e.sorts))ez(e,t);eM(e);let t=Object.keys(e.sorts).reduce((t,r)=>{let{docs:n,orderedDocs:o,type:i}=e.sorts[r];return t[r]={docs:Object.fromEntries(n.entries()),orderedDocs:o,type:i},t},{});return{language:e.language,sortableProperties:e.sortableProperties,sortablePropertiesWithTypes:e.sortablePropertiesWithTypes,sorts:t,enabled:e.enabled,isSorted:e.isSorted}}let e$=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115],eJ={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},eG={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},eY="[aeiouy]",eH="[^aeiou][^aeiouy]*",eK=eY+"[aeiou]*",eq="^("+eH+")?"+eK+eH,eZ="^("+eH+")?"+eK+eH+"("+eK+")?$",eX="^("+eH+")?"+eK+eH+eK+eH,eQ="^("+eH+")?"+eY;function e0(e){let t,r,n,o,i,s;if(e.length<3)return e;let l=e.substring(0,1);if("y"==l&&(e=l.toUpperCase()+e.substring(1)),o=/^(.+?)([^s])s$/,(n=/^(.+?)(ss|i)es$/).test(e)?e=e.replace(n,"$1$2"):o.test(e)&&(e=e.replace(o,"$1$2")),o=/^(.+?)(ed|ing)$/,(n=/^(.+?)eed$/).test(e)){let t=n.exec(e);(n=new RegExp(eq)).test(t[1])&&(n=/.$/,e=e.replace(n,""))}else o.test(e)&&(t=o.exec(e)[1],(o=new RegExp(eQ)).test(t)&&(e=t,o=/(at|bl|iz)$/,i=RegExp("([^aeiouylsz])\\1$"),s=RegExp("^"+eH+eY+"[^aeiouwxy]$"),o.test(e)?e+="e":i.test(e)?(n=/.$/,e=e.replace(n,"")):s.test(e)&&(e+="e")));if((n=/^(.+?)y$/).test(e)){let r=n.exec(e);t=r?.[1],n=new RegExp(eQ),t&&n.test(t)&&(e=t+"i")}if((n=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/).test(e)){let o=n.exec(e);t=o?.[1],r=o?.[2],n=new RegExp(eq),t&&n.test(t)&&(e=t+eJ[r])}if((n=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/).test(e)){let o=n.exec(e);t=o?.[1],r=o?.[2],n=new RegExp(eq),t&&n.test(t)&&(e=t+eG[r])}if(o=/^(.+?)(s|t)(ion)$/,(n=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/).test(e)){let r=n.exec(e);t=r?.[1],n=new RegExp(eX),t&&n.test(t)&&(e=t)}else if(o.test(e)){let r=o.exec(e);t=r?.[1]??""+r?.[2]??"",(o=new RegExp(eX)).test(t)&&(e=t)}if((n=/^(.+?)e$/).test(e)){let r=n.exec(e);t=r?.[1],n=new RegExp(eX),o=new RegExp(eZ),i=RegExp("^"+eH+eY+"[^aeiouwxy]$"),t&&(n.test(t)||o.test(t)&&!i.test(t))&&(e=t)}return n=/ll$/,o=new RegExp(eX),n.test(e)&&o.test(e)&&(n=/.$/,e=e.replace(n,"")),"y"==l&&(e=l.toLowerCase()+e.substring(1)),e}function e1(e,t,r=!0){let n=`${this.language}:${e}:${t}`;return r&&this.normalizationCache.has(n)?this.normalizationCache.get(n):this.stopWords?.includes(t)?(r&&this.normalizationCache.set(n,""),""):(this.stemmer&&!this.stemmerSkipProperties.has(e)&&(t=this.stemmer(t)),t=function(e){let t=[];for(let n=0;n383?r:e$[r-192]||r}return String.fromCharCode(...t)}(t),r&&this.normalizationCache.set(n,t),t)}function e9(e,t,r,n=!0){let o;if(t&&t!==this.language)throw M("LANGUAGE_NOT_SUPPORTED",t);if("string"!=typeof e)return[e];let i=this.normalizeToken.bind(this,r??"");if(r&&this.tokenizeSkipProperties.has(r))o=[i(e,n)];else{let t=s[this.language];o=e.toLowerCase().split(t).map(e=>i(e,n)).filter(Boolean)}let l=function(e){for(;""===e[e.length-1];)e.pop();for(;""===e[0];)e.shift();return e}(o);return this.allowDuplicates?l:Array.from(new Set(l))}function e7(e={}){let t,r;if(e.language){if(!l.includes(e.language))throw M("LANGUAGE_NOT_SUPPORTED",e.language)}else e.language="english";if(e.stemming||e.stemmer&&!("stemming"in e))if(e.stemmer){if("function"!=typeof e.stemmer)throw M("INVALID_STEMMER_FUNCTION_TYPE");t=e.stemmer}else if("english"===e.language)t=e0;else throw M("MISSING_STEMMER",e.language);if(!1!==e.stopWords){if(r=[],Array.isArray(e.stopWords))r=e.stopWords;else if("function"==typeof e.stopWords)r=e.stopWords(r);else if(e.stopWords)throw M("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");if(!Array.isArray(r))throw M("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");for(let e of r)if("string"!=typeof e)throw M("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY")}let n={tokenize:e9,language:e.language,stemmer:t,stemmerSkipProperties:new Set(e.stemmerSkipProperties?[e.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(e.tokenizeSkipProperties?[e.tokenizeSkipProperties].flat():[]),stopWords:r,allowDuplicates:!!e.allowDuplicates,normalizeToken:e1,normalizationCache:new Map};return n.tokenize=e9.bind(n),n.normalizeToken=e1,n}let e5="fulltext";function e2(e,t){return e[1]-t[1]}function e6(e,t){return t[1]-e[1]}function e8(e,t,r){let n={},o=t.map(([e])=>e),i=e.documentsStore.getMultiple(e.data.docs,o),s=Object.keys(r),l=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e of s){let t;if("number"===l[e]){let{ranges:n}=r[e],o=n.length,i=Array.from({length:o});for(let e=0;e{for(let o of e){let e=`${o.from}-${o.to}`;!r?.has(e)&&n>=o.from&&n<=o.to&&(void 0===t[e]?t[e]=1:(t[e]++,r?.add(e)))}}}function e4(e,t,r){let n="boolean"===t?"false":"";return t=>{let o=t?.toString()??n;r?.has(o)||(e[o]=(e[o]??0)+1,r?.add(o))}}let te={reducer:(e,t,r,n)=>(t[n]=r,t),getInitialValue:e=>Array.from({length:e})},tt=["string","number","boolean"];function tr(e,t,r){let n=r.properties,o=n.length,i=e.index.getSearchablePropertiesWithTypes(e.data.index);for(let e=0;e$(e.internalDocumentIDStore,t)),l=e.documentsStore.getMultiple(e.data.docs,s),a=l.length,u=r.maxResult||Number.MAX_SAFE_INTEGER,c=[],f={};for(let e=0;e=u||(s.indexes.push(e),s.count++,r.perValue[i]=s,o.add(n))}c.push(Array.from(o)),f[t]=r}let d=function e(t,r=0){if(r+1===t.length)return t[r].map(e=>[e]);let n=t[r],o=e(t,r+1),i=[];for(let e of n)for(let t of o){let r=[e];p(r,t),i.push(r)}return i}(c),h=d.length,g=[];for(let e=0;e{let n=t.get(r);return void 0!==n&&t.set(r,0),n===e.length})})(i).sort((e,t)=>e-t),0!==o.indexes.length&&g.push(o)}let m=g.length,y=Array.from({length:m});for(let e=0;e({id:s[e],score:t[e][1],document:l[e]})),a=o.reducer.bind(null,n.values),u=o.getInitialValue(n.indexes.length),c=i.reduce(a,u);y[e]={values:n.values,result:c}}return y}function tn(e,t,r){let n,o,{term:i,properties:s}=t,l=e.data.index,a=e.caches.propertiesToSearch;if(!a){let t=e.index.getSearchablePropertiesWithTypes(l);a=(a=e.index.getSearchableProperties(l)).filter(e=>t[e].startsWith("string")),e.caches.propertiesToSearch=a}if(s&&"*"!==s){for(let e of s)if(!a.includes(e))throw M("UNKNOWN_INDEX",e,a.join(", "));a=a.filter(e=>s.includes(e))}let u=Object.keys(t.where??{}).length>0;u&&(n=e.index.searchByWhereClause(l,e.tokenizer,t.where,r));let c=void 0!==t.threshold&&null!==t.threshold?t.threshold:1;if(i||s){let s=e.documentsStore.count(e.data.docs);o=e.index.search(l,i||"",e.tokenizer,r,a,t.exact||!1,t.tolerance||0,t.boost||{},function(e){let t=e??{};return t.k=t.k??to.k,t.b=t.b??to.b,t.d=t.d??to.d,t}(t.relevance),s,n,c)}else if(u){let e=function(e,t){let r,n=function(e,t){let r=Object.keys(e);if(1!==r.length)return{isGeoOnly:!1};let n=r[0],o=e[n];if(void 0===t.indexes[n])return{isGeoOnly:!1};let{type:i}=t.indexes[n];return"BKD"===i&&o&&("radius"in o||"polygon"in o)?{isGeoOnly:!0,geoProperty:n,geoOperation:o}:{isGeoOnly:!1}}(t,e);if(!n.isGeoOnly||!n.geoProperty||!n.geoOperation)return null;let{node:o}=e.indexes[n.geoProperty],i=n.geoOperation;if("radius"in i){let{value:e,coordinates:t,unit:n="m",inside:s=!0,highPrecision:l=!1}=i.radius,a=T(e,n);return ek(r=o.searchByRadius(t,a,s,"asc",l),t,l)}if("polygon"in i){let{coordinates:e,inside:t=!0,highPrecision:n=!1}=i.polygon;return ek(r=o.searchByPolygon(e,t,"asc",n),ed.calculatePolygonCentroid(e),n)}return null}(l,t.where);o=e||(n?Array.from(n):[]).map(e=>[+e,0])}else o=Object.keys(e.documentsStore.getAll(e.data.docs)).map(e=>[+e,0]);return o}let to={k:1.2,b:.75,d:.5};function ti(e,t,r){let n,o=t.vector;if(o&&(!("value"in o)||!("property"in o)))throw M("INVALID_VECTOR_INPUT",Object.keys(o).join(", "));let i=e.data.index.vectorIndexes[o.property];if(!i)throw M("UNKNOWN_VECTOR_PROPERTY",o.property);let s=i.node.size;if(o?.value.length!==s){if(o?.property===void 0||o?.value.length===void 0)throw M("INVALID_INPUT_VECTOR","undefined",s,"undefined");throw M("INVALID_INPUT_VECTOR",o.property,s,o.value.length)}let l=e.data.index;return Object.keys(t.where??{}).length>0&&(n=e.index.searchByWhereClause(l,e.tokenizer,t.where,r)),i.node.find(o.value,t.similarity??.8,n)}function ts(e){return e[1]}function tl(e,t,r){let n=t.mode??e5;if(n===e5){let n=y();function o(){let o,i=Object.keys(e.data.index.vectorIndexes),s=t.facets&&Object.keys(t.facets).length>0,{limit:l=10,offset:a=0,distinctOn:u,includeVectors:c=!1}=t,f=!0===t.preflight,d=tn(e,t,r);if(t.sortBy)if("function"==typeof t.sortBy){let r=d.map(([e])=>e),n=e.documentsStore.getMultiple(e.data.docs,r).map((e,t)=>[d[t][0],d[t][1],e]);n.sort(t.sortBy),d=n.map(([e,t])=>[e,t])}else d=e.sorter.sortBy(e.data.sorting,d,t.sortBy).map(([t,r])=>[F(e.internalDocumentIDStore,t),r]);else d=d.sort(I);f||(o=u?function(e,t,r,n,o){let i=e.data.docs,s=new Map,l=[],a=new Set,u=t.length,c=0;for(let f=0;f=r+n)))break}return l}(e,d,a,l,u):ta(e,d,a,l));let h={elapsed:{formatted:"",raw:0},hits:[],count:d.length};return void 0!==o&&(h.hits=o.filter(Boolean),c||v(h,i)),s&&(h.facets=e8(e,d,t.facets)),t.groupBy&&(h.groups=tr(e,d,t.groupBy)),h.elapsed=e.formatElapsedTime(y()-n),h}async function i(){e.beforeSearch&&await eo(e.beforeSearch,e,t,r);let n=o();return e.afterSearch&&await en(e.afterSearch,e,t,r,n),n}return e.beforeSearch?.length||e.afterSearch?.length?i():o()}if("vector"===n)return function(e,t,r="english"){let n=y();function o(){let o=ti(e,t,r).sort(I),i=[];t.facets&&Object.keys(t.facets).length>0&&(i=e8(e,o,t.facets));let s=t.vector.property,l=t.includeVectors??!1,a=t.limit??10,u=t.offset??0,c=Array.from({length:a});for(let t=0;t[e,r/t])}(tn(e,t,r)),o=ti(e,t,r),i=t.hybridWeights;return function(e,t,r,n){let o=Math.max.apply(Math,e.map(ts)),i=Math.max.apply(Math,t.map(ts)),{text:s,vector:l}=n&&n.text&&n.vector?n:{text:.5,vector:.5},a=new Map,u=e.length,c=(e,t)=>e*s+t*l;for(let t=0;tt[1]-e[1])}(n,o,t.term??"",i)}(e,t,void 0);t.facets&&Object.keys(t.facets).length>0&&(r=e8(e,i,t.facets)),t.groupBy&&(o=tr(e,i,t.groupBy));let s=ta(e,i,t.offset??0,t.limit??10).filter(Boolean),l=y(),a={count:i.length,elapsed:{raw:Number(l-n),formatted:m(l-n)},hits:s,...r?{facets:r}:{},...o?{groups:o}:{}};return t.includeVectors||v(a,Object.keys(e.data.index.vectorIndexes)),a}async function i(){e.beforeSearch&&await eo(e.beforeSearch,e,t,void 0);let n=o();return e.afterSearch&&await en(e.afterSearch,e,t,r,n),n}return e.beforeSearch?.length||e.afterSearch?.length?i():o()}(e,t);throw M("INVALID_SEARCH_MODE",n)}function ta(e,t,r,n){let o=e.data.docs,i=Array.from({length:n}),s=new Set;for(let l=r;l({type:"page",content:e.document.title,contentWithHighlights:n.highlight(e.document.title),id:e.document.url,url:e.document.url}))}async function tf(e,t,r=[],i={}){"string"==typeof r&&(r=[r]);let s={...i,where:(0,n.B)({tags:r.length>0?{containsAll:r}:void 0,...i.where}),groupBy:{properties:["page_id"],maxResult:8,...i.groupBy}};t.length>0&&(s={...s,term:t,properties:["content"]});let l=(0,o.r)(t),a=await tl(e,s),u=[];for(let t of a.groups??[]){let r=t.values[0],n=e.documentsStore.get(e.data.docs,r);if(n)for(let e of(u.push({id:r,type:"page",content:n.content,contentWithHighlights:l.highlight(n.content),url:n.url}),t.result))"page"!==e.document.type&&u.push({id:e.document.id.toString(),content:e.document.content,contentWithHighlights:l.highlight(e.document.content),type:e.document.type,url:e.document.url})}return u}Symbol("orama.insertions"),Symbol("orama.removals"),r(65156);var td=new Map;async function th({from:e="/api/search",initOrama:t=e=>(function({schema:e,sort:t,language:r,components:n,id:o,plugins:i}){for(let t of(n||(n={}),i??[])){if(!("getComponents"in t)||"function"!=typeof t.getComponents)continue;let r=t.getComponents(e);for(let e of Object.keys(r))if(n[e])throw M("PLUGIN_COMPONENT_CONFLICT",e,t.name);n={...n,...r}}o||(o=b());let s=n.tokenizer,l=n.index,a=n.documentsStore,u=n.sorter;if(s=s?s.tokenize?s:e7(s):e7({language:r??"english"}),n.tokenizer&&r)throw M("NO_LANGUAGE_WITH_CUSTOM_TOKENIZER");let c={idToInternalId:new Map,internalIdToId:[],save:j,load:W};l||={create:function e(t,r,n,o,i=""){for(let[s,l]of(o||(o={sharedInternalDocumentStore:r,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}}),Object.entries(n))){let n=`${i}${i?".":""}${s}`;if("object"==typeof l&&!Array.isArray(l)){e(t,r,l,o,n);continue}if(L(l))o.searchableProperties.push(n),o.searchablePropertiesWithTypes[n]=l,o.vectorIndexes[n]={type:"Vector",node:new ep(V(l)),isArray:!1};else{let e=/\[/.test(l);switch(l){case"boolean":case"boolean[]":o.indexes[n]={type:"Bool",node:new eh,isArray:e};break;case"number":case"number[]":o.indexes[n]={type:"AVL",node:new es(0,[]),isArray:e};break;case"string":case"string[]":o.indexes[n]={type:"Radix",node:new ec,isArray:e},o.avgFieldLength[n]=0,o.frequencies[n]={},o.tokenOccurrences[n]={},o.fieldLengths[n]={};break;case"enum":case"enum[]":o.indexes[n]={type:"Flat",node:new el,isArray:e};break;case"geopoint":o.indexes[n]={type:"BKD",node:new ed,isArray:e};break;default:throw M("INVALID_SCHEMA_TYPE",Array.isArray(l)?"array":l,n)}o.searchableProperties.push(n),o.searchablePropertiesWithTypes[n]=l}}return o},insert:eI,remove:ew,insertDocumentScoreParameters:em,insertTokenScoreParameters:ey,removeDocumentScoreParameters:eb,removeTokenScoreParameters:eS,calculateResultScores:eN,search:eT,searchByWhereClause:function e(t,r,n,o){if("and"in n&&n.and&&Array.isArray(n.and)){let i=n.and;return 0===i.length?new Set:A(...i.map(n=>e(t,r,n,o)))}if("or"in n&&n.or&&Array.isArray(n.or)){let i=n.or;return 0===i.length?new Set:i.map(n=>e(t,r,n,o)).reduce((e,t)=>k(e,t),new Set)}if("not"in n&&n.not){let i=n.not,s=new Set,l=t.sharedInternalDocumentStore;for(let e=1;e<=l.internalIdToId.length;e++)s.add(e);let a=e(t,r,i,o),u=new Set;for(let e of s)a.has(e)||u.add(e);return u}let i=Object.keys(n),s=i.reduce((e,t)=>({[t]:new Set,...e}),{});for(let e of i){let i=n[e];if(void 0===t.indexes[e])throw M("UNKNOWN_FILTER_PROPERTY",e);let{node:l,type:a,isArray:u}=t.indexes[e];if("Bool"===a){let t=i?l.true:l.false;s[e]=k(s[e],t);continue}if("BKD"===a){let t;if("radius"in i)t="radius";else if("polygon"in i)t="polygon";else throw Error(`Invalid operation ${i}`);if("radius"===t){let{value:r,coordinates:n,unit:o="m",inside:a=!0,highPrecision:u=!1}=i[t],c=T(r,o),f=l.searchByRadius(n,c,a,void 0,u);s[e]=eE(s[e],f)}else{let{coordinates:r,inside:n=!0,highPrecision:o=!1}=i[t],a=l.searchByPolygon(r,n,void 0,o);s[e]=eE(s[e],a)}continue}if("Radix"===a&&("string"==typeof i||Array.isArray(i))){for(let t of[i].flat())for(let n of r.tokenize(t,o,e)){let t=l.find({term:n,exact:!0});s[e]=function(e,t){e||(e=new Set);let r=Object.keys(t),n=r.length;for(let o=0;o1)throw M("INVALID_FILTER_OPERATION",c.length);if("Flat"===a){let t=new Set(u?l.filterArr(i):l.filter(i));s[e]=k(s[e],t);continue}if("AVL"===a){let t,r=c[0],n=i[r];switch(r){case"gt":t=l.greaterThan(n,!1);break;case"gte":t=l.greaterThan(n,!0);break;case"lt":t=l.lessThan(n,!1);break;case"lte":t=l.lessThan(n,!0);break;case"eq":t=l.find(n)??new Set;break;case"between":{let[e,r]=n;t=l.rangeSearch(e,r);break}default:throw M("INVALID_FILTER_OPERATION",r)}s[e]=k(s[e],t)}}return A(...Object.values(s))},getSearchableProperties:ev,getSearchablePropertiesWithTypes:e_,load:eD,save:eA},u||={create:eP,insert:eR,remove:eL,save:eF,load:eW,sortBy:eB,getSortableProperties:eV,getSortablePropertiesWithTypes:ej},a||={create:J,get:G,getMultiple:Y,getAll:H,store:K,remove:q,count:Z,load:X,save:Q};var f=n;let d={formatElapsedTime:x,getDocumentIndexId:C,getDocumentProperties:O,validateSchema:function e(t,r){for(let[n,o]of Object.entries(r)){let r=t[n];if(void 0!==r&&("geopoint"!==o||"object"!=typeof r||"number"!=typeof r.lon||"number"!=typeof r.lat)&&("enum"!==o||"string"!=typeof r&&"number"!=typeof r)){if("enum[]"===o&&Array.isArray(r)){let e=r.length;for(let t=0;t{for(let r of e)await r(t)})();for(let r of e)r(t)}(S,y),y})({schema:{_:"string"},language:e})}){let r=td.get(e);if(r)return r;let n=async function(){let r=await fetch(e);if(!r.ok)throw Error(`failed to fetch exported search indexes from ${e}, make sure the search database is exported and available for client.`);let n=await r.json(),o=new Map;if("i18n"===n.type)return await Promise.all(Object.entries(n.data).map(async([e,r])=>{let n=await t(e);tu(n,r),o.set(e,{type:r.type,db:n})})),o;let i=await t();return tu(i,n),o.set("",{type:n.type,db:i}),o}();return td.set(e,n),n}async function tp(e,t){let{tag:r,locale:n}=t,o=(await th(t)).get(n??"");return o?"simple"===o.type?tc(o,e):tf(o.db,e,r):[]}},82263:(e,t,r)=>{r.d(t,{B:()=>function e(t,r=!1){for(let n of Object.keys(t))void 0===t[n]&&delete t[n],r&&"object"==typeof t[n]&&null!==t[n]?e(t[n],r):r&&Array.isArray(t[n])&&t[n].forEach(t=>e(t,r));return t}})},84e3:(e,t,r)=>{function n(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(e){let t="string"==typeof e?function(e){let t=e.trim();if(0===t.length)return null;let r=Array.from(new Set(t.split(/\s+/).map(e=>e.trim()).filter(Boolean)));if(0===r.length)return null;let o=r.map(n).join("|");return RegExp(`(${o})`,"gi")}(e):e;return{highlight(e){if(!t)return[{type:"text",content:e}];let r=[],n=0;for(let o of e.matchAll(t))no})}}]);