@searchcraft/javascript-sdk 0.10.5 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +16 -7
- package/dist/components/index.js +4 -4
- package/dist/components/{p-7c10ca44.js → p-062d6b80.js} +388 -365
- package/dist/components/p-062d6b80.js.map +1 -0
- package/dist/components/{p-b72015a6.js → p-274c5cc8.js} +2 -2
- package/dist/components/{p-b72015a6.js.map → p-274c5cc8.js.map} +1 -1
- package/dist/components/{p-6c471ee0.js → p-320e3895.js} +2 -2
- package/dist/components/{p-6c471ee0.js.map → p-320e3895.js.map} +1 -1
- package/dist/components/{p-bfad84c6.js → p-acab4d41.js} +8 -12
- package/dist/components/p-acab4d41.js.map +1 -0
- package/dist/components/{p-f1afb299.js → p-adc6236e.js} +80 -35
- package/dist/components/p-adc6236e.js.map +1 -0
- package/dist/components/{p-d9222264.js → p-b01f8216.js} +11 -11
- package/dist/components/p-b01f8216.js.map +1 -0
- package/dist/components/{p-f4b0ff45.js → p-b4cac872.js} +2 -2
- package/dist/components/{p-f4b0ff45.js.map → p-b4cac872.js.map} +1 -1
- package/dist/components/{p-bb700499.js → p-e99cd628.js} +104 -36
- package/dist/components/p-e99cd628.js.map +1 -0
- package/dist/components/{p-8a4cfe99.js → p-ea48ccae.js} +2 -2
- package/dist/components/{p-8a4cfe99.js.map → p-ea48ccae.js.map} +1 -1
- package/dist/components/searchcraft-ad.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +3 -3
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-pagination.js +1 -1
- package/dist/components/searchcraft-popover-button.js +1 -1
- package/dist/components/searchcraft-popover-footer.js +1 -1
- package/dist/components/searchcraft-popover-form.js +6 -6
- package/dist/components/searchcraft-popover-list-item.js +1 -1
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +1 -1
- package/dist/components/searchcraft-search-result.js +1 -1
- package/dist/components/searchcraft-search-results-per-page.js +1 -1
- package/dist/components/searchcraft-search-results.js +10 -10
- package/dist/components/searchcraft-search-results.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/hydrate/index.js +402 -296
- package/dist/hydrate/index.mjs +402 -296
- package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +22 -2
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +17 -6
- package/dist/types/components.d.ts +8 -2
- package/dist/types/store/SearchcraftStore.types.d.ts +4 -3
- package/dist/types/utils/facets.d.ts +11 -1
- package/package.json +3 -3
- package/dist/components/p-7c10ca44.js.map +0 -1
- package/dist/components/p-bb700499.js.map +0 -1
- package/dist/components/p-bfad84c6.js.map +0 -1
- package/dist/components/p-d9222264.js.map +0 -1
- package/dist/components/p-f1afb299.js.map +0 -1
package/dist/hydrate/index.js
CHANGED
|
@@ -3183,7 +3183,7 @@ Object.keys(react).forEach(function (k) {
|
|
|
3183
3183
|
var B = Object.defineProperty;
|
|
3184
3184
|
var N = (a, e, n) => e in a ? B(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3185
3185
|
var h = (a, e, n) => N(a, typeof e != "symbol" ? e + "" : e, n);
|
|
3186
|
-
var
|
|
3186
|
+
var D = /* @__PURE__ */ ((a) => (a[a.DEBUG = 0] = "DEBUG", a[a.INFO = 1] = "INFO", a[a.WARN = 2] = "WARN", a[a.ERROR = 3] = "ERROR", a))(D || {});
|
|
3187
3187
|
class pe {
|
|
3188
3188
|
constructor(e) {
|
|
3189
3189
|
h(this, "logLevel");
|
|
@@ -3191,7 +3191,7 @@ class pe {
|
|
|
3191
3191
|
this.logLevel = e.logLevel || 1, this.logFormatter = e.logFormatter || this.defaultFormatter;
|
|
3192
3192
|
}
|
|
3193
3193
|
defaultFormatter(e, n) {
|
|
3194
|
-
return `[${
|
|
3194
|
+
return `[${D[e]}] ${( new Date()).toISOString()}: ${n}`;
|
|
3195
3195
|
}
|
|
3196
3196
|
debug(e) {
|
|
3197
3197
|
this.logLevel <= 0 && console.log(this.logFormatter(0, e));
|
|
@@ -3222,149 +3222,149 @@ class pe {
|
|
|
3222
3222
|
}
|
|
3223
3223
|
}
|
|
3224
3224
|
}
|
|
3225
|
-
function
|
|
3226
|
-
return new (n || (n = Promise))(function(
|
|
3227
|
-
function t(
|
|
3225
|
+
function w(a, e, n, r) {
|
|
3226
|
+
return new (n || (n = Promise))(function(o, i) {
|
|
3227
|
+
function t(s) {
|
|
3228
3228
|
try {
|
|
3229
|
-
|
|
3230
|
-
} catch (
|
|
3231
|
-
|
|
3229
|
+
l(r.next(s));
|
|
3230
|
+
} catch (c) {
|
|
3231
|
+
i(c);
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
|
-
function u(
|
|
3234
|
+
function u(s) {
|
|
3235
3235
|
try {
|
|
3236
|
-
|
|
3237
|
-
} catch (
|
|
3238
|
-
|
|
3236
|
+
l(r.throw(s));
|
|
3237
|
+
} catch (c) {
|
|
3238
|
+
i(c);
|
|
3239
3239
|
}
|
|
3240
3240
|
}
|
|
3241
|
-
function
|
|
3242
|
-
var
|
|
3243
|
-
|
|
3244
|
-
|
|
3241
|
+
function l(s) {
|
|
3242
|
+
var c;
|
|
3243
|
+
s.done ? o(s.value) : (c = s.value, c instanceof n ? c : new n(function(g) {
|
|
3244
|
+
g(c);
|
|
3245
3245
|
})).then(t, u);
|
|
3246
3246
|
}
|
|
3247
|
-
|
|
3247
|
+
l((r = r.apply(a, [])).next());
|
|
3248
3248
|
});
|
|
3249
3249
|
}
|
|
3250
|
-
function
|
|
3251
|
-
var n, r,
|
|
3252
|
-
if (1 &
|
|
3253
|
-
return
|
|
3250
|
+
function y(a, e) {
|
|
3251
|
+
var n, r, o, i, t = { label: 0, sent: function() {
|
|
3252
|
+
if (1 & o[0]) throw o[1];
|
|
3253
|
+
return o[1];
|
|
3254
3254
|
}, trys: [], ops: [] };
|
|
3255
|
-
return
|
|
3255
|
+
return i = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
|
|
3256
3256
|
return this;
|
|
3257
|
-
}),
|
|
3258
|
-
function u(
|
|
3259
|
-
return function(
|
|
3260
|
-
return function(
|
|
3257
|
+
}), i;
|
|
3258
|
+
function u(l) {
|
|
3259
|
+
return function(s) {
|
|
3260
|
+
return function(c) {
|
|
3261
3261
|
if (n) throw new TypeError("Generator is already executing.");
|
|
3262
|
-
for (;
|
|
3263
|
-
if (n = 1, r && (
|
|
3264
|
-
switch (r = 0,
|
|
3262
|
+
for (; i && (i = 0, c[0] && (t = 0)), t; ) try {
|
|
3263
|
+
if (n = 1, r && (o = 2 & c[0] ? r.return : c[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, c[1])).done) return o;
|
|
3264
|
+
switch (r = 0, o && (c = [2 & c[0], o.value]), c[0]) {
|
|
3265
3265
|
case 0:
|
|
3266
3266
|
case 1:
|
|
3267
|
-
|
|
3267
|
+
o = c;
|
|
3268
3268
|
break;
|
|
3269
3269
|
case 4:
|
|
3270
|
-
return t.label++, { value:
|
|
3270
|
+
return t.label++, { value: c[1], done: !1 };
|
|
3271
3271
|
case 5:
|
|
3272
|
-
t.label++, r =
|
|
3272
|
+
t.label++, r = c[1], c = [0];
|
|
3273
3273
|
continue;
|
|
3274
3274
|
case 7:
|
|
3275
|
-
|
|
3275
|
+
c = t.ops.pop(), t.trys.pop();
|
|
3276
3276
|
continue;
|
|
3277
3277
|
default:
|
|
3278
|
-
if (
|
|
3278
|
+
if (o = t.trys, !((o = o.length > 0 && o[o.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
|
|
3279
3279
|
t = 0;
|
|
3280
3280
|
continue;
|
|
3281
3281
|
}
|
|
3282
|
-
if (
|
|
3283
|
-
t.label =
|
|
3282
|
+
if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
|
|
3283
|
+
t.label = c[1];
|
|
3284
3284
|
break;
|
|
3285
3285
|
}
|
|
3286
|
-
if (
|
|
3287
|
-
t.label =
|
|
3286
|
+
if (c[0] === 6 && t.label < o[1]) {
|
|
3287
|
+
t.label = o[1], o = c;
|
|
3288
3288
|
break;
|
|
3289
3289
|
}
|
|
3290
|
-
if (
|
|
3291
|
-
t.label =
|
|
3290
|
+
if (o && t.label < o[2]) {
|
|
3291
|
+
t.label = o[2], t.ops.push(c);
|
|
3292
3292
|
break;
|
|
3293
3293
|
}
|
|
3294
|
-
|
|
3294
|
+
o[2] && t.ops.pop(), t.trys.pop();
|
|
3295
3295
|
continue;
|
|
3296
3296
|
}
|
|
3297
|
-
|
|
3298
|
-
} catch (
|
|
3299
|
-
|
|
3297
|
+
c = e.call(a, t);
|
|
3298
|
+
} catch (g) {
|
|
3299
|
+
c = [6, g], r = 0;
|
|
3300
3300
|
} finally {
|
|
3301
|
-
n =
|
|
3301
|
+
n = o = 0;
|
|
3302
3302
|
}
|
|
3303
|
-
if (5 &
|
|
3304
|
-
return { value:
|
|
3305
|
-
}([
|
|
3303
|
+
if (5 & c[0]) throw c[1];
|
|
3304
|
+
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
3305
|
+
}([l, s]);
|
|
3306
3306
|
};
|
|
3307
3307
|
}
|
|
3308
3308
|
}
|
|
3309
|
-
var S = { exclude: [] },
|
|
3310
|
-
typeof window < "u" && (
|
|
3309
|
+
var S = { exclude: [] }, U = {}, v = function(a, e) {
|
|
3310
|
+
typeof window < "u" && (U[a] = e);
|
|
3311
3311
|
};
|
|
3312
|
-
function
|
|
3312
|
+
function I(a) {
|
|
3313
3313
|
return a ^= a >>> 16, a = Math.imul(a, 2246822507), a ^= a >>> 13, a = Math.imul(a, 3266489909), (a ^= a >>> 16) >>> 0;
|
|
3314
3314
|
}
|
|
3315
3315
|
var m = new Uint32Array([597399067, 2869860233, 951274213, 2716044179]);
|
|
3316
|
-
function
|
|
3316
|
+
function p(a, e) {
|
|
3317
3317
|
return a << e | a >>> 32 - e;
|
|
3318
3318
|
}
|
|
3319
|
-
function
|
|
3319
|
+
function R(a, e) {
|
|
3320
3320
|
var n;
|
|
3321
3321
|
if (e === void 0 && (e = 0), e = e ? 0 | e : 0, typeof a == "string" && (n = a, a = new TextEncoder().encode(n).buffer), !(a instanceof ArrayBuffer)) throw new TypeError("Expected key to be ArrayBuffer or string");
|
|
3322
3322
|
var r = new Uint32Array([e, e, e, e]);
|
|
3323
|
-
(((function(
|
|
3324
|
-
for (var u =
|
|
3325
|
-
var
|
|
3326
|
-
|
|
3327
|
-
}
|
|
3328
|
-
})))(a, r), function(
|
|
3329
|
-
var u =
|
|
3330
|
-
switch (
|
|
3323
|
+
(((function(i, t) {
|
|
3324
|
+
for (var u = i.byteLength / 16 | 0, l = new Uint32Array(i, 0, 4 * u), s = 0; s < u; s++) {
|
|
3325
|
+
var c = l.subarray(4 * s, 4 * (s + 1));
|
|
3326
|
+
c[0] = Math.imul(c[0], m[0]), c[0] = p(c[0], 15), c[0] = Math.imul(c[0], m[1]), t[0] = t[0] ^ c[0], t[0] = p(t[0], 19), t[0] = t[0] + t[1], t[0] = Math.imul(t[0], 5) + 1444728091, c[1] = Math.imul(c[1], m[1]), c[1] = p(c[1], 16), c[1] = Math.imul(c[1], m[2]), t[1] = t[1] ^ c[1], t[1] = p(t[1], 17), t[1] = t[1] + t[2], t[1] = Math.imul(t[1], 5) + 197830471, c[2] = Math.imul(c[2], m[2]), c[2] = p(c[2], 17), c[2] = Math.imul(c[2], m[3]), t[2] = t[2] ^ c[2], t[2] = p(t[2], 15), t[2] = t[2] + t[3], t[2] = Math.imul(t[2], 5) + 2530024501, c[3] = Math.imul(c[3], m[3]), c[3] = p(c[3], 18), c[3] = Math.imul(c[3], m[0]), t[3] = t[3] ^ c[3], t[3] = p(t[3], 13), t[3] = t[3] + t[0], t[3] = Math.imul(t[3], 5) + 850148119;
|
|
3327
|
+
}
|
|
3328
|
+
})))(a, r), function(i, t) {
|
|
3329
|
+
var u = i.byteLength / 16 | 0, l = i.byteLength % 16, s = new Uint32Array(4), c = new Uint8Array(i, 16 * u, l);
|
|
3330
|
+
switch (l) {
|
|
3331
3331
|
case 15:
|
|
3332
|
-
|
|
3332
|
+
s[3] = s[3] ^ c[14] << 16;
|
|
3333
3333
|
case 14:
|
|
3334
|
-
|
|
3334
|
+
s[3] = s[3] ^ c[13] << 8;
|
|
3335
3335
|
case 13:
|
|
3336
|
-
|
|
3336
|
+
s[3] = s[3] ^ c[12] << 0, s[3] = Math.imul(s[3], m[3]), s[3] = p(s[3], 18), s[3] = Math.imul(s[3], m[0]), t[3] = t[3] ^ s[3];
|
|
3337
3337
|
case 12:
|
|
3338
|
-
|
|
3338
|
+
s[2] = s[2] ^ c[11] << 24;
|
|
3339
3339
|
case 11:
|
|
3340
|
-
|
|
3340
|
+
s[2] = s[2] ^ c[10] << 16;
|
|
3341
3341
|
case 10:
|
|
3342
|
-
|
|
3342
|
+
s[2] = s[2] ^ c[9] << 8;
|
|
3343
3343
|
case 9:
|
|
3344
|
-
|
|
3344
|
+
s[2] = s[2] ^ c[8] << 0, s[2] = Math.imul(s[2], m[2]), s[2] = p(s[2], 17), s[2] = Math.imul(s[2], m[3]), t[2] = t[2] ^ s[2];
|
|
3345
3345
|
case 8:
|
|
3346
|
-
|
|
3346
|
+
s[1] = s[1] ^ c[7] << 24;
|
|
3347
3347
|
case 7:
|
|
3348
|
-
|
|
3348
|
+
s[1] = s[1] ^ c[6] << 16;
|
|
3349
3349
|
case 6:
|
|
3350
|
-
|
|
3350
|
+
s[1] = s[1] ^ c[5] << 8;
|
|
3351
3351
|
case 5:
|
|
3352
|
-
|
|
3352
|
+
s[1] = s[1] ^ c[4] << 0, s[1] = Math.imul(s[1], m[1]), s[1] = p(s[1], 16), s[1] = Math.imul(s[1], m[2]), t[1] = t[1] ^ s[1];
|
|
3353
3353
|
case 4:
|
|
3354
|
-
|
|
3354
|
+
s[0] = s[0] ^ c[3] << 24;
|
|
3355
3355
|
case 3:
|
|
3356
|
-
|
|
3356
|
+
s[0] = s[0] ^ c[2] << 16;
|
|
3357
3357
|
case 2:
|
|
3358
|
-
|
|
3358
|
+
s[0] = s[0] ^ c[1] << 8;
|
|
3359
3359
|
case 1:
|
|
3360
|
-
|
|
3360
|
+
s[0] = s[0] ^ c[0] << 0, s[0] = Math.imul(s[0], m[0]), s[0] = p(s[0], 15), s[0] = Math.imul(s[0], m[1]), t[0] = t[0] ^ s[0];
|
|
3361
3361
|
}
|
|
3362
|
-
}(a, r), function(
|
|
3363
|
-
t[0] = t[0] ^
|
|
3362
|
+
}(a, r), function(i, t) {
|
|
3363
|
+
t[0] = t[0] ^ i.byteLength, t[1] = t[1] ^ i.byteLength, t[2] = t[2] ^ i.byteLength, t[3] = t[3] ^ i.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] = I(t[0]), t[1] = I(t[1]), t[2] = I(t[2]), t[3] = I(t[3]), t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0;
|
|
3364
3364
|
}(a, r);
|
|
3365
|
-
var
|
|
3366
|
-
return Array.from(
|
|
3367
|
-
return
|
|
3365
|
+
var o = new Uint8Array(r.buffer);
|
|
3366
|
+
return Array.from(o).map(function(i) {
|
|
3367
|
+
return i.toString(16).padStart(2, "0");
|
|
3368
3368
|
}).join("");
|
|
3369
3369
|
}
|
|
3370
3370
|
function H(a) {
|
|
@@ -3372,9 +3372,9 @@ function H(a) {
|
|
|
3372
3372
|
return e;
|
|
3373
3373
|
}
|
|
3374
3374
|
function L(a, e, n) {
|
|
3375
|
-
for (var r = [],
|
|
3376
|
-
for (var
|
|
3377
|
-
r.push(Q(
|
|
3375
|
+
for (var r = [], o = 0; o < a[0].data.length; o++) {
|
|
3376
|
+
for (var i = [], t = 0; t < a.length; t++) i.push(a[t].data[o]);
|
|
3377
|
+
r.push(Q(i));
|
|
3378
3378
|
}
|
|
3379
3379
|
var u = new Uint8ClampedArray(r);
|
|
3380
3380
|
return new ImageData(u, e, n);
|
|
@@ -3382,73 +3382,73 @@ function L(a, e, n) {
|
|
|
3382
3382
|
function Q(a) {
|
|
3383
3383
|
if (a.length === 0) return 0;
|
|
3384
3384
|
for (var e = {}, n = 0, r = a; n < r.length; n++)
|
|
3385
|
-
e[
|
|
3386
|
-
var
|
|
3387
|
-
for (var
|
|
3388
|
-
return
|
|
3385
|
+
e[i = r[n]] = (e[i] || 0) + 1;
|
|
3386
|
+
var o = a[0];
|
|
3387
|
+
for (var i in e) e[i] > e[o] && (o = parseInt(i, 10));
|
|
3388
|
+
return o;
|
|
3389
3389
|
}
|
|
3390
|
-
function
|
|
3390
|
+
function A() {
|
|
3391
3391
|
if (typeof navigator > "u") return { name: "unknown", version: "unknown" };
|
|
3392
3392
|
for (var a = navigator.userAgent, e = { Edg: "Edge", OPR: "Opera" }, n = 0, r = [/(?<name>Edge|Edg)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>(?:Chrome|Chromium|OPR|Opera|Vivaldi|Brave))\/(?<version>\d+(?:\.\d+)?)/, /(?<name>(?:Firefox|Waterfox|Iceweasel|IceCat))\/(?<version>\d+(?:\.\d+)?)/, /(?<name>Safari)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>MSIE|Trident|IEMobile).+?(?<version>\d+(?:\.\d+)?)/, /(?<name>[A-Za-z]+)\/(?<version>\d+(?:\.\d+)?)/, /(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)?)/]; n < r.length; n++) {
|
|
3393
|
-
var
|
|
3394
|
-
if (
|
|
3393
|
+
var o = r[n], i = a.match(o);
|
|
3394
|
+
if (i && i.groups) return { name: e[i.groups.name] || i.groups.name, version: i.groups.version };
|
|
3395
3395
|
}
|
|
3396
3396
|
return { name: "unknown", version: "unknown" };
|
|
3397
3397
|
}
|
|
3398
3398
|
v("audio", function() {
|
|
3399
|
-
return
|
|
3400
|
-
return
|
|
3399
|
+
return w(this, void 0, void 0, function() {
|
|
3400
|
+
return y(this, function(a) {
|
|
3401
3401
|
return [2, new Promise(function(e, n) {
|
|
3402
3402
|
try {
|
|
3403
|
-
var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100),
|
|
3404
|
-
|
|
3403
|
+
var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100), o = r.createBufferSource(), i = r.createOscillator();
|
|
3404
|
+
i.frequency.value = 1e3;
|
|
3405
3405
|
var t, u = r.createDynamicsCompressor();
|
|
3406
|
-
u.threshold.value = -50, u.knee.value = 40, u.ratio.value = 12, u.attack.value = 0, u.release.value = 0.2,
|
|
3407
|
-
t =
|
|
3406
|
+
u.threshold.value = -50, u.knee.value = 40, u.ratio.value = 12, u.attack.value = 0, u.release.value = 0.2, i.connect(u), u.connect(r.destination), i.start(), r.oncomplete = function(l) {
|
|
3407
|
+
t = l.renderedBuffer.getChannelData(0), e({ sampleHash: H(t), oscillator: i.type, maxChannels: r.destination.maxChannelCount, channelCountMode: o.channelCountMode });
|
|
3408
3408
|
}, r.startRendering();
|
|
3409
|
-
} catch (
|
|
3410
|
-
console.error("Error creating audio fingerprint:",
|
|
3409
|
+
} catch (l) {
|
|
3410
|
+
console.error("Error creating audio fingerprint:", l), n(l);
|
|
3411
3411
|
}
|
|
3412
3412
|
})];
|
|
3413
3413
|
});
|
|
3414
3414
|
});
|
|
3415
3415
|
});
|
|
3416
|
-
var K =
|
|
3417
|
-
|
|
3416
|
+
var K = A().name !== "SamsungBrowser" ? 1 : 3, k = 280, F = 20;
|
|
3417
|
+
A().name != "Firefox" && v("canvas", function() {
|
|
3418
3418
|
return document.createElement("canvas").getContext("2d"), new Promise(function(a) {
|
|
3419
3419
|
var e = Array.from({ length: K }, function() {
|
|
3420
3420
|
return function() {
|
|
3421
3421
|
var n = document.createElement("canvas"), r = n.getContext("2d");
|
|
3422
3422
|
if (!r) return new ImageData(1, 1);
|
|
3423
|
-
n.width =
|
|
3424
|
-
var
|
|
3425
|
-
|
|
3426
|
-
var
|
|
3427
|
-
r.font = "23.123px Arial", r.fillStyle = "black", r.fillText(
|
|
3423
|
+
n.width = k, n.height = F;
|
|
3424
|
+
var o = r.createLinearGradient(0, 0, n.width, n.height);
|
|
3425
|
+
o.addColorStop(0, "red"), o.addColorStop(0.16666666666666666, "orange"), o.addColorStop(0.3333333333333333, "yellow"), o.addColorStop(0.5, "green"), o.addColorStop(0.6666666666666666, "blue"), o.addColorStop(0.8333333333333334, "indigo"), o.addColorStop(1, "violet"), r.fillStyle = o, r.fillRect(0, 0, n.width, n.height);
|
|
3426
|
+
var i = "Random Text WMwmil10Oo";
|
|
3427
|
+
r.font = "23.123px Arial", r.fillStyle = "black", r.fillText(i, -5, 15), r.fillStyle = "rgba(0, 0, 255, 0.5)", r.fillText(i, -3.3, 17.7), r.beginPath(), r.moveTo(0, 0), r.lineTo(2 * n.width / 7, n.height), r.strokeStyle = "white", r.lineWidth = 2, r.stroke();
|
|
3428
3428
|
var t = r.getImageData(0, 0, n.width, n.height);
|
|
3429
3429
|
return t;
|
|
3430
3430
|
}();
|
|
3431
3431
|
});
|
|
3432
|
-
a({ commonImageDataHash:
|
|
3432
|
+
a({ commonImageDataHash: R(L(e, k, F).data.toString()).toString() });
|
|
3433
3433
|
});
|
|
3434
3434
|
});
|
|
3435
|
-
var
|
|
3436
|
-
function
|
|
3435
|
+
var M, X = ["Arial", "Arial Black", "Arial Narrow", "Arial Rounded MT", "Arimo", "Archivo", "Barlow", "Bebas Neue", "Bitter", "Bookman", "Calibri", "Cabin", "Candara", "Century", "Century Gothic", "Comic Sans MS", "Constantia", "Courier", "Courier New", "Crimson Text", "DM Mono", "DM Sans", "DM Serif Display", "DM Serif Text", "Dosis", "Droid Sans", "Exo", "Fira Code", "Fira Sans", "Franklin Gothic Medium", "Garamond", "Geneva", "Georgia", "Gill Sans", "Helvetica", "Impact", "Inconsolata", "Indie Flower", "Inter", "Josefin Sans", "Karla", "Lato", "Lexend", "Lucida Bright", "Lucida Console", "Lucida Sans Unicode", "Manrope", "Merriweather", "Merriweather Sans", "Montserrat", "Myriad", "Noto Sans", "Nunito", "Nunito Sans", "Open Sans", "Optima", "Orbitron", "Oswald", "Pacifico", "Palatino", "Perpetua", "PT Sans", "PT Serif", "Poppins", "Prompt", "Public Sans", "Quicksand", "Rajdhani", "Recursive", "Roboto", "Roboto Condensed", "Rockwell", "Rubik", "Segoe Print", "Segoe Script", "Segoe UI", "Sora", "Source Sans Pro", "Space Mono", "Tahoma", "Taviraj", "Times", "Times New Roman", "Titillium Web", "Trebuchet MS", "Ubuntu", "Varela Round", "Verdana", "Work Sans"], J = ["monospace", "sans-serif", "serif"];
|
|
3436
|
+
function O(a, e) {
|
|
3437
3437
|
if (!a) throw new Error("Canvas context not supported");
|
|
3438
3438
|
return a.font = "72px ".concat(e), a.measureText("WwMmLli0Oo").width;
|
|
3439
3439
|
}
|
|
3440
3440
|
function Y() {
|
|
3441
3441
|
var a, e = document.createElement("canvas"), n = (a = e.getContext("webgl")) !== null && a !== void 0 ? a : e.getContext("experimental-webgl");
|
|
3442
3442
|
if (n && "getParameter" in n) try {
|
|
3443
|
-
var r = (n.getParameter(n.VENDOR) || "").toString(),
|
|
3444
|
-
if (!
|
|
3443
|
+
var r = (n.getParameter(n.VENDOR) || "").toString(), o = (n.getParameter(n.RENDERER) || "").toString(), i = { vendor: r, renderer: o, version: (n.getParameter(n.VERSION) || "").toString(), shadingLanguageVersion: (n.getParameter(n.SHADING_LANGUAGE_VERSION) || "").toString() };
|
|
3444
|
+
if (!o.length || !r.length) {
|
|
3445
3445
|
var t = n.getExtension("WEBGL_debug_renderer_info");
|
|
3446
3446
|
if (t) {
|
|
3447
|
-
var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(),
|
|
3448
|
-
u && (
|
|
3447
|
+
var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(), l = (n.getParameter(t.UNMASKED_RENDERER_WEBGL) || "").toString();
|
|
3448
|
+
u && (i.vendorUnmasked = u), l && (i.rendererUnmasked = l);
|
|
3449
3449
|
}
|
|
3450
3450
|
}
|
|
3451
|
-
return
|
|
3451
|
+
return i;
|
|
3452
3452
|
} catch {
|
|
3453
3453
|
}
|
|
3454
3454
|
return "undefined";
|
|
@@ -3460,23 +3460,23 @@ function Z() {
|
|
|
3460
3460
|
function ee(a, e) {
|
|
3461
3461
|
var n = {};
|
|
3462
3462
|
return e.forEach(function(r) {
|
|
3463
|
-
var
|
|
3464
|
-
if (
|
|
3463
|
+
var o = function(i) {
|
|
3464
|
+
if (i.length === 0) return null;
|
|
3465
3465
|
var t = {};
|
|
3466
|
-
|
|
3467
|
-
var
|
|
3468
|
-
t[
|
|
3466
|
+
i.forEach(function(s) {
|
|
3467
|
+
var c = String(s);
|
|
3468
|
+
t[c] = (t[c] || 0) + 1;
|
|
3469
3469
|
});
|
|
3470
|
-
var u =
|
|
3471
|
-
return Object.keys(t).forEach(function(
|
|
3472
|
-
t[
|
|
3470
|
+
var u = i[0], l = 1;
|
|
3471
|
+
return Object.keys(t).forEach(function(s) {
|
|
3472
|
+
t[s] > l && (u = s, l = t[s]);
|
|
3473
3473
|
}), u;
|
|
3474
|
-
}(a.map(function(
|
|
3475
|
-
return r in
|
|
3476
|
-
}).filter(function(
|
|
3477
|
-
return
|
|
3474
|
+
}(a.map(function(i) {
|
|
3475
|
+
return r in i ? i[r] : void 0;
|
|
3476
|
+
}).filter(function(i) {
|
|
3477
|
+
return i !== void 0;
|
|
3478
3478
|
}));
|
|
3479
|
-
|
|
3479
|
+
o && (n[r] = o);
|
|
3480
3480
|
}), n;
|
|
3481
3481
|
}
|
|
3482
3482
|
function te() {
|
|
@@ -3495,42 +3495,42 @@ function ne() {
|
|
|
3495
3495
|
}
|
|
3496
3496
|
return 0;
|
|
3497
3497
|
}
|
|
3498
|
-
|
|
3498
|
+
A().name != "Firefox" && v("fonts", function() {
|
|
3499
3499
|
var a = this;
|
|
3500
3500
|
return new Promise(function(e, n) {
|
|
3501
3501
|
try {
|
|
3502
3502
|
(function(r) {
|
|
3503
|
-
var
|
|
3504
|
-
|
|
3505
|
-
var
|
|
3506
|
-
return
|
|
3507
|
-
switch (
|
|
3503
|
+
var o;
|
|
3504
|
+
w(this, void 0, void 0, function() {
|
|
3505
|
+
var i, t, u;
|
|
3506
|
+
return y(this, function(l) {
|
|
3507
|
+
switch (l.label) {
|
|
3508
3508
|
case 0:
|
|
3509
|
-
return document.body ? [3, 2] : [4, (
|
|
3510
|
-
return setTimeout(
|
|
3509
|
+
return document.body ? [3, 2] : [4, (s = 50, new Promise(function(g) {
|
|
3510
|
+
return setTimeout(g, s, c);
|
|
3511
3511
|
}))];
|
|
3512
3512
|
case 1:
|
|
3513
|
-
return
|
|
3513
|
+
return l.sent(), [3, 0];
|
|
3514
3514
|
case 2:
|
|
3515
|
-
if ((
|
|
3515
|
+
if ((i = document.createElement("iframe")).setAttribute("frameBorder", "0"), (t = i.style).setProperty("position", "fixed"), t.setProperty("display", "block", "important"), t.setProperty("visibility", "visible"), t.setProperty("border", "0"), t.setProperty("opacity", "0"), i.src = "about:blank", document.body.appendChild(i), !(u = i.contentDocument || ((o = i.contentWindow) === null || o === void 0 ? void 0 : o.document))) throw new Error("Iframe document is not accessible");
|
|
3516
3516
|
return r({ iframe: u }), setTimeout(function() {
|
|
3517
|
-
document.body.removeChild(
|
|
3517
|
+
document.body.removeChild(i);
|
|
3518
3518
|
}, 0), [2];
|
|
3519
3519
|
}
|
|
3520
|
-
var
|
|
3520
|
+
var s, c;
|
|
3521
3521
|
});
|
|
3522
3522
|
});
|
|
3523
3523
|
})(function(r) {
|
|
3524
|
-
var
|
|
3525
|
-
return
|
|
3526
|
-
var
|
|
3527
|
-
return
|
|
3528
|
-
return
|
|
3529
|
-
return
|
|
3530
|
-
}),
|
|
3531
|
-
var
|
|
3532
|
-
u.includes(
|
|
3533
|
-
}), e(
|
|
3524
|
+
var o = r.iframe;
|
|
3525
|
+
return w(a, void 0, void 0, function() {
|
|
3526
|
+
var i, t, u, l;
|
|
3527
|
+
return y(this, function(s) {
|
|
3528
|
+
return i = o.createElement("canvas"), t = i.getContext("2d"), u = J.map(function(c) {
|
|
3529
|
+
return O(t, c);
|
|
3530
|
+
}), l = {}, X.forEach(function(c) {
|
|
3531
|
+
var g = O(t, c);
|
|
3532
|
+
u.includes(g) || (l[c] = g);
|
|
3533
|
+
}), e(l), [2];
|
|
3534
3534
|
});
|
|
3535
3535
|
});
|
|
3536
3536
|
});
|
|
@@ -3548,24 +3548,24 @@ C().name != "Firefox" && v("fonts", function() {
|
|
|
3548
3548
|
a({ languages: navigator.language, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
|
|
3549
3549
|
});
|
|
3550
3550
|
}), v("permissions", function() {
|
|
3551
|
-
return
|
|
3551
|
+
return w(this, void 0, void 0, function() {
|
|
3552
3552
|
var a;
|
|
3553
|
-
return
|
|
3554
|
-
return
|
|
3553
|
+
return y(this, function(e) {
|
|
3554
|
+
return M = (S == null ? void 0 : S.permissions_to_check) || ["accelerometer", "accessibility", "accessibility-events", "ambient-light-sensor", "background-fetch", "background-sync", "bluetooth", "camera", "clipboard-read", "clipboard-write", "device-info", "display-capture", "gyroscope", "geolocation", "local-fonts", "magnetometer", "microphone", "midi", "nfc", "notifications", "payment-handler", "persistent-storage", "push", "speaker", "storage-access", "top-level-storage-access", "window-management", "query"], a = Array.from({ length: (S == null ? void 0 : S.retries) || 3 }, function() {
|
|
3555
3555
|
return function() {
|
|
3556
|
-
return
|
|
3557
|
-
var n, r,
|
|
3558
|
-
return
|
|
3556
|
+
return w(this, void 0, void 0, function() {
|
|
3557
|
+
var n, r, o, i, t;
|
|
3558
|
+
return y(this, function(u) {
|
|
3559
3559
|
switch (u.label) {
|
|
3560
3560
|
case 0:
|
|
3561
|
-
n = {}, r = 0,
|
|
3561
|
+
n = {}, r = 0, o = M, u.label = 1;
|
|
3562
3562
|
case 1:
|
|
3563
|
-
if (!(r <
|
|
3564
|
-
|
|
3563
|
+
if (!(r < o.length)) return [3, 6];
|
|
3564
|
+
i = o[r], u.label = 2;
|
|
3565
3565
|
case 2:
|
|
3566
|
-
return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name:
|
|
3566
|
+
return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name: i })];
|
|
3567
3567
|
case 3:
|
|
3568
|
-
return t = u.sent(), n[
|
|
3568
|
+
return t = u.sent(), n[i] = t.state.toString(), [3, 5];
|
|
3569
3569
|
case 4:
|
|
3570
3570
|
return u.sent(), [3, 5];
|
|
3571
3571
|
case 5:
|
|
@@ -3577,7 +3577,7 @@ C().name != "Firefox" && v("fonts", function() {
|
|
|
3577
3577
|
});
|
|
3578
3578
|
}();
|
|
3579
3579
|
}), [2, Promise.all(a).then(function(n) {
|
|
3580
|
-
return ee(n,
|
|
3580
|
+
return ee(n, M);
|
|
3581
3581
|
})];
|
|
3582
3582
|
});
|
|
3583
3583
|
});
|
|
@@ -3596,22 +3596,22 @@ C().name != "Firefox" && v("fonts", function() {
|
|
|
3596
3596
|
});
|
|
3597
3597
|
}), v("system", function() {
|
|
3598
3598
|
return new Promise(function(a) {
|
|
3599
|
-
var e =
|
|
3599
|
+
var e = A();
|
|
3600
3600
|
a({ platform: window.navigator.platform, cookieEnabled: window.navigator.cookieEnabled, productSub: navigator.productSub, product: navigator.product, useragent: navigator.userAgent, hardwareConcurrency: navigator.hardwareConcurrency, browser: { name: e.name, version: e.version }, applePayVersion: ne() });
|
|
3601
3601
|
});
|
|
3602
3602
|
});
|
|
3603
|
-
var f, re =
|
|
3603
|
+
var f, re = A().name !== "SamsungBrowser" ? 1 : 3, d = null;
|
|
3604
3604
|
v("webgl", function() {
|
|
3605
|
-
return
|
|
3605
|
+
return w(this, void 0, void 0, function() {
|
|
3606
3606
|
var a;
|
|
3607
|
-
return
|
|
3608
|
-
typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100,
|
|
3607
|
+
return y(this, function(e) {
|
|
3608
|
+
typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100, d = f.getContext("webgl"));
|
|
3609
3609
|
try {
|
|
3610
|
-
if (!
|
|
3610
|
+
if (!d) throw new Error("WebGL not supported");
|
|
3611
3611
|
return a = Array.from({ length: re }, function() {
|
|
3612
3612
|
return function() {
|
|
3613
3613
|
try {
|
|
3614
|
-
if (!
|
|
3614
|
+
if (!d) throw new Error("WebGL not supported");
|
|
3615
3615
|
var n = `
|
|
3616
3616
|
attribute vec2 position;
|
|
3617
3617
|
void main() {
|
|
@@ -3622,31 +3622,31 @@ v("webgl", function() {
|
|
|
3622
3622
|
void main() {
|
|
3623
3623
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
3624
3624
|
}
|
|
3625
|
-
`,
|
|
3626
|
-
if (!
|
|
3627
|
-
if (
|
|
3628
|
-
if (
|
|
3629
|
-
var t =
|
|
3625
|
+
`, o = d.createShader(d.VERTEX_SHADER), i = d.createShader(d.FRAGMENT_SHADER);
|
|
3626
|
+
if (!o || !i) throw new Error("Failed to create shaders");
|
|
3627
|
+
if (d.shaderSource(o, n), d.shaderSource(i, r), d.compileShader(o), !d.getShaderParameter(o, d.COMPILE_STATUS)) throw new Error("Vertex shader compilation failed: " + d.getShaderInfoLog(o));
|
|
3628
|
+
if (d.compileShader(i), !d.getShaderParameter(i, d.COMPILE_STATUS)) throw new Error("Fragment shader compilation failed: " + d.getShaderInfoLog(i));
|
|
3629
|
+
var t = d.createProgram();
|
|
3630
3630
|
if (!t) throw new Error("Failed to create shader program");
|
|
3631
|
-
if (
|
|
3632
|
-
|
|
3633
|
-
for (var u = 137,
|
|
3634
|
-
var
|
|
3635
|
-
|
|
3631
|
+
if (d.attachShader(t, o), d.attachShader(t, i), d.linkProgram(t), !d.getProgramParameter(t, d.LINK_STATUS)) throw new Error("Shader program linking failed: " + d.getProgramInfoLog(t));
|
|
3632
|
+
d.useProgram(t);
|
|
3633
|
+
for (var u = 137, l = new Float32Array(4 * u), s = 2 * Math.PI / u, c = 0; c < u; c++) {
|
|
3634
|
+
var g = c * s;
|
|
3635
|
+
l[4 * c] = 0, l[4 * c + 1] = 0, l[4 * c + 2] = Math.cos(g) * (f.width / 2), l[4 * c + 3] = Math.sin(g) * (f.height / 2);
|
|
3636
3636
|
}
|
|
3637
|
-
var
|
|
3638
|
-
|
|
3639
|
-
var
|
|
3640
|
-
|
|
3641
|
-
var
|
|
3642
|
-
return
|
|
3637
|
+
var T = d.createBuffer();
|
|
3638
|
+
d.bindBuffer(d.ARRAY_BUFFER, T), d.bufferData(d.ARRAY_BUFFER, l, d.STATIC_DRAW);
|
|
3639
|
+
var E = d.getAttribLocation(t, "position");
|
|
3640
|
+
d.enableVertexAttribArray(E), d.vertexAttribPointer(E, 2, d.FLOAT, !1, 0, 0), d.viewport(0, 0, f.width, f.height), d.clearColor(0, 0, 0, 1), d.clear(d.COLOR_BUFFER_BIT), d.drawArrays(d.LINES, 0, 2 * u);
|
|
3641
|
+
var P = new Uint8ClampedArray(f.width * f.height * 4);
|
|
3642
|
+
return d.readPixels(0, 0, f.width, f.height, d.RGBA, d.UNSIGNED_BYTE, P), new ImageData(P, f.width, f.height);
|
|
3643
3643
|
} catch {
|
|
3644
3644
|
return new ImageData(1, 1);
|
|
3645
3645
|
} finally {
|
|
3646
|
-
|
|
3646
|
+
d && (d.bindBuffer(d.ARRAY_BUFFER, null), d.useProgram(null), d.viewport(0, 0, d.drawingBufferWidth, d.drawingBufferHeight), d.clearColor(0, 0, 0, 0));
|
|
3647
3647
|
}
|
|
3648
3648
|
}();
|
|
3649
|
-
}), [2, { commonImageHash:
|
|
3649
|
+
}), [2, { commonImageHash: R(L(a, f.width, f.height).data.toString()).toString() }];
|
|
3650
3650
|
} catch {
|
|
3651
3651
|
return [2, { webgl: "unsupported" }];
|
|
3652
3652
|
}
|
|
@@ -3655,13 +3655,13 @@ v("webgl", function() {
|
|
|
3655
3655
|
});
|
|
3656
3656
|
});
|
|
3657
3657
|
var b = function(a, e, n, r) {
|
|
3658
|
-
for (var
|
|
3659
|
-
|
|
3660
|
-
return
|
|
3658
|
+
for (var o = (n - e) / r, i = 0, t = 0; t < r; t++)
|
|
3659
|
+
i += a(e + (t + 0.5) * o);
|
|
3660
|
+
return i * o;
|
|
3661
3661
|
};
|
|
3662
3662
|
v("math", function() {
|
|
3663
|
-
return
|
|
3664
|
-
return
|
|
3663
|
+
return w(void 0, void 0, void 0, function() {
|
|
3664
|
+
return y(this, function(a) {
|
|
3665
3665
|
return [2, { acos: Math.acos(0.5), asin: b(Math.asin, -1, 1, 97), atan: b(Math.atan, -1, 1, 97), cos: b(Math.cos, 0, Math.PI, 97), cosh: Math.cosh(9 / 7), e: Math.E, largeCos: Math.cos(1e20), largeSin: Math.sin(1e20), largeTan: Math.tan(1e20), log: Math.log(1e3), pi: Math.PI, sin: b(Math.sin, -Math.PI, Math.PI, 97), sinh: b(Math.sinh, -9 / 7, 7 / 9, 97), sqrt: Math.sqrt(2), tan: b(Math.tan, 0, 2 * Math.PI, 97), tanh: b(Math.tanh, -9 / 7, 7 / 9, 97) }];
|
|
3666
3666
|
});
|
|
3667
3667
|
});
|
|
@@ -3681,6 +3681,7 @@ const initialSearchcraftStateValues = {
|
|
|
3681
3681
|
rangeValueForIndexFields: {},
|
|
3682
3682
|
searchTerm: '',
|
|
3683
3683
|
searchMode: 'fuzzy',
|
|
3684
|
+
searchClientRequest: undefined,
|
|
3684
3685
|
searchClientResponseItems: [],
|
|
3685
3686
|
searchResponseTimeTaken: undefined,
|
|
3686
3687
|
searchResponseFacetPrime: undefined,
|
|
@@ -3717,7 +3718,7 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3717
3718
|
},
|
|
3718
3719
|
init: (core, debug = false) => {
|
|
3719
3720
|
const logger = debug
|
|
3720
|
-
? new pe({ logLevel:
|
|
3721
|
+
? new pe({ logLevel: D.DEBUG })
|
|
3721
3722
|
: undefined;
|
|
3722
3723
|
const state = functions.set({
|
|
3723
3724
|
core,
|
|
@@ -3755,12 +3756,12 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3755
3756
|
},
|
|
3756
3757
|
search: async () => {
|
|
3757
3758
|
const state = get();
|
|
3758
|
-
state.logger?.log(
|
|
3759
|
+
state.logger?.log(D.INFO, `Starting search with search term: "${state.searchTerm}"`);
|
|
3759
3760
|
if (!state.core) {
|
|
3760
3761
|
throw new Error('Searchcraft instance is not initialized.');
|
|
3761
3762
|
}
|
|
3762
3763
|
if (!state.searchTerm.trim()) {
|
|
3763
|
-
state.logger?.log(
|
|
3764
|
+
state.logger?.log(D.INFO, 'No search request was made: search term was empty.');
|
|
3764
3765
|
functions.set({
|
|
3765
3766
|
searchClientResponseItems: [],
|
|
3766
3767
|
searchResultsCount: 0,
|
|
@@ -3784,7 +3785,7 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3784
3785
|
}, functions.setSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
|
|
3785
3786
|
},
|
|
3786
3787
|
setAdClientResponseItems: (items) => functions.set({ adClientResponseItems: items }),
|
|
3787
|
-
setSearchClientResponseItemsFromResponse: (response, items, supplementalResponse) => {
|
|
3788
|
+
setSearchClientResponseItemsFromResponse: (request, response, items, supplementalResponse) => {
|
|
3788
3789
|
const { facets, count = 0, time_taken = 0 } = response.data;
|
|
3789
3790
|
const state = functions.set((state) => {
|
|
3790
3791
|
return {
|
|
@@ -3797,12 +3798,13 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3797
3798
|
searchResultsCount: count,
|
|
3798
3799
|
searchResponseFacetPrime: facets,
|
|
3799
3800
|
supplementalFacetPrime: supplementalResponse?.data.facets,
|
|
3801
|
+
searchClientRequest: request,
|
|
3800
3802
|
};
|
|
3801
3803
|
});
|
|
3802
|
-
state.logger?.log(
|
|
3803
|
-
state.logger?.log(
|
|
3804
|
+
state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
|
|
3805
|
+
state.logger?.log(D.DEBUG, `Facets from response: ${JSON.stringify(facets)}`);
|
|
3804
3806
|
},
|
|
3805
|
-
setInitialSearchClientResponseItemsFromResponse: (response, items) => {
|
|
3807
|
+
setInitialSearchClientResponseItemsFromResponse: (request, response, items) => {
|
|
3806
3808
|
const state = get();
|
|
3807
3809
|
const { count = 0, time_taken = 0 } = response.data;
|
|
3808
3810
|
functions.set((state) => {
|
|
@@ -3814,13 +3816,14 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3814
3816
|
// Reset to first page when response count changes
|
|
3815
3817
|
count === state.searchResultsCount ? state.searchResultsPage : 1,
|
|
3816
3818
|
searchResultsCount: count,
|
|
3819
|
+
searchClientRequest: request,
|
|
3817
3820
|
};
|
|
3818
3821
|
});
|
|
3819
|
-
state.logger?.log(
|
|
3822
|
+
state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
|
|
3820
3823
|
},
|
|
3821
3824
|
setInitialQuery: async (query) => {
|
|
3822
3825
|
const state = functions.set({ initialQuery: query });
|
|
3823
|
-
state.logger?.log(
|
|
3826
|
+
state.logger?.log(D.INFO, `Starting search with query: "${state.initialQuery}"`);
|
|
3824
3827
|
if (!state.core) {
|
|
3825
3828
|
throw new Error('Searchcraft instance is not initialized.');
|
|
3826
3829
|
}
|
|
@@ -3841,12 +3844,6 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3841
3844
|
*/
|
|
3842
3845
|
functions.set({
|
|
3843
3846
|
searchTerm,
|
|
3844
|
-
facetPathsForIndexFields: {},
|
|
3845
|
-
...(searchTerm.trim().length === 0 && {
|
|
3846
|
-
searchMode: 'fuzzy',
|
|
3847
|
-
sortType: null,
|
|
3848
|
-
orderByField: null,
|
|
3849
|
-
}),
|
|
3850
3847
|
});
|
|
3851
3848
|
},
|
|
3852
3849
|
setSearchClientResponseItems: (items) => functions.set({ searchClientResponseItems: items }),
|
|
@@ -3878,7 +3875,7 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3878
3875
|
* Helper function for getting a Node (FacetWithChildrenObject)
|
|
3879
3876
|
* at a given path. Traverses the node tree to get the node.
|
|
3880
3877
|
*/
|
|
3881
|
-
const
|
|
3878
|
+
const getFacetTreeNodeAtPath = (tree, nodePaths) => {
|
|
3882
3879
|
let cursor = tree;
|
|
3883
3880
|
for (const nodePath of nodePaths) {
|
|
3884
3881
|
cursor = cursor?.children[nodePath];
|
|
@@ -3923,7 +3920,7 @@ const mergeFacetTrees = (currentTree, incomingTree) => {
|
|
|
3923
3920
|
const mergedTree = structuredClone(currentTree);
|
|
3924
3921
|
const merge = (currentBranch, nodePath) => {
|
|
3925
3922
|
const mergedBranch = structuredClone(currentBranch);
|
|
3926
|
-
const incomingBranch =
|
|
3923
|
+
const incomingBranch = getFacetTreeNodeAtPath(incomingTree, nodePath);
|
|
3927
3924
|
if (!incomingBranch) {
|
|
3928
3925
|
return mergedBranch;
|
|
3929
3926
|
}
|
|
@@ -5569,17 +5566,35 @@ class SearchcraftFacetList {
|
|
|
5569
5566
|
*/
|
|
5570
5567
|
facetSelectionUpdated;
|
|
5571
5568
|
/**
|
|
5572
|
-
*
|
|
5569
|
+
* The currently selected facet paths.
|
|
5570
|
+
*/
|
|
5571
|
+
selectedPaths = {};
|
|
5572
|
+
/**
|
|
5573
|
+
* A Tree representing all of the facets collected from search responses.
|
|
5573
5574
|
*/
|
|
5574
|
-
|
|
5575
|
+
facetTreeCollectedFromSearchResponse = {
|
|
5575
5576
|
path: '/',
|
|
5576
5577
|
count: 0,
|
|
5577
5578
|
children: {},
|
|
5578
5579
|
};
|
|
5579
5580
|
/**
|
|
5580
|
-
*
|
|
5581
|
+
* A Tree representing the facet paths that are selected, but were not included
|
|
5582
|
+
* in any search response.
|
|
5581
5583
|
*/
|
|
5582
|
-
|
|
5584
|
+
facetTreeFromFacetPathsNotInSearchResponse = {
|
|
5585
|
+
path: '/',
|
|
5586
|
+
count: 0,
|
|
5587
|
+
children: {},
|
|
5588
|
+
};
|
|
5589
|
+
/**
|
|
5590
|
+
* The facet tree that ultimately gets rendered.
|
|
5591
|
+
* This is a mergin of the facetTreeCollectedFromSearchResponse and the facetTreeFromFacetPathsNotInSearchResponse tree
|
|
5592
|
+
*/
|
|
5593
|
+
renderedFacetTree = {
|
|
5594
|
+
path: '/',
|
|
5595
|
+
count: 0,
|
|
5596
|
+
children: {},
|
|
5597
|
+
};
|
|
5583
5598
|
// Internal vars used to track when to perform various facet actions.
|
|
5584
5599
|
lastTimeTaken;
|
|
5585
5600
|
lastSearchTerm;
|
|
@@ -5588,6 +5603,9 @@ class SearchcraftFacetList {
|
|
|
5588
5603
|
lastRangeValues;
|
|
5589
5604
|
lastFacetValues;
|
|
5590
5605
|
unsubscribe;
|
|
5606
|
+
get areAnyFacetPathsSelected() {
|
|
5607
|
+
return Object.keys(this.selectedPaths).some((key) => this.selectedPaths[key]);
|
|
5608
|
+
}
|
|
5591
5609
|
handleIncomingSearchResponse(state, actionType) {
|
|
5592
5610
|
// Look at the incoming facet root from the search response, and convert it to a FacetTree
|
|
5593
5611
|
const incomingFacetRoot = state.searchResponseFacetPrime?.find((facet) => this.fieldName === Object.keys(facet)[0]);
|
|
@@ -5597,18 +5615,20 @@ class SearchcraftFacetList {
|
|
|
5597
5615
|
count: 0,
|
|
5598
5616
|
children: incomingFacetsWithChildrenArray || [],
|
|
5599
5617
|
});
|
|
5600
|
-
// Determine what action to take
|
|
5618
|
+
// Determine what action to take to accumulate items into the `facetTreeCollectedFromSearchResponse`.
|
|
5619
|
+
// This facet tree gets accumulated in different ways depending on what action type occured.
|
|
5601
5620
|
switch (actionType) {
|
|
5602
5621
|
case 'SEARCH_TERM_EMPTY':
|
|
5603
|
-
this.
|
|
5622
|
+
this.facetTreeCollectedFromSearchResponse = {
|
|
5604
5623
|
path: '/',
|
|
5605
5624
|
count: 0,
|
|
5606
5625
|
children: {},
|
|
5607
5626
|
};
|
|
5608
5627
|
break;
|
|
5609
5628
|
case 'NEW_SEARCH_TERM':
|
|
5610
|
-
this.
|
|
5629
|
+
this.facetTreeCollectedFromSearchResponse = incomingFacetTree;
|
|
5611
5630
|
break;
|
|
5631
|
+
case 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE':
|
|
5612
5632
|
case 'EXACT_MATCH_UPDATE':
|
|
5613
5633
|
case 'RANGE_VALUE_UPDATE': {
|
|
5614
5634
|
if (state.supplementalFacetPrime) {
|
|
@@ -5619,53 +5639,95 @@ class SearchcraftFacetList {
|
|
|
5619
5639
|
count: 0,
|
|
5620
5640
|
children: supplementalFacetsWithChildrenArray || [],
|
|
5621
5641
|
});
|
|
5622
|
-
this.
|
|
5642
|
+
this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(supplementalFacetTree, incomingFacetTree);
|
|
5623
5643
|
}
|
|
5624
5644
|
else {
|
|
5625
|
-
this.
|
|
5645
|
+
this.facetTreeCollectedFromSearchResponse = incomingFacetTree;
|
|
5626
5646
|
}
|
|
5627
5647
|
break;
|
|
5628
5648
|
}
|
|
5629
5649
|
case 'FACET_UPDATE':
|
|
5630
5650
|
case 'SORT_ORDER_UPDATE':
|
|
5631
|
-
this.
|
|
5651
|
+
this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(this.facetTreeCollectedFromSearchResponse, incomingFacetTree);
|
|
5632
5652
|
break;
|
|
5633
5653
|
default:
|
|
5634
|
-
|
|
5654
|
+
return;
|
|
5635
5655
|
}
|
|
5656
|
+
// Determine if there are any selected facet paths not in the current tree.
|
|
5657
|
+
// If there are, we add them to "facetTreeFromFacetPathsNotInSearchResponse"
|
|
5658
|
+
this.facetTreeFromFacetPathsNotInSearchResponse = {
|
|
5659
|
+
path: '/',
|
|
5660
|
+
count: 0,
|
|
5661
|
+
children: {},
|
|
5662
|
+
};
|
|
5663
|
+
const collectedFacetArray = {
|
|
5664
|
+
path: '/',
|
|
5665
|
+
count: 0,
|
|
5666
|
+
children: [],
|
|
5667
|
+
};
|
|
5668
|
+
for (const pathName of Object.keys(this.selectedPaths).filter((path) => this.selectedPaths[path])) {
|
|
5669
|
+
const nodePaths = pathName.startsWith('/')
|
|
5670
|
+
? pathName.substring(1).split('/')
|
|
5671
|
+
: pathName.split('/');
|
|
5672
|
+
const wasFoundInFacetTree = !!getFacetTreeNodeAtPath(this.facetTreeCollectedFromSearchResponse, nodePaths);
|
|
5673
|
+
const pathKeyName = nodePaths.at(-1);
|
|
5674
|
+
if (!wasFoundInFacetTree && pathKeyName) {
|
|
5675
|
+
collectedFacetArray.children?.push({
|
|
5676
|
+
children: [],
|
|
5677
|
+
count: 0,
|
|
5678
|
+
path: pathName,
|
|
5679
|
+
});
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5682
|
+
this.facetTreeFromFacetPathsNotInSearchResponse =
|
|
5683
|
+
facetWithChildrenArrayToCompleteFacetTree(collectedFacetArray);
|
|
5684
|
+
// Merges facetTreeCollectedFromSearchResponse with selectedFacetPathsNotInCurrentFacetTree.
|
|
5685
|
+
// This results in a single, final facet tree that gets rendered in as Checkboxes
|
|
5686
|
+
this.renderedFacetTree = deepMergeWithSpread(this.facetTreeFromFacetPathsNotInSearchResponse, this.facetTreeCollectedFromSearchResponse);
|
|
5636
5687
|
}
|
|
5637
|
-
handleStateUpdate(
|
|
5688
|
+
handleStateUpdate(_state) {
|
|
5689
|
+
const state = { ..._state };
|
|
5638
5690
|
// Determine what action to take based on the current State
|
|
5639
|
-
if (
|
|
5640
|
-
state.searchTerm.trim() === '') {
|
|
5691
|
+
if (state.searchTerm.trim() === '') {
|
|
5641
5692
|
this.handleIncomingSearchResponse(state, 'SEARCH_TERM_EMPTY');
|
|
5693
|
+
this.lastSearchTerm = '';
|
|
5642
5694
|
}
|
|
5643
|
-
else if (this.lastTimeTaken !== state.searchResponseTimeTaken
|
|
5695
|
+
else if (this.lastTimeTaken !== state.searchResponseTimeTaken &&
|
|
5696
|
+
state.searchClientRequest &&
|
|
5697
|
+
typeof state.searchClientRequest === 'object') {
|
|
5698
|
+
const request = state.searchClientRequest;
|
|
5644
5699
|
let actionType = 'UNKNOWN';
|
|
5645
|
-
if (this.lastSearchTerm !==
|
|
5646
|
-
|
|
5700
|
+
if (this.lastSearchTerm !== request.searchTerm) {
|
|
5701
|
+
if (this.areAnyFacetPathsSelected) {
|
|
5702
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
5703
|
+
}
|
|
5704
|
+
else {
|
|
5705
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
5706
|
+
}
|
|
5647
5707
|
}
|
|
5648
|
-
else if (this.lastRangeValues !==
|
|
5708
|
+
else if (this.lastRangeValues !==
|
|
5709
|
+
JSON.stringify(request.rangeValueForIndexFields)) {
|
|
5649
5710
|
actionType = 'RANGE_VALUE_UPDATE';
|
|
5650
5711
|
}
|
|
5651
|
-
else if (this.lastFacetValues !==
|
|
5712
|
+
else if (this.lastFacetValues !==
|
|
5713
|
+
JSON.stringify(request.facetPathsForIndexFields)) {
|
|
5652
5714
|
actionType = 'FACET_UPDATE';
|
|
5653
5715
|
}
|
|
5654
|
-
else if (this.lastSortType !==
|
|
5716
|
+
else if (this.lastSortType !== request.order_by) {
|
|
5655
5717
|
actionType = 'SORT_ORDER_UPDATE';
|
|
5656
5718
|
}
|
|
5657
|
-
else if (this.lastSearchMode !==
|
|
5719
|
+
else if (this.lastSearchMode !== request.mode) {
|
|
5658
5720
|
actionType = 'EXACT_MATCH_UPDATE';
|
|
5659
5721
|
}
|
|
5722
|
+
this.lastRangeValues = JSON.stringify(request.rangeValueForIndexFields);
|
|
5723
|
+
this.lastFacetValues = JSON.stringify(request.facetPathsForIndexFields);
|
|
5724
|
+
this.lastSortType = request.order_by;
|
|
5725
|
+
this.lastSearchMode = request.mode;
|
|
5726
|
+
this.lastSearchTerm = request.searchTerm;
|
|
5727
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
5660
5728
|
// Handle the incoming response, using the action we have determined.
|
|
5661
5729
|
this.handleIncomingSearchResponse(state, actionType);
|
|
5662
|
-
this.lastSearchTerm = state.searchTerm;
|
|
5663
|
-
this.lastRangeValues = JSON.stringify(state.rangeValueForIndexFields);
|
|
5664
|
-
this.lastFacetValues = JSON.stringify(state.facetPathsForIndexFields);
|
|
5665
|
-
this.lastSortType = state.sortType;
|
|
5666
|
-
this.lastSearchMode = state.searchMode;
|
|
5667
5730
|
}
|
|
5668
|
-
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
5669
5731
|
}
|
|
5670
5732
|
connectedCallback() {
|
|
5671
5733
|
this.handleStateUpdate(searchcraftStore.getState());
|
|
@@ -5737,23 +5799,26 @@ class SearchcraftFacetList {
|
|
|
5737
5799
|
if (!this.fieldName) {
|
|
5738
5800
|
return;
|
|
5739
5801
|
}
|
|
5740
|
-
if (Object.keys(this.
|
|
5802
|
+
if (Object.keys(this.facetTreeCollectedFromSearchResponse.children).length ===
|
|
5803
|
+
0 &&
|
|
5741
5804
|
(this.lastSearchTerm || '').trim().length === 0) {
|
|
5742
5805
|
return;
|
|
5743
5806
|
}
|
|
5744
|
-
if (Object.keys(this.
|
|
5807
|
+
if (Object.keys(this.facetTreeCollectedFromSearchResponse.children).length ===
|
|
5808
|
+
0 &&
|
|
5745
5809
|
(this.lastSearchTerm || '').trim().length > 0) {
|
|
5746
5810
|
return (hAsync("p", { class: 'searchcraft-facet-list-message' }, "No facets are available for this search query."));
|
|
5747
5811
|
}
|
|
5748
|
-
return (hAsync("div", { class: 'searchcraft-facet-list' }, this.renderFacet('@@root', this.
|
|
5812
|
+
return (hAsync("div", { class: 'searchcraft-facet-list' }, this.renderFacet('@@root', this.renderedFacetTree)));
|
|
5749
5813
|
}
|
|
5750
5814
|
static get cmpMeta() { return {
|
|
5751
5815
|
"$flags$": 0,
|
|
5752
5816
|
"$tagName$": "searchcraft-facet-list",
|
|
5753
5817
|
"$members$": {
|
|
5754
5818
|
"fieldName": [1, "field-name"],
|
|
5755
|
-
"
|
|
5756
|
-
"
|
|
5819
|
+
"selectedPaths": [32],
|
|
5820
|
+
"facetTreeCollectedFromSearchResponse": [32],
|
|
5821
|
+
"renderedFacetTree": [32]
|
|
5757
5822
|
},
|
|
5758
5823
|
"$listeners$": undefined,
|
|
5759
5824
|
"$lazyBundleId$": "-",
|
|
@@ -6026,22 +6091,18 @@ class SearchcraftInputForm {
|
|
|
6026
6091
|
handleInput = (event) => {
|
|
6027
6092
|
const input = event.target;
|
|
6028
6093
|
this.inputValue = input.value;
|
|
6094
|
+
this.searchcraftStore.setSearchTerm(input.value);
|
|
6029
6095
|
if (!this.autoSearch) {
|
|
6030
6096
|
return;
|
|
6031
6097
|
}
|
|
6032
|
-
this.performSearch(
|
|
6098
|
+
this.performSearch();
|
|
6033
6099
|
};
|
|
6034
|
-
performSearch = async (
|
|
6035
|
-
if (searchTerm === this.searchTerm) {
|
|
6036
|
-
return;
|
|
6037
|
-
}
|
|
6038
|
-
this.searchcraftStore.setSearchTerm(searchTerm.trim());
|
|
6100
|
+
performSearch = async () => {
|
|
6039
6101
|
this.error = false;
|
|
6040
6102
|
try {
|
|
6041
6103
|
await this.searchcraftStore.search();
|
|
6042
6104
|
}
|
|
6043
6105
|
catch (error) {
|
|
6044
|
-
console.error(`Search for ${searchTerm} failed:`, error);
|
|
6045
6106
|
this.error = true;
|
|
6046
6107
|
}
|
|
6047
6108
|
};
|
|
@@ -6056,7 +6117,7 @@ class SearchcraftInputForm {
|
|
|
6056
6117
|
};
|
|
6057
6118
|
handleFormSubmit = async (event) => {
|
|
6058
6119
|
event.preventDefault();
|
|
6059
|
-
await this.performSearch(
|
|
6120
|
+
await this.performSearch();
|
|
6060
6121
|
};
|
|
6061
6122
|
render() {
|
|
6062
6123
|
const isShowingClearButton = this.inputValue.length > 0;
|
|
@@ -6069,11 +6130,11 @@ class SearchcraftInputForm {
|
|
|
6069
6130
|
const inputGridStyles = {
|
|
6070
6131
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
6071
6132
|
};
|
|
6072
|
-
return (hAsync("form", { key: '
|
|
6133
|
+
return (hAsync("form", { key: 'd0654def009278279b7edeeccc6044d999c0d5b0', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, hAsync("div", { key: '27978b08e46e0f8ecdf6dc95a74c962d85f5e9ff', class: inputGridClassNames, style: inputGridStyles }, hAsync("div", { key: '1f7cecc80a84bfc46c994971cd751d2b65af6d83', class: 'searchcraft-input-form-button' }, hAsync("searchcraft-button", { key: 'b3f2078604c380eef895be103b2bdf5cef6bca84', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (hAsync("div", { key: 'b33c0d3cbb3512964c3a47a2c354a610fa6faa09', class: 'searchcraft-input-form-label' }, hAsync("searchcraft-input-label", { key: 'e620088318c82e2e70d885bd3ee2c88ef8118e7c', label: this.inputLabel }))), this.error && (hAsync("div", { key: 'c3a20576917aaa33cc12df5ee5b479f87d628de7', class: 'searchcraft-input-form-error-message' }, hAsync("searchcraft-error-message", { key: 'f48e54a236b7a33fa55bab7f29d3b321be0bbb77' }, "Something went wrong."))), hAsync("div", { key: 'ebda089a3b8698892fd6cebcbaf89582a1bb21a2', class: 'searchcraft-input-form-input-wrapper' }, hAsync("input", { key: 'd7ea7b49f7d65067924168fc281033841a71d419', autoComplete: 'off', class: classNames('searchcraft-input-form-input', {
|
|
6073
6134
|
'searchcraft-placeholder-hide-on-focus': this.placeholderBehavior === 'hide-on-focus',
|
|
6074
6135
|
}), onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
6075
6136
|
this.handleInput(event);
|
|
6076
|
-
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), hAsync("div", { key: '
|
|
6137
|
+
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), hAsync("div", { key: '6dd4a02322072467a104938a47626592658eaa1e', class: 'searchcraft-input-form-input-icon' }, hAsync("svg", { key: '26a4deabe9149db6db219e49fcccbbe7688e9f0a', class: 'searchcraft-input-form-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'searchcraft-title' }, hAsync("title", { key: 'eff07788d2edaead45a60d8ac20e5d1d694c5165' }, "Search icon"), hAsync("path", { key: '9083cf32c8f749210232b51b1f5934a3c32b109f', d: 'M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), isShowingClearButton && (hAsync("button", { key: '0b2117ae2510fe743b11d8e638e981ee0f7e4760', type: 'button', class: 'searchcraft-input-form-clear-button', onClick: this.handleClearInput }, hAsync("svg", { key: '3fbb57c1b6486638286e1010639751a83a75f489', class: 'searchcraft-input-form-clear-icon', viewBox: '0 0 22 22', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'icon-title' }, hAsync("title", { key: '84ce771c55c072b4339babb136639469b68a1f9b' }, "Clear icon"), hAsync("path", { key: '811f5fc9cc708f80004f1cf50ddcd85de05f3b6b', d: 'M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))))))));
|
|
6077
6138
|
}
|
|
6078
6139
|
static get watchers() { return {
|
|
6079
6140
|
"core": ["onCoreChange"]
|
|
@@ -6843,40 +6904,99 @@ class SearchcraftPopoverListItemAd {
|
|
|
6843
6904
|
}
|
|
6844
6905
|
adSource = 'Custom';
|
|
6845
6906
|
adClientResponseItem;
|
|
6846
|
-
|
|
6907
|
+
/**
|
|
6908
|
+
* Where the ad is being rendered within the search results div.
|
|
6909
|
+
* Lifecycle behavior differs for ads being rendered in different positions,
|
|
6910
|
+
* so we need to be able to handle all of those cases.
|
|
6911
|
+
*/
|
|
6912
|
+
renderPosition = 'interstitial';
|
|
6847
6913
|
searchTerm;
|
|
6848
6914
|
isSearchInProgress = false;
|
|
6915
|
+
searchResultCount = 0;
|
|
6849
6916
|
get hostElement() { return getElement(this); }
|
|
6850
6917
|
core;
|
|
6851
6918
|
intersectionObserver;
|
|
6852
6919
|
storeUnsubscribe;
|
|
6853
6920
|
adContainerRenderedTimeout;
|
|
6854
|
-
isComponentConnected =
|
|
6921
|
+
isComponentConnected = false;
|
|
6922
|
+
timeTaken;
|
|
6923
|
+
adContainerId = '';
|
|
6924
|
+
/**
|
|
6925
|
+
* Handles when an ad container is first rendered.
|
|
6926
|
+
* Core emits an ad_container_rendered event and performs ad client side effects
|
|
6927
|
+
*
|
|
6928
|
+
*/
|
|
6929
|
+
handleAdRendered() {
|
|
6930
|
+
this.adContainerId = nanoid();
|
|
6931
|
+
if (this.isComponentConnected && this.searchResultCount > 0) {
|
|
6932
|
+
clearTimeout(this.adContainerRenderedTimeout);
|
|
6933
|
+
this.adContainerRenderedTimeout = setTimeout(() => {
|
|
6934
|
+
this.core?.handleAdContainerRendered({
|
|
6935
|
+
adClientResponseItem: this.adClientResponseItem,
|
|
6936
|
+
adContainerId: this.adContainerId,
|
|
6937
|
+
adSource: this.adSource,
|
|
6938
|
+
searchTerm: this.searchTerm || '',
|
|
6939
|
+
});
|
|
6940
|
+
}, this.core?.config?.adContainerRenderedDebounceDelay || 300);
|
|
6941
|
+
}
|
|
6942
|
+
}
|
|
6943
|
+
handleAdViewed() {
|
|
6944
|
+
this.core?.handleAdContainerViewed({
|
|
6945
|
+
adClientResponseItem: this.adClientResponseItem,
|
|
6946
|
+
adContainerId: this.adContainerId,
|
|
6947
|
+
adSource: this.adSource,
|
|
6948
|
+
searchTerm: this.searchTerm || '',
|
|
6949
|
+
});
|
|
6950
|
+
}
|
|
6951
|
+
/**
|
|
6952
|
+
* Things to do when there's a new incoming search request.
|
|
6953
|
+
*/
|
|
6954
|
+
handleNewIncomingSearchRequest(state) {
|
|
6955
|
+
const request = state.searchClientRequest;
|
|
6956
|
+
if (request && typeof request === 'object') {
|
|
6957
|
+
this.searchTerm = request.searchTerm;
|
|
6958
|
+
}
|
|
6959
|
+
this.searchResultCount = state.searchClientResponseItems.length;
|
|
6960
|
+
this.handleAdRendered();
|
|
6961
|
+
this.startIntersectionObserver();
|
|
6962
|
+
}
|
|
6855
6963
|
connectedCallback() {
|
|
6856
6964
|
const currentState = searchcraftStore.getState();
|
|
6965
|
+
this.isComponentConnected = true;
|
|
6857
6966
|
this.core = currentState.core;
|
|
6858
|
-
this.searchTerm = currentState.searchTerm;
|
|
6859
6967
|
this.isSearchInProgress = currentState.isSearchInProgress;
|
|
6968
|
+
this.searchResultCount = currentState.searchClientResponseItems.length;
|
|
6969
|
+
this.timeTaken = currentState.searchResponseTimeTaken;
|
|
6970
|
+
const request = currentState.searchClientRequest;
|
|
6971
|
+
if (request && typeof request === 'object') {
|
|
6972
|
+
this.searchTerm = request.searchTerm;
|
|
6973
|
+
}
|
|
6974
|
+
/**
|
|
6975
|
+
* Interstial ads have a different lifecycle, where we need handle an incoming search
|
|
6976
|
+
* request immediately, because they are rendered alongside the search results.
|
|
6977
|
+
*/
|
|
6978
|
+
if (this.renderPosition === 'interstitial') {
|
|
6979
|
+
this.handleNewIncomingSearchRequest(currentState);
|
|
6980
|
+
}
|
|
6860
6981
|
// Subscribes to store changes (for search term).
|
|
6861
6982
|
this.storeUnsubscribe = searchcraftStore.subscribe((state) => {
|
|
6862
|
-
this.
|
|
6983
|
+
if (this.timeTaken !== state.searchResponseTimeTaken) {
|
|
6984
|
+
this.handleNewIncomingSearchRequest(state);
|
|
6985
|
+
}
|
|
6986
|
+
this.timeTaken = state.searchResponseTimeTaken;
|
|
6863
6987
|
this.isSearchInProgress = state.isSearchInProgress;
|
|
6864
6988
|
});
|
|
6865
6989
|
}
|
|
6866
|
-
|
|
6990
|
+
startIntersectionObserver() {
|
|
6991
|
+
this.intersectionObserver?.disconnect();
|
|
6867
6992
|
/**
|
|
6868
6993
|
* Handles when an ad container is viewable within the document,
|
|
6869
6994
|
* Core emits an ad_container_viewed event and performs ad client side effects
|
|
6870
6995
|
*/
|
|
6871
6996
|
if (this.hostElement) {
|
|
6872
6997
|
this.intersectionObserver = new IntersectionObserver(([entry]) => {
|
|
6873
|
-
if (entry?.isIntersecting &&
|
|
6874
|
-
this.
|
|
6875
|
-
adClientResponseItem: this.adClientResponseItem,
|
|
6876
|
-
adContainerId: this.adContainerId,
|
|
6877
|
-
adSource: this.adSource,
|
|
6878
|
-
searchTerm: this.searchTerm || '',
|
|
6879
|
-
});
|
|
6998
|
+
if (entry?.isIntersecting && this.searchResultCount > 0) {
|
|
6999
|
+
this.handleAdViewed();
|
|
6880
7000
|
}
|
|
6881
7001
|
}, { threshold: 0 });
|
|
6882
7002
|
this.intersectionObserver.observe(this.hostElement);
|
|
@@ -6916,26 +7036,10 @@ class SearchcraftPopoverListItemAd {
|
|
|
6916
7036
|
return (hAsync("div", { id: `searchcraft-native-ad-${this.adContainerId}`, class: classNames('searchcraft-ad', nativoClassName), "data-searchcraft-ad-container-id": this.adContainerId }));
|
|
6917
7037
|
}
|
|
6918
7038
|
render() {
|
|
6919
|
-
// Don't render ads
|
|
6920
|
-
if (this.
|
|
7039
|
+
// Don't render ads if no search results
|
|
7040
|
+
if (this.searchResultCount === 0) {
|
|
6921
7041
|
return;
|
|
6922
7042
|
}
|
|
6923
|
-
/**
|
|
6924
|
-
* Handles when an ad container is first rendered.
|
|
6925
|
-
* Core emits an ad_container_rendered event and performs ad client side effects
|
|
6926
|
-
*
|
|
6927
|
-
*/
|
|
6928
|
-
if (this.isComponentConnected) {
|
|
6929
|
-
clearTimeout(this.adContainerRenderedTimeout);
|
|
6930
|
-
this.adContainerRenderedTimeout = setTimeout(() => {
|
|
6931
|
-
this.core?.handleAdContainerRendered({
|
|
6932
|
-
adClientResponseItem: this.adClientResponseItem,
|
|
6933
|
-
adContainerId: this.adContainerId,
|
|
6934
|
-
adSource: this.adSource,
|
|
6935
|
-
searchTerm: this.searchTerm || '',
|
|
6936
|
-
});
|
|
6937
|
-
}, this.core?.config?.adContainerRenderedDebounceDelay || 500);
|
|
6938
|
-
}
|
|
6939
7043
|
switch (this.adSource) {
|
|
6940
7044
|
case 'adMarketplace':
|
|
6941
7045
|
return this.renderADMAd();
|
|
@@ -6953,9 +7057,11 @@ class SearchcraftPopoverListItemAd {
|
|
|
6953
7057
|
"$members$": {
|
|
6954
7058
|
"adSource": [1, "ad-source"],
|
|
6955
7059
|
"adClientResponseItem": [16],
|
|
6956
|
-
"
|
|
7060
|
+
"renderPosition": [1, "render-position"],
|
|
6957
7061
|
"searchTerm": [32],
|
|
6958
|
-
"isSearchInProgress": [32]
|
|
7062
|
+
"isSearchInProgress": [32],
|
|
7063
|
+
"searchResultCount": [32],
|
|
7064
|
+
"adContainerId": [32]
|
|
6959
7065
|
},
|
|
6960
7066
|
"$listeners$": undefined,
|
|
6961
7067
|
"$lazyBundleId$": "-",
|
|
@@ -6992,7 +7098,7 @@ class SearchcraftPopoverListView {
|
|
|
6992
7098
|
searchResultsPerPage;
|
|
6993
7099
|
config = searchcraftStore.getState().core?.config;
|
|
6994
7100
|
renderWithADMAds() {
|
|
6995
|
-
return (hAsync("div", { class: 'searchcraft-popover-list-view' }, this.adClientResponseItems?.map((item) => (hAsync("searchcraft-ad", { adClientResponseItem: item,
|
|
7101
|
+
return (hAsync("div", { class: 'searchcraft-popover-list-view' }, this.adClientResponseItems?.map((item) => (hAsync("searchcraft-ad", { adClientResponseItem: item, adSource: 'adMarketplace', key: item.id, renderPosition: 'top' }))), this.searchClientResponseItems?.map((item, index) => (hAsync("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index })))));
|
|
6996
7102
|
}
|
|
6997
7103
|
renderWithCustomAds() {
|
|
6998
7104
|
const itemsToRender = [];
|
|
@@ -7003,7 +7109,7 @@ class SearchcraftPopoverListView {
|
|
|
7003
7109
|
const searchItems = this.searchClientResponseItems || [];
|
|
7004
7110
|
// Renders ads at beginning
|
|
7005
7111
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7006
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7112
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7007
7113
|
}
|
|
7008
7114
|
// Renders search results + interstitial ads
|
|
7009
7115
|
searchItems.forEach((item, index) => {
|
|
@@ -7012,14 +7118,14 @@ class SearchcraftPopoverListView {
|
|
|
7012
7118
|
index + interstitialInterval < searchItems.length &&
|
|
7013
7119
|
index >= interstitialInterval) {
|
|
7014
7120
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7015
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7121
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7016
7122
|
}
|
|
7017
7123
|
}
|
|
7018
7124
|
itemsToRender.push(hAsync("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index }));
|
|
7019
7125
|
});
|
|
7020
7126
|
// Renders ads at end
|
|
7021
7127
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7022
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7128
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7023
7129
|
}
|
|
7024
7130
|
return hAsync("div", { class: 'searchcraft-popover-list-view' }, itemsToRender);
|
|
7025
7131
|
}
|
|
@@ -7033,7 +7139,7 @@ class SearchcraftPopoverListView {
|
|
|
7033
7139
|
const searchItems = this.searchClientResponseItems || [];
|
|
7034
7140
|
// Renders ads at beginning
|
|
7035
7141
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7036
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7142
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7037
7143
|
}
|
|
7038
7144
|
// Renders search results + interstitial ads
|
|
7039
7145
|
searchItems.forEach((item, index) => {
|
|
@@ -7042,14 +7148,14 @@ class SearchcraftPopoverListView {
|
|
|
7042
7148
|
index + interstitialInterval < searchItems.length &&
|
|
7043
7149
|
index >= interstitialInterval) {
|
|
7044
7150
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7045
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7151
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7046
7152
|
}
|
|
7047
7153
|
}
|
|
7048
7154
|
itemsToRender.push(hAsync("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index }));
|
|
7049
7155
|
});
|
|
7050
7156
|
// Renders ads at end
|
|
7051
7157
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7052
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7158
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7053
7159
|
}
|
|
7054
7160
|
return hAsync("div", { class: 'searchcraft-popover-list-view' }, itemsToRender);
|
|
7055
7161
|
}
|
|
@@ -7406,7 +7512,7 @@ class SearchcraftSearchResults {
|
|
|
7406
7512
|
: this.initialSearchClientResponseItems?.length
|
|
7407
7513
|
? this.initialSearchClientResponseItems
|
|
7408
7514
|
: [];
|
|
7409
|
-
return (hAsync("div", { class: 'searchcraft-search-results' }, this.adClientResponseItems?.map((item) => (hAsync("searchcraft-ad", { adSource: 'adMarketplace', adClientResponseItem: item,
|
|
7515
|
+
return (hAsync("div", { class: 'searchcraft-search-results' }, this.adClientResponseItems?.map((item) => (hAsync("searchcraft-ad", { adSource: 'adMarketplace', adClientResponseItem: item, key: item.id, renderPosition: 'top' }))), items.map((item, index) => (hAsync("searchcraft-search-result", { key: item.id, "document-position": this.searchResultsPerPage * (this.searchResultsPage - 1) + index, index: index, item: item, template: this.template })))));
|
|
7410
7516
|
}
|
|
7411
7517
|
renderWithCustomAds() {
|
|
7412
7518
|
const itemsToRender = [];
|
|
@@ -7421,7 +7527,7 @@ class SearchcraftSearchResults {
|
|
|
7421
7527
|
: [];
|
|
7422
7528
|
// Renders ads at beginning
|
|
7423
7529
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7424
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7530
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7425
7531
|
}
|
|
7426
7532
|
// Renders search results + interstitial ads
|
|
7427
7533
|
items.forEach((item, index) => {
|
|
@@ -7430,14 +7536,14 @@ class SearchcraftSearchResults {
|
|
|
7430
7536
|
index + interstitialInterval < items.length &&
|
|
7431
7537
|
index >= interstitialInterval) {
|
|
7432
7538
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7433
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7539
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7434
7540
|
}
|
|
7435
7541
|
}
|
|
7436
7542
|
itemsToRender.push(hAsync("searchcraft-search-result", { key: item.id, "document-position": this.searchResultsPerPage * (this.searchResultsPage - 1) + index, index: index, item: item, template: this.template }));
|
|
7437
7543
|
});
|
|
7438
7544
|
// Renders ads at end
|
|
7439
7545
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7440
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7546
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7441
7547
|
}
|
|
7442
7548
|
return hAsync("div", { class: 'searchcraft-search-results' }, itemsToRender);
|
|
7443
7549
|
}
|
|
@@ -7455,7 +7561,7 @@ class SearchcraftSearchResults {
|
|
|
7455
7561
|
: [];
|
|
7456
7562
|
// Renders ads at beginning
|
|
7457
7563
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7458
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7564
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7459
7565
|
}
|
|
7460
7566
|
// Renders search results + interstitial ads
|
|
7461
7567
|
items.forEach((item, index) => {
|
|
@@ -7464,14 +7570,14 @@ class SearchcraftSearchResults {
|
|
|
7464
7570
|
index + interstitialInterval < items.length &&
|
|
7465
7571
|
index >= interstitialInterval) {
|
|
7466
7572
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7467
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7573
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7468
7574
|
}
|
|
7469
7575
|
}
|
|
7470
7576
|
itemsToRender.push(hAsync("searchcraft-search-result", { key: item.id, "document-position": this.searchResultsPerPage * (this.searchResultsPage - 1) + index, index: index, item: item, template: this.template }));
|
|
7471
7577
|
});
|
|
7472
7578
|
// Renders ads at end
|
|
7473
7579
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7474
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7580
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7475
7581
|
}
|
|
7476
7582
|
return hAsync("div", { class: 'searchcraft-search-results' }, itemsToRender);
|
|
7477
7583
|
}
|