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