@searchcraft/javascript-sdk 0.10.6 → 0.11.0

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.
Files changed (135) hide show
  1. package/dist/components/defineCustomElements.js +4 -0
  2. package/dist/components/index.d.ts +541 -221
  3. package/dist/components/index.js +1655 -8
  4. package/dist/components/index.js.map +1 -1
  5. package/dist/components/{p-b194d081.js → p-0c495408.js} +30 -20
  6. package/dist/components/p-0c495408.js.map +1 -0
  7. package/dist/components/{p-9f4c50ed.js → p-1d5c5536.js} +18 -8
  8. package/dist/components/p-1d5c5536.js.map +1 -0
  9. package/dist/components/{p-f2976b33.js → p-3286bbb3.js} +22 -10
  10. package/dist/components/p-3286bbb3.js.map +1 -0
  11. package/dist/components/{p-75134ca7.js → p-3e41546c.js} +17 -8
  12. package/dist/components/p-3e41546c.js.map +1 -0
  13. package/dist/components/{p-6e5ed641.js → p-87435aac.js} +98 -42
  14. package/dist/components/p-87435aac.js.map +1 -0
  15. package/dist/components/p-919734fe.js +31 -0
  16. package/dist/components/p-919734fe.js.map +1 -0
  17. package/dist/components/{p-aba24c85.js → p-b13c7fbb.js} +48 -33
  18. package/dist/components/p-b13c7fbb.js.map +1 -0
  19. package/dist/components/{p-810a7850.js → p-b4b67072.js} +2 -2
  20. package/dist/components/p-b4b67072.js.map +1 -0
  21. package/dist/components/{p-a7d611cd.js → p-b7e99386.js} +22 -22
  22. package/dist/components/p-b7e99386.js.map +1 -0
  23. package/dist/components/{p-4dd1995c.js → p-c9b65e8f.js} +4 -4
  24. package/dist/components/{p-4dd1995c.js.map → p-c9b65e8f.js.map} +1 -1
  25. package/dist/components/p-d54771ef.js.map +1 -1
  26. package/dist/components/{p-a64b4cba.js → p-e2a10337.js} +2 -2
  27. package/dist/components/{p-a64b4cba.js.map → p-e2a10337.js.map} +1 -1
  28. package/dist/components/p-e30203b1.js +62 -0
  29. package/dist/components/p-e30203b1.js.map +1 -0
  30. package/dist/components/{p-2735dceb.js → p-fc8ccffa.js} +22 -11
  31. package/dist/components/p-fc8ccffa.js.map +1 -0
  32. package/dist/components/searchcraft-ad.js +1 -1
  33. package/dist/components/searchcraft-facet-list.js +1 -1
  34. package/dist/components/searchcraft-filter-panel.js +51 -23
  35. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  36. package/dist/components/searchcraft-input-form.js +1 -1
  37. package/dist/components/searchcraft-loading.d.ts +11 -0
  38. package/dist/components/searchcraft-loading.js +8 -0
  39. package/dist/components/searchcraft-loading.js.map +1 -0
  40. package/dist/components/searchcraft-pagination.js +13 -3
  41. package/dist/components/searchcraft-pagination.js.map +1 -1
  42. package/dist/components/searchcraft-popover-button.js +21 -9
  43. package/dist/components/searchcraft-popover-button.js.map +1 -1
  44. package/dist/components/searchcraft-popover-footer.js +1 -1
  45. package/dist/components/searchcraft-popover-form.js +32 -20
  46. package/dist/components/searchcraft-popover-form.js.map +1 -1
  47. package/dist/components/searchcraft-popover-list-item.js +1 -1
  48. package/dist/components/searchcraft-popover-list-view.js +1 -1
  49. package/dist/components/searchcraft-results-info.js +15 -7
  50. package/dist/components/searchcraft-results-info.js.map +1 -1
  51. package/dist/components/searchcraft-search-result.js +1 -1
  52. package/dist/components/searchcraft-search-results-per-page.js +14 -4
  53. package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
  54. package/dist/components/searchcraft-search-results.js +50 -69
  55. package/dist/components/searchcraft-search-results.js.map +1 -1
  56. package/dist/components/searchcraft-slider.js +1 -1
  57. package/dist/components/searchcraft-summary-box.d.ts +11 -0
  58. package/dist/components/searchcraft-summary-box.js +2287 -0
  59. package/dist/components/searchcraft-summary-box.js.map +1 -0
  60. package/dist/components/searchcraft-theme.js +2 -2
  61. package/dist/components/searchcraft-theme.js.map +1 -1
  62. package/dist/components/searchcraft-toggle-button.js +1 -1
  63. package/dist/hydrate/index.js +5340 -4085
  64. package/dist/hydrate/index.mjs +5340 -4085
  65. package/dist/themes/hologram.css +1 -1
  66. package/dist/themes/hologram.css.map +1 -1
  67. package/dist/types/classes/CoreInstanceRegistry.d.ts +38 -0
  68. package/dist/types/classes/Logger.d.ts +25 -0
  69. package/dist/types/classes/SearchcraftCore.d.ts +50 -0
  70. package/dist/types/classes/index.d.ts +3 -0
  71. package/dist/types/clients/MeasureClient.d.ts +27 -0
  72. package/dist/types/clients/SearchClient.d.ts +35 -0
  73. package/dist/types/clients/SummaryClient.d.ts +10 -0
  74. package/dist/types/clients/ad-clients/AdClient.d.ts +20 -0
  75. package/dist/types/clients/ad-clients/AdMarketplaceClient.d.ts +14 -0
  76. package/dist/types/clients/ad-clients/CustomAdClient.d.ts +6 -0
  77. package/dist/types/clients/ad-clients/NativoClient.d.ts +14 -0
  78. package/dist/types/clients/ad-clients/index.d.ts +5 -0
  79. package/dist/types/clients/index.d.ts +4 -0
  80. package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +31 -4
  81. package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +9 -2
  82. package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +14 -3
  83. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +9 -6
  84. package/dist/types/components/searchcraft-loading/searchcraft-loading.d.ts +10 -0
  85. package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +8 -1
  86. package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +10 -2
  87. package/dist/types/components/searchcraft-popover-footer/searchcraft-popover-footer.d.ts +8 -1
  88. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +11 -3
  89. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +9 -1
  90. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +11 -3
  91. package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +8 -1
  92. package/dist/types/components/searchcraft-search-result/searchcraft-search-result.d.ts +10 -1
  93. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +11 -5
  94. package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +8 -1
  95. package/dist/types/components/searchcraft-summary-box/searchcraft-summary-box.d.ts +49 -0
  96. package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +8 -1
  97. package/dist/types/components.d.ts +264 -8
  98. package/dist/types/index.d.ts +4 -5
  99. package/dist/types/store/SearchcraftStore.types.d.ts +14 -15
  100. package/dist/types/store/SearchcraftStoreFactory.d.ts +13 -0
  101. package/dist/types/store/index.d.ts +1 -1
  102. package/dist/types/types/core-types/AdClientResponses.types.d.ts +24 -0
  103. package/dist/types/types/core-types/Facets.types.d.ts +39 -0
  104. package/dist/types/types/core-types/Measure.types.d.ts +52 -0
  105. package/dist/types/types/core-types/SearchClient.types.d.ts +67 -0
  106. package/dist/types/types/core-types/SearchClientResponses.types.d.ts +7 -0
  107. package/dist/types/types/core-types/SearchcraftAdConfig.types.d.ts +76 -0
  108. package/dist/types/types/core-types/SearchcraftConfig.types.d.ts +65 -0
  109. package/dist/types/types/core-types/SearchcraftResponse.types.d.ts +46 -0
  110. package/dist/types/types/core-types/SubscriptionEvents.types.d.ts +51 -0
  111. package/dist/types/types/core-types/index.d.ts +10 -0
  112. package/dist/types/types/index.d.ts +3 -0
  113. package/dist/types/types/sdk-types/index.d.ts +4 -0
  114. package/dist/types/types/sdk-types/result-mappings.types.d.ts +58 -0
  115. package/dist/types/types/sdk-types/searchcraft-filter-panel.types.d.ts +44 -0
  116. package/dist/types/types/sdk-types/templates.types.d.ts +29 -0
  117. package/dist/types/utils/core-utils/index.d.ts +3 -0
  118. package/dist/types/utils/core-utils/sanitize.d.ts +2 -0
  119. package/dist/types/utils/core-utils/url.d.ts +2 -0
  120. package/dist/types/utils/facets.d.ts +1 -1
  121. package/dist/types/utils/html.d.ts +1 -1
  122. package/dist/types/utils/units.d.ts +1 -1
  123. package/package.json +5 -3
  124. package/dist/components/p-2735dceb.js.map +0 -1
  125. package/dist/components/p-6e5ed641.js.map +0 -1
  126. package/dist/components/p-75134ca7.js.map +0 -1
  127. package/dist/components/p-810a7850.js.map +0 -1
  128. package/dist/components/p-9f4c50ed.js.map +0 -1
  129. package/dist/components/p-a7d611cd.js.map +0 -1
  130. package/dist/components/p-aba24c85.js.map +0 -1
  131. package/dist/components/p-b194d081.js.map +0 -1
  132. package/dist/components/p-b54873ff.js +0 -1928
  133. package/dist/components/p-b54873ff.js.map +0 -1
  134. package/dist/components/p-f2976b33.js.map +0 -1
  135. package/dist/types/store/SearchcraftStore.d.ts +0 -4
