Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appbaseio/searchbase

Package Overview
Dependencies
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appbaseio/searchbase - npm Package Compare versions

Comparing version 1.6.2-beta to 1.6.3-beta

2

dist/@appbaseio/searchbase.umd.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Searchbase={})}(this,(function(e){"use strict";function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function o(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var u=function(){function e(){this.observers=[]}var t=e.prototype;return t.subscribe=function(e,t){this.observers.push({callback:e,properties:t})},t.unsubscribe=function(e){this.observers=e?this.observers.filter((function(t){return t.callback!==e?t:null})):[]},t.next=function(e,t,r){var n=r;!n&&window&&(n=window),this.observers.forEach((function(r){(void 0===r.properties||r.properties instanceof Array&&r.properties.length&&r.properties.includes(t)||"string"==typeof r.properties&&r.properties&&r.properties===t)&&r.callback.call(n,e)}))},e}(),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var l=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var r=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:c);!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function f(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function g(e){var t=new FileReader,r=f(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&s&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=f(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=c(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[c(e)]},d.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},d.prototype.set=function(e,t){this.map[c(e)]=l(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),h(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),h(e)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(e,t){var r,n,s=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(r=t.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function q(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},q.error=function(){var e=new q(null,{status:0,statusText:""});return e.type="error",e};var w=[301,302,303,307,308];q.redirect=function(e,t){if(-1===w.indexOf(t))throw new RangeError("Invalid status code");return new q(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,r){return new Promise((function(n,i){var o=new b(e,r);if(o.signal&&o.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var s="response"in a?a.response:a.responseText;n(new q(s,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",u)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=d,e.Request=b,e.Response=q),t.Headers=d,t.Request=b,t.Response=q,t.fetch=S}({})}(r),delete r.fetch.polyfill,(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t}));l.fetch,l.Headers,l.Request,l.Response;function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(o="=",i%1);n+=o.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}function p(e,t){if(null==e&&!t)throw new Error("appbase-analytics: query or queryID must be present to register a click/conversion event")}var f={init:function(e){void 0===e&&(e={});var t={credentials:e.credentials,index:e.index,url:e.url,userID:e.userID,globalEventData:e.globalEventData,queryID:"",headers:null};return function(e){if(!e)throw new Error("appbase-analytics: A valid index must be present to record analytics events.")}(t.index),function(e){if(!e)throw new Error("appbase-analytics: Auth credentials is missing.")}(t.credentials),function(e){if(!e)throw new Error("appbase-analytics: URL is missing.")}(t.url),t._request=function(e,r,n){var s=h({},r,{user_id:t.userID,event_data:h({},r&&r.event_data,{},t.globalEventData)});return l(t.url+"/"+t.index+"/_analytics/"+e,{method:"PUT",headers:h({},t.headers,{"Content-Type":"application/json",Authorization:"Basic "+d(t.credentials)}),body:JSON.stringify(s)}).then((function(e){n&&n(null,e)})).catch((function(e){console.error(e),n&&n(e,null)}))},t.search=function(e,r){p(e.query,e.queryID);if(t._request){var n={query:e.query,query_id:e.queryID,event_data:e.eventData,filters:e.filters,hits:e.hits};t._request("search",n,(function(e,n){n&&n.json().then((function(e){e&&e.query_id&&(t.queryID=e.query_id)})).catch((function(e){console.error(e)})),r&&r(e,n)}))}},t.click=function(e,r){if(p(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={click_on:e.objects,click_type:e.isSuggestionClick?"suggestion":"result",query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("click",n,r)}},t.conversion=function(e,r){if(p(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={conversion_on:e.objects,query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("conversion",n,r)}},t.setUserID=function(e){t.userID=e},t.setGlobalEventData=function(e){t.globalEventData=e},t.setHeaders=function(e){t.headers=e},t}};function g(e){return"SearchBase: "+e}var y={invalidIndex:g("Please provide a valid index."),invalidURL:g("Please provide a valid url."),invalidComponentId:g("Please provide component id."),invalidDataField:g("Please provide data field."),dataFieldAsArray:g("Only components with `search` type supports the multiple data fields. Please define `dataField` as a string.")},m=["key","key.autosuggest"],v="search",b=function(e){var t=[];return e&&(t=[].concat(e).map((function(e){var t=function(e){var t=s({},e);return t.highlight&&Object.keys(t.highlight).forEach((function(e){var r,n=t.highlight[e][0];t._source=s({},t._source,((r={})[e]=n,r))})),t}(e);return Object.keys(t).filter((function(e){return"_source"!==e})).reduce((function(e,r){return e[r]=t[r],e}),s({},t._source))}))),t},_=function(e){if(e){if(!Array.isArray(e))return[e];if(e.length){var t=[];return e.forEach((function(e){"string"==typeof e?t.push(e):e.field&&t.push(e.field)})),t}}};var q=function(e){if(e&&Array.isArray(e)&&e.length){var t=[];return e.forEach((function(e){var r;r=e.weight,!Number.isNaN(parseFloat(r))&&Number.isFinite(r)?t.push(e.weight):t.push(1)})),t}};function w(e,t){var r=[];return function e(t){t&&Object.keys(t)&&Object.keys(t).forEach((function(n){t[n]&&("string"==typeof t[n]?r=[].concat(r,[t[n]]):Array.isArray(t[n])?r=[].concat(r,t[n]):"object"==typeof t[n]&&e(t[n]))}))}(e),r=r.filter((function(e){return e!==t}))}var S=function(e){return"object"==typeof e?Array.isArray(e)?function e(t){return t.reduce((function(t,r){return t.concat(Array.isArray(r)?e(r):r)}),[])}(e):null:e};function C(e){return void 0===e&&(e=""),e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var R=function(e,t,r,n,i){void 0===e&&(e=[]),void 0===r&&(r=""),void 0===n&&(n=!0),void 0===i&&(i=!1);var a=[],u=[],c=!1,l=r||"",h=function(e,t,r){if((c||l.trim().split(" ").some((function(t){return String(e).toLowerCase().includes(t)})))&&!u.includes(e)||r._promoted){var i=s({},{label:e,value:e,source:r});if(u=[].concat(u,[e]),a=[].concat(a,[i]),n)return!0}return!1},d=function e(t,r,s){if(void 0===r&&(r=""),void 0===s&&(s=t),"object"==typeof t){var i=r.split("."),o=t[i[0]];if(o)if(i.length>1){var a=r.substring(i[0].length+1);Array.isArray(o)?o.forEach((function(t){e(t,a,s)})):e(o,a,s)}else{var u=S(o);if(u){if(Array.isArray(u)){if(n)return u.some((function(e){return h(e,0,s)}));u.forEach((function(e){return h(e,0,s)}))}return h(u,0,s)}}}return!1},p=function(){n?t.forEach((function(t){e.some((function(e){return d(t,e)}))})):t.forEach((function(t){e.forEach((function(e){d(t,e)}))}))};return p(),a.length<t.length&&!c&&(c=!0,p()),i?function(e){var t=e.suggestions,r=e.currentValue,n=e.wordsToShowAfterHighlight,i={};if(r){var a=r.trim();return t.reduce((function(e,t){var r=t.label,u=o(t,["label"]),c=(new DOMParser).parseFromString(r,"text/html").documentElement.textContent,l="^("+C(a)+")\\w+",h=new RegExp(l,"i"),d=h.exec(c);if(d||(l="^("+C(a)+")",d=(h=new RegExp(l,"i")).exec(c)),d){var p=c.slice(d.index,c.length).slice(a.length).split(" ").slice(0,n+1).join(" "),f=a+'<mark class="highlight">'+p+"</mark>",g=""+a+p;return i[f]?e:(i[f]=1,[].concat(e,[s({},u,{label:f,value:g,isPredictiveSuggestion:!0})]))}return e}),[])}return[]}({suggestions:a,currentValue:r,wordsToShowAfterHighlight:!0}):a};function F(e,t){if(e===t)return!0;if(!(e instanceof Object&&t instanceof Object))return!1;if(e.constructor!==t.constructor)return!1;for(var r in e)if(e.hasOwnProperty(r)){if(!t.hasOwnProperty(r))return!1;if(e[r]!==t[r]){if("object"!=typeof e[r])return!1;if(!F(e[r],t[r]))return!1}}for(var n in t)if(t.hasOwnProperty(n)&&!e.hasOwnProperty(n))return!1;return!0}var D={id:"id",type:"type",react:"react",queryFormat:"queryFormat",dataField:"dataField",categoryField:"categoryField",categoryValue:"categoryValue",nestedField:"nestedField",from:"from",size:"size",sortBy:"sortBy",value:"value",aggregationField:"aggregationField",aggregationSize:"aggregationSize",after:"after",includeNullValues:"includeNullValues",includeFields:"includeFields",excludeFields:"excludeFields",fuzziness:"fuzziness",searchOperators:"searchOperators",highlight:"highlight",highlightField:"highlightField",customHighlight:"customHighlight",interval:"interval",aggregations:"aggregations",missingLabel:"missingLabel",showMissing:"showMissing",enableSynonyms:"enableSynonyms",selectAllLabel:"selectAllLabel",pagination:"pagination",queryString:"queryString",enablePopularSuggestions:"enablePopularSuggestions",showDistinctSuggestions:"showDistinctSuggestions",error:"error",defaultQuery:"defaultQuery",customQuery:"customQuery",requestStatus:"requestStatus",results:"results",aggregationData:"aggregationData",micStatus:"micStatus",micInstance:"micInstance",micActive:"micActive",micInactive:"micInactive",micDenied:"micDenied",query:"query",requestPending:"loading",appbaseSettings:"appbaseConfig",suggestions:"suggestions",queryId:"queryId",recentSearches:"recentSearches",distinctField:"distinctField",distinctFieldConfig:"distinctFieldConfig",onMicClick:"handleMicClick",triggerDefaultQuery:"triggerDefaultQuery",triggerCustomQuery:"triggerCustomQuery",recordClick:"recordClick",recordConversions:"recordConversions",subscribeToStateChanges:"subscribeToStateChanges",unsubscribeToStateChanges:"unsubscribeToStateChanges",setDataField:"setDataField",setValue:"setValue",setSize:"setSize",setFrom:"setFrom",setFuzziness:"setFuzziness",setIncludeFields:"setIncludeFields",setExcludeFields:"setExcludeFields",setSortBy:"setSortBy",setReact:"setReact",setDefaultQuery:"setDefaultQuery",setCustomQuery:"setCustomQuery",setAfter:"setAfter"};function A(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(o="=",i%1);n+=o.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}var E="SearchBase",O="SearchBox",x="SearchComponent",I={MONGODB:"mongodb",ELASTICSEARCH:"elasticsearch"},Q="array",k="function",P="object",j="number",T="boolean",B="string";function z(e,t,r,n){void 0===e&&(e={}),void 0===t&&(t={}),void 0===r&&(r=""),void 0===n&&(n="");var s=Object.keys(e).filter((function(t){return!!e[t]})),i=Object.keys(t),o=[],a=[];i.forEach((function(e){var r=t[e];r.components.includes(n)&&(a.push(e),r.required&&o.push(e))})),o.forEach((function(e){if(!s.includes(e))throw new Error(e+" is required for <"+n+" /> component when used with the "+r+" Search backend.")})),s.forEach((function(r){if(!a.includes(r))throw new Error("<"+n+" /> component doesn't accept a property "+r+".");var s,i=Array.isArray(t[r].type)?t[r].type:[].concat(t[r].type),o=typeof(s=e[r])===P?Array.isArray(s)?Q:P:typeof s;if(!i.includes(o))throw new Error("<"+n+" /> component accepts a property "+r+" with type(s) ["+i.join(", ")+"], but type was set as "+o+".")}))}var M={mongodb:{url:{components:[E],type:B,required:!0},index:{components:[E,O,x],type:B,required:!1},credentials:{components:[E],type:B,required:!1},headers:{components:[E,O,x],type:P,required:!1},transformRequest:{components:[E,O,x],type:k,required:!1},transformResponse:{components:[E,O,x],type:k,required:!1},mongodb:{components:[E],type:P,required:!1},id:{components:[O,x],type:B,required:!0},dataField:{components:[O,x],type:[Q,B],required:!1},autocompleteField:{components:[O,x],type:[Q,B],required:!1},react:{components:[O,x],type:P,required:!1},size:{components:[O,x],type:j,required:!1},from:{components:[O,x],type:j,required:!1},includeFields:{components:[O,x],type:Q,required:!1},excludeFields:{components:[O,x],type:Q,required:!1},sortBy:{components:[O,x],type:B,required:!1},aggregationSize:{components:[O,x],type:j,required:!1},highlight:{components:[O,x],type:T,required:!1},highlightField:{components:[O,x],type:B,required:!1},highlightConfig:{components:[O,x],type:P,required:!1},fuzziness:{components:[O,x],type:[B,j],required:!1},enableSynonyms:{components:[O,x],type:T,required:!1},searchOperators:{components:[O,x],type:T,required:!1},queryString:{components:[O,x],type:B,required:!1},defaultQuery:{components:[O,x],type:[k,P],required:!1},customQuery:{components:[O,x],type:[k,P],required:!1},value:{components:[O,x],type:[B,Q,P],required:!1},type:{components:[O,x],type:B,required:!1}},elasticsearch:{url:{components:[E],type:B,required:!0},index:{components:[E,O,x],type:B,required:!1},credentials:{components:[E],type:B,required:!0},appbaseConfig:{components:[E],type:P,required:!1},headers:{components:[E,O,x],type:P,required:!1},transformRequest:{components:[E,O,x],type:k,required:!1},transformResponse:{components:[E,O,x],type:k,required:!1},id:{components:[O,x],type:B,required:!0},dataField:{components:[O,x],type:[Q,B],required:!1},autocompleteField:{components:[O,x],type:[Q,B],required:!1},queryFormat:{components:[O,x],type:B,required:!1},react:{components:[O,x],type:P,required:!1},size:{components:[O,x],type:j,required:!1},from:{components:[O,x],type:j,required:!1},includeFields:{components:[O,x],type:Q,required:!1},excludeFields:{components:[O,x],type:Q,required:!1},sortBy:{components:[O,x],type:B,required:!1},aggregationField:{components:[O,x],type:B,required:!1},aggregationSize:{components:[O,x],type:j,required:!1},highlight:{components:[O,x],type:T,required:!1},highlightField:{components:[O,x],type:B,required:!1},customHighlight:{components:[O,x],type:P,required:!1},categoryField:{components:[O,x],type:B,required:!1},categoryValue:{components:[O,x],type:B,required:!1},nestedField:{components:[O,x],type:B,required:!1},fuzziness:{components:[O,x],type:[B,j],required:!1},enableSynonyms:{components:[O,x],type:T,required:!1},searchOperators:{components:[O,x],type:T,required:!1},queryString:{components:[O,x],type:B,required:!1},distinctField:{components:[O,x],type:B,required:!1},distinctFieldConfig:{components:[O,x],type:P,required:!1},enableRecentSuggestions:{components:[O],type:T,required:!1},enablePopularSuggestions:{components:[O],type:T,required:!1},recentSuggestionsConfig:{components:[O],type:P,required:!1},popularSuggestionsConfig:{components:[O],type:P,required:!1},enablePredictiveSuggestions:{components:[O],type:T,required:!1},maxPredictedWords:{components:[O],type:j,required:!1},urlField:{components:[O],type:B,required:!1},pagination:{components:[x],type:T,required:!1},after:{components:[x],type:P,required:!1},showMissing:{components:[x],type:T,required:!1},includeNullValues:{components:[x],type:T,required:!1},interval:{components:[x],type:j,required:!1},aggregations:{components:[x],type:Q,required:!1},defaultQuery:{components:[O,x],type:[k,P],required:!1},customQuery:{components:[O,x],type:[k,P],required:!1},value:{components:[O,x],type:[B,Q,P],required:!1},type:{components:[O,x],type:B,required:!1},clearOnQueryChange:{components:[O,x],type:T,required:!1}}},V=function(){function e(e){var t=e.index,r=e.url,n=e.credentials,i=e.headers,o=e.mongodb,a=e.appbaseConfig,u=e.transformRequest,c=e.transformResponse,l=I[o?"MONGODB":"ELASTICSEARCH"];z({index:t,url:r,credentials:n,headers:i,mongodb:o,appbaseConfig:a,transformRequest:u,transformResponse:c},M[l],l,E),this.index=t,this.url=r,this.credentials=n||"",this.mongodb=o,a&&(this.appbaseConfig=a),u&&(this.transformRequest=u),c&&(this.transformResponse=c);var h=(a||{}).enableTelemetry;this.headers=s({Accept:"application/json","Content-Type":"application/json","x-search-client":"Searchbase Headless"},!1===h?{"X-Enable-Telemetry":!1}:{}),this.credentials&&(this.headers=s({},this.headers,{Authorization:"Basic "+A(this.credentials)})),i&&this.setHeaders(i),this.mongodb||(this._analyticsInstance=f.init({index:t,url:r,credentials:n}))}var t=e.prototype;return t.setHeaders=function(e){this.headers=s({},this.headers,e)},t.setQueryID=function(e){this._queryId=e},e}(),L=function(){function e(e){var t=this;n(this,"setRaw",(function(e){t.raw=e,e.hits&&e.hits.hits&&t.setData(e.hits.hits)})),this.data=e||[]}return e.prototype.setData=function(e){var t,r=b(e);if(this.promotedData.length){var n=this.promotedData.map((function(e){return e._id})).filter(Boolean);n&&(r=r.filter((function(e){return!n.includes(e._id)}))),r=[].concat(this.promotedData.map((function(e){return s({},e,{_promoted:!0})})),r)}this.parseResults?this.data=this.parseResults(r,e):this.data=r,this.data=(void 0===(t=this.data)&&(t=[]),t.map((function(e,t){return s({},e,{_click_id:t+1})})))},r(e,[{key:"numberOfResults",get:function(){return this.raw&&this.raw.hits?"object"==typeof this.raw.hits.total?this.raw.hits.total.value:this.raw.hits.total:0}},{key:"time",get:function(){return this.raw?this.raw.took:0}},{key:"hidden",get:function(){return this.raw&&this.raw.hits&&this.raw.hits.hidden||0}},{key:"promotedData",get:function(){return this.raw&&this.raw.promoted&&this.raw.promoted||[]}},{key:"promoted",get:function(){return this.promotedData.length||0}},{key:"rawData",get:function(){return this.raw||{}}},{key:"customData",get:function(){return this.raw&&this.raw.customData&&this.raw.customData||{}}}]),e}(),H=function(){function e(e){this.data=e||[]}var t=e.prototype;return t.setRaw=function(e){this.raw=e,(null==e?void 0:e.after_key)&&this.setAfterKey(e.after_key)},t.setAfterKey=function(e){this.afterKey=e},t.setData=function(e,t,r){void 0===r&&(r=!1);var n,i,o=(n=e,void 0===(i=t)&&(i=[]),i.map((function(e){var t=e.doc_count,r=e.key,i=e[n];return s({_doc_count:t,_key:void 0!==r[n]?r[n]:r},i)})));this.data=r?[].concat(this.data,o):o},r(e,[{key:"rawData",get:function(){return this.raw||{}}}]),e}(),N={triggerDefaultQuery:!0,triggerCustomQuery:!1,stateChanges:!0},U={stateChanges:!0},G="INACTIVE",K="ACTIVE",X="DENIED",J="INACTIVE",W="PENDING",$="ERROR",Y=function(e){function t(t){var r,i=t.index,c=t.url,l=t.credentials,h=t.mongodb,d=t.appbaseConfig,p=t.headers,f=t.transformRequest,g=t.transformResponse,m=t.beforeValueChange,b=t.onValueChange,_=t.onResults,q=t.onAggregationData,w=t.onError,S=t.onRequestStatusChange,C=t.onQueryChange,R=t.onMicStatusChange,D=t.enablePopularSuggestions,A=t.maxPopularSuggestions,E=t.results,O=t.showDistinctSuggestions,x=t.enablePredictiveSuggestions,Q=t.preserveResults,k=t.clearOnQueryChange,P=t.autocompleteField,j=(t.componentName,o(t,["index","url","credentials","mongodb","appbaseConfig","headers","transformRequest","transformResponse","beforeValueChange","onValueChange","onResults","onAggregationData","onError","onRequestStatusChange","onQueryChange","onMicStatusChange","enablePopularSuggestions","maxPopularSuggestions","results","showDistinctSuggestions","enablePredictiveSuggestions","preserveResults","clearOnQueryChange","autocompleteField","componentName"]));n(a(r=e.call(this,{index:i,url:c,credentials:l,mongodb:h,headers:p,appbaseConfig:d,transformRequest:f,transformResponse:g})||this),"onMicClick",(function(e,t){void 0===e&&(e={}),void 0===t&&(t={triggerDefaultQuery:!1,triggerCustomQuery:!1,stateChanges:!0});var n=r._micStatus;if("undefined"!=typeof window&&(window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition||null),window&&window.SpeechRecognition&&n!==X){n===K&&r._setMicStatus(G,t);var s=window.SpeechRecognition;if(r._micInstance)return void r._stopMic();r._micInstance=new s,r._micInstance.continuous=!0,r._micInstance.interimResults=!0,Object.assign(r._micInstance,e),r._micInstance.start(),r._micInstance.onstart=function(){r._setMicStatus(K,t)},r._micInstance.onresult=function(e){var n=e.results;n&&n[0]&&n[0].isFinal&&r._stopMic(),r._handleVoiceResults({results:n},t)},r._micInstance.onerror=function(e){"no-speech"===e.error||"audio-capture"===e.error?r._setMicStatus(G,t):"not-allowed"===e.error&&r._setMicStatus(X,t),console.error(e)}}})),n(a(r),"setDataField",(function(e,t){void 0===t&&(t=N);var n=r.dataField;r.dataField=e,r._applyOptions(t,"dataField",n,e)})),n(a(r),"setParent",(function(e){r._parent=e})),n(a(r),"setValue",(function(e,t){void 0===t&&(t=N);var n=function(){var n=r.value;r.value=e,r._applyOptions(t,"value",n,r.value)};r.beforeValueChange?r.beforeValueChange(e).then(n).catch((function(e){console.warn("beforeValueChange rejected the promise with ",e)})):n()})),n(a(r),"setSize",(function(e,t){void 0===t&&(t=N);var n=r.size;r.size=e,r._applyOptions(t,"size",n,r.size)})),n(a(r),"setFrom",(function(e,t){void 0===t&&(t=N);var n=r.from;r.from=e,r._applyOptions(t,"from",n,r.from)})),n(a(r),"setFuzziness",(function(e,t){void 0===t&&(t=N);var n=r.fuzziness;r.fuzziness=e,r._applyOptions(t,"fuzziness",n,r.fuzziness)})),n(a(r),"setIncludeFields",(function(e,t){void 0===t&&(t=N);var n=r.includeFields;r.includeFields=e,r._applyOptions(t,"includeFields",n,e)})),n(a(r),"setExcludeFields",(function(e,t){void 0===t&&(t=N);var n=r.excludeFields;r.excludeFields=e,r._applyOptions(t,"excludeFields",n,e)})),n(a(r),"setSortBy",(function(e,t){void 0===t&&(t=N);var n=r.sortBy;r.sortBy=e,r._applyOptions(t,"sortBy",n,e)})),n(a(r),"setReact",(function(e,t){void 0===t&&(t=N);var n=r.react;r.react=e,r._applyOptions(t,"react",n,e)})),n(a(r),"setDefaultQuery",(function(e,t){void 0===t&&(t=N);var n=r.defaultQuery;r.defaultQuery=e,r._applyOptions(t,"defaultQuery",n,e)})),n(a(r),"setCustomQuery",(function(e,t){void 0===t&&(t=N);var n=r.customQuery;r.customQuery=e,r._applyOptions(t,"customQuery",n,e)})),n(a(r),"setAfter",(function(e,t){void 0===t&&(t=N);var n=r.after;r.after=e,r.aggregationData.setAfterKey(e),r._applyOptions(t,"after",n,e)})),n(a(r),"triggerDefaultQuery",(function(e){if(void 0===e&&(e=U),F(r._query,r.componentQuery))return Promise.resolve(!0);var t=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{return r._updateQuery(),r._setRequestStatus(W),r._lastRequestTimeDefaultQuery=(new Date).getTime(),r._fetchRequest({query:Array.isArray(r.query)?r.query:[r.query],settings:r.appbaseSettings}).then((function(n){if(r._lastRequestTimeDefaultQuery<n._timestamp){var i=r.results,o=n&&n[r.id],a=function(){o.aggregations&&r._handleAggregationResponse(o.aggregations,s({defaultOptions:N},e)),r._setRequestStatus(J),r._applyOptions({stateChanges:e.stateChanges},"results",i,r.results)};return r.type&&r.type!==v||!r.enablePopularSuggestions?(r._appendResults(o),a()):r._fetchRequest(r.getSuggestionsQuery(),!0).then((function(e){var t=e.DataSearch__suggestions;t&&t.hits&&t.hits.hits&&o.hits&&o.hits.hits&&(o.hits.hits=[].concat((t.hits.hits||[]).map((function(e){return s({},e,{_popular_suggestion:!0})})),o.hits.hits)),r._appendResults(o),a()})).catch(t),Promise.resolve(o)}return Promise.resolve([])})).catch(t)}catch(e){return t(e)}})),n(a(r),"triggerCustomQuery",(function(e){void 0===e&&(e=U);var t=r._generateQuery(),n=t.requestBody,i=t.orderOfQueries;if(!n.length)return Promise.resolve({});if(F(r._query,n))return Promise.resolve(!0);var o=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{i.forEach((function(e){var t=r._parent.getComponent(e);t&&(t.setFrom(0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t.setAfter(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),r.clearOnQueryChange&&r._query&&t.setValue(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t._setRequestStatus(W),t._updateQuery())})),r._lastRequestTimeCustomQuery=(new Date).getTime();var a=r._generateQuery().requestBody;return r._fetchRequest({query:a,settings:r.appbaseSettings}).then((function(t){return r._lastRequestTimeCustomQuery<t._timestamp?(i.forEach((function(n){var i=r._parent.getComponent(n);if(i){i._setRequestStatus(J);var o=i.results,a=t&&t[n];a.hits&&(i.results.setRaw(a),i._applyOptions({stateChanges:e.stateChanges},"results",o,i.results)),a.aggregations&&i._handleAggregationResponse(a.aggregations,s({defaultOptions:N},e),!1)}})),Promise.resolve(t)):Promise.resolve([])})).catch(o)}catch(e){return o(e)}})),n(a(r),"recordClick",(function(e,t){void 0===t&&(t=!1),r._analyticsInstance&&r.queryId&&r._analyticsInstance.click({queryID:r.queryId,objects:e,isSuggestionClick:t})})),n(a(r),"recordConversions",(function(e){r._analyticsInstance&&r.queryId&&r._analyticsInstance.conversion({queryID:r.queryId,objects:e})})),n(a(r),"subscribeToStateChanges",(function(e,t){r.stateChanges.subscribe(e,t)})),n(a(r),"unsubscribeToStateChanges",(function(e){r.stateChanges.unsubscribe(e)})),n(a(r),"clearResults",(function(e){void 0===e&&(e=U);var t=r.results;r.results.setRaw({hits:{hits:[]}}),r._applyOptions({stateChanges:e.stateChanges},"results",t,r.results)})),n(a(r),"getRecentSearches",(function(e,t){void 0===e&&(e={size:5,minChars:3}),void 0===t&&(t=U);var n={headers:s({},r.headers)},i="",o=function(e,t){i+=i?"&"+e+"="+t:e+"="+t};return r.appbaseSettings&&r.appbaseSettings.userId&&o("user_id",r.appbaseSettings.userId),e&&(e.size&&o("size",String(e.size)),e.from&&o("from",e.from),e.to&&o("to",e.to),e.minChars&&o("min_chars",String(e.minChars)),e.customEvents&&Object.keys(e.customEvents).forEach((function(t){o(t,e.customEvents[t])}))),new Promise((function(e,s){fetch(r.url+"/_analytics"+(r.mongodb?"":"/"+r._getSearchIndex())+"/recent-searches?"+i,n).then((function(n){return n.status>=500||n.status>=400?s(n):n.json().then((function(n){var s=r.recentSearches;r.recentSearches=n.map((function(e){return{label:e.key,value:e.key}})),r._applyOptions({stateChanges:t.stateChanges},"recentSearches",s,r.recentSearches),e(r.recentSearches)})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))}))})),n(a(r),"_handleVoiceResults",(function(e,t){var n=e.results;void 0===t&&(t=N),n&&n[0]&&n[0].isFinal&&n[0][0]&&n[0][0].transcript&&n[0][0].transcript.trim()&&r.setValue(n[0][0].transcript.trim(),s({},t,{triggerCustomQuery:!0,triggerDefaultQuery:!0}))})),n(a(r),"_stopMic",(function(){r._micInstance&&(r._micInstance.stop(),r._micInstance=null,r._setMicStatus(G))})),n(a(r),"_setMicStatus",(function(e,t){void 0===t&&(t=N);var n=r._micStatus;r._micStatus=e,r._applyOptions(t,"micStatus",n,r._micStatus)}));var T=I[h?"MONGODB":"ELASTICSEARCH"];z({index:i,url:c,credentials:l,headers:p,mongodb:h,appbaseConfig:d,transformRequest:f,transformResponse:g},M[T],T,componentsAlias.SEARCHBASE);var B=j.id,V=j.type,$=j.react,Y=j.queryFormat,Z=j.dataField,ee=j.categoryField,te=j.categoryValue,re=j.nestedField,ne=j.from,se=j.size,ie=j.sortBy,oe=j.value,ae=j.aggregationField,ue=j.aggregationSize,ce=j.after,le=j.includeNullValues,he=j.includeFields,de=j.excludeFields,pe=j.fuzziness,fe=j.searchOperators,ge=j.highlight,ye=j.highlightField,me=j.customHighlight,ve=j.interval,be=j.aggregations,_e=j.missingLabel,qe=j.showMissing,we=j.defaultQuery,Se=j.customQuery,Ce=j.execute,Re=j.enableSynonyms,Fe=j.selectAllLabel,De=j.pagination,Ae=j.queryString,Ee=j.distinctField,Oe=j.distinctFieldConfig;if(!B)throw new Error(y.invalidComponentId);if(V&&V!==v&&Array.isArray(Z))throw new Error(y.dataFieldAsArray);return r.id=B,r.type=V,r.react=$,r.queryFormat=Y,r.dataField=Z,r.autocompleteField=P,r.categoryField=ee,r.categoryValue=te,r.nestedField=re,r.from=ne,r.size=se,r.sortBy=ie,r.aggregationField=ae,r.aggregationSize=ue,r.after=ce,r.includeNullValues=le,r.includeFields=he,r.excludeFields=de,r.fuzziness=pe,r.searchOperators=fe,r.highlight=ge,r.highlightField=ye,r.customHighlight=me,r.interval=ve,r.aggregations=be,r.missingLabel=_e,r.showMissing=qe,r.execute=Ce,r.enableSynonyms=Re,r.selectAllLabel=Fe,r.pagination=De,r.queryString=Ae,r.defaultQuery=we,r.customQuery=Se,r.beforeValueChange=m,r.onValueChange=b,r.onResults=_,r.onAggregationData=q,r.onError=w,r.onRequestStatusChange=S,r.onQueryChange=C,r.onMicStatusChange=R,r.distinctField=Ee,r.distinctFieldConfig=Oe,r.enablePopularSuggestions=D,r.maxPopularSuggestions=A,r.showDistinctSuggestions=O,r.enablePredictiveSuggestions=x,r.preserveResults=Q,r.clearOnQueryChange=k,r.stateChanges=new u,r.results=new L(E),r.aggregationData=new H,oe?r.setValue(oe,{stateChanges:!0}):r.value=oe,r}i(t,e);var c=t.prototype;return c.getSuggestionsQuery=function(){return{query:[{id:"DataSearch__suggestions",dataField:m,size:this.maxPopularSuggestions||5,value:this.value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:"count",modifier:"sqrt",missing:1}}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],fuzziness:0,operator:"or",query:this.value,type:"best_fields"}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],operator:"or",query:this.value,type:"phrase"}},{multi_match:{fields:["key^9"],operator:"or",query:this.value,type:"phrase_prefix"}}]}}}}]}},c._appendResults=function(e){this.preserveResults&&e&&Array.isArray(e.hits&&e.hits.hits)&&Array.isArray(this.results.rawData&&this.results.rawData.hits&&this.results.rawData.hits.hits)?this.results.setRaw(s({},e,{hits:s({},e.hits,{hits:[].concat(this.results.rawData.hits.hits,e.hits.hits)})})):this.results.setRaw(e)},c._applyOptions=function(e,t,r,n){var s;("micStatus"===t&&this.onMicStatusChange&&this.onMicStatusChange(n,r),"query"===t&&this.onQueryChange&&this.onQueryChange(n,r),"value"===t&&this.onValueChange&&this.onValueChange(n,r),"error"===t&&this.onError&&this.onError(n),"results"===t&&this.onResults&&this.onResults(n,r),"aggregationData"===t&&this.onAggregationData&&this.onAggregationData(n,r),"requestStatus"===t&&this.onRequestStatusChange&&this.onRequestStatusChange(n,r),e.triggerDefaultQuery&&this.triggerDefaultQuery(),e.triggerCustomQuery&&this.triggerCustomQuery(),!1!==e.stateChanges)&&this.stateChanges.next(((s={})[t]={prev:r,next:n},s),t,this)},c._getSearchIndex=function(e){void 0===e&&(e=!1);var t=this.index;return e?t=".suggestions":this._parent&&this._parent.index&&(t=this._parent.index),t},c._fetchRequest=function(e,t){var r=this;void 0===t&&(t=!1);var n={method:"POST",body:JSON.stringify(s({},e,!!this.mongodb&&{mongodb:this._getMongoRequest()})),headers:s({},this.headers)};return new Promise((function(e,i){r._handleTransformRequest(n).then((function(n){var o=Date.now(),a=r._getSearchIndex(t);return fetch(r.url+(r.mongodb?"":"/"+a+"/_reactivesearch.v3"),n).then((function(t){var n=t.headers;if(t.headers){var a=t.headers.get("X-Search-Id");a&&(r._parent?r._parent.setQueryID(a):r.setQueryID(a))}return t.status>=500||t.status>=400?i(t):t.json().then((function(t){r._handleTransformResponse(t).then((function(t){t&&Object.prototype.hasOwnProperty.call(t,"error")&&i(t);var r=s({},t,{_timestamp:o,_headers:n});return e(r)})).catch((function(e){return console.warn("SearchBase: transformResponse rejected the promise with ",e),i(e)}))}))})).catch((function(e){return i(e)}))})).catch((function(e){return console.warn("SearchBase: transformRequest rejected the promise with ",e),i(e)}))}))},c._generateQuery=function(){var e=this;if(this._parent){var t=this._parent.getComponents(),r=[];Object.keys(t).forEach((function(n){var s=t[n];s&&s.react&&(w(s.react,n).indexOf(e.id)>-1&&r.push(n))}));var n={};return r.forEach((function(t){var r=e._parent.getComponent(t);r&&(n[t]=r.componentQuery,w(r.react,r.id).forEach((function(t){if(!n[t]){var r=e._parent.getComponent(t);if(r&&r.value){var s=r.componentQuery;s.execute=!1,n[t]=s}}})))})),{requestBody:Object.values(n),orderOfQueries:r}}return{requestBody:[],orderOfQueries:[]}},c._handleTransformResponse=function(e){return this.transformResponse&&"function"==typeof this.transformResponse?this.transformResponse(e):new Promise((function(t){return t(e)}))},c._handleTransformRequest=function(e){return this.transformRequest&&"function"==typeof this.transformRequest?this.transformRequest(e):new Promise((function(t){return t(e)}))},c._handleAggregationResponse=function(e,t,r){void 0===t&&(t=N),void 0===r&&(r=!0);var n=this.aggregationField;if(n||"string"!=typeof this.dataField||(n=this.dataField),n){var s,i=this.aggregationData;this.aggregationData.setRaw(e[n]),this.aggregationData.setData(n,null==(s=e[n])?void 0:s.buckets,this.preserveResults&&r),this._applyOptions({stateChanges:t.stateChanges},"aggregationData",i,this.aggregationData)}},c._setError=function(e,t){void 0===t&&(t=N),this._setRequestStatus($);var r=this.error;this.error=e,this._applyOptions(t,"error",r,this.error)},c._setRequestStatus=function(e){var t=this.requestStatus;this.requestStatus=e,this._applyOptions({stateChanges:!0},"requestStatus",t,this.requestStatus)},c._updateQuery=function(e){var t,r=this;t=s({},this._query);var n=[this.componentQuery];w(this.react,this.id).forEach((function(e){var t=r._parent.getComponent(e);if(t&&t.value){var s=t.componentQuery;s.execute=!1,n.push(s)}})),this._query=e||n,this._applyOptions({stateChanges:!1},"query",t,this._query)},c._getMongoRequest=function(){var e={};return this.index&&(e.index=this.index),this.mongodb&&(this.mongodb.db&&(e.db=this.mongodb.db),this.mongodb.collection&&(e.collection=this.mongodb.collection)),e},r(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===K}},{key:"micInactive",get:function(){return this._micStatus===G}},{key:"micDenied",get:function(){return this._micStatus===X}},{key:"query",get:function(){return this._query}},{key:"requestPending",get:function(){return this.requestStatus===W}},{key:"appbaseSettings",get:function(){var e=this.appbaseConfig||{};return{recordAnalytics:e.recordAnalytics,customEvents:e.customEvents,enableQueryRules:e.enableQueryRules,userId:e.userId}}},{key:"suggestions",get:function(){if(this.type&&this.type!==v)return[];if(this.results){var e=_(this.dataField)||[];return 0===e.length&&this.results.data&&Array.isArray(this.results.data)&&this.results.data.length>0&&this.results.data[0]&&(e=Object.keys(this.results.data[0]).filter((function(e){return!["_id","_click_id","_index","_score","_type"].includes(e)}))),this.enablePopularSuggestions&&(e=[].concat(e,m)),R(e,this.results.data,this.value,this.showDistinctSuggestions,this.enablePredictiveSuggestions).slice(0,this.size)}return[]}},{key:"componentQuery",get:function(){return s({id:this.id,type:this.type,dataField:_(this.dataField)},this.mongodb&&{autocompleteField:this.autocompleteField},{react:this.react,highlight:this.highlight,highlightField:_(this.highlightField),fuzziness:this.fuzziness,searchOperators:this.searchOperators,includeFields:this.includeFields,excludeFields:this.excludeFields,size:this.size,from:this.from,queryFormat:this.queryFormat,sortBy:this.sortBy,fieldWeights:q(this.dataField),includeNullValues:this.includeNullValues,aggregationField:this.aggregationField,aggregationSize:this.aggregationSize,categoryField:this.categoryField,missingLabel:this.missingLabel,showMissing:this.showMissing,nestedField:this.nestedField,interval:this.interval,customHighlight:this.customHighlight,customQuery:this.customQuery?this.customQuery(this):void 0,defaultQuery:this.defaultQuery?this.defaultQuery(this):void 0,value:this.value,categoryValue:this.categoryValue,after:this.after,aggregations:this.aggregations,enableSynonyms:this.enableSynonyms,selectAllLabel:this.selectAllLabel,pagination:this.pagination,queryString:this.queryString,distinctField:this.distinctField,distinctFieldConfig:this.distinctFieldConfig,index:this.index})}},{key:"queryId",get:function(){return this._parent&&this._parent._queryId?this._parent._queryId:this._queryId?this._queryId:""}},{key:"mappedProps",get:function(){var e=this,t={},r=s({},D);return this.mongodb&&(delete r.recordClick,delete r.recordConversions),Object.keys(D).forEach((function(r){t[D[r]]=e[r]})),t}}]),t}(V),Z=function(e){function t(t){var r,i=t.index,o=t.url,u=t.credentials,c=t.mongodb,l=t.headers,h=t.appbaseConfig,d=t.transformRequest,p=t.transformResponse;return n(a(r=e.call(this,{index:i,url:o,credentials:u,mongodb:c,headers:l,appbaseConfig:h,transformRequest:d,transformResponse:p})||this),"register",(function(e,t){if(!e)throw new Error(y.invalidComponentId);if(r._components[e])return r._components[e];var n=t;return!t||t instanceof Y?n.id=e:n=new Y(s({},t,{id:e,index:t.index||r.index,url:t.url||r.url,mongodb:t.mongodb||r.mongodb,credentials:t.credentials||r.credentials,headers:t.headers||r.headers,transformRequest:t.transformRequest||r.transformRequest,transformResponse:t.transformResponse||r.transformResponse,appbaseConfig:t.appbaseConfig||r.appbaseConfig})),r._components[e]=n,n.setParent(a(r)),n})),n(a(r),"unregister",(function(e){e&&delete r._components[e]})),n(a(r),"getComponent",(function(e){return r._components[e]})),n(a(r),"getComponents",(function(){return r._components})),r._components={},r}return i(t,e),t}(V);e.SearchBase=Z,e.SearchComponent=Y,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Searchbase={})}(this,(function(e){"use strict";function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(){return(s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function o(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var u=function(){function e(){this.observers=[]}var t=e.prototype;return t.subscribe=function(e,t){this.observers.push({callback:e,properties:t})},t.unsubscribe=function(e){this.observers=e?this.observers.filter((function(t){return t.callback!==e?t:null})):[]},t.next=function(e,t,r){var n=r;!n&&window&&(n=window),this.observers.forEach((function(r){(void 0===r.properties||r.properties instanceof Array&&r.properties.length&&r.properties.includes(t)||"string"==typeof r.properties&&r.properties&&r.properties===t)&&r.callback.call(n,e)}))},e}(),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var l=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var r=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:c);!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,s="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function f(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function g(e){var t=new FileReader,r=f(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&s&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,r,n=p(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=f(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=c(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[c(e)]},d.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},d.prototype.set=function(e,t){this.map[c(e)]=l(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),h(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),h(e)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(e,t){var r,n,s=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,s||null==e._bodyInit||(s=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(r=t.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}})),t}function q(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},q.error=function(){var e=new q(null,{status:0,statusText:""});return e.type="error",e};var w=[301,302,303,307,308];q.redirect=function(e,t){if(-1===w.indexOf(t))throw new RangeError("Invalid status code");return new q(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,r){return new Promise((function(n,i){var o=new b(e,r);if(o.signal&&o.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var s="response"in a?a.response:a.responseText;n(new q(s,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&s&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",u)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=d,e.Request=b,e.Response=q),t.Headers=d,t.Request=b,t.Response=q,t.fetch=S}({})}(r),delete r.fetch.polyfill,(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t}));l.fetch,l.Headers,l.Request,l.Response;function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function d(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(o="=",i%1);n+=o.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}function p(e,t){if(null==e&&!t)throw new Error("appbase-analytics: query or queryID must be present to register a click/conversion event")}var f={init:function(e){void 0===e&&(e={});var t={credentials:e.credentials,index:e.index,url:e.url,userID:e.userID,globalEventData:e.globalEventData,queryID:"",headers:null};return function(e){if(!e)throw new Error("appbase-analytics: A valid index must be present to record analytics events.")}(t.index),function(e){if(!e)throw new Error("appbase-analytics: Auth credentials is missing.")}(t.credentials),function(e){if(!e)throw new Error("appbase-analytics: URL is missing.")}(t.url),t._request=function(e,r,n){var s=h({},r,{user_id:t.userID,event_data:h({},r&&r.event_data,{},t.globalEventData)});return l(t.url+"/"+t.index+"/_analytics/"+e,{method:"PUT",headers:h({},t.headers,{"Content-Type":"application/json",Authorization:"Basic "+d(t.credentials)}),body:JSON.stringify(s)}).then((function(e){n&&n(null,e)})).catch((function(e){console.error(e),n&&n(e,null)}))},t.search=function(e,r){p(e.query,e.queryID);if(t._request){var n={query:e.query,query_id:e.queryID,event_data:e.eventData,filters:e.filters,hits:e.hits};t._request("search",n,(function(e,n){n&&n.json().then((function(e){e&&e.query_id&&(t.queryID=e.query_id)})).catch((function(e){console.error(e)})),r&&r(e,n)}))}},t.click=function(e,r){if(p(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={click_on:e.objects,click_type:e.isSuggestionClick?"suggestion":"result",query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("click",n,r)}},t.conversion=function(e,r){if(p(e.query,e.queryID),function(e){if(!e||Object.keys(e).length<1)throw new Error("appbase-analytics: at least one click object must be present to register a click event")}(e.objects),t._request){var n={conversion_on:e.objects,query:e.query,query_id:e.queryID,event_data:e.eventData};t._request("conversion",n,r)}},t.setUserID=function(e){t.userID=e},t.setGlobalEventData=function(e){t.globalEventData=e},t.setHeaders=function(e){t.headers=e},t}};function g(e){return"SearchBase: "+e}var y={invalidIndex:g("Please provide a valid index."),invalidURL:g("Please provide a valid url."),invalidComponentId:g("Please provide component id."),invalidDataField:g("Please provide data field."),dataFieldAsArray:g("Only components with `search` type supports the multiple data fields. Please define `dataField` as a string.")},m=["key","key.autosuggest"],v="search",b=function(e){var t=[];return e&&(t=[].concat(e).map((function(e){var t=function(e){var t=s({},e);return t.highlight&&Object.keys(t.highlight).forEach((function(e){var r,n=t.highlight[e][0];t._source=s({},t._source,((r={})[e]=n,r))})),t}(e);return Object.keys(t).filter((function(e){return"_source"!==e})).reduce((function(e,r){return e[r]=t[r],e}),s({},t._source))}))),t},_=function(e){if(e){if(!Array.isArray(e))return[e];if(e.length){var t=[];return e.forEach((function(e){"string"==typeof e?t.push(e):e.field&&t.push(e.field)})),t}}};var q=function(e){if(e&&Array.isArray(e)&&e.length){var t=[];return e.forEach((function(e){var r;r=e.weight,!Number.isNaN(parseFloat(r))&&Number.isFinite(r)?t.push(e.weight):t.push(1)})),t}};function w(e,t){var r=[];return function e(t){t&&Object.keys(t)&&Object.keys(t).forEach((function(n){t[n]&&("string"==typeof t[n]?r=[].concat(r,[t[n]]):Array.isArray(t[n])?r=[].concat(r,t[n]):"object"==typeof t[n]&&e(t[n]))}))}(e),r=r.filter((function(e){return e!==t}))}var S=function(e){return"object"==typeof e?Array.isArray(e)?function e(t){return t.reduce((function(t,r){return t.concat(Array.isArray(r)?e(r):r)}),[])}(e):null:e};function C(e){return void 0===e&&(e=""),e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var R=function(e,t,r,n,i){void 0===e&&(e=[]),void 0===r&&(r=""),void 0===n&&(n=!0),void 0===i&&(i=!1);var a=[],u=[],c=!1,l=r||"",h=function(e,t,r){if((c||l.trim().split(" ").some((function(t){return String(e).toLowerCase().includes(t)})))&&!u.includes(e)||r._promoted){var i=s({},{label:e,value:e,source:r});if(u=[].concat(u,[e]),a=[].concat(a,[i]),n)return!0}return!1},d=function e(t,r,s){if(void 0===r&&(r=""),void 0===s&&(s=t),"object"==typeof t){var i=r.split("."),o=t[i[0]];if(o)if(i.length>1){var a=r.substring(i[0].length+1);Array.isArray(o)?o.forEach((function(t){e(t,a,s)})):e(o,a,s)}else{var u=S(o);if(u){if(Array.isArray(u)){if(n)return u.some((function(e){return h(e,0,s)}));u.forEach((function(e){return h(e,0,s)}))}return h(u,0,s)}}}return!1},p=function(){n?t.forEach((function(t){e.some((function(e){return d(t,e)}))})):t.forEach((function(t){e.forEach((function(e){d(t,e)}))}))};return p(),a.length<t.length&&!c&&(c=!0,p()),i?function(e){var t=e.suggestions,r=e.currentValue,n=e.wordsToShowAfterHighlight,i={};if(r){var a=r.trim();return t.reduce((function(e,t){var r=t.label,u=o(t,["label"]),c=(new DOMParser).parseFromString(r,"text/html").documentElement.textContent,l="^("+C(a)+")\\w+",h=new RegExp(l,"i"),d=h.exec(c);if(d||(l="^("+C(a)+")",d=(h=new RegExp(l,"i")).exec(c)),d){var p=c.slice(d.index,c.length).slice(a.length).split(" ").slice(0,n+1).join(" "),f=a+'<mark class="highlight">'+p+"</mark>",g=""+a+p;return i[f]?e:(i[f]=1,[].concat(e,[s({},u,{label:f,value:g,isPredictiveSuggestion:!0})]))}return e}),[])}return[]}({suggestions:a,currentValue:r,wordsToShowAfterHighlight:!0}):a};function F(e,t){if(e===t)return!0;if(!(e instanceof Object&&t instanceof Object))return!1;if(e.constructor!==t.constructor)return!1;for(var r in e)if(e.hasOwnProperty(r)){if(!t.hasOwnProperty(r))return!1;if(e[r]!==t[r]){if("object"!=typeof e[r])return!1;if(!F(e[r],t[r]))return!1}}for(var n in t)if(t.hasOwnProperty(n)&&!e.hasOwnProperty(n))return!1;return!0}var D={id:"id",type:"type",react:"react",queryFormat:"queryFormat",dataField:"dataField",categoryField:"categoryField",categoryValue:"categoryValue",nestedField:"nestedField",from:"from",size:"size",sortBy:"sortBy",value:"value",aggregationField:"aggregationField",aggregationSize:"aggregationSize",after:"after",includeNullValues:"includeNullValues",includeFields:"includeFields",excludeFields:"excludeFields",fuzziness:"fuzziness",searchOperators:"searchOperators",highlight:"highlight",highlightField:"highlightField",customHighlight:"customHighlight",interval:"interval",aggregations:"aggregations",missingLabel:"missingLabel",showMissing:"showMissing",enableSynonyms:"enableSynonyms",selectAllLabel:"selectAllLabel",pagination:"pagination",queryString:"queryString",enablePopularSuggestions:"enablePopularSuggestions",showDistinctSuggestions:"showDistinctSuggestions",error:"error",defaultQuery:"defaultQuery",customQuery:"customQuery",requestStatus:"requestStatus",results:"results",aggregationData:"aggregationData",micStatus:"micStatus",micInstance:"micInstance",micActive:"micActive",micInactive:"micInactive",micDenied:"micDenied",query:"query",requestPending:"loading",appbaseSettings:"appbaseConfig",suggestions:"suggestions",queryId:"queryId",recentSearches:"recentSearches",distinctField:"distinctField",distinctFieldConfig:"distinctFieldConfig",onMicClick:"handleMicClick",triggerDefaultQuery:"triggerDefaultQuery",triggerCustomQuery:"triggerCustomQuery",recordClick:"recordClick",recordConversions:"recordConversions",subscribeToStateChanges:"subscribeToStateChanges",unsubscribeToStateChanges:"unsubscribeToStateChanges",setDataField:"setDataField",setValue:"setValue",setSize:"setSize",setFrom:"setFrom",setFuzziness:"setFuzziness",setIncludeFields:"setIncludeFields",setExcludeFields:"setExcludeFields",setSortBy:"setSortBy",setReact:"setReact",setDefaultQuery:"setDefaultQuery",setCustomQuery:"setCustomQuery",setAfter:"setAfter"};function A(e){void 0===e&&(e="");for(var t,r=e,n="",s=0,i=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|i)||(o="=",i%1);n+=o.charAt(63&s>>8-i%1*8)){if((t=r.charCodeAt(i+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');s=s<<8|t}return n}var E="SearchBase",O="SearchBox",x="SearchComponent",I={MONGODB:"mongodb",ELASTICSEARCH:"elasticsearch"},Q="array",k="function",P="object",j="number",T="boolean",z="string";function B(e,t,r,n){void 0===e&&(e={}),void 0===t&&(t={}),void 0===r&&(r=""),void 0===n&&(n="");var s=Object.keys(e).filter((function(t){return!!e[t]})),i=Object.keys(t),o=[],a=[];i.forEach((function(e){var r=t[e];r.components.includes(n)&&(a.push(e),r.required&&o.push(e))})),o.forEach((function(e){if(!s.includes(e))throw new Error(e+" is required for <"+n+" /> component when used with the "+r+" Search backend.")})),s.forEach((function(r){if(!a.includes(r))throw new Error("<"+n+" /> component doesn't accept a property "+r+".");var s,i=Array.isArray(t[r].type)?t[r].type:[].concat(t[r].type),o=typeof(s=e[r])===P?Array.isArray(s)?Q:P:typeof s;if(!i.includes(o))throw new Error("<"+n+" /> component accepts a property "+r+" with type(s) ["+i.join(", ")+"], but type was set as "+o+".")}))}var M={mongodb:{url:{components:[E],type:z,required:!0},index:{components:[E,O,x],type:z,required:!1},credentials:{components:[E],type:z,required:!1},headers:{components:[E,O,x],type:P,required:!1},transformRequest:{components:[E,O,x],type:k,required:!1},transformResponse:{components:[E,O,x],type:k,required:!1},mongodb:{components:[E],type:P,required:!1},id:{components:[O,x],type:z,required:!0},dataField:{components:[O,x],type:[Q,z],required:!1},autocompleteField:{components:[O,x],type:[Q,z],required:!1},react:{components:[O,x],type:P,required:!1},size:{components:[O,x],type:j,required:!1},from:{components:[O,x],type:j,required:!1},includeFields:{components:[O,x],type:Q,required:!1},excludeFields:{components:[O,x],type:Q,required:!1},sortBy:{components:[O,x],type:z,required:!1},aggregationSize:{components:[O,x],type:j,required:!1},highlight:{components:[O,x],type:T,required:!1},highlightField:{components:[O,x],type:z,required:!1},highlightConfig:{components:[O,x],type:P,required:!1},fuzziness:{components:[O,x],type:[z,j],required:!1},enableSynonyms:{components:[O,x],type:T,required:!1},searchOperators:{components:[O,x],type:T,required:!1},queryString:{components:[O,x],type:z,required:!1},defaultQuery:{components:[O,x],type:[k,P],required:!1},customQuery:{components:[O,x],type:[k,P],required:!1},value:{components:[O,x],type:[z,Q,P],required:!1},type:{components:[O,x],type:z,required:!1}},elasticsearch:{url:{components:[E],type:z,required:!0},index:{components:[E,O,x],type:z,required:!1},credentials:{components:[E],type:z,required:!0},appbaseConfig:{components:[E],type:P,required:!1},headers:{components:[E,O,x],type:P,required:!1},transformRequest:{components:[E,O,x],type:k,required:!1},transformResponse:{components:[E,O,x],type:k,required:!1},id:{components:[O,x],type:z,required:!0},dataField:{components:[O,x],type:[Q,z],required:!1},autocompleteField:{components:[O,x],type:[Q,z],required:!1},queryFormat:{components:[O,x],type:z,required:!1},react:{components:[O,x],type:P,required:!1},size:{components:[O,x],type:j,required:!1},from:{components:[O,x],type:j,required:!1},includeFields:{components:[O,x],type:Q,required:!1},excludeFields:{components:[O,x],type:Q,required:!1},sortBy:{components:[O,x],type:z,required:!1},aggregationField:{components:[O,x],type:z,required:!1},aggregationSize:{components:[O,x],type:j,required:!1},highlight:{components:[O,x],type:T,required:!1},highlightField:{components:[O,x],type:z,required:!1},customHighlight:{components:[O,x],type:P,required:!1},categoryField:{components:[O,x],type:z,required:!1},categoryValue:{components:[O,x],type:z,required:!1},nestedField:{components:[O,x],type:z,required:!1},fuzziness:{components:[O,x],type:[z,j],required:!1},enableSynonyms:{components:[O,x],type:T,required:!1},searchOperators:{components:[O,x],type:T,required:!1},queryString:{components:[O,x],type:z,required:!1},distinctField:{components:[O,x],type:z,required:!1},distinctFieldConfig:{components:[O,x],type:P,required:!1},enableRecentSuggestions:{components:[O],type:T,required:!1},enablePopularSuggestions:{components:[O],type:T,required:!1},recentSuggestionsConfig:{components:[O],type:P,required:!1},popularSuggestionsConfig:{components:[O],type:P,required:!1},enablePredictiveSuggestions:{components:[O],type:T,required:!1},maxPredictedWords:{components:[O],type:j,required:!1},urlField:{components:[O],type:z,required:!1},pagination:{components:[x],type:T,required:!1},after:{components:[x],type:P,required:!1},showMissing:{components:[x],type:T,required:!1},includeNullValues:{components:[x],type:T,required:!1},interval:{components:[x],type:j,required:!1},aggregations:{components:[x],type:Q,required:!1},defaultQuery:{components:[O,x],type:[k,P],required:!1},customQuery:{components:[O,x],type:[k,P],required:!1},value:{components:[O,x],type:[z,Q,P],required:!1},type:{components:[O,x],type:z,required:!1},clearOnQueryChange:{components:[O,x],type:T,required:!1}}},V=function(){function e(e){var t=e.index,r=e.url,n=e.credentials,i=e.headers,o=e.mongodb,a=e.appbaseConfig,u=e.transformRequest,c=e.transformResponse,l=I[o?"MONGODB":"ELASTICSEARCH"];B({index:t,url:r,credentials:n,headers:i,mongodb:o,appbaseConfig:a,transformRequest:u,transformResponse:c},M[l],l,E),this.index=t,this.url=r,this.credentials=n||"",this.mongodb=o,a&&(this.appbaseConfig=a),u&&(this.transformRequest=u),c&&(this.transformResponse=c);var h=(a||{}).enableTelemetry;this.headers=s({Accept:"application/json","Content-Type":"application/json","x-search-client":"Searchbase Headless"},!1===h?{"X-Enable-Telemetry":!1}:{}),this.credentials&&(this.headers=s({},this.headers,{Authorization:"Basic "+A(this.credentials)})),i&&this.setHeaders(i),this.mongodb||(this._analyticsInstance=f.init({index:t,url:r,credentials:n}))}var t=e.prototype;return t.setHeaders=function(e){this.headers=s({},this.headers,e)},t.setQueryID=function(e){this._queryId=e},e}(),L=function(){function e(e){var t=this;n(this,"setRaw",(function(e){t.raw=e,e.hits&&e.hits.hits&&t.setData(e.hits.hits)})),this.data=e||[]}return e.prototype.setData=function(e){var t,r=b(e);if(this.promotedData.length){var n=this.promotedData.map((function(e){return e._id})).filter(Boolean);n&&(r=r.filter((function(e){return!n.includes(e._id)}))),r=[].concat(this.promotedData.map((function(e){return s({},e,{_promoted:!0})})),r)}this.parseResults?this.data=this.parseResults(r,e):this.data=r,this.data=(void 0===(t=this.data)&&(t=[]),t.map((function(e,t){return s({},e,{_click_id:t+1})})))},r(e,[{key:"numberOfResults",get:function(){return this.raw&&this.raw.hits?"object"==typeof this.raw.hits.total?this.raw.hits.total.value:this.raw.hits.total:0}},{key:"time",get:function(){return this.raw?this.raw.took:0}},{key:"hidden",get:function(){return this.raw&&this.raw.hits&&this.raw.hits.hidden||0}},{key:"promotedData",get:function(){return this.raw&&this.raw.promoted&&this.raw.promoted||[]}},{key:"promoted",get:function(){return this.promotedData.length||0}},{key:"rawData",get:function(){return this.raw||{}}},{key:"customData",get:function(){return this.raw&&this.raw.customData&&this.raw.customData||{}}}]),e}(),N=function(){function e(e){this.data=e||[]}var t=e.prototype;return t.setRaw=function(e){this.raw=e,(null==e?void 0:e.after_key)&&this.setAfterKey(e.after_key)},t.setAfterKey=function(e){this.afterKey=e},t.setData=function(e,t,r){void 0===r&&(r=!1);var n,i,o=(n=e,void 0===(i=t)&&(i=[]),i.map((function(e){var t=e.doc_count,r=e.key,i=e[n];return s({_doc_count:t,_key:void 0!==r[n]?r[n]:r},i)})));this.data=r?[].concat(this.data,o):o},r(e,[{key:"rawData",get:function(){return this.raw||{}}}]),e}(),U={triggerDefaultQuery:!0,triggerCustomQuery:!1,stateChanges:!0},H={stateChanges:!0},G="INACTIVE",K="ACTIVE",X="DENIED",J="INACTIVE",W="PENDING",$="ERROR",Y=function(e){function t(t){var r,i=t.index,c=t.url,l=t.credentials,h=t.mongodb,d=t.appbaseConfig,p=t.headers,f=t.transformRequest,g=t.transformResponse,m=t.beforeValueChange,b=t.onValueChange,_=t.onResults,q=t.onAggregationData,w=t.onError,S=t.onRequestStatusChange,C=t.onQueryChange,R=t.onMicStatusChange,D=t.enablePopularSuggestions,A=t.maxPopularSuggestions,O=t.results,x=t.showDistinctSuggestions,Q=t.enablePredictiveSuggestions,k=t.preserveResults,P=t.clearOnQueryChange,j=t.autocompleteField,T=(t.componentName,o(t,["index","url","credentials","mongodb","appbaseConfig","headers","transformRequest","transformResponse","beforeValueChange","onValueChange","onResults","onAggregationData","onError","onRequestStatusChange","onQueryChange","onMicStatusChange","enablePopularSuggestions","maxPopularSuggestions","results","showDistinctSuggestions","enablePredictiveSuggestions","preserveResults","clearOnQueryChange","autocompleteField","componentName"]));n(a(r=e.call(this,{index:i,url:c,credentials:l,mongodb:h,headers:p,appbaseConfig:d,transformRequest:f,transformResponse:g})||this),"onMicClick",(function(e,t){void 0===e&&(e={}),void 0===t&&(t={triggerDefaultQuery:!1,triggerCustomQuery:!1,stateChanges:!0});var n=r._micStatus;if("undefined"!=typeof window&&(window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition||null),window&&window.SpeechRecognition&&n!==X){n===K&&r._setMicStatus(G,t);var s=window.SpeechRecognition;if(r._micInstance)return void r._stopMic();r._micInstance=new s,r._micInstance.continuous=!0,r._micInstance.interimResults=!0,Object.assign(r._micInstance,e),r._micInstance.start(),r._micInstance.onstart=function(){r._setMicStatus(K,t)},r._micInstance.onresult=function(e){var n=e.results;n&&n[0]&&n[0].isFinal&&r._stopMic(),r._handleVoiceResults({results:n},t)},r._micInstance.onerror=function(e){"no-speech"===e.error||"audio-capture"===e.error?r._setMicStatus(G,t):"not-allowed"===e.error&&r._setMicStatus(X,t),console.error(e)}}})),n(a(r),"setDataField",(function(e,t){void 0===t&&(t=U);var n=r.dataField;r.dataField=e,r._applyOptions(t,"dataField",n,e)})),n(a(r),"setParent",(function(e){r._parent=e})),n(a(r),"setValue",(function(e,t){void 0===t&&(t=U);var n=function(){var n=r.value;r.value=e,r._applyOptions(t,"value",n,r.value)};r.beforeValueChange?r.beforeValueChange(e).then(n).catch((function(e){console.warn("beforeValueChange rejected the promise with ",e)})):n()})),n(a(r),"setSize",(function(e,t){void 0===t&&(t=U);var n=r.size;r.size=e,r._applyOptions(t,"size",n,r.size)})),n(a(r),"setFrom",(function(e,t){void 0===t&&(t=U);var n=r.from;r.from=e,r._applyOptions(t,"from",n,r.from)})),n(a(r),"setFuzziness",(function(e,t){void 0===t&&(t=U);var n=r.fuzziness;r.fuzziness=e,r._applyOptions(t,"fuzziness",n,r.fuzziness)})),n(a(r),"setIncludeFields",(function(e,t){void 0===t&&(t=U);var n=r.includeFields;r.includeFields=e,r._applyOptions(t,"includeFields",n,e)})),n(a(r),"setExcludeFields",(function(e,t){void 0===t&&(t=U);var n=r.excludeFields;r.excludeFields=e,r._applyOptions(t,"excludeFields",n,e)})),n(a(r),"setSortBy",(function(e,t){void 0===t&&(t=U);var n=r.sortBy;r.sortBy=e,r._applyOptions(t,"sortBy",n,e)})),n(a(r),"setReact",(function(e,t){void 0===t&&(t=U);var n=r.react;r.react=e,r._applyOptions(t,"react",n,e)})),n(a(r),"setDefaultQuery",(function(e,t){void 0===t&&(t=U);var n=r.defaultQuery;r.defaultQuery=e,r._applyOptions(t,"defaultQuery",n,e)})),n(a(r),"setCustomQuery",(function(e,t){void 0===t&&(t=U);var n=r.customQuery;r.customQuery=e,r._applyOptions(t,"customQuery",n,e)})),n(a(r),"setAfter",(function(e,t){void 0===t&&(t=U);var n=r.after;r.after=e,r.aggregationData.setAfterKey(e),r._applyOptions(t,"after",n,e)})),n(a(r),"triggerDefaultQuery",(function(e){if(void 0===e&&(e=H),F(r._query,r.componentQuery))return Promise.resolve(!0);var t=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{return r._updateQuery(),r._setRequestStatus(W),r._lastRequestTimeDefaultQuery=(new Date).getTime(),r._fetchRequest({query:Array.isArray(r.query)?r.query:[r.query],settings:r.appbaseSettings}).then((function(n){if(r._lastRequestTimeDefaultQuery<n._timestamp){var i=r.results,o=n&&n[r.id],a=function(){o.aggregations&&r._handleAggregationResponse(o.aggregations,s({defaultOptions:U},e)),r._setRequestStatus(J),r._applyOptions({stateChanges:e.stateChanges},"results",i,r.results)};return r.type&&r.type!==v||!r.enablePopularSuggestions?(r._appendResults(o),a()):r._fetchRequest(r.getSuggestionsQuery(),!0).then((function(e){var t=e.DataSearch__suggestions;t&&t.hits&&t.hits.hits&&o.hits&&o.hits.hits&&(o.hits.hits=[].concat((t.hits.hits||[]).map((function(e){return s({},e,{_popular_suggestion:!0})})),o.hits.hits)),r._appendResults(o),a()})).catch(t),Promise.resolve(o)}return Promise.resolve([])})).catch(t)}catch(e){return t(e)}})),n(a(r),"triggerCustomQuery",(function(e){void 0===e&&(e=H);var t=r._generateQuery(),n=t.requestBody,i=t.orderOfQueries;if(!n.length)return Promise.resolve({});if(F(r._query,n))return Promise.resolve(!0);var o=function(t){return r._setError(t,{stateChanges:e.stateChanges}),console.error(t),Promise.reject(t)};try{i.forEach((function(e){var t=r._parent.getComponent(e);t&&(t.setFrom(0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t.setAfter(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),r.clearOnQueryChange&&r._query&&t.setValue(void 0,{stateChanges:!0,triggerDefaultQuery:!1,triggerCustomQuery:!1}),t._setRequestStatus(W),t._updateQuery())})),r._lastRequestTimeCustomQuery=(new Date).getTime();var a=r._generateQuery().requestBody;return r._fetchRequest({query:a,settings:r.appbaseSettings}).then((function(t){return r._lastRequestTimeCustomQuery<t._timestamp?(i.forEach((function(n){var i=r._parent.getComponent(n);if(i){i._setRequestStatus(J);var o=i.results,a=t&&t[n];a.hits&&(i.results.setRaw(a),i._applyOptions({stateChanges:e.stateChanges},"results",o,i.results)),a.aggregations&&i._handleAggregationResponse(a.aggregations,s({defaultOptions:U},e),!1)}})),Promise.resolve(t)):Promise.resolve([])})).catch(o)}catch(e){return o(e)}})),n(a(r),"recordClick",(function(e,t){void 0===t&&(t=!1),r._analyticsInstance&&r.queryId&&r._analyticsInstance.click({queryID:r.queryId,objects:e,isSuggestionClick:t})})),n(a(r),"recordConversions",(function(e){r._analyticsInstance&&r.queryId&&r._analyticsInstance.conversion({queryID:r.queryId,objects:e})})),n(a(r),"subscribeToStateChanges",(function(e,t){r.stateChanges.subscribe(e,t)})),n(a(r),"unsubscribeToStateChanges",(function(e){r.stateChanges.unsubscribe(e)})),n(a(r),"clearResults",(function(e){void 0===e&&(e=H);var t=r.results;r.results.setRaw({hits:{hits:[]}}),r._applyOptions({stateChanges:e.stateChanges},"results",t,r.results)})),n(a(r),"getRecentSearches",(function(e,t){void 0===e&&(e={size:5,minChars:3}),void 0===t&&(t=H);var n={headers:s({},r.headers)},i="",o=function(e,t){i+=i?"&"+e+"="+t:e+"="+t};return r.appbaseSettings&&r.appbaseSettings.userId&&o("user_id",r.appbaseSettings.userId),e&&(e.size&&o("size",String(e.size)),e.from&&o("from",e.from),e.to&&o("to",e.to),e.minChars&&o("min_chars",String(e.minChars)),e.customEvents&&Object.keys(e.customEvents).forEach((function(t){o(t,e.customEvents[t])}))),new Promise((function(e,s){fetch(r.url+"/_analytics"+(r.mongodb?"":"/"+r._getSearchIndex())+"/recent-searches?"+i,n).then((function(n){return n.status>=500||n.status>=400?s(n):n.json().then((function(n){var s=r.recentSearches;r.recentSearches=n.map((function(e){return{label:e.key,value:e.key}})),r._applyOptions({stateChanges:t.stateChanges},"recentSearches",s,r.recentSearches),e(r.recentSearches)})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),s(e)}))}))})),n(a(r),"_handleVoiceResults",(function(e,t){var n=e.results;void 0===t&&(t=U),n&&n[0]&&n[0].isFinal&&n[0][0]&&n[0][0].transcript&&n[0][0].transcript.trim()&&r.setValue(n[0][0].transcript.trim(),s({},t,{triggerCustomQuery:!0,triggerDefaultQuery:!0}))})),n(a(r),"_stopMic",(function(){r._micInstance&&(r._micInstance.stop(),r._micInstance=null,r._setMicStatus(G))})),n(a(r),"_setMicStatus",(function(e,t){void 0===t&&(t=U);var n=r._micStatus;r._micStatus=e,r._applyOptions(t,"micStatus",n,r._micStatus)}));var z=I[h?"MONGODB":"ELASTICSEARCH"];B({index:i,url:c,credentials:l,headers:p,mongodb:h,appbaseConfig:d,transformRequest:f,transformResponse:g},M[z],z,E);var V=T.id,$=T.type,Y=T.react,Z=T.queryFormat,ee=T.dataField,te=T.categoryField,re=T.categoryValue,ne=T.nestedField,se=T.from,ie=T.size,oe=T.sortBy,ae=T.value,ue=T.aggregationField,ce=T.aggregationSize,le=T.after,he=T.includeNullValues,de=T.includeFields,pe=T.excludeFields,fe=T.fuzziness,ge=T.searchOperators,ye=T.highlight,me=T.highlightField,ve=T.customHighlight,be=T.interval,_e=T.aggregations,qe=T.missingLabel,we=T.showMissing,Se=T.defaultQuery,Ce=T.customQuery,Re=T.execute,Fe=T.enableSynonyms,De=T.selectAllLabel,Ae=T.pagination,Ee=T.queryString,Oe=T.distinctField,xe=T.distinctFieldConfig;if(!V)throw new Error(y.invalidComponentId);if($&&$!==v&&Array.isArray(ee))throw new Error(y.dataFieldAsArray);return r.id=V,r.type=$,r.react=Y,r.queryFormat=Z,r.dataField=ee,r.autocompleteField=j,r.categoryField=te,r.categoryValue=re,r.nestedField=ne,r.from=se,r.size=ie,r.sortBy=oe,r.aggregationField=ue,r.aggregationSize=ce,r.after=le,r.includeNullValues=he,r.includeFields=de,r.excludeFields=pe,r.fuzziness=fe,r.searchOperators=ge,r.highlight=ye,r.highlightField=me,r.customHighlight=ve,r.interval=be,r.aggregations=_e,r.missingLabel=qe,r.showMissing=we,r.execute=Re,r.enableSynonyms=Fe,r.selectAllLabel=De,r.pagination=Ae,r.queryString=Ee,r.defaultQuery=Se,r.customQuery=Ce,r.beforeValueChange=m,r.onValueChange=b,r.onResults=_,r.onAggregationData=q,r.onError=w,r.onRequestStatusChange=S,r.onQueryChange=C,r.onMicStatusChange=R,r.distinctField=Oe,r.distinctFieldConfig=xe,r.enablePopularSuggestions=D,r.maxPopularSuggestions=A,r.showDistinctSuggestions=x,r.enablePredictiveSuggestions=Q,r.preserveResults=k,r.clearOnQueryChange=P,r.stateChanges=new u,r.results=new L(O),r.aggregationData=new N,ae?r.setValue(ae,{stateChanges:!0}):r.value=ae,r}i(t,e);var c=t.prototype;return c.getSuggestionsQuery=function(){return{query:[{id:"DataSearch__suggestions",dataField:m,size:this.maxPopularSuggestions||5,value:this.value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:"count",modifier:"sqrt",missing:1}}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],fuzziness:0,operator:"or",query:this.value,type:"best_fields"}},{multi_match:{fields:["key^9","key.autosuggest^1","key.keyword^10"],operator:"or",query:this.value,type:"phrase"}},{multi_match:{fields:["key^9"],operator:"or",query:this.value,type:"phrase_prefix"}}]}}}}]}},c._appendResults=function(e){this.preserveResults&&e&&Array.isArray(e.hits&&e.hits.hits)&&Array.isArray(this.results.rawData&&this.results.rawData.hits&&this.results.rawData.hits.hits)?this.results.setRaw(s({},e,{hits:s({},e.hits,{hits:[].concat(this.results.rawData.hits.hits,e.hits.hits)})})):this.results.setRaw(e)},c._applyOptions=function(e,t,r,n){var s;("micStatus"===t&&this.onMicStatusChange&&this.onMicStatusChange(n,r),"query"===t&&this.onQueryChange&&this.onQueryChange(n,r),"value"===t&&this.onValueChange&&this.onValueChange(n,r),"error"===t&&this.onError&&this.onError(n),"results"===t&&this.onResults&&this.onResults(n,r),"aggregationData"===t&&this.onAggregationData&&this.onAggregationData(n,r),"requestStatus"===t&&this.onRequestStatusChange&&this.onRequestStatusChange(n,r),e.triggerDefaultQuery&&this.triggerDefaultQuery(),e.triggerCustomQuery&&this.triggerCustomQuery(),!1!==e.stateChanges)&&this.stateChanges.next(((s={})[t]={prev:r,next:n},s),t,this)},c._getSearchIndex=function(e){void 0===e&&(e=!1);var t=this.index;return e?t=".suggestions":this._parent&&this._parent.index&&(t=this._parent.index),t},c._fetchRequest=function(e,t){var r=this;void 0===t&&(t=!1);var n={method:"POST",body:JSON.stringify(s({},e,!!this.mongodb&&{mongodb:this._getMongoRequest()})),headers:s({},this.headers)};return new Promise((function(e,i){r._handleTransformRequest(n).then((function(n){var o=Date.now(),a=r._getSearchIndex(t);return fetch(r.url+(r.mongodb?"":"/"+a+"/_reactivesearch.v3"),n).then((function(t){var n=t.headers;if(t.headers){var a=t.headers.get("X-Search-Id");a&&(r._parent?r._parent.setQueryID(a):r.setQueryID(a))}return t.status>=500||t.status>=400?i(t):t.json().then((function(t){r._handleTransformResponse(t).then((function(t){t&&Object.prototype.hasOwnProperty.call(t,"error")&&i(t);var r=s({},t,{_timestamp:o,_headers:n});return e(r)})).catch((function(e){return console.warn("SearchBase: transformResponse rejected the promise with ",e),i(e)}))}))})).catch((function(e){return i(e)}))})).catch((function(e){return console.warn("SearchBase: transformRequest rejected the promise with ",e),i(e)}))}))},c._generateQuery=function(){var e=this;if(this._parent){var t=this._parent.getComponents(),r=[];Object.keys(t).forEach((function(n){var s=t[n];s&&s.react&&(w(s.react,n).indexOf(e.id)>-1&&r.push(n))}));var n={};return r.forEach((function(t){var r=e._parent.getComponent(t);r&&(n[t]=r.componentQuery,w(r.react,r.id).forEach((function(t){if(!n[t]){var r=e._parent.getComponent(t);if(r&&r.value){var s=r.componentQuery;s.execute=!1,n[t]=s}}})))})),{requestBody:Object.values(n),orderOfQueries:r}}return{requestBody:[],orderOfQueries:[]}},c._handleTransformResponse=function(e){return this.transformResponse&&"function"==typeof this.transformResponse?this.transformResponse(e):new Promise((function(t){return t(e)}))},c._handleTransformRequest=function(e){return this.transformRequest&&"function"==typeof this.transformRequest?this.transformRequest(e):new Promise((function(t){return t(e)}))},c._handleAggregationResponse=function(e,t,r){void 0===t&&(t=U),void 0===r&&(r=!0);var n=this.aggregationField;if(n||"string"!=typeof this.dataField||(n=this.dataField),n){var s,i=this.aggregationData;this.aggregationData.setRaw(e[n]),this.aggregationData.setData(n,null==(s=e[n])?void 0:s.buckets,this.preserveResults&&r),this._applyOptions({stateChanges:t.stateChanges},"aggregationData",i,this.aggregationData)}},c._setError=function(e,t){void 0===t&&(t=U),this._setRequestStatus($);var r=this.error;this.error=e,this._applyOptions(t,"error",r,this.error)},c._setRequestStatus=function(e){var t=this.requestStatus;this.requestStatus=e,this._applyOptions({stateChanges:!0},"requestStatus",t,this.requestStatus)},c._updateQuery=function(e){var t,r=this;t=s({},this._query);var n=[this.componentQuery];w(this.react,this.id).forEach((function(e){var t=r._parent.getComponent(e);if(t&&t.value){var s=t.componentQuery;s.execute=!1,n.push(s)}})),this._query=e||n,this._applyOptions({stateChanges:!1},"query",t,this._query)},c._getMongoRequest=function(){var e={};return this.index&&(e.index=this.index),this.mongodb&&(this.mongodb.db&&(e.db=this.mongodb.db),this.mongodb.collection&&(e.collection=this.mongodb.collection)),e},r(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===K}},{key:"micInactive",get:function(){return this._micStatus===G}},{key:"micDenied",get:function(){return this._micStatus===X}},{key:"query",get:function(){return this._query}},{key:"requestPending",get:function(){return this.requestStatus===W}},{key:"appbaseSettings",get:function(){var e=this.appbaseConfig||{};return{recordAnalytics:e.recordAnalytics,customEvents:e.customEvents,enableQueryRules:e.enableQueryRules,userId:e.userId}}},{key:"suggestions",get:function(){if(this.type&&this.type!==v)return[];if(this.results){var e=_(this.dataField)||[];return 0===e.length&&this.results.data&&Array.isArray(this.results.data)&&this.results.data.length>0&&this.results.data[0]&&(e=Object.keys(this.results.data[0]).filter((function(e){return!["_id","_click_id","_index","_score","_type"].includes(e)}))),this.enablePopularSuggestions&&(e=[].concat(e,m)),R(e,this.results.data,this.value,this.showDistinctSuggestions,this.enablePredictiveSuggestions).slice(0,this.size)}return[]}},{key:"componentQuery",get:function(){return s({id:this.id,type:this.type,dataField:_(this.dataField)},this.mongodb&&{autocompleteField:this.autocompleteField},{react:this.react,highlight:this.highlight,highlightField:_(this.highlightField),fuzziness:this.fuzziness,searchOperators:this.searchOperators,includeFields:this.includeFields,excludeFields:this.excludeFields,size:this.size,from:this.from,queryFormat:this.queryFormat,sortBy:this.sortBy,fieldWeights:q(this.dataField),includeNullValues:this.includeNullValues,aggregationField:this.aggregationField,aggregationSize:this.aggregationSize,categoryField:this.categoryField,missingLabel:this.missingLabel,showMissing:this.showMissing,nestedField:this.nestedField,interval:this.interval,customHighlight:this.customHighlight,customQuery:this.customQuery?this.customQuery(this):void 0,defaultQuery:this.defaultQuery?this.defaultQuery(this):void 0,value:this.value,categoryValue:this.categoryValue,after:this.after,aggregations:this.aggregations,enableSynonyms:this.enableSynonyms,selectAllLabel:this.selectAllLabel,pagination:this.pagination,queryString:this.queryString,distinctField:this.distinctField,distinctFieldConfig:this.distinctFieldConfig,index:this.index})}},{key:"queryId",get:function(){return this._parent&&this._parent._queryId?this._parent._queryId:this._queryId?this._queryId:""}},{key:"mappedProps",get:function(){var e=this,t={},r=s({},D);return this.mongodb&&(delete r.recordClick,delete r.recordConversions),Object.keys(D).forEach((function(r){t[D[r]]=e[r]})),t}}]),t}(V),Z=function(e){function t(t){var r,i=t.index,o=t.url,u=t.credentials,c=t.mongodb,l=t.headers,h=t.appbaseConfig,d=t.transformRequest,p=t.transformResponse;return n(a(r=e.call(this,{index:i,url:o,credentials:u,mongodb:c,headers:l,appbaseConfig:h,transformRequest:d,transformResponse:p})||this),"register",(function(e,t){if(!e)throw new Error(y.invalidComponentId);if(r._components[e])return r._components[e];var n=t;return!t||t instanceof Y?n.id=e:n=new Y(s({},t,{id:e,index:t.index||r.index,url:t.url||r.url,mongodb:t.mongodb||r.mongodb,credentials:t.credentials||r.credentials,headers:t.headers||r.headers,transformRequest:t.transformRequest||r.transformRequest,transformResponse:t.transformResponse||r.transformResponse,appbaseConfig:t.appbaseConfig||r.appbaseConfig})),r._components[e]=n,n.setParent(a(r)),n})),n(a(r),"unregister",(function(e){e&&delete r._components[e]})),n(a(r),"getComponent",(function(e){return r._components[e]})),n(a(r),"getComponents",(function(){return r._components})),r._components={},r}return i(t,e),t}(V);e.SearchBase=Z,e.SearchComponent=Y,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=searchbase.umd.min.js.map
{
"name": "@appbaseio/searchbase",
"version": "1.6.2-beta",
"version": "1.6.3-beta",
"private": false,

@@ -5,0 +5,0 @@ "description": "Headless core + common utilities for search",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc