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.0-mongo-alpha to 1.6.1-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 i(){return(i=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 s(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,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}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,i="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="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 f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(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=p(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:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&i&&((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"))},i&&(this.blob=function(){var e=f(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?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(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)},s&&(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 b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var r,n,i=(t=t||{}).body;if(e instanceof v){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,i||null==e._bodyInit||(i=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(),b.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)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function w(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)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},w.error=function(){var e=new w(null,{status:0,statusText:""});return e.type="error",e};var q=[301,302,303,307,308];w.redirect=function(e,t){if(-1===q.indexOf(t))throw new RangeError("Invalid status code");return new w(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,s){var o=new v(e,r);if(o.signal&&o.signal.aborted)return s(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 i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new w(i,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(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&&i&&(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=v,e.Response=w),t.Headers=d,t.Request=v,t.Response=w,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="",i=0,s=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|s)||(o="=",s%1);n+=o.charAt(63&i>>8-s%1*8)){if((t=r.charCodeAt(s+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|t}return n}function f(e,t){if(null==e&&!t)throw new Error("appbase-analytics: query or queryID must be present to register a click/conversion event")}var p={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 i=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(i)}).then((function(e){n&&n(null,e)})).catch((function(e){console.error(e),n&&n(e,null)}))},t.search=function(e,r){f(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(f(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(f(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"],b="search",v=function(e){var t=[];return e&&(t=[].concat(e).map((function(e){var t=function(e){var t=i({},e);return t.highlight&&Object.keys(t.highlight).forEach((function(e){var r,n=t.highlight[e][0];t._source=i({},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}),i({},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 w=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 q(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,s){void 0===e&&(e=[]),void 0===r&&(r=""),void 0===n&&(n=!0),void 0===s&&(s=!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 s=i({},{label:e,value:e,source:r});if(u=[].concat(u,[e]),a=[].concat(a,[s]),n)return!0}return!1},d=function e(t,r,i){if(void 0===r&&(r=""),void 0===i&&(i=t),"object"==typeof t){var s=r.split("."),o=t[s[0]];if(o)if(s.length>1){var a=r.substring(s[0].length+1);Array.isArray(o)?o.forEach((function(t){e(t,a,i)})):e(o,a,i)}else{var u=S(o);if(u){if(Array.isArray(u)){if(n)return u.some((function(e){return h(e,0,i)}));u.forEach((function(e){return h(e,0,i)}))}return h(u,0,i)}}}return!1},f=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 f(),a.length<t.length&&!c&&(c=!0,f()),s?function(e){var t=e.suggestions,r=e.currentValue,n=e.wordsToShowAfterHighlight,s={};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 f=c.slice(d.index,c.length).slice(a.length).split(" ").slice(0,n+1).join(" "),p=a+'<mark class="highlight">'+f+"</mark>",g=""+a+f;return s[p]?e:(s[p]=1,[].concat(e,[i({},u,{label:p,value:g,isPredictiveSuggestion:!0})]))}return e}),[])}return[]}({suggestions:a,currentValue:r,wordsToShowAfterHighlight:!0}):a};function k(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(!k(e[r],t[r]))return!1}}for(var n in t)if(t.hasOwnProperty(n)&&!e.hasOwnProperty(n))return!1;return!0}var F={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 D(e){void 0===e&&(e="");for(var t,r=e,n="",i=0,s=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|s)||(o="=",s%1);n+=o.charAt(63&i>>8-s%1*8)){if((t=r.charCodeAt(s+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|t}return n}var A="SearchBase",E="SearchBox",O="SearchComponent",x={MONGODB:"mongodb",ELASTICSEARCH:"elasticsearch"},I="array",Q="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 i=Object.keys(e).filter((function(t){return!!e[t]})),s=Object.keys(t),o=[],a=[];s.forEach((function(e){var r=t[e];r.components.includes(n)&&(a.push(e),r.required&&o.push(e))})),o.forEach((function(e){if(!i.includes(e))throw new Error(e+" is required for <"+n+" /> component when used with an "+r+" Search backend.")})),i.forEach((function(r){if(!a.includes(r))throw new Error("<"+n+" /> component doesn't accept a property "+r+".");var i,s=Array.isArray(t[r].type)?t[r].type:[].concat(t[r].type),o=typeof(i=e[r])===P?Array.isArray(i)?I:P:typeof i;if(!s.includes(o))throw new Error("<"+n+" /> component accepts a property "+r+" with type(s) ["+s.join(", ")+"], but type was set as "+o+".")}))}var M=x.MONGODB,V=x.ELASTICSEARCH,L={url:{components:[A],backend:[V,M],type:B,required:!0},index:{components:[A,E,O],backend:[V,M],type:B,required:!1},credentials:{components:[A],backend:[V,M],type:B,required:!1},appbaseConfig:{components:[A],backend:[V],type:P,required:!1},headers:{components:[A,E,O],backend:[V,M],type:P,required:!1},transformRequest:{components:[A,E,O],backend:[V,M],type:Q,required:!1},transformResponse:{components:[A,E,O],backend:[V,M],type:Q,required:!1},mongodb:{components:[A],backend:[M],type:P,required:!1},id:{components:[E,O],backend:[V,M],type:B,required:!0},dataField:{components:[E,O],backend:[V,M],type:[I,B],required:!1},autocompleteField:{components:[E,O],backend:[M],type:[I,B],required:!1},queryFormat:{components:[E,O],backend:[V],type:B,required:!1},react:{components:[E,O],backend:[V,M],type:P,required:!1},size:{components:[E,O],backend:[V,M],type:j,required:!1},from:{components:[E,O],backend:[V,M],type:j,required:!1},includeFields:{components:[E,O],backend:[V,M],type:I,required:!1},excludeFields:{components:[E,O],backend:[V,M],type:I,required:!1},sortBy:{components:[E,O],backend:[V,M],type:B,required:!1},aggregationField:{components:[E,O],backend:[V],type:B,required:!1},aggregationSize:{components:[E,O],backend:[V,M],type:j,required:!1},highlight:{components:[E,O],backend:[V,M],type:T,required:!1},highlightField:{components:[E,O],backend:[V,M],type:B,required:!1},customHighlight:{components:[E,O],backend:[V],type:P,required:!1},highlightConfig:{components:[E,O],backend:[M],type:P,required:!1},categoryField:{components:[E,O],backend:[V],type:B,required:!1},categoryValue:{components:[E,O],backend:[V],type:B,required:!1},nestedField:{components:[E,O],backend:[V],type:B,required:!1},fuzziness:{components:[E,O],backend:[V,M],type:[B,j],required:!1},enableSynonyms:{components:[E,O],backend:[V,M],type:T,required:!1},searchOperators:{components:[E,O],backend:[V],type:T,required:!1},queryString:{components:[E,O],backend:[V,M],type:B,required:!1},distinctField:{components:[E,O],backend:[V],type:B,required:!1},distinctFieldConfig:{components:[E,O],backend:[V],type:P,required:!1},enableRecentSuggestions:{components:[E],backend:[V],type:T,required:!1},enablePopularSuggestions:{components:[E],backend:[V],type:T,required:!1},recentSuggestionsConfig:{components:[E],backend:[V],type:P,required:!1},popularSuggestionsConfig:{components:[E],backend:[V],type:P,required:!1},enablePredictiveSuggestions:{components:[E],backend:[V],type:T,required:!1},maxPredictedWords:{components:[E],backend:[V],type:j,required:!1},urlField:{components:[E],backend:[V],type:B,required:!1},pagination:{components:[O],backend:[V],type:T,required:!1},after:{components:[O],backend:[V],type:P,required:!1},showMissing:{components:[O],backend:[V],type:T,required:!1},includeNullValues:{components:[O],backend:[V],type:T,required:!1},interval:{components:[O],backend:[V],type:j,required:!1},aggregations:{components:[O],backend:[V],type:I,required:!1},defaultQuery:{components:[E,O],backend:[V,M],type:[Q,P],required:!1},customQuery:{components:[E,O],backend:[V,M],type:[Q,P],required:!1}},N=function(){function e(e){var t=e.index,r=e.url,n=e.credentials,s=e.headers,o=e.mongodb,a=e.appbaseConfig,u=e.transformRequest,c=e.transformResponse;z({index:t,url:r,credentials:n,headers:s,mongodb:o,appbaseConfig:a,transformRequest:u,transformResponse:c},L,x[o?"MONGODB":"ELASTICSEARCH"],A),this.index=t,this.url=r,this.credentials=n||"",this.mongodb=o,a&&(this.appbaseConfig=a),u&&(this.transformRequest=u),c&&(this.transformResponse=c),this.headers={Accept:"application/json","Content-Type":"application/json"},this.credentials&&(this.headers=i({},this.headers,{Authorization:"Basic "+D(this.credentials)})),s&&this.setHeaders(s),this.mongodb||(this._analyticsInstance=p.init({index:t,url:r,credentials:n}))}var t=e.prototype;return t.setHeaders=function(e){this.headers=i({},this.headers,e)},t.setQueryID=function(e){this._queryId=e},e}(),U=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=v(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 i({},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 i({},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,s,o=(n=e,void 0===(s=t)&&(s=[]),s.map((function(e){var t=e.doc_count,r=e.key,s=e[n];return i({_doc_count:t,_key:void 0!==r[n]?r[n]:r},s)})));this.data=r?[].concat(this.data,o):o},r(e,[{key:"rawData",get:function(){return this.raw||{}}}]),e}(),G={triggerDefaultQuery:!0,triggerCustomQuery:!1,stateChanges:!0},K={stateChanges:!0},J="INACTIVE",X="ACTIVE",W="DENIED",$="INACTIVE",Y="PENDING",Z="ERROR",ee=function(e){function t(t){var r,s=t.index,c=t.url,l=t.credentials,h=t.mongodb,d=t.appbaseConfig,f=t.headers,p=t.transformRequest,g=t.transformResponse,m=t.beforeValueChange,v=t.onValueChange,_=t.onResults,w=t.onAggregationData,q=t.onError,S=t.onRequestStatusChange,C=t.onQueryChange,R=t.onMicStatusChange,F=t.enablePopularSuggestions,D=t.maxPopularSuggestions,A=t.results,E=t.showDistinctSuggestions,O=t.enablePredictiveSuggestions,I=t.preserveResults,Q=t.clearOnQueryChange,P=t.autocompleteField,j=t.componentName,T=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:s,url:c,credentials:l,mongodb:h,headers:f,appbaseConfig:d,transformRequest:p,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!==W){n===X&&r._setMicStatus(J,t);var i=window.SpeechRecognition;if(r._micInstance)return void r._stopMic();r._micInstance=new i,r._micInstance.continuous=!0,r._micInstance.interimResults=!0,Object.assign(r._micInstance,e),r._micInstance.start(),r._micInstance.onstart=function(){r._setMicStatus(X,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(J,t):"not-allowed"===e.error&&r._setMicStatus(W,t),console.error(e)}}})),n(a(r),"setDataField",(function(e,t){void 0===t&&(t=G);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=G);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=G);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=G);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=G);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=G);var n=r.includeFields;r.includeFields=e,r._applyOptions(t,"includeFields",n,e)})),n(a(r),"setExcludeFields",(function(e,t){void 0===t&&(t=G);var n=r.excludeFields;r.excludeFields=e,r._applyOptions(t,"excludeFields",n,e)})),n(a(r),"setSortBy",(function(e,t){void 0===t&&(t=G);var n=r.sortBy;r.sortBy=e,r._applyOptions(t,"sortBy",n,e)})),n(a(r),"setReact",(function(e,t){void 0===t&&(t=G);var n=r.react;r.react=e,r._applyOptions(t,"react",n,e)})),n(a(r),"setDefaultQuery",(function(e,t){void 0===t&&(t=G);var n=r.defaultQuery;r.defaultQuery=e,r._applyOptions(t,"defaultQuery",n,e)})),n(a(r),"setCustomQuery",(function(e,t){void 0===t&&(t=G);var n=r.customQuery;r.customQuery=e,r._applyOptions(t,"customQuery",n,e)})),n(a(r),"setAfter",(function(e,t){void 0===t&&(t=G);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=K),k(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(Y),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 s=r.results,o=n&&n[r.id],a=function(){o.aggregations&&r._handleAggregationResponse(o.aggregations,i({defaultOptions:G},e)),r._setRequestStatus($),r._applyOptions({stateChanges:e.stateChanges},"results",s,r.results)};return r.type&&r.type!==b||!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 i({},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=K);var t=r._generateQuery(),n=t.requestBody,s=t.orderOfQueries;if(!n.length)return Promise.resolve({});if(k(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{s.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(Y),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?(s.forEach((function(n){var s=r._parent.getComponent(n);if(s){s._setRequestStatus($);var o=s.results,a=t&&t[n];a.hits&&(s.results.setRaw(a),s._applyOptions({stateChanges:e.stateChanges},"results",o,s.results)),a.aggregations&&s._handleAggregationResponse(a.aggregations,i({defaultOptions:G},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=K);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=K);var n={headers:i({},r.headers)},s="",o=function(e,t){s+=s?"&"+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,i){fetch(r.url+"/_analytics"+(r.mongodb?"":"/"+r._getSearchIndex())+"/recent-searches?"+s,n).then((function(n){return n.status>=500||n.status>=400?i(n):n.json().then((function(n){var i=r.recentSearches;r.recentSearches=n.map((function(e){return{label:e.key,value:e.key}})),r._applyOptions({stateChanges:t.stateChanges},"recentSearches",i,r.recentSearches),e(r.recentSearches)})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),i(e)}))})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),i(e)}))}))})),n(a(r),"_handleVoiceResults",(function(e,t){var n=e.results;void 0===t&&(t=G),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(),i({},t,{triggerCustomQuery:!0,triggerDefaultQuery:!0}))})),n(a(r),"_stopMic",(function(){r._micInstance&&(r._micInstance.stop(),r._micInstance=null,r._setMicStatus(J))})),n(a(r),"_setMicStatus",(function(e,t){void 0===t&&(t=G);var n=r._micStatus;r._micStatus=e,r._applyOptions(t,"micStatus",n,r._micStatus)}));var B=x[h?"MONGODB":"ELASTICSEARCH"];z(i({enablePopularSuggestions:F,enablePredictiveSuggestions:O,autocompleteField:P},T),L,B,j);var M=T.id,V=T.type,N=T.react,Z=T.queryFormat,ee=T.dataField,te=T.categoryField,re=T.categoryValue,ne=T.nestedField,ie=T.from,se=T.size,oe=T.sortBy,ae=T.value,ue=T.aggregationField,ce=T.aggregationSize,le=T.after,he=T.includeNullValues,de=T.includeFields,fe=T.excludeFields,pe=T.fuzziness,ge=T.searchOperators,ye=T.highlight,me=T.highlightField,be=T.customHighlight,ve=T.interval,_e=T.aggregations,we=T.missingLabel,qe=T.showMissing,Se=T.defaultQuery,Ce=T.customQuery,Re=T.execute,ke=T.enableSynonyms,Fe=T.selectAllLabel,De=T.pagination,Ae=T.queryString,Ee=T.distinctField,Oe=T.distinctFieldConfig;if(!M)throw new Error(y.invalidComponentId);if(V&&V!==b&&Array.isArray(ee))throw new Error(y.dataFieldAsArray);return r.id=M,r.type=V,r.react=N,r.queryFormat=Z,r.dataField=ee,r.autocompleteField=P,r.categoryField=te,r.categoryValue=re,r.nestedField=ne,r.from=ie,r.size=se,r.sortBy=oe,r.aggregationField=ue,r.aggregationSize=ce,r.after=le,r.includeNullValues=he,r.includeFields=de,r.excludeFields=fe,r.fuzziness=pe,r.searchOperators=ge,r.highlight=ye,r.highlightField=me,r.customHighlight=be,r.interval=ve,r.aggregations=_e,r.missingLabel=we,r.showMissing=qe,r.execute=Re,r.enableSynonyms=ke,r.selectAllLabel=Fe,r.pagination=De,r.queryString=Ae,r.defaultQuery=Se,r.customQuery=Ce,r.beforeValueChange=m,r.onValueChange=v,r.onResults=_,r.onAggregationData=w,r.onError=q,r.onRequestStatusChange=S,r.onQueryChange=C,r.onMicStatusChange=R,r.distinctField=Ee,r.distinctFieldConfig=Oe,r.enablePopularSuggestions=F,r.maxPopularSuggestions=D,r.showDistinctSuggestions=E,r.enablePredictiveSuggestions=O,r.preserveResults=I,r.clearOnQueryChange=Q,r.stateChanges=new u,r.results=new U(A),r.aggregationData=new H,ae?r.setValue(ae,{stateChanges:!0}):r.value=ae,r}s(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(i({},e,{hits:i({},e.hits,{hits:[].concat(this.results.rawData.hits.hits,e.hits.hits)})})):this.results.setRaw(e)},c._applyOptions=function(e,t,r,n){var i;("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(((i={})[t]={prev:r,next:n},i),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._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},c._fetchRequest=function(e,t){var r=this;void 0===t&&(t=!1);var n={method:"POST",body:JSON.stringify(i({},e,!!this.mongodb&&{mongodb:this._getMongoRequest()})),headers:i({},this.headers)};return new Promise((function(e,s){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?s(t):t.json().then((function(t){r._handleTransformResponse(t).then((function(t){t&&Object.prototype.hasOwnProperty.call(t,"error")&&s(t);var r=i({},t,{_timestamp:o,_headers:n});return e(r)})).catch((function(e){return console.warn("SearchBase: transformResponse rejected the promise with ",e),s(e)}))}))})).catch((function(e){return s(e)}))})).catch((function(e){return console.warn("SearchBase: transformRequest rejected the promise with ",e),s(e)}))}))},c._generateQuery=function(){var e=this;if(this._parent){var t=this._parent.getComponents(),r=[];Object.keys(t).forEach((function(n){var i=t[n];i&&i.react&&(q(i.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,q(r.react,r.id).forEach((function(t){if(!n[t]){var r=e._parent.getComponent(t);if(r&&r.value){var i=r.componentQuery;i.execute=!1,n[t]=i}}})))})),{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=G),void 0===r&&(r=!0);var n=this.aggregationField;if(n||"string"!=typeof this.dataField||(n=this.dataField),n){var i,s=this.aggregationData;this.aggregationData.setRaw(e[n]),this.aggregationData.setData(n,null==(i=e[n])?void 0:i.buckets,this.preserveResults&&r),this._applyOptions({stateChanges:t.stateChanges},"aggregationData",s,this.aggregationData)}},c._setError=function(e,t){void 0===t&&(t=G),this._setRequestStatus(Z);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=i({},this._query);var n=[this.componentQuery];q(this.react,this.id).forEach((function(e){var t=r._parent.getComponent(e);if(t&&t.value){var i=t.componentQuery;i.execute=!1,n.push(i)}})),this._query=e||n,this._applyOptions({stateChanges:!1},"query",t,this._query)},r(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===X}},{key:"micInactive",get:function(){return this._micStatus===J}},{key:"micDenied",get:function(){return this._micStatus===W}},{key:"query",get:function(){return this._query}},{key:"requestPending",get:function(){return this.requestStatus===Y}},{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!==b)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 i({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:w(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=i({},F);return this.mongodb&&(delete r.recordClick,delete r.recordConversions),Object.keys(F).forEach((function(r){t[F[r]]=e[r]})),t}}]),t}(N),te=function(e){function t(t){var r,s=t.index,o=t.url,u=t.credentials,c=t.mongodb,l=t.headers,h=t.appbaseConfig,d=t.transformRequest,f=t.transformResponse;return n(a(r=e.call(this,{index:s,url:o,credentials:u,mongodb:c,headers:l,appbaseConfig:h,transformRequest:d,transformResponse:f})||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 ee?n.id=e:n=new ee(i({},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 s(t,e),t}(N);e.SearchBase=te,e.SearchComponent=ee,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 i(){return(i=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 s(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,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}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,i="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="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 d(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 h(e){this.map={},e instanceof h?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 f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(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=p(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:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&i&&((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"))},i&&(this.blob=function(){var e=f(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?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(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)},s&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(e,t){e=c(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},h.prototype.delete=function(e){delete this.map[c(e)]},h.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},h.prototype.set=function(e,t){this.map[c(e)]=l(t)},h.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},h.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),d(e)},h.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},h.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),d(e)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var r,n,i=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=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 h(t.headers)),this.method=(r=t.method||this.method||"GET",n=r.toUpperCase(),b.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)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function w(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 h(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var e=new w(null,{status:0,statusText:""});return e.type="error",e};var q=[301,302,303,307,308];w.redirect=function(e,t){if(-1===q.indexOf(t))throw new RangeError("Invalid status code");return new w(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,s){var o=new v(e,r);if(o.signal&&o.signal.aborted)return s(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 h,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new w(i,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(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&&i&&(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=h,e.Request=v,e.Response=w),t.Headers=h,t.Request=v,t.Response=w,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 d(){return(d=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 h(e){void 0===e&&(e="");for(var t,r=e,n="",i=0,s=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|s)||(o="=",s%1);n+=o.charAt(63&i>>8-s%1*8)){if((t=r.charCodeAt(s+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|t}return n}function f(e,t){if(null==e&&!t)throw new Error("appbase-analytics: query or queryID must be present to register a click/conversion event")}var p={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 i=d({},r,{user_id:t.userID,event_data:d({},r&&r.event_data,{},t.globalEventData)});return l(t.url+"/"+t.index+"/_analytics/"+e,{method:"PUT",headers:d({},t.headers,{"Content-Type":"application/json",Authorization:"Basic "+h(t.credentials)}),body:JSON.stringify(i)}).then((function(e){n&&n(null,e)})).catch((function(e){console.error(e),n&&n(e,null)}))},t.search=function(e,r){f(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(f(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(f(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"],b="search",v=function(e){var t=[];return e&&(t=[].concat(e).map((function(e){var t=function(e){var t=i({},e);return t.highlight&&Object.keys(t.highlight).forEach((function(e){var r,n=t.highlight[e][0];t._source=i({},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}),i({},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 w=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 q(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 k=function(e,t,r,n,s){void 0===e&&(e=[]),void 0===r&&(r=""),void 0===n&&(n=!0),void 0===s&&(s=!1);var a=[],u=[],c=!1,l=r||"",d=function(e,t,r){if((c||l.trim().split(" ").some((function(t){return String(e).toLowerCase().includes(t)})))&&!u.includes(e)||r._promoted){var s=i({},{label:e,value:e,source:r});if(u=[].concat(u,[e]),a=[].concat(a,[s]),n)return!0}return!1},h=function e(t,r,i){if(void 0===r&&(r=""),void 0===i&&(i=t),"object"==typeof t){var s=r.split("."),o=t[s[0]];if(o)if(s.length>1){var a=r.substring(s[0].length+1);Array.isArray(o)?o.forEach((function(t){e(t,a,i)})):e(o,a,i)}else{var u=S(o);if(u){if(Array.isArray(u)){if(n)return u.some((function(e){return d(e,0,i)}));u.forEach((function(e){return d(e,0,i)}))}return d(u,0,i)}}}return!1},f=function(){n?t.forEach((function(t){e.some((function(e){return h(t,e)}))})):t.forEach((function(t){e.forEach((function(e){h(t,e)}))}))};return f(),a.length<t.length&&!c&&(c=!0,f()),s?function(e){var t=e.suggestions,r=e.currentValue,n=e.wordsToShowAfterHighlight,s={};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+",d=new RegExp(l,"i"),h=d.exec(c);if(h||(l="^("+C(a)+")",h=(d=new RegExp(l,"i")).exec(c)),h){var f=c.slice(h.index,c.length).slice(a.length).split(" ").slice(0,n+1).join(" "),p=a+'<mark class="highlight">'+f+"</mark>",g=""+a+f;return s[p]?e:(s[p]=1,[].concat(e,[i({},u,{label:p,value:g,isPredictiveSuggestion:!0})]))}return e}),[])}return[]}({suggestions:a,currentValue:r,wordsToShowAfterHighlight:!0}):a};function R(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(!R(e[r],t[r]))return!1}}for(var n in t)if(t.hasOwnProperty(n)&&!e.hasOwnProperty(n))return!1;return!0}var F={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 D(e){void 0===e&&(e="");for(var t,r=e,n="",i=0,s=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.charAt(0|s)||(o="=",s%1);n+=o.charAt(63&i>>8-s%1*8)){if((t=r.charCodeAt(s+=3/4))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|t}return n}var A="SearchBase",E="SearchBox",O="SearchComponent",x={MONGODB:"mongodb",ELASTICSEARCH:"elasticsearch"},I="array",Q="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 i=Object.keys(e).filter((function(t){return!!e[t]})),s=Object.keys(t),o=[],a=[];s.forEach((function(e){var r=t[e];r.components.includes(n)&&(a.push(e),r.required&&o.push(e))})),o.forEach((function(e){if(!i.includes(e))throw new Error(e+" is required for <"+n+" /> component when used with an "+r+" Search backend.")})),i.forEach((function(r){if(!a.includes(r))throw new Error("<"+n+" /> component doesn't accept a property "+r+".");var i,s=Array.isArray(t[r].type)?t[r].type:[].concat(t[r].type),o=typeof(i=e[r])===P?Array.isArray(i)?I:P:typeof i;if(!s.includes(o))throw new Error("<"+n+" /> component accepts a property "+r+" with type(s) ["+s.join(", ")+"], but type was set as "+o+".")}))}var M=x.MONGODB,V=x.ELASTICSEARCH,L={url:{components:[A],backend:[V,M],type:B,required:!0},index:{components:[A,E,O],backend:[V,M],type:B,required:!1},credentials:{components:[A],backend:[V,M],type:B,required:!1},appbaseConfig:{components:[A],backend:[V],type:P,required:!1},headers:{components:[A,E,O],backend:[V,M],type:P,required:!1},transformRequest:{components:[A,E,O],backend:[V,M],type:Q,required:!1},transformResponse:{components:[A,E,O],backend:[V,M],type:Q,required:!1},mongodb:{components:[A],backend:[M],type:P,required:!1},id:{components:[E,O],backend:[V,M],type:B,required:!0},dataField:{components:[E,O],backend:[V,M],type:[I,B],required:!1},autocompleteField:{components:[E,O],backend:[M],type:[I,B],required:!1},queryFormat:{components:[E,O],backend:[V],type:B,required:!1},react:{components:[E,O],backend:[V,M],type:P,required:!1},size:{components:[E,O],backend:[V,M],type:j,required:!1},from:{components:[E,O],backend:[V,M],type:j,required:!1},includeFields:{components:[E,O],backend:[V,M],type:I,required:!1},excludeFields:{components:[E,O],backend:[V,M],type:I,required:!1},sortBy:{components:[E,O],backend:[V,M],type:B,required:!1},aggregationField:{components:[E,O],backend:[V],type:B,required:!1},aggregationSize:{components:[E,O],backend:[V,M],type:j,required:!1},highlight:{components:[E,O],backend:[V,M],type:T,required:!1},highlightField:{components:[E,O],backend:[V,M],type:B,required:!1},customHighlight:{components:[E,O],backend:[V],type:P,required:!1},highlightConfig:{components:[E,O],backend:[M],type:P,required:!1},categoryField:{components:[E,O],backend:[V],type:B,required:!1},categoryValue:{components:[E,O],backend:[V],type:B,required:!1},nestedField:{components:[E,O],backend:[V],type:B,required:!1},fuzziness:{components:[E,O],backend:[V,M],type:[B,j],required:!1},enableSynonyms:{components:[E,O],backend:[V,M],type:T,required:!1},searchOperators:{components:[E,O],backend:[V],type:T,required:!1},queryString:{components:[E,O],backend:[V,M],type:B,required:!1},distinctField:{components:[E,O],backend:[V],type:B,required:!1},distinctFieldConfig:{components:[E,O],backend:[V],type:P,required:!1},enableRecentSuggestions:{components:[E],backend:[V],type:T,required:!1},enablePopularSuggestions:{components:[E],backend:[V],type:T,required:!1},recentSuggestionsConfig:{components:[E],backend:[V],type:P,required:!1},popularSuggestionsConfig:{components:[E],backend:[V],type:P,required:!1},enablePredictiveSuggestions:{components:[E],backend:[V],type:T,required:!1},maxPredictedWords:{components:[E],backend:[V],type:j,required:!1},urlField:{components:[E],backend:[V],type:B,required:!1},pagination:{components:[O],backend:[V],type:T,required:!1},after:{components:[O],backend:[V],type:P,required:!1},showMissing:{components:[O],backend:[V],type:T,required:!1},includeNullValues:{components:[O],backend:[V],type:T,required:!1},interval:{components:[O],backend:[V],type:j,required:!1},aggregations:{components:[O],backend:[V],type:I,required:!1},defaultQuery:{components:[E,O],backend:[V,M],type:[Q,P],required:!1},customQuery:{components:[E,O],backend:[V,M],type:[Q,P],required:!1},value:{components:[E,O],backend:[V,M],type:[B,I,P],required:!1},type:{components:[E,O],backend:[V,M],type:B,required:!1}},N=function(){function e(e){var t=e.index,r=e.url,n=e.credentials,s=e.headers,o=e.mongodb,a=e.appbaseConfig,u=e.transformRequest,c=e.transformResponse;z({index:t,url:r,credentials:n,headers:s,mongodb:o,appbaseConfig:a,transformRequest:u,transformResponse:c},L,x[o?"MONGODB":"ELASTICSEARCH"],A),this.index=t,this.url=r,this.credentials=n||"",this.mongodb=o,a&&(this.appbaseConfig=a),u&&(this.transformRequest=u),c&&(this.transformResponse=c),this.headers={Accept:"application/json","Content-Type":"application/json"},this.credentials&&(this.headers=i({},this.headers,{Authorization:"Basic "+D(this.credentials)})),s&&this.setHeaders(s),this.mongodb||(this._analyticsInstance=p.init({index:t,url:r,credentials:n}))}var t=e.prototype;return t.setHeaders=function(e){this.headers=i({},this.headers,e)},t.setQueryID=function(e){this._queryId=e},e}(),U=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=v(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 i({},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 i({},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,s,o=(n=e,void 0===(s=t)&&(s=[]),s.map((function(e){var t=e.doc_count,r=e.key,s=e[n];return i({_doc_count:t,_key:void 0!==r[n]?r[n]:r},s)})));this.data=r?[].concat(this.data,o):o},r(e,[{key:"rawData",get:function(){return this.raw||{}}}]),e}(),G={triggerDefaultQuery:!0,triggerCustomQuery:!1,stateChanges:!0},K={stateChanges:!0},J="INACTIVE",X="ACTIVE",W="DENIED",$="INACTIVE",Y="PENDING",Z="ERROR",ee=function(e){function t(t){var r,s=t.index,c=t.url,l=t.credentials,d=t.mongodb,h=t.appbaseConfig,f=t.headers,p=t.transformRequest,g=t.transformResponse,m=t.beforeValueChange,v=t.onValueChange,_=t.onResults,w=t.onAggregationData,q=t.onError,S=t.onRequestStatusChange,C=t.onQueryChange,k=t.onMicStatusChange,F=t.enablePopularSuggestions,D=t.maxPopularSuggestions,A=t.results,E=t.showDistinctSuggestions,O=t.enablePredictiveSuggestions,I=t.preserveResults,Q=t.clearOnQueryChange,P=t.autocompleteField,j=t.componentName,T=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:s,url:c,credentials:l,mongodb:d,headers:f,appbaseConfig:h,transformRequest:p,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!==W){n===X&&r._setMicStatus(J,t);var i=window.SpeechRecognition;if(r._micInstance)return void r._stopMic();r._micInstance=new i,r._micInstance.continuous=!0,r._micInstance.interimResults=!0,Object.assign(r._micInstance,e),r._micInstance.start(),r._micInstance.onstart=function(){r._setMicStatus(X,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(J,t):"not-allowed"===e.error&&r._setMicStatus(W,t),console.error(e)}}})),n(a(r),"setDataField",(function(e,t){void 0===t&&(t=G);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=G);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=G);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=G);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=G);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=G);var n=r.includeFields;r.includeFields=e,r._applyOptions(t,"includeFields",n,e)})),n(a(r),"setExcludeFields",(function(e,t){void 0===t&&(t=G);var n=r.excludeFields;r.excludeFields=e,r._applyOptions(t,"excludeFields",n,e)})),n(a(r),"setSortBy",(function(e,t){void 0===t&&(t=G);var n=r.sortBy;r.sortBy=e,r._applyOptions(t,"sortBy",n,e)})),n(a(r),"setReact",(function(e,t){void 0===t&&(t=G);var n=r.react;r.react=e,r._applyOptions(t,"react",n,e)})),n(a(r),"setDefaultQuery",(function(e,t){void 0===t&&(t=G);var n=r.defaultQuery;r.defaultQuery=e,r._applyOptions(t,"defaultQuery",n,e)})),n(a(r),"setCustomQuery",(function(e,t){void 0===t&&(t=G);var n=r.customQuery;r.customQuery=e,r._applyOptions(t,"customQuery",n,e)})),n(a(r),"setAfter",(function(e,t){void 0===t&&(t=G);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=K),R(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(Y),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 s=r.results,o=n&&n[r.id],a=function(){o.aggregations&&r._handleAggregationResponse(o.aggregations,i({defaultOptions:G},e)),r._setRequestStatus($),r._applyOptions({stateChanges:e.stateChanges},"results",s,r.results)};return r.type&&r.type!==b||!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 i({},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=K);var t=r._generateQuery(),n=t.requestBody,s=t.orderOfQueries;if(!n.length)return Promise.resolve({});if(R(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{s.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(Y),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?(s.forEach((function(n){var s=r._parent.getComponent(n);if(s){s._setRequestStatus($);var o=s.results,a=t&&t[n];a.hits&&(s.results.setRaw(a),s._applyOptions({stateChanges:e.stateChanges},"results",o,s.results)),a.aggregations&&s._handleAggregationResponse(a.aggregations,i({defaultOptions:G},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=K);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=K);var n={headers:i({},r.headers)},s="",o=function(e,t){s+=s?"&"+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,i){fetch(r.url+"/_analytics"+(r.mongodb?"":"/"+r._getSearchIndex())+"/recent-searches?"+s,n).then((function(n){return n.status>=500||n.status>=400?i(n):n.json().then((function(n){var i=r.recentSearches;r.recentSearches=n.map((function(e){return{label:e.key,value:e.key}})),r._applyOptions({stateChanges:t.stateChanges},"recentSearches",i,r.recentSearches),e(r.recentSearches)})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),i(e)}))})).catch((function(e){return console.warn("SearchBase: error while fetching the recent searches ",e),i(e)}))}))})),n(a(r),"_handleVoiceResults",(function(e,t){var n=e.results;void 0===t&&(t=G),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(),i({},t,{triggerCustomQuery:!0,triggerDefaultQuery:!0}))})),n(a(r),"_stopMic",(function(){r._micInstance&&(r._micInstance.stop(),r._micInstance=null,r._setMicStatus(J))})),n(a(r),"_setMicStatus",(function(e,t){void 0===t&&(t=G);var n=r._micStatus;r._micStatus=e,r._applyOptions(t,"micStatus",n,r._micStatus)}));var B=x[d?"MONGODB":"ELASTICSEARCH"];z(i({enablePopularSuggestions:F,enablePredictiveSuggestions:O,autocompleteField:P},T),L,B,j);var M=T.id,V=T.type,N=T.react,Z=T.queryFormat,ee=T.dataField,te=T.categoryField,re=T.categoryValue,ne=T.nestedField,ie=T.from,se=T.size,oe=T.sortBy,ae=T.value,ue=T.aggregationField,ce=T.aggregationSize,le=T.after,de=T.includeNullValues,he=T.includeFields,fe=T.excludeFields,pe=T.fuzziness,ge=T.searchOperators,ye=T.highlight,me=T.highlightField,be=T.customHighlight,ve=T.interval,_e=T.aggregations,we=T.missingLabel,qe=T.showMissing,Se=T.defaultQuery,Ce=T.customQuery,ke=T.execute,Re=T.enableSynonyms,Fe=T.selectAllLabel,De=T.pagination,Ae=T.queryString,Ee=T.distinctField,Oe=T.distinctFieldConfig;if(!M)throw new Error(y.invalidComponentId);if(V&&V!==b&&Array.isArray(ee))throw new Error(y.dataFieldAsArray);return r.id=M,r.type=V,r.react=N,r.queryFormat=Z,r.dataField=ee,r.autocompleteField=P,r.categoryField=te,r.categoryValue=re,r.nestedField=ne,r.from=ie,r.size=se,r.sortBy=oe,r.aggregationField=ue,r.aggregationSize=ce,r.after=le,r.includeNullValues=de,r.includeFields=he,r.excludeFields=fe,r.fuzziness=pe,r.searchOperators=ge,r.highlight=ye,r.highlightField=me,r.customHighlight=be,r.interval=ve,r.aggregations=_e,r.missingLabel=we,r.showMissing=qe,r.execute=ke,r.enableSynonyms=Re,r.selectAllLabel=Fe,r.pagination=De,r.queryString=Ae,r.defaultQuery=Se,r.customQuery=Ce,r.beforeValueChange=m,r.onValueChange=v,r.onResults=_,r.onAggregationData=w,r.onError=q,r.onRequestStatusChange=S,r.onQueryChange=C,r.onMicStatusChange=k,r.distinctField=Ee,r.distinctFieldConfig=Oe,r.enablePopularSuggestions=F,r.maxPopularSuggestions=D,r.showDistinctSuggestions=E,r.enablePredictiveSuggestions=O,r.preserveResults=I,r.clearOnQueryChange=Q,r.stateChanges=new u,r.results=new U(A),r.aggregationData=new H,ae?r.setValue(ae,{stateChanges:!0}):r.value=ae,r}s(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(i({},e,{hits:i({},e.hits,{hits:[].concat(this.results.rawData.hits.hits,e.hits.hits)})})):this.results.setRaw(e)},c._applyOptions=function(e,t,r,n){var i;("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(((i={})[t]={prev:r,next:n},i),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._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},c._fetchRequest=function(e,t){var r=this;void 0===t&&(t=!1);var n={method:"POST",body:JSON.stringify(i({},e,!!this.mongodb&&{mongodb:this._getMongoRequest()})),headers:i({},this.headers)};return new Promise((function(e,s){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?s(t):t.json().then((function(t){r._handleTransformResponse(t).then((function(t){t&&Object.prototype.hasOwnProperty.call(t,"error")&&s(t);var r=i({},t,{_timestamp:o,_headers:n});return e(r)})).catch((function(e){return console.warn("SearchBase: transformResponse rejected the promise with ",e),s(e)}))}))})).catch((function(e){return s(e)}))})).catch((function(e){return console.warn("SearchBase: transformRequest rejected the promise with ",e),s(e)}))}))},c._generateQuery=function(){var e=this;if(this._parent){var t=this._parent.getComponents(),r=[];Object.keys(t).forEach((function(n){var i=t[n];i&&i.react&&(q(i.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,q(r.react,r.id).forEach((function(t){if(!n[t]){var r=e._parent.getComponent(t);if(r&&r.value){var i=r.componentQuery;i.execute=!1,n[t]=i}}})))})),{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=G),void 0===r&&(r=!0);var n=this.aggregationField;if(n||"string"!=typeof this.dataField||(n=this.dataField),n){var i,s=this.aggregationData;this.aggregationData.setRaw(e[n]),this.aggregationData.setData(n,null==(i=e[n])?void 0:i.buckets,this.preserveResults&&r),this._applyOptions({stateChanges:t.stateChanges},"aggregationData",s,this.aggregationData)}},c._setError=function(e,t){void 0===t&&(t=G),this._setRequestStatus(Z);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=i({},this._query);var n=[this.componentQuery];q(this.react,this.id).forEach((function(e){var t=r._parent.getComponent(e);if(t&&t.value){var i=t.componentQuery;i.execute=!1,n.push(i)}})),this._query=e||n,this._applyOptions({stateChanges:!1},"query",t,this._query)},r(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===X}},{key:"micInactive",get:function(){return this._micStatus===J}},{key:"micDenied",get:function(){return this._micStatus===W}},{key:"query",get:function(){return this._query}},{key:"requestPending",get:function(){return this.requestStatus===Y}},{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!==b)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)),k(e,this.results.data,this.value,this.showDistinctSuggestions,this.enablePredictiveSuggestions).slice(0,this.size)}return[]}},{key:"componentQuery",get:function(){return i({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:w(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=i({},F);return this.mongodb&&(delete r.recordClick,delete r.recordConversions),Object.keys(F).forEach((function(r){t[F[r]]=e[r]})),t}}]),t}(N),te=function(e){function t(t){var r,s=t.index,o=t.url,u=t.credentials,c=t.mongodb,l=t.headers,d=t.appbaseConfig,h=t.transformRequest,f=t.transformResponse;return n(a(r=e.call(this,{index:s,url:o,credentials:u,mongodb:c,headers:l,appbaseConfig:d,transformRequest:h,transformResponse:f})||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 ee?n.id=e:n=new ee(i({},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 s(t,e),t}(N);e.SearchBase=te,e.SearchComponent=ee,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=searchbase.umd.min.js.map
{
"name": "@appbaseio/searchbase",
"version": "1.6.0-mongo-alpha",
"version": "1.6.1-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

Sorry, the diff of this file is not supported yet

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