@@ -1,1928 +0,0 @@
1
- var B = Object.defineProperty;
2
- var N = (a, e, n) => e in a ? B(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
3
- var h = (a, e, n) => N(a, typeof e != "symbol" ? e + "" : e, n);
4
- var O = /* @__PURE__ */ ((a) => (a[a.DEBUG = 0] = "DEBUG", a[a.INFO = 1] = "INFO", a[a.WARN = 2] = "WARN", a[a.ERROR = 3] = "ERROR", a))(O || {});
5
- class pe {
6
- constructor(e) {
7
- h(this, "logLevel");
8
- h(this, "logFormatter");
9
- this.logLevel = e.logLevel || 1, this.logFormatter = e.logFormatter || this.defaultFormatter;
10
- }
11
- defaultFormatter(e, n) {
12
- return `[${O[e]}] ${( new Date()).toISOString()}: ${n}`;
13
- }
14
- debug(e) {
15
- this.logLevel <= 0 && console.log(this.logFormatter(0, e));
16
- }
17
- info(e) {
18
- this.logLevel <= 1 && console.info(this.logFormatter(1, e));
19
- }
20
- warn(e) {
21
- this.logLevel <= 2 && console.warn(this.logFormatter(2, e));
22
- }
23
- error(e) {
24
- this.logLevel <= 3 && console.error(this.logFormatter(3, e));
25
- }
26
- log(e, n) {
27
- switch (e) {
28
- case 0:
29
- this.debug(n);
30
- break;
31
- case 1:
32
- this.info(n);
33
- break;
34
- case 2:
35
- this.warn(n);
36
- break;
37
- case 3:
38
- this.error(n);
39
- break;
40
- }
41
- }
42
- }
43
- function y(a, e, n, r) {
44
- return new (n || (n = Promise))(function(o, i) {
45
- function t(s) {
46
- try {
47
- l(r.next(s));
48
- } catch (c) {
49
- i(c);
50
- }
51
- }
52
- function u(s) {
53
- try {
54
- l(r.throw(s));
55
- } catch (c) {
56
- i(c);
57
- }
58
- }
59
- function l(s) {
60
- var c;
61
- s.done ? o(s.value) : (c = s.value, c instanceof n ? c : new n(function(g) {
62
- g(c);
63
- })).then(t, u);
64
- }
65
- l((r = r.apply(a, [])).next());
66
- });
67
- }
68
- function w(a, e) {
69
- var n, r, o, i, t = { label: 0, sent: function() {
70
- if (1 & o[0]) throw o[1];
71
- return o[1];
72
- }, trys: [], ops: [] };
73
- return i = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
74
- return this;
75
- }), i;
76
- function u(l) {
77
- return function(s) {
78
- return function(c) {
79
- if (n) throw new TypeError("Generator is already executing.");
80
- for (; i && (i = 0, c[0] && (t = 0)), t; ) try {
81
- 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;
82
- switch (r = 0, o && (c = [2 & c[0], o.value]), c[0]) {
83
- case 0:
84
- case 1:
85
- o = c;
86
- break;
87
- case 4:
88
- return t.label++, { value: c[1], done: !1 };
89
- case 5:
90
- t.label++, r = c[1], c = [0];
91
- continue;
92
- case 7:
93
- c = t.ops.pop(), t.trys.pop();
94
- continue;
95
- default:
96
- if (o = t.trys, !((o = o.length > 0 && o[o.length - 1]) || c[0] !== 6 && c[0] !== 2)) {
97
- t = 0;
98
- continue;
99
- }
100
- if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
101
- t.label = c[1];
102
- break;
103
- }
104
- if (c[0] === 6 && t.label < o[1]) {
105
- t.label = o[1], o = c;
106
- break;
107
- }
108
- if (o && t.label < o[2]) {
109
- t.label = o[2], t.ops.push(c);
110
- break;
111
- }
112
- o[2] && t.ops.pop(), t.trys.pop();
113
- continue;
114
- }
115
- c = e.call(a, t);
116
- } catch (g) {
117
- c = [6, g], r = 0;
118
- } finally {
119
- n = o = 0;
120
- }
121
- if (5 & c[0]) throw c[1];
122
- return { value: c[0] ? c[1] : void 0, done: !0 };
123
- }([l, s]);
124
- };
125
- }
126
- }
127
- var S = { exclude: [] }, D = {}, j = { timeout: "true" }, v = function(a, e) {
128
- typeof window < "u" && (D[a] = e);
129
- }, G = function() {
130
- return Object.fromEntries(Object.entries(D).filter(function(a) {
131
- var e, n = a[0];
132
- return !(!((e = S == null ? void 0 : S.exclude) === null || e === void 0) && e.includes(n));
133
- }).map(function(a) {
134
- return [a[0], (0, a[1])()];
135
- }));
136
- };
137
- function T(a) {
138
- return a ^= a >>> 16, a = Math.imul(a, 2246822507), a ^= a >>> 13, a = Math.imul(a, 3266489909), (a ^= a >>> 16) >>> 0;
139
- }
140
- var m = new Uint32Array([597399067, 2869860233, 951274213, 2716044179]);
141
- function p(a, e) {
142
- return a << e | a >>> 32 - e;
143
- }
144
- function _(a, e) {
145
- var n;
146
- 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");
147
- var r = new Uint32Array([e, e, e, e]);
148
- ((function(i, t) {
149
- for (var u = i.byteLength / 16 | 0, l = new Uint32Array(i, 0, 4 * u), s = 0; s < u; s++) {
150
- var c = l.subarray(4 * s, 4 * (s + 1));
151
- 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;
152
- }
153
- }))(a, r), function(i, t) {
154
- var u = i.byteLength / 16 | 0, l = i.byteLength % 16, s = new Uint32Array(4), c = new Uint8Array(i, 16 * u, l);
155
- switch (l) {
156
- case 15:
157
- s[3] = s[3] ^ c[14] << 16;
158
- case 14:
159
- s[3] = s[3] ^ c[13] << 8;
160
- case 13:
161
- 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];
162
- case 12:
163
- s[2] = s[2] ^ c[11] << 24;
164
- case 11:
165
- s[2] = s[2] ^ c[10] << 16;
166
- case 10:
167
- s[2] = s[2] ^ c[9] << 8;
168
- case 9:
169
- 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];
170
- case 8:
171
- s[1] = s[1] ^ c[7] << 24;
172
- case 7:
173
- s[1] = s[1] ^ c[6] << 16;
174
- case 6:
175
- s[1] = s[1] ^ c[5] << 8;
176
- case 5:
177
- 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];
178
- case 4:
179
- s[0] = s[0] ^ c[3] << 24;
180
- case 3:
181
- s[0] = s[0] ^ c[2] << 16;
182
- case 2:
183
- s[0] = s[0] ^ c[1] << 8;
184
- case 1:
185
- 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];
186
- }
187
- }(a, r), function(i, t) {
188
- 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] = T(t[0]), t[1] = T(t[1]), t[2] = T(t[2]), t[3] = T(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;
189
- }(a, r);
190
- var o = new Uint8Array(r.buffer);
191
- return Array.from(o).map(function(i) {
192
- return i.toString(16).padStart(2, "0");
193
- }).join("");
194
- }
195
- function W(a, e) {
196
- return new Promise(function(n) {
197
- setTimeout(function() {
198
- return n(e);
199
- }, a);
200
- });
201
- }
202
- function V(a, e, n) {
203
- return Promise.all(a.map(function(r) {
204
- return Promise.race([r, W(e, n)]);
205
- }));
206
- }
207
- function $() {
208
- return y(this, void 0, void 0, function() {
209
- var a, e, n, r, o;
210
- return w(this, function(i) {
211
- switch (i.label) {
212
- case 0:
213
- return i.trys.push([0, 2, , 3]), a = G(), e = Object.keys(a), [4, V(Object.values(a), (S == null ? void 0 : S.timeout) || 1e3, j)];
214
- case 1:
215
- return n = i.sent(), r = n.filter(function(t) {
216
- return t !== void 0;
217
- }), o = {}, r.forEach(function(t, u) {
218
- o[e[u]] = t;
219
- }), [2, U(o, S.exclude || [])];
220
- case 2:
221
- throw i.sent();
222
- case 3:
223
- return [2];
224
- }
225
- });
226
- });
227
- }
228
- function U(a, e) {
229
- var n = {}, r = function(i) {
230
- if (a.hasOwnProperty(i)) {
231
- var t = a[i];
232
- if (typeof t != "object" || Array.isArray(t)) e.includes(i) || (n[i] = t);
233
- else {
234
- var u = U(t, e.map(function(l) {
235
- return l.startsWith(i + ".") ? l.slice(i.length + 1) : l;
236
- }));
237
- Object.keys(u).length > 0 && (n[i] = u);
238
- }
239
- }
240
- };
241
- for (var o in a) r(o);
242
- return n;
243
- }
244
- function z(a) {
245
- return y(this, void 0, void 0, function() {
246
- var e, n;
247
- return w(this, function(r) {
248
- switch (r.label) {
249
- case 0:
250
- return r.trys.push([0, 2, , 3]), [4, $()];
251
- case 1:
252
- return e = r.sent(), n = _(JSON.stringify(e)), [2, n.toString()];
253
- case 2:
254
- throw r.sent();
255
- case 3:
256
- return [2];
257
- }
258
- });
259
- });
260
- }
261
- function H(a) {
262
- for (var e = 0, n = 0; n < a.length; ++n) e += Math.abs(a[n]);
263
- return e;
264
- }
265
- function q(a, e, n) {
266
- for (var r = [], o = 0; o < a[0].data.length; o++) {
267
- for (var i = [], t = 0; t < a.length; t++) i.push(a[t].data[o]);
268
- r.push(Q(i));
269
- }
270
- var u = new Uint8ClampedArray(r);
271
- return new ImageData(u, e, n);
272
- }
273
- function Q(a) {
274
- if (a.length === 0) return 0;
275
- for (var e = {}, n = 0, r = a; n < r.length; n++)
276
- e[i = r[n]] = (e[i] || 0) + 1;
277
- var o = a[0];
278
- for (var i in e) e[i] > e[o] && (o = parseInt(i, 10));
279
- return o;
280
- }
281
- function C() {
282
- if (typeof navigator > "u") return { name: "unknown", version: "unknown" };
283
- 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++) {
284
- var o = r[n], i = a.match(o);
285
- if (i && i.groups) return { name: e[i.groups.name] || i.groups.name, version: i.groups.version };
286
- }
287
- return { name: "unknown", version: "unknown" };
288
- }
289
- v("audio", function() {
290
- return y(this, void 0, void 0, function() {
291
- return w(this, function(a) {
292
- return [2, new Promise(function(e, n) {
293
- try {
294
- var r = new (window.OfflineAudioContext || window.webkitOfflineAudioContext)(1, 5e3, 44100), o = r.createBufferSource(), i = r.createOscillator();
295
- i.frequency.value = 1e3;
296
- var t, u = r.createDynamicsCompressor();
297
- 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) {
298
- t = l.renderedBuffer.getChannelData(0), e({ sampleHash: H(t), oscillator: i.type, maxChannels: r.destination.maxChannelCount, channelCountMode: o.channelCountMode });
299
- }, r.startRendering();
300
- } catch (l) {
301
- console.error("Error creating audio fingerprint:", l), n(l);
302
- }
303
- })];
304
- });
305
- });
306
- });
307
- var K = C().name !== "SamsungBrowser" ? 1 : 3, P = 280, k = 20;
308
- C().name != "Firefox" && v("canvas", function() {
309
- return document.createElement("canvas").getContext("2d"), new Promise(function(a) {
310
- var e = Array.from({ length: K }, function() {
311
- return function() {
312
- var n = document.createElement("canvas"), r = n.getContext("2d");
313
- if (!r) return new ImageData(1, 1);
314
- n.width = P, n.height = k;
315
- var o = r.createLinearGradient(0, 0, n.width, n.height);
316
- 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);
317
- var i = "Random Text WMwmil10Oo";
318
- 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();
319
- var t = r.getImageData(0, 0, n.width, n.height);
320
- return t;
321
- }();
322
- });
323
- a({ commonImageDataHash: _(q(e, P, k).data.toString()).toString() });
324
- });
325
- });
326
- var I, 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"];
327
- function F(a, e) {
328
- if (!a) throw new Error("Canvas context not supported");
329
- return a.font = "72px ".concat(e), a.measureText("WwMmLli0Oo").width;
330
- }
331
- function Y() {
332
- var a, e = document.createElement("canvas"), n = (a = e.getContext("webgl")) !== null && a !== void 0 ? a : e.getContext("experimental-webgl");
333
- if (n && "getParameter" in n) try {
334
- 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() };
335
- if (!o.length || !r.length) {
336
- var t = n.getExtension("WEBGL_debug_renderer_info");
337
- if (t) {
338
- var u = (n.getParameter(t.UNMASKED_VENDOR_WEBGL) || "").toString(), l = (n.getParameter(t.UNMASKED_RENDERER_WEBGL) || "").toString();
339
- u && (i.vendorUnmasked = u), l && (i.rendererUnmasked = l);
340
- }
341
- }
342
- return i;
343
- } catch {
344
- }
345
- return "undefined";
346
- }
347
- function Z() {
348
- var a = new Float32Array(1), e = new Uint8Array(a.buffer);
349
- return a[0] = 1 / 0, a[0] = a[0] - a[0], e[3];
350
- }
351
- function ee(a, e) {
352
- var n = {};
353
- return e.forEach(function(r) {
354
- var o = function(i) {
355
- if (i.length === 0) return null;
356
- var t = {};
357
- i.forEach(function(s) {
358
- var c = String(s);
359
- t[c] = (t[c] || 0) + 1;
360
- });
361
- var u = i[0], l = 1;
362
- return Object.keys(t).forEach(function(s) {
363
- t[s] > l && (u = s, l = t[s]);
364
- }), u;
365
- }(a.map(function(i) {
366
- return r in i ? i[r] : void 0;
367
- }).filter(function(i) {
368
- return i !== void 0;
369
- }));
370
- o && (n[r] = o);
371
- }), n;
372
- }
373
- function te() {
374
- var a = [], e = { "prefers-contrast": ["high", "more", "low", "less", "forced", "no-preference"], "any-hover": ["hover", "none"], "any-pointer": ["none", "coarse", "fine"], pointer: ["none", "coarse", "fine"], hover: ["hover", "none"], update: ["fast", "slow"], "inverted-colors": ["inverted", "none"], "prefers-reduced-motion": ["reduce", "no-preference"], "prefers-reduced-transparency": ["reduce", "no-preference"], scripting: ["none", "initial-only", "enabled"], "forced-colors": ["active", "none"] };
375
- return Object.keys(e).forEach(function(n) {
376
- e[n].forEach(function(r) {
377
- matchMedia("(".concat(n, ": ").concat(r, ")")).matches && a.push("".concat(n, ": ").concat(r));
378
- });
379
- }), a;
380
- }
381
- function ne() {
382
- if (window.location.protocol === "https:" && typeof window.ApplePaySession == "function") try {
383
- for (var a = window.ApplePaySession.supportsVersion, e = 15; e > 0; e--) if (a(e)) return e;
384
- } catch {
385
- return 0;
386
- }
387
- return 0;
388
- }
389
- C().name != "Firefox" && v("fonts", function() {
390
- var a = this;
391
- return new Promise(function(e, n) {
392
- try {
393
- (function(r) {
394
- var o;
395
- y(this, void 0, void 0, function() {
396
- var i, t, u;
397
- return w(this, function(l) {
398
- switch (l.label) {
399
- case 0:
400
- return document.body ? [3, 2] : [4, (s = 50, new Promise(function(g) {
401
- return setTimeout(g, s, c);
402
- }))];
403
- case 1:
404
- return l.sent(), [3, 0];
405
- case 2:
406
- 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");
407
- return r({ iframe: u }), setTimeout(function() {
408
- document.body.removeChild(i);
409
- }, 0), [2];
410
- }
411
- var s, c;
412
- });
413
- });
414
- })(function(r) {
415
- var o = r.iframe;
416
- return y(a, void 0, void 0, function() {
417
- var i, t, u, l;
418
- return w(this, function(s) {
419
- return i = o.createElement("canvas"), t = i.getContext("2d"), u = J.map(function(c) {
420
- return F(t, c);
421
- }), l = {}, X.forEach(function(c) {
422
- var g = F(t, c);
423
- u.includes(g) || (l[c] = g);
424
- }), e(l), [2];
425
- });
426
- });
427
- });
428
- } catch {
429
- n({ error: "unsupported" });
430
- }
431
- });
432
- }), v("hardware", function() {
433
- return new Promise(function(a, e) {
434
- var n = navigator.deviceMemory !== void 0 ? navigator.deviceMemory : 0, r = window.performance && window.performance.memory ? window.performance.memory : 0;
435
- a({ videocard: Y(), architecture: Z(), deviceMemory: n.toString() || "undefined", jsHeapSizeLimit: r.jsHeapSizeLimit || 0 });
436
- });
437
- }), v("locales", function() {
438
- return new Promise(function(a) {
439
- a({ languages: navigator.language, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone });
440
- });
441
- }), v("permissions", function() {
442
- return y(this, void 0, void 0, function() {
443
- var a;
444
- return w(this, function(e) {
445
- return I = (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() {
446
- return function() {
447
- return y(this, void 0, void 0, function() {
448
- var n, r, o, i, t;
449
- return w(this, function(u) {
450
- switch (u.label) {
451
- case 0:
452
- n = {}, r = 0, o = I, u.label = 1;
453
- case 1:
454
- if (!(r < o.length)) return [3, 6];
455
- i = o[r], u.label = 2;
456
- case 2:
457
- return u.trys.push([2, 4, , 5]), [4, navigator.permissions.query({ name: i })];
458
- case 3:
459
- return t = u.sent(), n[i] = t.state.toString(), [3, 5];
460
- case 4:
461
- return u.sent(), [3, 5];
462
- case 5:
463
- return r++, [3, 1];
464
- case 6:
465
- return [2, n];
466
- }
467
- });
468
- });
469
- }();
470
- }), [2, Promise.all(a).then(function(n) {
471
- return ee(n, I);
472
- })];
473
- });
474
- });
475
- }), v("plugins", function() {
476
- var a = [];
477
- if (navigator.plugins) for (var e = 0; e < navigator.plugins.length; e++) {
478
- var n = navigator.plugins[e];
479
- a.push([n.name, n.filename, n.description].join("|"));
480
- }
481
- return new Promise(function(r) {
482
- r({ plugins: a });
483
- });
484
- }), v("screen", function() {
485
- return new Promise(function(a) {
486
- a({ is_touchscreen: navigator.maxTouchPoints > 0, maxTouchPoints: navigator.maxTouchPoints, colorDepth: screen.colorDepth, mediaMatches: te() });
487
- });
488
- }), v("system", function() {
489
- return new Promise(function(a) {
490
- var e = C();
491
- 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() });
492
- });
493
- });
494
- var f, re = C().name !== "SamsungBrowser" ? 1 : 3, d = null;
495
- v("webgl", function() {
496
- return y(this, void 0, void 0, function() {
497
- var a;
498
- return w(this, function(e) {
499
- typeof document < "u" && ((f = document.createElement("canvas")).width = 200, f.height = 100, d = f.getContext("webgl"));
500
- try {
501
- if (!d) throw new Error("WebGL not supported");
502
- return a = Array.from({ length: re }, function() {
503
- return function() {
504
- try {
505
- if (!d) throw new Error("WebGL not supported");
506
- var n = `
507
- attribute vec2 position;
508
- void main() {
509
- gl_Position = vec4(position, 0.0, 1.0);
510
- }
511
- `, r = `
512
- precision mediump float;
513
- void main() {
514
- gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
515
- }
516
- `, o = d.createShader(d.VERTEX_SHADER), i = d.createShader(d.FRAGMENT_SHADER);
517
- if (!o || !i) throw new Error("Failed to create shaders");
518
- 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));
519
- if (d.compileShader(i), !d.getShaderParameter(i, d.COMPILE_STATUS)) throw new Error("Fragment shader compilation failed: " + d.getShaderInfoLog(i));
520
- var t = d.createProgram();
521
- if (!t) throw new Error("Failed to create shader program");
522
- 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));
523
- d.useProgram(t);
524
- for (var u = 137, l = new Float32Array(4 * u), s = 2 * Math.PI / u, c = 0; c < u; c++) {
525
- var g = c * s;
526
- 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);
527
- }
528
- var L = d.createBuffer();
529
- d.bindBuffer(d.ARRAY_BUFFER, L), d.bufferData(d.ARRAY_BUFFER, l, d.STATIC_DRAW);
530
- var R = d.getAttribLocation(t, "position");
531
- d.enableVertexAttribArray(R), d.vertexAttribPointer(R, 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);
532
- var x = new Uint8ClampedArray(f.width * f.height * 4);
533
- return d.readPixels(0, 0, f.width, f.height, d.RGBA, d.UNSIGNED_BYTE, x), new ImageData(x, f.width, f.height);
534
- } catch {
535
- return new ImageData(1, 1);
536
- } finally {
537
- d && (d.bindBuffer(d.ARRAY_BUFFER, null), d.useProgram(null), d.viewport(0, 0, d.drawingBufferWidth, d.drawingBufferHeight), d.clearColor(0, 0, 0, 0));
538
- }
539
- }();
540
- }), [2, { commonImageHash: _(q(a, f.width, f.height).data.toString()).toString() }];
541
- } catch {
542
- return [2, { webgl: "unsupported" }];
543
- }
544
- return [2];
545
- });
546
- });
547
- });
548
- var b = function(a, e, n, r) {
549
- for (var o = (n - e) / r, i = 0, t = 0; t < r; t++)
550
- i += a(e + (t + 0.5) * o);
551
- return i * o;
552
- };
553
- v("math", function() {
554
- return y(void 0, void 0, void 0, function() {
555
- return w(this, function(a) {
556
- 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) }];
557
- });
558
- });
559
- });
560
- const ae = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
561
- let E = (a = 21) => {
562
- let e = "", n = crypto.getRandomValues(new Uint8Array(a |= 0));
563
- for (; a--; )
564
- e += ae[n[a] & 63];
565
- return e;
566
- };
567
- class M {
568
- constructor(e) {
569
- h(this, "config");
570
- this.config = e;
571
- }
572
- async getAds(e) {
573
- return [];
574
- }
575
- async onQuerySubmitted(e) {
576
- }
577
- async onQueryFetched(e, n) {
578
- }
579
- async onInputCleared() {
580
- }
581
- async onAdContainerRendered(e) {
582
- }
583
- async onAdContainerViewed(e) {
584
- }
585
- }
586
- class oe extends M {
587
- /**
588
- * Gets ads from the adMarketplace API based on the search term.
589
- */
590
- async getAds(e) {
591
- if (!this.config.admSub)
592
- return console.error("No admSub specified in config."), [];
593
- const r = `https://demofeed.is.ampfeed.com/is?${new URLSearchParams({
594
- partner: "demofeed",
595
- sub1: this.config.admSub,
596
- qt: e.searchTerm,
597
- v: "2.0",
598
- rfr: "searchcraft.io",
599
- "results-ta": `${this.config.admTextAdQuantity || 0}`,
600
- "results-pa": `${this.config.admProductAdQuantity || 0}`
601
- }).toString()}`, i = await (await fetch(r, { method: "GET" })).json(), t = i.product_ads.map(
602
- (s) => ({
603
- id: E(),
604
- adSource: "adMarketplace",
605
- admAdType: "adm-product-ad",
606
- admAd: s
607
- })
608
- ), u = i.text_ads.map((s) => ({
609
- id: E(),
610
- adSource: "adMarketplace",
611
- admAdType: "adm-text-ad",
612
- admAd: s
613
- }));
614
- return t.concat(u);
615
- }
616
- async onAdContainerViewed(e) {
617
- var r;
618
- const n = e.adClientResponseItem;
619
- (r = n.admAd) != null && r.impression_url && fetch(n.admAd.impression_url);
620
- }
621
- }
622
- class ie extends M {
623
- async getAds(e) {
624
- return [];
625
- }
626
- }
627
- const se = 1e3;
628
- class ce extends M {
629
- constructor(n) {
630
- super(n);
631
- h(this, "adCallTimeout");
632
- this.addScriptTagToDocument();
633
- }
634
- async onQuerySubmitted(n) {
635
- this.addScriptTagToDocument();
636
- }
637
- async onQueryFetched(n, r) {
638
- var o;
639
- if ((((o = r.data.hits) == null ? void 0 : o.length) || 0) === 0) {
640
- this.removeScriptTagFromDocument();
641
- return;
642
- }
643
- this.performAdCall(se);
644
- }
645
- async onInputCleared() {
646
- this.removeScriptTagFromDocument();
647
- }
648
- performAdCall(n) {
649
- this.adCallTimeout && clearTimeout(this.adCallTimeout), this.adCallTimeout = setTimeout(() => {
650
- this.addScriptTagToDocument();
651
- try {
652
- PostRelease == null || PostRelease.Start({ ptd: [this.config.nativoPlacementId] });
653
- } catch (r) {
654
- console.error(r);
655
- }
656
- }, n);
657
- }
658
- async getAds(n) {
659
- return [];
660
- }
661
- addScriptTagToDocument() {
662
- if (!document.head.querySelector("#nativo-tag")) {
663
- const n = document.createElement("script");
664
- n.type = "text/javascript", n.src = "https://s.ntv.io/serve/load.js", n.id = "nativo-tag", n.setAttribute("data-ntv-set-no-auto-start", "true"), document.head.appendChild(n);
665
- }
666
- }
667
- removeScriptTagFromDocument() {
668
- const n = document.head.querySelector("#nativo-tag");
669
- n && document.head.removeChild(n);
670
- }
671
- }
672
- const ue = 600;
673
- class de {
674
- constructor(e, n, r) {
675
- h(this, "measureRequestTimeout");
676
- h(this, "measureRequestsBatched", []);
677
- h(this, "config");
678
- h(this, "sdkInfo");
679
- h(this, "userId");
680
- h(this, "sessionId");
681
- /**
682
- * Sends a measure event to the `/measure/event` endpoint for analytics purposes.
683
- *
684
- * @param {MeasureEventName} eventName - Name of the event.
685
- * @param {Partial<MeasureRequestProperties>} properties - Additional properties to send with the event.
686
- * @param {Partial<MeasureRequestUser>} user - Additional user properites to send with the event.
687
- */
688
- h(this, "sendMeasureEvent", async (e, n = {}, r = {}) => {
689
- const o = {
690
- event_name: e,
691
- properties: {
692
- searchcraft_index_names: this.config.index,
693
- session_id: this.sessionId,
694
- ...n
695
- },
696
- user: {
697
- ...this.measureRequestUser,
698
- ...r
699
- }
700
- };
701
- if (e === "document_clicked") {
702
- const i = JSON.stringify(o), t = `${this.baseMeasureUrl}/event`;
703
- try {
704
- const u = await fetch(t, {
705
- method: "POST",
706
- headers: {
707
- "Content-Type": "application/json",
708
- Authorization: this.config.readKey,
709
- "X-Sc-User-Id": this.userId,
710
- "X-Sc-Session-Id": this.sessionId
711
- },
712
- body: i,
713
- keepalive: !0
714
- });
715
- if (!u.ok)
716
- throw new Error(
717
- `Failed to send request: ${u.status} ${u.statusText}`
718
- );
719
- } catch (u) {
720
- throw console.error("Error sending MeasureRequest:", u), u;
721
- }
722
- } else
723
- this.measureRequestsBatched.push(o), clearTimeout(this.measureRequestTimeout), this.measureRequestTimeout = setTimeout(async () => {
724
- const i = JSON.stringify({ items: this.measureRequestsBatched }), t = `${this.baseMeasureUrl}/batch`;
725
- try {
726
- const u = await fetch(t, {
727
- method: "POST",
728
- headers: {
729
- "Content-Type": "application/json",
730
- Authorization: this.config.readKey,
731
- "X-Sc-User-Id": this.userId,
732
- "X-Sc-Session-Id": this.sessionId
733
- },
734
- body: i,
735
- keepalive: !0
736
- });
737
- if (this.measureRequestsBatched = [], !u.ok)
738
- throw new Error(
739
- `Failed to send request: ${u.status} ${u.statusText}`
740
- );
741
- return;
742
- } catch (u) {
743
- throw this.measureRequestsBatched = [], console.error("Error sending MeasureRequest:", u), u;
744
- }
745
- }, ue);
746
- });
747
- this.config = e, this.sdkInfo = n, this.userId = r, this.sessionId = E(), this.sendMeasureEvent("sdk_initialized");
748
- }
749
- /**
750
- * Getter for the base url used by the /measure endpoints.
751
- */
752
- get baseMeasureUrl() {
753
- return `${this.config.endpointURL}/measure`;
754
- }
755
- /**
756
- * Getter for the measure request user. Uses config values + navigator values.
757
- */
758
- get measureRequestUser() {
759
- return {
760
- user_id: this.userId,
761
- locale: navigator.language || "en-US",
762
- os: navigator.userAgent.includes("Windows") ? "Windows" : navigator.userAgent.includes("Mac") ? "Mac" : navigator.userAgent.includes("Linux") ? "Linux" : "Unknown",
763
- platform: navigator.platform || "Unknown",
764
- sdk_name: this.sdkInfo.sdkName,
765
- sdk_version: this.sdkInfo.sdkVersion,
766
- user_agent: navigator.userAgent || "Unknown"
767
- };
768
- }
769
- }
770
- const le = (a) => a.endsWith("/") ? a.slice(0, -1) : a, A = (a) => {
771
- let e = "";
772
- if (e = a.trim(), e = e.replace(/[‘’“”]/g, (r) => ({
773
- "‘": "'",
774
- "’": "'",
775
- "“": '"',
776
- "”": '"'
777
- })[r] || r), (e.match(/"/g) || []).length % 2 !== 0)
778
- throw new Error(
779
- "The search term contains an uneven number of quote characters."
780
- );
781
- return e;
782
- }, he = 500;
783
- class me {
784
- constructor(e, n, r) {
785
- h(this, "config");
786
- h(this, "userId");
787
- h(this, "parent");
788
- h(this, "searchCompletedEventTimeout");
789
- h(this, "abortController");
790
- /**
791
- * Make the request to get the search results.
792
- * @param {properties} properties - The properties for the search.
793
- * @param sendTelemetry - Whether or not to emit measure and subscription events for this search.
794
- * @returns
795
- */
796
- h(this, "getSearchResponseItems", async (e, n = !0) => {
797
- var i, t, u, l, s, c;
798
- (i = this.abortController) == null || i.abort(
799
- "A newer search request has replaced this one."
800
- ), this.abortController = new AbortController();
801
- let r, o = "";
802
- return typeof e == "string" ? o = A(e) : (e.searchTerm = A(e.searchTerm), o = e.searchTerm), (t = this.parent.measureClient) == null || t.sendMeasureEvent("search_requested", {
803
- search_term: o
804
- }), this.parent.emitEvent("query_submitted", {
805
- name: "query_submitted",
806
- data: {
807
- searchTerm: o
808
- }
809
- }), (u = this.parent.adClient) == null || u.onQuerySubmitted(
810
- typeof e == "string" ? { searchTerm: o, mode: "exact" } : e
811
- ), typeof e == "string" ? r = await this.handleGetSearchResponseItemsWithString(o) : r = await this.handleGetSearchResponseItemsWithObject(e), n && ((l = this.parent.measureClient) == null || l.sendMeasureEvent("search_response_received", {
812
- search_term: o,
813
- number_of_documents: r.data.count
814
- }), clearTimeout(this.searchCompletedEventTimeout), this.searchCompletedEventTimeout = setTimeout(() => {
815
- var g;
816
- (g = this.parent.measureClient) == null || g.sendMeasureEvent("search_completed", {
817
- search_term: o,
818
- number_of_documents: r.data.count
819
- });
820
- }, he), this.parent.emitEvent("query_fetched", {
821
- name: "query_fetched",
822
- data: {
823
- searchTerm: o
824
- }
825
- }), (((s = r.data.hits) == null ? void 0 : s.length) || 0) === 0 && this.parent.emitEvent("no_results_returned", {
826
- name: "no_results_returned"
827
- }), (c = this.parent.adClient) == null || c.onQueryFetched(
828
- typeof e == "string" ? { searchTerm: o, mode: "exact" } : e,
829
- r
830
- )), r;
831
- });
832
- h(this, "handleGetSearchResponseItemsWithString", async (e) => {
833
- var o, i;
834
- let n;
835
- try {
836
- n = JSON.parse(e), n = {
837
- limit: this.config.searchResultsPerPage,
838
- ...n
839
- };
840
- } catch {
841
- throw new Error("Error: Query string is not valid json.");
842
- }
843
- const r = await fetch(this.baseSearchUrl, {
844
- method: "POST",
845
- headers: {
846
- Authorization: this.config.readKey,
847
- "Content-Type": "application/json",
848
- "X-Sc-User-Id": this.userId,
849
- "X-Sc-Session-Id": ((o = this.parent.measureClient) == null ? void 0 : o.sessionId) || E()
850
- },
851
- body: JSON.stringify(n),
852
- signal: (i = this.abortController) == null ? void 0 : i.signal
853
- });
854
- if (!r.ok)
855
- throw new Error(
856
- `Error: ${r.statusText} (Status: ${r.status})`
857
- );
858
- return await r.json();
859
- });
860
- h(this, "handleGetSearchResponseItemsWithObject", async (e) => {
861
- var r, o;
862
- const n = await fetch(this.baseSearchUrl, {
863
- method: "POST",
864
- headers: {
865
- Authorization: this.config.readKey,
866
- "Content-Type": "application/json",
867
- "X-Sc-User-Id": this.userId,
868
- "X-Sc-Session-Id": ((r = this.parent.measureClient) == null ? void 0 : r.sessionId) || E()
869
- },
870
- body: JSON.stringify({
871
- query: this.formatParamsForRequest(e),
872
- offset: e.offset || 0,
873
- limit: e.limit || this.config.searchResultsPerPage || 20,
874
- ...e.order_by && {
875
- order_by: e.order_by
876
- },
877
- ...e.sort && {
878
- sort: e.sort
879
- }
880
- }),
881
- signal: (o = this.abortController) == null ? void 0 : o.signal
882
- });
883
- if (!n.ok)
884
- throw new Error(
885
- `Error: ${n.statusText} (Status: ${n.status})`
886
- );
887
- return await n.json();
888
- });
889
- this.parent = e, this.config = n, this.userId = r;
890
- }
891
- /**
892
- * Getter for the base url used by the /search endpoint.
893
- */
894
- get baseSearchUrl() {
895
- return `${this.config.endpointURL}/index/${this.config.index.join(",")}/search`;
896
- }
897
- /**
898
- * Builds a query object for the SearchClient request.
899
- * @param {properties} properties - The properties for the search.
900
- * @returns {SearchClientQuery} - A properly formatted SearchClient query object.
901
- */
902
- formatParamsForRequest(e) {
903
- const n = [];
904
- let r = "should";
905
- e.facetPathsForIndexFields && Object.keys(e.facetPathsForIndexFields).forEach((t) => {
906
- var l;
907
- const u = (l = e.facetPathsForIndexFields) == null ? void 0 : l[t];
908
- u && (r = "must", n.push({
909
- occur: "must",
910
- exact: {
911
- ctx: A(u.value)
912
- }
913
- }));
914
- }), e.rangeValueForIndexFields && Object.keys(e.rangeValueForIndexFields).forEach((t) => {
915
- var l;
916
- const u = (l = e.rangeValueForIndexFields) == null ? void 0 : l[t];
917
- u && (r = "must", n.push({
918
- occur: "must",
919
- exact: {
920
- ctx: A(u.value)
921
- }
922
- }));
923
- });
924
- const o = e.searchTerm, i = e.mode === "fuzzy" ? { fuzzy: { ctx: o } } : {
925
- exact: {
926
- ctx: `${o.startsWith('"') ? o : `"${o}"`}`
927
- }
928
- };
929
- return n.push({
930
- occur: e.mode === "exact" ? "must" : r,
931
- // Valid, as 'occur' is a required property in SearchClientQuery
932
- ...i
933
- }), n;
934
- }
935
- }
936
- class ve {
937
- constructor(e, n) {
938
- h(this, "config");
939
- h(this, "measureClient");
940
- h(this, "searchClient");
941
- h(this, "adClient");
942
- h(this, "userId");
943
- h(this, "requestTimeout");
944
- h(this, "subscriptionEvents", {});
945
- h(this, "getResponseItems", (e, n, r) => {
946
- const o = async () => {
947
- (async () => {
948
- var l;
949
- if (!this.searchClient) {
950
- console.error("Search client was not initialized.");
951
- return;
952
- }
953
- let i;
954
- try {
955
- i = await this.searchClient.getSearchResponseItems(e);
956
- } catch (s) {
957
- console.info(`Search request error: ${s}`);
958
- return;
959
- }
960
- if (!i) {
961
- console.error("Search request error: Search response was undefined");
962
- return;
963
- }
964
- const t = (i.data.hits || []).filter((s) => !!s.doc).map((s) => ({
965
- id: E(),
966
- document: s.doc || { id: -1 },
967
- source_index: s.source_index,
968
- type: "SearchDocument"
969
- }));
970
- let u;
971
- if (typeof e == "object") {
972
- const s = structuredClone(
973
- e
974
- );
975
- if (s.facetPathsForIndexFields && Object.keys(s.facetPathsForIndexFields).length > 0) {
976
- s.facetPathsForIndexFields = void 0;
977
- try {
978
- u = await ((l = this == null ? void 0 : this.searchClient) == null ? void 0 : l.getSearchResponseItems(s, !1));
979
- } catch (c) {
980
- console.info(`Search request error: ${c}`);
981
- }
982
- }
983
- }
984
- n(e, i, t, u);
985
- })(), (async () => {
986
- if (this.adClient && typeof e != "string") {
987
- const i = await this.adClient.getAds(e);
988
- r(i);
989
- }
990
- })();
991
- };
992
- clearTimeout(this.requestTimeout), this.config.searchDebounceDelay ? this.requestTimeout = setTimeout(
993
- o,
994
- this.config.searchDebounceDelay
995
- ) : o();
996
- });
997
- if (!e.endpointURL || !e.index || !e.readKey)
998
- throw new Error(
999
- "Endpoint URL, Index value(s), and Read Key must be provided"
1000
- );
1001
- this.config = {
1002
- ...e,
1003
- // Strips off the trailing '/' from an endpointURL if one is accidentally added
1004
- endpointURL: le(e.endpointURL)
1005
- }, this.userId = "", typeof window < "u" && typeof customElements < "u" && n.sdkName === "@searchcraft/javascript-sdk" && globalThis.__scDefineCustomElements__ && globalThis.__scDefineCustomElements__(), typeof window < "u" && (this.initClients(this.config, n), this.initInputForms(), this.startObservingMutations());
1006
- }
1007
- initInputForms() {
1008
- const e = document.querySelectorAll(
1009
- "searchcraft-input-form"
1010
- );
1011
- setTimeout(() => {
1012
- e.forEach((n) => {
1013
- n.core = this;
1014
- });
1015
- }, 40);
1016
- }
1017
- /**
1018
- * When changes happen in the DOM, we want to link any input forms found to the instance of the core.
1019
- */
1020
- startObservingMutations() {
1021
- new MutationObserver((n, r) => {
1022
- let o = !1;
1023
- for (const i of n)
1024
- i.type === "childList" && i.addedNodes.forEach((t) => {
1025
- t.nodeType === 1 && (t.getAttribute("class") || "").toLowerCase() === "searchcraft-input-form" && (o = !0);
1026
- });
1027
- o && this.initInputForms();
1028
- }).observe(document.body, { childList: !0, subtree: !0 });
1029
- }
1030
- initClients(e, n) {
1031
- setTimeout(async () => {
1032
- let r = this.config.userId;
1033
- switch (r || (r = await z()), this.measureClient = new de(e, n, r), this.searchClient = new me(this, e, r), e.adSource) {
1034
- case "adMarketplace":
1035
- this.adClient = new oe(e);
1036
- break;
1037
- case "Nativo":
1038
- this.adClient = new ce(e);
1039
- break;
1040
- case "Custom":
1041
- this.adClient = new ie(e);
1042
- break;
1043
- }
1044
- this.emitEvent("initialized", {
1045
- name: "initialized"
1046
- });
1047
- }, 300);
1048
- }
1049
- emitEvent(e, n) {
1050
- var r;
1051
- (r = this.subscriptionEvents[e]) == null || r.forEach((o) => {
1052
- o(n);
1053
- });
1054
- }
1055
- subscribe(e, n) {
1056
- return this.subscriptionEvents[e] || (this.subscriptionEvents[e] = []), this.subscriptionEvents[e].push(
1057
- n
1058
- ), () => {
1059
- this.subscriptionEvents[e] = this.subscriptionEvents[e].filter((r) => r !== n);
1060
- };
1061
- }
1062
- /**
1063
- * Called when a `<searchcraft-ad>` component is rendered
1064
- */
1065
- handleAdContainerRendered(e) {
1066
- var n;
1067
- (n = this.adClient) == null || n.onAdContainerRendered(e), this.emitEvent("ad_container_rendered", {
1068
- name: "ad_container_rendered",
1069
- data: {
1070
- adContainerId: e.adContainerId,
1071
- adSource: e.adSource,
1072
- searchTerm: e.searchTerm
1073
- }
1074
- });
1075
- }
1076
- /**
1077
- * Called when a `<searchcraft-ad>` is viewed
1078
- */
1079
- handleAdContainerViewed(e) {
1080
- var n;
1081
- (n = this.adClient) == null || n.onAdContainerViewed(e), this.emitEvent("ad_container_viewed", {
1082
- name: "ad_container_viewed",
1083
- data: {
1084
- adContainerId: e.adContainerId,
1085
- adSource: e.adSource,
1086
- searchTerm: e.searchTerm
1087
- }
1088
- });
1089
- }
1090
- /**
1091
- * Perform various actions when the input is cleared
1092
- */
1093
- handleInputCleared() {
1094
- var e;
1095
- this.emitEvent("input_cleared", {
1096
- name: "input_cleared"
1097
- }), (e = this.adClient) == null || e.onInputCleared();
1098
- }
1099
- }
1100
-
1101
- var zustand = {};
1102
-
1103
- var vanilla$1 = {};
1104
-
1105
- const createStoreImpl = (createState) => {
1106
- let state;
1107
- const listeners = /* @__PURE__ */ new Set();
1108
- const setState = (partial, replace) => {
1109
- const nextState = typeof partial === "function" ? partial(state) : partial;
1110
- if (!Object.is(nextState, state)) {
1111
- const previousState = state;
1112
- state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
1113
- listeners.forEach((listener) => listener(state, previousState));
1114
- }
1115
- };
1116
- const getState = () => state;
1117
- const getInitialState = () => initialState;
1118
- const subscribe = (listener) => {
1119
- listeners.add(listener);
1120
- return () => listeners.delete(listener);
1121
- };
1122
- const api = { setState, getState, getInitialState, subscribe };
1123
- const initialState = state = createState(setState, getState, api);
1124
- return api;
1125
- };
1126
- const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1127
-
1128
- vanilla$1.createStore = createStore;
1129
-
1130
- var react$1 = {};
1131
-
1132
- var react = {exports: {}};
1133
-
1134
- var react_production = {};
1135
-
1136
- /**
1137
- * @license React
1138
- * react.production.js
1139
- *
1140
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1141
- *
1142
- * This source code is licensed under the MIT license found in the
1143
- * LICENSE file in the root directory of this source tree.
1144
- */
1145
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
1146
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
1147
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
1148
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
1149
- REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
1150
- REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
1151
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
1152
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
1153
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
1154
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
1155
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
1156
- MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
1157
- function getIteratorFn(maybeIterable) {
1158
- if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
1159
- maybeIterable =
1160
- (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
1161
- maybeIterable["@@iterator"];
1162
- return "function" === typeof maybeIterable ? maybeIterable : null;
1163
- }
1164
- var ReactNoopUpdateQueue = {
1165
- isMounted: function () {
1166
- return !1;
1167
- },
1168
- enqueueForceUpdate: function () {},
1169
- enqueueReplaceState: function () {},
1170
- enqueueSetState: function () {}
1171
- },
1172
- assign = Object.assign,
1173
- emptyObject = {};
1174
- function Component(props, context, updater) {
1175
- this.props = props;
1176
- this.context = context;
1177
- this.refs = emptyObject;
1178
- this.updater = updater || ReactNoopUpdateQueue;
1179
- }
1180
- Component.prototype.isReactComponent = {};
1181
- Component.prototype.setState = function (partialState, callback) {
1182
- if (
1183
- "object" !== typeof partialState &&
1184
- "function" !== typeof partialState &&
1185
- null != partialState
1186
- )
1187
- throw Error(
1188
- "takes an object of state variables to update or a function which returns an object of state variables."
1189
- );
1190
- this.updater.enqueueSetState(this, partialState, callback, "setState");
1191
- };
1192
- Component.prototype.forceUpdate = function (callback) {
1193
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
1194
- };
1195
- function ComponentDummy() {}
1196
- ComponentDummy.prototype = Component.prototype;
1197
- function PureComponent(props, context, updater) {
1198
- this.props = props;
1199
- this.context = context;
1200
- this.refs = emptyObject;
1201
- this.updater = updater || ReactNoopUpdateQueue;
1202
- }
1203
- var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
1204
- pureComponentPrototype.constructor = PureComponent;
1205
- assign(pureComponentPrototype, Component.prototype);
1206
- pureComponentPrototype.isPureReactComponent = !0;
1207
- var isArrayImpl = Array.isArray,
1208
- ReactSharedInternals = { H: null, A: null, T: null, S: null },
1209
- hasOwnProperty = Object.prototype.hasOwnProperty;
1210
- function ReactElement(type, key, self, source, owner, props) {
1211
- self = props.ref;
1212
- return {
1213
- $$typeof: REACT_ELEMENT_TYPE,
1214
- type: type,
1215
- key: key,
1216
- ref: void 0 !== self ? self : null,
1217
- props: props
1218
- };
1219
- }
1220
- function cloneAndReplaceKey(oldElement, newKey) {
1221
- return ReactElement(
1222
- oldElement.type,
1223
- newKey,
1224
- void 0,
1225
- void 0,
1226
- void 0,
1227
- oldElement.props
1228
- );
1229
- }
1230
- function isValidElement(object) {
1231
- return (
1232
- "object" === typeof object &&
1233
- null !== object &&
1234
- object.$$typeof === REACT_ELEMENT_TYPE
1235
- );
1236
- }
1237
- function escape(key) {
1238
- var escaperLookup = { "=": "=0", ":": "=2" };
1239
- return (
1240
- "$" +
1241
- key.replace(/[=:]/g, function (match) {
1242
- return escaperLookup[match];
1243
- })
1244
- );
1245
- }
1246
- var userProvidedKeyEscapeRegex = /\/+/g;
1247
- function getElementKey(element, index) {
1248
- return "object" === typeof element && null !== element && null != element.key
1249
- ? escape("" + element.key)
1250
- : index.toString(36);
1251
- }
1252
- function noop$1() {}
1253
- function resolveThenable(thenable) {
1254
- switch (thenable.status) {
1255
- case "fulfilled":
1256
- return thenable.value;
1257
- case "rejected":
1258
- throw thenable.reason;
1259
- default:
1260
- switch (
1261
- ("string" === typeof thenable.status
1262
- ? thenable.then(noop$1, noop$1)
1263
- : ((thenable.status = "pending"),
1264
- thenable.then(
1265
- function (fulfilledValue) {
1266
- "pending" === thenable.status &&
1267
- ((thenable.status = "fulfilled"),
1268
- (thenable.value = fulfilledValue));
1269
- },
1270
- function (error) {
1271
- "pending" === thenable.status &&
1272
- ((thenable.status = "rejected"), (thenable.reason = error));
1273
- }
1274
- )),
1275
- thenable.status)
1276
- ) {
1277
- case "fulfilled":
1278
- return thenable.value;
1279
- case "rejected":
1280
- throw thenable.reason;
1281
- }
1282
- }
1283
- throw thenable;
1284
- }
1285
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1286
- var type = typeof children;
1287
- if ("undefined" === type || "boolean" === type) children = null;
1288
- var invokeCallback = !1;
1289
- if (null === children) invokeCallback = !0;
1290
- else
1291
- switch (type) {
1292
- case "bigint":
1293
- case "string":
1294
- case "number":
1295
- invokeCallback = !0;
1296
- break;
1297
- case "object":
1298
- switch (children.$$typeof) {
1299
- case REACT_ELEMENT_TYPE:
1300
- case REACT_PORTAL_TYPE:
1301
- invokeCallback = !0;
1302
- break;
1303
- case REACT_LAZY_TYPE:
1304
- return (
1305
- (invokeCallback = children._init),
1306
- mapIntoArray(
1307
- invokeCallback(children._payload),
1308
- array,
1309
- escapedPrefix,
1310
- nameSoFar,
1311
- callback
1312
- )
1313
- );
1314
- }
1315
- }
1316
- if (invokeCallback)
1317
- return (
1318
- (callback = callback(children)),
1319
- (invokeCallback =
1320
- "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar),
1321
- isArrayImpl(callback)
1322
- ? ((escapedPrefix = ""),
1323
- null != invokeCallback &&
1324
- (escapedPrefix =
1325
- invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"),
1326
- mapIntoArray(callback, array, escapedPrefix, "", function (c) {
1327
- return c;
1328
- }))
1329
- : null != callback &&
1330
- (isValidElement(callback) &&
1331
- (callback = cloneAndReplaceKey(
1332
- callback,
1333
- escapedPrefix +
1334
- (null == callback.key ||
1335
- (children && children.key === callback.key)
1336
- ? ""
1337
- : ("" + callback.key).replace(
1338
- userProvidedKeyEscapeRegex,
1339
- "$&/"
1340
- ) + "/") +
1341
- invokeCallback
1342
- )),
1343
- array.push(callback)),
1344
- 1
1345
- );
1346
- invokeCallback = 0;
1347
- var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
1348
- if (isArrayImpl(children))
1349
- for (var i = 0; i < children.length; i++)
1350
- (nameSoFar = children[i]),
1351
- (type = nextNamePrefix + getElementKey(nameSoFar, i)),
1352
- (invokeCallback += mapIntoArray(
1353
- nameSoFar,
1354
- array,
1355
- escapedPrefix,
1356
- type,
1357
- callback
1358
- ));
1359
- else if (((i = getIteratorFn(children)), "function" === typeof i))
1360
- for (
1361
- children = i.call(children), i = 0;
1362
- !(nameSoFar = children.next()).done;
1363
-
1364
- )
1365
- (nameSoFar = nameSoFar.value),
1366
- (type = nextNamePrefix + getElementKey(nameSoFar, i++)),
1367
- (invokeCallback += mapIntoArray(
1368
- nameSoFar,
1369
- array,
1370
- escapedPrefix,
1371
- type,
1372
- callback
1373
- ));
1374
- else if ("object" === type) {
1375
- if ("function" === typeof children.then)
1376
- return mapIntoArray(
1377
- resolveThenable(children),
1378
- array,
1379
- escapedPrefix,
1380
- nameSoFar,
1381
- callback
1382
- );
1383
- array = String(children);
1384
- throw Error(
1385
- "Objects are not valid as a React child (found: " +
1386
- ("[object Object]" === array
1387
- ? "object with keys {" + Object.keys(children).join(", ") + "}"
1388
- : array) +
1389
- "). If you meant to render a collection of children, use an array instead."
1390
- );
1391
- }
1392
- return invokeCallback;
1393
- }
1394
- function mapChildren(children, func, context) {
1395
- if (null == children) return children;
1396
- var result = [],
1397
- count = 0;
1398
- mapIntoArray(children, result, "", "", function (child) {
1399
- return func.call(context, child, count++);
1400
- });
1401
- return result;
1402
- }
1403
- function lazyInitializer(payload) {
1404
- if (-1 === payload._status) {
1405
- var ctor = payload._result;
1406
- ctor = ctor();
1407
- ctor.then(
1408
- function (moduleObject) {
1409
- if (0 === payload._status || -1 === payload._status)
1410
- (payload._status = 1), (payload._result = moduleObject);
1411
- },
1412
- function (error) {
1413
- if (0 === payload._status || -1 === payload._status)
1414
- (payload._status = 2), (payload._result = error);
1415
- }
1416
- );
1417
- -1 === payload._status && ((payload._status = 0), (payload._result = ctor));
1418
- }
1419
- if (1 === payload._status) return payload._result.default;
1420
- throw payload._result;
1421
- }
1422
- var reportGlobalError =
1423
- "function" === typeof reportError
1424
- ? reportError
1425
- : function (error) {
1426
- if (
1427
- "object" === typeof window &&
1428
- "function" === typeof window.ErrorEvent
1429
- ) {
1430
- var event = new window.ErrorEvent("error", {
1431
- bubbles: !0,
1432
- cancelable: !0,
1433
- message:
1434
- "object" === typeof error &&
1435
- null !== error &&
1436
- "string" === typeof error.message
1437
- ? String(error.message)
1438
- : String(error),
1439
- error: error
1440
- });
1441
- if (!window.dispatchEvent(event)) return;
1442
- } else if (
1443
- "object" === typeof process &&
1444
- "function" === typeof process.emit
1445
- ) {
1446
- process.emit("uncaughtException", error);
1447
- return;
1448
- }
1449
- console.error(error);
1450
- };
1451
- function noop() {}
1452
- react_production.Children = {
1453
- map: mapChildren,
1454
- forEach: function (children, forEachFunc, forEachContext) {
1455
- mapChildren(
1456
- children,
1457
- function () {
1458
- forEachFunc.apply(this, arguments);
1459
- },
1460
- forEachContext
1461
- );
1462
- },
1463
- count: function (children) {
1464
- var n = 0;
1465
- mapChildren(children, function () {
1466
- n++;
1467
- });
1468
- return n;
1469
- },
1470
- toArray: function (children) {
1471
- return (
1472
- mapChildren(children, function (child) {
1473
- return child;
1474
- }) || []
1475
- );
1476
- },
1477
- only: function (children) {
1478
- if (!isValidElement(children))
1479
- throw Error(
1480
- "React.Children.only expected to receive a single React element child."
1481
- );
1482
- return children;
1483
- }
1484
- };
1485
- react_production.Component = Component;
1486
- react_production.Fragment = REACT_FRAGMENT_TYPE;
1487
- react_production.Profiler = REACT_PROFILER_TYPE;
1488
- react_production.PureComponent = PureComponent;
1489
- react_production.StrictMode = REACT_STRICT_MODE_TYPE;
1490
- react_production.Suspense = REACT_SUSPENSE_TYPE;
1491
- react_production.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
1492
- ReactSharedInternals;
1493
- react_production.act = function () {
1494
- throw Error("act(...) is not supported in production builds of React.");
1495
- };
1496
- react_production.cache = function (fn) {
1497
- return function () {
1498
- return fn.apply(null, arguments);
1499
- };
1500
- };
1501
- react_production.cloneElement = function (element, config, children) {
1502
- if (null === element || void 0 === element)
1503
- throw Error(
1504
- "The argument must be a React element, but you passed " + element + "."
1505
- );
1506
- var props = assign({}, element.props),
1507
- key = element.key,
1508
- owner = void 0;
1509
- if (null != config)
1510
- for (propName in (void 0 !== config.ref && (owner = void 0),
1511
- void 0 !== config.key && (key = "" + config.key),
1512
- config))
1513
- !hasOwnProperty.call(config, propName) ||
1514
- "key" === propName ||
1515
- "__self" === propName ||
1516
- "__source" === propName ||
1517
- ("ref" === propName && void 0 === config.ref) ||
1518
- (props[propName] = config[propName]);
1519
- var propName = arguments.length - 2;
1520
- if (1 === propName) props.children = children;
1521
- else if (1 < propName) {
1522
- for (var childArray = Array(propName), i = 0; i < propName; i++)
1523
- childArray[i] = arguments[i + 2];
1524
- props.children = childArray;
1525
- }
1526
- return ReactElement(element.type, key, void 0, void 0, owner, props);
1527
- };
1528
- react_production.createContext = function (defaultValue) {
1529
- defaultValue = {
1530
- $$typeof: REACT_CONTEXT_TYPE,
1531
- _currentValue: defaultValue,
1532
- _currentValue2: defaultValue,
1533
- _threadCount: 0,
1534
- Provider: null,
1535
- Consumer: null
1536
- };
1537
- defaultValue.Provider = defaultValue;
1538
- defaultValue.Consumer = {
1539
- $$typeof: REACT_CONSUMER_TYPE,
1540
- _context: defaultValue
1541
- };
1542
- return defaultValue;
1543
- };
1544
- react_production.createElement = function (type, config, children) {
1545
- var propName,
1546
- props = {},
1547
- key = null;
1548
- if (null != config)
1549
- for (propName in (void 0 !== config.key && (key = "" + config.key), config))
1550
- hasOwnProperty.call(config, propName) &&
1551
- "key" !== propName &&
1552
- "__self" !== propName &&
1553
- "__source" !== propName &&
1554
- (props[propName] = config[propName]);
1555
- var childrenLength = arguments.length - 2;
1556
- if (1 === childrenLength) props.children = children;
1557
- else if (1 < childrenLength) {
1558
- for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
1559
- childArray[i] = arguments[i + 2];
1560
- props.children = childArray;
1561
- }
1562
- if (type && type.defaultProps)
1563
- for (propName in ((childrenLength = type.defaultProps), childrenLength))
1564
- void 0 === props[propName] &&
1565
- (props[propName] = childrenLength[propName]);
1566
- return ReactElement(type, key, void 0, void 0, null, props);
1567
- };
1568
- react_production.createRef = function () {
1569
- return { current: null };
1570
- };
1571
- react_production.forwardRef = function (render) {
1572
- return { $$typeof: REACT_FORWARD_REF_TYPE, render: render };
1573
- };
1574
- react_production.isValidElement = isValidElement;
1575
- react_production.lazy = function (ctor) {
1576
- return {
1577
- $$typeof: REACT_LAZY_TYPE,
1578
- _payload: { _status: -1, _result: ctor },
1579
- _init: lazyInitializer
1580
- };
1581
- };
1582
- react_production.memo = function (type, compare) {
1583
- return {
1584
- $$typeof: REACT_MEMO_TYPE,
1585
- type: type,
1586
- compare: void 0 === compare ? null : compare
1587
- };
1588
- };
1589
- react_production.startTransition = function (scope) {
1590
- var prevTransition = ReactSharedInternals.T,
1591
- currentTransition = {};
1592
- ReactSharedInternals.T = currentTransition;
1593
- try {
1594
- var returnValue = scope(),
1595
- onStartTransitionFinish = ReactSharedInternals.S;
1596
- null !== onStartTransitionFinish &&
1597
- onStartTransitionFinish(currentTransition, returnValue);
1598
- "object" === typeof returnValue &&
1599
- null !== returnValue &&
1600
- "function" === typeof returnValue.then &&
1601
- returnValue.then(noop, reportGlobalError);
1602
- } catch (error) {
1603
- reportGlobalError(error);
1604
- } finally {
1605
- ReactSharedInternals.T = prevTransition;
1606
- }
1607
- };
1608
- react_production.unstable_useCacheRefresh = function () {
1609
- return ReactSharedInternals.H.useCacheRefresh();
1610
- };
1611
- react_production.use = function (usable) {
1612
- return ReactSharedInternals.H.use(usable);
1613
- };
1614
- react_production.useActionState = function (action, initialState, permalink) {
1615
- return ReactSharedInternals.H.useActionState(action, initialState, permalink);
1616
- };
1617
- react_production.useCallback = function (callback, deps) {
1618
- return ReactSharedInternals.H.useCallback(callback, deps);
1619
- };
1620
- react_production.useContext = function (Context) {
1621
- return ReactSharedInternals.H.useContext(Context);
1622
- };
1623
- react_production.useDebugValue = function () {};
1624
- react_production.useDeferredValue = function (value, initialValue) {
1625
- return ReactSharedInternals.H.useDeferredValue(value, initialValue);
1626
- };
1627
- react_production.useEffect = function (create, deps) {
1628
- return ReactSharedInternals.H.useEffect(create, deps);
1629
- };
1630
- react_production.useId = function () {
1631
- return ReactSharedInternals.H.useId();
1632
- };
1633
- react_production.useImperativeHandle = function (ref, create, deps) {
1634
- return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
1635
- };
1636
- react_production.useInsertionEffect = function (create, deps) {
1637
- return ReactSharedInternals.H.useInsertionEffect(create, deps);
1638
- };
1639
- react_production.useLayoutEffect = function (create, deps) {
1640
- return ReactSharedInternals.H.useLayoutEffect(create, deps);
1641
- };
1642
- react_production.useMemo = function (create, deps) {
1643
- return ReactSharedInternals.H.useMemo(create, deps);
1644
- };
1645
- react_production.useOptimistic = function (passthrough, reducer) {
1646
- return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
1647
- };
1648
- react_production.useReducer = function (reducer, initialArg, init) {
1649
- return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
1650
- };
1651
- react_production.useRef = function (initialValue) {
1652
- return ReactSharedInternals.H.useRef(initialValue);
1653
- };
1654
- react_production.useState = function (initialState) {
1655
- return ReactSharedInternals.H.useState(initialState);
1656
- };
1657
- react_production.useSyncExternalStore = function (
1658
- subscribe,
1659
- getSnapshot,
1660
- getServerSnapshot
1661
- ) {
1662
- return ReactSharedInternals.H.useSyncExternalStore(
1663
- subscribe,
1664
- getSnapshot,
1665
- getServerSnapshot
1666
- );
1667
- };
1668
- react_production.useTransition = function () {
1669
- return ReactSharedInternals.H.useTransition();
1670
- };
1671
- react_production.version = "19.0.0";
1672
-
1673
- {
1674
- react.exports = react_production;
1675
- }
1676
-
1677
- var React = react.exports;
1678
- var vanilla = vanilla$1;
1679
-
1680
- const identity = (arg) => arg;
1681
- function useStore(api, selector = identity) {
1682
- const slice = React.useSyncExternalStore(
1683
- api.subscribe,
1684
- () => selector(api.getState()),
1685
- () => selector(api.getInitialState())
1686
- );
1687
- React.useDebugValue(slice);
1688
- return slice;
1689
- }
1690
- const createImpl = (createState) => {
1691
- const api = vanilla.createStore(createState);
1692
- const useBoundStore = (selector) => useStore(api, selector);
1693
- Object.assign(useBoundStore, api);
1694
- return useBoundStore;
1695
- };
1696
- const create = (createState) => createState ? createImpl(createState) : createImpl;
1697
-
1698
- react$1.create = create;
1699
- react$1.useStore = useStore;
1700
-
1701
- (function (exports) {
1702
-
1703
- var vanilla = vanilla$1;
1704
- var react = react$1;
1705
-
1706
-
1707
-
1708
- Object.keys(vanilla).forEach(function (k) {
1709
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1710
- enumerable: true,
1711
- get: function () { return vanilla[k]; }
1712
- });
1713
- });
1714
- Object.keys(react).forEach(function (k) {
1715
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1716
- enumerable: true,
1717
- get: function () { return react[k]; }
1718
- });
1719
- });
1720
- }(zustand));
1721
-
1722
- const initialSearchcraftStateValues = {
1723
- adClientResponseItems: [],
1724
- core: undefined,
1725
- hotkey: 'k',
1726
- hotkeyModifier: 'meta',
1727
- logger: undefined,
1728
- facetPathsForIndexFields: {},
1729
- initialQuery: '',
1730
- initialSearchClientResponseItems: [],
1731
- isPopoverVisible: false,
1732
- isSearchInProgress: false,
1733
- rangeValueForIndexFields: {},
1734
- searchTerm: '',
1735
- searchMode: 'fuzzy',
1736
- searchClientRequest: undefined,
1737
- searchClientResponseItems: [],
1738
- searchResponseTimeTaken: undefined,
1739
- searchResponseFacetPrime: undefined,
1740
- supplementalFacetPrime: undefined,
1741
- searchResultsCount: 0,
1742
- searchResultsPerPage: 20,
1743
- searchResultsPage: 1,
1744
- sortType: undefined,
1745
- orderByField: undefined,
1746
- // Callbacks
1747
- afterInit: () => { },
1748
- };
1749
- const searchcraftStore = zustand.createStore((_set, get) => {
1750
- const functions = {
1751
- set: (state) => {
1752
- _set(state);
1753
- return get();
1754
- },
1755
- addFacetPathsForIndexField: (facetPaths) => functions.set((state) => ({
1756
- facetPathsForIndexFields: {
1757
- ...state.facetPathsForIndexFields,
1758
- [facetPaths.fieldName]: facetPaths,
1759
- },
1760
- })),
1761
- addRangeValueForIndexField: (rangeValue) => functions.set((state) => ({
1762
- rangeValueForIndexFields: {
1763
- ...state.rangeValueForIndexFields,
1764
- [rangeValue.fieldName]: rangeValue,
1765
- },
1766
- })),
1767
- getSearchcraftCore: () => {
1768
- const { core } = get();
1769
- return core;
1770
- },
1771
- init: (core, debug = false) => {
1772
- const logger = debug
1773
- ? new pe({ logLevel: O.DEBUG })
1774
- : undefined;
1775
- const state = functions.set({
1776
- core,
1777
- logger,
1778
- searchResultsPerPage: core?.config.searchResultsPerPage || 20,
1779
- });
1780
- core?.subscribe('initialized', () => {
1781
- if (state.afterInit) {
1782
- state.afterInit(state);
1783
- }
1784
- });
1785
- },
1786
- removeFacetPathsForIndexField: (fieldName) => functions.set((state) => {
1787
- const currentPaths = state.facetPathsForIndexFields;
1788
- delete currentPaths[fieldName];
1789
- return {
1790
- facetPathsForIndexFields: {
1791
- ...currentPaths,
1792
- },
1793
- };
1794
- }),
1795
- removeRangeValueForIndexField: (fieldName) => functions.set((state) => {
1796
- const currentValues = state.rangeValueForIndexFields;
1797
- delete currentValues[fieldName];
1798
- return {
1799
- rangeValueForIndexFields: {
1800
- ...currentValues,
1801
- },
1802
- };
1803
- }),
1804
- resetFacetPaths: () => {
1805
- functions.set({
1806
- facetPathsForIndexFields: {},
1807
- });
1808
- },
1809
- search: async () => {
1810
- const state = get();
1811
- state.logger?.log(O.INFO, `Starting search with search term: "${state.searchTerm}"`);
1812
- if (!state.core) {
1813
- throw new Error('Searchcraft instance is not initialized.');
1814
- }
1815
- if (!state.searchTerm.trim()) {
1816
- state.logger?.log(O.INFO, 'No search request was made: search term was empty.');
1817
- functions.set({
1818
- searchClientResponseItems: [],
1819
- searchResultsCount: 0,
1820
- searchResultsPage: 1,
1821
- searchTerm: '',
1822
- });
1823
- return;
1824
- }
1825
- functions.set({ isSearchInProgress: true });
1826
- state.core.getResponseItems({
1827
- searchTerm: state.searchTerm,
1828
- mode: state.searchMode,
1829
- sort: state.sortType,
1830
- order_by: state.orderByField,
1831
- facetPathsForIndexFields: state.facetPathsForIndexFields,
1832
- rangeValueForIndexFields: state.rangeValueForIndexFields,
1833
- offset: state.searchResultsPerPage
1834
- ? state.searchResultsPerPage * (state.searchResultsPage - 1)
1835
- : 0,
1836
- limit: state.searchResultsPerPage,
1837
- }, functions.setSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
1838
- },
1839
- setAdClientResponseItems: (items) => functions.set({ adClientResponseItems: items }),
1840
- setSearchClientResponseItemsFromResponse: (request, response, items, supplementalResponse) => {
1841
- const { facets, count = 0, time_taken = 0 } = response.data;
1842
- const state = functions.set((state) => {
1843
- return {
1844
- isSearchInProgress: false,
1845
- searchClientResponseItems: items,
1846
- searchResponseTimeTaken: time_taken,
1847
- searchResultsPage:
1848
- // Reset to first page when response count changes
1849
- count === state.searchResultsCount ? state.searchResultsPage : 1,
1850
- searchResultsCount: count,
1851
- searchResponseFacetPrime: facets,
1852
- supplementalFacetPrime: supplementalResponse?.data.facets,
1853
- searchClientRequest: request,
1854
- };
1855
- });
1856
- state.logger?.log(O.DEBUG, `Search results: ${JSON.stringify(items)}`);
1857
- state.logger?.log(O.DEBUG, `Facets from response: ${JSON.stringify(facets)}`);
1858
- },
1859
- setInitialSearchClientResponseItemsFromResponse: (request, response, items) => {
1860
- const state = get();
1861
- const { count = 0, time_taken = 0 } = response.data;
1862
- functions.set((state) => {
1863
- return {
1864
- isSearchInProgress: false,
1865
- initialSearchClientResponseItems: items,
1866
- searchResponseTimeTaken: time_taken,
1867
- searchResultsPage:
1868
- // Reset to first page when response count changes
1869
- count === state.searchResultsCount ? state.searchResultsPage : 1,
1870
- searchResultsCount: count,
1871
- searchClientRequest: request,
1872
- };
1873
- });
1874
- state.logger?.log(O.DEBUG, `Search results: ${JSON.stringify(items)}`);
1875
- },
1876
- setInitialQuery: async (query) => {
1877
- const state = functions.set({ initialQuery: query });
1878
- state.logger?.log(O.INFO, `Starting search with query: "${state.initialQuery}"`);
1879
- if (!state.core) {
1880
- throw new Error('Searchcraft instance is not initialized.');
1881
- }
1882
- await state.core.getResponseItems(query, functions.setInitialSearchClientResponseItemsFromResponse, functions.setAdClientResponseItems);
1883
- },
1884
- setPopoverVisibility: (isVisible) => functions.set({
1885
- isPopoverVisible: isVisible,
1886
- }),
1887
- setSearchMode: (mode) => functions.set({ searchMode: mode }),
1888
- setSortOrder: ({ orderByField, sortType }) => functions.set({ sortType, orderByField }),
1889
- setSearchTerm: (searchTerm) => {
1890
- const { core } = get();
1891
- if (searchTerm.length === 0) {
1892
- core?.handleInputCleared();
1893
- }
1894
- /**
1895
- * When a new searchTerm is set, also reset the sort type, search mode, and facet paths.
1896
- */
1897
- functions.set({
1898
- searchTerm,
1899
- });
1900
- },
1901
- setSearchClientResponseItems: (items) => functions.set({ searchClientResponseItems: items }),
1902
- setSearchResultsCount: (count) => functions.set({ searchResultsCount: count }),
1903
- setSearchResultsPage: async (page) => {
1904
- functions.set({ searchResultsPage: page });
1905
- await functions.search();
1906
- },
1907
- setSearchResultsPerPage: async (perPage) => {
1908
- functions.set({ searchResultsPerPage: perPage });
1909
- await functions.search();
1910
- },
1911
- setHotKeyAndHotKeyModifier: (hotkey, hotkeyModifier) => {
1912
- const { hotkey: initialHotkey, hotkeyModifier: initialHotkeyModifier } = initialSearchcraftStateValues;
1913
- functions.set({
1914
- hotkey: hotkey || initialHotkey,
1915
- hotkeyModifier: hotkeyModifier || initialHotkeyModifier,
1916
- });
1917
- },
1918
- };
1919
- const stateObject = {
1920
- ...initialSearchcraftStateValues,
1921
- ...functions,
1922
- };
1923
- return stateObject;
1924
- });
1925
-
1926
- export { searchcraftStore as s, ve as v };
1927
-
1928
- //# sourceMappingURL=p-b54873ff.js.map