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

addsearch-js-client

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addsearch-js-client - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

2

dist/addsearch-js-client.min.js

@@ -8,2 +8,2 @@ window.AddSearchClient=function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){(function(e,n){

* @version v4.2.8+1e68dce6
*/var i;i=function(){"use strict";function t(t){return"function"==typeof t}var i=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},s=0,r=void 0,o=void 0,a=function(t,e){p[s]=t,p[s+1]=e,2===(s+=2)&&(o?o(g):w())},u="undefined"!=typeof window?window:void 0,c=u||{},l=c.MutationObserver||c.WebKitMutationObserver,h="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),f="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var p=new Array(1e3);function g(){for(var t=0;t<s;t+=2)(0,p[t])(p[t+1]),p[t]=void 0,p[t+1]=void 0;s=0}var y,m,b,v,w=void 0;function _(t,e){var n=this,i=new this.constructor(A);void 0===i[T]&&L(i);var s=n._state;if(s){var r=arguments[s-1];a((function(){return R(s,i,r,n._result)}))}else C(n,i,t,e);return i}function F(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(A);return E(e,t),e}h?w=function(){return e.nextTick(g)}:l?(m=0,b=new l(g),v=document.createTextNode(""),b.observe(v,{characterData:!0}),w=function(){v.data=m=++m%2}):f?((y=new MessageChannel).port1.onmessage=g,w=function(){return y.port2.postMessage(0)}):w=void 0===u?function(){try{var t=Function("return this")().require("vertx");return void 0!==(r=t.runOnLoop||t.runOnContext)?function(){r(g)}:d()}catch(t){return d()}}():d();var T=Math.random().toString(36).substring(2);function A(){}var S=void 0,x=1,O=2;function P(e,n,i){n.constructor===e.constructor&&i===_&&n.constructor.resolve===F?function(t,e){e._state===x?z(t,e._result):e._state===O?k(t,e._result):C(e,void 0,(function(e){return E(t,e)}),(function(e){return k(t,e)}))}(e,n):void 0===i?z(e,n):t(i)?function(t,e,n){a((function(t){var i=!1,s=function(t,e,n,i){try{t.call(e,n,i)}catch(t){return t}}(n,e,(function(n){i||(i=!0,e!==n?E(t,n):z(t,n))}),(function(e){i||(i=!0,k(t,e))}),t._label);!i&&s&&(i=!0,k(t,s))}),t)}(e,n,i):z(e,n)}function E(t,e){if(t===e)k(t,new TypeError("You cannot resolve a promise with itself"));else if(s=typeof(i=e),null===i||"object"!==s&&"function"!==s)z(t,e);else{var n=void 0;try{n=e.then}catch(e){return void k(t,e)}P(t,e,n)}var i,s}function j(t){t._onerror&&t._onerror(t._result),B(t)}function z(t,e){t._state===S&&(t._result=e,t._state=x,0!==t._subscribers.length&&a(B,t))}function k(t,e){t._state===S&&(t._state=O,t._result=e,a(j,t))}function C(t,e,n,i){var s=t._subscribers,r=s.length;t._onerror=null,s[r]=e,s[r+x]=n,s[r+O]=i,0===r&&t._state&&a(B,t)}function B(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var i=void 0,s=void 0,r=t._result,o=0;o<e.length;o+=3)i=e[o],s=e[o+n],i?R(n,i,s,r):s(r);t._subscribers.length=0}}function R(e,n,i,s){var r=t(i),o=void 0,a=void 0,u=!0;if(r){try{o=i(s)}catch(t){u=!1,a=t}if(n===o)return void k(n,new TypeError("A promises callback cannot return that same promise."))}else o=s;n._state!==S||(r&&u?E(n,o):!1===u?k(n,a):e===x?z(n,o):e===O&&k(n,o))}var U=0;function L(t){t[T]=U++,t._state=void 0,t._result=void 0,t._subscribers=[]}var I=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(A),this.promise[T]||L(this.promise),i(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?z(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&z(this.promise,this._result))):k(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;this._state===S&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,i=n.resolve;if(i===F){var s=void 0,r=void 0,o=!1;try{s=t.then}catch(t){o=!0,r=t}if(s===_&&t._state!==S)this._settledAt(t._state,e,t._result);else if("function"!=typeof s)this._remaining--,this._result[e]=t;else if(n===D){var a=new n(A);o?k(a,r):P(a,t,s),this._willSettleAt(a,e)}else this._willSettleAt(new n((function(e){return e(t)})),e)}else this._willSettleAt(i(t),e)},t.prototype._settledAt=function(t,e,n){var i=this.promise;i._state===S&&(this._remaining--,t===O?k(i,n):this._result[e]=n),0===this._remaining&&z(i,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;C(t,void 0,(function(t){return n._settledAt(x,e,t)}),(function(t){return n._settledAt(O,e,t)}))},t}(),D=function(){function e(t){this[T]=U++,this._result=this._state=void 0,this._subscribers=[],A!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(t,e){try{e((function(e){E(t,e)}),(function(e){k(t,e)}))}catch(e){k(t,e)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var n=this.constructor;return t(e)?this.then((function(t){return n.resolve(e()).then((function(){return t}))}),(function(t){return n.resolve(e()).then((function(){throw t}))})):this.then(e,e)},e}();return D.prototype.then=_,D.all=function(t){return new I(this,t).promise},D.race=function(t){var e=this;return i(t)?new e((function(n,i){for(var s=t.length,r=0;r<s;r++)e.resolve(t[r]).then(n,i)})):new e((function(t,e){return e(new TypeError("You must pass an array to race."))}))},D.resolve=F,D.reject=function(t){var e=new this(A);return k(e,t),e},D._setScheduler=function(t){o=t},D._setAsap=function(t){a=t},D._asap=a,D.polyfill=function(){var t=void 0;if(void 0!==n)t=n;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var i=null;try{i=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===i&&!e.cast)return}t.Promise=D},D.Promise=D,D},t.exports=i()}).call(this,n(4),n(5))},function(t,e,n){n(6),t.exports=self.fetch.bind(self)},function(t,e,n){"use strict";var i=n(3),s=n(7),r=n(8),o=n(9);t.exports=function(t){this.sitekey=t,this.settings=new r,this.sessionId=("a-"+1e8*Math.random()).substring(0,10),this.search=function(t,e){var n=null,s=null;if(t&&o.isFunction(e))n=t,s=e;else if(!e&&o.isFunction(t))n=this.settings.getSettings().keyword,s=t;else{if(!this.settings.getSettings().callback)throw"Illegal search parameters. Should be (keyword, callbackFunction) or (callbackFunction)";n=this.settings.getSettings().keyword,s=this.settings.getSettings().callback}this.settings.setCallback(s),this.settings.setKeyword(n),i(this.sitekey,"search",this.settings.getSettings(),s)},this.suggestions=function(t,e){if(!t||!e||!o.isFunction(e))throw"Illegal suggestions parameters. Should be (prefix, callbackFunction)";this.settings.setSuggestionsPrefix(t),i(this.sitekey,"suggest",this.settings.getSettings(),e)},this.autocomplete=function(t,e,n){if(!(t&&e&&n&&o.isFunction(n)))throw"Illegal autocomplete parameters. Should be (field, prefix, callbackFunction)";this.settings.setAutocompleteParams(t,e),i(this.sitekey,"autocomplete",this.settings.getSettings(),n)},this.getSettings=function(){return this.settings.getSettings()},this.setLanguage=function(t){this.settings.setLanguage(t)},this.setCategoryFilters=function(t){this.settings.setCategoryFilters(t)},this.addCustomFieldFilter=function(t,e){this.settings.addCustomFieldFilter(t,e)},this.removeCustomFieldFilter=function(t,e){this.settings.removeCustomFieldFilter(t,e)},this.setPriceRangeFilter=function(t,e){this.settings.setPriceRangeFilter(t,e)},this.setDateFilter=function(t,e){this.settings.setDateFilter(t,e)},this.setJWT=function(t){this.settings.setJWT(t)},this.setUserToken=function(t){this.settings.setUserToken(t)},this.setPaging=function(t,e,n,i){this.settings.setPaging(t,e,n,i)},this.nextPage=function(){this.settings.nextPage()},this.previousPage=function(){this.settings.previousPage()},this.setSuggestionsSize=function(t){this.settings.setSuggestionsSize(t)},this.setAutocompleteSize=function(t){this.settings.setAutocompleteSize(t)},this.addFacetField=function(t){this.settings.addFacetField(t)},this.setNumberOfFacets=function(t){this.settings.setNumberOfFacets(t)},this.setResultType=function(t){this.settings.setResultType(t)},this.setPersonalizationEvents=function(t){this.settings.setPersonalizationEvents(t)},this.setFilterObject=function(t){this.settings.setFilterObject(t)},this.setShuffleAndLimitTo=function(t){this.settings.setShuffleAndLimitTo(t)},this.setFuzzyMatch=function(t){this.settings.setFuzzyMatch(t)},this.setCollectAnalytics=function(t){this.settings.setCollectAnalytics(t)},this.searchResultClicked=function(t,e){var n={action:"click",session:this.sessionId,keyword:this.settings.getSettings().keyword,docid:t,position:e};s(this.sitekey,n)},this.useFuzzyMatch=function(t){this.settings.setFuzzyMatch(t)}}},function(t,e,n){"use strict";n(0).polyfill(),n(1);t.exports=function(t,e,n,i){var s=function(t,e){return t||!1===t?"&"+e+"="+t:""};if("search"===e||"suggest"===e||"autocomplete"===e){var r="",o="",a=null;if("search"===e){if(a=e,r=(r=n.keyword).replace(/ and /g," AND ").replace(/ or /g," OR ").replace(/ not /g," NOT "),r=encodeURIComponent(r),"search"===e){if(o=s(n.lang,"lang")+s(n.fuzzy,"fuzzy")+s(n.collectAnalytics,"collectAnalytics")+s(n.categories,"categories")+s(n.priceFromCents,"priceFromCents")+s(n.priceToCents,"priceToCents")+s(n.dateFrom,"dateFrom")+s(n.dateTo,"dateTo")+s(n.paging.page,"page")+s(n.paging.pageSize,"limit")+s(n.paging.sortBy,"sort")+s(n.paging.sortOrder,"order")+s(n.shuffleAndLimitTo,"shuffleAndLimitTo")+s(n.jwt,"jwt")+s(n.resultType,"resultType")+s(n.userToken,"userToken")+s(n.numFacets,"numFacets"),n.customFieldFilters)for(var u=0;u<n.customFieldFilters.length;u++)o=o+"&customField="+n.customFieldFilters[u];if(n.facetFields)for(u=0;u<n.facetFields.length;u++)o=o+"&facet="+n.facetFields[u];if(n.personalizationEvents&&Array.isArray(n.personalizationEvents))for(u=0;u<n.personalizationEvents.length;u++){var c=n.personalizationEvents[u],l=Object.keys(c);o=o+"&personalizationEvent="+encodeURIComponent(l+"="+c[l])}n.filterObject&&(o=o+"&filter="+JSON.stringify(n.filterObject))}}else"suggest"===e?(a=e,o=s(n.suggestionsSize,"size"),r=n.suggestionsPrefix):"autocomplete"===e&&(a="autocomplete/document-field",o=s(n.autocomplete.field,"source")+s(n.autocomplete.size,"size"),r=n.autocomplete.prefix);fetch("https://api.addsearch.com/v1/"+a+"/"+t+"?term="+r+o).then((function(t){return t.json()})).then((function(t){i(t)})).catch((function(t){console.log(t),i({error:{response:500,message:"invalid server response"}})}))}else i({error:{response:400,message:"invalid query type"}})}},function(t,e){var n,i,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(t){n=r}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(t){i=o}}();var u,c=[],l=!1,h=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):h=-1,c.length&&d())}function d(){if(!l){var t=a(f);l=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,l=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function g(){}s.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new p(t,e)),1!==c.length||l||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=g,s.addListener=g,s.once=g,s.off=g,s.removeListener=g,s.removeAllListeners=g,s.emit=g,s.prependListener=g,s.prependOnceListener=g,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"Headers",(function(){return c})),n.d(e,"Request",(function(){return y})),n.d(e,"Response",(function(){return b})),n.d(e,"DOMException",(function(){return w})),n.d(e,"fetch",(function(){return _}));var i={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(i.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],r=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function o(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 a(t){return"string"!=typeof t&&(t=String(t)),t}function u(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return i.iterable&&(e[Symbol.iterator]=function(){return e}),e}function c(t){this.map={},t instanceof c?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 l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function h(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function f(t){var e=new FileReader,n=h(e);return e.readAsArrayBuffer(t),n}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 p(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:i.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():i.arrayBuffer&&i.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):i.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||r(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):i.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i.blob&&(this.blob=function(){var t=l(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?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,n,i=l(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=h(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),i=0;i<e.length;i++)n[i]=String.fromCharCode(e[i]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}c.prototype.append=function(t,e){t=o(t),e=a(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},c.prototype.delete=function(t){delete this.map[o(t)]},c.prototype.get=function(t){return t=o(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(o(t))},c.prototype.set=function(t,e){this.map[o(t)]=a(e)},c.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},c.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),u(t)},c.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),u(t)},c.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),u(t)},i.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function y(t,e){var n,i,s=(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 c(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,s||null==t._bodyInit||(s=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 c(e.headers)),this.method=(n=e.method||this.method||"GET",i=n.toUpperCase(),g.indexOf(i)>-1?i:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),i=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(s))}})),e}function b(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 c(e.headers),this.url=e.url||"",this._initBody(t)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},p.call(y.prototype),p.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];b.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})};var w=self.DOMException;try{new w}catch(t){(w=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),w.prototype.constructor=w}function _(t,e){return new Promise((function(n,s){var r=new y(t,e);if(r.signal&&r.signal.aborted)return s(new w("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}o.onload=function(){var t,e,i={status:o.status,statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new c,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),i=n.shift().trim();if(i){var s=n.join(":").trim();e.append(i,s)}})),e)};i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;n(new b(s,i))},o.onerror=function(){s(new TypeError("Network request failed"))},o.ontimeout=function(){s(new TypeError("Network request failed"))},o.onabort=function(){s(new w("Aborted","AbortError"))},o.open(r.method,r.url,!0),"include"===r.credentials?o.withCredentials=!0:"omit"===r.credentials&&(o.withCredentials=!1),"responseType"in o&&i.blob&&(o.responseType="blob"),r.headers.forEach((function(t,e){o.setRequestHeader(e,t)})),r.signal&&(r.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&r.signal.removeEventListener("abort",a)}),o.send(void 0===r._bodyInit?null:r._bodyInit)}))}_.polyfill=!0,self.fetch||(self.fetch=_,self.Headers=c,self.Request=y,self.Response=b)},function(t,e,n){"use strict";n(0).polyfill(),n(1);t.exports=function(t,e){"undefined"!=typeof window&&window.navigator&&window.navigator.sendBeacon?navigator.sendBeacon("https://api.addsearch.com/v1/stats/"+t+"/",JSON.stringify(e)):fetch("https://api.addsearch.com/v1/stats/"+t+"/",{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify(e)})}},function(t,e,n){"use strict";t.exports=function(){this.settings={keyword:"*",callback:null,fuzzy:"auto",paging:{page:1,pageSize:10,sortBy:"relevance",sortOrder:"desc"},customFieldFilters:[],userToken:null,suggestionsSize:10,facetFields:[],autocomplete:{size:10}},this.getSettings=function(){return this.settings},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setCallback=function(t){this.settings.callback=t},this.setSuggestionsPrefix=function(t){this.settings.suggestionsPrefix=t},this.setSuggestionsSize=function(t){this.settings.suggestionsSize=t},this.setAutocompleteSize=function(t){this.settings.autocomplete.size=t},this.setAutocompleteParams=function(t,e){this.settings.autocomplete.field=t,this.settings.autocomplete.prefix=e},this.setLanguage=function(t){if(t&&2!==t.length)throw'use 2-char language code (e.g. "en")';this.settings.lang=t},this.setFuzzyMatch=function(t){if(!0!==t&&!1!==t&&"auto"!==t)throw"fuzzy matching can be true, false, or 'auto'";this.settings.fuzzy=t},this.setCollectAnalytics=function(t){this.settings.collectAnalytics=t},this.setCategoryFilters=function(t){this.settings.categories=t},this.setFilterObject=function(t){this.settings.filterObject=t},this.setPriceRangeFilter=function(t,e){this.settings.priceFromCents=t,this.settings.priceToCents=e},this.addCustomFieldFilter=function(t,e){var n=encodeURIComponent(t+"="+e);-1===this.settings.customFieldFilters.indexOf(n)&&this.settings.customFieldFilters.push(n)},this.removeCustomFieldFilter=function(t,e){var n=!1,i=encodeURIComponent(t+"="+e);e||(n=!0,i=encodeURIComponent(t+"="));for(var s=this.settings.customFieldFilters.length;s>0;s--){var r=this.settings.customFieldFilters[s-1];n&&0===r.indexOf(i)?this.settings.customFieldFilters.splice(s-1,1):r===i&&this.settings.customFieldFilters.splice(s-1,1)}},this.setDateFilter=function(t,e){this.settings.dateFrom=t,this.settings.dateTo=e},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setJWT=function(t){this.settings.jwt=t},this.setUserToken=function(t){this.settings.userToken=t},this.setPersonalizationEvents=function(t){this.settings.personalizationEvents=t},this.setResultType=function(t){this.settings.resultType=t},this.addFacetField=function(t){-1===this.settings.facetFields.indexOf(t)&&this.settings.facetFields.push(t)},this.setNumberOfFacets=function(t){this.settings.numFacets=t},this.setPaging=function(t,e,n,i){if(t<1)throw"page must be 1 or bigger";if(e<1||e>300)throw"pageSize must be 1-300";if("asc"!==i&&"desc"!==i)throw"sortOrder must be asc or desc";this.settings.paging.page=t,this.settings.paging.pageSize=e,this.settings.paging.sortBy=n,this.settings.paging.sortOrder=i},this.setShuffleAndLimitTo=function(t){this.settings.shuffleAndLimitTo=t},this.nextPage=function(){this.settings.paging.page=this.settings.paging.page+1},this.previousPage=function(){this.settings.paging.page>0&&(this.settings.paging.page=this.settings.paging.page-1)}}},function(t,e){t.exports={isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)}}}]);
*/var i;i=function(){"use strict";function t(t){return"function"==typeof t}var i=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},s=0,r=void 0,o=void 0,a=function(t,e){p[s]=t,p[s+1]=e,2===(s+=2)&&(o?o(g):w())},u="undefined"!=typeof window?window:void 0,c=u||{},l=c.MutationObserver||c.WebKitMutationObserver,h="undefined"==typeof self&&void 0!==e&&"[object process]"==={}.toString.call(e),f="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function d(){var t=setTimeout;return function(){return t(g,1)}}var p=new Array(1e3);function g(){for(var t=0;t<s;t+=2)(0,p[t])(p[t+1]),p[t]=void 0,p[t+1]=void 0;s=0}var y,m,v,b,w=void 0;function _(t,e){var n=this,i=new this.constructor(A);void 0===i[T]&&B(i);var s=n._state;if(s){var r=arguments[s-1];a((function(){return z(s,i,r,n._result)}))}else k(n,i,t,e);return i}function F(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=new this(A);return x(e,t),e}h?w=function(){return e.nextTick(g)}:l?(m=0,v=new l(g),b=document.createTextNode(""),v.observe(b,{characterData:!0}),w=function(){b.data=m=++m%2}):f?((y=new MessageChannel).port1.onmessage=g,w=function(){return y.port2.postMessage(0)}):w=void 0===u?function(){try{var t=Function("return this")().require("vertx");return void 0!==(r=t.runOnLoop||t.runOnContext)?function(){r(g)}:d()}catch(t){return d()}}():d();var T=Math.random().toString(36).substring(2);function A(){}function S(e,n,i){n.constructor===e.constructor&&i===_&&n.constructor.resolve===F?function(t,e){1===e._state?O(t,e._result):2===e._state?P(t,e._result):k(e,void 0,(function(e){return x(t,e)}),(function(e){return P(t,e)}))}(e,n):void 0===i?O(e,n):t(i)?function(t,e,n){a((function(t){var i=!1,s=function(t,e,n,i){try{t.call(e,n,i)}catch(t){return t}}(n,e,(function(n){i||(i=!0,e!==n?x(t,n):O(t,n))}),(function(e){i||(i=!0,P(t,e))}),t._label);!i&&s&&(i=!0,P(t,s))}),t)}(e,n,i):O(e,n)}function x(t,e){if(t===e)P(t,new TypeError("You cannot resolve a promise with itself"));else if(s=typeof(i=e),null===i||"object"!==s&&"function"!==s)O(t,e);else{var n=void 0;try{n=e.then}catch(e){return void P(t,e)}S(t,e,n)}var i,s}function E(t){t._onerror&&t._onerror(t._result),j(t)}function O(t,e){void 0===t._state&&(t._result=e,t._state=1,0!==t._subscribers.length&&a(j,t))}function P(t,e){void 0===t._state&&(t._state=2,t._result=e,a(E,t))}function k(t,e,n,i){var s=t._subscribers,r=s.length;t._onerror=null,s[r]=e,s[r+1]=n,s[r+2]=i,0===r&&t._state&&a(j,t)}function j(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var i=void 0,s=void 0,r=t._result,o=0;o<e.length;o+=3)i=e[o],s=e[o+n],i?z(n,i,s,r):s(r);t._subscribers.length=0}}function z(e,n,i,s){var r=t(i),o=void 0,a=void 0,u=!0;if(r){try{o=i(s)}catch(t){u=!1,a=t}if(n===o)return void P(n,new TypeError("A promises callback cannot return that same promise."))}else o=s;void 0!==n._state||(r&&u?x(n,o):!1===u?P(n,a):1===e?O(n,o):2===e&&P(n,o))}var C=0;function B(t){t[T]=C++,t._state=void 0,t._result=void 0,t._subscribers=[]}var R=function(){function t(t,e){this._instanceConstructor=t,this.promise=new t(A),this.promise[T]||B(this.promise),i(e)?(this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?O(this.promise,this._result):(this.length=this.length||0,this._enumerate(e),0===this._remaining&&O(this.promise,this._result))):P(this.promise,new Error("Array Methods must be provided an Array"))}return t.prototype._enumerate=function(t){for(var e=0;void 0===this._state&&e<t.length;e++)this._eachEntry(t[e],e)},t.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,i=n.resolve;if(i===F){var s=void 0,r=void 0,o=!1;try{s=t.then}catch(t){o=!0,r=t}if(s===_&&void 0!==t._state)this._settledAt(t._state,e,t._result);else if("function"!=typeof s)this._remaining--,this._result[e]=t;else if(n===I){var a=new n(A);o?P(a,r):S(a,t,s),this._willSettleAt(a,e)}else this._willSettleAt(new n((function(e){return e(t)})),e)}else this._willSettleAt(i(t),e)},t.prototype._settledAt=function(t,e,n){var i=this.promise;void 0===i._state&&(this._remaining--,2===t?P(i,n):this._result[e]=n),0===this._remaining&&O(i,this._result)},t.prototype._willSettleAt=function(t,e){var n=this;k(t,void 0,(function(t){return n._settledAt(1,e,t)}),(function(t){return n._settledAt(2,e,t)}))},t}(),I=function(){function e(t){this[T]=C++,this._result=this._state=void 0,this._subscribers=[],A!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(t,e){try{e((function(e){x(t,e)}),(function(e){P(t,e)}))}catch(e){P(t,e)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(t){return this.then(null,t)},e.prototype.finally=function(e){var n=this.constructor;return t(e)?this.then((function(t){return n.resolve(e()).then((function(){return t}))}),(function(t){return n.resolve(e()).then((function(){throw t}))})):this.then(e,e)},e}();return I.prototype.then=_,I.all=function(t){return new R(this,t).promise},I.race=function(t){var e=this;return i(t)?new e((function(n,i){for(var s=t.length,r=0;r<s;r++)e.resolve(t[r]).then(n,i)})):new e((function(t,e){return e(new TypeError("You must pass an array to race."))}))},I.resolve=F,I.reject=function(t){var e=new this(A);return P(e,t),e},I._setScheduler=function(t){o=t},I._setAsap=function(t){a=t},I._asap=a,I.polyfill=function(){var t=void 0;if(void 0!==n)t=n;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var i=null;try{i=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===i&&!e.cast)return}t.Promise=I},I.Promise=I,I},t.exports=i()}).call(this,n(4),n(5))},function(t,e,n){n(6),t.exports=self.fetch.bind(self)},function(t,e,n){"use strict";var i=n(3),s=n(7),r=n(8),o=n(9);t.exports=function(t){this.sitekey=t,this.settings=new r,this.sessionId=("a-"+1e8*Math.random()).substring(0,10),this.search=function(t,e){var n=null,s=null;if(t&&o.isFunction(e))n=t,s=e;else if(!e&&o.isFunction(t))n=this.settings.getSettings().keyword,s=t;else{if(!this.settings.getSettings().callback)throw"Illegal search parameters. Should be (keyword, callbackFunction) or (callbackFunction)";n=this.settings.getSettings().keyword,s=this.settings.getSettings().callback}this.settings.setCallback(s),this.settings.setKeyword(n),i(this.sitekey,"search",this.settings.getSettings(),s)},this.suggestions=function(t,e){if(!t||!e||!o.isFunction(e))throw"Illegal suggestions parameters. Should be (prefix, callbackFunction)";this.settings.setSuggestionsPrefix(t),i(this.sitekey,"suggest",this.settings.getSettings(),e)},this.autocomplete=function(t,e,n){if(!(t&&e&&n&&o.isFunction(n)))throw"Illegal autocomplete parameters. Should be (field, prefix, callbackFunction)";this.settings.setAutocompleteParams(t,e),i(this.sitekey,"autocomplete",this.settings.getSettings(),n)},this.getSettings=function(){return this.settings.getSettings()},this.setLanguage=function(t){this.settings.setLanguage(t)},this.setCategoryFilters=function(t){this.settings.setCategoryFilters(t)},this.addCustomFieldFilter=function(t,e){this.settings.addCustomFieldFilter(t,e)},this.removeCustomFieldFilter=function(t,e){this.settings.removeCustomFieldFilter(t,e)},this.setPriceRangeFilter=function(t,e){this.settings.setPriceRangeFilter(t,e)},this.setDateFilter=function(t,e){this.settings.setDateFilter(t,e)},this.setJWT=function(t){this.settings.setJWT(t)},this.setUserToken=function(t){this.settings.setUserToken(t)},this.setPaging=function(t,e,n,i){this.settings.setPaging(t,e,n,i)},this.nextPage=function(){this.settings.nextPage()},this.previousPage=function(){this.settings.previousPage()},this.setSuggestionsSize=function(t){this.settings.setSuggestionsSize(t)},this.setAutocompleteSize=function(t){this.settings.setAutocompleteSize(t)},this.addFacetField=function(t){this.settings.addFacetField(t)},this.setNumberOfFacets=function(t){this.settings.setNumberOfFacets(t)},this.setResultType=function(t){this.settings.setResultType(t)},this.setPersonalizationEvents=function(t){this.settings.setPersonalizationEvents(t)},this.setFilterObject=function(t){this.settings.setFilterObject(t)},this.setShuffleAndLimitTo=function(t){this.settings.setShuffleAndLimitTo(t)},this.setFuzzyMatch=function(t){this.settings.setFuzzyMatch(t)},this.setCollectAnalytics=function(t){this.settings.setCollectAnalytics(t)},this.setStatsSessionId=function(t){this.sessionId=t},this.getStatsSessionId=function(){return this.sessionId},this.sendStatsEvent=function(t,e,n){if("search"===t){n={action:"search",session:this.sessionId,keyword:e,numberOfResults:n.numberOfResults};s(this.sitekey,n)}else{if("click"!==t)throw"Illegal sendStatsEvent type parameters. Should be search or click)";n={action:"click",session:this.sessionId,keyword:e,docid:n.documentId,position:n.position};s(this.sitekey,n)}},this.searchResultClicked=function(t,e){this.sendStatsEvent("click",this.settings.getSettings().keyword,{documentId:t,position:e})}}},function(t,e,n){"use strict";n(0).polyfill(),n(1);t.exports=function(t,e,n,i){var s=function(t,e){return t||!1===t?"&"+e+"="+t:""};if("search"===e||"suggest"===e||"autocomplete"===e){var r="",o="",a=null;if("search"===e){if(a=e,r=(r=n.keyword).replace(/ and /g," AND ").replace(/ or /g," OR ").replace(/ not /g," NOT "),r=encodeURIComponent(r),"search"===e){if(o=s(n.lang,"lang")+s(n.fuzzy,"fuzzy")+s(n.collectAnalytics,"collectAnalytics")+s(n.categories,"categories")+s(n.priceFromCents,"priceFromCents")+s(n.priceToCents,"priceToCents")+s(n.dateFrom,"dateFrom")+s(n.dateTo,"dateTo")+s(n.paging.page,"page")+s(n.paging.pageSize,"limit")+s(n.paging.sortBy,"sort")+s(n.paging.sortOrder,"order")+s(n.shuffleAndLimitTo,"shuffleAndLimitTo")+s(n.jwt,"jwt")+s(n.resultType,"resultType")+s(n.userToken,"userToken")+s(n.numFacets,"numFacets"),n.customFieldFilters)for(var u=0;u<n.customFieldFilters.length;u++)o=o+"&customField="+n.customFieldFilters[u];if(n.facetFields)for(u=0;u<n.facetFields.length;u++)o=o+"&facet="+n.facetFields[u];if(n.personalizationEvents&&Array.isArray(n.personalizationEvents))for(u=0;u<n.personalizationEvents.length;u++){var c=n.personalizationEvents[u],l=Object.keys(c);o=o+"&personalizationEvent="+encodeURIComponent(l+"="+c[l])}n.filterObject&&(o=o+"&filter="+JSON.stringify(n.filterObject))}}else"suggest"===e?(a=e,o=s(n.suggestionsSize,"size"),r=n.suggestionsPrefix):"autocomplete"===e&&(a="autocomplete/document-field",o=s(n.autocomplete.field,"source")+s(n.autocomplete.size,"size"),r=n.autocomplete.prefix);fetch("https://api.addsearch.com/v1/"+a+"/"+t+"?term="+r+o).then((function(t){return t.json()})).then((function(t){i(t)})).catch((function(t){console.log(t),i({error:{response:500,message:"invalid server response"}})}))}else i({error:{response:400,message:"invalid query type"}})}},function(t,e){var n,i,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(t){n=r}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(t){i=o}}();var u,c=[],l=!1,h=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):h=-1,c.length&&d())}function d(){if(!l){var t=a(f);l=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,l=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function g(){}s.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new p(t,e)),1!==c.length||l||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=g,s.addListener=g,s.once=g,s.off=g,s.removeListener=g,s.removeAllListeners=g,s.emit=g,s.prependListener=g,s.prependOnceListener=g,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"Headers",(function(){return d})),n.d(e,"Request",(function(){return w})),n.d(e,"Response",(function(){return F})),n.d(e,"DOMException",(function(){return A})),n.d(e,"fetch",(function(){return S}));var i="URLSearchParams"in self,s="Symbol"in self&&"iterator"in Symbol,r="FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in self,a="ArrayBuffer"in self;if(a)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function l(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 h(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return s&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?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 p(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function g(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function y(t){var e=new FileReader,n=g(e);return e.readAsArrayBuffer(t),n}function m(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:i&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():a&&r&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=m(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(t)||c(t))?this._bodyArrayBuffer=m(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):i&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r&&(this.blob=function(){var t=p(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?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,n,i=p(this);if(i)return i;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=g(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),i=0;i<e.length;i++)n[i]=String.fromCharCode(e[i]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=l(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},d.prototype.delete=function(t){delete this.map[l(t)]},d.prototype.get=function(t){return t=l(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(l(t))},d.prototype.set=function(t,e){this.map[l(t)]=h(e)},d.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),f(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),f(t)},s&&(d.prototype[Symbol.iterator]=d.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,i,s=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,s||null==t._bodyInit||(s=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 d(e.headers)),this.method=(n=e.method||this.method||"GET",i=n.toUpperCase(),b.indexOf(i)>-1?i:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(s)}function _(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),i=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(s))}})),e}function F(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 d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},v.call(w.prototype),v.call(F.prototype),F.prototype.clone=function(){return new F(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},F.error=function(){var t=new F(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];F.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new F(null,{status:e,headers:{location:t}})};var A=self.DOMException;try{new A}catch(t){(A=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack}).prototype=Object.create(Error.prototype),A.prototype.constructor=A}function S(t,e){return new Promise((function(n,i){var s=new w(t,e);if(s.signal&&s.signal.aborted)return i(new A("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}o.onload=function(){var t,e,i={status:o.status,statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),i=n.shift().trim();if(i){var s=n.join(":").trim();e.append(i,s)}})),e)};i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var s="response"in o?o.response:o.responseText;n(new F(s,i))},o.onerror=function(){i(new TypeError("Network request failed"))},o.ontimeout=function(){i(new TypeError("Network request failed"))},o.onabort=function(){i(new A("Aborted","AbortError"))},o.open(s.method,s.url,!0),"include"===s.credentials?o.withCredentials=!0:"omit"===s.credentials&&(o.withCredentials=!1),"responseType"in o&&r&&(o.responseType="blob"),s.headers.forEach((function(t,e){o.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&s.signal.removeEventListener("abort",a)}),o.send(void 0===s._bodyInit?null:s._bodyInit)}))}S.polyfill=!0,self.fetch||(self.fetch=S,self.Headers=d,self.Request=w,self.Response=F)},function(t,e,n){"use strict";n(0).polyfill(),n(1);t.exports=function(t,e){"undefined"!=typeof window&&window.navigator&&window.navigator.sendBeacon?navigator.sendBeacon("https://api.addsearch.com/v1/stats/"+t+"/",JSON.stringify(e)):fetch("https://api.addsearch.com/v1/stats/"+t+"/",{method:"POST",headers:{"Content-Type":"text/plain"},body:JSON.stringify(e)})}},function(t,e,n){"use strict";t.exports=function(){this.settings={keyword:"*",callback:null,fuzzy:"auto",paging:{page:1,pageSize:10,sortBy:"relevance",sortOrder:"desc"},customFieldFilters:[],userToken:null,suggestionsSize:10,facetFields:[],autocomplete:{size:10}},this.getSettings=function(){return this.settings},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setCallback=function(t){this.settings.callback=t},this.setSuggestionsPrefix=function(t){this.settings.suggestionsPrefix=t},this.setSuggestionsSize=function(t){this.settings.suggestionsSize=t},this.setAutocompleteSize=function(t){this.settings.autocomplete.size=t},this.setAutocompleteParams=function(t,e){this.settings.autocomplete.field=t,this.settings.autocomplete.prefix=e},this.setLanguage=function(t){if(t&&2!==t.length)throw'use 2-char language code (e.g. "en")';this.settings.lang=t},this.setFuzzyMatch=function(t){if(!0!==t&&!1!==t&&"auto"!==t)throw"fuzzy matching can be true, false, or 'auto'";this.settings.fuzzy=t},this.setCollectAnalytics=function(t){this.settings.collectAnalytics=t},this.setCategoryFilters=function(t){this.settings.categories=t},this.setFilterObject=function(t){this.settings.filterObject=t},this.setPriceRangeFilter=function(t,e){this.settings.priceFromCents=t,this.settings.priceToCents=e},this.addCustomFieldFilter=function(t,e){var n=encodeURIComponent(t+"="+e);-1===this.settings.customFieldFilters.indexOf(n)&&this.settings.customFieldFilters.push(n)},this.removeCustomFieldFilter=function(t,e){var n=!1,i=encodeURIComponent(t+"="+e);e||(n=!0,i=encodeURIComponent(t+"="));for(var s=this.settings.customFieldFilters.length;s>0;s--){var r=this.settings.customFieldFilters[s-1];(n&&0===r.indexOf(i)||r===i)&&this.settings.customFieldFilters.splice(s-1,1)}},this.setDateFilter=function(t,e){this.settings.dateFrom=t,this.settings.dateTo=e},this.setKeyword=function(t){this.settings.keyword=t||"*"},this.setJWT=function(t){this.settings.jwt=t},this.setUserToken=function(t){this.settings.userToken=t},this.setPersonalizationEvents=function(t){this.settings.personalizationEvents=t},this.setResultType=function(t){this.settings.resultType=t},this.addFacetField=function(t){-1===this.settings.facetFields.indexOf(t)&&this.settings.facetFields.push(t)},this.setNumberOfFacets=function(t){this.settings.numFacets=t},this.setPaging=function(t,e,n,i){if(t<1)throw"page must be 1 or bigger";if(e<1||e>300)throw"pageSize must be 1-300";if("asc"!==i&&"desc"!==i)throw"sortOrder must be asc or desc";this.settings.paging.page=t,this.settings.paging.pageSize=e,this.settings.paging.sortBy=n,this.settings.paging.sortOrder=i},this.setShuffleAndLimitTo=function(t){this.settings.shuffleAndLimitTo=t},this.nextPage=function(){this.settings.paging.page=this.settings.paging.page+1},this.previousPage=function(){this.settings.paging.page>0&&(this.settings.paging.page=this.settings.paging.page-1)}}},function(t,e){t.exports={isFunction:function(t){return t&&"[object Function]"==={}.toString.call(t)}}}]);
{
"name": "addsearch-js-client",
"version": "0.2.4",
"version": "0.3.0",
"description": "AddSearch API JavaScript client",

@@ -44,14 +44,14 @@ "main": "index.js",

"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/register": "^7.7.7",
"@babel/core": "^7.8.6",
"@babel/preset-env": "^7.8.6",
"@babel/register": "^7.8.6",
"babel-loader": "^8.0.6",
"esm": "^3.2.25",
"fetch-mock": "^8.3.2",
"mocha": "^6.2.2",
"fetch-mock": "^9.0.0",
"mocha": "^7.1.0",
"node-fetch": "^2.6.0",
"uglify-js": "^3.7.7",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
"uglify-js": "^3.8.0",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
}
}

@@ -73,7 +73,8 @@ # AddSearch Search API Client for JavaScript

#### Fetch custom field autocompletion
#### Custom field autocompletion
Custom fields autocomplete can be used for predictive search. For example, product names or categories can be
suggested as the keyword is being typed in.
```js
// Fetch custom field values starting with a specific prefix. In this example, results could be "adidas, apple, azure"
// Fetch custom field values starting with a specific prefix In this example, fetch records
// starting with *a* from the *custom_fields.brand* field. Results could be "adidas, apple, azure"
client.autocomplete('custom_fields.brand', 'a', callback);

@@ -90,53 +91,32 @@ ```

```js
// Enable/disable fuzzy matching. Possible values true/false/"auto" (default: "auto")
client.setFuzzyMatch(false);
// Control fuzzy matching used for typo-tolerance
// Possible values true/false/"auto" (default: "auto")
client.setFuzzyMatch(false);
```
#### Collect analytics
### Pagination
Set page number, page size and sorting parameters. It's possible to order results by:
- relevance (descending)
- date (ascending or descending)
- custom field value (ascending or descending. E.g. *custom_fields.price*)
```js
// Control whether search queries are sent to your AddSearch Analytics Dashboard or not (default: true)
client.setCollectAnalytics(false);
// Defaults: page "1", pageSize "10", sortBy "relevance", sortOrder "desc"
client.setPaging(page, pageSize, sortBy, sortOrder);
```
#### Send click event to analytics
When a search results is clicked, send the event to your AddSearch Analytics Dashboard. Information on clicks is used
in your statistics and in the self-learning search algorithm.
```js
// Docid is the 32-character long id that is part of each hit in search results
// Position is the position of the document that was clicked, the first result being 1
client.searchResultClicked(docid, position);
```
Other functions.
#### Set JSON Web Token (for authentication)
```js
// Add JWT to the search request (if protected search index)
client.setJWT(token);
```
// Next page (call search function to fetch results)
client.nextPage();
#### Set user token (for personalized search results)
```js
// Add a user token to the search request (if personalization in use)
client.setUserToken('uuid');
// Previous page
client.previousPage();
```
#### Send personalization events with search query
In personalized search, user events are typically sent to AddSearch via API and a user token
is passed with the search query (see setUserToken function).
An alternative way is to send user events needed for personalization with the search query.
### Filters
```js
// Events depend on the personalization strategy
// Contact AddSearch for more information
var events = [
{favorite_genre: 'rock'},
{favorite_band: 'Red Hot Chili Peppers'},
{least_favorite_genre: 'country'}
];
client.setPersonalizationEvents(events);
```
#### Define language filter
```js
// Documents in specific language (e.g. "en" or "de")
// Fetch documents in specific language (e.g. "en" or "de")
client.setLanguage('en');

@@ -199,22 +179,2 @@ ```

#### Manage paging
Set page number, page size and sorting parameters. It's possible to order results by:
- relevance (descending)
- date (ascending or descending)
- custom field value (ascending or descending. E.g. *custom_fields.price*)
```js
// Defaults: page "1", pageSize "10", sortBy "relevance", sortOrder "desc"
client.setPaging(page, pageSize, sortBy, sortOrder);
```
Other functions.
```js
// Next page (call search function to fetch results)
client.nextPage();
// Previous page
client.previousPage();
```
#### Set result type

@@ -227,3 +187,3 @@ ```js

#### Facets
### Facets
```js

@@ -241,2 +201,68 @@ // Declare fields for faceting. Number of hits found from

### Search analytics
#### Send search event to analytics
When search is executed, send the event to your AddSearch Analytics Dashboard.
```js
// If the numberOfResults is 0, the search is shown in the list of "queries with no hits"
client.sendStatsEvent('search', keyword, {numberOfResults: n});
```
#### Send click event to analytics
When a search results is clicked, send the event to your AddSearch Analytics Dashboard. Click information is shown
in your statistics and used by the self-learning search algorithm.
```js
// documentId is the 32-character long id that is part of each hit in search results.
// position is the position of the document that was clicked, the first result being 1
client.sendStatsEvent('click', keyword, {documentId: id, position: n});
```
#### Set or get stats session ID
Control the search session ID manually. Search queries with the same ID are grouped on the Analytics Dashboard.
For example, in a search-as-you-type implementation the final keyword of a given session is shown.
```js
client.getStatsSessionId();
client.setStatsSessionId(id);
```
#### Collect search events automatically
Send search events automatically to the Analytics Dashboard. Not recommended in search-as-you-type implementations,
as every keystroke would fire a statistics event
```js
// Control whether search queries are sent to your AddSearch Analytics Dashboard automatically or not (default: true)
client.setCollectAnalytics(false);
```
### Personalization
#### Set user token (for personalized search results)
```js
// Add a user token to the search request (if personalization in use)
client.setUserToken('uuid');
```
#### Send personalization events with search query
In personalized search, user events are typically sent to AddSearch via API and a user token
is passed with the search query (see setUserToken function).
An alternative way is to send user events needed for personalization with the search query.
```js
// Events depend on the personalization strategy
// Contact AddSearch for more information
var events = [
{favorite_genre: 'rock'},
{favorite_band: 'Red Hot Chili Peppers'},
{least_favorite_genre: 'country'}
];
client.setPersonalizationEvents(events);
```
### Other
#### Set JSON Web Token (for authentication)
```js
// Add JWT to the search request (if protected search index)
client.setJWT(token);
```
## Supported web browsers and node.js versions

@@ -259,2 +285,8 @@ The client is tested on

#### Code
Re-compile automatically when source files are changed
```sh
npm run watch
```
#### Run tests

@@ -261,0 +293,0 @@ ```sh

@@ -104,17 +104,39 @@ 'use strict';

this.setCollectAnalytics = function(collectAnalytics) { this.settings.setCollectAnalytics(collectAnalytics); }
this.searchResultClicked = function(documentId, position) {
var data = {
action: 'click',
session: this.sessionId,
keyword: this.settings.getSettings().keyword,
docid: documentId,
position: position
};
sendStats(this.sitekey, data);
this.setStatsSessionId = function(id) { this.sessionId = id; }
this.getStatsSessionId = function() { return this.sessionId; }
this.sendStatsEvent = function(type, keyword, data) {
if (type === 'search') {
var data = {
action: 'search',
session: this.sessionId,
keyword: keyword,
numberOfResults: data.numberOfResults
};
sendStats(this.sitekey, data);
}
else if (type === 'click') {
var data = {
action: 'click',
session: this.sessionId,
keyword: keyword,
docid: data.documentId,
position: data.position
};
sendStats(this.sitekey, data);
}
else {
throw "Illegal sendStatsEvent type parameters. Should be search or click)";
}
}
// Deprecated
this.useFuzzyMatch = function(use) { this.settings.setFuzzyMatch(use); }
this.searchResultClicked = function(documentId, position) {
this.sendStatsEvent('click', this.settings.getSettings().keyword, {documentId: documentId, position: position});
}
}
module.exports = client;
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