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

@appbaseio/searchbase

Package Overview
Dependencies
Maintainers
1
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.0.0-alpha.3 to 1.0.0-alpha.4

6

dist/@appbaseio/searchbase.cjs.js

@@ -1039,8 +1039,6 @@ 'use strict';

// Set analytics headers
var analyticsHeaders = this.analyticsInstance.setSearchQuery(this.value).getAnalyticsHeaders();
var requestOptions = {
method: 'POST',
body: JSON.stringify(requestBody),
headers: _extends({}, this.headers, {}, analyticsHeaders)
headers: _extends({}, this.headers, {}, this.analytics ? this.analyticsInstance.setSearchQuery(this.value).getAnalyticsHeaders() : null)
};

@@ -1054,3 +1052,3 @@ return new Promise(function (resolve, reject) {

if (res.headers) {
if (res.headers && _this5.analytics) {
_this5.analyticsInstance.setSearchID(res.headers.get('X-Search-Id') || null);

@@ -1057,0 +1055,0 @@ }

@@ -1035,8 +1035,6 @@ import fetch from 'cross-fetch';

// Set analytics headers
var analyticsHeaders = this.analyticsInstance.setSearchQuery(this.value).getAnalyticsHeaders();
var requestOptions = {
method: 'POST',
body: JSON.stringify(requestBody),
headers: _extends({}, this.headers, {}, analyticsHeaders)
headers: _extends({}, this.headers, {}, this.analytics ? this.analyticsInstance.setSearchQuery(this.value).getAnalyticsHeaders() : null)
};

@@ -1050,3 +1048,3 @@ return new Promise(function (resolve, reject) {

if (res.headers) {
if (res.headers && _this5.analytics) {
_this5.analyticsInstance.setSearchID(res.headers.get('X-Search-Id') || null);

@@ -1053,0 +1051,0 @@ }

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Searchbase=e()}(this,function(){"use strict";function t(t,e){for(var s=0;s<e.length;s++){var r=e[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(e,s,r){return s&&t(e.prototype,s),r&&t(e,r),e}function s(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=function(t,e){return t(e={exports:{}},e.exports),e.exports}(function(t,e){var s=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:i);!function(t){!function(e){var s={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(s.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};function n(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return s.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function c(t){return new Promise(function(e,s){t.onload=function(){e(t.result)},t.onerror=function(){s(t.error)}})}function l(t){var e=new FileReader,s=c(e);return e.readAsArrayBuffer(t),s}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:s.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s.arrayBuffer&&s.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var t=h(this);if(t)return t;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?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,e,s,r=h(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,s=c(e),e.readAsText(t),s;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),s=new Array(e.length),r=0;r<e.length;r++)s[r]=String.fromCharCode(e[r]);return s.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(g)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=n(t),e=o(e);var s=this.map[t];this.map[t]=s?s+", "+e:e},u.prototype.delete=function(t){delete this.map[n(t)]},u.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},u.prototype.set=function(t,e){this.map[n(t)]=o(e)},u.prototype.forEach=function(t,e){for(var s in this.map)this.map.hasOwnProperty(s)&&t.call(e,this.map[s],s,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,s){t.push(s)}),a(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),a(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,s){t.push([s,e])}),a(t)},s.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var p=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var s,r,i=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=(s=e.method||this.method||"GET",r=s.toUpperCase(),p.indexOf(r)>-1?r:s),this.mode=e.mode||this.mode||null,this.signal=e.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 g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var s=t.split("="),r=s.shift().replace(/\+/g," "),i=s.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},f.call(y.prototype),f.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];v.redirect=function(t,e){if(-1===m.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var s=Error(t);this.stack=s.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,r){return new Promise(function(i,n){var o=new y(t,r);if(o.signal&&o.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var t,e,s={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var s=t.split(":"),r=s.shift().trim();if(r){var i=s.join(":").trim();e.append(r,i)}}),e)};s.url="responseURL"in a?a.responseURL:s.headers.get("X-Request-URL");var r="response"in a?a.response:a.responseText;i(new v(r,s))},a.onerror=function(){n(new TypeError("Network request failed"))},a.ontimeout=function(){n(new TypeError("Network request failed"))},a.onabort=function(){n(new e.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.blob&&(a.responseType="blob"),o.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),o.signal&&(o.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",h)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=u,t.Request=y,t.Response=v),e.Headers=u,e.Request=y,e.Response=v,e.fetch=b}({})}(s),delete s.fetch.polyfill,(e=s.fetch).default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e});n.fetch,n.Headers,n.Request,n.Response;function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}function a(t,e){if(null==t)return{};var s,r,i={},n=Object.keys(t);for(r=0;r<n.length;r++)s=n[r],e.indexOf(s)>=0||(i[s]=t[s]);return i}function u(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var r=s.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function h(t){var e="";return t&&Object.keys(t).forEach(function(s,r){e+=s+"="+t[s],r<Object.keys(t).length-1&&(e+=",")}),e}function c(t){return t&&""!==t.trim()?t:"https://scalr.api.appbase.io"}function l(t){void 0===t&&(t="");for(var e,s=t,r="",i=0,n=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.charAt(0|n)||(o="=",n%1);r+=o.charAt(63&i>>8-n%1*8)){if((e=s.charCodeAt(n+=.75))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|e}return r}function d(t){void 0===t&&(t={}),this.index=t.index,this.credentials=t.credentials,this.url=c(t.url),this.userID=t.userID,this.customEvents=t.customEvents,this.searchQuery=void 0,this.searchID=void 0,this.searchState=null,this.filters=null,this.emptyQuery=void 0===t.emptyQuery||t.emptyQuery,this.headers=null}var f=function(t){var e=[];return t&&(e=[].concat(t).map(function(t){var e={};t._updated?e._updated=t._updated:t._deleted&&(e._deleted=t._deleted);var s=function(t){var e=r({},t);return e.highlight&&Object.keys(e.highlight).forEach(function(t){var s,i=e.highlight[t][0];e._source=r({},e._source,((s={})[t]=i,s))}),e}(t);return Object.keys(s).filter(function(t){return"_source"!==t}).reduce(function(t,e){return t[e]=s[e],t},r({},s._source,{},e))})),e},p=function(t){return"object"==typeof t?Array.isArray(t)?function t(e){return e.reduce(function(e,s){return e.concat(Array.isArray(s)?t(s):s)},[])}(t):null:t},y=function(t,e,s){void 0===t&&(t=[]),void 0===s&&(s="");var i=[],n=[],o=function(t,e,r){if(s.trim().split(" ").some(function(e){return String(t).toLowerCase().includes(e)})&&!n.includes(t)){var o={label:t,value:t,source:r};n=[].concat(n,[t]),i=[].concat(i,[o])}};return e.forEach(function(e){var s=e._score,i=e._index,n=e._type,a=r({},e,{_id:e._id,_index:i,_score:s,_type:n});t.forEach(function(t){!function t(e,s,r){if(void 0===r&&(r=e),"object"==typeof e){var i=s.split("."),n=e[i[0]];if(n)if(i.length>1){var a=s.substring(i[0].length+1);Array.isArray(n)?n.forEach(function(e){t(e,a,r)}):t(n,a,r)}else{var u=p(n);u&&(Array.isArray(u)?u.forEach(function(t){return o(t,0,r)}):o(u,0,r))}}}(a,t)})}),i},g=function(){function t(t){var e=this;s(this,"data",void 0),s(this,"raw",void 0),s(this,"parseResults",void 0),s(this,"setRaw",function(t){e.raw=t,t.hits&&t.hits.hits&&e.setData(t.hits.hits)}),this.data=t||[]}return t.prototype.setData=function(t){var e=f(t);if(this.promotedData.length){var s=this.promotedData.map(function(t){return t._id}).filter(Boolean);s&&(e=e.filter(function(t){return!s.includes(t._id)})),e=[].concat(this.promotedData,e)}this.parseResults?this.data=this.parseResults(e):this.data=e},e(t,[{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:"promotedData",get:function(){return this.raw&&this.raw.promoted&&this.raw.promoted||[]}},{key:"rawData",get:function(){return this.raw&&this.raw.hits&&this.raw.hits&&this.raw.hits.hits||[]}}]),t}(),v=function(){function t(){s(this,"observers",void 0),this.observers=[]}var e=t.prototype;return e.subscribe=function(t,e){this.observers.push({callback:t,properties:e})},e.unsubscribe=function(t){this.observers=t?this.observers.filter(function(e){return e.callback!==t?e:null}):[]},e.next=function(t,e,s){var r=s||window;this.observers.forEach(function(s){void 0===s.properties?s.callback.call(r,t):s.properties instanceof Array&&s.properties.length&&s.properties.includes(e)?s.callback.call(r,t):"string"==typeof s.properties&&s.properties&&s.properties===e&&s.callback.call(r,t)})},t}(),m={inactive:"INACTIVE",active:"ACTIVE",denied:"DENIED"},b={inactive:"INACTIVE",pending:"PENDING",error:"ERROR"},_={triggerQuery:!0,triggerSuggestionsQuery:!1,stateChanges:!0},S={stateChanges:!0},w=function(){function t(t){var e=this,i=t.index,f=t.url,p=t.credentials,S=t.analytics,w=t.headers,E=t.value,F=t.suggestions,O=t.results,R=t.fuzziness,q=t.searchOperators,C=t.queryFormat,x=t.size,I=t.from,Q=t.dataField,A=t.includeFields,B=t.excludeFields,D=t.transformQuery,P=t.transformSuggestionsQuery,T=t.transformRequest,j=t.transformResponse,z=t.beforeValueChange,k=t.sortBy,U=t.nestedField,M=t.sortOptions,H=t.sortByField,N=t.highlight,V=t.highlightField;if(s(this,"index",void 0),s(this,"url",void 0),s(this,"credentials",void 0),s(this,"analytics",void 0),s(this,"value",void 0),s(this,"headers",void 0),s(this,"suggestions",void 0),s(this,"suggestionsError",void 0),s(this,"results",void 0),s(this,"error",void 0),s(this,"stateChanges",void 0),s(this,"requestStatus",void 0),s(this,"suggestionsRequestStatus",void 0),s(this,"nestedField",void 0),s(this,"queryFormat",void 0),s(this,"searchOperators",void 0),s(this,"size",void 0),s(this,"from",void 0),s(this,"fuzziness",void 0),s(this,"sortBy",void 0),s(this,"sortByField",void 0),s(this,"dataField",void 0),s(this,"includeFields",void 0),s(this,"excludeFields",void 0),s(this,"sortOptions",void 0),s(this,"highlight",void 0),s(this,"highlightField",void 0),s(this,"analyticsInstance",void 0),s(this,"onValueChange",void 0),s(this,"onResults",void 0),s(this,"onSuggestions",void 0),s(this,"onError",void 0),s(this,"onSuggestionsError",void 0),s(this,"onRequestStatusChange",void 0),s(this,"onSuggestionsRequestStatusChange",void 0),s(this,"onQueryChange",void 0),s(this,"onSuggestionsQueryChange",void 0),s(this,"onMicStatusChange",void 0),s(this,"transformQuery",void 0),s(this,"transformSuggestionsQuery",void 0),s(this,"transformRequest",void 0),s(this,"transformResponse",void 0),s(this,"beforeValueChange",void 0),s(this,"_query",void 0),s(this,"_suggestionsQuery",void 0),s(this,"_queryOptions",void 0),s(this,"_micStatus",void 0),s(this,"_micInstance",void 0),s(this,"onMicClick",function(t,s){void 0===t&&(t={}),void 0===s&&(s=_);var r=e._micStatus;if(window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition||null,window.SpeechRecognition&&r!==m.denied){r===m.active&&e._setMicStatus(m.inactive,s);var i=window.SpeechRecognition;if(e._micInstance)return void e._stopMic();e._micInstance=new i,e._micInstance.continuous=!0,e._micInstance.interimResults=!0,Object.assign(e._micInstance,t),e._micInstance.start(),e._micInstance.onstart=function(){e._setMicStatus(m.active,s)},e._micInstance.onresult=function(t){var r=t.results;r&&r[0]&&r[0].isFinal&&e._stopMic(),e._handleVoiceResults({results:r},s)},e._micInstance.onerror=function(t){"no-speech"===t.error||"audio-capture"===t.error?e._setMicStatus(m.inactive,s):"not-allowed"===t.error&&e._setMicStatus(m.denied,s),console.error(t)}}}),s(this,"_handleVoiceResults",function(t,s){var r=t.results;void 0===s&&(s=_),r&&r[0]&&r[0].isFinal&&r[0][0]&&r[0][0].transcript&&r[0][0].transcript.trim()&&e.setValue(r[0][0].transcript.trim(),s)}),s(this,"_stopMic",function(){e._micInstance&&(e._micInstance.stop(),e._micInstance=null,e._setMicStatus(m.inactive))}),s(this,"_setMicStatus",function(t,s){void 0===s&&(s=_);var r=e._micStatus;e._micStatus=t,e._applyOptions(s,"micStatus",r,e._micStatus)}),s(this,"_parseSuggestions",function(t){var s=[];return"string"===e.dataField?s=[e.dataField]:Array.isArray(e.dataField)&&e.dataField.forEach(function(t){"object"==typeof t?s.push(t.field):s.push(t)}),y(s,t,e.value).slice(0,e.size)}),!i)throw new Error("Please provide a valid index.");if(!f)throw new Error("Please provide a valid url.");if(!Q)throw new Error("Please provide a valid data field.");this.index=i,this.url=f,this.analytics=S||!1,this.analytics&&(this.analyticsInstance=function(t){void 0===t&&(t={});var e=new d(t);return d.prototype.setIndex=function(t){return this.index=t,this},d.prototype.setCredentials=function(t){return this.credentials=t,this},d.prototype.setURL=function(t){return this.url=c(t),this},d.prototype.setHeaders=function(t){return this.headers=t,this},d.prototype.setSearchQuery=function(t){return this.searchQuery=t,this},d.prototype.clearSearchQuery=function(){return this.searchQuery=void 0,this},d.prototype.setSearchID=function(t){return this.searchID=t,this},d.prototype.clearSearchID=function(){return this.searchID=void 0,this},d.prototype.setSearchState=function(t){return this.searchState=t,this},d.prototype.clearSearchState=function(){return this.searchState=null,this},d.prototype.setUserID=function(t){return this.userID=t,this},d.prototype.clearUserID=function(){return this.userID=null,this},d.prototype.setCustomEvents=function(t){return this.customEvents=t,this},d.prototype.clearCustomEvents=function(){return this.customEvents=null,this},d.prototype.addCustomEvent=function(t){return this.customEvents=o({},this.customEvents,{customEvent:t}),this},d.prototype.removeCustomEvent=function(t){var e=this.customEvents,s=(e[t],a(e,[t].map(u)));return this.customEvents=s,this},d.prototype.setFilters=function(t){return this.filters=t,this},d.prototype.clearFilters=function(){return this.filters=null,this},d.prototype.addFilter=function(t){return this.filters=o({},this.filters,{filter:t}),this},d.prototype.removeFilter=function(t){var e=this.filters,s=(e[t],a(e,[t].map(u)));return this.filters=s,this},d.prototype.enableEmptyQuery=function(){return this.emptyQuery=!0,this},d.prototype.disableEmptyQuery=function(){return this.emptyQuery=!1,this},d.prototype.registerClick=function(t,e){if(Number.isNaN(parseInt(t,10)))throw new Error("appbase-analytics: click position must be an integer.");var s=this._recordEventHeaders();return n(this.url+"/"+this.index+"/_analytics",{method:"POST",headers:o({},s,{},e?{"X-Search-Suggestions-Click":!0,"X-Search-Suggestions-ClickPosition":t}:{"X-Search-Click":!0,"X-Search-ClickPosition":t})})},d.prototype.registerConversion=function(){var t=this._recordEventHeaders();return n(this.url+"/"+this.index+"/_analytics",{method:"POST",headers:o({},t,{"X-Search-Conversion":!0})})},d.prototype.getAnalyticsHeaders=function(){return o({},this.searchQuery||this.emptyQuery?{"X-Search-Query":this.searchQuery||""}:null,{},this.searchID?{"X-Search-Id":this.searchID}:null,{},this.searchState?{"X-Search-State":JSON.stringify(this.searchState)}:null,{},this.userID?{"X-User-Id":this.userID}:null,{},this.customEvents?{"X-Search-CustomEvent":h(this.customEvents)}:null,{},this.filters?{"X-Search-Filters":h(this.filters)}:null)},d.prototype._recordEventHeaders=function(){if(!this.index)throw new Error("appbase-analytics: A valid index must be present to record an event.");if(!this.credentials)throw new Error("appbase-analytics: Auth credentials is missing.");if(!this.searchID)throw new Error("appbase-analytics: searchID must be present to record an event.");return o({},this.headers,{"Content-Type":"application/json",Authorization:"Basic "+l(this.credentials),"X-Search-Id":this.searchID},this.userID?{"X-User-Id":this.userID}:null,{},this.customEvents?{"X-Search-CustomEvent":h(this.customEvents)}:null)},e}({index:i,url:f,credentials:p})),this.dataField=Q,this.credentials=p||"",this.nestedField=U||"",this.queryFormat=C||"or",this.fuzziness=R||0,this.searchOperators=q||!1,this.size=Number(x)||10,this.from=Number(I)||0,this.sortBy=k||"",this.includeFields=A||["*"],this.excludeFields=B||[],this.sortOptions=M||null,this.sortByField=H||"",this.highlight=N,this.highlightField=V,this.requestStatus=b.inactive,this.suggestionsRequestStatus=b.inactive,this.transformRequest=T||null,this.transformResponse=j||null,this.transformQuery=D||null,this.transformSuggestionsQuery=P||null,this.beforeValueChange=z||null,this.stateChanges=new v,this.suggestions=new g(F),this.suggestions.parseResults=this._parseSuggestions,this.results=new g(O),this.headers={Accept:"application/json","Content-Type":"application/json"},this.credentials&&(this.headers=r({},this.headers,{Authorization:"Basic "+btoa(this.credentials)})),w&&this.setHeaders(w,{stateChanges:!1}),E?this.setValue(E,{stateChanges:!0}):this.value=""}var i=t.prototype;return i.subscribeToStateChanges=function(t,e){this.stateChanges.subscribe(t,e)},i.unsubscribeToStateChanges=function(t){this.stateChanges.unsubscribe(t)},i.setHeaders=function(t,e){void 0===e&&(e=_);var s=this.headers;this.headers=r({},this.headers,{},t),this._applyOptions(e,"headers",s,this.headers)},i.setSize=function(t,e){void 0===e&&(e=_);var s=this.size;this.size=t,this._applyOptions(e,"size",s,this.size)},i.setFrom=function(t,e){void 0===e&&(e=_);var s=this.from;this.from=t,this._applyOptions(e,"from",s,this.from)},i.setFuzziness=function(t,e){void 0===e&&(e=_);var s=this.fuzziness;this.fuzziness=t,this._applyOptions(e,"fuzziness",s,this.fuzziness)},i.setIncludeFields=function(t,e){void 0===e&&(e=_);var s=this.includeFields;this.includeFields=t,this._applyOptions(e,"includeFields",s,t)},i.setExcludeFields=function(t,e){void 0===e&&(e=_);var s=this.excludeFields;this.excludeFields=t,this._applyOptions(e,"excludeFields",s,t)},i.setSortBy=function(t,e){void 0===e&&(e=_);var s=this.sortBy;this.sortBy=t,this._applyOptions(e,"sortBy",s,t)},i.setSortByField=function(t,e){void 0===e&&(e=_);var s=this.sortByField;this.sortByField=t,this._applyOptions(e,"sortByField",s,t)},i.setNestedField=function(t,e){void 0===e&&(e=_);var s=this.nestedField;this.nestedField=t,this._applyOptions(e,"nestedField",s,t)},i.setDataField=function(t,e){void 0===e&&(e=_);var s=this.dataField;this.dataField=t,this._applyOptions(e,"dataField",s,t)},i.setResults=function(t,e){if(void 0===e&&(e=S),t){var s=this.results;this.results=new g(t),this._applyOptions({stateChanges:e.stateChanges},"results",s,this.results)}},i.setSuggestions=function(t,e){if(void 0===e&&(e=S),t){var s=this.suggestions;this.suggestions=new g(t),this.suggestions.parseResults=this._parseSuggestions,this._applyOptions({stateChanges:e.stateChanges},"suggestions",s,this.suggestions)}},i.setValue=function(t,e){var s=this;void 0===e&&(e=_);var r=function(){var r=s.value;s.value=t,s._applyOptions(e,"value",r,s.value)};this.beforeValueChange?this.beforeValueChange(t).then(r).catch(function(t){console.warn("beforeValueChange rejected the promise with ",t)}):r()},i.triggerQuery=function(t){var e=this;void 0===t&&(t=S);var s=function(s){return e._setError(s,{stateChanges:t.stateChanges}),console.error(s),Promise.reject(s)};try{return this._updateQuery(),this._setRequestStatus(b.pending),(this.transformQuery?this.transformQuery(this.query):new Promise(function(t){return t(e.query)})).then(function(r){e._fetchRequest(r).then(function(s){e._setRequestStatus(b.inactive);var r=e.results;return e.results.setRaw(s),e._applyOptions({stateChanges:t.stateChanges},"results",r,e.results),Promise.resolve(s)}).catch(s)}).catch(s)}catch(t){return s(t)}},i.triggerSuggestionsQuery=function(t){var e=this;void 0===t&&(t=S);var s=function(s){return e._setSuggestionsError(s,{stateChanges:t.stateChanges}),console.error(s),Promise.reject(s)};try{return this._updateSuggestionsQuery(),this._setSuggestionsRequestStatus(b.pending),(this.transformSuggestionsQuery?this.transformSuggestionsQuery(this.suggestionsQuery):new Promise(function(t){return t(e.suggestionsQuery)})).then(function(r){e._fetchRequest(r).then(function(s){e._setSuggestionsRequestStatus(b.inactive);var r=e.suggestions;return e.suggestions.setRaw(s),e._applyOptions({stateChanges:t.stateChanges},"suggestions",r,e.suggestions),Promise.resolve(s)}).catch(s)}).catch(s)}catch(t){return s(t)}},i._handleTransformResponse=function(t){return this.transformResponse&&"function"==typeof this.transformResponse?this.transformResponse(t):new Promise(function(e){return e(t)})},i._handleTransformRequest=function(t){return this.transformRequest&&"function"==typeof this.transformRequest?this.transformRequest(t):new Promise(function(e){return e(t)})},i._fetchRequest=function(t){var e=this,s=this.analyticsInstance.setSearchQuery(this.value).getAnalyticsHeaders(),i={method:"POST",body:JSON.stringify(t),headers:r({},this.headers,{},s)};return new Promise(function(t,s){e._handleTransformRequest(i).then(function(i){var o=Date.now();return n(e.url+"/"+e.index+"/_search",i).then(function(i){var n=i.headers;return i.headers&&e.analyticsInstance.setSearchID(i.headers.get("X-Search-Id")||null),i.status>=500?s(i):i.status>=400?s(i):i.json().then(function(i){e._handleTransformResponse(i).then(function(e){e&&Object.prototype.hasOwnProperty.call(e,"error")&&s(e);var i=r({},e,{_timestamp:o,_headers:n});return t(i)}).catch(function(t){return console.warn("transformResponse rejected the promise with ",t),s(t)})})}).catch(function(t){return s(t)})}).catch(function(t){return console.warn("transformRequest rejected the promise with ",t),s(t)})})},i._setSuggestionsError=function(t,e){void 0===e&&(e=_),this._setSuggestionsRequestStatus(b.error);var s=this.suggestionsError;this.suggestionsError=t,this._applyOptions(e,"suggestionsError",s,this.suggestionsError)},i._setError=function(t,e){void 0===e&&(e=_),this._setRequestStatus(b.error);var s=this.error;this.error=t,this._applyOptions(e,"error",s,this.error)},i._setRequestStatus=function(t){var e=this.requestStatus;this.requestStatus=t,this._applyOptions({stateChanges:!0},"requestStatus",e,this.requestStatus)},i._setSuggestionsRequestStatus=function(t){var e=this.suggestionsRequestStatus;this.suggestionsRequestStatus=t,this._applyOptions({stateChanges:!0},"suggestionsRequestStatus",e,this.suggestionsRequestStatus)},i._updateQuery=function(e,s){var i=t.generateQueryOptions({excludeFields:this.excludeFields,includeFields:this.includeFields,size:this.size,from:this.from,sortBy:this.sortBy,sortByField:this.sortByField,sortOptions:this.sortOptions}),n=e||t.defaultQuery(this.value,{dataField:this.dataField,searchOperators:this.searchOperators,queryFormat:this.queryFormat,fuzziness:this.fuzziness,nestedField:this.nestedField})||{match_all:{}},o=this._query;this._query=r({query:n},t.highlightQuery(this.highlight,this.highlightField,this.dataField),{},i,{},s),this._applyOptions({stateChanges:!1},"query",o,this._query)},i._updateSuggestionsQuery=function(e,s){var i=t.generateQueryOptions({size:10}),n=e||t.defaultQuery(this.value,{dataField:this.dataField,searchOperators:this.searchOperators,queryFormat:this.queryFormat,fuzziness:this.fuzziness,nestedField:this.nestedField})||{match_all:{}},o=this._suggestionsQuery;this._suggestionsQuery=r({query:n},t.highlightQuery(this.highlight,this.highlightField,this.dataField),{},i,{},s),this._applyOptions({stateChanges:!1},"suggestionsQuery",o,this._suggestionsQuery)},i._applyOptions=function(t,e,s,r){var i;("micStatus"===e&&this.onMicStatusChange&&this.onMicStatusChange(r,s),"query"===e&&this.onQueryChange&&this.onQueryChange(r,s),"suggestionsQuery"===e&&this.onSuggestionsQueryChange&&this.onSuggestionsQueryChange(r,s),"value"===e&&this.onValueChange&&this.onValueChange(r,s),"error"===e&&this.onError&&this.onError(r),"suggestionsError"===e&&this.onSuggestionsError&&this.onSuggestionsError(r),"results"===e&&this.onResults&&this.onResults(r,s),"suggestions"===e&&this.onSuggestions&&this.onSuggestions(r,s),"requestStatus"===e&&this.onRequestStatusChange&&this.onRequestStatusChange(r,s),"suggestionsRequestStatus"===e&&this.onSuggestionsRequestStatusChange&&this.onSuggestionsRequestStatusChange(r,s),t.triggerQuery&&this.triggerQuery(),t.triggerSuggestionsQuery&&this.triggerSuggestionsQuery(),!1!==t.stateChanges)&&this.stateChanges.next(((i={})[e]={prev:s,next:r},i),e)},e(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===m.active}},{key:"micInactive",get:function(){return this._micStatus===m.inactive}},{key:"micDenied",get:function(){return this._micStatus===m.denied}},{key:"query",get:function(){return this._query}},{key:"suggestionsQuery",get:function(){return this._suggestionsQuery}},{key:"requestPending",get:function(){return this.requestStatus===b.pending}},{key:"suggestionsRequestPending",get:function(){return this.suggestionsRequestStatus===b.pending}}]),t}();return s(w,"defaultQuery",void 0),s(w,"shouldQuery",void 0),s(w,"highlightQuery",void 0),s(w,"generateQueryOptions",void 0),w.defaultQuery=function(t,e){var s,r=null;return t&&(s=Array.isArray(e.dataField)?e.dataField:[e.dataField],r=e.searchOperators?{simple_query_string:w.shouldQuery(t,s,e)}:{bool:{should:w.shouldQuery(t,s,e),minimum_should_match:"1"}}),""===t&&(r=null),r&&e.nestedField&&(r={nested:{path:e.nestedField,query:r}}),r},w.shouldQuery=function(t,e,s){void 0===s&&(s={searchOperators:!1,queryFormat:"or",fuzziness:0});var r=e.map(function(t){return"object"==typeof t?t.field+(t.weight?"^"+t.weight:""):t});return s.searchOperators?{query:t,fields:r,default_operator:s.queryFormat}:"and"===s.queryFormat?[{multi_match:{query:t,fields:r,type:"cross_fields",operator:"and"}},{multi_match:{query:t,fields:r,type:"phrase_prefix",operator:"and"}}]:[{multi_match:{query:t,fields:r,type:"best_fields",operator:"or",fuzziness:s.fuzziness}},{multi_match:{query:t,fields:r,type:"phrase_prefix",operator:"or"}}]},w.highlightQuery=function(t,e,s){if(!t)return null;var i={},n=e||s,o="string"==typeof e?[e]:e;return"string"==typeof n?i[n]={}:Array.isArray(n)&&n.forEach(function(t){"object"==typeof t?i[t.field]={}:i[t]={}}),{highlight:r({pre_tags:["<mark>"],post_tags:["</mark>"],fields:i},o&&{require_field_match:!1})}},w.generateQueryOptions=function(t){var e,s={};if(void 0!==t.size&&(s.size=t.size),void 0!==t.from&&(s.from=t.from),t.includeFields||t.excludeFields){var r={};t.includeFields&&(r.includes=t.includeFields),t.excludeFields&&(r.excludes=t.excludeFields),s._source=r}if(t.sortOptions)s.sort=[(e={},e[t.sortOptions[0].dataField]={order:t.sortOptions[0].sortBy},e)];else if(t.sortBy&&t.sortByField){var i;s.sort=[(i={},i[t.sortByField]={order:t.sortBy},i)]}return s},w});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Searchbase=e()}(this,function(){"use strict";function t(t,e){for(var s=0;s<e.length;s++){var r=e[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(e,s,r){return s&&t(e.prototype,s),r&&t(e,r),e}function s(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=function(t,e){return t(e={exports:{}},e.exports),e.exports}(function(t,e){var s=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:i);!function(t){!function(e){var s={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(s.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};function n(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return s.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function c(t){return new Promise(function(e,s){t.onload=function(){e(t.result)},t.onerror=function(){s(t.error)}})}function l(t){var e=new FileReader,s=c(e);return e.readAsArrayBuffer(t),s}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:s.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s.arrayBuffer&&s.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):s.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s.blob&&(this.blob=function(){var t=h(this);if(t)return t;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?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,e,s,r=h(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,s=c(e),e.readAsText(t),s;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),s=new Array(e.length),r=0;r<e.length;r++)s[r]=String.fromCharCode(e[r]);return s.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s.formData&&(this.formData=function(){return this.text().then(g)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=n(t),e=o(e);var s=this.map[t];this.map[t]=s?s+", "+e:e},u.prototype.delete=function(t){delete this.map[n(t)]},u.prototype.get=function(t){return t=n(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},u.prototype.set=function(t,e){this.map[n(t)]=o(e)},u.prototype.forEach=function(t,e){for(var s in this.map)this.map.hasOwnProperty(s)&&t.call(e,this.map[s],s,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,s){t.push(s)}),a(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),a(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,s){t.push([s,e])}),a(t)},s.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var p=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var s,r,i=(e=e||{}).body;if(t instanceof y){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=(s=e.method||this.method||"GET",r=s.toUpperCase(),p.indexOf(r)>-1?r:s),this.mode=e.mode||this.mode||null,this.signal=e.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 g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var s=t.split("="),r=s.shift().replace(/\+/g," "),i=s.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},f.call(y.prototype),f.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];v.redirect=function(t,e){if(-1===m.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var s=Error(t);this.stack=s.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,r){return new Promise(function(i,n){var o=new y(t,r);if(o.signal&&o.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var t,e,s={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var s=t.split(":"),r=s.shift().trim();if(r){var i=s.join(":").trim();e.append(r,i)}}),e)};s.url="responseURL"in a?a.responseURL:s.headers.get("X-Request-URL");var r="response"in a?a.response:a.responseText;i(new v(r,s))},a.onerror=function(){n(new TypeError("Network request failed"))},a.ontimeout=function(){n(new TypeError("Network request failed"))},a.onabort=function(){n(new e.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.blob&&(a.responseType="blob"),o.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),o.signal&&(o.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",h)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=u,t.Request=y,t.Response=v),e.Headers=u,e.Request=y,e.Response=v,e.fetch=b}({})}(s),delete s.fetch.polyfill,(e=s.fetch).default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e});n.fetch,n.Headers,n.Request,n.Response;function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t}).apply(this,arguments)}function a(t,e){if(null==t)return{};var s,r,i={},n=Object.keys(t);for(r=0;r<n.length;r++)s=n[r],e.indexOf(s)>=0||(i[s]=t[s]);return i}function u(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var r=s.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function h(t){var e="";return t&&Object.keys(t).forEach(function(s,r){e+=s+"="+t[s],r<Object.keys(t).length-1&&(e+=",")}),e}function c(t){return t&&""!==t.trim()?t:"https://scalr.api.appbase.io"}function l(t){void 0===t&&(t="");for(var e,s=t,r="",i=0,n=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.charAt(0|n)||(o="=",n%1);r+=o.charAt(63&i>>8-n%1*8)){if((e=s.charCodeAt(n+=.75))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|e}return r}function d(t){void 0===t&&(t={}),this.index=t.index,this.credentials=t.credentials,this.url=c(t.url),this.userID=t.userID,this.customEvents=t.customEvents,this.searchQuery=void 0,this.searchID=void 0,this.searchState=null,this.filters=null,this.emptyQuery=void 0===t.emptyQuery||t.emptyQuery,this.headers=null}var f=function(t){var e=[];return t&&(e=[].concat(t).map(function(t){var e={};t._updated?e._updated=t._updated:t._deleted&&(e._deleted=t._deleted);var s=function(t){var e=r({},t);return e.highlight&&Object.keys(e.highlight).forEach(function(t){var s,i=e.highlight[t][0];e._source=r({},e._source,((s={})[t]=i,s))}),e}(t);return Object.keys(s).filter(function(t){return"_source"!==t}).reduce(function(t,e){return t[e]=s[e],t},r({},s._source,{},e))})),e},p=function(t){return"object"==typeof t?Array.isArray(t)?function t(e){return e.reduce(function(e,s){return e.concat(Array.isArray(s)?t(s):s)},[])}(t):null:t},y=function(t,e,s){void 0===t&&(t=[]),void 0===s&&(s="");var i=[],n=[],o=function(t,e,r){if(s.trim().split(" ").some(function(e){return String(t).toLowerCase().includes(e)})&&!n.includes(t)){var o={label:t,value:t,source:r};n=[].concat(n,[t]),i=[].concat(i,[o])}};return e.forEach(function(e){var s=e._score,i=e._index,n=e._type,a=r({},e,{_id:e._id,_index:i,_score:s,_type:n});t.forEach(function(t){!function t(e,s,r){if(void 0===r&&(r=e),"object"==typeof e){var i=s.split("."),n=e[i[0]];if(n)if(i.length>1){var a=s.substring(i[0].length+1);Array.isArray(n)?n.forEach(function(e){t(e,a,r)}):t(n,a,r)}else{var u=p(n);u&&(Array.isArray(u)?u.forEach(function(t){return o(t,0,r)}):o(u,0,r))}}}(a,t)})}),i},g=function(){function t(t){var e=this;s(this,"data",void 0),s(this,"raw",void 0),s(this,"parseResults",void 0),s(this,"setRaw",function(t){e.raw=t,t.hits&&t.hits.hits&&e.setData(t.hits.hits)}),this.data=t||[]}return t.prototype.setData=function(t){var e=f(t);if(this.promotedData.length){var s=this.promotedData.map(function(t){return t._id}).filter(Boolean);s&&(e=e.filter(function(t){return!s.includes(t._id)})),e=[].concat(this.promotedData,e)}this.parseResults?this.data=this.parseResults(e):this.data=e},e(t,[{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:"promotedData",get:function(){return this.raw&&this.raw.promoted&&this.raw.promoted||[]}},{key:"rawData",get:function(){return this.raw&&this.raw.hits&&this.raw.hits&&this.raw.hits.hits||[]}}]),t}(),v=function(){function t(){s(this,"observers",void 0),this.observers=[]}var e=t.prototype;return e.subscribe=function(t,e){this.observers.push({callback:t,properties:e})},e.unsubscribe=function(t){this.observers=t?this.observers.filter(function(e){return e.callback!==t?e:null}):[]},e.next=function(t,e,s){var r=s||window;this.observers.forEach(function(s){void 0===s.properties?s.callback.call(r,t):s.properties instanceof Array&&s.properties.length&&s.properties.includes(e)?s.callback.call(r,t):"string"==typeof s.properties&&s.properties&&s.properties===e&&s.callback.call(r,t)})},t}(),m={inactive:"INACTIVE",active:"ACTIVE",denied:"DENIED"},b={inactive:"INACTIVE",pending:"PENDING",error:"ERROR"},_={triggerQuery:!0,triggerSuggestionsQuery:!1,stateChanges:!0},S={stateChanges:!0},w=function(){function t(t){var e=this,i=t.index,f=t.url,p=t.credentials,S=t.analytics,w=t.headers,E=t.value,F=t.suggestions,O=t.results,R=t.fuzziness,q=t.searchOperators,C=t.queryFormat,x=t.size,I=t.from,Q=t.dataField,A=t.includeFields,B=t.excludeFields,D=t.transformQuery,P=t.transformSuggestionsQuery,T=t.transformRequest,j=t.transformResponse,z=t.beforeValueChange,k=t.sortBy,U=t.nestedField,M=t.sortOptions,H=t.sortByField,N=t.highlight,V=t.highlightField;if(s(this,"index",void 0),s(this,"url",void 0),s(this,"credentials",void 0),s(this,"analytics",void 0),s(this,"value",void 0),s(this,"headers",void 0),s(this,"suggestions",void 0),s(this,"suggestionsError",void 0),s(this,"results",void 0),s(this,"error",void 0),s(this,"stateChanges",void 0),s(this,"requestStatus",void 0),s(this,"suggestionsRequestStatus",void 0),s(this,"nestedField",void 0),s(this,"queryFormat",void 0),s(this,"searchOperators",void 0),s(this,"size",void 0),s(this,"from",void 0),s(this,"fuzziness",void 0),s(this,"sortBy",void 0),s(this,"sortByField",void 0),s(this,"dataField",void 0),s(this,"includeFields",void 0),s(this,"excludeFields",void 0),s(this,"sortOptions",void 0),s(this,"highlight",void 0),s(this,"highlightField",void 0),s(this,"analyticsInstance",void 0),s(this,"onValueChange",void 0),s(this,"onResults",void 0),s(this,"onSuggestions",void 0),s(this,"onError",void 0),s(this,"onSuggestionsError",void 0),s(this,"onRequestStatusChange",void 0),s(this,"onSuggestionsRequestStatusChange",void 0),s(this,"onQueryChange",void 0),s(this,"onSuggestionsQueryChange",void 0),s(this,"onMicStatusChange",void 0),s(this,"transformQuery",void 0),s(this,"transformSuggestionsQuery",void 0),s(this,"transformRequest",void 0),s(this,"transformResponse",void 0),s(this,"beforeValueChange",void 0),s(this,"_query",void 0),s(this,"_suggestionsQuery",void 0),s(this,"_queryOptions",void 0),s(this,"_micStatus",void 0),s(this,"_micInstance",void 0),s(this,"onMicClick",function(t,s){void 0===t&&(t={}),void 0===s&&(s=_);var r=e._micStatus;if(window.SpeechRecognition=window.webkitSpeechRecognition||window.SpeechRecognition||null,window.SpeechRecognition&&r!==m.denied){r===m.active&&e._setMicStatus(m.inactive,s);var i=window.SpeechRecognition;if(e._micInstance)return void e._stopMic();e._micInstance=new i,e._micInstance.continuous=!0,e._micInstance.interimResults=!0,Object.assign(e._micInstance,t),e._micInstance.start(),e._micInstance.onstart=function(){e._setMicStatus(m.active,s)},e._micInstance.onresult=function(t){var r=t.results;r&&r[0]&&r[0].isFinal&&e._stopMic(),e._handleVoiceResults({results:r},s)},e._micInstance.onerror=function(t){"no-speech"===t.error||"audio-capture"===t.error?e._setMicStatus(m.inactive,s):"not-allowed"===t.error&&e._setMicStatus(m.denied,s),console.error(t)}}}),s(this,"_handleVoiceResults",function(t,s){var r=t.results;void 0===s&&(s=_),r&&r[0]&&r[0].isFinal&&r[0][0]&&r[0][0].transcript&&r[0][0].transcript.trim()&&e.setValue(r[0][0].transcript.trim(),s)}),s(this,"_stopMic",function(){e._micInstance&&(e._micInstance.stop(),e._micInstance=null,e._setMicStatus(m.inactive))}),s(this,"_setMicStatus",function(t,s){void 0===s&&(s=_);var r=e._micStatus;e._micStatus=t,e._applyOptions(s,"micStatus",r,e._micStatus)}),s(this,"_parseSuggestions",function(t){var s=[];return"string"===e.dataField?s=[e.dataField]:Array.isArray(e.dataField)&&e.dataField.forEach(function(t){"object"==typeof t?s.push(t.field):s.push(t)}),y(s,t,e.value).slice(0,e.size)}),!i)throw new Error("Please provide a valid index.");if(!f)throw new Error("Please provide a valid url.");if(!Q)throw new Error("Please provide a valid data field.");this.index=i,this.url=f,this.analytics=S||!1,this.analytics&&(this.analyticsInstance=function(t){void 0===t&&(t={});var e=new d(t);return d.prototype.setIndex=function(t){return this.index=t,this},d.prototype.setCredentials=function(t){return this.credentials=t,this},d.prototype.setURL=function(t){return this.url=c(t),this},d.prototype.setHeaders=function(t){return this.headers=t,this},d.prototype.setSearchQuery=function(t){return this.searchQuery=t,this},d.prototype.clearSearchQuery=function(){return this.searchQuery=void 0,this},d.prototype.setSearchID=function(t){return this.searchID=t,this},d.prototype.clearSearchID=function(){return this.searchID=void 0,this},d.prototype.setSearchState=function(t){return this.searchState=t,this},d.prototype.clearSearchState=function(){return this.searchState=null,this},d.prototype.setUserID=function(t){return this.userID=t,this},d.prototype.clearUserID=function(){return this.userID=null,this},d.prototype.setCustomEvents=function(t){return this.customEvents=t,this},d.prototype.clearCustomEvents=function(){return this.customEvents=null,this},d.prototype.addCustomEvent=function(t){return this.customEvents=o({},this.customEvents,{customEvent:t}),this},d.prototype.removeCustomEvent=function(t){var e=this.customEvents,s=(e[t],a(e,[t].map(u)));return this.customEvents=s,this},d.prototype.setFilters=function(t){return this.filters=t,this},d.prototype.clearFilters=function(){return this.filters=null,this},d.prototype.addFilter=function(t){return this.filters=o({},this.filters,{filter:t}),this},d.prototype.removeFilter=function(t){var e=this.filters,s=(e[t],a(e,[t].map(u)));return this.filters=s,this},d.prototype.enableEmptyQuery=function(){return this.emptyQuery=!0,this},d.prototype.disableEmptyQuery=function(){return this.emptyQuery=!1,this},d.prototype.registerClick=function(t,e){if(Number.isNaN(parseInt(t,10)))throw new Error("appbase-analytics: click position must be an integer.");var s=this._recordEventHeaders();return n(this.url+"/"+this.index+"/_analytics",{method:"POST",headers:o({},s,{},e?{"X-Search-Suggestions-Click":!0,"X-Search-Suggestions-ClickPosition":t}:{"X-Search-Click":!0,"X-Search-ClickPosition":t})})},d.prototype.registerConversion=function(){var t=this._recordEventHeaders();return n(this.url+"/"+this.index+"/_analytics",{method:"POST",headers:o({},t,{"X-Search-Conversion":!0})})},d.prototype.getAnalyticsHeaders=function(){return o({},this.searchQuery||this.emptyQuery?{"X-Search-Query":this.searchQuery||""}:null,{},this.searchID?{"X-Search-Id":this.searchID}:null,{},this.searchState?{"X-Search-State":JSON.stringify(this.searchState)}:null,{},this.userID?{"X-User-Id":this.userID}:null,{},this.customEvents?{"X-Search-CustomEvent":h(this.customEvents)}:null,{},this.filters?{"X-Search-Filters":h(this.filters)}:null)},d.prototype._recordEventHeaders=function(){if(!this.index)throw new Error("appbase-analytics: A valid index must be present to record an event.");if(!this.credentials)throw new Error("appbase-analytics: Auth credentials is missing.");if(!this.searchID)throw new Error("appbase-analytics: searchID must be present to record an event.");return o({},this.headers,{"Content-Type":"application/json",Authorization:"Basic "+l(this.credentials),"X-Search-Id":this.searchID},this.userID?{"X-User-Id":this.userID}:null,{},this.customEvents?{"X-Search-CustomEvent":h(this.customEvents)}:null)},e}({index:i,url:f,credentials:p})),this.dataField=Q,this.credentials=p||"",this.nestedField=U||"",this.queryFormat=C||"or",this.fuzziness=R||0,this.searchOperators=q||!1,this.size=Number(x)||10,this.from=Number(I)||0,this.sortBy=k||"",this.includeFields=A||["*"],this.excludeFields=B||[],this.sortOptions=M||null,this.sortByField=H||"",this.highlight=N,this.highlightField=V,this.requestStatus=b.inactive,this.suggestionsRequestStatus=b.inactive,this.transformRequest=T||null,this.transformResponse=j||null,this.transformQuery=D||null,this.transformSuggestionsQuery=P||null,this.beforeValueChange=z||null,this.stateChanges=new v,this.suggestions=new g(F),this.suggestions.parseResults=this._parseSuggestions,this.results=new g(O),this.headers={Accept:"application/json","Content-Type":"application/json"},this.credentials&&(this.headers=r({},this.headers,{Authorization:"Basic "+btoa(this.credentials)})),w&&this.setHeaders(w,{stateChanges:!1}),E?this.setValue(E,{stateChanges:!0}):this.value=""}var i=t.prototype;return i.subscribeToStateChanges=function(t,e){this.stateChanges.subscribe(t,e)},i.unsubscribeToStateChanges=function(t){this.stateChanges.unsubscribe(t)},i.setHeaders=function(t,e){void 0===e&&(e=_);var s=this.headers;this.headers=r({},this.headers,{},t),this._applyOptions(e,"headers",s,this.headers)},i.setSize=function(t,e){void 0===e&&(e=_);var s=this.size;this.size=t,this._applyOptions(e,"size",s,this.size)},i.setFrom=function(t,e){void 0===e&&(e=_);var s=this.from;this.from=t,this._applyOptions(e,"from",s,this.from)},i.setFuzziness=function(t,e){void 0===e&&(e=_);var s=this.fuzziness;this.fuzziness=t,this._applyOptions(e,"fuzziness",s,this.fuzziness)},i.setIncludeFields=function(t,e){void 0===e&&(e=_);var s=this.includeFields;this.includeFields=t,this._applyOptions(e,"includeFields",s,t)},i.setExcludeFields=function(t,e){void 0===e&&(e=_);var s=this.excludeFields;this.excludeFields=t,this._applyOptions(e,"excludeFields",s,t)},i.setSortBy=function(t,e){void 0===e&&(e=_);var s=this.sortBy;this.sortBy=t,this._applyOptions(e,"sortBy",s,t)},i.setSortByField=function(t,e){void 0===e&&(e=_);var s=this.sortByField;this.sortByField=t,this._applyOptions(e,"sortByField",s,t)},i.setNestedField=function(t,e){void 0===e&&(e=_);var s=this.nestedField;this.nestedField=t,this._applyOptions(e,"nestedField",s,t)},i.setDataField=function(t,e){void 0===e&&(e=_);var s=this.dataField;this.dataField=t,this._applyOptions(e,"dataField",s,t)},i.setResults=function(t,e){if(void 0===e&&(e=S),t){var s=this.results;this.results=new g(t),this._applyOptions({stateChanges:e.stateChanges},"results",s,this.results)}},i.setSuggestions=function(t,e){if(void 0===e&&(e=S),t){var s=this.suggestions;this.suggestions=new g(t),this.suggestions.parseResults=this._parseSuggestions,this._applyOptions({stateChanges:e.stateChanges},"suggestions",s,this.suggestions)}},i.setValue=function(t,e){var s=this;void 0===e&&(e=_);var r=function(){var r=s.value;s.value=t,s._applyOptions(e,"value",r,s.value)};this.beforeValueChange?this.beforeValueChange(t).then(r).catch(function(t){console.warn("beforeValueChange rejected the promise with ",t)}):r()},i.triggerQuery=function(t){var e=this;void 0===t&&(t=S);var s=function(s){return e._setError(s,{stateChanges:t.stateChanges}),console.error(s),Promise.reject(s)};try{return this._updateQuery(),this._setRequestStatus(b.pending),(this.transformQuery?this.transformQuery(this.query):new Promise(function(t){return t(e.query)})).then(function(r){e._fetchRequest(r).then(function(s){e._setRequestStatus(b.inactive);var r=e.results;return e.results.setRaw(s),e._applyOptions({stateChanges:t.stateChanges},"results",r,e.results),Promise.resolve(s)}).catch(s)}).catch(s)}catch(t){return s(t)}},i.triggerSuggestionsQuery=function(t){var e=this;void 0===t&&(t=S);var s=function(s){return e._setSuggestionsError(s,{stateChanges:t.stateChanges}),console.error(s),Promise.reject(s)};try{return this._updateSuggestionsQuery(),this._setSuggestionsRequestStatus(b.pending),(this.transformSuggestionsQuery?this.transformSuggestionsQuery(this.suggestionsQuery):new Promise(function(t){return t(e.suggestionsQuery)})).then(function(r){e._fetchRequest(r).then(function(s){e._setSuggestionsRequestStatus(b.inactive);var r=e.suggestions;return e.suggestions.setRaw(s),e._applyOptions({stateChanges:t.stateChanges},"suggestions",r,e.suggestions),Promise.resolve(s)}).catch(s)}).catch(s)}catch(t){return s(t)}},i._handleTransformResponse=function(t){return this.transformResponse&&"function"==typeof this.transformResponse?this.transformResponse(t):new Promise(function(e){return e(t)})},i._handleTransformRequest=function(t){return this.transformRequest&&"function"==typeof this.transformRequest?this.transformRequest(t):new Promise(function(e){return e(t)})},i._fetchRequest=function(t){var e=this,s={method:"POST",body:JSON.stringify(t),headers:r({},this.headers,{},this.analytics?this.analyticsInstance.setSearchQuery(this.value).getAnalyticsHeaders():null)};return new Promise(function(t,i){e._handleTransformRequest(s).then(function(s){var o=Date.now();return n(e.url+"/"+e.index+"/_search",s).then(function(s){var n=s.headers;return s.headers&&e.analytics&&e.analyticsInstance.setSearchID(s.headers.get("X-Search-Id")||null),s.status>=500?i(s):s.status>=400?i(s):s.json().then(function(s){e._handleTransformResponse(s).then(function(e){e&&Object.prototype.hasOwnProperty.call(e,"error")&&i(e);var s=r({},e,{_timestamp:o,_headers:n});return t(s)}).catch(function(t){return console.warn("transformResponse rejected the promise with ",t),i(t)})})}).catch(function(t){return i(t)})}).catch(function(t){return console.warn("transformRequest rejected the promise with ",t),i(t)})})},i._setSuggestionsError=function(t,e){void 0===e&&(e=_),this._setSuggestionsRequestStatus(b.error);var s=this.suggestionsError;this.suggestionsError=t,this._applyOptions(e,"suggestionsError",s,this.suggestionsError)},i._setError=function(t,e){void 0===e&&(e=_),this._setRequestStatus(b.error);var s=this.error;this.error=t,this._applyOptions(e,"error",s,this.error)},i._setRequestStatus=function(t){var e=this.requestStatus;this.requestStatus=t,this._applyOptions({stateChanges:!0},"requestStatus",e,this.requestStatus)},i._setSuggestionsRequestStatus=function(t){var e=this.suggestionsRequestStatus;this.suggestionsRequestStatus=t,this._applyOptions({stateChanges:!0},"suggestionsRequestStatus",e,this.suggestionsRequestStatus)},i._updateQuery=function(e,s){var i=t.generateQueryOptions({excludeFields:this.excludeFields,includeFields:this.includeFields,size:this.size,from:this.from,sortBy:this.sortBy,sortByField:this.sortByField,sortOptions:this.sortOptions}),n=e||t.defaultQuery(this.value,{dataField:this.dataField,searchOperators:this.searchOperators,queryFormat:this.queryFormat,fuzziness:this.fuzziness,nestedField:this.nestedField})||{match_all:{}},o=this._query;this._query=r({query:n},t.highlightQuery(this.highlight,this.highlightField,this.dataField),{},i,{},s),this._applyOptions({stateChanges:!1},"query",o,this._query)},i._updateSuggestionsQuery=function(e,s){var i=t.generateQueryOptions({size:10}),n=e||t.defaultQuery(this.value,{dataField:this.dataField,searchOperators:this.searchOperators,queryFormat:this.queryFormat,fuzziness:this.fuzziness,nestedField:this.nestedField})||{match_all:{}},o=this._suggestionsQuery;this._suggestionsQuery=r({query:n},t.highlightQuery(this.highlight,this.highlightField,this.dataField),{},i,{},s),this._applyOptions({stateChanges:!1},"suggestionsQuery",o,this._suggestionsQuery)},i._applyOptions=function(t,e,s,r){var i;("micStatus"===e&&this.onMicStatusChange&&this.onMicStatusChange(r,s),"query"===e&&this.onQueryChange&&this.onQueryChange(r,s),"suggestionsQuery"===e&&this.onSuggestionsQueryChange&&this.onSuggestionsQueryChange(r,s),"value"===e&&this.onValueChange&&this.onValueChange(r,s),"error"===e&&this.onError&&this.onError(r),"suggestionsError"===e&&this.onSuggestionsError&&this.onSuggestionsError(r),"results"===e&&this.onResults&&this.onResults(r,s),"suggestions"===e&&this.onSuggestions&&this.onSuggestions(r,s),"requestStatus"===e&&this.onRequestStatusChange&&this.onRequestStatusChange(r,s),"suggestionsRequestStatus"===e&&this.onSuggestionsRequestStatusChange&&this.onSuggestionsRequestStatusChange(r,s),t.triggerQuery&&this.triggerQuery(),t.triggerSuggestionsQuery&&this.triggerSuggestionsQuery(),!1!==t.stateChanges)&&this.stateChanges.next(((i={})[e]={prev:s,next:r},i),e)},e(t,[{key:"micStatus",get:function(){return this._micStatus}},{key:"micInstance",get:function(){return this._micInstance}},{key:"micActive",get:function(){return this._micStatus===m.active}},{key:"micInactive",get:function(){return this._micStatus===m.inactive}},{key:"micDenied",get:function(){return this._micStatus===m.denied}},{key:"query",get:function(){return this._query}},{key:"suggestionsQuery",get:function(){return this._suggestionsQuery}},{key:"requestPending",get:function(){return this.requestStatus===b.pending}},{key:"suggestionsRequestPending",get:function(){return this.suggestionsRequestStatus===b.pending}}]),t}();return s(w,"defaultQuery",void 0),s(w,"shouldQuery",void 0),s(w,"highlightQuery",void 0),s(w,"generateQueryOptions",void 0),w.defaultQuery=function(t,e){var s,r=null;return t&&(s=Array.isArray(e.dataField)?e.dataField:[e.dataField],r=e.searchOperators?{simple_query_string:w.shouldQuery(t,s,e)}:{bool:{should:w.shouldQuery(t,s,e),minimum_should_match:"1"}}),""===t&&(r=null),r&&e.nestedField&&(r={nested:{path:e.nestedField,query:r}}),r},w.shouldQuery=function(t,e,s){void 0===s&&(s={searchOperators:!1,queryFormat:"or",fuzziness:0});var r=e.map(function(t){return"object"==typeof t?t.field+(t.weight?"^"+t.weight:""):t});return s.searchOperators?{query:t,fields:r,default_operator:s.queryFormat}:"and"===s.queryFormat?[{multi_match:{query:t,fields:r,type:"cross_fields",operator:"and"}},{multi_match:{query:t,fields:r,type:"phrase_prefix",operator:"and"}}]:[{multi_match:{query:t,fields:r,type:"best_fields",operator:"or",fuzziness:s.fuzziness}},{multi_match:{query:t,fields:r,type:"phrase_prefix",operator:"or"}}]},w.highlightQuery=function(t,e,s){if(!t)return null;var i={},n=e||s,o="string"==typeof e?[e]:e;return"string"==typeof n?i[n]={}:Array.isArray(n)&&n.forEach(function(t){"object"==typeof t?i[t.field]={}:i[t]={}}),{highlight:r({pre_tags:["<mark>"],post_tags:["</mark>"],fields:i},o&&{require_field_match:!1})}},w.generateQueryOptions=function(t){var e,s={};if(void 0!==t.size&&(s.size=t.size),void 0!==t.from&&(s.from=t.from),t.includeFields||t.excludeFields){var r={};t.includeFields&&(r.includes=t.includeFields),t.excludeFields&&(r.excludes=t.excludeFields),s._source=r}if(t.sortOptions)s.sort=[(e={},e[t.sortOptions[0].dataField]={order:t.sortOptions[0].sortBy},e)];else if(t.sortBy&&t.sortByField){var i;s.sort=[(i={},i[t.sortByField]={order:t.sortBy},i)]}return s},w});
//# sourceMappingURL=searchbase.umd.min.js.map
{
"name": "@appbaseio/searchbase",
"version": "1.0.0-alpha.3",
"version": "1.0.0-alpha.4",
"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 not supported yet

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