@appbaseio/autocomplete-suggestions-plugin
Advanced tools
Comparing version 1.0.13-alpha to 1.0.14-alpha
1269
lib/index.js
@@ -1,1267 +0,2 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __commonJS = (cb, mod) => function __require() { | ||
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
}; | ||
var __reExport = (target, module, desc) => { | ||
if (module && typeof module === "object" || typeof module === "function") { | ||
for (let key of __getOwnPropNames(module)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toModule = (module) => { | ||
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module); | ||
}; | ||
// node_modules/url-parser-lite/index.js | ||
var require_url_parser_lite = __commonJS({ | ||
"node_modules/url-parser-lite/index.js"(exports, module) { | ||
function URL2(url) { | ||
var pattern = RegExp("^(([^:/?#]*)?://)?(((.*)?@)?([^/?#]*)?)([^?#]*)(\\?([^#]*))?(#(.*))?"); | ||
var matches = url.match(pattern); | ||
return { | ||
protocol: matches[2], | ||
auth: matches[5], | ||
host: matches[6], | ||
path: matches[7], | ||
query: matches[9], | ||
hash: matches[11] | ||
}; | ||
} | ||
module.exports = URL2; | ||
} | ||
}); | ||
// node_modules/querystring/decode.js | ||
var require_decode = __commonJS({ | ||
"node_modules/querystring/decode.js"(exports, module) { | ||
"use strict"; | ||
function hasOwnProperty(obj, prop) { | ||
return Object.prototype.hasOwnProperty.call(obj, prop); | ||
} | ||
module.exports = function(qs, sep, eq, options) { | ||
sep = sep || "&"; | ||
eq = eq || "="; | ||
var obj = {}; | ||
if (typeof qs !== "string" || qs.length === 0) { | ||
return obj; | ||
} | ||
var regexp = /\+/g; | ||
qs = qs.split(sep); | ||
var maxKeys = 1e3; | ||
if (options && typeof options.maxKeys === "number") { | ||
maxKeys = options.maxKeys; | ||
} | ||
var len = qs.length; | ||
if (maxKeys > 0 && len > maxKeys) { | ||
len = maxKeys; | ||
} | ||
for (var i = 0; i < len; ++i) { | ||
var x = qs[i].replace(regexp, "%20"), idx = x.indexOf(eq), kstr, vstr, k, v; | ||
if (idx >= 0) { | ||
kstr = x.substr(0, idx); | ||
vstr = x.substr(idx + 1); | ||
} else { | ||
kstr = x; | ||
vstr = ""; | ||
} | ||
k = decodeURIComponent(kstr); | ||
v = decodeURIComponent(vstr); | ||
if (!hasOwnProperty(obj, k)) { | ||
obj[k] = v; | ||
} else if (Array.isArray(obj[k])) { | ||
obj[k].push(v); | ||
} else { | ||
obj[k] = [obj[k], v]; | ||
} | ||
} | ||
return obj; | ||
}; | ||
} | ||
}); | ||
// node_modules/querystring/encode.js | ||
var require_encode = __commonJS({ | ||
"node_modules/querystring/encode.js"(exports, module) { | ||
"use strict"; | ||
var stringifyPrimitive = function(v) { | ||
switch (typeof v) { | ||
case "string": | ||
return v; | ||
case "boolean": | ||
return v ? "true" : "false"; | ||
case "number": | ||
return isFinite(v) ? v : ""; | ||
default: | ||
return ""; | ||
} | ||
}; | ||
module.exports = function(obj, sep, eq, name) { | ||
sep = sep || "&"; | ||
eq = eq || "="; | ||
if (obj === null) { | ||
obj = void 0; | ||
} | ||
if (typeof obj === "object") { | ||
return Object.keys(obj).map(function(k) { | ||
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; | ||
if (Array.isArray(obj[k])) { | ||
return obj[k].map(function(v) { | ||
return ks + encodeURIComponent(stringifyPrimitive(v)); | ||
}).join(sep); | ||
} else { | ||
return ks + encodeURIComponent(stringifyPrimitive(obj[k])); | ||
} | ||
}).filter(Boolean).join(sep); | ||
} | ||
if (!name) | ||
return ""; | ||
return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj)); | ||
}; | ||
} | ||
}); | ||
// node_modules/querystring/index.js | ||
var require_querystring = __commonJS({ | ||
"node_modules/querystring/index.js"(exports) { | ||
"use strict"; | ||
exports.decode = exports.parse = require_decode(); | ||
exports.encode = exports.stringify = require_encode(); | ||
} | ||
}); | ||
// node_modules/cross-fetch/dist/browser-ponyfill.js | ||
var require_browser_ponyfill = __commonJS({ | ||
"node_modules/cross-fetch/dist/browser-ponyfill.js"(exports, module) { | ||
var __root__ = function(root) { | ||
function F() { | ||
this.fetch = false; | ||
} | ||
F.prototype = root; | ||
return new F(); | ||
}(typeof self !== "undefined" ? self : exports); | ||
(function(self2) { | ||
(function(self3) { | ||
if (self3.fetch) { | ||
return; | ||
} | ||
var support = { | ||
searchParams: "URLSearchParams" in self3, | ||
iterable: "Symbol" in self3 && "iterator" in Symbol, | ||
blob: "FileReader" in self3 && "Blob" in self3 && function() { | ||
try { | ||
new Blob(); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
}(), | ||
formData: "FormData" in self3, | ||
arrayBuffer: "ArrayBuffer" in self3 | ||
}; | ||
if (support.arrayBuffer) { | ||
var viewClasses = [ | ||
"[object Int8Array]", | ||
"[object Uint8Array]", | ||
"[object Uint8ClampedArray]", | ||
"[object Int16Array]", | ||
"[object Uint16Array]", | ||
"[object Int32Array]", | ||
"[object Uint32Array]", | ||
"[object Float32Array]", | ||
"[object Float64Array]" | ||
]; | ||
var isDataView = function(obj) { | ||
return obj && DataView.prototype.isPrototypeOf(obj); | ||
}; | ||
var isArrayBufferView = ArrayBuffer.isView || function(obj) { | ||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1; | ||
}; | ||
} | ||
function normalizeName(name) { | ||
if (typeof name !== "string") { | ||
name = String(name); | ||
} | ||
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { | ||
throw new TypeError("Invalid character in header field name"); | ||
} | ||
return name.toLowerCase(); | ||
} | ||
function normalizeValue(value) { | ||
if (typeof value !== "string") { | ||
value = String(value); | ||
} | ||
return value; | ||
} | ||
function iteratorFor(items) { | ||
var iterator = { | ||
next: function() { | ||
var value = items.shift(); | ||
return { done: value === void 0, value }; | ||
} | ||
}; | ||
if (support.iterable) { | ||
iterator[Symbol.iterator] = function() { | ||
return iterator; | ||
}; | ||
} | ||
return iterator; | ||
} | ||
function Headers2(headers) { | ||
this.map = {}; | ||
if (headers instanceof Headers2) { | ||
headers.forEach(function(value, name) { | ||
this.append(name, value); | ||
}, this); | ||
} else if (Array.isArray(headers)) { | ||
headers.forEach(function(header) { | ||
this.append(header[0], header[1]); | ||
}, this); | ||
} else if (headers) { | ||
Object.getOwnPropertyNames(headers).forEach(function(name) { | ||
this.append(name, headers[name]); | ||
}, this); | ||
} | ||
} | ||
Headers2.prototype.append = function(name, value) { | ||
name = normalizeName(name); | ||
value = normalizeValue(value); | ||
var oldValue = this.map[name]; | ||
this.map[name] = oldValue ? oldValue + "," + value : value; | ||
}; | ||
Headers2.prototype["delete"] = function(name) { | ||
delete this.map[normalizeName(name)]; | ||
}; | ||
Headers2.prototype.get = function(name) { | ||
name = normalizeName(name); | ||
return this.has(name) ? this.map[name] : null; | ||
}; | ||
Headers2.prototype.has = function(name) { | ||
return this.map.hasOwnProperty(normalizeName(name)); | ||
}; | ||
Headers2.prototype.set = function(name, value) { | ||
this.map[normalizeName(name)] = normalizeValue(value); | ||
}; | ||
Headers2.prototype.forEach = function(callback, thisArg) { | ||
for (var name in this.map) { | ||
if (this.map.hasOwnProperty(name)) { | ||
callback.call(thisArg, this.map[name], name, this); | ||
} | ||
} | ||
}; | ||
Headers2.prototype.keys = function() { | ||
var items = []; | ||
this.forEach(function(value, name) { | ||
items.push(name); | ||
}); | ||
return iteratorFor(items); | ||
}; | ||
Headers2.prototype.values = function() { | ||
var items = []; | ||
this.forEach(function(value) { | ||
items.push(value); | ||
}); | ||
return iteratorFor(items); | ||
}; | ||
Headers2.prototype.entries = function() { | ||
var items = []; | ||
this.forEach(function(value, name) { | ||
items.push([name, value]); | ||
}); | ||
return iteratorFor(items); | ||
}; | ||
if (support.iterable) { | ||
Headers2.prototype[Symbol.iterator] = Headers2.prototype.entries; | ||
} | ||
function consumed(body) { | ||
if (body.bodyUsed) { | ||
return Promise.reject(new TypeError("Already read")); | ||
} | ||
body.bodyUsed = true; | ||
} | ||
function fileReaderReady(reader) { | ||
return new Promise(function(resolve, reject) { | ||
reader.onload = function() { | ||
resolve(reader.result); | ||
}; | ||
reader.onerror = function() { | ||
reject(reader.error); | ||
}; | ||
}); | ||
} | ||
function readBlobAsArrayBuffer(blob) { | ||
var reader = new FileReader(); | ||
var promise = fileReaderReady(reader); | ||
reader.readAsArrayBuffer(blob); | ||
return promise; | ||
} | ||
function readBlobAsText(blob) { | ||
var reader = new FileReader(); | ||
var promise = fileReaderReady(reader); | ||
reader.readAsText(blob); | ||
return promise; | ||
} | ||
function readArrayBufferAsText(buf) { | ||
var view = new Uint8Array(buf); | ||
var chars = new Array(view.length); | ||
for (var i = 0; i < view.length; i++) { | ||
chars[i] = String.fromCharCode(view[i]); | ||
} | ||
return chars.join(""); | ||
} | ||
function bufferClone(buf) { | ||
if (buf.slice) { | ||
return buf.slice(0); | ||
} else { | ||
var view = new Uint8Array(buf.byteLength); | ||
view.set(new Uint8Array(buf)); | ||
return view.buffer; | ||
} | ||
} | ||
function Body() { | ||
this.bodyUsed = false; | ||
this._initBody = function(body) { | ||
this._bodyInit = body; | ||
if (!body) { | ||
this._bodyText = ""; | ||
} else if (typeof body === "string") { | ||
this._bodyText = body; | ||
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) { | ||
this._bodyBlob = body; | ||
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) { | ||
this._bodyFormData = body; | ||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { | ||
this._bodyText = body.toString(); | ||
} else if (support.arrayBuffer && support.blob && isDataView(body)) { | ||
this._bodyArrayBuffer = bufferClone(body.buffer); | ||
this._bodyInit = new Blob([this._bodyArrayBuffer]); | ||
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { | ||
this._bodyArrayBuffer = bufferClone(body); | ||
} else { | ||
throw new Error("unsupported BodyInit type"); | ||
} | ||
if (!this.headers.get("content-type")) { | ||
if (typeof body === "string") { | ||
this.headers.set("content-type", "text/plain;charset=UTF-8"); | ||
} else if (this._bodyBlob && this._bodyBlob.type) { | ||
this.headers.set("content-type", this._bodyBlob.type); | ||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { | ||
this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"); | ||
} | ||
} | ||
}; | ||
if (support.blob) { | ||
this.blob = function() { | ||
var rejected = consumed(this); | ||
if (rejected) { | ||
return rejected; | ||
} | ||
if (this._bodyBlob) { | ||
return Promise.resolve(this._bodyBlob); | ||
} else if (this._bodyArrayBuffer) { | ||
return Promise.resolve(new Blob([this._bodyArrayBuffer])); | ||
} else if (this._bodyFormData) { | ||
throw new Error("could not read FormData body as blob"); | ||
} else { | ||
return Promise.resolve(new Blob([this._bodyText])); | ||
} | ||
}; | ||
this.arrayBuffer = function() { | ||
if (this._bodyArrayBuffer) { | ||
return consumed(this) || Promise.resolve(this._bodyArrayBuffer); | ||
} else { | ||
return this.blob().then(readBlobAsArrayBuffer); | ||
} | ||
}; | ||
} | ||
this.text = function() { | ||
var rejected = consumed(this); | ||
if (rejected) { | ||
return rejected; | ||
} | ||
if (this._bodyBlob) { | ||
return readBlobAsText(this._bodyBlob); | ||
} else if (this._bodyArrayBuffer) { | ||
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); | ||
} else if (this._bodyFormData) { | ||
throw new Error("could not read FormData body as text"); | ||
} else { | ||
return Promise.resolve(this._bodyText); | ||
} | ||
}; | ||
if (support.formData) { | ||
this.formData = function() { | ||
return this.text().then(decode); | ||
}; | ||
} | ||
this.json = function() { | ||
return this.text().then(JSON.parse); | ||
}; | ||
return this; | ||
} | ||
var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; | ||
function normalizeMethod(method) { | ||
var upcased = method.toUpperCase(); | ||
return methods.indexOf(upcased) > -1 ? upcased : method; | ||
} | ||
function Request2(input, options) { | ||
options = options || {}; | ||
var body = options.body; | ||
if (input instanceof Request2) { | ||
if (input.bodyUsed) { | ||
throw new TypeError("Already read"); | ||
} | ||
this.url = input.url; | ||
this.credentials = input.credentials; | ||
if (!options.headers) { | ||
this.headers = new Headers2(input.headers); | ||
} | ||
this.method = input.method; | ||
this.mode = input.mode; | ||
if (!body && input._bodyInit != null) { | ||
body = input._bodyInit; | ||
input.bodyUsed = true; | ||
} | ||
} else { | ||
this.url = String(input); | ||
} | ||
this.credentials = options.credentials || this.credentials || "omit"; | ||
if (options.headers || !this.headers) { | ||
this.headers = new Headers2(options.headers); | ||
} | ||
this.method = normalizeMethod(options.method || this.method || "GET"); | ||
this.mode = options.mode || this.mode || null; | ||
this.referrer = null; | ||
if ((this.method === "GET" || this.method === "HEAD") && body) { | ||
throw new TypeError("Body not allowed for GET or HEAD requests"); | ||
} | ||
this._initBody(body); | ||
} | ||
Request2.prototype.clone = function() { | ||
return new Request2(this, { body: this._bodyInit }); | ||
}; | ||
function decode(body) { | ||
var form = new FormData(); | ||
body.trim().split("&").forEach(function(bytes) { | ||
if (bytes) { | ||
var split = bytes.split("="); | ||
var name = split.shift().replace(/\+/g, " "); | ||
var value = split.join("=").replace(/\+/g, " "); | ||
form.append(decodeURIComponent(name), decodeURIComponent(value)); | ||
} | ||
}); | ||
return form; | ||
} | ||
function parseHeaders(rawHeaders) { | ||
var headers = new Headers2(); | ||
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " "); | ||
preProcessedHeaders.split(/\r?\n/).forEach(function(line) { | ||
var parts = line.split(":"); | ||
var key = parts.shift().trim(); | ||
if (key) { | ||
var value = parts.join(":").trim(); | ||
headers.append(key, value); | ||
} | ||
}); | ||
return headers; | ||
} | ||
Body.call(Request2.prototype); | ||
function Response2(bodyInit, options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
this.type = "default"; | ||
this.status = options.status === void 0 ? 200 : options.status; | ||
this.ok = this.status >= 200 && this.status < 300; | ||
this.statusText = "statusText" in options ? options.statusText : "OK"; | ||
this.headers = new Headers2(options.headers); | ||
this.url = options.url || ""; | ||
this._initBody(bodyInit); | ||
} | ||
Body.call(Response2.prototype); | ||
Response2.prototype.clone = function() { | ||
return new Response2(this._bodyInit, { | ||
status: this.status, | ||
statusText: this.statusText, | ||
headers: new Headers2(this.headers), | ||
url: this.url | ||
}); | ||
}; | ||
Response2.error = function() { | ||
var response = new Response2(null, { status: 0, statusText: "" }); | ||
response.type = "error"; | ||
return response; | ||
}; | ||
var redirectStatuses = [301, 302, 303, 307, 308]; | ||
Response2.redirect = function(url, status) { | ||
if (redirectStatuses.indexOf(status) === -1) { | ||
throw new RangeError("Invalid status code"); | ||
} | ||
return new Response2(null, { status, headers: { location: url } }); | ||
}; | ||
self3.Headers = Headers2; | ||
self3.Request = Request2; | ||
self3.Response = Response2; | ||
self3.fetch = function(input, init) { | ||
return new Promise(function(resolve, reject) { | ||
var request = new Request2(input, init); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.onload = function() { | ||
var options = { | ||
status: xhr.status, | ||
statusText: xhr.statusText, | ||
headers: parseHeaders(xhr.getAllResponseHeaders() || "") | ||
}; | ||
options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL"); | ||
var body = "response" in xhr ? xhr.response : xhr.responseText; | ||
resolve(new Response2(body, options)); | ||
}; | ||
xhr.onerror = function() { | ||
reject(new TypeError("Network request failed")); | ||
}; | ||
xhr.ontimeout = function() { | ||
reject(new TypeError("Network request failed")); | ||
}; | ||
xhr.open(request.method, request.url, true); | ||
if (request.credentials === "include") { | ||
xhr.withCredentials = true; | ||
} else if (request.credentials === "omit") { | ||
xhr.withCredentials = false; | ||
} | ||
if ("responseType" in xhr && support.blob) { | ||
xhr.responseType = "blob"; | ||
} | ||
request.headers.forEach(function(value, name) { | ||
xhr.setRequestHeader(name, value); | ||
}); | ||
xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit); | ||
}); | ||
}; | ||
self3.fetch.polyfill = true; | ||
})(typeof self2 !== "undefined" ? self2 : this); | ||
}).call(__root__, void 0); | ||
var fetch2 = __root__.fetch; | ||
var Response = fetch2.Response = __root__.Response; | ||
var Request = fetch2.Request = __root__.Request; | ||
var Headers = fetch2.Headers = __root__.Headers; | ||
if (typeof module === "object" && module.exports) { | ||
module.exports = fetch2; | ||
module.exports.default = fetch2; | ||
} | ||
} | ||
}); | ||
// node_modules/appbase-js/dist/appbase-js.es.js | ||
var import_url_parser_lite = __toModule(require_url_parser_lite()); | ||
var import_querystring = __toModule(require_querystring()); | ||
var import_cross_fetch = __toModule(require_browser_ponyfill()); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) { | ||
return typeof obj; | ||
} : function(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
function contains(string, substring) { | ||
return string.indexOf(substring) !== -1; | ||
} | ||
function isAppbase(url) { | ||
return contains(url, "scalr.api.appbase.io"); | ||
} | ||
function btoa() { | ||
var input = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; | ||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | ||
var str = input; | ||
var output = ""; | ||
for (var block = 0, charCode, i = 0, map = chars; str.charAt(i | 0) || (map = "=", i % 1); output += map.charAt(63 & block >> 8 - i % 1 * 8)) { | ||
charCode = str.charCodeAt(i += 3 / 4); | ||
if (charCode > 255) { | ||
throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.'); | ||
} | ||
block = block << 8 | charCode; | ||
} | ||
return output; | ||
} | ||
function validateRSQuery(query) { | ||
if (query && Object.prototype.toString.call(query) === "[object Array]") { | ||
for (var i = 0; i < query.length; i += 1) { | ||
var q = query[i]; | ||
if (q) { | ||
if (!q.id) { | ||
return new Error("'id' field must be present in query object"); | ||
} | ||
} else { | ||
return new Error("query object can not have an empty value"); | ||
} | ||
} | ||
return true; | ||
} | ||
return new Error("invalid query value, 'query' value must be an array"); | ||
} | ||
function validate(object, fields) { | ||
var invalid = []; | ||
var emptyFor = { | ||
object: null, | ||
string: "", | ||
number: 0 | ||
}; | ||
var keys = Object.keys(fields); | ||
keys.forEach(function(key) { | ||
var types = fields[key].split("|"); | ||
var matchedType = types.find(function(type) { | ||
return _typeof(object[key]) === type; | ||
}); | ||
if (!matchedType || object[key] === emptyFor[matchedType]) { | ||
invalid.push(key); | ||
} | ||
}); | ||
var missing = ""; | ||
for (var i = 0; i < invalid.length; i += 1) { | ||
missing += invalid[i] + ", "; | ||
} | ||
if (invalid.length > 0) { | ||
return new Error("fields missing: " + missing); | ||
} | ||
return true; | ||
} | ||
function removeUndefined() { | ||
var value = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | ||
if (value || !(Object.keys(value).length === 0 && value.constructor === Object)) { | ||
return JSON.parse(JSON.stringify(value)); | ||
} | ||
return null; | ||
} | ||
function encodeHeaders() { | ||
var headers = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | ||
var shouldEncode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; | ||
var encodedHeaders = {}; | ||
if (shouldEncode) { | ||
Object.keys(headers).forEach(function(header) { | ||
encodedHeaders[header] = encodeURI(headers[header]); | ||
}); | ||
} else { | ||
encodedHeaders = headers; | ||
} | ||
return encodedHeaders; | ||
} | ||
function getTelemetryHeaders(enableTelemetry) { | ||
var headers = {}; | ||
Object.assign(headers, { | ||
"X-Search-Client": "Appbase JS" | ||
}); | ||
if (enableTelemetry === false) { | ||
Object.assign(headers, { | ||
"X-Enable-Telemetry": enableTelemetry | ||
}); | ||
} | ||
return headers; | ||
} | ||
function AppBase(config) { | ||
var _URL = (0, import_url_parser_lite.default)(config.url || ""), _URL$auth = _URL.auth, auth = _URL$auth === void 0 ? null : _URL$auth, _URL$host = _URL.host, host = _URL$host === void 0 ? "" : _URL$host, _URL$path = _URL.path, path = _URL$path === void 0 ? "" : _URL$path, _URL$protocol = _URL.protocol, protocol = _URL$protocol === void 0 ? "" : _URL$protocol; | ||
var url = host + path; | ||
if (typeof url !== "string" || url === "") { | ||
throw new Error("URL not present in options."); | ||
} | ||
if (typeof config.app !== "string" || config.app === "") { | ||
throw new Error("App name is not present in options."); | ||
} | ||
if (typeof protocol !== "string" || protocol === "") { | ||
throw new Error("Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io"); | ||
} | ||
if (url.slice(-1) === "/") { | ||
url = url.slice(0, -1); | ||
} | ||
var credentials = auth || null; | ||
if (typeof config.credentials === "string" && config.credentials !== "") { | ||
credentials = config.credentials; | ||
} else if (typeof config.username === "string" && config.username !== "" && typeof config.password === "string" && config.password !== "") { | ||
credentials = config.username + ":" + config.password; | ||
} | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error("Authentication information is not present. Did you add credentials?"); | ||
} | ||
this.url = url; | ||
this.protocol = protocol; | ||
this.app = config.app; | ||
this.credentials = credentials; | ||
if (typeof config.enableTelemetry === "boolean") { | ||
this.enableTelemetry = config.enableTelemetry; | ||
} | ||
} | ||
function fetchRequest(args) { | ||
var _this = this; | ||
return new Promise(function(resolve, reject) { | ||
var parsedArgs = removeUndefined(args); | ||
try { | ||
var method = parsedArgs.method, path = parsedArgs.path, params = parsedArgs.params, body = parsedArgs.body, isRSAPI = parsedArgs.isRSAPI, isSuggestionsAPI = parsedArgs.isSuggestionsAPI; | ||
var app = isSuggestionsAPI ? ".suggestions" : _this.app; | ||
var bodyCopy = body; | ||
var contentType = path.endsWith("msearch") || path.endsWith("bulk") ? "application/x-ndjson" : "application/json"; | ||
var headers = Object.assign({}, { | ||
Accept: "application/json", | ||
"Content-Type": contentType | ||
}, _this.headers, args.headers); | ||
var timestamp = Date.now(); | ||
if (_this.credentials) { | ||
headers.Authorization = "Basic " + btoa(_this.credentials); | ||
} | ||
var requestOptions = { | ||
method, | ||
headers | ||
}; | ||
if (Array.isArray(bodyCopy)) { | ||
var arrayBody = ""; | ||
bodyCopy.forEach(function(item) { | ||
arrayBody += JSON.stringify(item); | ||
arrayBody += "\n"; | ||
}); | ||
bodyCopy = arrayBody; | ||
} else { | ||
bodyCopy = JSON.stringify(bodyCopy) || {}; | ||
} | ||
if (Object.keys(bodyCopy).length !== 0) { | ||
requestOptions.body = bodyCopy; | ||
} | ||
var handleTransformRequest = function handleTransformRequest2(res) { | ||
if (_this.transformRequest && typeof _this.transformRequest === "function") { | ||
var tarnsformRequestPromise = _this.transformRequest(res); | ||
return tarnsformRequestPromise instanceof Promise ? tarnsformRequestPromise : Promise.resolve(tarnsformRequestPromise); | ||
} | ||
return Promise.resolve(res); | ||
}; | ||
var responseHeaders = {}; | ||
var paramsString = ""; | ||
if (params) { | ||
paramsString = "?" + import_querystring.default.stringify(params); | ||
} | ||
var finalURL = _this.protocol + "://" + _this.url + "/" + app + "/" + path + paramsString; | ||
return handleTransformRequest(Object.assign({}, { | ||
url: finalURL | ||
}, requestOptions)).then(function(ts) { | ||
var transformedRequest = Object.assign({}, ts); | ||
var url = transformedRequest.url; | ||
delete transformedRequest.url; | ||
return (0, import_cross_fetch.default)(url || finalURL, transformedRequest).then(function(res) { | ||
if (res.status >= 500) { | ||
return reject(res); | ||
} | ||
responseHeaders = res.headers; | ||
return res.json().then(function(data) { | ||
if (res.status >= 400) { | ||
return reject(res); | ||
} | ||
if (data && data.error) { | ||
return reject(data); | ||
} | ||
if (isRSAPI && data && Object.prototype.toString.call(data) === "[object Object]") { | ||
if (body && body.query && body.query instanceof Array) { | ||
var errorResponses = 0; | ||
var allResponses = body.query.filter(function(q) { | ||
return q.execute || q.execute === void 0; | ||
}).length; | ||
if (data) { | ||
Object.keys(data).forEach(function(key) { | ||
if (data[key] && Object.prototype.hasOwnProperty.call(data[key], "error")) { | ||
errorResponses += 1; | ||
} | ||
}); | ||
} | ||
if (errorResponses > 0 && allResponses === errorResponses) { | ||
return reject(data); | ||
} | ||
} | ||
} | ||
if (data && data.responses instanceof Array) { | ||
var _allResponses = data.responses.length; | ||
var _errorResponses = data.responses.filter(function(entry) { | ||
return Object.prototype.hasOwnProperty.call(entry, "error"); | ||
}).length; | ||
if (_allResponses === _errorResponses) { | ||
return reject(data); | ||
} | ||
} | ||
var response = Object.assign({}, data, { | ||
_timestamp: timestamp, | ||
_headers: responseHeaders | ||
}); | ||
return resolve(response); | ||
}).catch(function(e) { | ||
return reject(e); | ||
}); | ||
}).catch(function(e) { | ||
return reject(e); | ||
}); | ||
}).catch(function(err) { | ||
return reject(err); | ||
}); | ||
} catch (e) { | ||
return reject(e); | ||
} | ||
}); | ||
} | ||
function indexApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
body: "object" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var _parsedArgs$type = parsedArgs.type, type = _parsedArgs$type === void 0 ? "_doc" : _parsedArgs$type, id = parsedArgs.id, body = parsedArgs.body; | ||
delete parsedArgs.type; | ||
delete parsedArgs.body; | ||
delete parsedArgs.id; | ||
var path = void 0; | ||
if (id) { | ||
path = type ? type + "/" + encodeURIComponent(id) : encodeURIComponent(id); | ||
} else { | ||
path = type; | ||
} | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path, | ||
params: parsedArgs, | ||
body | ||
}); | ||
} | ||
function getApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
id: "string|number" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var _parsedArgs$type = parsedArgs.type, type = _parsedArgs$type === void 0 ? "_doc" : _parsedArgs$type, id = parsedArgs.id; | ||
delete parsedArgs.type; | ||
delete parsedArgs.id; | ||
var path = type + "/" + encodeURIComponent(id); | ||
return this.performFetchRequest({ | ||
method: "GET", | ||
path, | ||
params: parsedArgs | ||
}); | ||
} | ||
function updateApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
id: "string|number", | ||
body: "object" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var _parsedArgs$type = parsedArgs.type, type = _parsedArgs$type === void 0 ? "_doc" : _parsedArgs$type, id = parsedArgs.id, body = parsedArgs.body; | ||
delete parsedArgs.type; | ||
delete parsedArgs.id; | ||
delete parsedArgs.body; | ||
var path = type + "/" + encodeURIComponent(id) + "/_update"; | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path, | ||
params: parsedArgs, | ||
body | ||
}); | ||
} | ||
function deleteApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
id: "string|number" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var _parsedArgs$type = parsedArgs.type, type = _parsedArgs$type === void 0 ? "_doc" : _parsedArgs$type, id = parsedArgs.id; | ||
delete parsedArgs.type; | ||
delete parsedArgs.id; | ||
var path = type + "/" + encodeURIComponent(id); | ||
return this.performFetchRequest({ | ||
method: "DELETE", | ||
path, | ||
params: parsedArgs | ||
}); | ||
} | ||
function bulkApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
body: "object" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var type = parsedArgs.type, body = parsedArgs.body; | ||
delete parsedArgs.type; | ||
delete parsedArgs.body; | ||
var path = void 0; | ||
if (type) { | ||
path = type + "/_bulk"; | ||
} else { | ||
path = "_bulk"; | ||
} | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path, | ||
params: parsedArgs, | ||
body | ||
}); | ||
} | ||
function searchApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
body: "object" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var type = void 0; | ||
if (Array.isArray(parsedArgs.type)) { | ||
type = parsedArgs.type.join(); | ||
} else { | ||
type = parsedArgs.type; | ||
} | ||
var body = parsedArgs.body; | ||
delete parsedArgs.type; | ||
delete parsedArgs.body; | ||
var path = void 0; | ||
if (type) { | ||
path = type + "/_search"; | ||
} else { | ||
path = "_search"; | ||
} | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path, | ||
params: parsedArgs, | ||
body | ||
}); | ||
} | ||
function msearchApi(args) { | ||
var parsedArgs = removeUndefined(args); | ||
var valid = validate(parsedArgs, { | ||
body: "object" | ||
}); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var type = void 0; | ||
if (Array.isArray(parsedArgs.type)) { | ||
type = parsedArgs.type.join(); | ||
} else { | ||
type = parsedArgs.type; | ||
} | ||
var body = parsedArgs.body; | ||
delete parsedArgs.type; | ||
delete parsedArgs.body; | ||
var path = void 0; | ||
if (type) { | ||
path = type + "/_msearch"; | ||
} else { | ||
path = "_msearch"; | ||
} | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path, | ||
params: parsedArgs, | ||
body | ||
}); | ||
} | ||
function reactiveSearchApi(query, settings) { | ||
var parsedSettings = removeUndefined(settings); | ||
var valid = validateRSQuery(query); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var body = { | ||
settings: parsedSettings, | ||
query | ||
}; | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path: "_reactivesearch", | ||
body, | ||
headers: getTelemetryHeaders(this.enableTelemetry), | ||
isRSAPI: true | ||
}); | ||
} | ||
function reactiveSearchv3Api(query, settings) { | ||
var parsedSettings = removeUndefined(settings); | ||
var valid = validateRSQuery(query); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var body = { | ||
settings: parsedSettings, | ||
query | ||
}; | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path: "_reactivesearch.v3", | ||
body, | ||
headers: getTelemetryHeaders(this.enableTelemetry), | ||
isRSAPI: true | ||
}); | ||
} | ||
function getMappings() { | ||
return this.performFetchRequest({ | ||
method: "GET", | ||
path: "_mapping" | ||
}); | ||
} | ||
function getSuggestionsv3Api(query, settings) { | ||
var parsedSettings = removeUndefined(settings); | ||
var valid = validateRSQuery(query); | ||
if (valid !== true) { | ||
throw valid; | ||
} | ||
var body = { | ||
settings: parsedSettings, | ||
query | ||
}; | ||
return this.performFetchRequest({ | ||
method: "POST", | ||
path: "_reactivesearch.v3", | ||
body, | ||
headers: getTelemetryHeaders(this.enableTelemetry), | ||
isRSAPI: true, | ||
isSuggestionsAPI: true | ||
}); | ||
} | ||
function appbasejs(config) { | ||
var client = new AppBase(config); | ||
AppBase.prototype.performFetchRequest = fetchRequest; | ||
AppBase.prototype.index = indexApi; | ||
AppBase.prototype.get = getApi; | ||
AppBase.prototype.update = updateApi; | ||
AppBase.prototype.delete = deleteApi; | ||
AppBase.prototype.bulk = bulkApi; | ||
AppBase.prototype.search = searchApi; | ||
AppBase.prototype.msearch = msearchApi; | ||
AppBase.prototype.reactiveSearch = reactiveSearchApi; | ||
AppBase.prototype.reactiveSearchv3 = reactiveSearchv3Api; | ||
AppBase.prototype.getQuerySuggestions = getSuggestionsv3Api; | ||
AppBase.prototype.getMappings = getMappings; | ||
AppBase.prototype.setHeaders = function setHeaders() { | ||
var headers = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; | ||
var shouldEncode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; | ||
if (shouldEncode) { | ||
this.headers = encodeHeaders(headers); | ||
} else { | ||
this.headers = headers; | ||
} | ||
}; | ||
if (typeof window !== "undefined") { | ||
window.Appbase = client; | ||
} | ||
return client; | ||
} | ||
var appbase_js_es_default = appbasejs; | ||
// src/utils/constants.js | ||
var QUERY_ID = "suggestions"; | ||
var ACCEPTABLE_APPBASE_CLIENT_KEYS = [ | ||
"url", | ||
"index", | ||
"app", | ||
"username", | ||
"password", | ||
"credentials", | ||
"enableTelemetry" | ||
]; | ||
// src/utils/helper.js | ||
var RecentSearchIcon = (createElement) => { | ||
return /* @__PURE__ */ createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
alt: "Recent Search", | ||
height: "20", | ||
width: "20", | ||
viewBox: "0 0 24 24", | ||
style: { fill: "#707070" } | ||
}, /* @__PURE__ */ createElement("path", { | ||
d: "M0 0h24v24H0z", | ||
fill: "none" | ||
}), /* @__PURE__ */ createElement("path", { | ||
d: "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z" | ||
})); | ||
}; | ||
var PopularSeachIcon = (createElement) => { | ||
return /* @__PURE__ */ createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
alt: "Popular Search", | ||
height: "20", | ||
width: "20", | ||
viewBox: "0 0 24 24", | ||
style: { fill: "#707070" } | ||
}, /* @__PURE__ */ createElement("path", { | ||
d: "M0 0h24v24H0z", | ||
fill: "none" | ||
}), /* @__PURE__ */ createElement("path", { | ||
d: "M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z" | ||
})); | ||
}; | ||
var SearchIcon = (createElement) => { | ||
return /* @__PURE__ */ createElement("svg", { | ||
viewBox: "0 0 24 24", | ||
width: "20", | ||
height: "20", | ||
style: { fill: "#707070" } | ||
}, /* @__PURE__ */ createElement("path", { | ||
d: "M16.041 15.856c-0.034 0.026-0.067 0.055-0.099 0.087s-0.060 0.064-0.087 0.099c-1.258 1.213-2.969 1.958-4.855 1.958-1.933 0-3.682-0.782-4.95-2.050s-2.050-3.017-2.050-4.95 0.782-3.682 2.050-4.95 3.017-2.050 4.95-2.050 3.682 0.782 4.95 2.050 2.050 3.017 2.050 4.95c0 1.886-0.745 3.597-1.959 4.856zM21.707 20.293l-3.675-3.675c1.231-1.54 1.968-3.493 1.968-5.618 0-2.485-1.008-4.736-2.636-6.364s-3.879-2.636-6.364-2.636-4.736 1.008-6.364 2.636-2.636 3.879-2.636 6.364 1.008 4.736 2.636 6.364 3.879 2.636 6.364 2.636c2.125 0 4.078-0.737 5.618-1.968l3.675 3.675c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414z" | ||
})); | ||
}; | ||
var PromotedIcon = (createElement) => { | ||
return /* @__PURE__ */ createElement("svg", { | ||
xmlns: "http://www.w3.org/2000/svg", | ||
width: "20", | ||
height: "20", | ||
viewBox: "0 0 24 24", | ||
style: { fill: "#707070" } | ||
}, /* @__PURE__ */ createElement("path", { | ||
d: "M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z" | ||
})); | ||
}; | ||
var getIcon = (type) => { | ||
switch (type) { | ||
case "index": | ||
return SearchIcon; | ||
case "recent": | ||
return RecentSearchIcon; | ||
case "popular": | ||
return PopularSeachIcon; | ||
case "promoted": | ||
return PromotedIcon; | ||
default: | ||
return () => { | ||
}; | ||
} | ||
}; | ||
var processSuggestions = (results) => { | ||
return results.map((item) => ({ ...item, type: item._suggestion_type })); | ||
}; | ||
var parseAppbaseClientObject = (configObject) => { | ||
const parsedConfig = {}; | ||
ACCEPTABLE_APPBASE_CLIENT_KEYS.forEach((propertyKey) => { | ||
if (configObject[propertyKey]) { | ||
Object.assign(parsedConfig, { [propertyKey]: configObject[propertyKey] }); | ||
} | ||
}); | ||
return parsedConfig; | ||
}; | ||
// src/index.js | ||
function createSuggestionsPlugin(appbaseClientConfig = {}, queryConfig = {}, renderConfig = {}) { | ||
const appbaseRef = appbase_js_es_default({ | ||
...parseAppbaseClientObject(appbaseClientConfig) | ||
}); | ||
const sourceId = `suggestions_source_${Math.random() * Math.random() * 1e3}`; | ||
return { | ||
getSources: function getSources(_ref) { | ||
var query = _ref.query, setQuery = _ref.setQuery, refresh = _ref.refresh, setContext = _ref.setContext; | ||
return [ | ||
{ | ||
sourceId, | ||
getItems() { | ||
return appbaseRef.reactiveSearchv3([ | ||
{ | ||
id: QUERY_ID, | ||
type: "suggestion", | ||
...!!query && { value: query }, | ||
...queryConfig | ||
} | ||
], { | ||
...appbaseClientConfig.settings | ||
}).then(function(res) { | ||
if (renderConfig?.useContextValue) { | ||
setContext({ | ||
total: res?.[QUERY_ID]?.hits?.total?.value, | ||
time: res?.[QUERY_ID]?.took, | ||
resultsJson: res?.[QUERY_ID]?.hits?.hits | ||
}); | ||
} | ||
return processSuggestions(res?.suggestions?.hits?.hits || []); | ||
}).catch(function(err) { | ||
console.log("suggestions search error: ", err); | ||
return []; | ||
}); | ||
}, | ||
onSelect(props) { | ||
const { item, setQuery: setQuery2, refresh: refresh2 } = props; | ||
if (typeof renderConfig?.onItemSelect === "function") { | ||
renderConfig.onItemSelect(props); | ||
return; | ||
} | ||
setQuery2(item.label); | ||
refresh2(); | ||
}, | ||
templates: { | ||
header(props) { | ||
if (typeof renderConfig?.renderHeader === "function") { | ||
return renderConfig.renderHeader(props); | ||
} | ||
return null; | ||
}, | ||
item(props) { | ||
const { item, createElement } = props; | ||
if (typeof renderConfig?.renderItem === "function") { | ||
return renderConfig.renderItem({ | ||
...props, | ||
setQuery, | ||
refresh, | ||
setContext | ||
}); | ||
} | ||
return /* @__PURE__ */ createElement("div", { | ||
className: "item" | ||
}, /* @__PURE__ */ createElement("div", { | ||
className: "item__content-wrapper" | ||
}, getIcon(item.type)(createElement), /* @__PURE__ */ createElement("span", { | ||
dangerouslySetInnerHTML: { | ||
__html: item.label | ||
} | ||
})), /* @__PURE__ */ createElement("div", { | ||
className: "item__actions-wrapper" | ||
}, " ", /* @__PURE__ */ createElement("button", { | ||
onClick: (e) => { | ||
e.stopPropagation(); | ||
setQuery(item.value); | ||
refresh(); | ||
}, | ||
type: "button", | ||
className: "set-search-arrow" | ||
}, /* @__PURE__ */ createElement("svg", { | ||
viewBox: "0 0 24 24", | ||
fill: "currentColor" | ||
}, /* @__PURE__ */ createElement("path", { | ||
d: "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z" | ||
}))))); | ||
}, | ||
footer(props) { | ||
if (typeof renderConfig?.renderFooter === "function") { | ||
return renderConfig.renderFooter(props); | ||
} | ||
return null; | ||
}, | ||
noResults(props) { | ||
const { createElement } = props; | ||
if (typeof renderConfig?.renderNoResults === "function") { | ||
return renderConfig.renderNoResults(props); | ||
} | ||
return /* @__PURE__ */ createElement("span", { | ||
style: { marginLeft: "-9px" } | ||
}, "No Results Found!"); | ||
} | ||
} | ||
} | ||
]; | ||
} | ||
}; | ||
} | ||
var src_default = createSuggestionsPlugin; | ||
export { | ||
src_default as default | ||
}; | ||
var ye=Object.create;var Q=Object.defineProperty,ve=Object.defineProperties,me=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertyNames,Y=Object.getOwnPropertySymbols,we=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var W=(t,e,n)=>e in t?Q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,I=(t,e)=>{for(var n in e||(e={}))k.call(e,n)&&W(t,n,e[n]);if(Y)for(var n of Y(e))Ae.call(e,n)&&W(t,n,e[n]);return t},V=(t,e)=>ve(t,be(e)),_e=t=>Q(t,"__esModule",{value:!0});var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Re=(t,e,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ge(e))!k.call(t,s)&&s!=="default"&&Q(t,s,{get:()=>e[s],enumerable:!(n=me(e,s))||n.enumerable});return t},G=t=>Re(_e(Q(t!=null?ye(we(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var C=L((ke,Z)=>{function Se(t){var e=RegExp("^(([^:/?#]*)?://)?(((.*)?@)?([^/?#]*)?)([^?#]*)(\\?([^#]*))?(#(.*))?"),n=t.match(e);return{protocol:n[2],auth:n[5],host:n[6],path:n[7],query:n[9],hash:n[11]}}Z.exports=Se});var te=L((We,ee)=>{"use strict";function xe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}ee.exports=function(t,e,n,s){e=e||"&",n=n||"=";var i={};if(typeof t!="string"||t.length===0)return i;var h=/\+/g;t=t.split(e);var u=1e3;s&&typeof s.maxKeys=="number"&&(u=s.maxKeys);var f=t.length;u>0&&f>u&&(f=u);for(var m=0;m<f;++m){var c=t[m].replace(h,"%20"),v=c.indexOf(n),p,y,d,g;v>=0?(p=c.substr(0,v),y=c.substr(v+1)):(p=c,y=""),d=decodeURIComponent(p),g=decodeURIComponent(y),xe(i,d)?Array.isArray(i[d])?i[d].push(g):i[d]=[i[d],g]:i[d]=g}return i}});var ne=L((Ze,re)=>{"use strict";var q=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};re.exports=function(t,e,n,s){return e=e||"&",n=n||"=",t===null&&(t=void 0),typeof t=="object"?Object.keys(t).map(function(i){var h=encodeURIComponent(q(i))+n;return Array.isArray(t[i])?t[i].map(function(u){return h+encodeURIComponent(q(u))}).join(e):h+encodeURIComponent(q(t[i]))}).filter(Boolean).join(e):s?encodeURIComponent(q(s))+n+encodeURIComponent(q(t)):""}});var oe=L(H=>{"use strict";H.decode=H.parse=te();H.encode=H.stringify=ne()});var ie=L((se,M)=>{var D=function(t){function e(){this.fetch=!1}return e.prototype=t,new e}(typeof self!="undefined"?self:se);(function(t){(function(e){if(e.fetch)return;var n={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(r){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(n.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=function(r){return r&&DataView.prototype.isPrototypeOf(r)},h=ArrayBuffer.isView||function(r){return r&&s.indexOf(Object.prototype.toString.call(r))>-1};function u(r){if(typeof r!="string"&&(r=String(r)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(r))throw new TypeError("Invalid character in header field name");return r.toLowerCase()}function f(r){return typeof r!="string"&&(r=String(r)),r}function m(r){var o={next:function(){var a=r.shift();return{done:a===void 0,value:a}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function c(r){this.map={},r instanceof c?r.forEach(function(o,a){this.append(a,o)},this):Array.isArray(r)?r.forEach(function(o){this.append(o[0],o[1])},this):r&&Object.getOwnPropertyNames(r).forEach(function(o){this.append(o,r[o])},this)}c.prototype.append=function(r,o){r=u(r),o=f(o);var a=this.map[r];this.map[r]=a?a+","+o:o},c.prototype.delete=function(r){delete this.map[u(r)]},c.prototype.get=function(r){return r=u(r),this.has(r)?this.map[r]:null},c.prototype.has=function(r){return this.map.hasOwnProperty(u(r))},c.prototype.set=function(r,o){this.map[u(r)]=f(o)},c.prototype.forEach=function(r,o){for(var a in this.map)this.map.hasOwnProperty(a)&&r.call(o,this.map[a],a,this)},c.prototype.keys=function(){var r=[];return this.forEach(function(o,a){r.push(a)}),m(r)},c.prototype.values=function(){var r=[];return this.forEach(function(o){r.push(o)}),m(r)},c.prototype.entries=function(){var r=[];return this.forEach(function(o,a){r.push([a,o])}),m(r)},n.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);function v(r){if(r.bodyUsed)return Promise.reject(new TypeError("Already read"));r.bodyUsed=!0}function p(r){return new Promise(function(o,a){r.onload=function(){o(r.result)},r.onerror=function(){a(r.error)}})}function y(r){var o=new FileReader,a=p(o);return o.readAsArrayBuffer(r),a}function d(r){var o=new FileReader,a=p(o);return o.readAsText(r),a}function g(r){for(var o=new Uint8Array(r),a=new Array(o.length),w=0;w<o.length;w++)a[w]=String.fromCharCode(o[w]);return a.join("")}function B(r){if(r.slice)return r.slice(0);var o=new Uint8Array(r.byteLength);return o.set(new Uint8Array(r)),o.buffer}function T(){return this.bodyUsed=!1,this._initBody=function(r){if(this._bodyInit=r,!r)this._bodyText="";else if(typeof r=="string")this._bodyText=r;else if(n.blob&&Blob.prototype.isPrototypeOf(r))this._bodyBlob=r;else if(n.formData&&FormData.prototype.isPrototypeOf(r))this._bodyFormData=r;else if(n.searchParams&&URLSearchParams.prototype.isPrototypeOf(r))this._bodyText=r.toString();else if(n.arrayBuffer&&n.blob&&i(r))this._bodyArrayBuffer=B(r.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else if(n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(r)||h(r)))this._bodyArrayBuffer=B(r);else throw new Error("unsupported BodyInit type");this.headers.get("content-type")||(typeof r=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n.blob&&(this.blob=function(){var r=v(this);if(r)return r;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?v(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var r=v(this);if(r)return r;if(this._bodyBlob)return d(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(g(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then($)}),this.json=function(){return this.text().then(JSON.parse)},this}var P=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(r){var o=r.toUpperCase();return P.indexOf(o)>-1?o:r}function R(r,o){o=o||{};var a=o.body;if(r instanceof R){if(r.bodyUsed)throw new TypeError("Already read");this.url=r.url,this.credentials=r.credentials,o.headers||(this.headers=new c(r.headers)),this.method=r.method,this.mode=r.mode,!a&&r._bodyInit!=null&&(a=r._bodyInit,r.bodyUsed=!0)}else this.url=String(r);if(this.credentials=o.credentials||this.credentials||"omit",(o.headers||!this.headers)&&(this.headers=new c(o.headers)),this.method=j(o.method||this.method||"GET"),this.mode=o.mode||this.mode||null,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&a)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(a)}R.prototype.clone=function(){return new R(this,{body:this._bodyInit})};function $(r){var o=new FormData;return r.trim().split("&").forEach(function(a){if(a){var w=a.split("="),A=w.shift().replace(/\+/g," "),l=w.join("=").replace(/\+/g," ");o.append(decodeURIComponent(A),decodeURIComponent(l))}}),o}function J(r){var o=new c,a=r.replace(/\r?\n[\t ]+/g," ");return a.split(/\r?\n/).forEach(function(w){var A=w.split(":"),l=A.shift().trim();if(l){var x=A.join(":").trim();o.append(l,x)}}),o}T.call(R.prototype);function b(r,o){o||(o={}),this.type="default",this.status=o.status===void 0?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in o?o.statusText:"OK",this.headers=new c(o.headers),this.url=o.url||"",this._initBody(r)}T.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 r=new b(null,{status:0,statusText:""});return r.type="error",r};var O=[301,302,303,307,308];b.redirect=function(r,o){if(O.indexOf(o)===-1)throw new RangeError("Invalid status code");return new b(null,{status:o,headers:{location:r}})},e.Headers=c,e.Request=R,e.Response=b,e.fetch=function(r,o){return new Promise(function(a,w){var A=new R(r,o),l=new XMLHttpRequest;l.onload=function(){var x={status:l.status,statusText:l.statusText,headers:J(l.getAllResponseHeaders()||"")};x.url="responseURL"in l?l.responseURL:x.headers.get("X-Request-URL");var F="response"in l?l.response:l.responseText;a(new b(F,x))},l.onerror=function(){w(new TypeError("Network request failed"))},l.ontimeout=function(){w(new TypeError("Network request failed"))},l.open(A.method,A.url,!0),A.credentials==="include"?l.withCredentials=!0:A.credentials==="omit"&&(l.withCredentials=!1),"responseType"in l&&n.blob&&(l.responseType="blob"),A.headers.forEach(function(x,F){l.setRequestHeader(F,x)}),l.send(typeof A._bodyInit=="undefined"?null:A._bodyInit)})},e.fetch.polyfill=!0})(typeof t!="undefined"?t:this)}).call(D,void 0);var N=D.fetch,et=N.Response=D.Response,tt=N.Request=D.Request,rt=N.Headers=D.Headers;typeof M=="object"&&M.exports&&(M.exports=N,M.exports.default=N)});var ae=G(C()),ue=G(oe()),pe=G(ie()),Te=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function Pe(t,e){return t.indexOf(e)!==-1}function Oe(t){return Pe(t,"scalr.api.appbase.io")}function Ie(){for(var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=t,s="",i=0,h,u=0,f=e;n.charAt(u|0)||(f="=",u%1);s+=f.charAt(63&i>>8-u%1*8)){if(h=n.charCodeAt(u+=3/4),h>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');i=i<<8|h}return s}function K(t){if(t&&Object.prototype.toString.call(t)==="[object Array]"){for(var e=0;e<t.length;e+=1){var n=t[e];if(n){if(!n.id)return new Error("'id' field must be present in query object")}else return new Error("query object can not have an empty value")}return!0}return new Error("invalid query value, 'query' value must be an array")}function E(t,e){var n=[],s={object:null,string:"",number:0},i=Object.keys(e);i.forEach(function(f){var m=e[f].split("|"),c=m.find(function(v){return Te(t[f])===v});(!c||t[f]===s[c])&&n.push(f)});for(var h="",u=0;u<n.length;u+=1)h+=n[u]+", ";return n.length>0?new Error("fields missing: "+h):!0}function S(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return t||!(Object.keys(t).length===0&&t.constructor===Object)?JSON.parse(JSON.stringify(t)):null}function Be(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n={};return e?Object.keys(t).forEach(function(s){n[s]=encodeURI(t[s])}):n=t,n}function X(t){var e={};return Object.assign(e,{"X-Search-Client":"Appbase JS"}),t===!1&&Object.assign(e,{"X-Enable-Telemetry":t}),e}function _(t){var e=(0,ae.default)(t.url||""),n=e.auth,s=n===void 0?null:n,i=e.host,h=i===void 0?"":i,u=e.path,f=u===void 0?"":u,m=e.protocol,c=m===void 0?"":m,v=h+f;if(typeof v!="string"||v==="")throw new Error("URL not present in options.");if(typeof t.app!="string"||t.app==="")throw new Error("App name is not present in options.");if(typeof c!="string"||c==="")throw new Error("Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io");v.slice(-1)==="/"&&(v=v.slice(0,-1));var p=s||null;if(typeof t.credentials=="string"&&t.credentials!==""?p=t.credentials:typeof t.username=="string"&&t.username!==""&&typeof t.password=="string"&&t.password!==""&&(p=t.username+":"+t.password),Oe(v)&&p===null)throw new Error("Authentication information is not present. Did you add credentials?");this.url=v,this.protocol=c,this.app=t.app,this.credentials=p,typeof t.enableTelemetry=="boolean"&&(this.enableTelemetry=t.enableTelemetry)}function Ue(t){var e=this;return new Promise(function(n,s){var i=S(t);try{var h=i.method,u=i.path,f=i.params,m=i.body,c=i.isRSAPI,v=i.isSuggestionsAPI,p=v?".suggestions":e.app,y=m,d=u.endsWith("msearch")||u.endsWith("bulk")?"application/x-ndjson":"application/json",g=Object.assign({},{Accept:"application/json","Content-Type":d},e.headers,t.headers),B=Date.now();e.credentials&&(g.Authorization="Basic "+Ie(e.credentials));var T={method:h,headers:g};if(Array.isArray(y)){var P="";y.forEach(function(b){P+=JSON.stringify(b),P+=` | ||
`}),y=P}else y=JSON.stringify(y)||{};Object.keys(y).length!==0&&(T.body=y);var j=function(O){if(e.transformRequest&&typeof e.transformRequest=="function"){var r=e.transformRequest(O);return r instanceof Promise?r:Promise.resolve(r)}return Promise.resolve(O)},R={},$="";f&&($="?"+ue.default.stringify(f));var J=e.protocol+"://"+e.url+"/"+p+"/"+u+$;return j(Object.assign({},{url:J},T)).then(function(b){var O=Object.assign({},b),r=O.url;return delete O.url,(0,pe.default)(r||J,O).then(function(o){return o.status>=500?s(o):(R=o.headers,o.json().then(function(a){if(o.status>=400)return s(o);if(a&&a.error)return s(a);if(c&&a&&Object.prototype.toString.call(a)==="[object Object]"&&m&&m.query&&m.query instanceof Array){var w=0,A=m.query.filter(function(U){return U.execute||U.execute===void 0}).length;if(a&&Object.keys(a).forEach(function(U){a[U]&&Object.prototype.hasOwnProperty.call(a[U],"error")&&(w+=1)}),w>0&&A===w)return s(a)}if(a&&a.responses instanceof Array){var l=a.responses.length,x=a.responses.filter(function(U){return Object.prototype.hasOwnProperty.call(U,"error")}).length;if(l===x)return s(a)}var F=Object.assign({},a,{_timestamp:B,_headers:R});return n(F)}).catch(function(a){return s(a)}))}).catch(function(o){return s(o)})}).catch(function(b){return s(b)})}catch(b){return s(b)}})}function Ee(t){var e=S(t),n=E(e,{body:"object"});if(n!==!0)throw n;var s=e.type,i=s===void 0?"_doc":s,h=e.id,u=e.body;delete e.type,delete e.body,delete e.id;var f=void 0;return h?f=i?i+"/"+encodeURIComponent(h):encodeURIComponent(h):f=i,this.performFetchRequest({method:"POST",path:f,params:e,body:u})}function je(t){var e=S(t),n=E(e,{id:"string|number"});if(n!==!0)throw n;var s=e.type,i=s===void 0?"_doc":s,h=e.id;delete e.type,delete e.id;var u=i+"/"+encodeURIComponent(h);return this.performFetchRequest({method:"GET",path:u,params:e})}function Fe(t){var e=S(t),n=E(e,{id:"string|number",body:"object"});if(n!==!0)throw n;var s=e.type,i=s===void 0?"_doc":s,h=e.id,u=e.body;delete e.type,delete e.id,delete e.body;var f=i+"/"+encodeURIComponent(h)+"/_update";return this.performFetchRequest({method:"POST",path:f,params:e,body:u})}function Le(t){var e=S(t),n=E(e,{id:"string|number"});if(n!==!0)throw n;var s=e.type,i=s===void 0?"_doc":s,h=e.id;delete e.type,delete e.id;var u=i+"/"+encodeURIComponent(h);return this.performFetchRequest({method:"DELETE",path:u,params:e})}function qe(t){var e=S(t),n=E(e,{body:"object"});if(n!==!0)throw n;var s=e.type,i=e.body;delete e.type,delete e.body;var h=void 0;return s?h=s+"/_bulk":h="_bulk",this.performFetchRequest({method:"POST",path:h,params:e,body:i})}function He(t){var e=S(t),n=E(e,{body:"object"});if(n!==!0)throw n;var s=void 0;Array.isArray(e.type)?s=e.type.join():s=e.type;var i=e.body;delete e.type,delete e.body;var h=void 0;return s?h=s+"/_search":h="_search",this.performFetchRequest({method:"POST",path:h,params:e,body:i})}function De(t){var e=S(t),n=E(e,{body:"object"});if(n!==!0)throw n;var s=void 0;Array.isArray(e.type)?s=e.type.join():s=e.type;var i=e.body;delete e.type,delete e.body;var h=void 0;return s?h=s+"/_msearch":h="_msearch",this.performFetchRequest({method:"POST",path:h,params:e,body:i})}function Ne(t,e){var n=S(e),s=K(t);if(s!==!0)throw s;var i={settings:n,query:t};return this.performFetchRequest({method:"POST",path:"_reactivesearch",body:i,headers:X(this.enableTelemetry),isRSAPI:!0})}function Me(t,e){var n=S(e),s=K(t);if(s!==!0)throw s;var i={settings:n,query:t};return this.performFetchRequest({method:"POST",path:"_reactivesearch.v3",body:i,headers:X(this.enableTelemetry),isRSAPI:!0})}function ze(){return this.performFetchRequest({method:"GET",path:"_mapping"})}function $e(t,e){var n=S(e),s=K(t);if(s!==!0)throw s;var i={settings:n,query:t};return this.performFetchRequest({method:"POST",path:"_reactivesearch.v3",body:i,headers:X(this.enableTelemetry),isRSAPI:!0,isSuggestionsAPI:!0})}function Je(t){var e=new _(t);return _.prototype.performFetchRequest=Ue,_.prototype.index=Ee,_.prototype.get=je,_.prototype.update=Fe,_.prototype.delete=Le,_.prototype.bulk=qe,_.prototype.search=He,_.prototype.msearch=De,_.prototype.reactiveSearch=Ne,_.prototype.reactiveSearchv3=Me,_.prototype.getQuerySuggestions=$e,_.prototype.getMappings=ze,_.prototype.setHeaders=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;i?this.headers=Be(s):this.headers=s},typeof window!="undefined"&&(window.Appbase=e),e}var he=Je;var z="suggestions",ce=["url","index","app","username","password","credentials","enableTelemetry"];var Qe=t=>t("svg",{xmlns:"http://www.w3.org/2000/svg",alt:"Recent Search",height:"20",width:"20",viewBox:"0 0 24 24",style:{fill:"#707070"}},t("path",{d:"M0 0h24v24H0z",fill:"none"}),t("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"})),Ve=t=>t("svg",{xmlns:"http://www.w3.org/2000/svg",alt:"Popular Search",height:"20",width:"20",viewBox:"0 0 24 24",style:{fill:"#707070"}},t("path",{d:"M0 0h24v24H0z",fill:"none"}),t("path",{d:"M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"})),Ge=t=>t("svg",{viewBox:"0 0 24 24",width:"20",height:"20",style:{fill:"#707070"}},t("path",{d:"M16.041 15.856c-0.034 0.026-0.067 0.055-0.099 0.087s-0.060 0.064-0.087 0.099c-1.258 1.213-2.969 1.958-4.855 1.958-1.933 0-3.682-0.782-4.95-2.050s-2.050-3.017-2.050-4.95 0.782-3.682 2.050-4.95 3.017-2.050 4.95-2.050 3.682 0.782 4.95 2.050 2.050 3.017 2.050 4.95c0 1.886-0.745 3.597-1.959 4.856zM21.707 20.293l-3.675-3.675c1.231-1.54 1.968-3.493 1.968-5.618 0-2.485-1.008-4.736-2.636-6.364s-3.879-2.636-6.364-2.636-4.736 1.008-6.364 2.636-2.636 3.879-2.636 6.364 1.008 4.736 2.636 6.364 3.879 2.636 6.364 2.636c2.125 0 4.078-0.737 5.618-1.968l3.675 3.675c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414z"})),Ke=t=>t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",style:{fill:"#707070"}},t("path",{d:"M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z"})),fe=t=>{switch(t){case"index":return Ge;case"recent":return Qe;case"popular":return Ve;case"promoted":return Ke;default:return()=>{}}},de=t=>t.map(e=>V(I({},e),{type:e._suggestion_type})),le=t=>{let e={};return ce.forEach(n=>{t[n]&&Object.assign(e,{[n]:t[n]})}),e};function Xe(t={},e={},n={}){let s=he(I({},le(t))),i=`suggestions_source_${Math.random()*Math.random()*1e3}`;return{getSources:function(u){var f=u.query,m=u.setQuery,c=u.refresh,v=u.setContext;return[{sourceId:i,getItems(){return s.reactiveSearchv3([I(I({id:z,type:"suggestion"},!!f&&{value:f}),e)],I({},t.settings)).then(function(p){var y,d,g,B,T,P,j,R;return(n==null?void 0:n.useContextValue)&&v({total:(g=(d=(y=p==null?void 0:p[z])==null?void 0:y.hits)==null?void 0:d.total)==null?void 0:g.value,time:(B=p==null?void 0:p[z])==null?void 0:B.took,resultsJson:(P=(T=p==null?void 0:p[z])==null?void 0:T.hits)==null?void 0:P.hits}),de(((R=(j=p==null?void 0:p.suggestions)==null?void 0:j.hits)==null?void 0:R.hits)||[])}).catch(function(p){return console.log("suggestions search error: ",p),[]})},onSelect(p){let{item:y,setQuery:d,refresh:g}=p;if(typeof(n==null?void 0:n.onItemSelect)=="function"){n.onItemSelect(p);return}d(y.label),g()},templates:{header(p){return typeof(n==null?void 0:n.renderHeader)=="function"?n.renderHeader(p):null},item(p){let{item:y,createElement:d}=p;return typeof(n==null?void 0:n.renderItem)=="function"?n.renderItem(V(I({},p),{setQuery:m,refresh:c,setContext:v})):d("div",{className:"item"},d("div",{className:"item__content-wrapper"},fe(y.type)(d),d("span",{dangerouslySetInnerHTML:{__html:y.label}})),d("div",{className:"item__actions-wrapper"}," ",d("button",{onClick:g=>{g.stopPropagation(),m(y.value),c()},type:"button",className:"set-search-arrow"},d("svg",{viewBox:"0 0 24 24",fill:"currentColor"},d("path",{d:"M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"})))))},footer(p){return typeof(n==null?void 0:n.renderFooter)=="function"?n.renderFooter(p):null},noResults(p){let{createElement:y}=p;return typeof(n==null?void 0:n.renderNoResults)=="function"?n.renderNoResults(p):y("span",{style:{marginLeft:"-9px"}},"No Results Found!")}}}]}}}var dt=Xe;export{dt as default}; |
{ | ||
"name": "@appbaseio/autocomplete-suggestions-plugin", | ||
"version": "1.0.13-alpha", | ||
"version": "1.0.14-alpha", | ||
"description": "A suggestions plugin for autocomplete-js, backed by appbase client.", | ||
@@ -9,3 +9,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"build": "./node_modules/.bin/esbuild src/index.js --bundle --loader:.js=jsx --jsx-factory= --format=esm target=esnext --outfile=lib/index.js", | ||
"build": "./node_modules/.bin/esbuild src/index.js --bundle --minify --loader:.js=jsx --jsx-factory= --format=esm --target=es6 --outfile=lib/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -12,0 +12,0 @@ }, |
58571
803