@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.mjs
CHANGED
|
@@ -3179,7 +3179,7 @@ Object.keys(react).forEach(function (k) {
|
|
|
3179
3179
|
var B = Object.defineProperty;
|
|
3180
3180
|
var N = (a, e, n) => e in a ? B(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3181
3181
|
var h = (a, e, n) => N(a, typeof e != "symbol" ? e + "" : e, n);
|
|
3182
|
-
var
|
|
3182
|
+
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 || {});
|
|
3183
3183
|
class pe {
|
|
3184
3184
|
constructor(e) {
|
|
3185
3185
|
h(this, "logLevel");
|
|
@@ -3187,7 +3187,7 @@ class pe {
|
|
|
3187
3187
|
this.logLevel = e.logLevel || 1, this.logFormatter = e.logFormatter || this.defaultFormatter;
|
|
3188
3188
|
}
|
|
3189
3189
|
defaultFormatter(e, n) {
|
|
3190
|
-
return `[${
|
|
3190
|
+
return `[${D[e]}] ${( new Date()).toISOString()}: ${n}`;
|
|
3191
3191
|
}
|
|
3192
3192
|
debug(e) {
|
|
3193
3193
|
this.logLevel <= 0 && console.log(this.logFormatter(0, e));
|
|
@@ -3218,149 +3218,149 @@ class pe {
|
|
|
3218
3218
|
}
|
|
3219
3219
|
}
|
|
3220
3220
|
}
|
|
3221
|
-
function
|
|
3222
|
-
return new (n || (n = Promise))(function(
|
|
3223
|
-
function t(
|
|
3221
|
+
function w(a, e, n, r) {
|
|
3222
|
+
return new (n || (n = Promise))(function(o, i) {
|
|
3223
|
+
function t(s) {
|
|
3224
3224
|
try {
|
|
3225
|
-
|
|
3226
|
-
} catch (
|
|
3227
|
-
|
|
3225
|
+
l(r.next(s));
|
|
3226
|
+
} catch (c) {
|
|
3227
|
+
i(c);
|
|
3228
3228
|
}
|
|
3229
3229
|
}
|
|
3230
|
-
function u(
|
|
3230
|
+
function u(s) {
|
|
3231
3231
|
try {
|
|
3232
|
-
|
|
3233
|
-
} catch (
|
|
3234
|
-
|
|
3232
|
+
l(r.throw(s));
|
|
3233
|
+
} catch (c) {
|
|
3234
|
+
i(c);
|
|
3235
3235
|
}
|
|
3236
3236
|
}
|
|
3237
|
-
function
|
|
3238
|
-
var
|
|
3239
|
-
|
|
3240
|
-
|
|
3237
|
+
function l(s) {
|
|
3238
|
+
var c;
|
|
3239
|
+
s.done ? o(s.value) : (c = s.value, c instanceof n ? c : new n(function(g) {
|
|
3240
|
+
g(c);
|
|
3241
3241
|
})).then(t, u);
|
|
3242
3242
|
}
|
|
3243
|
-
|
|
3243
|
+
l((r = r.apply(a, [])).next());
|
|
3244
3244
|
});
|
|
3245
3245
|
}
|
|
3246
|
-
function
|
|
3247
|
-
var n, r,
|
|
3248
|
-
if (1 &
|
|
3249
|
-
return
|
|
3246
|
+
function y(a, e) {
|
|
3247
|
+
var n, r, o, i, t = { label: 0, sent: function() {
|
|
3248
|
+
if (1 & o[0]) throw o[1];
|
|
3249
|
+
return o[1];
|
|
3250
3250
|
}, trys: [], ops: [] };
|
|
3251
|
-
return
|
|
3251
|
+
return i = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
|
|
3252
3252
|
return this;
|
|
3253
|
-
}),
|
|
3254
|
-
function u(
|
|
3255
|
-
return function(
|
|
3256
|
-
return function(
|
|
3253
|
+
}), i;
|
|
3254
|
+
function u(l) {
|
|
3255
|
+
return function(s) {
|
|
3256
|
+
return function(c) {
|
|
3257
3257
|
if (n) throw new TypeError("Generator is already executing.");
|
|
3258
|
-
for (;
|
|
3259
|
-
if (n = 1, r && (
|
|
3260
|
-
switch (r = 0,
|
|
3258
|
+
for (; i && (i = 0, c[0] && (t = 0)), t; ) try {
|
|
3259
|
+
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;
|
|
3260
|
+
switch (r = 0, o && (c = [2 & c[0], o.value]), c[0]) {
|
|
3261
3261
|
case 0:
|
|
3262
3262
|
case 1:
|
|
3263
|
-
|
|
3263
|
+
o = c;
|
|
3264
3264
|
break;
|
|
3265
3265
|
case 4:
|
|
3266
|
-
return t.label++, { value:
|
|
3266
|
+
return t.label++, { value: c[1], done: !1 };
|
|
3267
3267
|
case 5:
|
|
3268
|
-
t.label++, r =
|
|
3268
|
+
t.label++, r = c[1], c = [0];
|
|
3269
3269
|
continue;
|
|
3270
3270
|
case 7:
|
|
3271
|
-
|
|
3271
|
+
c = t.ops.pop(), t.trys.pop();
|
|
3272
3272
|
continue;
|
|
3273
3273
|
default:
|
|
3274
|
-
if (
|
|
3274
|
+
if (o = t.trys, !((o = o.length > 0 && o[o.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
|
|
3275
3275
|
t = 0;
|
|
3276
3276
|
continue;
|
|
3277
3277
|
}
|
|
3278
|
-
if (
|
|
3279
|
-
t.label =
|
|
3278
|
+
if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
|
|
3279
|
+
t.label = c[1];
|
|
3280
3280
|
break;
|
|
3281
3281
|
}
|
|
3282
|
-
if (
|
|
3283
|
-
t.label =
|
|
3282
|
+
if (c[0] === 6 && t.label < o[1]) {
|
|
3283
|
+
t.label = o[1], o = c;
|
|
3284
3284
|
break;
|
|
3285
3285
|
}
|
|
3286
|
-
if (
|
|
3287
|
-
t.label =
|
|
3286
|
+
if (o && t.label < o[2]) {
|
|
3287
|
+
t.label = o[2], t.ops.push(c);
|
|
3288
3288
|
break;
|
|
3289
3289
|
}
|
|
3290
|
-
|
|
3290
|
+
o[2] && t.ops.pop(), t.trys.pop();
|
|
3291
3291
|
continue;
|
|
3292
3292
|
}
|
|
3293
|
-
|
|
3294
|
-
} catch (
|
|
3295
|
-
|
|
3293
|
+
c = e.call(a, t);
|
|
3294
|
+
} catch (g) {
|
|
3295
|
+
c = [6, g], r = 0;
|
|
3296
3296
|
} finally {
|
|
3297
|
-
n =
|
|
3297
|
+
n = o = 0;
|
|
3298
3298
|
}
|
|
3299
|
-
if (5 &
|
|
3300
|
-
return { value:
|
|
3301
|
-
}([
|
|
3299
|
+
if (5 & c[0]) throw c[1];
|
|
3300
|
+
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
3301
|
+
}([l, s]);
|
|
3302
3302
|
};
|
|
3303
3303
|
}
|
|
3304
3304
|
}
|
|
3305
|
-
var S = { exclude: [] },
|
|
3306
|
-
typeof window < "u" && (
|
|
3305
|
+
var S = { exclude: [] }, U = {}, v = function(a, e) {
|
|
3306
|
+
typeof window < "u" && (U[a] = e);
|
|
3307
3307
|
};
|
|
3308
|
-
function
|
|
3308
|
+
function I(a) {
|
|
3309
3309
|
return a ^= a >>> 16, a = Math.imul(a, 2246822507), a ^= a >>> 13, a = Math.imul(a, 3266489909), (a ^= a >>> 16) >>> 0;
|
|
3310
3310
|
}
|
|
3311
3311
|
var m = new Uint32Array([597399067, 2869860233, 951274213, 2716044179]);
|
|
3312
|
-
function
|
|
3312
|
+
function p(a, e) {
|
|
3313
3313
|
return a << e | a >>> 32 - e;
|
|
3314
3314
|
}
|
|
3315
|
-
function
|
|
3315
|
+
function R(a, e) {
|
|
3316
3316
|
var n;
|
|
3317
3317
|
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");
|
|
3318
3318
|
var r = new Uint32Array([e, e, e, e]);
|
|
3319
|
-
(((function(
|
|
3320
|
-
for (var u =
|
|
3321
|
-
var
|
|
3322
|
-
|
|
3323
|
-
}
|
|
3324
|
-
})))(a, r), function(
|
|
3325
|
-
var u =
|
|
3326
|
-
switch (
|
|
3319
|
+
(((function(i, t) {
|
|
3320
|
+
for (var u = i.byteLength / 16 | 0, l = new Uint32Array(i, 0, 4 * u), s = 0; s < u; s++) {
|
|
3321
|
+
var c = l.subarray(4 * s, 4 * (s + 1));
|
|
3322
|
+
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;
|
|
3323
|
+
}
|
|
3324
|
+
})))(a, r), function(i, t) {
|
|
3325
|
+
var u = i.byteLength / 16 | 0, l = i.byteLength % 16, s = new Uint32Array(4), c = new Uint8Array(i, 16 * u, l);
|
|
3326
|
+
switch (l) {
|
|
3327
3327
|
case 15:
|
|
3328
|
-
|
|
3328
|
+
s[3] = s[3] ^ c[14] << 16;
|
|
3329
3329
|
case 14:
|
|
3330
|
-
|
|
3330
|
+
s[3] = s[3] ^ c[13] << 8;
|
|
3331
3331
|
case 13:
|
|
3332
|
-
|
|
3332
|
+
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];
|
|
3333
3333
|
case 12:
|
|
3334
|
-
|
|
3334
|
+
s[2] = s[2] ^ c[11] << 24;
|
|
3335
3335
|
case 11:
|
|
3336
|
-
|
|
3336
|
+
s[2] = s[2] ^ c[10] << 16;
|
|
3337
3337
|
case 10:
|
|
3338
|
-
|
|
3338
|
+
s[2] = s[2] ^ c[9] << 8;
|
|
3339
3339
|
case 9:
|
|
3340
|
-
|
|
3340
|
+
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];
|
|
3341
3341
|
case 8:
|
|
3342
|
-
|
|
3342
|
+
s[1] = s[1] ^ c[7] << 24;
|
|
3343
3343
|
case 7:
|
|
3344
|
-
|
|
3344
|
+
s[1] = s[1] ^ c[6] << 16;
|
|
3345
3345
|
case 6:
|
|
3346
|
-
|
|
3346
|
+
s[1] = s[1] ^ c[5] << 8;
|
|
3347
3347
|
case 5:
|
|
3348
|
-
|
|
3348
|
+
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];
|
|
3349
3349
|
case 4:
|
|
3350
|
-
|
|
3350
|
+
s[0] = s[0] ^ c[3] << 24;
|
|
3351
3351
|
case 3:
|
|
3352
|
-
|
|
3352
|
+
s[0] = s[0] ^ c[2] << 16;
|
|
3353
3353
|
case 2:
|
|
3354
|
-
|
|
3354
|
+
s[0] = s[0] ^ c[1] << 8;
|
|
3355
3355
|
case 1:
|
|
3356
|
-
|
|
3356
|
+
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];
|
|
3357
3357
|
}
|
|
3358
|
-
}(a, r), function(
|
|
3359
|
-
t[0] = t[0] ^
|
|
3358
|
+
}(a, r), function(i, t) {
|
|
3359
|
+
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;
|
|
3360
3360
|
}(a, r);
|
|
3361
|
-
var
|
|
3362
|
-
return Array.from(
|
|
3363
|
-
return
|
|
3361
|
+
var o = new Uint8Array(r.buffer);
|
|
3362
|
+
return Array.from(o).map(function(i) {
|
|
3363
|
+
return i.toString(16).padStart(2, "0");
|
|
3364
3364
|
}).join("");
|
|
3365
3365
|
}
|
|
3366
3366
|
function H(a) {
|
|
@@ -3368,9 +3368,9 @@ function H(a) {
|
|
|
3368
3368
|
return e;
|
|
3369
3369
|
}
|
|
3370
3370
|
function L(a, e, n) {
|
|
3371
|
-
for (var r = [],
|
|
3372
|
-
for (var
|
|
3373
|
-
r.push(Q(
|
|
3371
|
+
for (var r = [], o = 0; o < a[0].data.length; o++) {
|
|
3372
|
+
for (var i = [], t = 0; t < a.length; t++) i.push(a[t].data[o]);
|
|
3373
|
+
r.push(Q(i));
|
|
3374
3374
|
}
|
|
3375
3375
|
var u = new Uint8ClampedArray(r);
|
|
3376
3376
|
return new ImageData(u, e, n);
|
|
@@ -3378,73 +3378,73 @@ function L(a, e, n) {
|
|
|
3378
3378
|
function Q(a) {
|
|
3379
3379
|
if (a.length === 0) return 0;
|
|
3380
3380
|
for (var e = {}, n = 0, r = a; n < r.length; n++)
|
|
3381
|
-
e[
|
|
3382
|
-
var
|
|
3383
|
-
for (var
|
|
3384
|
-
return
|
|
3381
|
+
e[i = r[n]] = (e[i] || 0) + 1;
|
|
3382
|
+
var o = a[0];
|
|
3383
|
+
for (var i in e) e[i] > e[o] && (o = parseInt(i, 10));
|
|
3384
|
+
return o;
|
|
3385
3385
|
}
|
|
3386
|
-
function
|
|
3386
|
+
function A() {
|
|
3387
3387
|
if (typeof navigator > "u") return { name: "unknown", version: "unknown" };
|
|
3388
3388
|
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++) {
|
|
3389
|
-
var
|
|
3390
|
-
if (
|
|
3389
|
+
var o = r[n], i = a.match(o);
|
|
3390
|
+
if (i && i.groups) return { name: e[i.groups.name] || i.groups.name, version: i.groups.version };
|
|
3391
3391
|
}
|
|
3392
3392
|
return { name: "unknown", version: "unknown" };
|
|
3393
3393
|
}
|
|
3394
3394
|
v("audio", function() {
|
|
3395
|
-
return
|
|
3396
|
-
return
|
|
3395
|
+
return w(this, void 0, void 0, function() {
|
|
3396
|
+
return y(this, function(a) {
|
|
3397
3397
|
return [2, new Promise(function(e, n) {
|
|
3398
3398
|
try {
|
|
3399
|
-
var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100),
|
|
3400
|
-
|
|
3399
|
+
var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100), o = r.createBufferSource(), i = r.createOscillator();
|
|
3400
|
+
i.frequency.value = 1e3;
|
|
3401
3401
|
var t, u = r.createDynamicsCompressor();
|
|
3402
|
-
u.threshold.value = -50, u.knee.value = 40, u.ratio.value = 12, u.attack.value = 0, u.release.value = 0.2,
|
|
3403
|
-
t =
|
|
3402
|
+
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) {
|
|
3403
|
+
t = l.renderedBuffer.getChannelData(0), e({ sampleHash: H(t), oscillator: i.type, maxChannels: r.destination.maxChannelCount, channelCountMode: o.channelCountMode });
|
|
3404
3404
|
}, r.startRendering();
|
|
3405
|
-
} catch (
|
|
3406
|
-
console.error("Error creating audio fingerprint:",
|
|
3405
|
+
} catch (l) {
|
|
3406
|
+
console.error("Error creating audio fingerprint:", l), n(l);
|
|
3407
3407
|
}
|
|
3408
3408
|
})];
|
|
3409
3409
|
});
|
|
3410
3410
|
});
|
|
3411
3411
|
});
|
|
3412
|
-
var K =
|
|
3413
|
-
|
|
3412
|
+
var K = A().name !== "SamsungBrowser" ? 1 : 3, k = 280, F = 20;
|
|
3413
|
+
A().name != "Firefox" && v("canvas", function() {
|
|
3414
3414
|
return document.createElement("canvas").getContext("2d"), new Promise(function(a) {
|
|
3415
3415
|
var e = Array.from({ length: K }, function() {
|
|
3416
3416
|
return function() {
|
|
3417
3417
|
var n = document.createElement("canvas"), r = n.getContext("2d");
|
|
3418
3418
|
if (!r) return new ImageData(1, 1);
|
|
3419
|
-
n.width =
|
|
3420
|
-
var
|
|
3421
|
-
|
|
3422
|
-
var
|
|
3423
|
-
r.font = "23.123px Arial", r.fillStyle = "black", r.fillText(
|
|
3419
|
+
n.width = k, n.height = F;
|
|
3420
|
+
var o = r.createLinearGradient(0, 0, n.width, n.height);
|
|
3421
|
+
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);
|
|
3422
|
+
var i = "Random Text WMwmil10Oo";
|
|
3423
|
+
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();
|
|
3424
3424
|
var t = r.getImageData(0, 0, n.width, n.height);
|
|
3425
3425
|
return t;
|
|
3426
3426
|
}();
|
|
3427
3427
|
});
|
|
3428
|
-
a({ commonImageDataHash:
|
|
3428
|
+
a({ commonImageDataHash: R(L(e, k, F).data.toString()).toString() });
|
|
3429
3429
|
});
|
|
3430
3430
|
});
|
|
3431
|
-
var
|
|
3432
|
-
function
|
|
3431
|
+
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"];
|
|
3432
|
+
function O(a, e) {
|
|
3433
3433
|
if (!a) throw new Error("Canvas context not supported");
|
|
3434
3434
|
return a.font = "72px ".concat(e), a.measureText("WwMmLli0Oo").width;
|
|
3435
3435
|
}
|
|
3436
3436
|
function Y() {
|
|
3437
3437
|
var a, e = document.createElement("canvas"), n = (a = e.getContext("webgl")) !== null && a !== void 0 ? a : e.getContext("experimental-webgl");
|
|
3438
3438
|
if (n && "getParameter" in n) try {
|
|
3439
|
-
var r = (n.getParameter(n.VENDOR) || "").toString(),
|
|
3440
|
-
if (!
|
|
3439
|
+
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() };
|
|
3440
|
+
if (!o.length || !r.length) {
|
|
3441
3441
|
var t = n.getExtension("WEBGL_debug_renderer_info");
|
|
3442
3442
|
if (t) {
|
|
3443
|
-
var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(),
|
|
3444
|
-
u && (
|
|
3443
|
+
var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(), l = (n.getParameter(t.UNMASKED_RENDERER_WEBGL) || "").toString();
|
|
3444
|
+
u && (i.vendorUnmasked = u), l && (i.rendererUnmasked = l);
|
|
3445
3445
|
}
|
|
3446
3446
|
}
|
|
3447
|
-
return
|
|
3447
|
+
return i;
|
|
3448
3448
|
} catch {
|
|
3449
3449
|
}
|
|
3450
3450
|
return "undefined";
|
|
@@ -3456,23 +3456,23 @@ function Z() {
|
|
|
3456
3456
|
function ee(a, e) {
|
|
3457
3457
|
var n = {};
|
|
3458
3458
|
return e.forEach(function(r) {
|
|
3459
|
-
var
|
|
3460
|
-
if (
|
|
3459
|
+
var o = function(i) {
|
|
3460
|
+
if (i.length === 0) return null;
|
|
3461
3461
|
var t = {};
|
|
3462
|
-
|
|
3463
|
-
var
|
|
3464
|
-
t[
|
|
3462
|
+
i.forEach(function(s) {
|
|
3463
|
+
var c = String(s);
|
|
3464
|
+
t[c] = (t[c] || 0) + 1;
|
|
3465
3465
|
});
|
|
3466
|
-
var u =
|
|
3467
|
-
return Object.keys(t).forEach(function(
|
|
3468
|
-
t[
|
|
3466
|
+
var u = i[0], l = 1;
|
|
3467
|
+
return Object.keys(t).forEach(function(s) {
|
|
3468
|
+
t[s] > l && (u = s, l = t[s]);
|
|
3469
3469
|
}), u;
|
|
3470
|
-
}(a.map(function(
|
|
3471
|
-
return r in
|
|
3472
|
-
}).filter(function(
|
|
3473
|
-
return
|
|
3470
|
+
}(a.map(function(i) {
|
|
3471
|
+
return r in i ? i[r] : void 0;
|
|
3472
|
+
}).filter(function(i) {
|
|
3473
|
+
return i !== void 0;
|
|
3474
3474
|
}));
|
|
3475
|
-
|
|
3475
|
+
o && (n[r] = o);
|
|
3476
3476
|
}), n;
|
|
3477
3477
|
}
|
|
3478
3478
|
function te() {
|
|
@@ -3491,42 +3491,42 @@ function ne() {
|
|
|
3491
3491
|
}
|
|
3492
3492
|
return 0;
|
|
3493
3493
|
}
|
|
3494
|
-
|
|
3494
|
+
A().name != "Firefox" && v("fonts", function() {
|
|
3495
3495
|
var a = this;
|
|
3496
3496
|
return new Promise(function(e, n) {
|
|
3497
3497
|
try {
|
|
3498
3498
|
(function(r) {
|
|
3499
|
-
var
|
|
3500
|
-
|
|
3501
|
-
var
|
|
3502
|
-
return
|
|
3503
|
-
switch (
|
|
3499
|
+
var o;
|
|
3500
|
+
w(this, void 0, void 0, function() {
|
|
3501
|
+
var i, t, u;
|
|
3502
|
+
return y(this, function(l) {
|
|
3503
|
+
switch (l.label) {
|
|
3504
3504
|
case 0:
|
|
3505
|
-
return document.body ? [3, 2] : [4, (
|
|
3506
|
-
return setTimeout(
|
|
3505
|
+
return document.body ? [3, 2] : [4, (s = 50, new Promise(function(g) {
|
|
3506
|
+
return setTimeout(g, s, c);
|
|
3507
3507
|
}))];
|
|
3508
3508
|
case 1:
|
|
3509
|
-
return
|
|
3509
|
+
return l.sent(), [3, 0];
|
|
3510
3510
|
case 2:
|
|
3511
|
-
if ((
|
|
3511
|
+
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");
|
|
3512
3512
|
return r({ iframe: u }), setTimeout(function() {
|
|
3513
|
-
document.body.removeChild(
|
|
3513
|
+
document.body.removeChild(i);
|
|
3514
3514
|
}, 0), [2];
|
|
3515
3515
|
}
|
|
3516
|
-
var
|
|
3516
|
+
var s, c;
|
|
3517
3517
|
});
|
|
3518
3518
|
});
|
|
3519
3519
|
})(function(r) {
|
|
3520
|
-
var
|
|
3521
|
-
return
|
|
3522
|
-
var
|
|
3523
|
-
return
|
|
3524
|
-
return
|
|
3525
|
-
return
|
|
3526
|
-
}),
|
|
3527
|
-
var
|
|
3528
|
-
u.includes(
|
|
3529
|
-
}), e(
|
|
3520
|
+
var o = r.iframe;
|
|
3521
|
+
return w(a, void 0, void 0, function() {
|
|
3522
|
+
var i, t, u, l;
|
|
3523
|
+
return y(this, function(s) {
|
|
3524
|
+
return i = o.createElement("canvas"), t = i.getContext("2d"), u = J.map(function(c) {
|
|
3525
|
+
return O(t, c);
|
|
3526
|
+
}), l = {}, X.forEach(function(c) {
|
|
3527
|
+
var g = O(t, c);
|
|
3528
|
+
u.includes(g) || (l[c] = g);
|
|
3529
|
+
}), e(l), [2];
|
|
3530
3530
|
});
|
|
3531
3531
|
});
|
|
3532
3532
|
});
|
|
@@ -3544,24 +3544,24 @@ C().name != "Firefox" && v("fonts", function() {
|
|
|
3544
3544
|
a({ languages: navigator.language, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
|
|
3545
3545
|
});
|
|
3546
3546
|
}), v("permissions", function() {
|
|
3547
|
-
return
|
|
3547
|
+
return w(this, void 0, void 0, function() {
|
|
3548
3548
|
var a;
|
|
3549
|
-
return
|
|
3550
|
-
return
|
|
3549
|
+
return y(this, function(e) {
|
|
3550
|
+
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() {
|
|
3551
3551
|
return function() {
|
|
3552
|
-
return
|
|
3553
|
-
var n, r,
|
|
3554
|
-
return
|
|
3552
|
+
return w(this, void 0, void 0, function() {
|
|
3553
|
+
var n, r, o, i, t;
|
|
3554
|
+
return y(this, function(u) {
|
|
3555
3555
|
switch (u.label) {
|
|
3556
3556
|
case 0:
|
|
3557
|
-
n = {}, r = 0,
|
|
3557
|
+
n = {}, r = 0, o = M, u.label = 1;
|
|
3558
3558
|
case 1:
|
|
3559
|
-
if (!(r <
|
|
3560
|
-
|
|
3559
|
+
if (!(r < o.length)) return [3, 6];
|
|
3560
|
+
i = o[r], u.label = 2;
|
|
3561
3561
|
case 2:
|
|
3562
|
-
return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name:
|
|
3562
|
+
return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name: i })];
|
|
3563
3563
|
case 3:
|
|
3564
|
-
return t = u.sent(), n[
|
|
3564
|
+
return t = u.sent(), n[i] = t.state.toString(), [3, 5];
|
|
3565
3565
|
case 4:
|
|
3566
3566
|
return u.sent(), [3, 5];
|
|
3567
3567
|
case 5:
|
|
@@ -3573,7 +3573,7 @@ C().name != "Firefox" && v("fonts", function() {
|
|
|
3573
3573
|
});
|
|
3574
3574
|
}();
|
|
3575
3575
|
}), [2, Promise.all(a).then(function(n) {
|
|
3576
|
-
return ee(n,
|
|
3576
|
+
return ee(n, M);
|
|
3577
3577
|
})];
|
|
3578
3578
|
});
|
|
3579
3579
|
});
|
|
@@ -3592,22 +3592,22 @@ C().name != "Firefox" && v("fonts", function() {
|
|
|
3592
3592
|
});
|
|
3593
3593
|
}), v("system", function() {
|
|
3594
3594
|
return new Promise(function(a) {
|
|
3595
|
-
var e =
|
|
3595
|
+
var e = A();
|
|
3596
3596
|
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() });
|
|
3597
3597
|
});
|
|
3598
3598
|
});
|
|
3599
|
-
var f, re =
|
|
3599
|
+
var f, re = A().name !== "SamsungBrowser" ? 1 : 3, d = null;
|
|
3600
3600
|
v("webgl", function() {
|
|
3601
|
-
return
|
|
3601
|
+
return w(this, void 0, void 0, function() {
|
|
3602
3602
|
var a;
|
|
3603
|
-
return
|
|
3604
|
-
typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100,
|
|
3603
|
+
return y(this, function(e) {
|
|
3604
|
+
typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100, d = f.getContext("webgl"));
|
|
3605
3605
|
try {
|
|
3606
|
-
if (!
|
|
3606
|
+
if (!d) throw new Error("WebGL not supported");
|
|
3607
3607
|
return a = Array.from({ length: re }, function() {
|
|
3608
3608
|
return function() {
|
|
3609
3609
|
try {
|
|
3610
|
-
if (!
|
|
3610
|
+
if (!d) throw new Error("WebGL not supported");
|
|
3611
3611
|
var n = `
|
|
3612
3612
|
attribute vec2 position;
|
|
3613
3613
|
void main() {
|
|
@@ -3618,31 +3618,31 @@ v("webgl", function() {
|
|
|
3618
3618
|
void main() {
|
|
3619
3619
|
gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
|
|
3620
3620
|
}
|
|
3621
|
-
`,
|
|
3622
|
-
if (!
|
|
3623
|
-
if (
|
|
3624
|
-
if (
|
|
3625
|
-
var t =
|
|
3621
|
+
`, o = d.createShader(d.VERTEX_SHADER), i = d.createShader(d.FRAGMENT_SHADER);
|
|
3622
|
+
if (!o || !i) throw new Error("Failed to create shaders");
|
|
3623
|
+
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));
|
|
3624
|
+
if (d.compileShader(i), !d.getShaderParameter(i, d.COMPILE_STATUS)) throw new Error("Fragment shader compilation failed: " + d.getShaderInfoLog(i));
|
|
3625
|
+
var t = d.createProgram();
|
|
3626
3626
|
if (!t) throw new Error("Failed to create shader program");
|
|
3627
|
-
if (
|
|
3628
|
-
|
|
3629
|
-
for (var u = 137,
|
|
3630
|
-
var
|
|
3631
|
-
|
|
3627
|
+
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));
|
|
3628
|
+
d.useProgram(t);
|
|
3629
|
+
for (var u = 137, l = new Float32Array(4 * u), s = 2 * Math.PI / u, c = 0; c < u; c++) {
|
|
3630
|
+
var g = c * s;
|
|
3631
|
+
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);
|
|
3632
3632
|
}
|
|
3633
|
-
var
|
|
3634
|
-
|
|
3635
|
-
var
|
|
3636
|
-
|
|
3637
|
-
var
|
|
3638
|
-
return
|
|
3633
|
+
var T = d.createBuffer();
|
|
3634
|
+
d.bindBuffer(d.ARRAY_BUFFER, T), d.bufferData(d.ARRAY_BUFFER, l, d.STATIC_DRAW);
|
|
3635
|
+
var E = d.getAttribLocation(t, "position");
|
|
3636
|
+
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);
|
|
3637
|
+
var P = new Uint8ClampedArray(f.width * f.height * 4);
|
|
3638
|
+
return d.readPixels(0, 0, f.width, f.height, d.RGBA, d.UNSIGNED_BYTE, P), new ImageData(P, f.width, f.height);
|
|
3639
3639
|
} catch {
|
|
3640
3640
|
return new ImageData(1, 1);
|
|
3641
3641
|
} finally {
|
|
3642
|
-
|
|
3642
|
+
d && (d.bindBuffer(d.ARRAY_BUFFER, null), d.useProgram(null), d.viewport(0, 0, d.drawingBufferWidth, d.drawingBufferHeight), d.clearColor(0, 0, 0, 0));
|
|
3643
3643
|
}
|
|
3644
3644
|
}();
|
|
3645
|
-
}), [2, { commonImageHash:
|
|
3645
|
+
}), [2, { commonImageHash: R(L(a, f.width, f.height).data.toString()).toString() }];
|
|
3646
3646
|
} catch {
|
|
3647
3647
|
return [2, { webgl: "unsupported" }];
|
|
3648
3648
|
}
|
|
@@ -3651,13 +3651,13 @@ v("webgl", function() {
|
|
|
3651
3651
|
});
|
|
3652
3652
|
});
|
|
3653
3653
|
var b = function(a, e, n, r) {
|
|
3654
|
-
for (var
|
|
3655
|
-
|
|
3656
|
-
return
|
|
3654
|
+
for (var o = (n - e) / r, i = 0, t = 0; t < r; t++)
|
|
3655
|
+
i += a(e + (t + 0.5) * o);
|
|
3656
|
+
return i * o;
|
|
3657
3657
|
};
|
|
3658
3658
|
v("math", function() {
|
|
3659
|
-
return
|
|
3660
|
-
return
|
|
3659
|
+
return w(void 0, void 0, void 0, function() {
|
|
3660
|
+
return y(this, function(a) {
|
|
3661
3661
|
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) }];
|
|
3662
3662
|
});
|
|
3663
3663
|
});
|
|
@@ -3677,6 +3677,7 @@ const initialSearchcraftStateValues = {
|
|
|
3677
3677
|
rangeValueForIndexFields: {},
|
|
3678
3678
|
searchTerm: '',
|
|
3679
3679
|
searchMode: 'fuzzy',
|
|
3680
|
+
searchClientRequest: undefined,
|
|
3680
3681
|
searchClientResponseItems: [],
|
|
3681
3682
|
searchResponseTimeTaken: undefined,
|
|
3682
3683
|
searchResponseFacetPrime: undefined,
|
|
@@ -3713,7 +3714,7 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3713
3714
|
},
|
|
3714
3715
|
init: (core, debug = false) => {
|
|
3715
3716
|
const logger = debug
|
|
3716
|
-
? new pe({ logLevel:
|
|
3717
|
+
? new pe({ logLevel: D.DEBUG })
|
|
3717
3718
|
: undefined;
|
|
3718
3719
|
const state = functions.set({
|
|
3719
3720
|
core,
|
|
@@ -3751,12 +3752,12 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3751
3752
|
},
|
|
3752
3753
|
search: async () => {
|
|
3753
3754
|
const state = get();
|
|
3754
|
-
state.logger?.log(
|
|
3755
|
+
state.logger?.log(D.INFO, `Starting search with search term: "${state.searchTerm}"`);
|
|
3755
3756
|
if (!state.core) {
|
|
3756
3757
|
throw new Error('Searchcraft instance is not initialized.');
|
|
3757
3758
|
}
|
|
3758
3759
|
if (!state.searchTerm.trim()) {
|
|
3759
|
-
state.logger?.log(
|
|
3760
|
+
state.logger?.log(D.INFO, 'No search request was made: search term was empty.');
|
|
3760
3761
|
functions.set({
|
|
3761
3762
|
searchClientResponseItems: [],
|
|
3762
3763
|
searchResultsCount: 0,
|
|
@@ -3780,7 +3781,7 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3780
3781
|
}, functions.setSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
|
|
3781
3782
|
},
|
|
3782
3783
|
setAdClientResponseItems: (items) => functions.set({ adClientResponseItems: items }),
|
|
3783
|
-
setSearchClientResponseItemsFromResponse: (response, items, supplementalResponse) => {
|
|
3784
|
+
setSearchClientResponseItemsFromResponse: (request, response, items, supplementalResponse) => {
|
|
3784
3785
|
const { facets, count = 0, time_taken = 0 } = response.data;
|
|
3785
3786
|
const state = functions.set((state) => {
|
|
3786
3787
|
return {
|
|
@@ -3793,12 +3794,13 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3793
3794
|
searchResultsCount: count,
|
|
3794
3795
|
searchResponseFacetPrime: facets,
|
|
3795
3796
|
supplementalFacetPrime: supplementalResponse?.data.facets,
|
|
3797
|
+
searchClientRequest: request,
|
|
3796
3798
|
};
|
|
3797
3799
|
});
|
|
3798
|
-
state.logger?.log(
|
|
3799
|
-
state.logger?.log(
|
|
3800
|
+
state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
|
|
3801
|
+
state.logger?.log(D.DEBUG, `Facets from response: ${JSON.stringify(facets)}`);
|
|
3800
3802
|
},
|
|
3801
|
-
setInitialSearchClientResponseItemsFromResponse: (response, items) => {
|
|
3803
|
+
setInitialSearchClientResponseItemsFromResponse: (request, response, items) => {
|
|
3802
3804
|
const state = get();
|
|
3803
3805
|
const { count = 0, time_taken = 0 } = response.data;
|
|
3804
3806
|
functions.set((state) => {
|
|
@@ -3810,13 +3812,14 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3810
3812
|
// Reset to first page when response count changes
|
|
3811
3813
|
count === state.searchResultsCount ? state.searchResultsPage : 1,
|
|
3812
3814
|
searchResultsCount: count,
|
|
3815
|
+
searchClientRequest: request,
|
|
3813
3816
|
};
|
|
3814
3817
|
});
|
|
3815
|
-
state.logger?.log(
|
|
3818
|
+
state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
|
|
3816
3819
|
},
|
|
3817
3820
|
setInitialQuery: async (query) => {
|
|
3818
3821
|
const state = functions.set({ initialQuery: query });
|
|
3819
|
-
state.logger?.log(
|
|
3822
|
+
state.logger?.log(D.INFO, `Starting search with query: "${state.initialQuery}"`);
|
|
3820
3823
|
if (!state.core) {
|
|
3821
3824
|
throw new Error('Searchcraft instance is not initialized.');
|
|
3822
3825
|
}
|
|
@@ -3837,12 +3840,6 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3837
3840
|
*/
|
|
3838
3841
|
functions.set({
|
|
3839
3842
|
searchTerm,
|
|
3840
|
-
facetPathsForIndexFields: {},
|
|
3841
|
-
...(searchTerm.trim().length === 0 && {
|
|
3842
|
-
searchMode: 'fuzzy',
|
|
3843
|
-
sortType: null,
|
|
3844
|
-
orderByField: null,
|
|
3845
|
-
}),
|
|
3846
3843
|
});
|
|
3847
3844
|
},
|
|
3848
3845
|
setSearchClientResponseItems: (items) => functions.set({ searchClientResponseItems: items }),
|
|
@@ -3874,7 +3871,7 @@ const searchcraftStore = zustand.createStore((_set, get) => {
|
|
|
3874
3871
|
* Helper function for getting a Node (FacetWithChildrenObject)
|
|
3875
3872
|
* at a given path. Traverses the node tree to get the node.
|
|
3876
3873
|
*/
|
|
3877
|
-
const
|
|
3874
|
+
const getFacetTreeNodeAtPath = (tree, nodePaths) => {
|
|
3878
3875
|
let cursor = tree;
|
|
3879
3876
|
for (const nodePath of nodePaths) {
|
|
3880
3877
|
cursor = cursor?.children[nodePath];
|
|
@@ -3919,7 +3916,7 @@ const mergeFacetTrees = (currentTree, incomingTree) => {
|
|
|
3919
3916
|
const mergedTree = structuredClone(currentTree);
|
|
3920
3917
|
const merge = (currentBranch, nodePath) => {
|
|
3921
3918
|
const mergedBranch = structuredClone(currentBranch);
|
|
3922
|
-
const incomingBranch =
|
|
3919
|
+
const incomingBranch = getFacetTreeNodeAtPath(incomingTree, nodePath);
|
|
3923
3920
|
if (!incomingBranch) {
|
|
3924
3921
|
return mergedBranch;
|
|
3925
3922
|
}
|
|
@@ -5565,17 +5562,35 @@ class SearchcraftFacetList {
|
|
|
5565
5562
|
*/
|
|
5566
5563
|
facetSelectionUpdated;
|
|
5567
5564
|
/**
|
|
5568
|
-
*
|
|
5565
|
+
* The currently selected facet paths.
|
|
5566
|
+
*/
|
|
5567
|
+
selectedPaths = {};
|
|
5568
|
+
/**
|
|
5569
|
+
* A Tree representing all of the facets collected from search responses.
|
|
5569
5570
|
*/
|
|
5570
|
-
|
|
5571
|
+
facetTreeCollectedFromSearchResponse = {
|
|
5571
5572
|
path: '/',
|
|
5572
5573
|
count: 0,
|
|
5573
5574
|
children: {},
|
|
5574
5575
|
};
|
|
5575
5576
|
/**
|
|
5576
|
-
*
|
|
5577
|
+
* A Tree representing the facet paths that are selected, but were not included
|
|
5578
|
+
* in any search response.
|
|
5577
5579
|
*/
|
|
5578
|
-
|
|
5580
|
+
facetTreeFromFacetPathsNotInSearchResponse = {
|
|
5581
|
+
path: '/',
|
|
5582
|
+
count: 0,
|
|
5583
|
+
children: {},
|
|
5584
|
+
};
|
|
5585
|
+
/**
|
|
5586
|
+
* The facet tree that ultimately gets rendered.
|
|
5587
|
+
* This is a mergin of the facetTreeCollectedFromSearchResponse and the facetTreeFromFacetPathsNotInSearchResponse tree
|
|
5588
|
+
*/
|
|
5589
|
+
renderedFacetTree = {
|
|
5590
|
+
path: '/',
|
|
5591
|
+
count: 0,
|
|
5592
|
+
children: {},
|
|
5593
|
+
};
|
|
5579
5594
|
// Internal vars used to track when to perform various facet actions.
|
|
5580
5595
|
lastTimeTaken;
|
|
5581
5596
|
lastSearchTerm;
|
|
@@ -5584,6 +5599,9 @@ class SearchcraftFacetList {
|
|
|
5584
5599
|
lastRangeValues;
|
|
5585
5600
|
lastFacetValues;
|
|
5586
5601
|
unsubscribe;
|
|
5602
|
+
get areAnyFacetPathsSelected() {
|
|
5603
|
+
return Object.keys(this.selectedPaths).some((key) => this.selectedPaths[key]);
|
|
5604
|
+
}
|
|
5587
5605
|
handleIncomingSearchResponse(state, actionType) {
|
|
5588
5606
|
// Look at the incoming facet root from the search response, and convert it to a FacetTree
|
|
5589
5607
|
const incomingFacetRoot = state.searchResponseFacetPrime?.find((facet) => this.fieldName === Object.keys(facet)[0]);
|
|
@@ -5593,18 +5611,20 @@ class SearchcraftFacetList {
|
|
|
5593
5611
|
count: 0,
|
|
5594
5612
|
children: incomingFacetsWithChildrenArray || [],
|
|
5595
5613
|
});
|
|
5596
|
-
// Determine what action to take
|
|
5614
|
+
// Determine what action to take to accumulate items into the `facetTreeCollectedFromSearchResponse`.
|
|
5615
|
+
// This facet tree gets accumulated in different ways depending on what action type occured.
|
|
5597
5616
|
switch (actionType) {
|
|
5598
5617
|
case 'SEARCH_TERM_EMPTY':
|
|
5599
|
-
this.
|
|
5618
|
+
this.facetTreeCollectedFromSearchResponse = {
|
|
5600
5619
|
path: '/',
|
|
5601
5620
|
count: 0,
|
|
5602
5621
|
children: {},
|
|
5603
5622
|
};
|
|
5604
5623
|
break;
|
|
5605
5624
|
case 'NEW_SEARCH_TERM':
|
|
5606
|
-
this.
|
|
5625
|
+
this.facetTreeCollectedFromSearchResponse = incomingFacetTree;
|
|
5607
5626
|
break;
|
|
5627
|
+
case 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE':
|
|
5608
5628
|
case 'EXACT_MATCH_UPDATE':
|
|
5609
5629
|
case 'RANGE_VALUE_UPDATE': {
|
|
5610
5630
|
if (state.supplementalFacetPrime) {
|
|
@@ -5615,53 +5635,95 @@ class SearchcraftFacetList {
|
|
|
5615
5635
|
count: 0,
|
|
5616
5636
|
children: supplementalFacetsWithChildrenArray || [],
|
|
5617
5637
|
});
|
|
5618
|
-
this.
|
|
5638
|
+
this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(supplementalFacetTree, incomingFacetTree);
|
|
5619
5639
|
}
|
|
5620
5640
|
else {
|
|
5621
|
-
this.
|
|
5641
|
+
this.facetTreeCollectedFromSearchResponse = incomingFacetTree;
|
|
5622
5642
|
}
|
|
5623
5643
|
break;
|
|
5624
5644
|
}
|
|
5625
5645
|
case 'FACET_UPDATE':
|
|
5626
5646
|
case 'SORT_ORDER_UPDATE':
|
|
5627
|
-
this.
|
|
5647
|
+
this.facetTreeCollectedFromSearchResponse = mergeFacetTrees(this.facetTreeCollectedFromSearchResponse, incomingFacetTree);
|
|
5628
5648
|
break;
|
|
5629
5649
|
default:
|
|
5630
|
-
|
|
5650
|
+
return;
|
|
5631
5651
|
}
|
|
5652
|
+
// Determine if there are any selected facet paths not in the current tree.
|
|
5653
|
+
// If there are, we add them to "facetTreeFromFacetPathsNotInSearchResponse"
|
|
5654
|
+
this.facetTreeFromFacetPathsNotInSearchResponse = {
|
|
5655
|
+
path: '/',
|
|
5656
|
+
count: 0,
|
|
5657
|
+
children: {},
|
|
5658
|
+
};
|
|
5659
|
+
const collectedFacetArray = {
|
|
5660
|
+
path: '/',
|
|
5661
|
+
count: 0,
|
|
5662
|
+
children: [],
|
|
5663
|
+
};
|
|
5664
|
+
for (const pathName of Object.keys(this.selectedPaths).filter((path) => this.selectedPaths[path])) {
|
|
5665
|
+
const nodePaths = pathName.startsWith('/')
|
|
5666
|
+
? pathName.substring(1).split('/')
|
|
5667
|
+
: pathName.split('/');
|
|
5668
|
+
const wasFoundInFacetTree = !!getFacetTreeNodeAtPath(this.facetTreeCollectedFromSearchResponse, nodePaths);
|
|
5669
|
+
const pathKeyName = nodePaths.at(-1);
|
|
5670
|
+
if (!wasFoundInFacetTree && pathKeyName) {
|
|
5671
|
+
collectedFacetArray.children?.push({
|
|
5672
|
+
children: [],
|
|
5673
|
+
count: 0,
|
|
5674
|
+
path: pathName,
|
|
5675
|
+
});
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
this.facetTreeFromFacetPathsNotInSearchResponse =
|
|
5679
|
+
facetWithChildrenArrayToCompleteFacetTree(collectedFacetArray);
|
|
5680
|
+
// Merges facetTreeCollectedFromSearchResponse with selectedFacetPathsNotInCurrentFacetTree.
|
|
5681
|
+
// This results in a single, final facet tree that gets rendered in as Checkboxes
|
|
5682
|
+
this.renderedFacetTree = deepMergeWithSpread(this.facetTreeFromFacetPathsNotInSearchResponse, this.facetTreeCollectedFromSearchResponse);
|
|
5632
5683
|
}
|
|
5633
|
-
handleStateUpdate(
|
|
5684
|
+
handleStateUpdate(_state) {
|
|
5685
|
+
const state = { ..._state };
|
|
5634
5686
|
// Determine what action to take based on the current State
|
|
5635
|
-
if (
|
|
5636
|
-
state.searchTerm.trim() === '') {
|
|
5687
|
+
if (state.searchTerm.trim() === '') {
|
|
5637
5688
|
this.handleIncomingSearchResponse(state, 'SEARCH_TERM_EMPTY');
|
|
5689
|
+
this.lastSearchTerm = '';
|
|
5638
5690
|
}
|
|
5639
|
-
else if (this.lastTimeTaken !== state.searchResponseTimeTaken
|
|
5691
|
+
else if (this.lastTimeTaken !== state.searchResponseTimeTaken &&
|
|
5692
|
+
state.searchClientRequest &&
|
|
5693
|
+
typeof state.searchClientRequest === 'object') {
|
|
5694
|
+
const request = state.searchClientRequest;
|
|
5640
5695
|
let actionType = 'UNKNOWN';
|
|
5641
|
-
if (this.lastSearchTerm !==
|
|
5642
|
-
|
|
5696
|
+
if (this.lastSearchTerm !== request.searchTerm) {
|
|
5697
|
+
if (this.areAnyFacetPathsSelected) {
|
|
5698
|
+
actionType = 'NEW_SEARCH_TERM_WHILE_FACETS_ACTIVE';
|
|
5699
|
+
}
|
|
5700
|
+
else {
|
|
5701
|
+
actionType = 'NEW_SEARCH_TERM';
|
|
5702
|
+
}
|
|
5643
5703
|
}
|
|
5644
|
-
else if (this.lastRangeValues !==
|
|
5704
|
+
else if (this.lastRangeValues !==
|
|
5705
|
+
JSON.stringify(request.rangeValueForIndexFields)) {
|
|
5645
5706
|
actionType = 'RANGE_VALUE_UPDATE';
|
|
5646
5707
|
}
|
|
5647
|
-
else if (this.lastFacetValues !==
|
|
5708
|
+
else if (this.lastFacetValues !==
|
|
5709
|
+
JSON.stringify(request.facetPathsForIndexFields)) {
|
|
5648
5710
|
actionType = 'FACET_UPDATE';
|
|
5649
5711
|
}
|
|
5650
|
-
else if (this.lastSortType !==
|
|
5712
|
+
else if (this.lastSortType !== request.order_by) {
|
|
5651
5713
|
actionType = 'SORT_ORDER_UPDATE';
|
|
5652
5714
|
}
|
|
5653
|
-
else if (this.lastSearchMode !==
|
|
5715
|
+
else if (this.lastSearchMode !== request.mode) {
|
|
5654
5716
|
actionType = 'EXACT_MATCH_UPDATE';
|
|
5655
5717
|
}
|
|
5718
|
+
this.lastRangeValues = JSON.stringify(request.rangeValueForIndexFields);
|
|
5719
|
+
this.lastFacetValues = JSON.stringify(request.facetPathsForIndexFields);
|
|
5720
|
+
this.lastSortType = request.order_by;
|
|
5721
|
+
this.lastSearchMode = request.mode;
|
|
5722
|
+
this.lastSearchTerm = request.searchTerm;
|
|
5723
|
+
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
5656
5724
|
// Handle the incoming response, using the action we have determined.
|
|
5657
5725
|
this.handleIncomingSearchResponse(state, actionType);
|
|
5658
|
-
this.lastSearchTerm = state.searchTerm;
|
|
5659
|
-
this.lastRangeValues = JSON.stringify(state.rangeValueForIndexFields);
|
|
5660
|
-
this.lastFacetValues = JSON.stringify(state.facetPathsForIndexFields);
|
|
5661
|
-
this.lastSortType = state.sortType;
|
|
5662
|
-
this.lastSearchMode = state.searchMode;
|
|
5663
5726
|
}
|
|
5664
|
-
this.lastTimeTaken = state.searchResponseTimeTaken;
|
|
5665
5727
|
}
|
|
5666
5728
|
connectedCallback() {
|
|
5667
5729
|
this.handleStateUpdate(searchcraftStore.getState());
|
|
@@ -5733,23 +5795,26 @@ class SearchcraftFacetList {
|
|
|
5733
5795
|
if (!this.fieldName) {
|
|
5734
5796
|
return;
|
|
5735
5797
|
}
|
|
5736
|
-
if (Object.keys(this.
|
|
5798
|
+
if (Object.keys(this.facetTreeCollectedFromSearchResponse.children).length ===
|
|
5799
|
+
0 &&
|
|
5737
5800
|
(this.lastSearchTerm || '').trim().length === 0) {
|
|
5738
5801
|
return;
|
|
5739
5802
|
}
|
|
5740
|
-
if (Object.keys(this.
|
|
5803
|
+
if (Object.keys(this.facetTreeCollectedFromSearchResponse.children).length ===
|
|
5804
|
+
0 &&
|
|
5741
5805
|
(this.lastSearchTerm || '').trim().length > 0) {
|
|
5742
5806
|
return (hAsync("p", { class: 'searchcraft-facet-list-message' }, "No facets are available for this search query."));
|
|
5743
5807
|
}
|
|
5744
|
-
return (hAsync("div", { class: 'searchcraft-facet-list' }, this.renderFacet('@@root', this.
|
|
5808
|
+
return (hAsync("div", { class: 'searchcraft-facet-list' }, this.renderFacet('@@root', this.renderedFacetTree)));
|
|
5745
5809
|
}
|
|
5746
5810
|
static get cmpMeta() { return {
|
|
5747
5811
|
"$flags$": 0,
|
|
5748
5812
|
"$tagName$": "searchcraft-facet-list",
|
|
5749
5813
|
"$members$": {
|
|
5750
5814
|
"fieldName": [1, "field-name"],
|
|
5751
|
-
"
|
|
5752
|
-
"
|
|
5815
|
+
"selectedPaths": [32],
|
|
5816
|
+
"facetTreeCollectedFromSearchResponse": [32],
|
|
5817
|
+
"renderedFacetTree": [32]
|
|
5753
5818
|
},
|
|
5754
5819
|
"$listeners$": undefined,
|
|
5755
5820
|
"$lazyBundleId$": "-",
|
|
@@ -6022,22 +6087,18 @@ class SearchcraftInputForm {
|
|
|
6022
6087
|
handleInput = (event) => {
|
|
6023
6088
|
const input = event.target;
|
|
6024
6089
|
this.inputValue = input.value;
|
|
6090
|
+
this.searchcraftStore.setSearchTerm(input.value);
|
|
6025
6091
|
if (!this.autoSearch) {
|
|
6026
6092
|
return;
|
|
6027
6093
|
}
|
|
6028
|
-
this.performSearch(
|
|
6094
|
+
this.performSearch();
|
|
6029
6095
|
};
|
|
6030
|
-
performSearch = async (
|
|
6031
|
-
if (searchTerm === this.searchTerm) {
|
|
6032
|
-
return;
|
|
6033
|
-
}
|
|
6034
|
-
this.searchcraftStore.setSearchTerm(searchTerm.trim());
|
|
6096
|
+
performSearch = async () => {
|
|
6035
6097
|
this.error = false;
|
|
6036
6098
|
try {
|
|
6037
6099
|
await this.searchcraftStore.search();
|
|
6038
6100
|
}
|
|
6039
6101
|
catch (error) {
|
|
6040
|
-
console.error(`Search for ${searchTerm} failed:`, error);
|
|
6041
6102
|
this.error = true;
|
|
6042
6103
|
}
|
|
6043
6104
|
};
|
|
@@ -6052,7 +6113,7 @@ class SearchcraftInputForm {
|
|
|
6052
6113
|
};
|
|
6053
6114
|
handleFormSubmit = async (event) => {
|
|
6054
6115
|
event.preventDefault();
|
|
6055
|
-
await this.performSearch(
|
|
6116
|
+
await this.performSearch();
|
|
6056
6117
|
};
|
|
6057
6118
|
render() {
|
|
6058
6119
|
const isShowingClearButton = this.inputValue.length > 0;
|
|
@@ -6065,11 +6126,11 @@ class SearchcraftInputForm {
|
|
|
6065
6126
|
const inputGridStyles = {
|
|
6066
6127
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
6067
6128
|
};
|
|
6068
|
-
return (hAsync("form", { key: '
|
|
6129
|
+
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', {
|
|
6069
6130
|
'searchcraft-placeholder-hide-on-focus': this.placeholderBehavior === 'hide-on-focus',
|
|
6070
6131
|
}), onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
6071
6132
|
this.handleInput(event);
|
|
6072
|
-
}, placeholder: this.placeholderValue, type: 'text', value: this.inputValue }), hAsync("div", { key: '
|
|
6133
|
+
}, 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' }))))))));
|
|
6073
6134
|
}
|
|
6074
6135
|
static get watchers() { return {
|
|
6075
6136
|
"core": ["onCoreChange"]
|
|
@@ -6839,40 +6900,99 @@ class SearchcraftPopoverListItemAd {
|
|
|
6839
6900
|
}
|
|
6840
6901
|
adSource = 'Custom';
|
|
6841
6902
|
adClientResponseItem;
|
|
6842
|
-
|
|
6903
|
+
/**
|
|
6904
|
+
* Where the ad is being rendered within the search results div.
|
|
6905
|
+
* Lifecycle behavior differs for ads being rendered in different positions,
|
|
6906
|
+
* so we need to be able to handle all of those cases.
|
|
6907
|
+
*/
|
|
6908
|
+
renderPosition = 'interstitial';
|
|
6843
6909
|
searchTerm;
|
|
6844
6910
|
isSearchInProgress = false;
|
|
6911
|
+
searchResultCount = 0;
|
|
6845
6912
|
get hostElement() { return getElement(this); }
|
|
6846
6913
|
core;
|
|
6847
6914
|
intersectionObserver;
|
|
6848
6915
|
storeUnsubscribe;
|
|
6849
6916
|
adContainerRenderedTimeout;
|
|
6850
|
-
isComponentConnected =
|
|
6917
|
+
isComponentConnected = false;
|
|
6918
|
+
timeTaken;
|
|
6919
|
+
adContainerId = '';
|
|
6920
|
+
/**
|
|
6921
|
+
* Handles when an ad container is first rendered.
|
|
6922
|
+
* Core emits an ad_container_rendered event and performs ad client side effects
|
|
6923
|
+
*
|
|
6924
|
+
*/
|
|
6925
|
+
handleAdRendered() {
|
|
6926
|
+
this.adContainerId = nanoid();
|
|
6927
|
+
if (this.isComponentConnected && this.searchResultCount > 0) {
|
|
6928
|
+
clearTimeout(this.adContainerRenderedTimeout);
|
|
6929
|
+
this.adContainerRenderedTimeout = setTimeout(() => {
|
|
6930
|
+
this.core?.handleAdContainerRendered({
|
|
6931
|
+
adClientResponseItem: this.adClientResponseItem,
|
|
6932
|
+
adContainerId: this.adContainerId,
|
|
6933
|
+
adSource: this.adSource,
|
|
6934
|
+
searchTerm: this.searchTerm || '',
|
|
6935
|
+
});
|
|
6936
|
+
}, this.core?.config?.adContainerRenderedDebounceDelay || 300);
|
|
6937
|
+
}
|
|
6938
|
+
}
|
|
6939
|
+
handleAdViewed() {
|
|
6940
|
+
this.core?.handleAdContainerViewed({
|
|
6941
|
+
adClientResponseItem: this.adClientResponseItem,
|
|
6942
|
+
adContainerId: this.adContainerId,
|
|
6943
|
+
adSource: this.adSource,
|
|
6944
|
+
searchTerm: this.searchTerm || '',
|
|
6945
|
+
});
|
|
6946
|
+
}
|
|
6947
|
+
/**
|
|
6948
|
+
* Things to do when there's a new incoming search request.
|
|
6949
|
+
*/
|
|
6950
|
+
handleNewIncomingSearchRequest(state) {
|
|
6951
|
+
const request = state.searchClientRequest;
|
|
6952
|
+
if (request && typeof request === 'object') {
|
|
6953
|
+
this.searchTerm = request.searchTerm;
|
|
6954
|
+
}
|
|
6955
|
+
this.searchResultCount = state.searchClientResponseItems.length;
|
|
6956
|
+
this.handleAdRendered();
|
|
6957
|
+
this.startIntersectionObserver();
|
|
6958
|
+
}
|
|
6851
6959
|
connectedCallback() {
|
|
6852
6960
|
const currentState = searchcraftStore.getState();
|
|
6961
|
+
this.isComponentConnected = true;
|
|
6853
6962
|
this.core = currentState.core;
|
|
6854
|
-
this.searchTerm = currentState.searchTerm;
|
|
6855
6963
|
this.isSearchInProgress = currentState.isSearchInProgress;
|
|
6964
|
+
this.searchResultCount = currentState.searchClientResponseItems.length;
|
|
6965
|
+
this.timeTaken = currentState.searchResponseTimeTaken;
|
|
6966
|
+
const request = currentState.searchClientRequest;
|
|
6967
|
+
if (request && typeof request === 'object') {
|
|
6968
|
+
this.searchTerm = request.searchTerm;
|
|
6969
|
+
}
|
|
6970
|
+
/**
|
|
6971
|
+
* Interstial ads have a different lifecycle, where we need handle an incoming search
|
|
6972
|
+
* request immediately, because they are rendered alongside the search results.
|
|
6973
|
+
*/
|
|
6974
|
+
if (this.renderPosition === 'interstitial') {
|
|
6975
|
+
this.handleNewIncomingSearchRequest(currentState);
|
|
6976
|
+
}
|
|
6856
6977
|
// Subscribes to store changes (for search term).
|
|
6857
6978
|
this.storeUnsubscribe = searchcraftStore.subscribe((state) => {
|
|
6858
|
-
this.
|
|
6979
|
+
if (this.timeTaken !== state.searchResponseTimeTaken) {
|
|
6980
|
+
this.handleNewIncomingSearchRequest(state);
|
|
6981
|
+
}
|
|
6982
|
+
this.timeTaken = state.searchResponseTimeTaken;
|
|
6859
6983
|
this.isSearchInProgress = state.isSearchInProgress;
|
|
6860
6984
|
});
|
|
6861
6985
|
}
|
|
6862
|
-
|
|
6986
|
+
startIntersectionObserver() {
|
|
6987
|
+
this.intersectionObserver?.disconnect();
|
|
6863
6988
|
/**
|
|
6864
6989
|
* Handles when an ad container is viewable within the document,
|
|
6865
6990
|
* Core emits an ad_container_viewed event and performs ad client side effects
|
|
6866
6991
|
*/
|
|
6867
6992
|
if (this.hostElement) {
|
|
6868
6993
|
this.intersectionObserver = new IntersectionObserver(([entry]) => {
|
|
6869
|
-
if (entry?.isIntersecting &&
|
|
6870
|
-
this.
|
|
6871
|
-
adClientResponseItem: this.adClientResponseItem,
|
|
6872
|
-
adContainerId: this.adContainerId,
|
|
6873
|
-
adSource: this.adSource,
|
|
6874
|
-
searchTerm: this.searchTerm || '',
|
|
6875
|
-
});
|
|
6994
|
+
if (entry?.isIntersecting && this.searchResultCount > 0) {
|
|
6995
|
+
this.handleAdViewed();
|
|
6876
6996
|
}
|
|
6877
6997
|
}, { threshold: 0 });
|
|
6878
6998
|
this.intersectionObserver.observe(this.hostElement);
|
|
@@ -6912,26 +7032,10 @@ class SearchcraftPopoverListItemAd {
|
|
|
6912
7032
|
return (hAsync("div", { id: `searchcraft-native-ad-${this.adContainerId}`, class: classNames('searchcraft-ad', nativoClassName), "data-searchcraft-ad-container-id": this.adContainerId }));
|
|
6913
7033
|
}
|
|
6914
7034
|
render() {
|
|
6915
|
-
// Don't render ads
|
|
6916
|
-
if (this.
|
|
7035
|
+
// Don't render ads if no search results
|
|
7036
|
+
if (this.searchResultCount === 0) {
|
|
6917
7037
|
return;
|
|
6918
7038
|
}
|
|
6919
|
-
/**
|
|
6920
|
-
* Handles when an ad container is first rendered.
|
|
6921
|
-
* Core emits an ad_container_rendered event and performs ad client side effects
|
|
6922
|
-
*
|
|
6923
|
-
*/
|
|
6924
|
-
if (this.isComponentConnected) {
|
|
6925
|
-
clearTimeout(this.adContainerRenderedTimeout);
|
|
6926
|
-
this.adContainerRenderedTimeout = setTimeout(() => {
|
|
6927
|
-
this.core?.handleAdContainerRendered({
|
|
6928
|
-
adClientResponseItem: this.adClientResponseItem,
|
|
6929
|
-
adContainerId: this.adContainerId,
|
|
6930
|
-
adSource: this.adSource,
|
|
6931
|
-
searchTerm: this.searchTerm || '',
|
|
6932
|
-
});
|
|
6933
|
-
}, this.core?.config?.adContainerRenderedDebounceDelay || 500);
|
|
6934
|
-
}
|
|
6935
7039
|
switch (this.adSource) {
|
|
6936
7040
|
case 'adMarketplace':
|
|
6937
7041
|
return this.renderADMAd();
|
|
@@ -6949,9 +7053,11 @@ class SearchcraftPopoverListItemAd {
|
|
|
6949
7053
|
"$members$": {
|
|
6950
7054
|
"adSource": [1, "ad-source"],
|
|
6951
7055
|
"adClientResponseItem": [16],
|
|
6952
|
-
"
|
|
7056
|
+
"renderPosition": [1, "render-position"],
|
|
6953
7057
|
"searchTerm": [32],
|
|
6954
|
-
"isSearchInProgress": [32]
|
|
7058
|
+
"isSearchInProgress": [32],
|
|
7059
|
+
"searchResultCount": [32],
|
|
7060
|
+
"adContainerId": [32]
|
|
6955
7061
|
},
|
|
6956
7062
|
"$listeners$": undefined,
|
|
6957
7063
|
"$lazyBundleId$": "-",
|
|
@@ -6988,7 +7094,7 @@ class SearchcraftPopoverListView {
|
|
|
6988
7094
|
searchResultsPerPage;
|
|
6989
7095
|
config = searchcraftStore.getState().core?.config;
|
|
6990
7096
|
renderWithADMAds() {
|
|
6991
|
-
return (hAsync("div", { class: 'searchcraft-popover-list-view' }, this.adClientResponseItems?.map((item) => (hAsync("searchcraft-ad", { adClientResponseItem: item,
|
|
7097
|
+
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 })))));
|
|
6992
7098
|
}
|
|
6993
7099
|
renderWithCustomAds() {
|
|
6994
7100
|
const itemsToRender = [];
|
|
@@ -6999,7 +7105,7 @@ class SearchcraftPopoverListView {
|
|
|
6999
7105
|
const searchItems = this.searchClientResponseItems || [];
|
|
7000
7106
|
// Renders ads at beginning
|
|
7001
7107
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7002
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7108
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7003
7109
|
}
|
|
7004
7110
|
// Renders search results + interstitial ads
|
|
7005
7111
|
searchItems.forEach((item, index) => {
|
|
@@ -7008,14 +7114,14 @@ class SearchcraftPopoverListView {
|
|
|
7008
7114
|
index + interstitialInterval < searchItems.length &&
|
|
7009
7115
|
index >= interstitialInterval) {
|
|
7010
7116
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7011
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7117
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7012
7118
|
}
|
|
7013
7119
|
}
|
|
7014
7120
|
itemsToRender.push(hAsync("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index }));
|
|
7015
7121
|
});
|
|
7016
7122
|
// Renders ads at end
|
|
7017
7123
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7018
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7124
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7019
7125
|
}
|
|
7020
7126
|
return hAsync("div", { class: 'searchcraft-popover-list-view' }, itemsToRender);
|
|
7021
7127
|
}
|
|
@@ -7029,7 +7135,7 @@ class SearchcraftPopoverListView {
|
|
|
7029
7135
|
const searchItems = this.searchClientResponseItems || [];
|
|
7030
7136
|
// Renders ads at beginning
|
|
7031
7137
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7032
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7138
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7033
7139
|
}
|
|
7034
7140
|
// Renders search results + interstitial ads
|
|
7035
7141
|
searchItems.forEach((item, index) => {
|
|
@@ -7038,14 +7144,14 @@ class SearchcraftPopoverListView {
|
|
|
7038
7144
|
index + interstitialInterval < searchItems.length &&
|
|
7039
7145
|
index >= interstitialInterval) {
|
|
7040
7146
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7041
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7147
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7042
7148
|
}
|
|
7043
7149
|
}
|
|
7044
7150
|
itemsToRender.push(hAsync("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index }));
|
|
7045
7151
|
});
|
|
7046
7152
|
// Renders ads at end
|
|
7047
7153
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7048
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7154
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7049
7155
|
}
|
|
7050
7156
|
return hAsync("div", { class: 'searchcraft-popover-list-view' }, itemsToRender);
|
|
7051
7157
|
}
|
|
@@ -7402,7 +7508,7 @@ class SearchcraftSearchResults {
|
|
|
7402
7508
|
: this.initialSearchClientResponseItems?.length
|
|
7403
7509
|
? this.initialSearchClientResponseItems
|
|
7404
7510
|
: [];
|
|
7405
|
-
return (hAsync("div", { class: 'searchcraft-search-results' }, this.adClientResponseItems?.map((item) => (hAsync("searchcraft-ad", { adSource: 'adMarketplace', adClientResponseItem: item,
|
|
7511
|
+
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 })))));
|
|
7406
7512
|
}
|
|
7407
7513
|
renderWithCustomAds() {
|
|
7408
7514
|
const itemsToRender = [];
|
|
@@ -7417,7 +7523,7 @@ class SearchcraftSearchResults {
|
|
|
7417
7523
|
: [];
|
|
7418
7524
|
// Renders ads at beginning
|
|
7419
7525
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7420
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7526
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7421
7527
|
}
|
|
7422
7528
|
// Renders search results + interstitial ads
|
|
7423
7529
|
items.forEach((item, index) => {
|
|
@@ -7426,14 +7532,14 @@ class SearchcraftSearchResults {
|
|
|
7426
7532
|
index + interstitialInterval < items.length &&
|
|
7427
7533
|
index >= interstitialInterval) {
|
|
7428
7534
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7429
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7535
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7430
7536
|
}
|
|
7431
7537
|
}
|
|
7432
7538
|
itemsToRender.push(hAsync("searchcraft-search-result", { key: item.id, "document-position": this.searchResultsPerPage * (this.searchResultsPage - 1) + index, index: index, item: item, template: this.template }));
|
|
7433
7539
|
});
|
|
7434
7540
|
// Renders ads at end
|
|
7435
7541
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7436
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom',
|
|
7542
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Custom', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7437
7543
|
}
|
|
7438
7544
|
return hAsync("div", { class: 'searchcraft-search-results' }, itemsToRender);
|
|
7439
7545
|
}
|
|
@@ -7451,7 +7557,7 @@ class SearchcraftSearchResults {
|
|
|
7451
7557
|
: [];
|
|
7452
7558
|
// Renders ads at beginning
|
|
7453
7559
|
for (let n = 0; n < adStartQuantity; n++) {
|
|
7454
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7560
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'top' }));
|
|
7455
7561
|
}
|
|
7456
7562
|
// Renders search results + interstitial ads
|
|
7457
7563
|
items.forEach((item, index) => {
|
|
@@ -7460,14 +7566,14 @@ class SearchcraftSearchResults {
|
|
|
7460
7566
|
index + interstitialInterval < items.length &&
|
|
7461
7567
|
index >= interstitialInterval) {
|
|
7462
7568
|
for (let n = 0; n < interstitialQuantity; n++) {
|
|
7463
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7569
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${item.id}-ad-${n}`, renderPosition: 'interstitial' }));
|
|
7464
7570
|
}
|
|
7465
7571
|
}
|
|
7466
7572
|
itemsToRender.push(hAsync("searchcraft-search-result", { key: item.id, "document-position": this.searchResultsPerPage * (this.searchResultsPage - 1) + index, index: index, item: item, template: this.template }));
|
|
7467
7573
|
});
|
|
7468
7574
|
// Renders ads at end
|
|
7469
7575
|
for (let n = 0; n < adEndQuantity; n++) {
|
|
7470
|
-
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo',
|
|
7576
|
+
itemsToRender.push(hAsync("searchcraft-ad", { adSource: 'Nativo', key: `${n}-ad`, renderPosition: 'bottom' }));
|
|
7471
7577
|
}
|
|
7472
7578
|
return hAsync("div", { class: 'searchcraft-search-results' }, itemsToRender);
|
|
7473
7579
|
}
|