@coveops/abi 1.5.8 → 2.0.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/abi/abi.css +206 -1
- package/dist/abi/abi.esm.js +129 -1
- package/dist/abi/app-globals-0f993ce5.js +3 -0
- package/dist/abi/css-shim-04165e59.js +4 -0
- package/dist/abi/dom-26e7cb2c.js +73 -0
- package/dist/{esm → abi}/faq-popup-component.entry.js +3 -4
- package/dist/abi/headless.esm-c328011d.js +72 -0
- package/dist/abi/index-4c45f50c.js +3064 -0
- package/dist/abi/index-bf9cad6e.js +4108 -0
- package/dist/abi/index.esm.js +168 -1
- package/dist/{esm → abi}/recs-initialization-helper.entry.js +3 -3
- package/dist/{esm → abi}/recs-results-manager.entry.js +1 -1
- package/dist/{esm → abi}/results-manager.entry.js +1 -1
- package/dist/{esm → abi}/sample-component.entry.js +3 -3
- package/dist/abi/shadow-css-1257b266.js +387 -0
- package/dist/{esm → abi}/standalone-searchbox-listener.entry.js +3 -3
- package/dist/{esm → abi}/strip-html-component.entry.js +2 -3
- package/package.json +2 -2
- package/dist/abi/p-380ced38.entry.js +0 -1
- package/dist/abi/p-9d42030c.entry.js +0 -1
- package/dist/abi/p-ac870f21.js +0 -49
- package/dist/abi/p-b09970bf.entry.js +0 -1
- package/dist/abi/p-b83bab81.js +0 -1
- package/dist/abi/p-c0436bc1.entry.js +0 -1
- package/dist/abi/p-c10b6b7f.js +0 -2
- package/dist/abi/p-c602c74e.entry.js +0 -1
- package/dist/abi/p-c82303fb.js +0 -1
- package/dist/abi/p-cd1744bb.entry.js +0 -1
- package/dist/abi/p-d20ee37c.js +0 -18
- package/dist/abi/p-d5e62885.entry.js +0 -1
- package/dist/bundle/index.css +0 -1
- package/dist/bundle/index.html +0 -72
- package/dist/bundle/index.js +0 -1363
- package/dist/cjs/abi.cjs.js +0 -19
- package/dist/cjs/atomic-70a93c69.js +0 -11
- package/dist/cjs/faq-popup-component.cjs.entry.js +0 -144
- package/dist/cjs/headless.esm-085e70ed-f2e18485.js +0 -1720
- package/dist/cjs/index-3cecd23d.js +0 -1283
- package/dist/cjs/index-d1493bab.js +0 -105
- package/dist/cjs/index.cjs.js +0 -170
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/cjs/recs-initialization-helper.cjs.entry.js +0 -55
- package/dist/cjs/recs-results-manager.cjs.entry.js +0 -36
- package/dist/cjs/result-template-decorators-881a4c8e-4ff46481.js +0 -33
- package/dist/cjs/results-manager.cjs.entry.js +0 -42
- package/dist/cjs/sample-component.cjs.entry.js +0 -87
- package/dist/cjs/standalone-searchbox-listener.cjs.entry.js +0 -48
- package/dist/cjs/strip-html-component.cjs.entry.js +0 -60
- package/dist/collection/collection-manifest.json +0 -23
- package/dist/collection/components/faq-popup-component/faq-popup-component.css +0 -15
- package/dist/collection/components/faq-popup-component/faq-popup-component.js +0 -162
- package/dist/collection/components/recs-initialization-helper/recs-initialization-helper.js +0 -66
- package/dist/collection/components/recs-results-manager/recs-results-manager.js +0 -39
- package/dist/collection/components/results-manager/results-manager.js +0 -50
- package/dist/collection/components/sample-component/sample-component.css +0 -10
- package/dist/collection/components/sample-component/sample-component.js +0 -102
- package/dist/collection/components/standalone-searchbox-listener/standalone-searchbox-listener.css +0 -1
- package/dist/collection/components/standalone-searchbox-listener/standalone-searchbox-listener.js +0 -50
- package/dist/collection/components/strip-html-component/strip-html-component.css +0 -3
- package/dist/collection/components/strip-html-component/strip-html-component.js +0 -64
- package/dist/collection/images/Default.png +0 -0
- package/dist/collection/images/Documents.png +0 -0
- package/dist/collection/images/FAQ.png +0 -0
- package/dist/collection/images/Images.png +0 -0
- package/dist/collection/images/Link.png +0 -0
- package/dist/collection/images/Movies.png +0 -0
- package/dist/collection/images/ProcessPeople.png +0 -0
- package/dist/collection/index.js +0 -167
- package/dist/collection/utils/atomic.js +0 -6
- package/dist/components/index.js +0 -3576
- package/dist/esm/abi.js +0 -17
- package/dist/esm/headless.esm-085e70ed-c4dfb380.js +0 -1717
- package/dist/esm/index-072be88f.js +0 -95
- package/dist/esm/index-66fdbb35.js +0 -1255
- package/dist/esm/index.js +0 -168
- package/dist/esm/loader.js +0 -17
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/result-template-decorators-881a4c8e-ed85ad21.js +0 -31
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/loader/cdn.js +0 -3
- package/dist/loader/index.cjs.js +0 -3
- package/dist/loader/index.d.ts +0 -12
- package/dist/loader/index.es2017.js +0 -3
- package/dist/loader/index.js +0 -4
- package/dist/loader/package.json +0 -10
- /package/dist/{esm → abi}/atomic-7b1e6d55.js +0 -0
|
@@ -0,0 +1,4108 @@
|
|
|
1
|
+
const NAMESPACE = 'atomic';
|
|
2
|
+
|
|
3
|
+
let scopeId;
|
|
4
|
+
let contentRef;
|
|
5
|
+
let hostTagName;
|
|
6
|
+
let useNativeShadowDom = false;
|
|
7
|
+
let checkSlotFallbackVisibility = false;
|
|
8
|
+
let checkSlotRelocate = false;
|
|
9
|
+
let isSvgMode = false;
|
|
10
|
+
let renderingRef = null;
|
|
11
|
+
let queuePending = false;
|
|
12
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
13
|
+
const doc = win.document || { head: {} };
|
|
14
|
+
const plt = {
|
|
15
|
+
$flags$: 0,
|
|
16
|
+
$resourcesUrl$: '',
|
|
17
|
+
jmp: (h) => h(),
|
|
18
|
+
raf: (h) => requestAnimationFrame(h),
|
|
19
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
20
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
21
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
22
|
+
};
|
|
23
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
24
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
25
|
+
try {
|
|
26
|
+
new CSSStyleSheet();
|
|
27
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
28
|
+
}
|
|
29
|
+
catch (e) { }
|
|
30
|
+
return false;
|
|
31
|
+
})()
|
|
32
|
+
;
|
|
33
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
34
|
+
if (listeners) {
|
|
35
|
+
listeners.map(([flags, name, method]) => {
|
|
36
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
37
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
38
|
+
const opts = hostListenerOpts(flags);
|
|
39
|
+
plt.ael(target, name, handler, opts);
|
|
40
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
45
|
+
try {
|
|
46
|
+
{
|
|
47
|
+
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
48
|
+
// instance is ready, let's call it's member method for this event
|
|
49
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
consoleError(e);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
61
|
+
if (flags & 4 /* TargetDocument */)
|
|
62
|
+
return doc;
|
|
63
|
+
if (flags & 16 /* TargetBody */)
|
|
64
|
+
return doc.body;
|
|
65
|
+
return elm;
|
|
66
|
+
};
|
|
67
|
+
// prettier-ignore
|
|
68
|
+
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
69
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
70
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
71
|
+
const createTime = (fnName, tagName = '') => {
|
|
72
|
+
{
|
|
73
|
+
return () => {
|
|
74
|
+
return;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const uniqueTime = (key, measureText) => {
|
|
79
|
+
{
|
|
80
|
+
return () => {
|
|
81
|
+
return;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const rootAppliedStyles = new WeakMap();
|
|
86
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
87
|
+
let style = styles.get(scopeId);
|
|
88
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
89
|
+
style = (style || new CSSStyleSheet());
|
|
90
|
+
if (typeof style === 'string') {
|
|
91
|
+
style = cssText;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
style.replaceSync(cssText);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
style = cssText;
|
|
99
|
+
}
|
|
100
|
+
styles.set(scopeId, style);
|
|
101
|
+
};
|
|
102
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
103
|
+
let scopeId = getScopeId(cmpMeta);
|
|
104
|
+
const style = styles.get(scopeId);
|
|
105
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
106
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
107
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
108
|
+
if (style) {
|
|
109
|
+
if (typeof style === 'string') {
|
|
110
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
111
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
112
|
+
let styleElm;
|
|
113
|
+
if (!appliedStyles) {
|
|
114
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
115
|
+
}
|
|
116
|
+
if (!appliedStyles.has(scopeId)) {
|
|
117
|
+
{
|
|
118
|
+
{
|
|
119
|
+
styleElm = doc.createElement('style');
|
|
120
|
+
styleElm.innerHTML = style;
|
|
121
|
+
}
|
|
122
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
123
|
+
}
|
|
124
|
+
if (appliedStyles) {
|
|
125
|
+
appliedStyles.add(scopeId);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
130
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return scopeId;
|
|
134
|
+
};
|
|
135
|
+
const attachStyles = (hostRef) => {
|
|
136
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
137
|
+
const elm = hostRef.$hostElement$;
|
|
138
|
+
const flags = cmpMeta.$flags$;
|
|
139
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
140
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
141
|
+
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
142
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
143
|
+
// or this browser doesn't support native shadow dom
|
|
144
|
+
// and this host element was NOT created with SSR
|
|
145
|
+
// let's pick out the inner content for slot projection
|
|
146
|
+
// create a node to represent where the original
|
|
147
|
+
// content was first placed, which is useful later on
|
|
148
|
+
// DOM WRITE!!
|
|
149
|
+
elm['s-sc'] = scopeId;
|
|
150
|
+
elm.classList.add(scopeId + '-h');
|
|
151
|
+
}
|
|
152
|
+
endAttachStyles();
|
|
153
|
+
};
|
|
154
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
155
|
+
/**
|
|
156
|
+
* Default style mode id
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Reusable empty obj/array
|
|
160
|
+
* Don't add values to these!!
|
|
161
|
+
*/
|
|
162
|
+
const EMPTY_OBJ = {};
|
|
163
|
+
const isDef = (v) => v != null;
|
|
164
|
+
const isComplexType = (o) => {
|
|
165
|
+
// https://jsperf.com/typeof-fn-object/5
|
|
166
|
+
o = typeof o;
|
|
167
|
+
return o === 'object' || o === 'function';
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Production h() function based on Preact by
|
|
171
|
+
* Jason Miller (@developit)
|
|
172
|
+
* Licensed under the MIT License
|
|
173
|
+
* https://github.com/developit/preact/blob/master/LICENSE
|
|
174
|
+
*
|
|
175
|
+
* Modified for Stencil's compiler and vdom
|
|
176
|
+
*/
|
|
177
|
+
// const stack: any[] = [];
|
|
178
|
+
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
179
|
+
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
180
|
+
const h = (nodeName, vnodeData, ...children) => {
|
|
181
|
+
let child = null;
|
|
182
|
+
let key = null;
|
|
183
|
+
let slotName = null;
|
|
184
|
+
let simple = false;
|
|
185
|
+
let lastSimple = false;
|
|
186
|
+
const vNodeChildren = [];
|
|
187
|
+
const walk = (c) => {
|
|
188
|
+
for (let i = 0; i < c.length; i++) {
|
|
189
|
+
child = c[i];
|
|
190
|
+
if (Array.isArray(child)) {
|
|
191
|
+
walk(child);
|
|
192
|
+
}
|
|
193
|
+
else if (child != null && typeof child !== 'boolean') {
|
|
194
|
+
if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
|
|
195
|
+
child = String(child);
|
|
196
|
+
}
|
|
197
|
+
if (simple && lastSimple) {
|
|
198
|
+
// If the previous child was simple (string), we merge both
|
|
199
|
+
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
// Append a new vNode, if it's text, we create a text vNode
|
|
203
|
+
vNodeChildren.push(simple ? newVNode(null, child) : child);
|
|
204
|
+
}
|
|
205
|
+
lastSimple = simple;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
walk(children);
|
|
210
|
+
if (vnodeData) {
|
|
211
|
+
// normalize class / classname attributes
|
|
212
|
+
if (vnodeData.key) {
|
|
213
|
+
key = vnodeData.key;
|
|
214
|
+
}
|
|
215
|
+
if (vnodeData.name) {
|
|
216
|
+
slotName = vnodeData.name;
|
|
217
|
+
}
|
|
218
|
+
{
|
|
219
|
+
const classData = vnodeData.className || vnodeData.class;
|
|
220
|
+
if (classData) {
|
|
221
|
+
vnodeData.class =
|
|
222
|
+
typeof classData !== 'object'
|
|
223
|
+
? classData
|
|
224
|
+
: Object.keys(classData)
|
|
225
|
+
.filter((k) => classData[k])
|
|
226
|
+
.join(' ');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (typeof nodeName === 'function') {
|
|
231
|
+
// nodeName is a functional component
|
|
232
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
233
|
+
}
|
|
234
|
+
const vnode = newVNode(nodeName, null);
|
|
235
|
+
vnode.$attrs$ = vnodeData;
|
|
236
|
+
if (vNodeChildren.length > 0) {
|
|
237
|
+
vnode.$children$ = vNodeChildren;
|
|
238
|
+
}
|
|
239
|
+
{
|
|
240
|
+
vnode.$key$ = key;
|
|
241
|
+
}
|
|
242
|
+
{
|
|
243
|
+
vnode.$name$ = slotName;
|
|
244
|
+
}
|
|
245
|
+
return vnode;
|
|
246
|
+
};
|
|
247
|
+
const newVNode = (tag, text) => {
|
|
248
|
+
const vnode = {
|
|
249
|
+
$flags$: 0,
|
|
250
|
+
$tag$: tag,
|
|
251
|
+
$text$: text,
|
|
252
|
+
$elm$: null,
|
|
253
|
+
$children$: null,
|
|
254
|
+
};
|
|
255
|
+
{
|
|
256
|
+
vnode.$attrs$ = null;
|
|
257
|
+
}
|
|
258
|
+
{
|
|
259
|
+
vnode.$key$ = null;
|
|
260
|
+
}
|
|
261
|
+
{
|
|
262
|
+
vnode.$name$ = null;
|
|
263
|
+
}
|
|
264
|
+
return vnode;
|
|
265
|
+
};
|
|
266
|
+
const Host = {};
|
|
267
|
+
const isHost = (node) => node && node.$tag$ === Host;
|
|
268
|
+
const vdomFnUtils = {
|
|
269
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
270
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
271
|
+
};
|
|
272
|
+
const convertToPublic = (node) => ({
|
|
273
|
+
vattrs: node.$attrs$,
|
|
274
|
+
vchildren: node.$children$,
|
|
275
|
+
vkey: node.$key$,
|
|
276
|
+
vname: node.$name$,
|
|
277
|
+
vtag: node.$tag$,
|
|
278
|
+
vtext: node.$text$,
|
|
279
|
+
});
|
|
280
|
+
const convertToPrivate = (node) => {
|
|
281
|
+
if (typeof node.vtag === 'function') {
|
|
282
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
283
|
+
if (node.vkey) {
|
|
284
|
+
vnodeData.key = node.vkey;
|
|
285
|
+
}
|
|
286
|
+
if (node.vname) {
|
|
287
|
+
vnodeData.name = node.vname;
|
|
288
|
+
}
|
|
289
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
290
|
+
}
|
|
291
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
292
|
+
vnode.$attrs$ = node.vattrs;
|
|
293
|
+
vnode.$children$ = node.vchildren;
|
|
294
|
+
vnode.$key$ = node.vkey;
|
|
295
|
+
vnode.$name$ = node.vname;
|
|
296
|
+
return vnode;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Production setAccessor() function based on Preact by
|
|
300
|
+
* Jason Miller (@developit)
|
|
301
|
+
* Licensed under the MIT License
|
|
302
|
+
* https://github.com/developit/preact/blob/master/LICENSE
|
|
303
|
+
*
|
|
304
|
+
* Modified for Stencil's compiler and vdom
|
|
305
|
+
*/
|
|
306
|
+
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
307
|
+
if (oldValue !== newValue) {
|
|
308
|
+
let isProp = isMemberInElement(elm, memberName);
|
|
309
|
+
let ln = memberName.toLowerCase();
|
|
310
|
+
if (memberName === 'class') {
|
|
311
|
+
const classList = elm.classList;
|
|
312
|
+
const oldClasses = parseClassList(oldValue);
|
|
313
|
+
const newClasses = parseClassList(newValue);
|
|
314
|
+
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
315
|
+
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
316
|
+
}
|
|
317
|
+
else if (memberName === 'style') {
|
|
318
|
+
// update style attribute, css properties and values
|
|
319
|
+
{
|
|
320
|
+
for (const prop in oldValue) {
|
|
321
|
+
if (!newValue || newValue[prop] == null) {
|
|
322
|
+
if (prop.includes('-')) {
|
|
323
|
+
elm.style.removeProperty(prop);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
elm.style[prop] = '';
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (const prop in newValue) {
|
|
332
|
+
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
333
|
+
if (prop.includes('-')) {
|
|
334
|
+
elm.style.setProperty(prop, newValue[prop]);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
elm.style[prop] = newValue[prop];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else if (memberName === 'key')
|
|
343
|
+
;
|
|
344
|
+
else if (memberName === 'ref') {
|
|
345
|
+
// minifier will clean this up
|
|
346
|
+
if (newValue) {
|
|
347
|
+
newValue(elm);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else if ((!isProp ) &&
|
|
351
|
+
memberName[0] === 'o' &&
|
|
352
|
+
memberName[1] === 'n') {
|
|
353
|
+
// Event Handlers
|
|
354
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
355
|
+
// a capital letter, and it's not already a member on the element,
|
|
356
|
+
// then we're assuming it's an event listener
|
|
357
|
+
if (memberName[2] === '-') {
|
|
358
|
+
// on- prefixed events
|
|
359
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
360
|
+
// under the hood:
|
|
361
|
+
// <my-cmp on-click> // listens for "click"
|
|
362
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
363
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
364
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
365
|
+
memberName = memberName.slice(3);
|
|
366
|
+
}
|
|
367
|
+
else if (isMemberInElement(win, ln)) {
|
|
368
|
+
// standard event
|
|
369
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
370
|
+
// member name "onmouseover" is on the window's prototype
|
|
371
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
372
|
+
memberName = ln.slice(2);
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
// custom event
|
|
376
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
377
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
378
|
+
// and add the listener "myCustomEvent"
|
|
379
|
+
// except for the first character, we keep the event name case
|
|
380
|
+
memberName = ln[2] + memberName.slice(3);
|
|
381
|
+
}
|
|
382
|
+
if (oldValue) {
|
|
383
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
384
|
+
}
|
|
385
|
+
if (newValue) {
|
|
386
|
+
plt.ael(elm, memberName, newValue, false);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
// Set property if it exists and it's not a SVG
|
|
391
|
+
const isComplex = isComplexType(newValue);
|
|
392
|
+
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
393
|
+
try {
|
|
394
|
+
if (!elm.tagName.includes('-')) {
|
|
395
|
+
const n = newValue == null ? '' : newValue;
|
|
396
|
+
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
397
|
+
if (memberName === 'list') {
|
|
398
|
+
isProp = false;
|
|
399
|
+
}
|
|
400
|
+
else if (oldValue == null || elm[memberName] != n) {
|
|
401
|
+
elm[memberName] = n;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
elm[memberName] = newValue;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
catch (e) { }
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Need to manually update attribute if:
|
|
412
|
+
* - memberName is not an attribute
|
|
413
|
+
* - if we are rendering the host element in order to reflect attribute
|
|
414
|
+
* - if it's a SVG, since properties might not work in <svg>
|
|
415
|
+
* - if the newValue is null/undefined or 'false'.
|
|
416
|
+
*/
|
|
417
|
+
let xlink = false;
|
|
418
|
+
{
|
|
419
|
+
if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
|
420
|
+
memberName = ln;
|
|
421
|
+
xlink = true;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
if (newValue == null || newValue === false) {
|
|
425
|
+
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
426
|
+
if (xlink) {
|
|
427
|
+
elm.removeAttributeNS(XLINK_NS, memberName);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
elm.removeAttribute(memberName);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
435
|
+
newValue = newValue === true ? '' : newValue;
|
|
436
|
+
if (xlink) {
|
|
437
|
+
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
elm.setAttribute(memberName, newValue);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const parseClassListRegex = /\s/;
|
|
447
|
+
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
|
448
|
+
const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
449
|
+
// if the element passed in is a shadow root, which is a document fragment
|
|
450
|
+
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
451
|
+
// if it's not a shadow root, then we add attrs/props to the same element
|
|
452
|
+
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
453
|
+
? newVnode.$elm$.host
|
|
454
|
+
: newVnode.$elm$;
|
|
455
|
+
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
456
|
+
const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
|
|
457
|
+
{
|
|
458
|
+
// remove attributes no longer present on the vnode by setting them to undefined
|
|
459
|
+
for (memberName in oldVnodeAttrs) {
|
|
460
|
+
if (!(memberName in newVnodeAttrs)) {
|
|
461
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
// add new & update changed attributes
|
|
466
|
+
for (memberName in newVnodeAttrs) {
|
|
467
|
+
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
471
|
+
// tslint:disable-next-line: prefer-const
|
|
472
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
473
|
+
let i = 0;
|
|
474
|
+
let elm;
|
|
475
|
+
let childNode;
|
|
476
|
+
let oldVNode;
|
|
477
|
+
if (!useNativeShadowDom) {
|
|
478
|
+
// remember for later we need to check to relocate nodes
|
|
479
|
+
checkSlotRelocate = true;
|
|
480
|
+
if (newVNode.$tag$ === 'slot') {
|
|
481
|
+
if (scopeId) {
|
|
482
|
+
// scoped css needs to add its scoped id to the parent element
|
|
483
|
+
parentElm.classList.add(scopeId + '-s');
|
|
484
|
+
}
|
|
485
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
486
|
+
? // slot element has fallback content
|
|
487
|
+
2 /* isSlotFallback */
|
|
488
|
+
: // slot element does not have fallback content
|
|
489
|
+
1 /* isSlotReference */;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (newVNode.$text$ !== null) {
|
|
493
|
+
// create text node
|
|
494
|
+
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
495
|
+
}
|
|
496
|
+
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
497
|
+
// create a slot reference node
|
|
498
|
+
elm = newVNode.$elm$ =
|
|
499
|
+
doc.createTextNode('');
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
// create element
|
|
503
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
|
|
504
|
+
? 'slot-fb'
|
|
505
|
+
: newVNode.$tag$));
|
|
506
|
+
// add css classes, attrs, props, listeners, etc.
|
|
507
|
+
{
|
|
508
|
+
updateElement(null, newVNode, isSvgMode);
|
|
509
|
+
}
|
|
510
|
+
if (isDef(scopeId) && elm['s-si'] !== scopeId) {
|
|
511
|
+
// if there is a scopeId and this is the initial render
|
|
512
|
+
// then let's add the scopeId as a css class
|
|
513
|
+
elm.classList.add((elm['s-si'] = scopeId));
|
|
514
|
+
}
|
|
515
|
+
if (newVNode.$children$) {
|
|
516
|
+
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
517
|
+
// create the node
|
|
518
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
519
|
+
// return node could have been null
|
|
520
|
+
if (childNode) {
|
|
521
|
+
// append our new node
|
|
522
|
+
elm.appendChild(childNode);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
{
|
|
528
|
+
elm['s-hn'] = hostTagName;
|
|
529
|
+
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
530
|
+
// remember the content reference comment
|
|
531
|
+
elm['s-sr'] = true;
|
|
532
|
+
// remember the content reference comment
|
|
533
|
+
elm['s-cr'] = contentRef;
|
|
534
|
+
// remember the slot name, or empty string for default slot
|
|
535
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
536
|
+
// check if we've got an old vnode for this slot
|
|
537
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
538
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
539
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
540
|
+
// so let's move the old slot content back to it's original location
|
|
541
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return elm;
|
|
546
|
+
};
|
|
547
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
548
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
549
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
550
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
551
|
+
const childNode = oldSlotChildNodes[i];
|
|
552
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
553
|
+
// // this child node in the old element is from another component
|
|
554
|
+
// // remove this node from the old slot's parent
|
|
555
|
+
// childNode.remove();
|
|
556
|
+
// and relocate it back to it's original location
|
|
557
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
558
|
+
// remove the old original location comment entirely
|
|
559
|
+
// later on the patch function will know what to do
|
|
560
|
+
// and move this to the correct spot in need be
|
|
561
|
+
childNode['s-ol'].remove();
|
|
562
|
+
childNode['s-ol'] = undefined;
|
|
563
|
+
checkSlotRelocate = true;
|
|
564
|
+
}
|
|
565
|
+
if (recursive) {
|
|
566
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
570
|
+
};
|
|
571
|
+
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
572
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
573
|
+
let childNode;
|
|
574
|
+
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
575
|
+
containerElm = containerElm.shadowRoot;
|
|
576
|
+
}
|
|
577
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
578
|
+
if (vnodes[startIdx]) {
|
|
579
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
580
|
+
if (childNode) {
|
|
581
|
+
vnodes[startIdx].$elm$ = childNode;
|
|
582
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
588
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
589
|
+
if ((vnode = vnodes[startIdx])) {
|
|
590
|
+
elm = vnode.$elm$;
|
|
591
|
+
callNodeRefs(vnode);
|
|
592
|
+
{
|
|
593
|
+
// we're removing this element
|
|
594
|
+
// so it's possible we need to show slot fallback content now
|
|
595
|
+
checkSlotFallbackVisibility = true;
|
|
596
|
+
if (elm['s-ol']) {
|
|
597
|
+
// remove the original location comment
|
|
598
|
+
elm['s-ol'].remove();
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
// it's possible that child nodes of the node
|
|
602
|
+
// that's being removed are slot nodes
|
|
603
|
+
putBackInOriginalLocation(elm, true);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
// remove the vnode's element from the dom
|
|
607
|
+
elm.remove();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
612
|
+
let oldStartIdx = 0;
|
|
613
|
+
let newStartIdx = 0;
|
|
614
|
+
let idxInOld = 0;
|
|
615
|
+
let i = 0;
|
|
616
|
+
let oldEndIdx = oldCh.length - 1;
|
|
617
|
+
let oldStartVnode = oldCh[0];
|
|
618
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
619
|
+
let newEndIdx = newCh.length - 1;
|
|
620
|
+
let newStartVnode = newCh[0];
|
|
621
|
+
let newEndVnode = newCh[newEndIdx];
|
|
622
|
+
let node;
|
|
623
|
+
let elmToMove;
|
|
624
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
625
|
+
if (oldStartVnode == null) {
|
|
626
|
+
// Vnode might have been moved left
|
|
627
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
628
|
+
}
|
|
629
|
+
else if (oldEndVnode == null) {
|
|
630
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
631
|
+
}
|
|
632
|
+
else if (newStartVnode == null) {
|
|
633
|
+
newStartVnode = newCh[++newStartIdx];
|
|
634
|
+
}
|
|
635
|
+
else if (newEndVnode == null) {
|
|
636
|
+
newEndVnode = newCh[--newEndIdx];
|
|
637
|
+
}
|
|
638
|
+
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
639
|
+
patch(oldStartVnode, newStartVnode);
|
|
640
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
641
|
+
newStartVnode = newCh[++newStartIdx];
|
|
642
|
+
}
|
|
643
|
+
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
644
|
+
patch(oldEndVnode, newEndVnode);
|
|
645
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
646
|
+
newEndVnode = newCh[--newEndIdx];
|
|
647
|
+
}
|
|
648
|
+
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
649
|
+
// Vnode moved right
|
|
650
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
651
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
652
|
+
}
|
|
653
|
+
patch(oldStartVnode, newEndVnode);
|
|
654
|
+
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
655
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
656
|
+
newEndVnode = newCh[--newEndIdx];
|
|
657
|
+
}
|
|
658
|
+
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
659
|
+
// Vnode moved left
|
|
660
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
661
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
662
|
+
}
|
|
663
|
+
patch(oldEndVnode, newStartVnode);
|
|
664
|
+
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
665
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
666
|
+
newStartVnode = newCh[++newStartIdx];
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
// createKeyToOldIdx
|
|
670
|
+
idxInOld = -1;
|
|
671
|
+
{
|
|
672
|
+
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
673
|
+
if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
|
674
|
+
idxInOld = i;
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
if (idxInOld >= 0) {
|
|
680
|
+
elmToMove = oldCh[idxInOld];
|
|
681
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
682
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
patch(elmToMove, newStartVnode);
|
|
686
|
+
oldCh[idxInOld] = undefined;
|
|
687
|
+
node = elmToMove.$elm$;
|
|
688
|
+
}
|
|
689
|
+
newStartVnode = newCh[++newStartIdx];
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
// new element
|
|
693
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
694
|
+
newStartVnode = newCh[++newStartIdx];
|
|
695
|
+
}
|
|
696
|
+
if (node) {
|
|
697
|
+
{
|
|
698
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
if (oldStartIdx > oldEndIdx) {
|
|
704
|
+
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
705
|
+
}
|
|
706
|
+
else if (newStartIdx > newEndIdx) {
|
|
707
|
+
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
const isSameVnode = (vnode1, vnode2) => {
|
|
711
|
+
// compare if two vnode to see if they're "technically" the same
|
|
712
|
+
// need to have the same element tag, and same key to be the same
|
|
713
|
+
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
714
|
+
if (vnode1.$tag$ === 'slot') {
|
|
715
|
+
return vnode1.$name$ === vnode2.$name$;
|
|
716
|
+
}
|
|
717
|
+
{
|
|
718
|
+
return vnode1.$key$ === vnode2.$key$;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return false;
|
|
722
|
+
};
|
|
723
|
+
const referenceNode = (node) => {
|
|
724
|
+
// this node was relocated to a new location in the dom
|
|
725
|
+
// because of some other component's slot
|
|
726
|
+
// but we still have an html comment in place of where
|
|
727
|
+
// it's original location was according to it's original vdom
|
|
728
|
+
return (node && node['s-ol']) || node;
|
|
729
|
+
};
|
|
730
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
731
|
+
const patch = (oldVNode, newVNode) => {
|
|
732
|
+
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
733
|
+
const oldChildren = oldVNode.$children$;
|
|
734
|
+
const newChildren = newVNode.$children$;
|
|
735
|
+
const tag = newVNode.$tag$;
|
|
736
|
+
const text = newVNode.$text$;
|
|
737
|
+
let defaultHolder;
|
|
738
|
+
if (text === null) {
|
|
739
|
+
// element node
|
|
740
|
+
{
|
|
741
|
+
if (tag === 'slot')
|
|
742
|
+
;
|
|
743
|
+
else {
|
|
744
|
+
// either this is the first render of an element OR it's an update
|
|
745
|
+
// AND we already know it's possible it could have changed
|
|
746
|
+
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
747
|
+
updateElement(oldVNode, newVNode, isSvgMode);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
if (oldChildren !== null && newChildren !== null) {
|
|
751
|
+
// looks like there's child vnodes for both the old and new vnodes
|
|
752
|
+
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
753
|
+
}
|
|
754
|
+
else if (newChildren !== null) {
|
|
755
|
+
// no old child vnodes, but there are new child vnodes to add
|
|
756
|
+
if (oldVNode.$text$ !== null) {
|
|
757
|
+
// the old vnode was text, so be sure to clear it out
|
|
758
|
+
elm.textContent = '';
|
|
759
|
+
}
|
|
760
|
+
// add the new vnode children
|
|
761
|
+
addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
|
|
762
|
+
}
|
|
763
|
+
else if (oldChildren !== null) {
|
|
764
|
+
// no new child vnodes, but there are old child vnodes to remove
|
|
765
|
+
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
769
|
+
// this element has slotted content
|
|
770
|
+
defaultHolder.parentNode.textContent = text;
|
|
771
|
+
}
|
|
772
|
+
else if (oldVNode.$text$ !== text) {
|
|
773
|
+
// update the text content for the text only vnode
|
|
774
|
+
// and also only if the text is different than before
|
|
775
|
+
elm.data = text;
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
779
|
+
// tslint:disable-next-line: prefer-const
|
|
780
|
+
const childNodes = elm.childNodes;
|
|
781
|
+
let childNode;
|
|
782
|
+
let i;
|
|
783
|
+
let ilen;
|
|
784
|
+
let j;
|
|
785
|
+
let slotNameAttr;
|
|
786
|
+
let nodeType;
|
|
787
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
788
|
+
childNode = childNodes[i];
|
|
789
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
790
|
+
if (childNode['s-sr']) {
|
|
791
|
+
// this is a slot fallback node
|
|
792
|
+
// get the slot name for this slot reference node
|
|
793
|
+
slotNameAttr = childNode['s-sn'];
|
|
794
|
+
// by default always show a fallback slot node
|
|
795
|
+
// then hide it if there are other slots in the light dom
|
|
796
|
+
childNode.hidden = false;
|
|
797
|
+
for (j = 0; j < ilen; j++) {
|
|
798
|
+
nodeType = childNodes[j].nodeType;
|
|
799
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
800
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
801
|
+
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
802
|
+
childNode.hidden = true;
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
// this is a default fallback slot node
|
|
808
|
+
// any element or text node (with content)
|
|
809
|
+
// should hide the default fallback slot node
|
|
810
|
+
if (nodeType === 1 /* ElementNode */ ||
|
|
811
|
+
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
812
|
+
childNode.hidden = true;
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
// keep drilling down
|
|
819
|
+
updateFallbackSlotVisibility(childNode);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
const relocateNodes = [];
|
|
824
|
+
const relocateSlotContent = (elm) => {
|
|
825
|
+
// tslint:disable-next-line: prefer-const
|
|
826
|
+
let childNode;
|
|
827
|
+
let node;
|
|
828
|
+
let hostContentNodes;
|
|
829
|
+
let slotNameAttr;
|
|
830
|
+
let relocateNodeData;
|
|
831
|
+
let j;
|
|
832
|
+
let i = 0;
|
|
833
|
+
const childNodes = elm.childNodes;
|
|
834
|
+
const ilen = childNodes.length;
|
|
835
|
+
for (; i < ilen; i++) {
|
|
836
|
+
childNode = childNodes[i];
|
|
837
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
838
|
+
// first got the content reference comment node
|
|
839
|
+
// then we got it's parent, which is where all the host content is in now
|
|
840
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
841
|
+
slotNameAttr = childNode['s-sn'];
|
|
842
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
843
|
+
node = hostContentNodes[j];
|
|
844
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
845
|
+
// let's do some relocating to its new home
|
|
846
|
+
// but never relocate a content reference node
|
|
847
|
+
// that is suppose to always represent the original content location
|
|
848
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
849
|
+
// it's possible we've already decided to relocate this node
|
|
850
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
851
|
+
// made some changes to slots
|
|
852
|
+
// let's make sure we also double check
|
|
853
|
+
// fallbacks are correctly hidden or shown
|
|
854
|
+
checkSlotFallbackVisibility = true;
|
|
855
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
856
|
+
if (relocateNodeData) {
|
|
857
|
+
// previously we never found a slot home for this node
|
|
858
|
+
// but turns out we did, so let's remember it now
|
|
859
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
// add to our list of nodes to relocate
|
|
863
|
+
relocateNodes.push({
|
|
864
|
+
$slotRefNode$: childNode,
|
|
865
|
+
$nodeToRelocate$: node,
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
if (node['s-sr']) {
|
|
869
|
+
relocateNodes.map((relocateNode) => {
|
|
870
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
871
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
872
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
873
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
880
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
881
|
+
// if we never find a home for this element then we'll need to hide it
|
|
882
|
+
relocateNodes.push({
|
|
883
|
+
$nodeToRelocate$: node,
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
890
|
+
relocateSlotContent(childNode);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
895
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
896
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
897
|
+
return true;
|
|
898
|
+
}
|
|
899
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
900
|
+
return true;
|
|
901
|
+
}
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
905
|
+
return true;
|
|
906
|
+
}
|
|
907
|
+
return slotNameAttr === '';
|
|
908
|
+
};
|
|
909
|
+
const callNodeRefs = (vNode) => {
|
|
910
|
+
{
|
|
911
|
+
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
912
|
+
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
const renderVdom = (hostRef, renderFnResults) => {
|
|
916
|
+
const hostElm = hostRef.$hostElement$;
|
|
917
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
918
|
+
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
919
|
+
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
920
|
+
hostTagName = hostElm.tagName;
|
|
921
|
+
if (cmpMeta.$attrsToReflect$) {
|
|
922
|
+
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
923
|
+
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
924
|
+
}
|
|
925
|
+
rootVnode.$tag$ = null;
|
|
926
|
+
rootVnode.$flags$ |= 4 /* isHost */;
|
|
927
|
+
hostRef.$vnode$ = rootVnode;
|
|
928
|
+
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
929
|
+
{
|
|
930
|
+
scopeId = hostElm['s-sc'];
|
|
931
|
+
}
|
|
932
|
+
{
|
|
933
|
+
contentRef = hostElm['s-cr'];
|
|
934
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
935
|
+
// always reset
|
|
936
|
+
checkSlotFallbackVisibility = false;
|
|
937
|
+
}
|
|
938
|
+
// synchronous patch
|
|
939
|
+
patch(oldVNode, rootVnode);
|
|
940
|
+
{
|
|
941
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
942
|
+
// the disconnectCallback from working
|
|
943
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
944
|
+
if (checkSlotRelocate) {
|
|
945
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
946
|
+
let relocateData;
|
|
947
|
+
let nodeToRelocate;
|
|
948
|
+
let orgLocationNode;
|
|
949
|
+
let parentNodeRef;
|
|
950
|
+
let insertBeforeNode;
|
|
951
|
+
let refNode;
|
|
952
|
+
let i = 0;
|
|
953
|
+
for (; i < relocateNodes.length; i++) {
|
|
954
|
+
relocateData = relocateNodes[i];
|
|
955
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
956
|
+
if (!nodeToRelocate['s-ol']) {
|
|
957
|
+
// add a reference node marking this node's original location
|
|
958
|
+
// keep a reference to this node for later lookups
|
|
959
|
+
orgLocationNode =
|
|
960
|
+
doc.createTextNode('');
|
|
961
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
962
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
966
|
+
relocateData = relocateNodes[i];
|
|
967
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
968
|
+
if (relocateData.$slotRefNode$) {
|
|
969
|
+
// by default we're just going to insert it directly
|
|
970
|
+
// after the slot reference node
|
|
971
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
972
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
973
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
974
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
975
|
+
refNode = orgLocationNode['s-nr'];
|
|
976
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
977
|
+
refNode = refNode.nextSibling;
|
|
978
|
+
if (!refNode || !refNode['s-nr']) {
|
|
979
|
+
insertBeforeNode = refNode;
|
|
980
|
+
break;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
985
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
986
|
+
// we've checked that it's worth while to relocate
|
|
987
|
+
// since that the node to relocate
|
|
988
|
+
// has a different next sibling or parent relocated
|
|
989
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
990
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
991
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
992
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
993
|
+
}
|
|
994
|
+
// add it back to the dom but in its new home
|
|
995
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
1001
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1002
|
+
nodeToRelocate.hidden = true;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
if (checkSlotFallbackVisibility) {
|
|
1008
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1009
|
+
}
|
|
1010
|
+
// done moving nodes around
|
|
1011
|
+
// allow the disconnect callback to work again
|
|
1012
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1013
|
+
// always reset
|
|
1014
|
+
relocateNodes.length = 0;
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
1018
|
+
const createEvent = (ref, name, flags) => {
|
|
1019
|
+
const elm = getElement(ref);
|
|
1020
|
+
return {
|
|
1021
|
+
emit: (detail) => {
|
|
1022
|
+
return emitEvent(elm, name, {
|
|
1023
|
+
bubbles: !!(flags & 4 /* Bubbles */),
|
|
1024
|
+
composed: !!(flags & 2 /* Composed */),
|
|
1025
|
+
cancelable: !!(flags & 1 /* Cancellable */),
|
|
1026
|
+
detail,
|
|
1027
|
+
});
|
|
1028
|
+
},
|
|
1029
|
+
};
|
|
1030
|
+
};
|
|
1031
|
+
/**
|
|
1032
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
1033
|
+
* @param elm the target of the Event
|
|
1034
|
+
* @param name the name to give the custom Event
|
|
1035
|
+
* @param opts options for configuring a custom Event
|
|
1036
|
+
* @returns the custom Event
|
|
1037
|
+
*/
|
|
1038
|
+
const emitEvent = (elm, name, opts) => {
|
|
1039
|
+
const ev = plt.ce(name, opts);
|
|
1040
|
+
elm.dispatchEvent(ev);
|
|
1041
|
+
return ev;
|
|
1042
|
+
};
|
|
1043
|
+
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1044
|
+
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
1045
|
+
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1049
|
+
{
|
|
1050
|
+
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1051
|
+
}
|
|
1052
|
+
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1053
|
+
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
1057
|
+
// there is no ancestor component or the ancestor component
|
|
1058
|
+
// has already fired off its lifecycle update then
|
|
1059
|
+
// fire off the initial update
|
|
1060
|
+
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
1061
|
+
return writeTask(dispatch) ;
|
|
1062
|
+
};
|
|
1063
|
+
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
1064
|
+
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
1065
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1066
|
+
let promise;
|
|
1067
|
+
if (isInitialLoad) {
|
|
1068
|
+
{
|
|
1069
|
+
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1070
|
+
if (hostRef.$queuedListeners$) {
|
|
1071
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1072
|
+
hostRef.$queuedListeners$ = null;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
{
|
|
1076
|
+
promise = safeCall(instance, 'componentWillLoad');
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
else {
|
|
1080
|
+
{
|
|
1081
|
+
promise = safeCall(instance, 'componentWillUpdate');
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
{
|
|
1085
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1086
|
+
}
|
|
1087
|
+
endSchedule();
|
|
1088
|
+
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
1089
|
+
};
|
|
1090
|
+
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
1091
|
+
// updateComponent
|
|
1092
|
+
const elm = hostRef.$hostElement$;
|
|
1093
|
+
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
1094
|
+
const rc = elm['s-rc'];
|
|
1095
|
+
if (isInitialLoad) {
|
|
1096
|
+
// DOM WRITE!
|
|
1097
|
+
attachStyles(hostRef);
|
|
1098
|
+
}
|
|
1099
|
+
const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
|
1100
|
+
{
|
|
1101
|
+
callRender(hostRef, instance);
|
|
1102
|
+
}
|
|
1103
|
+
if (rc) {
|
|
1104
|
+
// ok, so turns out there are some child host elements
|
|
1105
|
+
// waiting on this parent element to load
|
|
1106
|
+
// let's fire off all update callbacks waiting
|
|
1107
|
+
rc.map((cb) => cb());
|
|
1108
|
+
elm['s-rc'] = undefined;
|
|
1109
|
+
}
|
|
1110
|
+
endRender();
|
|
1111
|
+
endUpdate();
|
|
1112
|
+
{
|
|
1113
|
+
const childrenPromises = elm['s-p'];
|
|
1114
|
+
const postUpdate = () => postUpdateComponent(hostRef);
|
|
1115
|
+
if (childrenPromises.length === 0) {
|
|
1116
|
+
postUpdate();
|
|
1117
|
+
}
|
|
1118
|
+
else {
|
|
1119
|
+
Promise.all(childrenPromises).then(postUpdate);
|
|
1120
|
+
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1121
|
+
childrenPromises.length = 0;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
const callRender = (hostRef, instance, elm) => {
|
|
1126
|
+
try {
|
|
1127
|
+
renderingRef = instance;
|
|
1128
|
+
instance = instance.render && instance.render();
|
|
1129
|
+
{
|
|
1130
|
+
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1131
|
+
}
|
|
1132
|
+
{
|
|
1133
|
+
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1134
|
+
}
|
|
1135
|
+
{
|
|
1136
|
+
{
|
|
1137
|
+
// looks like we've got child nodes to render into this host element
|
|
1138
|
+
// or we need to update the css class/attrs on the host element
|
|
1139
|
+
// DOM WRITE!
|
|
1140
|
+
{
|
|
1141
|
+
renderVdom(hostRef, instance);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
catch (e) {
|
|
1147
|
+
consoleError(e, hostRef.$hostElement$);
|
|
1148
|
+
}
|
|
1149
|
+
renderingRef = null;
|
|
1150
|
+
return null;
|
|
1151
|
+
};
|
|
1152
|
+
const getRenderingRef = () => renderingRef;
|
|
1153
|
+
const postUpdateComponent = (hostRef) => {
|
|
1154
|
+
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
1155
|
+
const elm = hostRef.$hostElement$;
|
|
1156
|
+
const endPostUpdate = createTime('postUpdate', tagName);
|
|
1157
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1158
|
+
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1159
|
+
{
|
|
1160
|
+
safeCall(instance, 'componentDidRender');
|
|
1161
|
+
}
|
|
1162
|
+
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1163
|
+
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1164
|
+
{
|
|
1165
|
+
// DOM WRITE!
|
|
1166
|
+
addHydratedFlag(elm);
|
|
1167
|
+
}
|
|
1168
|
+
{
|
|
1169
|
+
safeCall(instance, 'componentDidLoad');
|
|
1170
|
+
}
|
|
1171
|
+
endPostUpdate();
|
|
1172
|
+
{
|
|
1173
|
+
hostRef.$onReadyResolve$(elm);
|
|
1174
|
+
if (!ancestorComponent) {
|
|
1175
|
+
appDidLoad();
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
{
|
|
1181
|
+
safeCall(instance, 'componentDidUpdate');
|
|
1182
|
+
}
|
|
1183
|
+
endPostUpdate();
|
|
1184
|
+
}
|
|
1185
|
+
{
|
|
1186
|
+
hostRef.$onInstanceResolve$(elm);
|
|
1187
|
+
}
|
|
1188
|
+
// load events fire from bottom to top
|
|
1189
|
+
// the deepest elements load first then bubbles up
|
|
1190
|
+
{
|
|
1191
|
+
if (hostRef.$onRenderResolve$) {
|
|
1192
|
+
hostRef.$onRenderResolve$();
|
|
1193
|
+
hostRef.$onRenderResolve$ = undefined;
|
|
1194
|
+
}
|
|
1195
|
+
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1196
|
+
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1197
|
+
}
|
|
1198
|
+
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1199
|
+
}
|
|
1200
|
+
// ( •_•)
|
|
1201
|
+
// ( •_•)>⌐■-■
|
|
1202
|
+
// (⌐■_■)
|
|
1203
|
+
};
|
|
1204
|
+
const forceUpdate = (ref) => {
|
|
1205
|
+
{
|
|
1206
|
+
const hostRef = getHostRef(ref);
|
|
1207
|
+
const isConnected = hostRef.$hostElement$.isConnected;
|
|
1208
|
+
if (isConnected &&
|
|
1209
|
+
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1210
|
+
scheduleUpdate(hostRef, false);
|
|
1211
|
+
}
|
|
1212
|
+
// Returns "true" when the forced update was successfully scheduled
|
|
1213
|
+
return isConnected;
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
const appDidLoad = (who) => {
|
|
1217
|
+
// on appload
|
|
1218
|
+
// we have finish the first big initial render
|
|
1219
|
+
{
|
|
1220
|
+
addHydratedFlag(doc.documentElement);
|
|
1221
|
+
}
|
|
1222
|
+
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1223
|
+
};
|
|
1224
|
+
const safeCall = (instance, method, arg) => {
|
|
1225
|
+
if (instance && instance[method]) {
|
|
1226
|
+
try {
|
|
1227
|
+
return instance[method](arg);
|
|
1228
|
+
}
|
|
1229
|
+
catch (e) {
|
|
1230
|
+
consoleError(e);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return undefined;
|
|
1234
|
+
};
|
|
1235
|
+
const then = (promise, thenFn) => {
|
|
1236
|
+
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
1237
|
+
};
|
|
1238
|
+
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1239
|
+
;
|
|
1240
|
+
/**
|
|
1241
|
+
* Parse a new property value for a given property type.
|
|
1242
|
+
*
|
|
1243
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1244
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1245
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
1246
|
+
* 2. the type stored from `propType`.
|
|
1247
|
+
*
|
|
1248
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1249
|
+
*
|
|
1250
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1251
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1252
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1253
|
+
* ```tsx
|
|
1254
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
1255
|
+
* ```
|
|
1256
|
+
*
|
|
1257
|
+
* HTML prop values on the other hand, will always a string
|
|
1258
|
+
*
|
|
1259
|
+
* @param propValue the new value to coerce to some type
|
|
1260
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
1261
|
+
* @returns the parsed/coerced value
|
|
1262
|
+
*/
|
|
1263
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
1264
|
+
// ensure this value is of the correct prop type
|
|
1265
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
1266
|
+
if (propType & 4 /* Boolean */) {
|
|
1267
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
1268
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1269
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1270
|
+
}
|
|
1271
|
+
if (propType & 2 /* Number */) {
|
|
1272
|
+
// force it to be a number
|
|
1273
|
+
return parseFloat(propValue);
|
|
1274
|
+
}
|
|
1275
|
+
if (propType & 1 /* String */) {
|
|
1276
|
+
// could have been passed as a number or boolean
|
|
1277
|
+
// but we still want it as a string
|
|
1278
|
+
return String(propValue);
|
|
1279
|
+
}
|
|
1280
|
+
// redundant return here for better minification
|
|
1281
|
+
return propValue;
|
|
1282
|
+
}
|
|
1283
|
+
// not sure exactly what type we want
|
|
1284
|
+
// so no need to change to a different type
|
|
1285
|
+
return propValue;
|
|
1286
|
+
};
|
|
1287
|
+
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1288
|
+
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1289
|
+
// check our new property value against our internal value
|
|
1290
|
+
const hostRef = getHostRef(ref);
|
|
1291
|
+
const elm = hostRef.$hostElement$ ;
|
|
1292
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
1293
|
+
const flags = hostRef.$flags$;
|
|
1294
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1295
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
1296
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1297
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1298
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1299
|
+
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1300
|
+
// gadzooks! the property's value has changed!!
|
|
1301
|
+
// set our new value!
|
|
1302
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
1303
|
+
if (instance) {
|
|
1304
|
+
// get an array of method names of watch functions to call
|
|
1305
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1306
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1307
|
+
if (watchMethods) {
|
|
1308
|
+
// this instance is watching for when this property changed
|
|
1309
|
+
watchMethods.map((watchMethodName) => {
|
|
1310
|
+
try {
|
|
1311
|
+
// fire off each of the watch methods that are watching this property
|
|
1312
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
1313
|
+
}
|
|
1314
|
+
catch (e) {
|
|
1315
|
+
consoleError(e, elm);
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1321
|
+
if (instance.componentShouldUpdate) {
|
|
1322
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
// looks like this value actually changed, so we've got work to do!
|
|
1327
|
+
// but only if we've already rendered, otherwise just chill out
|
|
1328
|
+
// queue that we need to do an update, but don't worry about queuing
|
|
1329
|
+
// up millions cuz this function ensures it only runs once
|
|
1330
|
+
scheduleUpdate(hostRef, false);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1336
|
+
if (cmpMeta.$members$) {
|
|
1337
|
+
if (Cstr.watchers) {
|
|
1338
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1339
|
+
}
|
|
1340
|
+
// It's better to have a const than two Object.entries()
|
|
1341
|
+
const members = Object.entries(cmpMeta.$members$);
|
|
1342
|
+
const prototype = Cstr.prototype;
|
|
1343
|
+
members.map(([memberName, [memberFlags]]) => {
|
|
1344
|
+
if ((memberFlags & 31 /* Prop */ ||
|
|
1345
|
+
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1346
|
+
// proxyComponent - prop
|
|
1347
|
+
Object.defineProperty(prototype, memberName, {
|
|
1348
|
+
get() {
|
|
1349
|
+
// proxyComponent, get value
|
|
1350
|
+
return getValue(this, memberName);
|
|
1351
|
+
},
|
|
1352
|
+
set(newValue) {
|
|
1353
|
+
// proxyComponent, set value
|
|
1354
|
+
setValue(this, memberName, newValue, cmpMeta);
|
|
1355
|
+
},
|
|
1356
|
+
configurable: true,
|
|
1357
|
+
enumerable: true,
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
else if (flags & 1 /* isElementConstructor */ &&
|
|
1361
|
+
memberFlags & 64 /* Method */) {
|
|
1362
|
+
// proxyComponent - method
|
|
1363
|
+
Object.defineProperty(prototype, memberName, {
|
|
1364
|
+
value(...args) {
|
|
1365
|
+
const ref = getHostRef(this);
|
|
1366
|
+
return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
|
|
1367
|
+
},
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
if ((flags & 1 /* isElementConstructor */)) {
|
|
1372
|
+
const attrNameToPropName = new Map();
|
|
1373
|
+
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1374
|
+
plt.jmp(() => {
|
|
1375
|
+
const propName = attrNameToPropName.get(attrName);
|
|
1376
|
+
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
1377
|
+
// in the case where an attribute was set inline.
|
|
1378
|
+
// ```html
|
|
1379
|
+
// <my-component some-attribute="some-value"></my-component>
|
|
1380
|
+
// ```
|
|
1381
|
+
//
|
|
1382
|
+
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
1383
|
+
// programmatically changes it before it has been upgraded as shown below:
|
|
1384
|
+
//
|
|
1385
|
+
// ```html
|
|
1386
|
+
// <!-- this component has _not_ been upgraded yet -->
|
|
1387
|
+
// <my-component id="test" some-attribute="some-value"></my-component>
|
|
1388
|
+
// <script>
|
|
1389
|
+
// // grab non-upgraded component
|
|
1390
|
+
// el = document.querySelector("#test");
|
|
1391
|
+
// el.someAttribute = "another-value";
|
|
1392
|
+
// // upgrade component
|
|
1393
|
+
// customElements.define('my-component', MyComponent);
|
|
1394
|
+
// </script>
|
|
1395
|
+
// ```
|
|
1396
|
+
// In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
|
|
1397
|
+
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
1398
|
+
// to the value that was set inline i.e. "some-value" from above example. When
|
|
1399
|
+
// the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
|
|
1400
|
+
//
|
|
1401
|
+
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
|
|
1402
|
+
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
1403
|
+
//
|
|
1404
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1405
|
+
//
|
|
1406
|
+
// TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
|
|
1407
|
+
// properties here given that this goes against best practices outlined here
|
|
1408
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
|
|
1409
|
+
if (this.hasOwnProperty(propName)) {
|
|
1410
|
+
newValue = this[propName];
|
|
1411
|
+
delete this[propName];
|
|
1412
|
+
}
|
|
1413
|
+
else if (prototype.hasOwnProperty(propName) &&
|
|
1414
|
+
typeof this[propName] === 'number' &&
|
|
1415
|
+
this[propName] == newValue) {
|
|
1416
|
+
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
|
|
1417
|
+
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
|
|
1418
|
+
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
1422
|
+
});
|
|
1423
|
+
};
|
|
1424
|
+
// create an array of attributes to observe
|
|
1425
|
+
// and also create a map of html attribute name to js property name
|
|
1426
|
+
Cstr.observedAttributes = members
|
|
1427
|
+
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1428
|
+
.map(([propName, m]) => {
|
|
1429
|
+
const attrName = m[1] || propName;
|
|
1430
|
+
attrNameToPropName.set(attrName, propName);
|
|
1431
|
+
if (m[0] & 512 /* ReflectAttr */) {
|
|
1432
|
+
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1433
|
+
}
|
|
1434
|
+
return attrName;
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
return Cstr;
|
|
1439
|
+
};
|
|
1440
|
+
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1441
|
+
// initializeComponent
|
|
1442
|
+
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1443
|
+
{
|
|
1444
|
+
// we haven't initialized this element yet
|
|
1445
|
+
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1446
|
+
// lazy loaded components
|
|
1447
|
+
// request the component's implementation to be
|
|
1448
|
+
// wired up with the host element
|
|
1449
|
+
Cstr = loadModule(cmpMeta);
|
|
1450
|
+
if (Cstr.then) {
|
|
1451
|
+
// Await creates a micro-task avoid if possible
|
|
1452
|
+
const endLoad = uniqueTime();
|
|
1453
|
+
Cstr = await Cstr;
|
|
1454
|
+
endLoad();
|
|
1455
|
+
}
|
|
1456
|
+
if (!Cstr.isProxied) {
|
|
1457
|
+
// we've never proxied this Constructor before
|
|
1458
|
+
// let's add the getters/setters to its prototype before
|
|
1459
|
+
// the first time we create an instance of the implementation
|
|
1460
|
+
{
|
|
1461
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1462
|
+
}
|
|
1463
|
+
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1464
|
+
Cstr.isProxied = true;
|
|
1465
|
+
}
|
|
1466
|
+
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
1467
|
+
// ok, time to construct the instance
|
|
1468
|
+
// but let's keep track of when we start and stop
|
|
1469
|
+
// so that the getters/setters don't incorrectly step on data
|
|
1470
|
+
{
|
|
1471
|
+
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1472
|
+
}
|
|
1473
|
+
// construct the lazy-loaded component implementation
|
|
1474
|
+
// passing the hostRef is very important during
|
|
1475
|
+
// construction in order to directly wire together the
|
|
1476
|
+
// host element and the lazy-loaded instance
|
|
1477
|
+
try {
|
|
1478
|
+
new Cstr(hostRef);
|
|
1479
|
+
}
|
|
1480
|
+
catch (e) {
|
|
1481
|
+
consoleError(e);
|
|
1482
|
+
}
|
|
1483
|
+
{
|
|
1484
|
+
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1485
|
+
}
|
|
1486
|
+
{
|
|
1487
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1488
|
+
}
|
|
1489
|
+
endNewInstance();
|
|
1490
|
+
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1491
|
+
}
|
|
1492
|
+
if (Cstr.style) {
|
|
1493
|
+
// this component has styles but we haven't registered them yet
|
|
1494
|
+
let style = Cstr.style;
|
|
1495
|
+
const scopeId = getScopeId(cmpMeta);
|
|
1496
|
+
if (!styles.has(scopeId)) {
|
|
1497
|
+
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1498
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1499
|
+
endRegisterStyles();
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
// we've successfully created a lazy instance
|
|
1504
|
+
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1505
|
+
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1506
|
+
if (ancestorComponent && ancestorComponent['s-rc']) {
|
|
1507
|
+
// this is the initial load and this component it has an ancestor component
|
|
1508
|
+
// but the ancestor component has NOT fired its will update lifecycle yet
|
|
1509
|
+
// so let's just cool our jets and wait for the ancestor to continue first
|
|
1510
|
+
// this will get fired off when the ancestor component
|
|
1511
|
+
// finally gets around to rendering its lazy self
|
|
1512
|
+
// fire off the initial update
|
|
1513
|
+
ancestorComponent['s-rc'].push(schedule);
|
|
1514
|
+
}
|
|
1515
|
+
else {
|
|
1516
|
+
schedule();
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
const fireConnectedCallback = (instance) => {
|
|
1520
|
+
{
|
|
1521
|
+
safeCall(instance, 'connectedCallback');
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
const connectedCallback = (elm) => {
|
|
1525
|
+
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1526
|
+
const hostRef = getHostRef(elm);
|
|
1527
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
1528
|
+
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1529
|
+
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1530
|
+
// first time this component has connected
|
|
1531
|
+
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1532
|
+
{
|
|
1533
|
+
// initUpdate
|
|
1534
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1535
|
+
// in here to act as original content anchors as we move nodes around
|
|
1536
|
+
// host element has been connected to the DOM
|
|
1537
|
+
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1538
|
+
setContentReference(elm);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
{
|
|
1542
|
+
// find the first ancestor component (if there is one) and register
|
|
1543
|
+
// this component as one of the actively loading child components for its ancestor
|
|
1544
|
+
let ancestorComponent = elm;
|
|
1545
|
+
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
1546
|
+
// climb up the ancestors looking for the first
|
|
1547
|
+
// component that hasn't finished its lifecycle update yet
|
|
1548
|
+
if (ancestorComponent['s-p']) {
|
|
1549
|
+
// we found this components first ancestor component
|
|
1550
|
+
// keep a reference to this component's ancestor component
|
|
1551
|
+
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
|
1552
|
+
break;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
// Lazy properties
|
|
1557
|
+
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1558
|
+
if (cmpMeta.$members$) {
|
|
1559
|
+
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1560
|
+
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1561
|
+
const value = elm[memberName];
|
|
1562
|
+
delete elm[memberName];
|
|
1563
|
+
elm[memberName] = value;
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
{
|
|
1568
|
+
initializeComponent(elm, hostRef, cmpMeta);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
else {
|
|
1572
|
+
// not the first time this has connected
|
|
1573
|
+
// reattach any event listeners to the host
|
|
1574
|
+
// since they would have been removed when disconnected
|
|
1575
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1576
|
+
// fire off connectedCallback() on component instance
|
|
1577
|
+
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1578
|
+
}
|
|
1579
|
+
endConnected();
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
const setContentReference = (elm) => {
|
|
1583
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1584
|
+
// or this browser doesn't support native shadow dom
|
|
1585
|
+
// and this host element was NOT created with SSR
|
|
1586
|
+
// let's pick out the inner content for slot projection
|
|
1587
|
+
// create a node to represent where the original
|
|
1588
|
+
// content was first placed, which is useful later on
|
|
1589
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1590
|
+
contentRefElm['s-cn'] = true;
|
|
1591
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1592
|
+
};
|
|
1593
|
+
const disconnectedCallback = (elm) => {
|
|
1594
|
+
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1595
|
+
const hostRef = getHostRef(elm);
|
|
1596
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1597
|
+
{
|
|
1598
|
+
if (hostRef.$rmListeners$) {
|
|
1599
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1600
|
+
hostRef.$rmListeners$ = undefined;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
{
|
|
1604
|
+
safeCall(instance, 'disconnectedCallback');
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1609
|
+
const endBootstrap = createTime();
|
|
1610
|
+
const cmpTags = [];
|
|
1611
|
+
const exclude = options.exclude || [];
|
|
1612
|
+
const customElements = win.customElements;
|
|
1613
|
+
const head = doc.head;
|
|
1614
|
+
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1615
|
+
const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
|
|
1616
|
+
const deferredConnectedCallbacks = [];
|
|
1617
|
+
let appLoadFallback;
|
|
1618
|
+
let isBootstrapping = true;
|
|
1619
|
+
Object.assign(plt, options);
|
|
1620
|
+
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1621
|
+
lazyBundles.map((lazyBundle) => {
|
|
1622
|
+
lazyBundle[1].map((compactMeta) => {
|
|
1623
|
+
const cmpMeta = {
|
|
1624
|
+
$flags$: compactMeta[0],
|
|
1625
|
+
$tagName$: compactMeta[1],
|
|
1626
|
+
$members$: compactMeta[2],
|
|
1627
|
+
$listeners$: compactMeta[3],
|
|
1628
|
+
};
|
|
1629
|
+
{
|
|
1630
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
1631
|
+
}
|
|
1632
|
+
{
|
|
1633
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1634
|
+
}
|
|
1635
|
+
{
|
|
1636
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
1637
|
+
}
|
|
1638
|
+
{
|
|
1639
|
+
cmpMeta.$watchers$ = {};
|
|
1640
|
+
}
|
|
1641
|
+
const tagName = cmpMeta.$tagName$;
|
|
1642
|
+
const HostElement = class extends HTMLElement {
|
|
1643
|
+
// StencilLazyHost
|
|
1644
|
+
constructor(self) {
|
|
1645
|
+
// @ts-ignore
|
|
1646
|
+
super(self);
|
|
1647
|
+
self = this;
|
|
1648
|
+
registerHost(self, cmpMeta);
|
|
1649
|
+
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1650
|
+
// this component is using shadow dom
|
|
1651
|
+
// and this browser supports shadow dom
|
|
1652
|
+
// add the read-only property "shadowRoot" to the host element
|
|
1653
|
+
// adding the shadow root build conditionals to minimize runtime
|
|
1654
|
+
{
|
|
1655
|
+
{
|
|
1656
|
+
self.attachShadow({ mode: 'open' });
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
connectedCallback() {
|
|
1662
|
+
if (appLoadFallback) {
|
|
1663
|
+
clearTimeout(appLoadFallback);
|
|
1664
|
+
appLoadFallback = null;
|
|
1665
|
+
}
|
|
1666
|
+
if (isBootstrapping) {
|
|
1667
|
+
// connectedCallback will be processed once all components have been registered
|
|
1668
|
+
deferredConnectedCallbacks.push(this);
|
|
1669
|
+
}
|
|
1670
|
+
else {
|
|
1671
|
+
plt.jmp(() => connectedCallback(this));
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
disconnectedCallback() {
|
|
1675
|
+
plt.jmp(() => disconnectedCallback(this));
|
|
1676
|
+
}
|
|
1677
|
+
componentOnReady() {
|
|
1678
|
+
return getHostRef(this).$onReadyPromise$;
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1682
|
+
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1683
|
+
cmpTags.push(tagName);
|
|
1684
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
});
|
|
1688
|
+
{
|
|
1689
|
+
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1690
|
+
visibilityStyle.setAttribute('data-styles', '');
|
|
1691
|
+
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1692
|
+
}
|
|
1693
|
+
// Process deferred connectedCallbacks now all components have been registered
|
|
1694
|
+
isBootstrapping = false;
|
|
1695
|
+
if (deferredConnectedCallbacks.length) {
|
|
1696
|
+
deferredConnectedCallbacks.map((host) => host.connectedCallback());
|
|
1697
|
+
}
|
|
1698
|
+
else {
|
|
1699
|
+
{
|
|
1700
|
+
plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
// Fallback appLoad event
|
|
1704
|
+
endBootstrap();
|
|
1705
|
+
};
|
|
1706
|
+
const getAssetPath = (path) => {
|
|
1707
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
1708
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
1709
|
+
};
|
|
1710
|
+
const Fragment = (_, children) => children;
|
|
1711
|
+
const hostRefs = new WeakMap();
|
|
1712
|
+
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1713
|
+
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1714
|
+
const registerHost = (elm, cmpMeta) => {
|
|
1715
|
+
const hostRef = {
|
|
1716
|
+
$flags$: 0,
|
|
1717
|
+
$hostElement$: elm,
|
|
1718
|
+
$cmpMeta$: cmpMeta,
|
|
1719
|
+
$instanceValues$: new Map(),
|
|
1720
|
+
};
|
|
1721
|
+
{
|
|
1722
|
+
hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
|
|
1723
|
+
}
|
|
1724
|
+
{
|
|
1725
|
+
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
1726
|
+
elm['s-p'] = [];
|
|
1727
|
+
elm['s-rc'] = [];
|
|
1728
|
+
}
|
|
1729
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1730
|
+
return hostRefs.set(elm, hostRef);
|
|
1731
|
+
};
|
|
1732
|
+
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
1733
|
+
const consoleError = (e, el) => (0, console.error)(e, el);
|
|
1734
|
+
const cmpModules = /*@__PURE__*/ new Map();
|
|
1735
|
+
const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
1736
|
+
// loadModuleImport
|
|
1737
|
+
const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
|
|
1738
|
+
const bundleId = cmpMeta.$lazyBundleId$;
|
|
1739
|
+
const module = cmpModules.get(bundleId) ;
|
|
1740
|
+
if (module) {
|
|
1741
|
+
return module[exportName];
|
|
1742
|
+
}
|
|
1743
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1744
|
+
return import(
|
|
1745
|
+
/* @vite-ignore */
|
|
1746
|
+
/* webpackInclude: /\.entry\.js$/ */
|
|
1747
|
+
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1748
|
+
/* webpackMode: "lazy" */
|
|
1749
|
+
`./${bundleId}.entry.js${''}`).then((importedModule) => {
|
|
1750
|
+
{
|
|
1751
|
+
cmpModules.set(bundleId, importedModule);
|
|
1752
|
+
}
|
|
1753
|
+
return importedModule[exportName];
|
|
1754
|
+
}, consoleError);
|
|
1755
|
+
};
|
|
1756
|
+
const styles = new Map();
|
|
1757
|
+
const queueDomReads = [];
|
|
1758
|
+
const queueDomWrites = [];
|
|
1759
|
+
const queueTask = (queue, write) => (cb) => {
|
|
1760
|
+
queue.push(cb);
|
|
1761
|
+
if (!queuePending) {
|
|
1762
|
+
queuePending = true;
|
|
1763
|
+
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1764
|
+
nextTick(flush);
|
|
1765
|
+
}
|
|
1766
|
+
else {
|
|
1767
|
+
plt.raf(flush);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
const consume = (queue) => {
|
|
1772
|
+
for (let i = 0; i < queue.length; i++) {
|
|
1773
|
+
try {
|
|
1774
|
+
queue[i](performance.now());
|
|
1775
|
+
}
|
|
1776
|
+
catch (e) {
|
|
1777
|
+
consoleError(e);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
queue.length = 0;
|
|
1781
|
+
};
|
|
1782
|
+
const flush = () => {
|
|
1783
|
+
// always force a bunch of medium callbacks to run, but still have
|
|
1784
|
+
// a throttle on how many can run in a certain time
|
|
1785
|
+
// DOM READS!!!
|
|
1786
|
+
consume(queueDomReads);
|
|
1787
|
+
// DOM WRITES!!!
|
|
1788
|
+
{
|
|
1789
|
+
consume(queueDomWrites);
|
|
1790
|
+
if ((queuePending = queueDomReads.length > 0)) {
|
|
1791
|
+
// still more to do yet, but we've run out of time
|
|
1792
|
+
// let's let this thing cool off and try again in the next tick
|
|
1793
|
+
plt.raf(flush);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1798
|
+
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1799
|
+
|
|
1800
|
+
function buildCustomEvent(name, detail) {
|
|
1801
|
+
return new CustomEvent(name, {
|
|
1802
|
+
detail,
|
|
1803
|
+
// Event will bubble up the DOM until it is caught
|
|
1804
|
+
bubbles: true,
|
|
1805
|
+
// Allows to verify if event is caught (cancelled). If it's not caught, it won't be initialized.
|
|
1806
|
+
cancelable: true,
|
|
1807
|
+
// Allows to compose Atomic components inside one another, event will go across DOM/Shadow DOM
|
|
1808
|
+
composed: true,
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
function listenOnce(element, type, listener, options) {
|
|
1812
|
+
const _listener = (evt) => {
|
|
1813
|
+
element.removeEventListener(type, _listener, options);
|
|
1814
|
+
typeof listener === 'object'
|
|
1815
|
+
? listener.handleEvent.call(element, evt)
|
|
1816
|
+
: listener.call(element, evt);
|
|
1817
|
+
};
|
|
1818
|
+
element.addEventListener(type, _listener, options);
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1822
|
+
|
|
1823
|
+
function getDefaultExportFromCjs (x) {
|
|
1824
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
function createCommonjsModule(fn, basedir, module) {
|
|
1828
|
+
return module = {
|
|
1829
|
+
path: basedir,
|
|
1830
|
+
exports: {},
|
|
1831
|
+
require: function (path, base) {
|
|
1832
|
+
return commonjsRequire();
|
|
1833
|
+
}
|
|
1834
|
+
}, fn(module, module.exports), module.exports;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
function commonjsRequire () {
|
|
1838
|
+
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
var purify = createCommonjsModule(function (module, exports) {
|
|
1842
|
+
/*! @license DOMPurify 2.3.10 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.10/LICENSE */
|
|
1843
|
+
|
|
1844
|
+
(function (global, factory) {
|
|
1845
|
+
module.exports = factory() ;
|
|
1846
|
+
})(commonjsGlobal, (function () {
|
|
1847
|
+
function _typeof(obj) {
|
|
1848
|
+
"@babel/helpers - typeof";
|
|
1849
|
+
|
|
1850
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
1851
|
+
return typeof obj;
|
|
1852
|
+
} : function (obj) {
|
|
1853
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
1854
|
+
}, _typeof(obj);
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
function _setPrototypeOf(o, p) {
|
|
1858
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
1859
|
+
o.__proto__ = p;
|
|
1860
|
+
return o;
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1863
|
+
return _setPrototypeOf(o, p);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
function _isNativeReflectConstruct() {
|
|
1867
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
1868
|
+
if (Reflect.construct.sham) return false;
|
|
1869
|
+
if (typeof Proxy === "function") return true;
|
|
1870
|
+
|
|
1871
|
+
try {
|
|
1872
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
1873
|
+
return true;
|
|
1874
|
+
} catch (e) {
|
|
1875
|
+
return false;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
function _construct(Parent, args, Class) {
|
|
1880
|
+
if (_isNativeReflectConstruct()) {
|
|
1881
|
+
_construct = Reflect.construct;
|
|
1882
|
+
} else {
|
|
1883
|
+
_construct = function _construct(Parent, args, Class) {
|
|
1884
|
+
var a = [null];
|
|
1885
|
+
a.push.apply(a, args);
|
|
1886
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
1887
|
+
var instance = new Constructor();
|
|
1888
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
1889
|
+
return instance;
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
return _construct.apply(null, arguments);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
function _toConsumableArray(arr) {
|
|
1897
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
function _arrayWithoutHoles(arr) {
|
|
1901
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
function _iterableToArray(iter) {
|
|
1905
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
1909
|
+
if (!o) return;
|
|
1910
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
1911
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1912
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1913
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
1914
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
function _arrayLikeToArray(arr, len) {
|
|
1918
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1919
|
+
|
|
1920
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
1921
|
+
|
|
1922
|
+
return arr2;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
function _nonIterableSpread() {
|
|
1926
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
var hasOwnProperty = Object.hasOwnProperty,
|
|
1930
|
+
setPrototypeOf = Object.setPrototypeOf,
|
|
1931
|
+
isFrozen = Object.isFrozen,
|
|
1932
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
1933
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
1934
|
+
var freeze = Object.freeze,
|
|
1935
|
+
seal = Object.seal,
|
|
1936
|
+
create = Object.create; // eslint-disable-line import/no-mutable-exports
|
|
1937
|
+
|
|
1938
|
+
var _ref = typeof Reflect !== 'undefined' && Reflect,
|
|
1939
|
+
apply = _ref.apply,
|
|
1940
|
+
construct = _ref.construct;
|
|
1941
|
+
|
|
1942
|
+
if (!apply) {
|
|
1943
|
+
apply = function apply(fun, thisValue, args) {
|
|
1944
|
+
return fun.apply(thisValue, args);
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
if (!freeze) {
|
|
1949
|
+
freeze = function freeze(x) {
|
|
1950
|
+
return x;
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
if (!seal) {
|
|
1955
|
+
seal = function seal(x) {
|
|
1956
|
+
return x;
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
if (!construct) {
|
|
1961
|
+
construct = function construct(Func, args) {
|
|
1962
|
+
return _construct(Func, _toConsumableArray(args));
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
1967
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
1968
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
1969
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
1970
|
+
var stringMatch = unapply(String.prototype.match);
|
|
1971
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
1972
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
1973
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
1974
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
1975
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
1976
|
+
function unapply(func) {
|
|
1977
|
+
return function (thisArg) {
|
|
1978
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1979
|
+
args[_key - 1] = arguments[_key];
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
return apply(func, thisArg, args);
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
function unconstruct(func) {
|
|
1986
|
+
return function () {
|
|
1987
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1988
|
+
args[_key2] = arguments[_key2];
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
return construct(func, args);
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
/* Add properties to a lookup table */
|
|
1995
|
+
|
|
1996
|
+
function addToSet(set, array, transformCaseFunc) {
|
|
1997
|
+
transformCaseFunc = transformCaseFunc ? transformCaseFunc : stringToLowerCase;
|
|
1998
|
+
|
|
1999
|
+
if (setPrototypeOf) {
|
|
2000
|
+
// Make 'in' and truthy checks like Boolean(set.constructor)
|
|
2001
|
+
// independent of any properties defined on Object.prototype.
|
|
2002
|
+
// Prevent prototype setters from intercepting set as a this value.
|
|
2003
|
+
setPrototypeOf(set, null);
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
var l = array.length;
|
|
2007
|
+
|
|
2008
|
+
while (l--) {
|
|
2009
|
+
var element = array[l];
|
|
2010
|
+
|
|
2011
|
+
if (typeof element === 'string') {
|
|
2012
|
+
var lcElement = transformCaseFunc(element);
|
|
2013
|
+
|
|
2014
|
+
if (lcElement !== element) {
|
|
2015
|
+
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
|
2016
|
+
if (!isFrozen(array)) {
|
|
2017
|
+
array[l] = lcElement;
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
element = lcElement;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
set[element] = true;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
return set;
|
|
2028
|
+
}
|
|
2029
|
+
/* Shallow clone an object */
|
|
2030
|
+
|
|
2031
|
+
function clone(object) {
|
|
2032
|
+
var newObject = create(null);
|
|
2033
|
+
var property;
|
|
2034
|
+
|
|
2035
|
+
for (property in object) {
|
|
2036
|
+
if (apply(hasOwnProperty, object, [property])) {
|
|
2037
|
+
newObject[property] = object[property];
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
return newObject;
|
|
2042
|
+
}
|
|
2043
|
+
/* IE10 doesn't support __lookupGetter__ so lets'
|
|
2044
|
+
* simulate it. It also automatically checks
|
|
2045
|
+
* if the prop is function or getter and behaves
|
|
2046
|
+
* accordingly. */
|
|
2047
|
+
|
|
2048
|
+
function lookupGetter(object, prop) {
|
|
2049
|
+
while (object !== null) {
|
|
2050
|
+
var desc = getOwnPropertyDescriptor(object, prop);
|
|
2051
|
+
|
|
2052
|
+
if (desc) {
|
|
2053
|
+
if (desc.get) {
|
|
2054
|
+
return unapply(desc.get);
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
if (typeof desc.value === 'function') {
|
|
2058
|
+
return unapply(desc.value);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
object = getPrototypeOf(object);
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
function fallbackValue(element) {
|
|
2066
|
+
console.warn('fallback value for', element);
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
return fallbackValue;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
var html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); // SVG
|
|
2074
|
+
|
|
2075
|
+
var svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
|
2076
|
+
var svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default.
|
|
2077
|
+
// We still need to know them so that we can do namespace
|
|
2078
|
+
// checks properly in case one wants to add them to
|
|
2079
|
+
// allow-list.
|
|
2080
|
+
|
|
2081
|
+
var svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
|
2082
|
+
var mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover']); // Similarly to SVG, we want to know all MathML elements,
|
|
2083
|
+
// even those that we disallow by default.
|
|
2084
|
+
|
|
2085
|
+
var mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
|
2086
|
+
var text = freeze(['#text']);
|
|
2087
|
+
|
|
2088
|
+
var html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
|
|
2089
|
+
var svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
|
2090
|
+
var mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
|
2091
|
+
var xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
|
2092
|
+
|
|
2093
|
+
var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
|
2094
|
+
|
|
2095
|
+
var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
|
2096
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
|
|
2097
|
+
|
|
2098
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
|
2099
|
+
|
|
2100
|
+
var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
|
2101
|
+
);
|
|
2102
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
2103
|
+
var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
|
2104
|
+
);
|
|
2105
|
+
var DOCTYPE_NAME = seal(/^html$/i);
|
|
2106
|
+
|
|
2107
|
+
var getGlobal = function getGlobal() {
|
|
2108
|
+
return typeof window === 'undefined' ? null : window;
|
|
2109
|
+
};
|
|
2110
|
+
/**
|
|
2111
|
+
* Creates a no-op policy for internal use only.
|
|
2112
|
+
* Don't export this function outside this module!
|
|
2113
|
+
* @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
|
|
2114
|
+
* @param {Document} document The document object (to determine policy name suffix)
|
|
2115
|
+
* @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
|
|
2116
|
+
* are not supported).
|
|
2117
|
+
*/
|
|
2118
|
+
|
|
2119
|
+
|
|
2120
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
|
|
2121
|
+
if (_typeof(trustedTypes) !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
|
2122
|
+
return null;
|
|
2123
|
+
} // Allow the callers to control the unique policy name
|
|
2124
|
+
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
|
2125
|
+
// Policy creation with duplicate names throws in Trusted Types.
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
var suffix = null;
|
|
2129
|
+
var ATTR_NAME = 'data-tt-policy-suffix';
|
|
2130
|
+
|
|
2131
|
+
if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
|
|
2132
|
+
suffix = document.currentScript.getAttribute(ATTR_NAME);
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
var policyName = 'dompurify' + (suffix ? '#' + suffix : '');
|
|
2136
|
+
|
|
2137
|
+
try {
|
|
2138
|
+
return trustedTypes.createPolicy(policyName, {
|
|
2139
|
+
createHTML: function createHTML(html) {
|
|
2140
|
+
return html;
|
|
2141
|
+
},
|
|
2142
|
+
createScriptURL: function createScriptURL(scriptUrl) {
|
|
2143
|
+
return scriptUrl;
|
|
2144
|
+
}
|
|
2145
|
+
});
|
|
2146
|
+
} catch (_) {
|
|
2147
|
+
// Policy creation failed (most likely another DOMPurify script has
|
|
2148
|
+
// already run). Skip creating the policy, as this will only cause errors
|
|
2149
|
+
// if TT are enforced.
|
|
2150
|
+
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
|
2151
|
+
return null;
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
|
|
2155
|
+
function createDOMPurify() {
|
|
2156
|
+
var window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
2157
|
+
|
|
2158
|
+
var DOMPurify = function DOMPurify(root) {
|
|
2159
|
+
return createDOMPurify(root);
|
|
2160
|
+
};
|
|
2161
|
+
/**
|
|
2162
|
+
* Version label, exposed for easier checks
|
|
2163
|
+
* if DOMPurify is up to date or not
|
|
2164
|
+
*/
|
|
2165
|
+
|
|
2166
|
+
|
|
2167
|
+
DOMPurify.version = '2.3.10';
|
|
2168
|
+
/**
|
|
2169
|
+
* Array of elements that DOMPurify removed during sanitation.
|
|
2170
|
+
* Empty if nothing was removed.
|
|
2171
|
+
*/
|
|
2172
|
+
|
|
2173
|
+
DOMPurify.removed = [];
|
|
2174
|
+
|
|
2175
|
+
if (!window || !window.document || window.document.nodeType !== 9) {
|
|
2176
|
+
// Not running in a browser, provide a factory function
|
|
2177
|
+
// so that you can pass your own Window
|
|
2178
|
+
DOMPurify.isSupported = false;
|
|
2179
|
+
return DOMPurify;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
var originalDocument = window.document;
|
|
2183
|
+
var document = window.document;
|
|
2184
|
+
var DocumentFragment = window.DocumentFragment,
|
|
2185
|
+
HTMLTemplateElement = window.HTMLTemplateElement,
|
|
2186
|
+
Node = window.Node,
|
|
2187
|
+
Element = window.Element,
|
|
2188
|
+
NodeFilter = window.NodeFilter,
|
|
2189
|
+
_window$NamedNodeMap = window.NamedNodeMap,
|
|
2190
|
+
NamedNodeMap = _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap,
|
|
2191
|
+
HTMLFormElement = window.HTMLFormElement,
|
|
2192
|
+
DOMParser = window.DOMParser,
|
|
2193
|
+
trustedTypes = window.trustedTypes;
|
|
2194
|
+
var ElementPrototype = Element.prototype;
|
|
2195
|
+
var cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
|
2196
|
+
var getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
|
2197
|
+
var getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
|
2198
|
+
var getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
|
|
2199
|
+
// new document created via createHTMLDocument. As per the spec
|
|
2200
|
+
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
|
2201
|
+
// a new empty registry is used when creating a template contents owner
|
|
2202
|
+
// document, so we use that as our parent document to ensure nothing
|
|
2203
|
+
// is inherited.
|
|
2204
|
+
|
|
2205
|
+
if (typeof HTMLTemplateElement === 'function') {
|
|
2206
|
+
var template = document.createElement('template');
|
|
2207
|
+
|
|
2208
|
+
if (template.content && template.content.ownerDocument) {
|
|
2209
|
+
document = template.content.ownerDocument;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
|
|
2214
|
+
|
|
2215
|
+
var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
|
|
2216
|
+
var _document = document,
|
|
2217
|
+
implementation = _document.implementation,
|
|
2218
|
+
createNodeIterator = _document.createNodeIterator,
|
|
2219
|
+
createDocumentFragment = _document.createDocumentFragment,
|
|
2220
|
+
getElementsByTagName = _document.getElementsByTagName;
|
|
2221
|
+
var importNode = originalDocument.importNode;
|
|
2222
|
+
var documentMode = {};
|
|
2223
|
+
|
|
2224
|
+
try {
|
|
2225
|
+
documentMode = clone(document).documentMode ? document.documentMode : {};
|
|
2226
|
+
} catch (_) {}
|
|
2227
|
+
|
|
2228
|
+
var hooks = {};
|
|
2229
|
+
/**
|
|
2230
|
+
* Expose whether this browser supports running the full DOMPurify.
|
|
2231
|
+
*/
|
|
2232
|
+
|
|
2233
|
+
DOMPurify.isSupported = typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined' && documentMode !== 9;
|
|
2234
|
+
var MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
|
|
2235
|
+
ERB_EXPR$1 = ERB_EXPR,
|
|
2236
|
+
DATA_ATTR$1 = DATA_ATTR,
|
|
2237
|
+
ARIA_ATTR$1 = ARIA_ATTR,
|
|
2238
|
+
IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
|
|
2239
|
+
ATTR_WHITESPACE$1 = ATTR_WHITESPACE;
|
|
2240
|
+
var IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
2241
|
+
/**
|
|
2242
|
+
* We consider the elements and attributes below to be safe. Ideally
|
|
2243
|
+
* don't add any new ones but feel free to remove unwanted ones.
|
|
2244
|
+
*/
|
|
2245
|
+
|
|
2246
|
+
/* allowed element names */
|
|
2247
|
+
|
|
2248
|
+
var ALLOWED_TAGS = null;
|
|
2249
|
+
var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text)));
|
|
2250
|
+
/* Allowed attribute names */
|
|
2251
|
+
|
|
2252
|
+
var ALLOWED_ATTR = null;
|
|
2253
|
+
var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml)));
|
|
2254
|
+
/*
|
|
2255
|
+
* Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
|
|
2256
|
+
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
|
2257
|
+
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
|
2258
|
+
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
|
2259
|
+
*/
|
|
2260
|
+
|
|
2261
|
+
var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
|
|
2262
|
+
tagNameCheck: {
|
|
2263
|
+
writable: true,
|
|
2264
|
+
configurable: false,
|
|
2265
|
+
enumerable: true,
|
|
2266
|
+
value: null
|
|
2267
|
+
},
|
|
2268
|
+
attributeNameCheck: {
|
|
2269
|
+
writable: true,
|
|
2270
|
+
configurable: false,
|
|
2271
|
+
enumerable: true,
|
|
2272
|
+
value: null
|
|
2273
|
+
},
|
|
2274
|
+
allowCustomizedBuiltInElements: {
|
|
2275
|
+
writable: true,
|
|
2276
|
+
configurable: false,
|
|
2277
|
+
enumerable: true,
|
|
2278
|
+
value: false
|
|
2279
|
+
}
|
|
2280
|
+
}));
|
|
2281
|
+
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
|
2282
|
+
|
|
2283
|
+
var FORBID_TAGS = null;
|
|
2284
|
+
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
|
2285
|
+
|
|
2286
|
+
var FORBID_ATTR = null;
|
|
2287
|
+
/* Decide if ARIA attributes are okay */
|
|
2288
|
+
|
|
2289
|
+
var ALLOW_ARIA_ATTR = true;
|
|
2290
|
+
/* Decide if custom data attributes are okay */
|
|
2291
|
+
|
|
2292
|
+
var ALLOW_DATA_ATTR = true;
|
|
2293
|
+
/* Decide if unknown protocols are okay */
|
|
2294
|
+
|
|
2295
|
+
var ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
2296
|
+
/* Output should be safe for common template engines.
|
|
2297
|
+
* This means, DOMPurify removes data attributes, mustaches and ERB
|
|
2298
|
+
*/
|
|
2299
|
+
|
|
2300
|
+
var SAFE_FOR_TEMPLATES = false;
|
|
2301
|
+
/* Decide if document with <html>... should be returned */
|
|
2302
|
+
|
|
2303
|
+
var WHOLE_DOCUMENT = false;
|
|
2304
|
+
/* Track whether config is already set on this instance of DOMPurify. */
|
|
2305
|
+
|
|
2306
|
+
var SET_CONFIG = false;
|
|
2307
|
+
/* Decide if all elements (e.g. style, script) must be children of
|
|
2308
|
+
* document.body. By default, browsers might move them to document.head */
|
|
2309
|
+
|
|
2310
|
+
var FORCE_BODY = false;
|
|
2311
|
+
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
|
2312
|
+
* string (or a TrustedHTML object if Trusted Types are supported).
|
|
2313
|
+
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
|
2314
|
+
*/
|
|
2315
|
+
|
|
2316
|
+
var RETURN_DOM = false;
|
|
2317
|
+
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
|
2318
|
+
* string (or a TrustedHTML object if Trusted Types are supported) */
|
|
2319
|
+
|
|
2320
|
+
var RETURN_DOM_FRAGMENT = false;
|
|
2321
|
+
/* Try to return a Trusted Type object instead of a string, return a string in
|
|
2322
|
+
* case Trusted Types are not supported */
|
|
2323
|
+
|
|
2324
|
+
var RETURN_TRUSTED_TYPE = false;
|
|
2325
|
+
/* Output should be free from DOM clobbering attacks? */
|
|
2326
|
+
|
|
2327
|
+
var SANITIZE_DOM = true;
|
|
2328
|
+
/* Keep element content when removing element? */
|
|
2329
|
+
|
|
2330
|
+
var KEEP_CONTENT = true;
|
|
2331
|
+
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
|
2332
|
+
* of importing it into a new Document and returning a sanitized copy */
|
|
2333
|
+
|
|
2334
|
+
var IN_PLACE = false;
|
|
2335
|
+
/* Allow usage of profiles like html, svg and mathMl */
|
|
2336
|
+
|
|
2337
|
+
var USE_PROFILES = {};
|
|
2338
|
+
/* Tags to ignore content of when KEEP_CONTENT is true */
|
|
2339
|
+
|
|
2340
|
+
var FORBID_CONTENTS = null;
|
|
2341
|
+
var DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
|
2342
|
+
/* Tags that are safe for data: URIs */
|
|
2343
|
+
|
|
2344
|
+
var DATA_URI_TAGS = null;
|
|
2345
|
+
var DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
|
2346
|
+
/* Attributes safe for values like "javascript:" */
|
|
2347
|
+
|
|
2348
|
+
var URI_SAFE_ATTRIBUTES = null;
|
|
2349
|
+
var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
|
2350
|
+
var MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
|
2351
|
+
var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
2352
|
+
var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
|
2353
|
+
/* Document namespace */
|
|
2354
|
+
|
|
2355
|
+
var NAMESPACE = HTML_NAMESPACE;
|
|
2356
|
+
var IS_EMPTY_INPUT = false;
|
|
2357
|
+
/* Parsing of strict XHTML documents */
|
|
2358
|
+
|
|
2359
|
+
var PARSER_MEDIA_TYPE;
|
|
2360
|
+
var SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
|
2361
|
+
var DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
|
2362
|
+
var transformCaseFunc;
|
|
2363
|
+
/* Keep a reference to config to pass to hooks */
|
|
2364
|
+
|
|
2365
|
+
var CONFIG = null;
|
|
2366
|
+
/* Ideally, do not touch anything below this line */
|
|
2367
|
+
|
|
2368
|
+
/* ______________________________________________ */
|
|
2369
|
+
|
|
2370
|
+
var formElement = document.createElement('form');
|
|
2371
|
+
|
|
2372
|
+
var isRegexOrFunction = function isRegexOrFunction(testValue) {
|
|
2373
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
2374
|
+
};
|
|
2375
|
+
/**
|
|
2376
|
+
* _parseConfig
|
|
2377
|
+
*
|
|
2378
|
+
* @param {Object} cfg optional config literal
|
|
2379
|
+
*/
|
|
2380
|
+
// eslint-disable-next-line complexity
|
|
2381
|
+
|
|
2382
|
+
|
|
2383
|
+
var _parseConfig = function _parseConfig(cfg) {
|
|
2384
|
+
if (CONFIG && CONFIG === cfg) {
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
/* Shield configuration object from tampering */
|
|
2388
|
+
|
|
2389
|
+
|
|
2390
|
+
if (!cfg || _typeof(cfg) !== 'object') {
|
|
2391
|
+
cfg = {};
|
|
2392
|
+
}
|
|
2393
|
+
/* Shield configuration object from prototype pollution */
|
|
2394
|
+
|
|
2395
|
+
|
|
2396
|
+
cfg = clone(cfg);
|
|
2397
|
+
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
2398
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
|
2399
|
+
|
|
2400
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? function (x) {
|
|
2401
|
+
return x;
|
|
2402
|
+
} : stringToLowerCase;
|
|
2403
|
+
/* Set configuration parameters */
|
|
2404
|
+
|
|
2405
|
+
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
|
2406
|
+
ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
|
2407
|
+
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
|
|
2408
|
+
cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
|
|
2409
|
+
transformCaseFunc // eslint-disable-line indent
|
|
2410
|
+
) // eslint-disable-line indent
|
|
2411
|
+
: DEFAULT_URI_SAFE_ATTRIBUTES;
|
|
2412
|
+
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
|
|
2413
|
+
cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
|
|
2414
|
+
transformCaseFunc // eslint-disable-line indent
|
|
2415
|
+
) // eslint-disable-line indent
|
|
2416
|
+
: DEFAULT_DATA_URI_TAGS;
|
|
2417
|
+
FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
|
2418
|
+
FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
|
2419
|
+
FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
|
2420
|
+
USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
|
|
2421
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
|
2422
|
+
|
|
2423
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
|
2424
|
+
|
|
2425
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
|
2426
|
+
|
|
2427
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
|
2428
|
+
|
|
2429
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
|
2430
|
+
|
|
2431
|
+
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
|
2432
|
+
|
|
2433
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
|
2434
|
+
|
|
2435
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
|
2436
|
+
|
|
2437
|
+
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
|
2438
|
+
|
|
2439
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
|
2440
|
+
|
|
2441
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
|
2442
|
+
|
|
2443
|
+
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
|
2444
|
+
|
|
2445
|
+
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1;
|
|
2446
|
+
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
|
2447
|
+
|
|
2448
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
|
2449
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
|
2453
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
|
|
2457
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
2461
|
+
ALLOW_DATA_ATTR = false;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
2465
|
+
RETURN_DOM = true;
|
|
2466
|
+
}
|
|
2467
|
+
/* Parse profile info */
|
|
2468
|
+
|
|
2469
|
+
|
|
2470
|
+
if (USE_PROFILES) {
|
|
2471
|
+
ALLOWED_TAGS = addToSet({}, _toConsumableArray(text));
|
|
2472
|
+
ALLOWED_ATTR = [];
|
|
2473
|
+
|
|
2474
|
+
if (USE_PROFILES.html === true) {
|
|
2475
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
2476
|
+
addToSet(ALLOWED_ATTR, html);
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
if (USE_PROFILES.svg === true) {
|
|
2480
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
2481
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
2482
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
2486
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
2487
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
2488
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
if (USE_PROFILES.mathMl === true) {
|
|
2492
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
2493
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
2494
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
/* Merge configuration parameters */
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
if (cfg.ADD_TAGS) {
|
|
2501
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
2502
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
if (cfg.ADD_ATTR) {
|
|
2509
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
2510
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
if (cfg.ADD_URI_SAFE_ATTR) {
|
|
2517
|
+
addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
if (cfg.FORBID_CONTENTS) {
|
|
2521
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
2522
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
|
2526
|
+
}
|
|
2527
|
+
/* Add #text in case KEEP_CONTENT is set to true */
|
|
2528
|
+
|
|
2529
|
+
|
|
2530
|
+
if (KEEP_CONTENT) {
|
|
2531
|
+
ALLOWED_TAGS['#text'] = true;
|
|
2532
|
+
}
|
|
2533
|
+
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
|
2534
|
+
|
|
2535
|
+
|
|
2536
|
+
if (WHOLE_DOCUMENT) {
|
|
2537
|
+
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
|
2538
|
+
}
|
|
2539
|
+
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
if (ALLOWED_TAGS.table) {
|
|
2543
|
+
addToSet(ALLOWED_TAGS, ['tbody']);
|
|
2544
|
+
delete FORBID_TAGS.tbody;
|
|
2545
|
+
} // Prevent further manipulation of configuration.
|
|
2546
|
+
// Not available in IE8, Safari 5, etc.
|
|
2547
|
+
|
|
2548
|
+
|
|
2549
|
+
if (freeze) {
|
|
2550
|
+
freeze(cfg);
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
CONFIG = cfg;
|
|
2554
|
+
};
|
|
2555
|
+
|
|
2556
|
+
var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
|
2557
|
+
var HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
|
|
2558
|
+
// namespace. We need to specify them explicitly
|
|
2559
|
+
// so that they don't get erroneously deleted from
|
|
2560
|
+
// HTML namespace.
|
|
2561
|
+
|
|
2562
|
+
var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
|
2563
|
+
/* Keep track of all possible SVG and MathML tags
|
|
2564
|
+
* so that we can perform the namespace checks
|
|
2565
|
+
* correctly. */
|
|
2566
|
+
|
|
2567
|
+
var ALL_SVG_TAGS = addToSet({}, svg$1);
|
|
2568
|
+
addToSet(ALL_SVG_TAGS, svgFilters);
|
|
2569
|
+
addToSet(ALL_SVG_TAGS, svgDisallowed);
|
|
2570
|
+
var ALL_MATHML_TAGS = addToSet({}, mathMl$1);
|
|
2571
|
+
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
|
2572
|
+
/**
|
|
2573
|
+
*
|
|
2574
|
+
*
|
|
2575
|
+
* @param {Element} element a DOM element whose namespace is being checked
|
|
2576
|
+
* @returns {boolean} Return false if the element has a
|
|
2577
|
+
* namespace that a spec-compliant parser would never
|
|
2578
|
+
* return. Return true otherwise.
|
|
2579
|
+
*/
|
|
2580
|
+
|
|
2581
|
+
var _checkValidNamespace = function _checkValidNamespace(element) {
|
|
2582
|
+
var parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
|
|
2583
|
+
// can be null. We just simulate parent in this case.
|
|
2584
|
+
|
|
2585
|
+
if (!parent || !parent.tagName) {
|
|
2586
|
+
parent = {
|
|
2587
|
+
namespaceURI: HTML_NAMESPACE,
|
|
2588
|
+
tagName: 'template'
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
var tagName = stringToLowerCase(element.tagName);
|
|
2593
|
+
var parentTagName = stringToLowerCase(parent.tagName);
|
|
2594
|
+
|
|
2595
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
2596
|
+
// The only way to switch from HTML namespace to SVG
|
|
2597
|
+
// is via <svg>. If it happens via any other tag, then
|
|
2598
|
+
// it should be killed.
|
|
2599
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
2600
|
+
return tagName === 'svg';
|
|
2601
|
+
} // The only way to switch from MathML to SVG is via
|
|
2602
|
+
// svg if parent is either <annotation-xml> or MathML
|
|
2603
|
+
// text integration points.
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
2607
|
+
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
2608
|
+
} // We only allow elements that are defined in SVG
|
|
2609
|
+
// spec. All others are disallowed in SVG namespace.
|
|
2610
|
+
|
|
2611
|
+
|
|
2612
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
2616
|
+
// The only way to switch from HTML namespace to MathML
|
|
2617
|
+
// is via <math>. If it happens via any other tag, then
|
|
2618
|
+
// it should be killed.
|
|
2619
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
2620
|
+
return tagName === 'math';
|
|
2621
|
+
} // The only way to switch from SVG to MathML is via
|
|
2622
|
+
// <math> and HTML integration points
|
|
2623
|
+
|
|
2624
|
+
|
|
2625
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
2626
|
+
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
|
2627
|
+
} // We only allow elements that are defined in MathML
|
|
2628
|
+
// spec. All others are disallowed in MathML namespace.
|
|
2629
|
+
|
|
2630
|
+
|
|
2631
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
2635
|
+
// The only way to switch from SVG to HTML is via
|
|
2636
|
+
// HTML integration points, and from MathML to HTML
|
|
2637
|
+
// is via MathML text integration points
|
|
2638
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
2639
|
+
return false;
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
2643
|
+
return false;
|
|
2644
|
+
} // We disallow tags that are specific for MathML
|
|
2645
|
+
// or SVG and should never appear in HTML namespace
|
|
2646
|
+
|
|
2647
|
+
|
|
2648
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
2649
|
+
} // The code should never reach this place (this means
|
|
2650
|
+
// that the element somehow got namespace that is not
|
|
2651
|
+
// HTML, SVG or MathML). Return false just in case.
|
|
2652
|
+
|
|
2653
|
+
|
|
2654
|
+
return false;
|
|
2655
|
+
};
|
|
2656
|
+
/**
|
|
2657
|
+
* _forceRemove
|
|
2658
|
+
*
|
|
2659
|
+
* @param {Node} node a DOM node
|
|
2660
|
+
*/
|
|
2661
|
+
|
|
2662
|
+
|
|
2663
|
+
var _forceRemove = function _forceRemove(node) {
|
|
2664
|
+
arrayPush(DOMPurify.removed, {
|
|
2665
|
+
element: node
|
|
2666
|
+
});
|
|
2667
|
+
|
|
2668
|
+
try {
|
|
2669
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
|
2670
|
+
node.parentNode.removeChild(node);
|
|
2671
|
+
} catch (_) {
|
|
2672
|
+
try {
|
|
2673
|
+
node.outerHTML = emptyHTML;
|
|
2674
|
+
} catch (_) {
|
|
2675
|
+
node.remove();
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
};
|
|
2679
|
+
/**
|
|
2680
|
+
* _removeAttribute
|
|
2681
|
+
*
|
|
2682
|
+
* @param {String} name an Attribute name
|
|
2683
|
+
* @param {Node} node a DOM node
|
|
2684
|
+
*/
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
var _removeAttribute = function _removeAttribute(name, node) {
|
|
2688
|
+
try {
|
|
2689
|
+
arrayPush(DOMPurify.removed, {
|
|
2690
|
+
attribute: node.getAttributeNode(name),
|
|
2691
|
+
from: node
|
|
2692
|
+
});
|
|
2693
|
+
} catch (_) {
|
|
2694
|
+
arrayPush(DOMPurify.removed, {
|
|
2695
|
+
attribute: null,
|
|
2696
|
+
from: node
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
|
|
2701
|
+
|
|
2702
|
+
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
|
2703
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
2704
|
+
try {
|
|
2705
|
+
_forceRemove(node);
|
|
2706
|
+
} catch (_) {}
|
|
2707
|
+
} else {
|
|
2708
|
+
try {
|
|
2709
|
+
node.setAttribute(name, '');
|
|
2710
|
+
} catch (_) {}
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
};
|
|
2714
|
+
/**
|
|
2715
|
+
* _initDocument
|
|
2716
|
+
*
|
|
2717
|
+
* @param {String} dirty a string of dirty markup
|
|
2718
|
+
* @return {Document} a DOM, filled with the dirty markup
|
|
2719
|
+
*/
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
var _initDocument = function _initDocument(dirty) {
|
|
2723
|
+
/* Create a HTML document */
|
|
2724
|
+
var doc;
|
|
2725
|
+
var leadingWhitespace;
|
|
2726
|
+
|
|
2727
|
+
if (FORCE_BODY) {
|
|
2728
|
+
dirty = '<remove></remove>' + dirty;
|
|
2729
|
+
} else {
|
|
2730
|
+
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
|
2731
|
+
var matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
2732
|
+
leadingWhitespace = matches && matches[0];
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml') {
|
|
2736
|
+
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
|
2737
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
2741
|
+
/*
|
|
2742
|
+
* Use the DOMParser API by default, fallback later if needs be
|
|
2743
|
+
* DOMParser not work for svg when has multiple root element.
|
|
2744
|
+
*/
|
|
2745
|
+
|
|
2746
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
2747
|
+
try {
|
|
2748
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
2749
|
+
} catch (_) {}
|
|
2750
|
+
}
|
|
2751
|
+
/* Use createHTMLDocument in case DOMParser is not available */
|
|
2752
|
+
|
|
2753
|
+
|
|
2754
|
+
if (!doc || !doc.documentElement) {
|
|
2755
|
+
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
|
2756
|
+
|
|
2757
|
+
try {
|
|
2758
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? '' : dirtyPayload;
|
|
2759
|
+
} catch (_) {// Syntax error if dirtyPayload is invalid xml
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
var body = doc.body || doc.documentElement;
|
|
2764
|
+
|
|
2765
|
+
if (dirty && leadingWhitespace) {
|
|
2766
|
+
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
2767
|
+
}
|
|
2768
|
+
/* Work on whole document or just its body */
|
|
2769
|
+
|
|
2770
|
+
|
|
2771
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
2772
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
2776
|
+
};
|
|
2777
|
+
/**
|
|
2778
|
+
* _createIterator
|
|
2779
|
+
*
|
|
2780
|
+
* @param {Document} root document/fragment to create iterator for
|
|
2781
|
+
* @return {Iterator} iterator instance
|
|
2782
|
+
*/
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
var _createIterator = function _createIterator(root) {
|
|
2786
|
+
return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
|
|
2787
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
|
|
2788
|
+
};
|
|
2789
|
+
/**
|
|
2790
|
+
* _isClobbered
|
|
2791
|
+
*
|
|
2792
|
+
* @param {Node} elm element to check for clobbering attacks
|
|
2793
|
+
* @return {Boolean} true if clobbered, false if safe
|
|
2794
|
+
*/
|
|
2795
|
+
|
|
2796
|
+
|
|
2797
|
+
var _isClobbered = function _isClobbered(elm) {
|
|
2798
|
+
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function');
|
|
2799
|
+
};
|
|
2800
|
+
/**
|
|
2801
|
+
* _isNode
|
|
2802
|
+
*
|
|
2803
|
+
* @param {Node} obj object to check whether it's a DOM node
|
|
2804
|
+
* @return {Boolean} true is object is a DOM node
|
|
2805
|
+
*/
|
|
2806
|
+
|
|
2807
|
+
|
|
2808
|
+
var _isNode = function _isNode(object) {
|
|
2809
|
+
return _typeof(Node) === 'object' ? object instanceof Node : object && _typeof(object) === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
|
|
2810
|
+
};
|
|
2811
|
+
/**
|
|
2812
|
+
* _executeHook
|
|
2813
|
+
* Execute user configurable hooks
|
|
2814
|
+
*
|
|
2815
|
+
* @param {String} entryPoint Name of the hook's entry point
|
|
2816
|
+
* @param {Node} currentNode node to work on with the hook
|
|
2817
|
+
* @param {Object} data additional hook parameters
|
|
2818
|
+
*/
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
var _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
|
2822
|
+
if (!hooks[entryPoint]) {
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
arrayForEach(hooks[entryPoint], function (hook) {
|
|
2827
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
2828
|
+
});
|
|
2829
|
+
};
|
|
2830
|
+
/**
|
|
2831
|
+
* _sanitizeElements
|
|
2832
|
+
*
|
|
2833
|
+
* @protect nodeName
|
|
2834
|
+
* @protect textContent
|
|
2835
|
+
* @protect removeChild
|
|
2836
|
+
*
|
|
2837
|
+
* @param {Node} currentNode to check for permission to exist
|
|
2838
|
+
* @return {Boolean} true if node was killed, false if left alive
|
|
2839
|
+
*/
|
|
2840
|
+
|
|
2841
|
+
|
|
2842
|
+
var _sanitizeElements = function _sanitizeElements(currentNode) {
|
|
2843
|
+
var content;
|
|
2844
|
+
/* Execute a hook if present */
|
|
2845
|
+
|
|
2846
|
+
_executeHook('beforeSanitizeElements', currentNode, null);
|
|
2847
|
+
/* Check if element is clobbered or can clobber */
|
|
2848
|
+
|
|
2849
|
+
|
|
2850
|
+
if (_isClobbered(currentNode)) {
|
|
2851
|
+
_forceRemove(currentNode);
|
|
2852
|
+
|
|
2853
|
+
return true;
|
|
2854
|
+
}
|
|
2855
|
+
/* Check if tagname contains Unicode */
|
|
2856
|
+
|
|
2857
|
+
|
|
2858
|
+
if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) {
|
|
2859
|
+
_forceRemove(currentNode);
|
|
2860
|
+
|
|
2861
|
+
return true;
|
|
2862
|
+
}
|
|
2863
|
+
/* Now let's check the element's type and name */
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
var tagName = transformCaseFunc(currentNode.nodeName);
|
|
2867
|
+
/* Execute a hook if present */
|
|
2868
|
+
|
|
2869
|
+
_executeHook('uponSanitizeElement', currentNode, {
|
|
2870
|
+
tagName: tagName,
|
|
2871
|
+
allowedTags: ALLOWED_TAGS
|
|
2872
|
+
});
|
|
2873
|
+
/* Detect mXSS attempts abusing namespace confusion */
|
|
2874
|
+
|
|
2875
|
+
|
|
2876
|
+
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
|
2877
|
+
_forceRemove(currentNode);
|
|
2878
|
+
|
|
2879
|
+
return true;
|
|
2880
|
+
}
|
|
2881
|
+
/* Mitigate a problem with templates inside select */
|
|
2882
|
+
|
|
2883
|
+
|
|
2884
|
+
if (tagName === 'select' && regExpTest(/<template/i, currentNode.innerHTML)) {
|
|
2885
|
+
_forceRemove(currentNode);
|
|
2886
|
+
|
|
2887
|
+
return true;
|
|
2888
|
+
}
|
|
2889
|
+
/* Remove element if anything forbids its presence */
|
|
2890
|
+
|
|
2891
|
+
|
|
2892
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
2893
|
+
/* Check if we have a custom element to handle */
|
|
2894
|
+
if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
|
|
2895
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
|
|
2896
|
+
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
|
|
2897
|
+
}
|
|
2898
|
+
/* Keep content except for bad-listed elements */
|
|
2899
|
+
|
|
2900
|
+
|
|
2901
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
2902
|
+
var parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
|
2903
|
+
var childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
|
2904
|
+
|
|
2905
|
+
if (childNodes && parentNode) {
|
|
2906
|
+
var childCount = childNodes.length;
|
|
2907
|
+
|
|
2908
|
+
for (var i = childCount - 1; i >= 0; --i) {
|
|
2909
|
+
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
_forceRemove(currentNode);
|
|
2915
|
+
|
|
2916
|
+
return true;
|
|
2917
|
+
}
|
|
2918
|
+
/* Check whether element has a valid namespace */
|
|
2919
|
+
|
|
2920
|
+
|
|
2921
|
+
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
|
2922
|
+
_forceRemove(currentNode);
|
|
2923
|
+
|
|
2924
|
+
return true;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
|
|
2928
|
+
_forceRemove(currentNode);
|
|
2929
|
+
|
|
2930
|
+
return true;
|
|
2931
|
+
}
|
|
2932
|
+
/* Sanitize element content to be template-safe */
|
|
2933
|
+
|
|
2934
|
+
|
|
2935
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
|
2936
|
+
/* Get the element's text content */
|
|
2937
|
+
content = currentNode.textContent;
|
|
2938
|
+
content = stringReplace(content, MUSTACHE_EXPR$1, ' ');
|
|
2939
|
+
content = stringReplace(content, ERB_EXPR$1, ' ');
|
|
2940
|
+
|
|
2941
|
+
if (currentNode.textContent !== content) {
|
|
2942
|
+
arrayPush(DOMPurify.removed, {
|
|
2943
|
+
element: currentNode.cloneNode()
|
|
2944
|
+
});
|
|
2945
|
+
currentNode.textContent = content;
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
/* Execute a hook if present */
|
|
2949
|
+
|
|
2950
|
+
|
|
2951
|
+
_executeHook('afterSanitizeElements', currentNode, null);
|
|
2952
|
+
|
|
2953
|
+
return false;
|
|
2954
|
+
};
|
|
2955
|
+
/**
|
|
2956
|
+
* _isValidAttribute
|
|
2957
|
+
*
|
|
2958
|
+
* @param {string} lcTag Lowercase tag name of containing element.
|
|
2959
|
+
* @param {string} lcName Lowercase attribute name.
|
|
2960
|
+
* @param {string} value Attribute value.
|
|
2961
|
+
* @return {Boolean} Returns true if `value` is valid, otherwise false.
|
|
2962
|
+
*/
|
|
2963
|
+
// eslint-disable-next-line complexity
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
var _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
2967
|
+
/* Make sure attribute cannot clobber */
|
|
2968
|
+
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
2969
|
+
return false;
|
|
2970
|
+
}
|
|
2971
|
+
/* Allow valid data-* attributes: At least one character after "-"
|
|
2972
|
+
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
|
2973
|
+
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
|
2974
|
+
We don't need to check the value; it's always URI safe. */
|
|
2975
|
+
|
|
2976
|
+
|
|
2977
|
+
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
|
2978
|
+
if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
2979
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2980
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
2981
|
+
_basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
2982
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2983
|
+
lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
|
|
2984
|
+
return false;
|
|
2985
|
+
}
|
|
2986
|
+
/* Check value is safe. First, is attr inert? If so, is safe */
|
|
2987
|
+
|
|
2988
|
+
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (!value) ; else {
|
|
2989
|
+
return false;
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
return true;
|
|
2993
|
+
};
|
|
2994
|
+
/**
|
|
2995
|
+
* _basicCustomElementCheck
|
|
2996
|
+
* checks if at least one dash is included in tagName, and it's not the first char
|
|
2997
|
+
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
|
2998
|
+
* @param {string} tagName name of the tag of the node to sanitize
|
|
2999
|
+
*/
|
|
3000
|
+
|
|
3001
|
+
|
|
3002
|
+
var _basicCustomElementTest = function _basicCustomElementTest(tagName) {
|
|
3003
|
+
return tagName.indexOf('-') > 0;
|
|
3004
|
+
};
|
|
3005
|
+
/**
|
|
3006
|
+
* _sanitizeAttributes
|
|
3007
|
+
*
|
|
3008
|
+
* @protect attributes
|
|
3009
|
+
* @protect nodeName
|
|
3010
|
+
* @protect removeAttribute
|
|
3011
|
+
* @protect setAttribute
|
|
3012
|
+
*
|
|
3013
|
+
* @param {Node} currentNode to sanitize
|
|
3014
|
+
*/
|
|
3015
|
+
|
|
3016
|
+
|
|
3017
|
+
var _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
|
3018
|
+
var attr;
|
|
3019
|
+
var value;
|
|
3020
|
+
var lcName;
|
|
3021
|
+
var l;
|
|
3022
|
+
/* Execute a hook if present */
|
|
3023
|
+
|
|
3024
|
+
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
|
3025
|
+
|
|
3026
|
+
var attributes = currentNode.attributes;
|
|
3027
|
+
/* Check if we have attributes; if not we might have a text node */
|
|
3028
|
+
|
|
3029
|
+
if (!attributes) {
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
var hookEvent = {
|
|
3034
|
+
attrName: '',
|
|
3035
|
+
attrValue: '',
|
|
3036
|
+
keepAttr: true,
|
|
3037
|
+
allowedAttributes: ALLOWED_ATTR
|
|
3038
|
+
};
|
|
3039
|
+
l = attributes.length;
|
|
3040
|
+
/* Go backwards over all attributes; safely remove bad ones */
|
|
3041
|
+
|
|
3042
|
+
while (l--) {
|
|
3043
|
+
attr = attributes[l];
|
|
3044
|
+
var _attr = attr,
|
|
3045
|
+
name = _attr.name,
|
|
3046
|
+
namespaceURI = _attr.namespaceURI;
|
|
3047
|
+
value = name === 'value' ? attr.value : stringTrim(attr.value);
|
|
3048
|
+
lcName = transformCaseFunc(name);
|
|
3049
|
+
/* Execute a hook if present */
|
|
3050
|
+
|
|
3051
|
+
hookEvent.attrName = lcName;
|
|
3052
|
+
hookEvent.attrValue = value;
|
|
3053
|
+
hookEvent.keepAttr = true;
|
|
3054
|
+
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
3055
|
+
|
|
3056
|
+
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
3057
|
+
|
|
3058
|
+
value = hookEvent.attrValue;
|
|
3059
|
+
/* Did the hooks approve of the attribute? */
|
|
3060
|
+
|
|
3061
|
+
if (hookEvent.forceKeepAttr) {
|
|
3062
|
+
continue;
|
|
3063
|
+
}
|
|
3064
|
+
/* Remove attribute */
|
|
3065
|
+
|
|
3066
|
+
|
|
3067
|
+
_removeAttribute(name, currentNode);
|
|
3068
|
+
/* Did the hooks approve of the attribute? */
|
|
3069
|
+
|
|
3070
|
+
|
|
3071
|
+
if (!hookEvent.keepAttr) {
|
|
3072
|
+
continue;
|
|
3073
|
+
}
|
|
3074
|
+
/* Work around a security issue in jQuery 3.0 */
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
if (regExpTest(/\/>/i, value)) {
|
|
3078
|
+
_removeAttribute(name, currentNode);
|
|
3079
|
+
|
|
3080
|
+
continue;
|
|
3081
|
+
}
|
|
3082
|
+
/* Sanitize attribute content to be template-safe */
|
|
3083
|
+
|
|
3084
|
+
|
|
3085
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
3086
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
|
|
3087
|
+
value = stringReplace(value, ERB_EXPR$1, ' ');
|
|
3088
|
+
}
|
|
3089
|
+
/* Is `value` valid for this attribute? */
|
|
3090
|
+
|
|
3091
|
+
|
|
3092
|
+
var lcTag = transformCaseFunc(currentNode.nodeName);
|
|
3093
|
+
|
|
3094
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
3095
|
+
continue;
|
|
3096
|
+
}
|
|
3097
|
+
/* Handle attributes that require Trusted Types */
|
|
3098
|
+
|
|
3099
|
+
|
|
3100
|
+
if (trustedTypesPolicy && _typeof(trustedTypes) === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
3101
|
+
if (namespaceURI) ; else {
|
|
3102
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
3103
|
+
case 'TrustedHTML':
|
|
3104
|
+
value = trustedTypesPolicy.createHTML(value);
|
|
3105
|
+
break;
|
|
3106
|
+
|
|
3107
|
+
case 'TrustedScriptURL':
|
|
3108
|
+
value = trustedTypesPolicy.createScriptURL(value);
|
|
3109
|
+
break;
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
/* Handle invalid data-* attribute set by try-catching it */
|
|
3114
|
+
|
|
3115
|
+
|
|
3116
|
+
try {
|
|
3117
|
+
if (namespaceURI) {
|
|
3118
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
3119
|
+
} else {
|
|
3120
|
+
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
|
3121
|
+
currentNode.setAttribute(name, value);
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
arrayPop(DOMPurify.removed);
|
|
3125
|
+
} catch (_) {}
|
|
3126
|
+
}
|
|
3127
|
+
/* Execute a hook if present */
|
|
3128
|
+
|
|
3129
|
+
|
|
3130
|
+
_executeHook('afterSanitizeAttributes', currentNode, null);
|
|
3131
|
+
};
|
|
3132
|
+
/**
|
|
3133
|
+
* _sanitizeShadowDOM
|
|
3134
|
+
*
|
|
3135
|
+
* @param {DocumentFragment} fragment to iterate over recursively
|
|
3136
|
+
*/
|
|
3137
|
+
|
|
3138
|
+
|
|
3139
|
+
var _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
|
3140
|
+
var shadowNode;
|
|
3141
|
+
|
|
3142
|
+
var shadowIterator = _createIterator(fragment);
|
|
3143
|
+
/* Execute a hook if present */
|
|
3144
|
+
|
|
3145
|
+
|
|
3146
|
+
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
|
3147
|
+
|
|
3148
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
3149
|
+
/* Execute a hook if present */
|
|
3150
|
+
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
|
3151
|
+
/* Sanitize tags and elements */
|
|
3152
|
+
|
|
3153
|
+
|
|
3154
|
+
if (_sanitizeElements(shadowNode)) {
|
|
3155
|
+
continue;
|
|
3156
|
+
}
|
|
3157
|
+
/* Deep shadow DOM detected */
|
|
3158
|
+
|
|
3159
|
+
|
|
3160
|
+
if (shadowNode.content instanceof DocumentFragment) {
|
|
3161
|
+
_sanitizeShadowDOM(shadowNode.content);
|
|
3162
|
+
}
|
|
3163
|
+
/* Check attributes, sanitize if necessary */
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
_sanitizeAttributes(shadowNode);
|
|
3167
|
+
}
|
|
3168
|
+
/* Execute a hook if present */
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
|
3172
|
+
};
|
|
3173
|
+
/**
|
|
3174
|
+
* Sanitize
|
|
3175
|
+
* Public method providing core sanitation functionality
|
|
3176
|
+
*
|
|
3177
|
+
* @param {String|Node} dirty string or DOM node
|
|
3178
|
+
* @param {Object} configuration object
|
|
3179
|
+
*/
|
|
3180
|
+
// eslint-disable-next-line complexity
|
|
3181
|
+
|
|
3182
|
+
|
|
3183
|
+
DOMPurify.sanitize = function (dirty, cfg) {
|
|
3184
|
+
var body;
|
|
3185
|
+
var importedNode;
|
|
3186
|
+
var currentNode;
|
|
3187
|
+
var oldNode;
|
|
3188
|
+
var returnNode;
|
|
3189
|
+
/* Make sure we have a string to sanitize.
|
|
3190
|
+
DO NOT return early, as this will return the wrong type if
|
|
3191
|
+
the user has requested a DOM object rather than a string */
|
|
3192
|
+
|
|
3193
|
+
IS_EMPTY_INPUT = !dirty;
|
|
3194
|
+
|
|
3195
|
+
if (IS_EMPTY_INPUT) {
|
|
3196
|
+
dirty = '<!-->';
|
|
3197
|
+
}
|
|
3198
|
+
/* Stringify, in case dirty is an object */
|
|
3199
|
+
|
|
3200
|
+
|
|
3201
|
+
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
|
3202
|
+
// eslint-disable-next-line no-negated-condition
|
|
3203
|
+
if (typeof dirty.toString !== 'function') {
|
|
3204
|
+
throw typeErrorCreate('toString is not a function');
|
|
3205
|
+
} else {
|
|
3206
|
+
dirty = dirty.toString();
|
|
3207
|
+
|
|
3208
|
+
if (typeof dirty !== 'string') {
|
|
3209
|
+
throw typeErrorCreate('dirty is not a string, aborting');
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
/* Check we can run. Otherwise fall back or ignore */
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
if (!DOMPurify.isSupported) {
|
|
3217
|
+
if (_typeof(window.toStaticHTML) === 'object' || typeof window.toStaticHTML === 'function') {
|
|
3218
|
+
if (typeof dirty === 'string') {
|
|
3219
|
+
return window.toStaticHTML(dirty);
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
if (_isNode(dirty)) {
|
|
3223
|
+
return window.toStaticHTML(dirty.outerHTML);
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3227
|
+
return dirty;
|
|
3228
|
+
}
|
|
3229
|
+
/* Assign config vars */
|
|
3230
|
+
|
|
3231
|
+
|
|
3232
|
+
if (!SET_CONFIG) {
|
|
3233
|
+
_parseConfig(cfg);
|
|
3234
|
+
}
|
|
3235
|
+
/* Clean up removed elements */
|
|
3236
|
+
|
|
3237
|
+
|
|
3238
|
+
DOMPurify.removed = [];
|
|
3239
|
+
/* Check if dirty is correctly typed for IN_PLACE */
|
|
3240
|
+
|
|
3241
|
+
if (typeof dirty === 'string') {
|
|
3242
|
+
IN_PLACE = false;
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
if (IN_PLACE) {
|
|
3246
|
+
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
|
3247
|
+
if (dirty.nodeName) {
|
|
3248
|
+
var tagName = transformCaseFunc(dirty.nodeName);
|
|
3249
|
+
|
|
3250
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
3251
|
+
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
} else if (dirty instanceof Node) {
|
|
3255
|
+
/* If dirty is a DOM element, append to an empty document to avoid
|
|
3256
|
+
elements being stripped by the parser */
|
|
3257
|
+
body = _initDocument('<!---->');
|
|
3258
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
3259
|
+
|
|
3260
|
+
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
|
|
3261
|
+
/* Node is already a body, use as is */
|
|
3262
|
+
body = importedNode;
|
|
3263
|
+
} else if (importedNode.nodeName === 'HTML') {
|
|
3264
|
+
body = importedNode;
|
|
3265
|
+
} else {
|
|
3266
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
3267
|
+
body.appendChild(importedNode);
|
|
3268
|
+
}
|
|
3269
|
+
} else {
|
|
3270
|
+
/* Exit directly if we have nothing to do */
|
|
3271
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
|
3272
|
+
dirty.indexOf('<') === -1) {
|
|
3273
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
|
3274
|
+
}
|
|
3275
|
+
/* Initialize the document to work on */
|
|
3276
|
+
|
|
3277
|
+
|
|
3278
|
+
body = _initDocument(dirty);
|
|
3279
|
+
/* Check we have a DOM node from the data */
|
|
3280
|
+
|
|
3281
|
+
if (!body) {
|
|
3282
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
/* Remove first element node (ours) if FORCE_BODY is set */
|
|
3286
|
+
|
|
3287
|
+
|
|
3288
|
+
if (body && FORCE_BODY) {
|
|
3289
|
+
_forceRemove(body.firstChild);
|
|
3290
|
+
}
|
|
3291
|
+
/* Get node iterator */
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
var nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
|
3295
|
+
/* Now start iterating over the created document */
|
|
3296
|
+
|
|
3297
|
+
|
|
3298
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
3299
|
+
/* Fix IE's strange behavior with manipulated textNodes #89 */
|
|
3300
|
+
if (currentNode.nodeType === 3 && currentNode === oldNode) {
|
|
3301
|
+
continue;
|
|
3302
|
+
}
|
|
3303
|
+
/* Sanitize tags and elements */
|
|
3304
|
+
|
|
3305
|
+
|
|
3306
|
+
if (_sanitizeElements(currentNode)) {
|
|
3307
|
+
continue;
|
|
3308
|
+
}
|
|
3309
|
+
/* Shadow DOM detected, sanitize it */
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
if (currentNode.content instanceof DocumentFragment) {
|
|
3313
|
+
_sanitizeShadowDOM(currentNode.content);
|
|
3314
|
+
}
|
|
3315
|
+
/* Check attributes, sanitize if necessary */
|
|
3316
|
+
|
|
3317
|
+
|
|
3318
|
+
_sanitizeAttributes(currentNode);
|
|
3319
|
+
|
|
3320
|
+
oldNode = currentNode;
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
oldNode = null;
|
|
3324
|
+
/* If we sanitized `dirty` in-place, return it. */
|
|
3325
|
+
|
|
3326
|
+
if (IN_PLACE) {
|
|
3327
|
+
return dirty;
|
|
3328
|
+
}
|
|
3329
|
+
/* Return sanitized string or DOM */
|
|
3330
|
+
|
|
3331
|
+
|
|
3332
|
+
if (RETURN_DOM) {
|
|
3333
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
3334
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
3335
|
+
|
|
3336
|
+
while (body.firstChild) {
|
|
3337
|
+
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
|
3338
|
+
returnNode.appendChild(body.firstChild);
|
|
3339
|
+
}
|
|
3340
|
+
} else {
|
|
3341
|
+
returnNode = body;
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
if (ALLOWED_ATTR.shadowroot) {
|
|
3345
|
+
/*
|
|
3346
|
+
AdoptNode() is not used because internal state is not reset
|
|
3347
|
+
(e.g. the past names map of a HTMLFormElement), this is safe
|
|
3348
|
+
in theory but we would rather not risk another attack vector.
|
|
3349
|
+
The state that is cloned by importNode() is explicitly defined
|
|
3350
|
+
by the specs.
|
|
3351
|
+
*/
|
|
3352
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
return returnNode;
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
var serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
3359
|
+
/* Serialize doctype if allowed */
|
|
3360
|
+
|
|
3361
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
3362
|
+
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
|
3363
|
+
}
|
|
3364
|
+
/* Sanitize final string template-safe */
|
|
3365
|
+
|
|
3366
|
+
|
|
3367
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
3368
|
+
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR$1, ' ');
|
|
3369
|
+
serializedHTML = stringReplace(serializedHTML, ERB_EXPR$1, ' ');
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
|
3373
|
+
};
|
|
3374
|
+
/**
|
|
3375
|
+
* Public method to set the configuration once
|
|
3376
|
+
* setConfig
|
|
3377
|
+
*
|
|
3378
|
+
* @param {Object} cfg configuration object
|
|
3379
|
+
*/
|
|
3380
|
+
|
|
3381
|
+
|
|
3382
|
+
DOMPurify.setConfig = function (cfg) {
|
|
3383
|
+
_parseConfig(cfg);
|
|
3384
|
+
|
|
3385
|
+
SET_CONFIG = true;
|
|
3386
|
+
};
|
|
3387
|
+
/**
|
|
3388
|
+
* Public method to remove the configuration
|
|
3389
|
+
* clearConfig
|
|
3390
|
+
*
|
|
3391
|
+
*/
|
|
3392
|
+
|
|
3393
|
+
|
|
3394
|
+
DOMPurify.clearConfig = function () {
|
|
3395
|
+
CONFIG = null;
|
|
3396
|
+
SET_CONFIG = false;
|
|
3397
|
+
};
|
|
3398
|
+
/**
|
|
3399
|
+
* Public method to check if an attribute value is valid.
|
|
3400
|
+
* Uses last set config, if any. Otherwise, uses config defaults.
|
|
3401
|
+
* isValidAttribute
|
|
3402
|
+
*
|
|
3403
|
+
* @param {string} tag Tag name of containing element.
|
|
3404
|
+
* @param {string} attr Attribute name.
|
|
3405
|
+
* @param {string} value Attribute value.
|
|
3406
|
+
* @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
|
|
3407
|
+
*/
|
|
3408
|
+
|
|
3409
|
+
|
|
3410
|
+
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
|
3411
|
+
/* Initialize shared config vars if necessary. */
|
|
3412
|
+
if (!CONFIG) {
|
|
3413
|
+
_parseConfig({});
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
var lcTag = transformCaseFunc(tag);
|
|
3417
|
+
var lcName = transformCaseFunc(attr);
|
|
3418
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
3419
|
+
};
|
|
3420
|
+
/**
|
|
3421
|
+
* AddHook
|
|
3422
|
+
* Public method to add DOMPurify hooks
|
|
3423
|
+
*
|
|
3424
|
+
* @param {String} entryPoint entry point for the hook to add
|
|
3425
|
+
* @param {Function} hookFunction function to execute
|
|
3426
|
+
*/
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
|
3430
|
+
if (typeof hookFunction !== 'function') {
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
hooks[entryPoint] = hooks[entryPoint] || [];
|
|
3435
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
3436
|
+
};
|
|
3437
|
+
/**
|
|
3438
|
+
* RemoveHook
|
|
3439
|
+
* Public method to remove a DOMPurify hook at a given entryPoint
|
|
3440
|
+
* (pops it from the stack of hooks if more are present)
|
|
3441
|
+
*
|
|
3442
|
+
* @param {String} entryPoint entry point for the hook to remove
|
|
3443
|
+
* @return {Function} removed(popped) hook
|
|
3444
|
+
*/
|
|
3445
|
+
|
|
3446
|
+
|
|
3447
|
+
DOMPurify.removeHook = function (entryPoint) {
|
|
3448
|
+
if (hooks[entryPoint]) {
|
|
3449
|
+
return arrayPop(hooks[entryPoint]);
|
|
3450
|
+
}
|
|
3451
|
+
};
|
|
3452
|
+
/**
|
|
3453
|
+
* RemoveHooks
|
|
3454
|
+
* Public method to remove all DOMPurify hooks at a given entryPoint
|
|
3455
|
+
*
|
|
3456
|
+
* @param {String} entryPoint entry point for the hooks to remove
|
|
3457
|
+
*/
|
|
3458
|
+
|
|
3459
|
+
|
|
3460
|
+
DOMPurify.removeHooks = function (entryPoint) {
|
|
3461
|
+
if (hooks[entryPoint]) {
|
|
3462
|
+
hooks[entryPoint] = [];
|
|
3463
|
+
}
|
|
3464
|
+
};
|
|
3465
|
+
/**
|
|
3466
|
+
* RemoveAllHooks
|
|
3467
|
+
* Public method to remove all DOMPurify hooks
|
|
3468
|
+
*
|
|
3469
|
+
*/
|
|
3470
|
+
|
|
3471
|
+
|
|
3472
|
+
DOMPurify.removeAllHooks = function () {
|
|
3473
|
+
hooks = {};
|
|
3474
|
+
};
|
|
3475
|
+
|
|
3476
|
+
return DOMPurify;
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
var purify = createDOMPurify();
|
|
3480
|
+
|
|
3481
|
+
return purify;
|
|
3482
|
+
|
|
3483
|
+
}));
|
|
3484
|
+
//# sourceMappingURL=purify.js.map
|
|
3485
|
+
});
|
|
3486
|
+
|
|
3487
|
+
/**
|
|
3488
|
+
* Returns a function that can be executed only once
|
|
3489
|
+
*/
|
|
3490
|
+
function once(fn) {
|
|
3491
|
+
let result;
|
|
3492
|
+
return function (...args) {
|
|
3493
|
+
if (fn) {
|
|
3494
|
+
result = fn.apply(this, args);
|
|
3495
|
+
fn = () => { };
|
|
3496
|
+
}
|
|
3497
|
+
return result;
|
|
3498
|
+
};
|
|
3499
|
+
}
|
|
3500
|
+
function camelToKebab(value) {
|
|
3501
|
+
return value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
3502
|
+
}
|
|
3503
|
+
function kebabToCamel(value) {
|
|
3504
|
+
return value.replace(/-./g, (x) => x[1].toUpperCase());
|
|
3505
|
+
}
|
|
3506
|
+
function snakeToCamel(value) {
|
|
3507
|
+
return value
|
|
3508
|
+
.toLowerCase()
|
|
3509
|
+
.replace(/([_][a-z])/g, (group) => group.toUpperCase().replace('_', ''));
|
|
3510
|
+
}
|
|
3511
|
+
function titleToKebab(value) {
|
|
3512
|
+
return value.replace(/\s/g, '-').toLowerCase();
|
|
3513
|
+
}
|
|
3514
|
+
function randomID(prepend, length = 5) {
|
|
3515
|
+
const randomStr = Math.random()
|
|
3516
|
+
.toString(36)
|
|
3517
|
+
.substring(2, 2 + length);
|
|
3518
|
+
if (!prepend) {
|
|
3519
|
+
return randomStr;
|
|
3520
|
+
}
|
|
3521
|
+
return prepend + randomStr;
|
|
3522
|
+
}
|
|
3523
|
+
function getRandomArbitrary(min, max) {
|
|
3524
|
+
return Math.random() * (max - min) + min;
|
|
3525
|
+
}
|
|
3526
|
+
function parseXML(string) {
|
|
3527
|
+
return new window.DOMParser().parseFromString(string, 'text/xml');
|
|
3528
|
+
}
|
|
3529
|
+
function isElementNode(node) {
|
|
3530
|
+
return node.nodeType === 1 /* ELEMENT_NODE */;
|
|
3531
|
+
}
|
|
3532
|
+
function isTextNode(node) {
|
|
3533
|
+
return node.nodeType === 3 /* TEXT_NODE */;
|
|
3534
|
+
}
|
|
3535
|
+
function isVisualNode(node) {
|
|
3536
|
+
var _a;
|
|
3537
|
+
if (isElementNode(node)) {
|
|
3538
|
+
return !(node instanceof HTMLStyleElement);
|
|
3539
|
+
}
|
|
3540
|
+
if (isTextNode(node)) {
|
|
3541
|
+
return !!((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim());
|
|
3542
|
+
}
|
|
3543
|
+
return false;
|
|
3544
|
+
}
|
|
3545
|
+
function containsVisualElement(node) {
|
|
3546
|
+
for (let i = 0; i < node.childNodes.length; i++) {
|
|
3547
|
+
const child = node.childNodes.item(i);
|
|
3548
|
+
if (isVisualNode(child)) {
|
|
3549
|
+
return true;
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
return false;
|
|
3553
|
+
}
|
|
3554
|
+
function parseAssetURL(url, assetPath = './assets') {
|
|
3555
|
+
const [, protocol, remainder] = url.match(/^([a-z]+):\/\/(.*?)(\.svg)?$/) || [];
|
|
3556
|
+
if (!protocol) {
|
|
3557
|
+
if (url.startsWith('./') || url.startsWith('../')) {
|
|
3558
|
+
return url;
|
|
3559
|
+
}
|
|
3560
|
+
return null;
|
|
3561
|
+
}
|
|
3562
|
+
if (protocol === 'http' || protocol === 'https') {
|
|
3563
|
+
return url;
|
|
3564
|
+
}
|
|
3565
|
+
if (protocol === 'assets') {
|
|
3566
|
+
return getAssetPath(`${assetPath}/${remainder}.svg`);
|
|
3567
|
+
}
|
|
3568
|
+
return null;
|
|
3569
|
+
}
|
|
3570
|
+
// TODO: add tests
|
|
3571
|
+
function elementHasAncestorTag(el, tagName) {
|
|
3572
|
+
const parentElement = el.parentElement;
|
|
3573
|
+
if (!parentElement) {
|
|
3574
|
+
return false;
|
|
3575
|
+
}
|
|
3576
|
+
if (parentElement.tagName === tagName.toUpperCase()) {
|
|
3577
|
+
return true;
|
|
3578
|
+
}
|
|
3579
|
+
return elementHasAncestorTag(parentElement, tagName);
|
|
3580
|
+
}
|
|
3581
|
+
function closest(element, selector) {
|
|
3582
|
+
if (!element) {
|
|
3583
|
+
return null;
|
|
3584
|
+
}
|
|
3585
|
+
if (element.matches(selector)) {
|
|
3586
|
+
return element;
|
|
3587
|
+
}
|
|
3588
|
+
if (element.parentNode instanceof ShadowRoot) {
|
|
3589
|
+
return closest(element.parentNode.host, selector);
|
|
3590
|
+
}
|
|
3591
|
+
return closest(element.parentElement, selector);
|
|
3592
|
+
}
|
|
3593
|
+
function sanitizeStyle(style) {
|
|
3594
|
+
var _a;
|
|
3595
|
+
const purifiedOuterHTML = purify.sanitize(`<style>${style}</style>`, {
|
|
3596
|
+
ALLOWED_TAGS: ['style'],
|
|
3597
|
+
ALLOWED_ATTR: [],
|
|
3598
|
+
FORCE_BODY: true,
|
|
3599
|
+
});
|
|
3600
|
+
const wrapperEl = document.createElement('div');
|
|
3601
|
+
// deepcode ignore ReactSetInnerHtml: sanitized by dompurify
|
|
3602
|
+
wrapperEl.innerHTML = purifiedOuterHTML;
|
|
3603
|
+
return (_a = wrapperEl.querySelector('style')) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
3604
|
+
}
|
|
3605
|
+
function getFocusedElement(rootElement = document) {
|
|
3606
|
+
var _a;
|
|
3607
|
+
const activeElement = rootElement.activeElement;
|
|
3608
|
+
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
|
|
3609
|
+
return (_a = getFocusedElement(activeElement.shadowRoot)) !== null && _a !== void 0 ? _a : activeElement;
|
|
3610
|
+
}
|
|
3611
|
+
return activeElement;
|
|
3612
|
+
}
|
|
3613
|
+
async function defer() {
|
|
3614
|
+
return new Promise((resolve) => setTimeout(resolve, 10));
|
|
3615
|
+
}
|
|
3616
|
+
// https://terodox.tech/how-to-tell-if-an-element-is-in-the-dom-including-the-shadow-dom/
|
|
3617
|
+
function isInDocument(element) {
|
|
3618
|
+
let currentElement = element;
|
|
3619
|
+
while (currentElement && currentElement.parentNode) {
|
|
3620
|
+
if (currentElement.parentNode === document) {
|
|
3621
|
+
return true;
|
|
3622
|
+
}
|
|
3623
|
+
else if (currentElement.parentNode instanceof ShadowRoot) {
|
|
3624
|
+
currentElement = currentElement.parentNode.host;
|
|
3625
|
+
}
|
|
3626
|
+
else {
|
|
3627
|
+
currentElement = currentElement.parentNode;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
return false;
|
|
3631
|
+
}
|
|
3632
|
+
function getParent(element) {
|
|
3633
|
+
if (element.parentNode) {
|
|
3634
|
+
return element.parentNode;
|
|
3635
|
+
}
|
|
3636
|
+
if (element instanceof ShadowRoot) {
|
|
3637
|
+
return element.host;
|
|
3638
|
+
}
|
|
3639
|
+
return null;
|
|
3640
|
+
}
|
|
3641
|
+
function isAncestorOf(ancestor, element) {
|
|
3642
|
+
if (element === ancestor) {
|
|
3643
|
+
return true;
|
|
3644
|
+
}
|
|
3645
|
+
if (element instanceof HTMLElement &&
|
|
3646
|
+
element.assignedSlot &&
|
|
3647
|
+
isAncestorOf(ancestor, element.assignedSlot)) {
|
|
3648
|
+
return true;
|
|
3649
|
+
}
|
|
3650
|
+
const parent = getParent(element);
|
|
3651
|
+
return parent === null ? false : isAncestorOf(ancestor, parent);
|
|
3652
|
+
}
|
|
3653
|
+
function aggregate(values, getKey) {
|
|
3654
|
+
return values.reduce((aggregatedValues, value, i) => {
|
|
3655
|
+
const key = getKey(value, i);
|
|
3656
|
+
if (!(key in aggregatedValues)) {
|
|
3657
|
+
aggregatedValues[key] = [];
|
|
3658
|
+
}
|
|
3659
|
+
aggregatedValues[key].push(value);
|
|
3660
|
+
return aggregatedValues;
|
|
3661
|
+
}, {});
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
const Hidden = () => (h(Host, { class: "atomic-hidden" }));
|
|
3665
|
+
|
|
3666
|
+
const initializeEventName = 'atomic/initializeComponent';
|
|
3667
|
+
const initializableElements = [
|
|
3668
|
+
'atomic-recs-interface',
|
|
3669
|
+
'atomic-search-interface',
|
|
3670
|
+
'atomic-relevance-inspector',
|
|
3671
|
+
'atomic-insight-interface',
|
|
3672
|
+
'atomic-external',
|
|
3673
|
+
];
|
|
3674
|
+
/**
|
|
3675
|
+
* Retrieves `Bindings` on a configured parent search interface.
|
|
3676
|
+
* @param event Element on which to dispatch the event, which must be the child of a configured "atomic-search-interface" or "atomic-external" element.
|
|
3677
|
+
* @returns A promise that resolves on initialization of the parent "atomic-search-interface" or "atomic-external" element, and rejects when it's not the case.
|
|
3678
|
+
*/
|
|
3679
|
+
function initializeBindings$1(element) {
|
|
3680
|
+
return new Promise((resolve, reject) => {
|
|
3681
|
+
const event = buildCustomEvent(initializeEventName, (bindings) => resolve(bindings));
|
|
3682
|
+
element.dispatchEvent(event);
|
|
3683
|
+
if (!closest(element, initializableElements.join(', '))) {
|
|
3684
|
+
reject(new MissingInterfaceParentError(element.nodeName.toLowerCase()));
|
|
3685
|
+
}
|
|
3686
|
+
});
|
|
3687
|
+
}
|
|
3688
|
+
class MissingInterfaceParentError extends Error {
|
|
3689
|
+
constructor(elementName) {
|
|
3690
|
+
super(`The "${elementName}" element must be the child of the following elements: ${initializableElements.join(', ')}`);
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
/**
|
|
3694
|
+
* Makes Shadow Dom elements compatible with the focus-visible polyfill https://github.com/WICG/focus-visible
|
|
3695
|
+
* Necessary for Safari under version 15.4.
|
|
3696
|
+
*/
|
|
3697
|
+
function applyFocusVisiblePolyfill(element) {
|
|
3698
|
+
if (!element.shadowRoot) {
|
|
3699
|
+
return;
|
|
3700
|
+
}
|
|
3701
|
+
if (window.applyFocusVisiblePolyfill) {
|
|
3702
|
+
window.applyFocusVisiblePolyfill(element.shadowRoot);
|
|
3703
|
+
return;
|
|
3704
|
+
}
|
|
3705
|
+
window.addEventListener('focus-visible-polyfill-ready', () => { var _a; return (_a = window.applyFocusVisiblePolyfill) === null || _a === void 0 ? void 0 : _a.call(window, element.shadowRoot); }, { once: true });
|
|
3706
|
+
}
|
|
3707
|
+
const renderedAttribute = 'data-atomic-rendered';
|
|
3708
|
+
const loadedAttribute = 'data-atomic-loaded';
|
|
3709
|
+
/**
|
|
3710
|
+
* A [StencilJS property decorator](https://stenciljs.com/) to be used on a property named `bindings`.
|
|
3711
|
+
* This will automatically fetch the `Bindings` from the parent `atomic-search-interface` or `atomic-external` components.
|
|
3712
|
+
*
|
|
3713
|
+
* Once a component is bound, the `initialize` method is called.
|
|
3714
|
+
* In the event of an initialization error, the `error` property will be set and an `atomic-component-error` will be rendered.
|
|
3715
|
+
*
|
|
3716
|
+
* In order for a component using this decorator to render properly, it should have an internal state bound to one of the properties from `bindings`.
|
|
3717
|
+
* This is possible by using the `BindStateToController` decorator.
|
|
3718
|
+
*
|
|
3719
|
+
* @example
|
|
3720
|
+
* @InitializeBindings() public bindings!: Bindings;
|
|
3721
|
+
*
|
|
3722
|
+
* For more information and examples, view the "Utilities" section of the readme.
|
|
3723
|
+
*/
|
|
3724
|
+
function InitializeBindings({ forceUpdate: forceUpdate$1, } = {}) {
|
|
3725
|
+
return (component, bindingsProperty) => {
|
|
3726
|
+
const { componentWillLoad, render, componentDidRender, componentDidLoad, disconnectedCallback, } = component;
|
|
3727
|
+
let unsubscribeLanguage = () => { };
|
|
3728
|
+
if (bindingsProperty !== 'bindings') {
|
|
3729
|
+
return console.error(`The InitializeBindings decorator should be used on a property called "bindings", and not "${bindingsProperty}"`, component);
|
|
3730
|
+
}
|
|
3731
|
+
component.componentWillLoad = function () {
|
|
3732
|
+
const element = getElement(this);
|
|
3733
|
+
element.setAttribute(renderedAttribute, 'false');
|
|
3734
|
+
element.setAttribute(loadedAttribute, 'false');
|
|
3735
|
+
const event = buildCustomEvent(initializeEventName, (bindings) => {
|
|
3736
|
+
this.bindings = bindings;
|
|
3737
|
+
const updateLanguage = () => forceUpdate(this);
|
|
3738
|
+
this.bindings.i18n.on('languageChanged', updateLanguage);
|
|
3739
|
+
unsubscribeLanguage = () => this.bindings.i18n.off('languageChanged', updateLanguage);
|
|
3740
|
+
try {
|
|
3741
|
+
// When no controller is initialized, updating a property with a State() decorator, there will be no re-render.
|
|
3742
|
+
// In this case, we have to manually trigger it.
|
|
3743
|
+
if (this.initialize) {
|
|
3744
|
+
this.initialize();
|
|
3745
|
+
if (forceUpdate$1) {
|
|
3746
|
+
forceUpdate(this);
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
else {
|
|
3750
|
+
forceUpdate(this);
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
catch (e) {
|
|
3754
|
+
this.error = e;
|
|
3755
|
+
}
|
|
3756
|
+
});
|
|
3757
|
+
element.dispatchEvent(event);
|
|
3758
|
+
if (!closest(element, initializableElements.join(', '))) {
|
|
3759
|
+
this.error = new MissingInterfaceParentError(element.nodeName.toLowerCase());
|
|
3760
|
+
return;
|
|
3761
|
+
}
|
|
3762
|
+
return componentWillLoad && componentWillLoad.call(this);
|
|
3763
|
+
};
|
|
3764
|
+
component.render = function () {
|
|
3765
|
+
if (this.error) {
|
|
3766
|
+
return (h("atomic-component-error", { element: getElement(this), error: this.error }));
|
|
3767
|
+
}
|
|
3768
|
+
if (!this.bindings) {
|
|
3769
|
+
return h(Hidden, null);
|
|
3770
|
+
}
|
|
3771
|
+
getElement(this).setAttribute(renderedAttribute, 'true');
|
|
3772
|
+
return render && render.call(this);
|
|
3773
|
+
};
|
|
3774
|
+
component.disconnectedCallback = function () {
|
|
3775
|
+
const element = getElement(this);
|
|
3776
|
+
element.setAttribute(renderedAttribute, 'false');
|
|
3777
|
+
element.setAttribute(loadedAttribute, 'false');
|
|
3778
|
+
unsubscribeLanguage();
|
|
3779
|
+
disconnectedCallback && disconnectedCallback.call(this);
|
|
3780
|
+
};
|
|
3781
|
+
component.componentDidRender = function () {
|
|
3782
|
+
const element = getElement(this);
|
|
3783
|
+
if (element.getAttribute(renderedAttribute) === 'false') {
|
|
3784
|
+
return;
|
|
3785
|
+
}
|
|
3786
|
+
componentDidRender && componentDidRender.call(this);
|
|
3787
|
+
if (element.getAttribute(loadedAttribute) === 'false') {
|
|
3788
|
+
element.setAttribute(loadedAttribute, 'true');
|
|
3789
|
+
applyFocusVisiblePolyfill(getElement(this));
|
|
3790
|
+
componentDidLoad && componentDidLoad.call(this);
|
|
3791
|
+
}
|
|
3792
|
+
};
|
|
3793
|
+
component.componentDidLoad = function () { };
|
|
3794
|
+
};
|
|
3795
|
+
}
|
|
3796
|
+
/**
|
|
3797
|
+
* A [StencilJS property decorator](https://stenciljs.com/) is used together with the [State decorator](https://stenciljs.com/docs/state#state-decorator).
|
|
3798
|
+
* This allows the Stencil component state property to automatically get updates from a [Coveo Headless controller](https://docs.coveo.com/en/headless/latest/usage/#use-headless-controllers).
|
|
3799
|
+
*
|
|
3800
|
+
* @example
|
|
3801
|
+
* @BindStateToController('pager') @State() private pagerState!: PagerState;
|
|
3802
|
+
*
|
|
3803
|
+
* For more information and examples, view the "Utilities" section of the readme.
|
|
3804
|
+
*
|
|
3805
|
+
* @param controllerProperty The controller property to subscribe to. The controller has to be created inside of the `initialize` method.
|
|
3806
|
+
* @param options The configurable `BindStateToController` options.
|
|
3807
|
+
*/
|
|
3808
|
+
function BindStateToController(controllerProperty, options) {
|
|
3809
|
+
return (component, stateProperty) => {
|
|
3810
|
+
const { disconnectedCallback, initialize } = component;
|
|
3811
|
+
let unsubscribeController = () => { };
|
|
3812
|
+
component.initialize = function () {
|
|
3813
|
+
initialize && initialize.call(this);
|
|
3814
|
+
if (!initialize) {
|
|
3815
|
+
return console.error(`ControllerState: The "initialize" method has to be defined and instanciate a controller for the property ${controllerProperty}`, component);
|
|
3816
|
+
}
|
|
3817
|
+
if (!this[controllerProperty]) {
|
|
3818
|
+
return;
|
|
3819
|
+
}
|
|
3820
|
+
if ((options === null || options === void 0 ? void 0 : options.onUpdateCallbackMethod) &&
|
|
3821
|
+
!this[options.onUpdateCallbackMethod]) {
|
|
3822
|
+
return console.error(`ControllerState: The onUpdateCallbackMethod property "${options.onUpdateCallbackMethod}" is not defined`, component);
|
|
3823
|
+
}
|
|
3824
|
+
unsubscribeController = this[controllerProperty].subscribe(() => {
|
|
3825
|
+
this[stateProperty] = this[controllerProperty].state;
|
|
3826
|
+
(options === null || options === void 0 ? void 0 : options.onUpdateCallbackMethod) &&
|
|
3827
|
+
this[options.onUpdateCallbackMethod]();
|
|
3828
|
+
});
|
|
3829
|
+
};
|
|
3830
|
+
component.disconnectedCallback = function () {
|
|
3831
|
+
!getElement(this).isConnected && unsubscribeController();
|
|
3832
|
+
disconnectedCallback && disconnectedCallback.call(this);
|
|
3833
|
+
};
|
|
3834
|
+
};
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
/**
|
|
3838
|
+
* @license
|
|
3839
|
+
*
|
|
3840
|
+
* Copyright 2023 Coveo Solutions Inc.
|
|
3841
|
+
*
|
|
3842
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3843
|
+
* you may not use this file except in compliance with the License.
|
|
3844
|
+
* You may obtain a copy of the License at
|
|
3845
|
+
*
|
|
3846
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3847
|
+
*
|
|
3848
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3849
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3850
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3851
|
+
* See the License for the specific language governing permissions and
|
|
3852
|
+
* limitations under the License.
|
|
3853
|
+
*/
|
|
3854
|
+
var zv=Object.create;var Ni=Object.defineProperty;var Wv=Object.getOwnPropertyDescriptor;var Yv=Object.getOwnPropertyNames;var Kv=Object.getPrototypeOf,Gv=Object.prototype.hasOwnProperty;var Op=e=>Ni(e,"__esModule",{value:!0});var fe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),nl=(e,t)=>{Op(e);for(var r in t)Ni(e,r,{get:t[r],enumerable:!0});},R=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Yv(t))!Gv.call(e,a)&&a!=="default"&&Ni(e,a,{get:()=>t[a],enumerable:!(r=Wv(t,a))||r.enumerable});return e},be=e=>R(Op(Ni(e!=null?zv(Kv(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Hp=fe((lk,Bo)=>{function iC(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Bo.exports=iC,Bo.exports.__esModule=!0,Bo.exports.default=Bo.exports;});var Wp=fe((dk,_o)=>{var sC=Hp();function zp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a);}return r}function cC(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zp(Object(r),!0).forEach(function(a){sC(e,a,r[a]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zp(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a));});}return e}_o.exports=cC,_o.exports.__esModule=!0,_o.exports.default=_o.exports;});var Ho=fe(pr=>{Object.defineProperty(pr,"__esModule",{value:!0});var uC=Wp();function lC(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Yp=lC(uC);function Te(e){return "Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var Kp=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),yl=function(){return Math.random().toString(36).substring(7).split("").join(".")},$o={INIT:"@@redux/INIT"+yl(),REPLACE:"@@redux/REPLACE"+yl(),PROBE_UNKNOWN_ACTION:function(){return "@@redux/PROBE_UNKNOWN_ACTION"+yl()}};function dC(e){if(typeof e!="object"||e===null)return !1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function vl(e,t,r){var a;if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Te(0));if(typeof t=="function"&&typeof r=="undefined"&&(r=t,t=void 0),typeof r!="undefined"){if(typeof r!="function")throw new Error(Te(1));return r(vl)(e,t)}if(typeof e!="function")throw new Error(Te(2));var n=e,o=t,i=[],s=i,u=!1;function c(){s===i&&(s=i.slice());}function l(){if(u)throw new Error(Te(3));return o}function p(h){if(typeof h!="function")throw new Error(Te(4));if(u)throw new Error(Te(5));var v=!0;return c(),s.push(h),function(){if(!!v){if(u)throw new Error(Te(6));v=!1,c();var x=s.indexOf(h);s.splice(x,1),i=null;}}}function f(h){if(!dC(h))throw new Error(Te(7));if(typeof h.type=="undefined")throw new Error(Te(8));if(u)throw new Error(Te(9));try{u=!0,o=n(o,h);}finally{u=!1;}for(var v=i=s,C=0;C<v.length;C++){var x=v[C];x();}return h}function d(h){if(typeof h!="function")throw new Error(Te(10));n=h,f({type:$o.REPLACE});}function m(){var h,v=p;return h={subscribe:function(x){if(typeof x!="object"||x===null)throw new Error(Te(11));function b(){x.next&&x.next(l());}b();var P=v(b);return {unsubscribe:P}}},h[Kp]=function(){return this},h}return f({type:$o.INIT}),a={dispatch:f,subscribe:p,getState:l,replaceReducer:d},a[Kp]=m,a}var pC=vl;function fC(e){Object.keys(e).forEach(function(t){var r=e[t],a=r(void 0,{type:$o.INIT});if(typeof a=="undefined")throw new Error(Te(12));if(typeof r(void 0,{type:$o.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error(Te(13))});}function mC(e){for(var t=Object.keys(e),r={},a=0;a<t.length;a++){var n=t[a];typeof e[n]=="function"&&(r[n]=e[n]);}var o=Object.keys(r),s;try{fC(r);}catch(u){s=u;}return function(c,l){if(c===void 0&&(c={}),s)throw s;for(var f=!1,d={},m=0;m<o.length;m++){var h=o[m],v=r[h],C=c[h],x=v(C,l);if(typeof x=="undefined"){throw new Error(Te(14))}d[h]=x,f=f||x!==C;}return f=f||o.length!==Object.keys(c).length,f?d:c}}function Gp(e,t){return function(){return t(e.apply(this,arguments))}}function gC(e,t){if(typeof e=="function")return Gp(e,t);if(typeof e!="object"||e===null)throw new Error(Te(16));var r={};for(var a in e){var n=e[a];typeof n=="function"&&(r[a]=Gp(n,t));}return r}function Jp(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.length===0?function(a){return a}:t.length===1?t[0]:t.reduce(function(a,n){return function(){return a(n.apply(void 0,arguments))}})}function hC(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(a){return function(){var n=a.apply(void 0,arguments),o=function(){throw new Error(Te(15))},i={getState:n.getState,dispatch:function(){return o.apply(void 0,arguments)}},s=t.map(function(u){return u(i)});return o=Jp.apply(void 0,s)(n.dispatch),Yp.default(Yp.default({},n),{},{dispatch:o})}}}pr.__DO_NOT_USE__ActionTypes=$o;pr.applyMiddleware=hC;pr.bindActionCreators=gC;pr.combineReducers=mC;pr.compose=Jp;pr.createStore=vl;pr.legacy_createStore=pC;});var Nf=fe((Ek,Vf)=>{function px(e){try{return JSON.stringify(e)}catch{return '"[Circular]"'}}Vf.exports=fx;function fx(e,t,r){var a=r&&r.stringify||px,n=1;if(typeof e=="object"&&e!==null){var o=t.length+n;if(o===1)return e;var i=new Array(o);i[0]=a(e);for(var s=1;s<o;s++)i[s]=a(t[s]);return i.join(" ")}if(typeof e!="string")return e;var u=t.length;if(u===0)return e;for(var c="",l=1-n,p=-1,f=e&&e.length||0,d=0;d<f;){if(e.charCodeAt(d)===37&&d+1<f){switch(p=p>-1?p:0,e.charCodeAt(d+1)){case 100:case 102:if(l>=u||t[l]==null)break;p<d&&(c+=e.slice(p,d)),c+=Number(t[l]),p=d+2,d++;break;case 105:if(l>=u||t[l]==null)break;p<d&&(c+=e.slice(p,d)),c+=Math.floor(Number(t[l])),p=d+2,d++;break;case 79:case 111:case 106:if(l>=u||t[l]===void 0)break;p<d&&(c+=e.slice(p,d));var m=typeof t[l];if(m==="string"){c+="'"+t[l]+"'",p=d+2,d++;break}if(m==="function"){c+=t[l].name||"<anonymous>",p=d+2,d++;break}c+=a(t[l]),p=d+2,d++;break;case 115:if(l>=u)break;p<d&&(c+=e.slice(p,d)),c+=String(t[l]),p=d+2,d++;break;case 37:p<d&&(c+=e.slice(p,d)),c+="%",p=d+2,d++,l--;break}++l;}++d;}return p===-1?e:(p<f&&(c+=e.slice(p)),c)}});var ri=fe((wk,jf)=>{var Mf=Nf();jf.exports=qt;var ei=bx().console||{},mx={mapHttpRequest:Ki,mapHttpResponse:Ki,wrapRequestSerializer:Dl,wrapResponseSerializer:Dl,wrapErrorSerializer:Dl,req:Ki,res:Ki,err:vx};function gx(e,t){return Array.isArray(e)?e.filter(function(a){return a!=="!stdSerializers.err"}):e===!0?Object.keys(t):!1}function qt(e){e=e||{},e.browser=e.browser||{};let t=e.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");let r=e.browser.write||ei;e.browser.write&&(e.browser.asObject=!0);let a=e.serializers||{},n=gx(e.browser.serialize,a),o=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(o=!1);let i=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),e.enabled===!1&&(e.level="silent");let s=e.level||"info",u=Object.create(r);u.log||(u.log=ti),Object.defineProperty(u,"levelVal",{get:l}),Object.defineProperty(u,"level",{get:p,set:f});let c={transmit:t,serialize:n,asObject:e.browser.asObject,levels:i,timestamp:Cx(e)};u.levels=qt.levels,u.level=s,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=ti,u.serializers=a,u._serialize=n,u._stdErrSerialize=o,u.child=d,t&&(u._logEvent=Tl());function l(){return this.level==="silent"?1/0:this.levels.values[this.level]}function p(){return this._level}function f(m){if(m!=="silent"&&!this.levels.values[m])throw Error("unknown level "+m);this._level=m,Ha(c,u,"error","log"),Ha(c,u,"fatal","error"),Ha(c,u,"warn","error"),Ha(c,u,"info","log"),Ha(c,u,"debug","log"),Ha(c,u,"trace","log");}function d(m,h){if(!m)throw new Error("missing bindings for child Pino");h=h||{},n&&m.serializers&&(h.serializers=m.serializers);let v=h.serializers;if(n&&v){var C=Object.assign({},a,v),x=e.browser.serialize===!0?Object.keys(C):n;delete m.serializers,Yi([m],x,C,this._stdErrSerialize);}function b(P){this._childLevel=(P._childLevel|0)+1,this.error=za(P,m,"error"),this.fatal=za(P,m,"fatal"),this.warn=za(P,m,"warn"),this.info=za(P,m,"info"),this.debug=za(P,m,"debug"),this.trace=za(P,m,"trace"),C&&(this.serializers=C,this._serialize=x),t&&(this._logEvent=Tl([].concat(P._logEvent.bindings,m)));}return b.prototype=this,new b(this)}return u}qt.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qt.stdSerializers=mx;qt.stdTimeFunctions=Object.assign({},{nullTime:Qf,epochTime:Lf,unixTime:xx,isoTime:Rx});function Ha(e,t,r,a){let n=Object.getPrototypeOf(t);t[r]=t.levelVal>t.levels.values[r]?ti:n[r]?n[r]:ei[r]||ei[a]||ti,hx(e,t,r);}function hx(e,t,r){!e.transmit&&t[r]===ti||(t[r]=function(a){return function(){let o=e.timestamp(),i=new Array(arguments.length),s=Object.getPrototypeOf&&Object.getPrototypeOf(this)===ei?ei:this;for(var u=0;u<i.length;u++)i[u]=arguments[u];if(e.serialize&&!e.asObject&&Yi(i,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?a.call(s,Sx(this,r,i,o)):a.apply(s,i),e.transmit){let c=e.transmit.level||t.level,l=qt.levels.values[c],p=qt.levels.values[r];if(p<l)return;yx(this,{ts:o,methodLevel:r,methodValue:p,transmitLevel:c,transmitValue:qt.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},i);}}}(t[r]));}function Sx(e,t,r,a){e._serialize&&Yi(r,e._serialize,e.serializers,e._stdErrSerialize);let n=r.slice(),o=n[0],i={};a&&(i.time=a),i.level=qt.levels.values[t];let s=(e._childLevel|0)+1;if(s<1&&(s=1),o!==null&&typeof o=="object"){for(;s--&&typeof n[0]=="object";)Object.assign(i,n.shift());o=n.length?Mf(n.shift(),n):void 0;}else typeof o=="string"&&(o=Mf(n.shift(),n));return o!==void 0&&(i.msg=o),i}function Yi(e,t,r,a){for(let n in e)if(a&&e[n]instanceof Error)e[n]=qt.stdSerializers.err(e[n]);else if(typeof e[n]=="object"&&!Array.isArray(e[n]))for(let o in e[n])t&&t.indexOf(o)>-1&&o in r&&(e[n][o]=r[o](e[n][o]));}function za(e,t,r){return function(){let a=new Array(1+arguments.length);a[0]=t;for(var n=1;n<a.length;n++)a[n]=arguments[n-1];return e[r].apply(this,a)}}function yx(e,t,r){let a=t.send,n=t.ts,o=t.methodLevel,i=t.methodValue,s=t.val,u=e._logEvent.bindings;Yi(r,e._serialize||Object.keys(e.serializers),e.serializers,e._stdErrSerialize===void 0?!0:e._stdErrSerialize),e._logEvent.ts=n,e._logEvent.messages=r.filter(function(c){return u.indexOf(c)===-1}),e._logEvent.level.label=o,e._logEvent.level.value=i,a(o,e._logEvent,s),e._logEvent=Tl(u);}function Tl(e){return {ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function vx(e){let t={type:e.constructor.name,msg:e.message,stack:e.stack};for(let r in e)t[r]===void 0&&(t[r]=e[r]);return t}function Cx(e){return typeof e.timestamp=="function"?e.timestamp:e.timestamp===!1?Qf:Lf}function Ki(){return {}}function Dl(e){return e}function ti(){}function Qf(){return !1}function Lf(){return Date.now()}function xx(){return Math.round(Date.now()/1e3)}function Rx(){return new Date(Date.now()).toISOString()}function bx(){function e(t){return typeof t!="undefined"&&t}try{return typeof globalThis!="undefined"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return e(self)||e(window)||e(this)||{}}}});var $f=fe((kk,_f)=>{var Fx="[object Object]";function Ax(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"");}catch{}return t}function Px(e,t){return function(r){return e(t(r))}}var Ix=Function.prototype,Uf=Object.prototype,Bf=Ix.toString,Ex=Uf.hasOwnProperty,wx=Bf.call(Object),kx=Uf.toString,Ox=Px(Object.getPrototypeOf,Object);function qx(e){return !!e&&typeof e=="object"}function Tx(e){if(!qx(e)||kx.call(e)!=Fx||Ax(e))return !1;var t=Ox(e);if(t===null)return !0;var r=Ex.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Bf.call(r)==wx}_f.exports=Tx;});var Hf=fe(Nl=>{Object.defineProperty(Nl,"__esModule",{value:!0});Nl.default=Lx;var Dx=Ho(),Vx=$f(),Nx=Mx(Vx);function Mx(e){return e&&e.__esModule?e:{default:e}}function Qx(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}else return Array.from(e)}var Vl=function(t){return typeof t=="function"};function Lx(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};function a(){var o=[],i=[],s={getState:function(){return Vl(r)?r(o):r},getActions:function(){return o},dispatch:function(c){if(!(0, Nx.default)(c))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof c.type=="undefined")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant? Action: '+JSON.stringify(c));o.push(c);for(var l=0;l<i.length;l++)i[l]();return c},clearActions:function(){o=[];},subscribe:function(c){return Vl(c)&&i.push(c),function(){var l=i.indexOf(c);l<0||i.splice(l,1);}},replaceReducer:function(c){if(!Vl(c))throw new Error("Expected the nextReducer to be a function.")}};return s}var n=Dx.applyMiddleware.apply(void 0,Qx(e))(a);return n()}}});var Dm=fe((pO,Tm)=>{Tm.exports=fetch;});var Vm=fe(ci=>{var rs=ci&&ci.__assign||function(){return rs=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);}return e},rs.apply(this,arguments)};Object.defineProperty(ci,"__esModule",{value:!0});var gb={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:function(){return !0},startingDelay:100,timeMultiple:2};function hb(e){var t=rs(rs({},gb),e);return t.numOfAttempts<1&&(t.numOfAttempts=1),t}ci.getSanitizedOptions=hb;});var Nm=fe(td=>{Object.defineProperty(td,"__esModule",{value:!0});function Sb(e){var t=Math.random()*e;return Math.round(t)}td.fullJitter=Sb;});var Mm=fe(rd=>{Object.defineProperty(rd,"__esModule",{value:!0});function yb(e){return e}rd.noJitter=yb;});var Qm=fe(ad=>{Object.defineProperty(ad,"__esModule",{value:!0});var vb=Nm(),Cb=Mm();function xb(e){switch(e.jitter){case"full":return vb.fullJitter;case"none":default:return Cb.noJitter}}ad.JitterFactory=xb;});var od=fe(nd=>{Object.defineProperty(nd,"__esModule",{value:!0});var Rb=Qm(),bb=function(){function e(t){this.options=t,this.attempt=0;}return e.prototype.apply=function(){var t=this;return new Promise(function(r){return setTimeout(r,t.jitteredDelay)})},e.prototype.setAttemptNumber=function(t){this.attempt=t;},Object.defineProperty(e.prototype,"jitteredDelay",{get:function(){var t=Rb.JitterFactory(this.options);return t(this.delay)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"delay",{get:function(){var t=this.options.startingDelay,r=this.options.timeMultiple,a=this.numOfDelayedAttempts,n=t*Math.pow(r,a);return Math.min(n,this.options.maxDelay)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt},enumerable:!0,configurable:!0}),e}();nd.Delay=bb;});var Lm=fe(gr=>{var Fb=gr&&gr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,n){a.__proto__=n;}||function(a,n){for(var o in n)n.hasOwnProperty(o)&&(a[o]=n[o]);},e(t,r)};return function(t,r){e(t,r);function a(){this.constructor=t;}t.prototype=r===null?Object.create(r):(a.prototype=r.prototype,new a);}}(),Ab=gr&&gr.__awaiter||function(e,t,r,a){function n(o){return o instanceof r?o:new r(function(i){i(o);})}return new(r||(r=Promise))(function(o,i){function s(l){try{c(a.next(l));}catch(p){i(p);}}function u(l){try{c(a.throw(l));}catch(p){i(p);}}function c(l){l.done?o(l.value):n(l.value).then(s,u);}c((a=a.apply(e,t||[])).next());})},Pb=gr&&gr.__generator||function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a,n,o,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(a)throw new TypeError("Generator is already executing.");for(;r;)try{if(a=1,n&&(o=c[0]&2?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,n=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r);}catch(l){c=[6,l],n=0;}finally{a=o=0;}if(c[0]&5)throw c[1];return {value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(gr,"__esModule",{value:!0});var Ib=od(),Eb=function(e){Fb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.apply=function(){return Ab(this,void 0,void 0,function(){return Pb(this,function(r){return [2,this.isFirstAttempt?!0:e.prototype.apply.call(this)]})})},Object.defineProperty(t.prototype,"isFirstAttempt",{get:function(){return this.attempt===0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt-1},enumerable:!0,configurable:!0}),t}(Ib.Delay);gr.SkipFirstDelay=Eb;});var jm=fe(ui=>{var wb=ui&&ui.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,n){a.__proto__=n;}||function(a,n){for(var o in n)n.hasOwnProperty(o)&&(a[o]=n[o]);},e(t,r)};return function(t,r){e(t,r);function a(){this.constructor=t;}t.prototype=r===null?Object.create(r):(a.prototype=r.prototype,new a);}}();Object.defineProperty(ui,"__esModule",{value:!0});var kb=od(),Ob=function(e){wb(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(kb.Delay);ui.AlwaysDelay=Ob;});var Um=fe(id=>{Object.defineProperty(id,"__esModule",{value:!0});var qb=Lm(),Tb=jm();function Db(e,t){var r=Vb(e);return r.setAttemptNumber(t),r}id.DelayFactory=Db;function Vb(e){return e.delayFirstAttempt?new Tb.AlwaysDelay(e):new qb.SkipFirstDelay(e)}});var Bm=fe(ha=>{var sd=ha&&ha.__awaiter||function(e,t,r,a){function n(o){return o instanceof r?o:new r(function(i){i(o);})}return new(r||(r=Promise))(function(o,i){function s(l){try{c(a.next(l));}catch(p){i(p);}}function u(l){try{c(a.throw(l));}catch(p){i(p);}}function c(l){l.done?o(l.value):n(l.value).then(s,u);}c((a=a.apply(e,t||[])).next());})},cd=ha&&ha.__generator||function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a,n,o,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(a)throw new TypeError("Generator is already executing.");for(;r;)try{if(a=1,n&&(o=c[0]&2?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,n=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r);}catch(l){c=[6,l],n=0;}finally{a=o=0;}if(c[0]&5)throw c[1];return {value:c[0]?c[1]:void 0,done:!0}}};Object.defineProperty(ha,"__esModule",{value:!0});var Nb=Vm(),Mb=Um();function Qb(e,t){return t===void 0&&(t={}),sd(this,void 0,void 0,function(){var r,a;return cd(this,function(n){switch(n.label){case 0:return r=Nb.getSanitizedOptions(t),a=new Lb(e,r),[4,a.execute()];case 1:return [2,n.sent()]}})})}ha.backOff=Qb;var Lb=function(){function e(t,r){this.request=t,this.options=r,this.attemptNumber=0;}return e.prototype.execute=function(){return sd(this,void 0,void 0,function(){var t,r;return cd(this,function(a){switch(a.label){case 0:if(this.attemptLimitReached)return [3,7];a.label=1;case 1:return a.trys.push([1,4,,6]),[4,this.applyDelay()];case 2:return a.sent(),[4,this.request()];case 3:return [2,a.sent()];case 4:return t=a.sent(),this.attemptNumber++,[4,this.options.retry(t,this.attemptNumber)];case 5:if(r=a.sent(),!r||this.attemptLimitReached)throw t;return [3,6];case 6:return [3,0];case 7:throw new Error("Something went wrong.")}})})},Object.defineProperty(e.prototype,"attemptLimitReached",{get:function(){return this.attemptNumber>=this.options.numOfAttempts},enumerable:!0,configurable:!0}),e.prototype.applyDelay=function(){return sd(this,void 0,void 0,function(){var t;return cd(this,function(r){switch(r.label){case 0:return t=Mb.DelayFactory(this.options,this.attemptNumber),[4,t.apply()];case 1:return r.sent(),[2]}})})},e}();});var Zm=fe((jO,dd)=>{var ns=typeof self!="undefined"?self:typeof window!="undefined"?window:void 0;if(!ns)throw new Error("Unable to find global scope. Are you sure this is running in the browser?");if(!ns.AbortController)throw new Error('Could not find "AbortController" in the global scope. You need to polyfill it first');dd.exports=ns.AbortController;dd.exports.default=ns.AbortController;});var ng=fe((bq,ag)=>{function Xb(e){if(arguments.length===0)throw new TypeError("1 argument required, but only 0 present.");if(e=`${e}`,e=e.replace(/[ \t\n\f\r]/g,""),e.length%4==0&&(e=e.replace(/==?$/,"")),e.length%4==1||/[^+/0-9A-Za-z]/.test(e))return null;let t="",r=0,a=0;for(let n=0;n<e.length;n++)r<<=6,r|=eF(e[n]),a+=6,a===24&&(t+=String.fromCharCode((r&16711680)>>16),t+=String.fromCharCode((r&65280)>>8),t+=String.fromCharCode(r&255),r=a=0);return a===12?(r>>=4,t+=String.fromCharCode(r)):a===18&&(r>>=2,t+=String.fromCharCode((r&65280)>>8),t+=String.fromCharCode(r&255)),t}var Zb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function eF(e){let t=Zb.indexOf(e);return t<0?void 0:t}ag.exports=Xb;});var ig=fe((Fq,og)=>{function tF(e){if(arguments.length===0)throw new TypeError("1 argument required, but only 0 present.");let t;for(e=`${e}`,t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return null;let r="";for(t=0;t<e.length;t+=3){let a=[void 0,void 0,void 0,void 0];a[0]=e.charCodeAt(t)>>2,a[1]=(e.charCodeAt(t)&3)<<4,e.length>t+1&&(a[1]|=e.charCodeAt(t+1)>>4,a[2]=(e.charCodeAt(t+1)&15)<<2),e.length>t+2&&(a[2]|=e.charCodeAt(t+2)>>6,a[3]=e.charCodeAt(t+2)&63);for(let n=0;n<a.length;n++)typeof a[n]=="undefined"?r+="=":r+=aF(a[n]);}return r}var rF="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function aF(e){if(e>=0&&e<64)return rF[e]}og.exports=tF;});var md=fe((Aq,sg)=>{var nF=ng(),oF=ig();sg.exports={atob:nF,btoa:oF};});var bs=fe((Fd,Ad)=>{(function(e,t){typeof Fd=="object"&&typeof Ad!="undefined"?Ad.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis!="undefined"?globalThis:e||self).dayjs=t();})(Fd,function(){var e=1e3,t=6e4,r=36e5,a="millisecond",n="second",o="minute",i="hour",s="day",u="week",c="month",l="quarter",p="year",f="date",d="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},C=function(N,A,V){var j=String(N);return !j||j.length>=A?N:""+Array(A+1-j.length).join(V)+N},x={s:C,z:function(N){var A=-N.utcOffset(),V=Math.abs(A),j=Math.floor(V/60),w=V%60;return (A<=0?"+":"-")+C(j,2,"0")+":"+C(w,2,"0")},m:function N(A,V){if(A.date()<V.date())return -N(V,A);var j=12*(V.year()-A.year())+(V.month()-A.month()),w=A.clone().add(j,c),z=V-w<0,Y=A.clone().add(j+(z?-1:1),c);return +(-(j+(V-w)/(z?w-Y:Y-w))||0)},a:function(N){return N<0?Math.ceil(N)||0:Math.floor(N)},p:function(N){return {M:c,y:p,w:u,d:s,D:f,h:i,m:o,s:n,ms:a,Q:l}[N]||String(N||"").toLowerCase().replace(/s$/,"")},u:function(N){return N===void 0}},b="en",P={};P[b]=v;var _=function(N){return N instanceof $},X=function N(A,V,j){var w;if(!A)return b;if(typeof A=="string"){var z=A.toLowerCase();P[z]&&(w=z),V&&(P[z]=V,w=z);var Y=A.split("-");if(!w&&Y.length>1)return N(Y[0])}else {var ae=A.name;P[ae]=A,w=ae;}return !j&&w&&(b=w),w||!j&&b},H=function(N,A){if(_(N))return N.clone();var V=typeof A=="object"?A:{};return V.date=N,V.args=arguments,new $(V)},I=x;I.l=X,I.i=_,I.w=function(N,A){return H(N,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var $=function(){function N(V){this.$L=X(V.locale,null,!0),this.parse(V);}var A=N.prototype;return A.parse=function(V){this.$d=function(j){var w=j.date,z=j.utc;if(w===null)return new Date(NaN);if(I.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var Y=w.match(m);if(Y){var ae=Y[2]-1||0,le=(Y[7]||"0").substring(0,3);return z?new Date(Date.UTC(Y[1],ae,Y[3]||1,Y[4]||0,Y[5]||0,Y[6]||0,le)):new Date(Y[1],ae,Y[3]||1,Y[4]||0,Y[5]||0,Y[6]||0,le)}}return new Date(w)}(V),this.$x=V.x||{},this.init();},A.init=function(){var V=this.$d;this.$y=V.getFullYear(),this.$M=V.getMonth(),this.$D=V.getDate(),this.$W=V.getDay(),this.$H=V.getHours(),this.$m=V.getMinutes(),this.$s=V.getSeconds(),this.$ms=V.getMilliseconds();},A.$utils=function(){return I},A.isValid=function(){return this.$d.toString()!==d},A.isSame=function(V,j){var w=H(V);return this.startOf(j)<=w&&w<=this.endOf(j)},A.isAfter=function(V,j){return H(V)<this.startOf(j)},A.isBefore=function(V,j){return this.endOf(j)<H(V)},A.$g=function(V,j,w){return I.u(V)?this[j]:this.set(w,V)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(V,j){var w=this,z=!!I.u(j)||j,Y=I.p(V),ae=function(kt,Ie){var tt=I.w(w.$u?Date.UTC(w.$y,Ie,kt):new Date(w.$y,Ie,kt),w);return z?tt:tt.endOf(s)},le=function(kt,Ie){return I.w(w.toDate()[kt].apply(w.toDate("s"),(z?[0,0,0,0]:[23,59,59,999]).slice(Ie)),w)},Se=this.$W,Pe=this.$M,wt=this.$D,ht="set"+(this.$u?"UTC":"");switch(Y){case p:return z?ae(1,0):ae(31,11);case c:return z?ae(1,Pe):ae(0,Pe+1);case u:var la=this.$locale().weekStart||0,Ar=(Se<la?Se+7:Se)-la;return ae(z?wt-Ar:wt+(6-Ar),Pe);case s:case f:return le(ht+"Hours",0);case i:return le(ht+"Minutes",1);case o:return le(ht+"Seconds",2);case n:return le(ht+"Milliseconds",3);default:return this.clone()}},A.endOf=function(V){return this.startOf(V,!1)},A.$set=function(V,j){var w,z=I.p(V),Y="set"+(this.$u?"UTC":""),ae=(w={},w[s]=Y+"Date",w[f]=Y+"Date",w[c]=Y+"Month",w[p]=Y+"FullYear",w[i]=Y+"Hours",w[o]=Y+"Minutes",w[n]=Y+"Seconds",w[a]=Y+"Milliseconds",w)[z],le=z===s?this.$D+(j-this.$W):j;if(z===c||z===p){var Se=this.clone().set(f,1);Se.$d[ae](le),Se.init(),this.$d=Se.set(f,Math.min(this.$D,Se.daysInMonth())).$d;}else ae&&this.$d[ae](le);return this.init(),this},A.set=function(V,j){return this.clone().$set(V,j)},A.get=function(V){return this[I.p(V)]()},A.add=function(V,j){var w,z=this;V=Number(V);var Y=I.p(j),ae=function(Pe){var wt=H(z);return I.w(wt.date(wt.date()+Math.round(Pe*V)),z)};if(Y===c)return this.set(c,this.$M+V);if(Y===p)return this.set(p,this.$y+V);if(Y===s)return ae(1);if(Y===u)return ae(7);var le=(w={},w[o]=t,w[i]=r,w[n]=e,w)[Y]||1,Se=this.$d.getTime()+V*le;return I.w(Se,this)},A.subtract=function(V,j){return this.add(-1*V,j)},A.format=function(V){var j=this,w=this.$locale();if(!this.isValid())return w.invalidDate||d;var z=V||"YYYY-MM-DDTHH:mm:ssZ",Y=I.z(this),ae=this.$H,le=this.$m,Se=this.$M,Pe=w.weekdays,wt=w.months,ht=function(Ie,tt,Pr,Ir){return Ie&&(Ie[tt]||Ie(j,z))||Pr[tt].slice(0,Ir)},la=function(Ie){return I.s(ae%12||12,Ie,"0")},Ar=w.meridiem||function(Ie,tt,Pr){var Ir=Ie<12?"AM":"PM";return Pr?Ir.toLowerCase():Ir},kt={YY:String(this.$y).slice(-2),YYYY:this.$y,M:Se+1,MM:I.s(Se+1,2,"0"),MMM:ht(w.monthsShort,Se,wt,3),MMMM:ht(wt,Se),D:this.$D,DD:I.s(this.$D,2,"0"),d:String(this.$W),dd:ht(w.weekdaysMin,this.$W,Pe,2),ddd:ht(w.weekdaysShort,this.$W,Pe,3),dddd:Pe[this.$W],H:String(ae),HH:I.s(ae,2,"0"),h:la(1),hh:la(2),a:Ar(ae,le,!0),A:Ar(ae,le,!1),m:String(le),mm:I.s(le,2,"0"),s:String(this.$s),ss:I.s(this.$s,2,"0"),SSS:I.s(this.$ms,3,"0"),Z:Y};return z.replace(h,function(Ie,tt){return tt||kt[Ie]||Y.replace(":","")})},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(V,j,w){var z,Y=I.p(j),ae=H(V),le=(ae.utcOffset()-this.utcOffset())*t,Se=this-ae,Pe=I.m(this,ae);return Pe=(z={},z[p]=Pe/12,z[c]=Pe,z[l]=Pe/3,z[u]=(Se-le)/6048e5,z[s]=(Se-le)/864e5,z[i]=Se/r,z[o]=Se/t,z[n]=Se/e,z)[Y]||Se,w?Pe:I.a(Pe)},A.daysInMonth=function(){return this.endOf(c).$D},A.$locale=function(){return P[this.$L]},A.locale=function(V,j){if(!V)return this.$L;var w=this.clone(),z=X(V,j,!0);return z&&(w.$L=z),w},A.clone=function(){return I.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},N}(),ne=$.prototype;return H.prototype=ne,[["$ms",a],["$s",n],["$m",o],["$H",i],["$W",s],["$M",c],["$y",p],["$D",f]].forEach(function(N){ne[N[1]]=function(A){return this.$g(A,N[0],N[1])};}),H.extend=function(N,A){return N.$i||(N(A,$,H),N.$i=!0),H},H.locale=X,H.isDayjs=_,H.unix=function(N){return H(1e3*N)},H.en=P[b],H.Ls=P,H.p={},H});});var Ig=fe((Pd,Id)=>{(function(e,t){typeof Pd=="object"&&typeof Id!="undefined"?Id.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis!="undefined"?globalThis:e||self).dayjs_plugin_quarterOfYear=t();})(Pd,function(){var e="month",t="quarter";return function(r,a){var n=a.prototype;n.quarter=function(s){return this.$utils().u(s)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(s-1))};var o=n.add;n.add=function(s,u){return s=Number(s),this.$utils().p(u)===t?this.add(3*s,e):o.bind(this)(s,u)};var i=n.startOf;n.startOf=function(s,u){var c=this.$utils(),l=!!c.u(u)||u;if(c.p(s)===t){var p=this.quarter()-1;return l?this.month(3*p).startOf(e).startOf("day"):this.month(3*p+2).endOf(e).endOf("day")}return i.bind(this)(s,u)};}});});var Eg=fe((Ed,wd)=>{(function(e,t){typeof Ed=="object"&&typeof wd!="undefined"?wd.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis!="undefined"?globalThis:e||self).dayjs_plugin_customParseFormat=t();})(Ed,function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,r=/\d\d/,a=/\d\d?/,n=/\d*[^-_:/,()\s\d]+/,o={},i=function(d){return (d=+d)+(d>68?1900:2e3)},s=function(d){return function(m){this[d]=+m;}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(d){(this.zone||(this.zone={})).offset=function(m){if(!m||m==="Z")return 0;var h=m.match(/([+-]|\d\d)/g),v=60*h[1]+(+h[2]||0);return v===0?0:h[0]==="+"?-v:v}(d);}],c=function(d){var m=o[d];return m&&(m.indexOf?m:m.s.concat(m.f))},l=function(d,m){var h,v=o.meridiem;if(v){for(var C=1;C<=24;C+=1)if(d.indexOf(v(C,0,m))>-1){h=C>12;break}}else h=d===(m?"pm":"PM");return h},p={A:[n,function(d){this.afternoon=l(d,!1);}],a:[n,function(d){this.afternoon=l(d,!0);}],S:[/\d/,function(d){this.milliseconds=100*+d;}],SS:[r,function(d){this.milliseconds=10*+d;}],SSS:[/\d{3}/,function(d){this.milliseconds=+d;}],s:[a,s("seconds")],ss:[a,s("seconds")],m:[a,s("minutes")],mm:[a,s("minutes")],H:[a,s("hours")],h:[a,s("hours")],HH:[a,s("hours")],hh:[a,s("hours")],D:[a,s("day")],DD:[r,s("day")],Do:[n,function(d){var m=o.ordinal,h=d.match(/\d+/);if(this.day=h[0],m)for(var v=1;v<=31;v+=1)m(v).replace(/\[|\]/g,"")===d&&(this.day=v);}],M:[a,s("month")],MM:[r,s("month")],MMM:[n,function(d){var m=c("months"),h=(c("monthsShort")||m.map(function(v){return v.slice(0,3)})).indexOf(d)+1;if(h<1)throw new Error;this.month=h%12||h;}],MMMM:[n,function(d){var m=c("months").indexOf(d)+1;if(m<1)throw new Error;this.month=m%12||m;}],Y:[/[+-]?\d+/,s("year")],YY:[r,function(d){this.year=i(d);}],YYYY:[/\d{4}/,s("year")],Z:u,ZZ:u};function f(d){var m,h;m=d,h=o&&o.formats;for(var v=(d=m.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(H,I,$){var ne=$&&$.toUpperCase();return I||h[$]||e[$]||h[ne].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(N,A,V){return A||V.slice(1)})})).match(t),C=v.length,x=0;x<C;x+=1){var b=v[x],P=p[b],_=P&&P[0],X=P&&P[1];v[x]=X?{regex:_,parser:X}:b.replace(/^\[|\]$/g,"");}return function(H){for(var I={},$=0,ne=0;$<C;$+=1){var N=v[$];if(typeof N=="string")ne+=N.length;else {var A=N.regex,V=N.parser,j=H.slice(ne),w=A.exec(j)[0];V.call(I,w),H=H.replace(w,"");}}return function(z){var Y=z.afternoon;if(Y!==void 0){var ae=z.hours;Y?ae<12&&(z.hours+=12):ae===12&&(z.hours=0),delete z.afternoon;}}(I),I}}return function(d,m,h){h.p.customParseFormat=!0,d&&d.parseTwoDigitYear&&(i=d.parseTwoDigitYear);var v=m.prototype,C=v.parse;v.parse=function(x){var b=x.date,P=x.utc,_=x.args;this.$u=P;var X=_[1];if(typeof X=="string"){var H=_[2]===!0,I=_[3]===!0,$=H||I,ne=_[2];I&&(ne=_[2]),o=this.$locale(),!H&&ne&&(o=h.Ls[ne]),this.$d=function(j,w,z){try{if(["x","X"].indexOf(w)>-1)return new Date((w==="X"?1e3:1)*j);var Y=f(w)(j),ae=Y.year,le=Y.month,Se=Y.day,Pe=Y.hours,wt=Y.minutes,ht=Y.seconds,la=Y.milliseconds,Ar=Y.zone,kt=new Date,Ie=Se||(ae||le?1:kt.getDate()),tt=ae||kt.getFullYear(),Pr=0;ae&&!le||(Pr=le>0?le-1:kt.getMonth());var Ir=Pe||0,tl=wt||0,rl=ht||0,al=la||0;return Ar?new Date(Date.UTC(tt,Pr,Ie,Ir,tl,rl,al+60*Ar.offset*1e3)):z?new Date(Date.UTC(tt,Pr,Ie,Ir,tl,rl,al)):new Date(tt,Pr,Ie,Ir,tl,rl,al)}catch{return new Date("")}}(b,X,P),this.init(),ne&&ne!==!0&&(this.$L=this.locale(ne).$L),$&&b!=this.format(X)&&(this.$d=new Date("")),o={};}else if(X instanceof Array)for(var N=X.length,A=1;A<=N;A+=1){_[1]=X[A-1];var V=h.apply(this,_);if(V.isValid()){this.$d=V.$d,this.$L=V.$L,this.init();break}A===N&&(this.$d=new Date(""));}else C.call(this,x);};}});});var $g=fe((qd,Td)=>{(function(e,t){typeof qd=="object"&&typeof Td!="undefined"?Td.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis!="undefined"?globalThis:e||self).dayjs_plugin_timezone=t();})(qd,function(){var e={year:0,month:1,day:2,hour:3,minute:4,second:5},t={};return function(r,a,n){var o,i=function(l,p,f){f===void 0&&(f={});var d=new Date(l),m=function(h,v){v===void 0&&(v={});var C=v.timeZoneName||"short",x=h+"|"+C,b=t[x];return b||(b=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:h,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:C}),t[x]=b),b}(p,f);return m.formatToParts(d)},s=function(l,p){for(var f=i(l,p),d=[],m=0;m<f.length;m+=1){var h=f[m],v=h.type,C=h.value,x=e[v];x>=0&&(d[x]=parseInt(C,10));}var b=d[3],P=b===24?0:b,_=d[0]+"-"+d[1]+"-"+d[2]+" "+P+":"+d[4]+":"+d[5]+":000",X=+l;return (n.utc(_).valueOf()-(X-=X%1e3))/6e4},u=a.prototype;u.tz=function(l,p){l===void 0&&(l=o);var f=this.utcOffset(),d=this.toDate(),m=d.toLocaleString("en-US",{timeZone:l}),h=Math.round((d-new Date(m))/1e3/60),v=n(m).$set("millisecond",this.$ms).utcOffset(15*-Math.round(d.getTimezoneOffset()/15)-h,!0);if(p){var C=v.utcOffset();v=v.add(f-C,"minute");}return v.$x.$timezone=l,v},u.offsetName=function(l){var p=this.$x.$timezone||n.tz.guess(),f=i(this.valueOf(),p,{timeZoneName:l}).find(function(d){return d.type.toLowerCase()==="timezonename"});return f&&f.value};var c=u.startOf;u.startOf=function(l,p){if(!this.$x||!this.$x.$timezone)return c.call(this,l,p);var f=n(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return c.call(f,l,p).tz(this.$x.$timezone,!0)},n.tz=function(l,p,f){var d=f&&p,m=f||p||o,h=s(+n(),m);if(typeof l!="string")return n(l).tz(m);var v=function(P,_,X){var H=P-60*_*1e3,I=s(H,X);if(_===I)return [H,_];var $=s(H-=60*(I-_)*1e3,X);return I===$?[H,I]:[P-60*Math.min(I,$)*1e3,Math.max(I,$)]}(n.utc(l,d).valueOf(),h,m),C=v[0],x=v[1],b=n(C).utcOffset(x);return b.$x.$timezone=m,b},n.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},n.tz.setDefault=function(l){o=l;};}});});var Hg=fe((Dd,Vd)=>{(function(e,t){typeof Dd=="object"&&typeof Vd!="undefined"?Vd.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis!="undefined"?globalThis:e||self).dayjs_plugin_utc=t();})(Dd,function(){var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(a,n,o){var i=n.prototype;o.utc=function(d){var m={date:d,utc:!0,args:arguments};return new n(m)},i.utc=function(d){var m=o(this.toDate(),{locale:this.$L,utc:!0});return d?m.add(this.utcOffset(),e):m},i.local=function(){return o(this.toDate(),{locale:this.$L,utc:!1})};var s=i.parse;i.parse=function(d){d.utc&&(this.$u=!0),this.$utils().u(d.$offset)||(this.$offset=d.$offset),s.call(this,d);};var u=i.init;i.init=function(){if(this.$u){var d=this.$d;this.$y=d.getUTCFullYear(),this.$M=d.getUTCMonth(),this.$D=d.getUTCDate(),this.$W=d.getUTCDay(),this.$H=d.getUTCHours(),this.$m=d.getUTCMinutes(),this.$s=d.getUTCSeconds(),this.$ms=d.getUTCMilliseconds();}else u.call(this);};var c=i.utcOffset;i.utcOffset=function(d,m){var h=this.$utils().u;if(h(d))return this.$u?0:h(this.$offset)?c.call(this):this.$offset;if(typeof d=="string"&&(d=function(b){b===void 0&&(b="");var P=b.match(t);if(!P)return null;var _=(""+P[0]).match(r)||["-",0,0],X=_[0],H=60*+_[1]+ +_[2];return H===0?0:X==="+"?H:-H}(d),d===null))return this;var v=Math.abs(d)<=16?60*d:d,C=this;if(m)return C.$offset=v,C.$u=d===0,C;if(d!==0){var x=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(C=this.local().add(v+x,e)).$offset=v,C.$x.$localOffset=x;}else C=this.utc();return C};var l=i.format;i.format=function(d){var m=d||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,m)},i.valueOf=function(){var d=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*d},i.isUTC=function(){return !!this.$u},i.toISOString=function(){return this.toDate().toISOString()},i.toString=function(){return this.toDate().toUTCString()};var p=i.toDate;i.toDate=function(d){return d==="s"&&this.$offset?o(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():p.call(this)};var f=i.diff;i.diff=function(d,m,h){if(d&&this.$u===d.$u)return f.call(this,d,m,h);var v=this.local(),C=o(d).local();return f.call(v,C,m,h)};}});});var ES=fe((Vc,IS)=>{(function(e,t){typeof Vc=="object"&&typeof IS!="undefined"?t(Vc):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["fast-equals"]={}));})(Vc,function(e){var t=typeof WeakSet=="function",r=Object.keys;function a(I,$){return I===$||I!==I&&$!==$}function n(I){return I.constructor===Object||I.constructor==null}function o(I){return !!I&&typeof I.then=="function"}function i(I){return !!(I&&I.$$typeof)}function s(){var I=[];return {add:function($){I.push($);},has:function($){return I.indexOf($)!==-1}}}var u=function(I){return I?function(){return new WeakSet}:s}(t);function c(I){return function(ne){var N=I||ne;return function(V,j,w){w===void 0&&(w=u());var z=!!V&&typeof V=="object",Y=!!j&&typeof j=="object";if(z||Y){var ae=z&&w.has(V),le=Y&&w.has(j);if(ae||le)return ae&≤z&&w.add(V),Y&&w.add(j);}return N(V,j,w)}}}function l(I,$,ne,N){var A=I.length;if($.length!==A)return !1;for(;A-- >0;)if(!ne(I[A],$[A],N))return !1;return !0}function p(I,$,ne,N){var A=I.size===$.size;if(A&&I.size){var V={};I.forEach(function(j,w){if(A){var z=!1,Y=0;$.forEach(function(ae,le){!z&&!V[Y]&&(z=ne(w,le,N)&&ne(j,ae,N),z&&(V[Y]=!0)),Y++;}),A=z;}});}return A}var f="_owner",d=Function.prototype.bind.call(Function.prototype.call,Object.prototype.hasOwnProperty);function m(I,$,ne,N){var A=r(I),V=A.length;if(r($).length!==V)return !1;if(V)for(var j=void 0;V-- >0;){if(j=A[V],j===f){var w=i(I),z=i($);if((w||z)&&w!==z)return !1}if(!d($,j)||!ne(I[j],$[j],N))return !1}return !0}function h(I,$){return I.source===$.source&&I.global===$.global&&I.ignoreCase===$.ignoreCase&&I.multiline===$.multiline&&I.unicode===$.unicode&&I.sticky===$.sticky&&I.lastIndex===$.lastIndex}function v(I,$,ne,N){var A=I.size===$.size;if(A&&I.size){var V={};I.forEach(function(j){if(A){var w=!1,z=0;$.forEach(function(Y){!w&&!V[z]&&(w=ne(j,Y,N),w&&(V[z]=!0)),z++;}),A=w;}});}return A}var C=typeof Map=="function",x=typeof Set=="function";function b(I){var $=typeof I=="function"?I(ne):ne;function ne(N,A,V){if(N===A)return !0;if(N&&A&&typeof N=="object"&&typeof A=="object"){if(n(N)&&n(A))return m(N,A,$,V);var j=Array.isArray(N),w=Array.isArray(A);return j||w?j===w&&l(N,A,$,V):(j=N instanceof Date,w=A instanceof Date,j||w?j===w&&a(N.getTime(),A.getTime()):(j=N instanceof RegExp,w=A instanceof RegExp,j||w?j===w&&h(N,A):o(N)||o(A)?N===A:C&&(j=N instanceof Map,w=A instanceof Map,j||w)?j===w&&p(N,A,$,V):x&&(j=N instanceof Set,w=A instanceof Set,j||w)?j===w&&v(N,A,$,V):m(N,A,$,V)))}return N!==N&&A!==A}return ne}var P=b(),_=b(function(){return a}),X=b(c()),H=b(c(a));e.circularDeepEqual=X,e.circularShallowEqual=H,e.createCustomEqual=b,e.deepEqual=P,e.sameValueZeroEqual=a,e.shallowEqual=_,Object.defineProperty(e,"__esModule",{value:!0});});});var mh={};nl(mh,{buildMockCaseAssistEngine:()=>dh,buildMockProductListingEngine:()=>lh,buildMockProductRecommendationsAppEngine:()=>uh,buildMockRaw:()=>Js,buildMockRecommendationAppEngine:()=>ch,buildMockResult:()=>fh,buildMockSearchAppEngine:()=>sh,createMockState:()=>Gs});var g={};nl(g,{MiddlewareArray:()=>of,TaskAbortError:()=>Xo,addListener:()=>qf,clearAllListeners:()=>Tf,configureStore:()=>Al,createAction:()=>S,createAsyncThunk:()=>te,createDraftSafeSelector:()=>fr,createEntityAdapter:()=>YC,createImmutableStateInvariantMiddleware:()=>TC,createListenerMiddleware:()=>dx,createNextState:()=>kr,createReducer:()=>k,createSelector:()=>Ui,createSerializableStateInvariantMiddleware:()=>DC,createSlice:()=>BC,current:()=>Qo,findNonSerializableValue:()=>_i,freeze:()=>Mo,getDefaultMiddleware:()=>$i,getType:()=>LC,isAllOf:()=>El,isAnyOf:()=>Go,isAsyncThunkAction:()=>Rf,isDraft:()=>Me,isFulfilled:()=>xf,isImmutableDefault:()=>uf,isPending:()=>vf,isPlain:()=>bl,isPlainObject:()=>Bi,isRejected:()=>zi,isRejectedWithValue:()=>Cf,miniSerializeError:()=>hf,nanoid:()=>Pl,original:()=>qp,removeListener:()=>Df,unwrapResult:()=>Sf});function Ge(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];throw Error("[Immer] minified error nr: "+e+(r.length?" "+r.map(function(i){return "'"+i+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Me(e){return !!e&&!!e[he]}function St(e){return !!e&&(function(t){if(!t||typeof t!="object")return !1;var r=Object.getPrototypeOf(t);if(r===null)return !0;var a=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return a===Object||typeof a=="function"&&Function.toString.call(a)===aC}(e)||Array.isArray(e)||!!e[_p]||!!e.constructor[_p]||ol(e)||il(e))}function qp(e){return Me(e)||Ge(23,e),e[he].t}function da(e,t,r){r===void 0&&(r=!1),La(e)===0?(r?Object.keys:Ua)(e).forEach(function(a){r&&typeof a=="symbol"||t(a,e[a],e);}):e.forEach(function(a,n){return t(n,a,e)});}function La(e){var t=e[he];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:ol(e)?2:il(e)?3:0}function ja(e,t){return La(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Jv(e,t){return La(e)===2?e.get(t):e[t]}function Tp(e,t,r){var a=La(e);a===2?e.set(t,r):a===3?(e.delete(t),e.add(r)):e[t]=r;}function Dp(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function ol(e){return tC&&e instanceof Map}function il(e){return rC&&e instanceof Set}function Er(e){return e.o||e.t}function sl(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=$p(e);delete t[he];for(var r=Ua(t),a=0;a<r.length;a++){var n=r[a],o=t[n];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[n]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[n]});}return Object.create(Object.getPrototypeOf(e),t)}function Mo(e,t){return t===void 0&&(t=!1),cl(e)||Me(e)||!St(e)||(La(e)>1&&(e.set=e.add=e.clear=e.delete=Xv),Object.freeze(e),t&&da(e,function(r,a){return Mo(a,!0)},!0)),e}function Xv(){Ge(2);}function cl(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function Ot(e){var t=Sl[e];return t||Ge(18,e),t}function Zv(e,t){Sl[e]||(Sl[e]=t);}function ul(){return Lo}function ll(e,t){t&&(Ot("Patches"),e.u=[],e.s=[],e.v=t);}function Mi(e){dl(e),e.p.forEach(eC),e.p=null;}function dl(e){e===Lo&&(Lo=e.l);}function Vp(e){return Lo={p:[],l:Lo,h:e,m:!0,_:0}}function eC(e){var t=e[he];t.i===0||t.i===1?t.j():t.O=!0;}function pl(e,t){t._=t.p.length;var r=t.p[0],a=e!==void 0&&e!==r;return t.h.g||Ot("ES5").S(t,e,a),a?(r[he].P&&(Mi(t),Ge(4)),St(e)&&(e=Qi(t,e),t.l||Li(t,e)),t.u&&Ot("Patches").M(r[he].t,e,t.u,t.s)):e=Qi(t,r,[]),Mi(t),t.u&&t.v(t.u,t.s),e!==Bp?e:void 0}function Qi(e,t,r){if(cl(t))return t;var a=t[he];if(!a)return da(t,function(o,i){return Np(e,a,t,o,i,r)},!0),t;if(a.A!==e)return t;if(!a.P)return Li(e,a.t,!0),a.t;if(!a.I){a.I=!0,a.A._--;var n=a.i===4||a.i===5?a.o=sl(a.k):a.o;da(a.i===3?new Set(n):n,function(o,i){return Np(e,a,n,o,i,r)}),Li(e,n,!1),r&&e.u&&Ot("Patches").R(a,r,e.u,e.s);}return a.o}function Np(e,t,r,a,n,o){if(Me(n)){var i=Qi(e,n,o&&t&&t.i!==3&&!ja(t.D,a)?o.concat(a):void 0);if(Tp(r,a,i),!Me(i))return;e.m=!1;}if(St(n)&&!cl(n)){if(!e.h.F&&e._<1)return;Qi(e,n),t&&t.A.l||Li(e,n);}}function Li(e,t,r){r===void 0&&(r=!1),e.h.F&&e.m&&Mo(t,r);}function fl(e,t){var r=e[he];return (r?Er(r):e)[t]}function Mp(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var a=Object.getOwnPropertyDescriptor(r,t);if(a)return a;r=Object.getPrototypeOf(r);}}function wr(e){e.P||(e.P=!0,e.l&&wr(e.l));}function ml(e){e.o||(e.o=sl(e.t));}function gl(e,t,r){var a=ol(t)?Ot("MapSet").N(t,r):il(t)?Ot("MapSet").T(t,r):e.g?function(n,o){var i=Array.isArray(n),s={i:i?1:0,A:o?o.A:ul(),P:!1,I:!1,D:{},l:o,t:n,k:null,o:null,j:null,C:!1},u=s,c=jo;i&&(u=[s],c=Uo);var l=Proxy.revocable(u,c),p=l.revoke,f=l.proxy;return s.k=f,s.j=p,f}(t,r):Ot("ES5").J(t,r);return (r?r.A:ul()).p.push(a),a}function Qo(e){return Me(e)||Ge(22,e),function t(r){if(!St(r))return r;var a,n=r[he],o=La(r);if(n){if(!n.P&&(n.i<4||!Ot("ES5").K(n)))return n.t;n.I=!0,a=Qp(r,o),n.I=!1;}else a=Qp(r,o);return da(a,function(i,s){n&&Jv(n.t,i)===s||Tp(a,i,t(s));}),o===3?new Set(a):a}(e)}function Qp(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return sl(e)}function Lp(){function e(i,s){var u=o[i];return u?u.enumerable=s:o[i]=u={configurable:!0,enumerable:s,get:function(){var c=this[he];return jo.get(c,i)},set:function(c){var l=this[he];jo.set(l,i,c);}},u}function t(i){for(var s=i.length-1;s>=0;s--){var u=i[s][he];if(!u.P)switch(u.i){case 5:a(u)&&wr(u);break;case 4:r(u)&&wr(u);}}}function r(i){for(var s=i.t,u=i.k,c=Ua(u),l=c.length-1;l>=0;l--){var p=c[l];if(p!==he){var f=s[p];if(f===void 0&&!ja(s,p))return !0;var d=u[p],m=d&&d[he];if(m?m.t!==f:!Dp(d,f))return !0}}var h=!!s[he];return c.length!==Ua(s).length+(h?0:1)}function a(i){var s=i.k;if(s.length!==i.t.length)return !0;var u=Object.getOwnPropertyDescriptor(s,s.length-1);if(u&&!u.get)return !0;for(var c=0;c<s.length;c++)if(!s.hasOwnProperty(c))return !0;return !1}var o={};Zv("ES5",{J:function(i,s){var u=Array.isArray(i),c=function(p,f){if(p){for(var d=Array(f.length),m=0;m<f.length;m++)Object.defineProperty(d,""+m,e(m,!0));return d}var h=$p(f);delete h[he];for(var v=Ua(h),C=0;C<v.length;C++){var x=v[C];h[x]=e(x,p||!!h[x].enumerable);}return Object.create(Object.getPrototypeOf(f),h)}(u,i),l={i:u?5:4,A:s?s.A:ul(),P:!1,I:!1,D:{},l:s,t:i,k:c,o:null,O:!1,C:!1};return Object.defineProperty(c,he,{value:l,writable:!0}),c},S:function(i,s,u){u?Me(s)&&s[he].A===i&&t(i.p):(i.u&&function c(l){if(l&&typeof l=="object"){var p=l[he];if(p){var f=p.t,d=p.k,m=p.D,h=p.i;if(h===4)da(d,function(P){P!==he&&(f[P]!==void 0||ja(f,P)?m[P]||c(d[P]):(m[P]=!0,wr(p)));}),da(f,function(P){d[P]!==void 0||ja(d,P)||(m[P]=!1,wr(p));});else if(h===5){if(a(p)&&(wr(p),m.length=!0),d.length<f.length)for(var v=d.length;v<f.length;v++)m[v]=!1;else for(var C=f.length;C<d.length;C++)m[C]=!0;for(var x=Math.min(d.length,f.length),b=0;b<x;b++)d.hasOwnProperty(b)||(m[b]=!0),m[b]===void 0&&c(d[b]);}}}}(i.p[0]),t(i.p));},K:function(i){return i.i===4?r(i):a(i)}});}var jp,Lo,hl=typeof Symbol!="undefined"&&typeof Symbol("x")=="symbol",tC=typeof Map!="undefined",rC=typeof Set!="undefined",Up=typeof Proxy!="undefined"&&Proxy.revocable!==void 0&&typeof Reflect!="undefined",Bp=hl?Symbol.for("immer-nothing"):((jp={})["immer-nothing"]=!0,jp),_p=hl?Symbol.for("immer-draftable"):"__$immer_draftable",he=hl?Symbol.for("immer-state"):"__$immer_state";var aC=""+Object.prototype.constructor,Ua=typeof Reflect!="undefined"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,$p=Object.getOwnPropertyDescriptors||function(e){var t={};return Ua(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r);}),t},Sl={},jo={get:function(e,t){if(t===he)return e;var r=Er(e);if(!ja(r,t))return function(n,o,i){var s,u=Mp(o,i);return u?"value"in u?u.value:(s=u.get)===null||s===void 0?void 0:s.call(n.k):void 0}(e,r,t);var a=r[t];return e.I||!St(a)?a:a===fl(e.t,t)?(ml(e),e.o[t]=gl(e.A.h,a,e)):a},has:function(e,t){return t in Er(e)},ownKeys:function(e){return Reflect.ownKeys(Er(e))},set:function(e,t,r){var a=Mp(Er(e),t);if(a==null?void 0:a.set)return a.set.call(e.k,r),!0;if(!e.P){var n=fl(Er(e),t),o=n==null?void 0:n[he];if(o&&o.t===r)return e.o[t]=r,e.D[t]=!1,!0;if(Dp(r,n)&&(r!==void 0||ja(e.t,t)))return !0;ml(e),wr(e);}return e.o[t]===r&&typeof r!="number"&&(r!==void 0||t in e.o)||(e.o[t]=r,e.D[t]=!0,!0)},deleteProperty:function(e,t){return fl(e.t,t)!==void 0||t in e.t?(e.D[t]=!1,ml(e),wr(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=Er(e),a=Reflect.getOwnPropertyDescriptor(r,t);return a&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:a.enumerable,value:r[t]}},defineProperty:function(){Ge(11);},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){Ge(12);}},Uo={};da(jo,function(e,t){Uo[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)};}),Uo.deleteProperty=function(e,t){return Uo.set.call(this,e,t,void 0)},Uo.set=function(e,t,r){return jo.set.call(this,e[0],t,r,e[0])};var nC=function(){function e(r){var a=this;this.g=Up,this.F=!0,this.produce=function(n,o,i){if(typeof n=="function"&&typeof o!="function"){var s=o;o=n;var u=a;return function(h){var v=this;h===void 0&&(h=s);for(var C=arguments.length,x=Array(C>1?C-1:0),b=1;b<C;b++)x[b-1]=arguments[b];return u.produce(h,function(P){var _;return (_=o).call.apply(_,[v,P].concat(x))})}}var c;if(typeof o!="function"&&Ge(6),i!==void 0&&typeof i!="function"&&Ge(7),St(n)){var l=Vp(a),p=gl(a,n,void 0),f=!0;try{c=o(p),f=!1;}finally{f?Mi(l):dl(l);}return typeof Promise!="undefined"&&c instanceof Promise?c.then(function(h){return ll(l,i),pl(h,l)},function(h){throw Mi(l),h}):(ll(l,i),pl(c,l))}if(!n||typeof n!="object"){if((c=o(n))===void 0&&(c=n),c===Bp&&(c=void 0),a.F&&Mo(c,!0),i){var d=[],m=[];Ot("Patches").M(n,c,d,m),i(d,m);}return c}Ge(21,n);},this.produceWithPatches=function(n,o){if(typeof n=="function")return function(c){for(var l=arguments.length,p=Array(l>1?l-1:0),f=1;f<l;f++)p[f-1]=arguments[f];return a.produceWithPatches(c,function(d){return n.apply(void 0,[d].concat(p))})};var i,s,u=a.produce(n,o,function(c,l){i=c,s=l;});return typeof Promise!="undefined"&&u instanceof Promise?u.then(function(c){return [c,i,s]}):[u,i,s]},typeof(r==null?void 0:r.useProxies)=="boolean"&&this.setUseProxies(r.useProxies),typeof(r==null?void 0:r.autoFreeze)=="boolean"&&this.setAutoFreeze(r.autoFreeze);}var t=e.prototype;return t.createDraft=function(r){St(r)||Ge(8),Me(r)&&(r=Qo(r));var a=Vp(this),n=gl(this,r,void 0);return n[he].C=!0,dl(a),n},t.finishDraft=function(r,a){var n=r&&r[he],o=n.A;return ll(o,a),pl(void 0,o)},t.setAutoFreeze=function(r){this.F=r;},t.setUseProxies=function(r){r&&!Up&&Ge(20),this.g=r;},t.applyPatches=function(r,a){var n;for(n=a.length-1;n>=0;n--){var o=a[n];if(o.path.length===0&&o.op==="replace"){r=o.value;break}}n>-1&&(a=a.slice(n+1));var i=Ot("Patches").$;return Me(r)?i(r,a):this.produce(r,function(s){return i(s,a)})},e}(),Je=new nC,oC=Je.produce;Je.produceWithPatches.bind(Je);Je.setAutoFreeze.bind(Je);Je.setUseProxies.bind(Je);Je.applyPatches.bind(Je);Je.createDraft.bind(Je);Je.finishDraft.bind(Je);var kr=oC;R(g,be(Ho()));var ji="NOT_FOUND";function SC(e){var t;return {get:function(a){return t&&e(t.key,a)?t.value:ji},put:function(a,n){t={key:a,value:n};},getEntries:function(){return t?[t]:[]},clear:function(){t=void 0;}}}function yC(e,t){var r=[];function a(s){var u=r.findIndex(function(l){return t(s,l.key)});if(u>-1){var c=r[u];return u>0&&(r.splice(u,1),r.unshift(c)),c.value}return ji}function n(s,u){a(s)===ji&&(r.unshift({key:s,value:u}),r.length>e&&r.pop());}function o(){return r}function i(){r=[];}return {get:a,put:n,getEntries:o,clear:i}}var Xp=function(t,r){return t===r};function vC(e){return function(r,a){if(r===null||a===null||r.length!==a.length)return !1;for(var n=r.length,o=0;o<n;o++)if(!e(r[o],a[o]))return !1;return !0}}function Zp(e,t){var r=typeof t=="object"?t:{equalityCheck:t},a=r.equalityCheck,n=a===void 0?Xp:a,o=r.maxSize,i=o===void 0?1:o,s=r.resultEqualityCheck,u=vC(n),c=i===1?SC(u):yC(i,u);function l(){var p=c.get(arguments);if(p===ji){if(p=e.apply(null,arguments),s){var f=c.getEntries(),d=f.find(function(m){return s(m.value,p)});d&&(p=d.value);}c.put(arguments,p);}return p}return l.clearCache=function(){return c.clear()},l}function CC(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every(function(a){return typeof a=="function"})){var r=t.map(function(a){return typeof a=="function"?"function "+(a.name||"unnamed")+"()":typeof a}).join(", ");throw new Error("createSelector expects all input-selectors to be functions, but received the following types: ["+r+"]")}return t}function xC(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];var n=function(){for(var i=arguments.length,s=new Array(i),u=0;u<i;u++)s[u]=arguments[u];var c=0,l,p={memoizeOptions:void 0},f=s.pop();if(typeof f=="object"&&(p=f,f=s.pop()),typeof f!="function")throw new Error("createSelector expects an output function after the inputs, but received: ["+typeof f+"]");var d=p,m=d.memoizeOptions,h=m===void 0?r:m,v=Array.isArray(h)?h:[h],C=CC(s),x=e.apply(void 0,[function(){return c++,f.apply(null,arguments)}].concat(v)),b=e(function(){for(var _=[],X=C.length,H=0;H<X;H++)_.push(C[H].apply(null,arguments));return l=x.apply(null,_),l});return Object.assign(b,{resultFunc:f,memoizedResultFunc:x,dependencies:C,lastResult:function(){return l},recomputations:function(){return c},resetRecomputations:function(){return c=0}}),b};return n}var Ui=xC(Zp);var Or=be(Ho()),xl=be(Ho());function ef(e){var t=function(a){var n=a.dispatch,o=a.getState;return function(i){return function(s){return typeof s=="function"?s(n,o,e):i(s)}}};return t}var tf=ef();tf.withExtraArgument=ef;var zo=tf;var RC=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,n){a.__proto__=n;}||function(a,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(a[o]=n[o]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function a(){this.constructor=t;}t.prototype=r===null?Object.create(r):(a.prototype=r.prototype,new a);}}(),Wo=function(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},a,n,o,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(c){return function(l){return u([c,l])}}function u(c){if(a)throw new TypeError("Generator is already executing.");for(;r;)try{if(a=1,n&&(o=c[0]&2?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,n=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r);}catch(l){c=[6,l],n=0;}finally{a=o=0;}if(c[0]&5)throw c[1];return {value:c[0]?c[1]:void 0,done:!0}}},Ba=function(e,t){for(var r=0,a=t.length,n=e.length;r<a;r++,n++)e[n]=t[r];return e},bC=Object.defineProperty,FC=Object.defineProperties,AC=Object.getOwnPropertyDescriptors,rf=Object.getOwnPropertySymbols,PC=Object.prototype.hasOwnProperty,IC=Object.prototype.propertyIsEnumerable,af=function(e,t,r){return t in e?bC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},He=function(e,t){for(var r in t||(t={}))PC.call(t,r)&&af(e,r,t[r]);if(rf)for(var a=0,n=rf(t);a<n.length;a++){var r=n[a];IC.call(t,r)&&af(e,r,t[r]);}return e},Cl=function(e,t){return FC(e,AC(t))},Yo=function(e,t,r){return new Promise(function(a,n){var o=function(u){try{s(r.next(u));}catch(c){n(c);}},i=function(u){try{s(r.throw(u));}catch(c){n(c);}},s=function(u){return u.done?a(u.value):Promise.resolve(u.value).then(o,i)};s((r=r.apply(e,t)).next());})},fr=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Ui.apply(void 0,e),a=function(n){for(var o=[],i=1;i<arguments.length;i++)o[i-1]=arguments[i];return r.apply(void 0,Ba([Me(n)?Qo(n):n],o))};return a},EC=typeof window!="undefined"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?xl.compose:xl.compose.apply(null,arguments)};function Bi(e){if(typeof e!="object"||e===null)return !1;var t=Object.getPrototypeOf(e);if(t===null)return !0;for(var r=t;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return t===r}var of=function(e){RC(t,e);function t(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];var n=e.apply(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];return e.prototype.concat.apply(this,r)},t.prototype.prepend=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];return r.length===1&&Array.isArray(r[0])?new(t.bind.apply(t,Ba([void 0],r[0].concat(this)))):new(t.bind.apply(t,Ba([void 0],r.concat(this))))},t}(Array);function Rl(e){return St(e)?kr(e,function(){}):e}function uf(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function TC(e){return function(){return function(u){return function(c){return u(c)}}};}function bl(e){var t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||Bi(e)}function _i(e,t,r,a,n){t===void 0&&(t=""),r===void 0&&(r=bl),n===void 0&&(n=[]);var o;if(!r(e))return {keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null)return !1;for(var i=a!=null?a(e):Object.entries(e),s=n.length>0,u=0,c=i;u<c.length;u++){var l=c[u],p=l[0],f=l[1],d=t?t+"."+p:p;if(!(s&&n.indexOf(d)>=0)){if(!r(f))return {keyPath:d,value:f};if(typeof f=="object"&&(o=_i(f,d,r,a,n),o))return o}}return !1}function DC(e){return function(){return function(v){return function(C){return v(C)}}};}function VC(e){return typeof e=="boolean"}function NC(){return function(t){return $i(t)}}function $i(e){e===void 0&&(e={});var t=e.thunk,r=t===void 0?!0:t,s=new of;if(r&&(VC(r)?s.push(zo):s.push(zo.withExtraArgument(r.extraArgument))),!1);return s}var Fl=!0;function Al(e){var t=NC(),r=e||{},a=r.reducer,n=a===void 0?void 0:a,o=r.middleware,i=o===void 0?t():o,s=r.devTools,u=s===void 0?!0:s,c=r.preloadedState,l=c===void 0?void 0:c,p=r.enhancers,f=p===void 0?void 0:p,d;if(typeof n=="function")d=n;else if(Bi(n))d=(0, Or.combineReducers)(n);else throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');var m=i;if(typeof m=="function"&&(m=m(t),!Fl))throw new Error("when using a middleware builder function, an array of middleware must be returned");var h=Or.applyMiddleware.apply(void 0,m),v=Or.compose;u&&(v=EC(He({trace:!Fl},typeof u=="object"&&u)));var C=[h];Array.isArray(f)?C=Ba([h],f):typeof f=="function"&&(C=f(C));var x=v.apply(void 0,C);return (0, Or.createStore)(d,l,x)}function S(e,t){function r(){for(var a=[],n=0;n<arguments.length;n++)a[n]=arguments[n];if(t){var o=t.apply(void 0,a);if(!o)throw new Error("prepareAction did not return an object");return He(He({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return {type:e,payload:a[0]}}return r.toString=function(){return ""+e},r.type=e,r.match=function(a){return a.type===e},r}function MC(e){return Bi(e)&&typeof e.type=="string"&&Object.keys(e).every(QC)}function QC(e){return ["type","payload","error","meta"].indexOf(e)>-1}function LC(e){return ""+e}function pf(e){var t={},r=[],a,n={addCase:function(o,i){var s=typeof o=="string"?o:o.type;if(s in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[s]=i,n},addMatcher:function(o,i){return r.push({matcher:o,reducer:i}),n},addDefaultCase:function(o){return a=o,n}};return e(n),[t,r,a]}function jC(e){return typeof e=="function"}function k(e,t,r,a){r===void 0&&(r=[]);var n=typeof t=="function"?pf(t):[t,r,a],o=n[0],i=n[1],s=n[2],u;if(jC(e))u=function(){return Rl(e())};else {var c=Rl(e);u=function(){return c};}function l(p,f){p===void 0&&(p=u());var d=Ba([o[f.type]],i.filter(function(m){var h=m.matcher;return h(f)}).map(function(m){var h=m.reducer;return h}));return d.filter(function(m){return !!m}).length===0&&(d=[s]),d.reduce(function(m,h){if(h)if(Me(m)){var v=m,C=h(v,f);return C===void 0?m:C}else {if(St(m))return kr(m,function(x){return h(x,f)});var C=h(m,f);if(C===void 0){if(m===null)return m;throw Error("A case reducer on a non-draftable value must not return undefined")}return C}return m},p)}return l.getInitialState=u,l}function UC(e,t){return e+"/"+t}function BC(e){var t=e.name;if(!t)throw new Error("`name` is a required option for createSlice");var r=typeof e.initialState=="function"?e.initialState:Rl(e.initialState),a=e.reducers||{},n=Object.keys(a),o={},i={},s={};n.forEach(function(l){var p=a[l],f=UC(t,l),d,m;"reducer"in p?(d=p.reducer,m=p.prepare):d=p,o[l]=d,i[f]=d,s[l]=m?S(f,m):S(f);});function u(){var l=typeof e.extraReducers=="function"?pf(e.extraReducers):[e.extraReducers],p=l[0],f=p===void 0?{}:p,d=l[1],m=d===void 0?[]:d,h=l[2],v=h===void 0?void 0:h,C=He(He({},f),i);return k(r,C,m,v)}var c;return {name:t,reducer:function(l,p){return c||(c=u()),c(l,p)},actions:s,caseReducers:o,getInitialState:function(){return c||(c=u()),c.getInitialState()}}}function _C(){return {ids:[],entities:{}}}function $C(){function e(t){return t===void 0&&(t={}),Object.assign(_C(),t)}return {getInitialState:e}}function HC(){function e(t){var r=function(c){return c.ids},a=function(c){return c.entities},n=fr(r,a,function(c,l){return c.map(function(p){return l[p]})}),o=function(c,l){return l},i=function(c,l){return c[l]},s=fr(r,function(c){return c.length});if(!t)return {selectIds:r,selectEntities:a,selectAll:n,selectTotal:s,selectById:fr(a,o,i)};var u=fr(t,a);return {selectIds:fr(t,r),selectEntities:u,selectAll:fr(t,n),selectTotal:fr(t,s),selectById:fr(u,o,i)}}return {getSelectors:e}}function zC(e){var t=Ce(function(r,a){return e(a)});return function(a){return t(a,void 0)}}function Ce(e){return function(r,a){function n(i){return MC(i)}var o=function(i){n(a)?e(a.payload,i):e(a,i);};return Me(r)?(o(r),r):kr(r,o)}}function Ko(e,t){var r=t(e);return r}function pa(e){return Array.isArray(e)||(e=Object.values(e)),e}function ff(e,t,r){e=pa(e);for(var a=[],n=[],o=0,i=e;o<i.length;o++){var s=i[o],u=Ko(s,t);u in r.entities?n.push({id:u,changes:s}):a.push(s);}return [a,n]}function mf(e){function t(m,h){var v=Ko(m,e);v in h.entities||(h.ids.push(v),h.entities[v]=m);}function r(m,h){m=pa(m);for(var v=0,C=m;v<C.length;v++){var x=C[v];t(x,h);}}function a(m,h){var v=Ko(m,e);v in h.entities||h.ids.push(v),h.entities[v]=m;}function n(m,h){m=pa(m);for(var v=0,C=m;v<C.length;v++){var x=C[v];a(x,h);}}function o(m,h){m=pa(m),h.ids=[],h.entities={},r(m,h);}function i(m,h){return s([m],h)}function s(m,h){var v=!1;m.forEach(function(C){C in h.entities&&(delete h.entities[C],v=!0);}),v&&(h.ids=h.ids.filter(function(C){return C in h.entities}));}function u(m){Object.assign(m,{ids:[],entities:{}});}function c(m,h,v){var C=v.entities[h.id],x=Object.assign({},C,h.changes),b=Ko(x,e),P=b!==h.id;return P&&(m[h.id]=b,delete v.entities[h.id]),v.entities[b]=x,P}function l(m,h){return p([m],h)}function p(m,h){var v={},C={};m.forEach(function(P){P.id in h.entities&&(C[P.id]={id:P.id,changes:He(He({},C[P.id]?C[P.id].changes:null),P.changes)});}),m=Object.values(C);var x=m.length>0;if(x){var b=m.filter(function(P){return c(v,P,h)}).length>0;b&&(h.ids=Object.keys(h.entities));}}function f(m,h){return d([m],h)}function d(m,h){var v=ff(m,e,h),C=v[0],x=v[1];p(x,h),r(C,h);}return {removeAll:zC(u),addOne:Ce(t),addMany:Ce(r),setOne:Ce(a),setMany:Ce(n),setAll:Ce(o),updateOne:Ce(l),updateMany:Ce(p),upsertOne:Ce(f),upsertMany:Ce(d),removeOne:Ce(i),removeMany:Ce(s)}}function WC(e,t){var r=mf(e),a=r.removeOne,n=r.removeMany,o=r.removeAll;function i(x,b){return s([x],b)}function s(x,b){x=pa(x);var P=x.filter(function(_){return !(Ko(_,e)in b.entities)});P.length!==0&&v(P,b);}function u(x,b){return c([x],b)}function c(x,b){x=pa(x),x.length!==0&&v(x,b);}function l(x,b){x=pa(x),b.entities={},b.ids=[],s(x,b);}function p(x,b){return f([x],b)}function f(x,b){for(var P=!1,_=0,X=x;_<X.length;_++){var H=X[_],I=b.entities[H.id];if(!!I){P=!0,Object.assign(I,H.changes);var $=e(I);H.id!==$&&(delete b.entities[H.id],b.entities[$]=I);}}P&&C(b);}function d(x,b){return m([x],b)}function m(x,b){var P=ff(x,e,b),_=P[0],X=P[1];f(X,b),s(_,b);}function h(x,b){if(x.length!==b.length)return !1;for(var P=0;P<x.length&&P<b.length;P++)if(x[P]!==b[P])return !1;return !0}function v(x,b){x.forEach(function(P){b.entities[e(P)]=P;}),C(b);}function C(x){var b=Object.values(x.entities);b.sort(t);var P=b.map(e),_=x.ids;h(_,P)||(x.ids=P);}return {removeOne:a,removeMany:n,removeAll:o,addOne:Ce(i),updateOne:Ce(p),upsertOne:Ce(d),setOne:Ce(u),setMany:Ce(c),setAll:Ce(l),addMany:Ce(s),updateMany:Ce(f),upsertMany:Ce(m)}}function YC(e){e===void 0&&(e={});var t=He({sortComparer:!1,selectId:function(s){return s.id}},e),r=t.selectId,a=t.sortComparer,n=$C(),o=HC(),i=a?WC(r,a):mf(r);return He(He(He({selectId:r,sortComparer:a},n),o),i)}var KC="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Pl=function(e){e===void 0&&(e=21);for(var t="",r=e;r--;)t+=KC[Math.random()*64|0];return t},GC=["name","message","stack","code"],Il=function(){function e(t,r){this.payload=t,this.meta=r;}return e}(),gf=function(){function e(t,r){this.payload=t,this.meta=r;}return e}(),hf=function(e){if(typeof e=="object"&&e!==null){for(var t={},r=0,a=GC;r<a.length;r++){var n=a[r];typeof e[n]=="string"&&(t[n]=e[n]);}return t}return {message:String(e)}};function te(e,t,r){var a=S(e+"/fulfilled",function(c,l,p,f){return {payload:c,meta:Cl(He({},f||{}),{arg:p,requestId:l,requestStatus:"fulfilled"})}}),n=S(e+"/pending",function(c,l,p){return {payload:void 0,meta:Cl(He({},p||{}),{arg:l,requestId:c,requestStatus:"pending"})}}),o=S(e+"/rejected",function(c,l,p,f,d){return {payload:f,error:(r&&r.serializeError||hf)(c||"Rejected"),meta:Cl(He({},d||{}),{arg:p,requestId:l,rejectedWithValue:!!f,requestStatus:"rejected",aborted:(c==null?void 0:c.name)==="AbortError",condition:(c==null?void 0:c.name)==="ConditionError"})}}),s=typeof AbortController!="undefined"?AbortController:function(){function c(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return !1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}};}return c.prototype.abort=function(){},c}();function u(c){return function(l,p,f){var d=(r==null?void 0:r.idGenerator)?r.idGenerator(c):Pl(),m=new s,h,v=new Promise(function(P,_){return m.signal.addEventListener("abort",function(){return _({name:"AbortError",message:h||"Aborted"})})}),C=!1;function x(P){C&&(h=P,m.abort());}var b=function(){return Yo(this,null,function(){var P,_,X,H,I,$;return Wo(this,function(ne){switch(ne.label){case 0:return ne.trys.push([0,4,,5]),H=(P=r==null?void 0:r.condition)==null?void 0:P.call(r,c,{getState:p,extra:f}),JC(H)?[4,H]:[3,2];case 1:H=ne.sent(),ne.label=2;case 2:if(H===!1)throw {name:"ConditionError",message:"Aborted due to condition callback returning false."};return C=!0,l(n(d,c,(_=r==null?void 0:r.getPendingMeta)==null?void 0:_.call(r,{requestId:d,arg:c},{getState:p,extra:f}))),[4,Promise.race([v,Promise.resolve(t(c,{dispatch:l,getState:p,extra:f,requestId:d,signal:m.signal,rejectWithValue:function(N,A){return new Il(N,A)},fulfillWithValue:function(N,A){return new gf(N,A)}})).then(function(N){if(N instanceof Il)throw N;return N instanceof gf?a(N.payload,d,c,N.meta):a(N,d,c)})])];case 3:return X=ne.sent(),[3,5];case 4:return I=ne.sent(),X=I instanceof Il?o(null,d,c,I.payload,I.meta):o(I,d,c),[3,5];case 5:return $=r&&!r.dispatchConditionRejection&&o.match(X)&&X.meta.condition,$||l(X),[2,X]}})})}();return Object.assign(b,{abort:x,requestId:d,arg:c,unwrap:function(){return b.then(Sf)}})}}return Object.assign(u,{pending:n,rejected:o,fulfilled:a,typePrefix:e})}function Sf(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function JC(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var XC=function(e){return e&&typeof e.match=="function"},yf=function(e,t){return XC(e)?e.match(t):e(t)};function Go(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(r){return e.some(function(a){return yf(a,r)})}}function El(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(r){return e.every(function(a){return yf(a,r)})}}function Hi(e,t){if(!e||!e.meta)return !1;var r=typeof e.meta.requestId=="string",a=t.indexOf(e.meta.requestStatus)>-1;return r&&a}function Jo(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function vf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length===0?function(r){return Hi(r,["pending"])}:Jo(e)?function(r){var a=e.map(function(o){return o.pending}),n=Go.apply(void 0,a);return n(r)}:vf()(e[0])}function zi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length===0?function(r){return Hi(r,["rejected"])}:Jo(e)?function(r){var a=e.map(function(o){return o.rejected}),n=Go.apply(void 0,a);return n(r)}:zi()(e[0])}function Cf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(a){return a&&a.meta&&a.meta.rejectedWithValue};return e.length===0?function(a){var n=El(zi.apply(void 0,e),r);return n(a)}:Jo(e)?function(a){var n=El(zi.apply(void 0,e),r);return n(a)}:Cf()(e[0])}function xf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length===0?function(r){return Hi(r,["fulfilled"])}:Jo(e)?function(r){var a=e.map(function(o){return o.fulfilled}),n=Go.apply(void 0,a);return n(r)}:xf()(e[0])}function Rf(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length===0?function(r){return Hi(r,["pending","fulfilled","rejected"])}:Jo(e)?function(r){for(var a=[],n=0,o=e;n<o.length;n++){var i=o[n];a.push(i.pending,i.rejected,i.fulfilled);}var s=Go.apply(void 0,a);return s(r)}:Rf()(e[0])}var wl=function(e,t){if(typeof e!="function")throw new TypeError(t+" is not a function")},ZC=function(){},kl=function(e,t){return t===void 0&&(t=ZC),e.catch(t),e},bf=function(e,t){e.addEventListener("abort",t,{once:!0});},_a=function(e,t){var r=e.signal;r.aborted||("reason"in r||Object.defineProperty(r,"reason",{enumerable:!0,value:t,configurable:!0,writable:!0}),e.abort(t));},ex="task",Ff="listener",Af="completed",Ol="cancelled",tx="task-"+Ol,rx="task-"+Af,Pf=Ff+"-"+Ol,ax=Ff+"-"+Af,Xo=function(){function e(t){this.code=t,this.name="TaskAbortError",this.message=ex+" "+Ol+" (reason: "+t+")";}return e}(),$a=function(e){if(e.aborted)throw new Xo(e.reason)},If=function(e){return kl(new Promise(function(t,r){var a=function(){return r(new Xo(e.reason))};e.aborted?a():bf(e,a);}))},nx=function(e,t){return Yo(void 0,null,function(){var r,a;return Wo(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,Promise.resolve()];case 1:return n.sent(),[4,e()];case 2:return r=n.sent(),[2,{status:"ok",value:r}];case 3:return a=n.sent(),[2,{status:a instanceof Xo?"cancelled":"rejected",error:a}];case 4:return t==null||t(),[7];case 5:return [2]}})})},Wi=function(e){return function(t){return kl(Promise.race([If(e),t]).then(function(r){return $a(e),r}))}},Ef=function(e){var t=Wi(e);return function(r){return t(new Promise(function(a){return setTimeout(a,r)}))}},ox=Object.assign,wf={},Zo="listenerMiddleware",ix=function(e){var t=function(r){return bf(e,function(){return _a(r,e.reason)})};return function(r){wl(r,"taskExecutor");var a=new AbortController;t(a);var n=nx(function(){return Yo(void 0,null,function(){var o;return Wo(this,function(i){switch(i.label){case 0:return $a(e),$a(a.signal),[4,r({pause:Wi(a.signal),delay:Ef(a.signal),signal:a.signal})];case 1:return o=i.sent(),$a(a.signal),[2,o]}})})},function(){return _a(a,rx)});return {result:Wi(e)(n),cancel:function(){_a(a,tx);}}}},sx=function(e,t){var r=function(a,n){return Yo(void 0,null,function(){var o,i,s,u;return Wo(this,function(c){switch(c.label){case 0:$a(t),o=function(){},i=new Promise(function(l){o=e({predicate:a,effect:function(p,f){f.unsubscribe(),l([p,f.getState(),f.getOriginalState()]);}});}),s=[If(t),i],n!=null&&s.push(new Promise(function(l){return setTimeout(l,n,null)})),c.label=1;case 1:return c.trys.push([1,,3,4]),[4,Promise.race(s)];case 2:return u=c.sent(),$a(t),[2,u];case 3:return o(),[7];case 4:return [2]}})})};return function(a,n){return kl(r(a,n))}},kf=function(e){var t=e.type,r=e.actionCreator,a=e.matcher,n=e.predicate,o=e.effect;if(t)n=S(t).match;else if(r)t=r.type,n=r.match;else if(a)n=a;else if(!n)throw new Error("Creating or removing a listener requires one of the known fields for matching an action");return wl(o,"options.listener"),{predicate:n,type:t,effect:o}},cx=function(e){var t=kf(e),r=t.type,a=t.predicate,n=t.effect,o=Pl(),i={id:o,effect:n,type:r,predicate:a,pending:new Set,unsubscribe:function(){throw new Error("Unsubscribe not initialized")}};return i},ux=function(e){return function(){e.forEach(ql),e.clear();}},Of=function(e,t,r){try{e(t,r);}catch(a){setTimeout(function(){throw a},0);}},qf=S(Zo+"/add"),Tf=S(Zo+"/removeAll"),Df=S(Zo+"/remove"),lx=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.error.apply(console,Ba([Zo+"/error"],e));},ql=function(e){e.pending.forEach(function(t){_a(t,Pf);});};function dx(e){var t=this;e===void 0&&(e={});var r=new Map,a=e.extra,n=e.onError,o=n===void 0?lx:n;wl(o,"onError");var i=function(d){return d.unsubscribe=function(){return r.delete(d.id)},r.set(d.id,d),function(m){d.unsubscribe(),(m==null?void 0:m.cancelActive)&&ql(d);}},s=function(d){for(var m=0,h=Array.from(r.values());m<h.length;m++){var v=h[m];if(d(v))return v}},u=function(d){var m=s(function(h){return h.effect===d.effect});return m||(m=cx(d)),i(m)},c=function(d){var m=kf(d),h=m.type,v=m.effect,C=m.predicate,x=s(function(b){var P=typeof h=="string"?b.type===h:b.predicate===C;return P&&b.effect===v});return x&&(x.unsubscribe(),d.cancelActive&&ql(x)),!!x},l=function(d,m,h,v){return Yo(t,null,function(){var C,x,b;return Wo(this,function(P){switch(P.label){case 0:C=new AbortController,x=sx(u,C.signal),P.label=1;case 1:return P.trys.push([1,3,4,5]),d.pending.add(C),[4,Promise.resolve(d.effect(m,ox({},h,{getOriginalState:v,condition:function(_,X){return x(_,X).then(Boolean)},take:x,delay:Ef(C.signal),pause:Wi(C.signal),extra:a,signal:C.signal,fork:ix(C.signal),unsubscribe:d.unsubscribe,subscribe:function(){r.set(d.id,d);},cancelActiveListeners:function(){d.pending.forEach(function(_,X,H){_!==C&&(_a(_,Pf),H.delete(_));});}})))];case 2:return P.sent(),[3,5];case 3:return b=P.sent(),b instanceof Xo||Of(o,b,{raisedBy:"effect"}),[3,5];case 4:return _a(C,ax),d.pending.delete(C),[7];case 5:return [2]}})})},p=ux(r),f=function(d){return function(m){return function(h){if(qf.match(h))return u(h.payload);if(Tf.match(h)){p();return}if(Df.match(h))return c(h.payload);var v=d.getState(),C=function(){if(v===wf)throw new Error(Zo+": getOriginalState can only be called synchronously");return v},x;try{if(x=m(h),r.size>0)for(var b=d.getState(),P=Array.from(r.values()),_=0,X=P;_<X.length;_++){var H=X[_],I=!1;try{I=H.predicate(h,b,v);}catch($){I=!1,Of(o,$,{raisedBy:"predicate"});}!I||l(H,h,d,C);}}finally{v=wf;}return x}}};return {middleware:f,startListening:u,stopListening:c,clearListeners:p}}Lp();var oh=be(ri()),ih=be(Hf());function jx(e,t){let r=`
|
|
3855
|
+
The following properties are invalid:
|
|
3856
|
+
|
|
3857
|
+
${e.join(`
|
|
3858
|
+
`)}
|
|
3859
|
+
|
|
3860
|
+
${t}
|
|
3861
|
+
`;return new fa(r)}var fa=class extends Error{constructor(e){super(e);this.name="SchemaValidationError";}},Z=class{constructor(e){this.definition=e;}validate(e={},t=""){let r={...this.default,...e},a=[];for(let n in this.definition){let o=this.definition[n].validate(r[n]);o&&a.push(`${n}: ${o}`);}if(a.length)throw jx(a,t);return r}get default(){let e={};for(let t in this.definition){let r=this.definition[t].default;r!==void 0&&(e[t]=r);}return e}},de=class{constructor(e={}){this.baseConfig=e;}validate(e){return this.baseConfig.required&&re(e)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}get required(){return this.baseConfig.required===!0}};function De(e){return e===void 0}function Ux(e){return e===null}function re(e){return De(e)||Ux(e)}var U=class{constructor(e={}){this.config=e,this.value=new de(e);}validate(e){let t=this.value.validate(e);return t||(Bx(e)?e<this.config.min?`minimum value of ${this.config.min} not respected.`:e>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required}};function Bx(e){return De(e)||zf(e)}function zf(e){return typeof e=="number"&&!isNaN(e)}var J=class{constructor(e={}){this.value=new de(e);}validate(e){let t=this.value.validate(e);return t||(_x(e)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required}};function _x(e){return De(e)||Wf(e)}function Wf(e){return typeof e=="boolean"}var $x=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i,O=class{constructor(e={}){this.config={emptyAllowed:!0,url:!1,...e},this.value=new de(this.config);}validate(e){let{emptyAllowed:t,url:r,regex:a,constrainTo:n}=this.config,o=this.value.validate(e);return o||(De(e)?null:Wa(e)?!t&&!e.length?"value is an empty string.":r&&!$x.test(e)?"value is not a valid URL.":a&&!a.test(e)?`value did not match provided regex ${a}`:n&&!n.includes(e)?`value should be one of: ${n.join(", ")}.`:null:"value is not a string.")}get default(){return this.value.default}get required(){return this.value.required}};function Wa(e){return Object.prototype.toString.call(e)==="[object String]"}var L=class{constructor(e={}){this.config={options:{required:!1},values:{},...e};}validate(e){if(De(e))return this.config.options.required?"value is required and is currently undefined":null;if(!Yf(e))return "value is not an object";for(let[r,a]of Object.entries(this.config.values))if(a.required&&re(e[r]))return `value does not contain ${r}`;let t="";for(let[r,a]of Object.entries(this.config.values)){let n=e[r],o=a.validate(n);o!==null&&(t+=" "+o);}return t===""?null:t}get default(){}get required(){return !!this.config.options.required}};function Yf(e){return e!==void 0&&typeof e=="object"}var K=class{constructor(e={}){this.config=e,this.value=new de(this.config);}validate(e){if(!re(e)&&!Array.isArray(e))return "value is not an array";let t=this.value.validate(e);if(t!==null)return t;if(re(e))return null;if(this.config.max!==void 0&&e.length>this.config.max)return `value contains more than ${this.config.max}`;if(this.config.min!==void 0&&e.length<this.config.min)return `value contains less than ${this.config.min}`;if(this.config.each!==void 0){let r="";return e.forEach(a=>{this.config.each.required&&re(a)&&(r=`value is null or undefined: ${e.join(",")}`);let n=this.validatePrimitiveValue(a,this.config.each);n!==null&&(r+=" "+n);}),r===""?null:r}return null}validatePrimitiveValue(e,t){return Wf(e)||Wa(e)||zf(e)||Yf(e)?t.validate(e):"value is not a primitive value"}get default(){}get required(){return this.value.required}};function Ya(e){return Array.isArray(e)}var Tt=class{constructor(e){this.config=e,this.value=new de(e);}validate(e){let t=this.value.validate(e);return t!==null?t:De(e)||Object.values(this.config.enum).find(a=>a===e)?null:"value is not in enum."}get default(){return this.value.default}get required(){return this.value.required}};function ma(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]]);return r}function F(e,t,r,a){function n(o){return o instanceof r?o:new r(function(i){i(o);})}return new(r||(r=Promise))(function(o,i){function s(l){try{c(a.next(l));}catch(p){i(p);}}function u(l){try{c(a.throw(l));}catch(p){i(p);}}function c(l){l.done?o(l.value):n(l.value).then(s,u);}c((a=a.apply(e,t||[])).next());})}var me;(function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect";})(me||(me={}));function Hx(){return typeof window!="undefined"}function Ml(){return typeof navigator!="undefined"}function ai(){return typeof document!="undefined"}function Ql(){try{return typeof localStorage!="undefined"}catch{return !1}}function zx(){try{return typeof sessionStorage!="undefined"}catch{return !1}}function Kf(){return Ml()&&navigator.cookieEnabled}function Wx(){return typeof crypto!="undefined"}function Yx(){return Wx()&&typeof crypto.getRandomValues!="undefined"}var Kx=[me.click,me.custom,me.search,me.view],Gx=(e,t)=>Kx.indexOf(e)!==-1?Object.assign({language:ai()?document.documentElement.lang:"unknown",userAgent:Ml()?navigator.userAgent:"unknown"},t):t,qr=class{static set(t,r,a){var n,o,i,s,u;a?(i=new Date,i.setTime(i.getTime()+a),s="; expires="+i.toGMTString()):s="",u=window.location.hostname,u.indexOf(".")===-1?document.cookie=t+"="+r+s+"; path=/":(o=u.split("."),o.shift(),n="."+o.join("."),Gf({name:t,value:r,expires:s,domain:n}),(qr.get(t)==null||qr.get(t)!=r)&&(n="."+u,Gf({name:t,value:r,expires:s,domain:n})));}static get(t){for(var r=t+"=",a=document.cookie.split(";"),n=0;n<a.length;n++){var o=a[n];if(o=o.replace(/^\s+/,""),o.indexOf(r)==0)return o.substring(r.length,o.length)}return null}static erase(t){qr.set(t,"",-1);}};function Gf(e){let{name:t,value:r,expires:a,domain:n}=e;document.cookie=`${t}=${r}${a}; path=/; domain=${n}; SameSite=Lax`;}function Jx(){return Ql()?localStorage:Kf()?new Tr:zx()?sessionStorage:new Ka}var Tr=class{getItem(t){return qr.get(`${Tr.prefix}${t}`)}removeItem(t){qr.erase(`${Tr.prefix}${t}`);}setItem(t,r){qr.set(`${Tr.prefix}${t}`,r);}};Tr.prefix="coveo_";var Jf=class{constructor(){this.cookieStorage=new Tr;}getItem(t){return localStorage.getItem(t)||this.cookieStorage.getItem(t)}removeItem(t){this.cookieStorage.removeItem(t),localStorage.removeItem(t);}setItem(t,r){localStorage.setItem(t,r),this.cookieStorage.setItem(t,r);}},Ka=class{getItem(t){return null}removeItem(t){}setItem(t,r){}},ni="__coveo.analytics.history",Xf=20,Zf=1e3*60,em=75,oi=class{constructor(t){this.store=t||Jx();}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t]);}addElementAsync(t){return F(this,void 0,void 0,function*(){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=yield this.getHistoryWithInternalTimeAsync();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t]);})}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){return F(this,void 0,void 0,function*(){let t=yield this.getHistoryWithInternalTimeAsync();return this.stripEmptyQueries(this.stripInternalTime(t))})}getHistoryWithInternalTime(){try{let t=this.store.getItem(ni);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return []}}getHistoryWithInternalTimeAsync(){return F(this,void 0,void 0,function*(){try{let t=yield this.store.getItem(ni);return t?JSON.parse(t):[]}catch{return []}})}setHistory(t){try{this.store.setItem(ni,JSON.stringify(t.slice(0,Xf)));}catch{}}clear(){try{this.store.removeItem(ni);}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return t!=null?t.sort((a,n)=>(n.internalTime||0)-(a.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,em)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>Zf:!0}stripInternalTime(t){return t.map(r=>{let{name:a,time:n,value:o}=r;return {name:a,time:n,value:o}})}stripEmptyQuery(t){let{name:r,time:a,value:n}=t;return r&&typeof n=="string"&&r.toLowerCase()==="query"&&n.trim()===""?{name:r,time:a}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}},Gi=Object.freeze({__proto__:null,STORE_KEY:ni,MAX_NUMBER_OF_HISTORY_ELEMENTS:Xf,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:Zf,MAX_VALUE_SIZE:em,HistoryStore:oi,default:oi}),Xx=(e,t)=>F(void 0,void 0,void 0,function*(){return e===me.view?(yield Zx(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}),Zx=e=>F(void 0,void 0,void 0,function*(){let t=new oi,r={name:"PageView",value:e,time:JSON.stringify(new Date)};yield t.addElementAsync(r);}),Ga=e=>e?(Number(e)^eR(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(`${1e7}`+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,Ga),eR=e=>{if(Yx())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)(t&3)==0&&(r=Math.random()*4294967296),e[t]=r>>>((t&3)<<3)&255;return e},rt=Object.keys,Ll={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},tR=rt(Ll).map(e=>Ll[e]),rR=[...tR].join("|"),aR=new RegExp(`^(${rR}$)`),nR={svcAction:"svc_action",svcActionData:"svc_action_data"},iR=e=>aR.test(e),sR=[iR],tm={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps",group:"group"},rm={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr",group:"group"},Qe={action:"pa",list:"pal",listSource:"pls"},Ji={id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"},cR=["loyaltyCardId","loyaltyTier","thirdPartyPersona","companyName","favoriteStore","storeName","userIndustry","userRole","userDepartment","businessUnit"],jl={id:"quoteId",affiliation:"quoteAffiliation"},Ul={id:"reviewId",rating:"reviewRating",comment:"reviewComment"},uR={add:Qe,bookmark_add:Qe,bookmark_remove:Qe,click:Qe,checkout:Qe,checkout_option:Qe,detail:Qe,impression:Qe,remove:Qe,refund:Object.assign(Object.assign({},Qe),Ji),purchase:Object.assign(Object.assign({},Qe),Ji),quickview:Qe,quote:Object.assign(Object.assign({},Qe),jl),review:Object.assign(Object.assign({},Qe),Ul)},lR=rt(tm).map(e=>tm[e]),dR=rt(rm).map(e=>rm[e]),pR=rt(Qe).map(e=>Qe[e]),fR=rt(Ji).map(e=>Ji[e]),mR=rt(Ul).map(e=>Ul[e]),gR=rt(jl).map(e=>jl[e]),hR=[...lR,"custom"].join("|"),SR=[...dR,"custom"].join("|"),am="(pr[0-9]+)",nm="(il[0-9]+pi[0-9]+)",yR=new RegExp(`^${am}(${hR})$`),vR=new RegExp(`^(${nm}(${SR}))|(il[0-9]+nm)$`),CR=new RegExp(`^(${pR.join("|")})$`),xR=new RegExp(`^(${fR.join("|")})$`),RR=new RegExp(`^${am}custom$`),bR=new RegExp(`^${nm}custom$`),FR=new RegExp(`^(${[...cR,...mR,...gR].join("|")})$`),AR=e=>yR.test(e),PR=e=>vR.test(e),IR=e=>CR.test(e),ER=e=>xR.test(e),wR=e=>FR.test(e),kR=[PR,AR,IR,ER,wR],OR=[RR,bR],qR={anonymizeIp:"aip"},TR={eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"},DR={hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"},VR=["contentId","contentIdKey","contentType","searchHub","tab","searchUid","permanentId","contentLocale"],NR=Object.assign(Object.assign(Object.assign(Object.assign({},qR),TR),DR),VR.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:t}),{})),Bl=Object.assign(Object.assign({},NR),nR),MR=e=>{let t=!!e.action&&uR[e.action]||{};return rt(e).reduce((r,a)=>{let n=t[a]||Bl[a]||a;return Object.assign(Object.assign({},r),{[n]:e[a]})},{})},QR=rt(Bl).map(e=>Bl[e]),LR=e=>QR.indexOf(e)!==-1,jR=e=>e==="custom",UR=e=>[...kR,...sR,LR,jR].some(t=>t(e)),BR=e=>rt(e).reduce((t,r)=>{let a=_R(r);return a?Object.assign(Object.assign({},t),$R(a,e[r])):Object.assign(Object.assign({},t),{[r]:e[r]})},{}),_R=e=>{let t;return [...OR].every(r=>{var a;return t=(a=r.exec(e))===null||a===void 0?void 0:a[1],!Boolean(t)}),t},$R=(e,t)=>rt(t).reduce((r,a)=>Object.assign(Object.assign({},r),{[`${e}${a}`]:t[a]}),{}),om=class{constructor(t){this.opts=t;}sendEvent(t,r){return F(this,void 0,void 0,function*(){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');let{baseUrl:a,preprocessRequest:n}=this.opts,o=this.encodeForEventType(t,r),i=yield this.getQueryParamsForEventType(t),s={url:`${a}/analytics/${t}?${i}`,body:new Blob([o],{type:"application/x-www-form-urlencoded"})},{url:u,body:c}=Object.assign(Object.assign({},s),n?yield n(s,"analyticsBeacon"):{});console.log(`Sending beacon for "${t}" with: `,JSON.stringify(r)),navigator.sendBeacon(u,c);})}deleteHttpCookieVisitorId(){return Promise.resolve()}encodeForEventType(t,r){return this.isEventTypeLegacy(t)?this.encodeForLegacyType(t,r):this.encodeForFormUrlEncoded(Object.assign({access_token:this.opts.token},r))}getQueryParamsForEventType(t){return F(this,void 0,void 0,function*(){let{token:r,visitorIdProvider:a}=this.opts,n=yield a.getCurrentVisitorId();return [r&&this.isEventTypeLegacy(t)?`access_token=${r}`:"",n?`visitorId=${n}`:"","discardVisitInfo=true"].filter(o=>!!o).join("&")})}isEventTypeLegacy(t){return [me.click,me.custom,me.search,me.view].indexOf(t)!==-1}encodeForLegacyType(t,r){return `${t}Event=${encodeURIComponent(JSON.stringify(r))}`}encodeForFormUrlEncoded(t){return Object.keys(t).filter(r=>!!t[r]).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(this.encodeValue(t[r]))}`).join("&")}encodeValue(t){return typeof t=="number"||typeof t=="string"||typeof t=="boolean"?t:JSON.stringify(t)}},im=class{sendEvent(t,r){return F(this,void 0,void 0,function*(){return Promise.resolve()})}deleteHttpCookieVisitorId(){return F(this,void 0,void 0,function*(){return Promise.resolve()})}},sm=window.fetch,_l=class{constructor(t){this.opts=t;}sendEvent(t,r){return F(this,void 0,void 0,function*(){let{baseUrl:a,visitorIdProvider:n,preprocessRequest:o}=this.opts,i=this.shouldAppendVisitorId(t)?yield this.getVisitorIdParam():"",s={url:`${a}/analytics/${t}${i}`,credentials:"include",mode:"cors",headers:this.getHeaders(),method:"POST",body:JSON.stringify(r)},u=Object.assign(Object.assign({},s),o?yield o(s,"analyticsFetch"):{}),{url:c}=u,l=ma(u,["url"]),p=yield sm(c,l);if(p.ok){let f=yield p.json();return f.visitorId&&n.setCurrentVisitorId(f.visitorId),f}else {try{p.json();}catch{}throw console.error(`An error has occured when sending the "${t}" event.`,p,r),new Error(`An error has occurred when sending the "${t}" event. Check the console logs for more details.`)}})}deleteHttpCookieVisitorId(){return F(this,void 0,void 0,function*(){let{baseUrl:t}=this.opts,r=`${t}/analytics/visit`;yield sm(r,{headers:this.getHeaders(),method:"DELETE"});})}shouldAppendVisitorId(t){return [me.click,me.custom,me.search,me.view].indexOf(t)!==-1}getVisitorIdParam(){return F(this,void 0,void 0,function*(){let{visitorIdProvider:t}=this.opts,r=yield t.getCurrentVisitorId();return r?`?visitor=${r}`:""})}getHeaders(){let{token:t}=this.opts;return Object.assign(Object.assign({},t?{Authorization:`Bearer ${t}`}:{}),{"Content-Type":"application/json"})}},cm=class{constructor(t,r){Ql()&&Kf()?this.storage=new Jf:Ql()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new Ka),this.client=new _l(t),this.beaconClient=new om(t),window.addEventListener("beforeunload",()=>{let a=r();for(let{eventType:n,payload:o}of a)this.beaconClient.sendEvent(n,o);});}},um=class{constructor(t,r){this.storage=r||new Ka,this.client=new _l(t);}},lm=class{constructor(){this.storage=new Ka,this.client=new im;}},HR="xx",zR=e=>(e==null?void 0:e.startsWith(HR))||!1,WR=`
|
|
3862
|
+
We've detected you're using React Native but have not provided the corresponding runtime,
|
|
3863
|
+
for an optimal experience please use the "coveo.analytics/react-native" subpackage.
|
|
3864
|
+
Follow the Readme on how to set it up: https://github.com/coveo/coveo.analytics.js#using-react-native
|
|
3865
|
+
`;function YR(){return typeof navigator!="undefined"&&navigator.product=="ReactNative"}var KR=["1",1,"yes",!0];function dm(){return Ml()&&[navigator.globalPrivacyControl,navigator.doNotTrack,navigator.msDoNotTrack,window.doNotTrack].some(e=>KR.indexOf(e)!==-1)}var pm="v15",fm={default:"https://analytics.cloud.coveo.com/rest/ua",production:"https://analytics.cloud.coveo.com/rest/ua",hipaa:"https://analyticshipaa.cloud.coveo.com/rest/ua"};function GR(e=fm.default,t=pm){let r=e.indexOf(".cloud.coveo.com")!==-1;return `${e}${r?"":"/rest"}/${t}`}var Dr=class{constructor(t){if(!t)throw new Error("You have to pass options to this constructor");this.options=Object.assign(Object.assign({},this.defaultOptions),t),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[Xx,Gx].concat(this.options.beforeSendHooks),this.afterSendHooks=this.options.afterSendHooks,this.eventTypeMapping={};let r={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this,preprocessRequest:this.options.preprocessRequest};this.runtime=this.options.runtimeEnvironment||this.initRuntime(r),dm()&&(this.clear(),this.runtime.storage=new Ka);}get defaultOptions(){return {endpoint:fm.default,token:"",version:pm,beforeSendHooks:[],afterSendHooks:[]}}initRuntime(t){return Hx()&&ai()?new cm(t,()=>{let r=[...this.bufferedRequests];return this.bufferedRequests=[],r}):(YR()&&console.warn(WR),new um(t))}get storage(){return this.runtime.storage}determineVisitorId(){return F(this,void 0,void 0,function*(){try{return (yield this.storage.getItem("visitorId"))||Ga()}catch(t){return console.log("Could not get visitor ID from the current runtime environment storage. Using a random ID instead.",t),Ga()}})}getCurrentVisitorId(){return F(this,void 0,void 0,function*(){if(!this.visitorId){let t=yield this.determineVisitorId();yield this.setCurrentVisitorId(t);}return this.visitorId})}setCurrentVisitorId(t){return F(this,void 0,void 0,function*(){this.visitorId=t,yield this.storage.setItem("visitorId",t);})}getParameters(t,...r){return F(this,void 0,void 0,function*(){return yield this.resolveParameters(t,...r)})}getPayload(t,...r){return F(this,void 0,void 0,function*(){let a=yield this.resolveParameters(t,...r);return yield this.resolvePayloadForParameters(t,a)})}get currentVisitorId(){return typeof(this.visitorId||this.storage.getItem("visitorId"))!="string"&&this.setCurrentVisitorId(Ga()),this.visitorId}set currentVisitorId(t){this.visitorId=t,this.storage.setItem("visitorId",t);}resolveParameters(t,...r){return F(this,void 0,void 0,function*(){let{variableLengthArgumentsNames:a=[],addVisitorIdParameter:n=!1,usesMeasurementProtocol:o=!1,addClientIdParameter:i=!1}=this.eventTypeMapping[t]||{};return yield [d=>a.length>0?this.parseVariableArgumentsPayload(a,d):d[0],d=>F(this,void 0,void 0,function*(){return Object.assign(Object.assign({},d),{visitorId:n?yield this.getCurrentVisitorId():""})}),d=>F(this,void 0,void 0,function*(){return i?Object.assign(Object.assign({},d),{clientId:yield this.getCurrentVisitorId()}):d}),d=>o?this.ensureAnonymousUserWhenUsingApiKey(d):d,d=>this.beforeSendHooks.reduce((m,h)=>F(this,void 0,void 0,function*(){let v=yield m;return yield h(t,v)}),d)].reduce((d,m)=>F(this,void 0,void 0,function*(){let h=yield d;return yield m(h)}),Promise.resolve(r))})}resolvePayloadForParameters(t,r){return F(this,void 0,void 0,function*(){let{usesMeasurementProtocol:a=!1}=this.eventTypeMapping[t]||{};return yield [l=>this.removeEmptyPayloadValues(l,t),l=>this.validateParams(l),l=>a?MR(l):l,l=>a?this.removeUnknownParameters(l):l,l=>a?this.processCustomParameters(l):l].reduce((l,p)=>F(this,void 0,void 0,function*(){let f=yield l;return yield p(f)}),Promise.resolve(r))})}makeEvent(t,...r){return F(this,void 0,void 0,function*(){let{newEventType:a=t}=this.eventTypeMapping[t]||{},n=yield this.resolveParameters(t,...r),o=yield this.resolvePayloadForParameters(t,n);return {eventType:a,payload:o,log:i=>F(this,void 0,void 0,function*(){return this.bufferedRequests.push({eventType:a,payload:Object.assign(Object.assign({},o),i)}),yield Promise.all(this.afterSendHooks.map(s=>s(t,Object.assign(Object.assign({},n),i)))),yield this.deferExecution(),yield this.sendFromBufferWithFetch()})}})}sendEvent(t,...r){return F(this,void 0,void 0,function*(){return (yield this.makeEvent(t,...r)).log({})})}deferExecution(){return new Promise(t=>setTimeout(t,0))}sendFromBufferWithFetch(){return F(this,void 0,void 0,function*(){let t=this.bufferedRequests.shift();if(t){let{eventType:r,payload:a}=t;return this.runtime.client.sendEvent(r,a)}})}clear(){this.storage.removeItem("visitorId"),new oi().clear();}deleteHttpOnlyVisitorId(){this.runtime.client.deleteHttpCookieVisitorId();}makeSearchEvent(t){return F(this,void 0,void 0,function*(){return this.makeEvent(me.search,t)})}sendSearchEvent(t){var{searchQueryUid:r}=t,a=ma(t,["searchQueryUid"]);return F(this,void 0,void 0,function*(){return (yield this.makeSearchEvent(a)).log({searchQueryUid:r})})}makeClickEvent(t){return F(this,void 0,void 0,function*(){return this.makeEvent(me.click,t)})}sendClickEvent(t){var{searchQueryUid:r}=t,a=ma(t,["searchQueryUid"]);return F(this,void 0,void 0,function*(){return (yield this.makeClickEvent(a)).log({searchQueryUid:r})})}makeCustomEvent(t){return F(this,void 0,void 0,function*(){return this.makeEvent(me.custom,t)})}sendCustomEvent(t){var{lastSearchQueryUid:r}=t,a=ma(t,["lastSearchQueryUid"]);return F(this,void 0,void 0,function*(){return (yield this.makeCustomEvent(a)).log({lastSearchQueryUid:r})})}makeViewEvent(t){return F(this,void 0,void 0,function*(){return this.makeEvent(me.view,t)})}sendViewEvent(t){return F(this,void 0,void 0,function*(){return (yield this.makeViewEvent(t)).log({})})}getVisit(){return F(this,void 0,void 0,function*(){let r=yield (yield fetch(`${this.baseUrl}/analytics/visit`)).json();return this.visitorId=r.visitorId,r})}getHealth(){return F(this,void 0,void 0,function*(){return yield (yield fetch(`${this.baseUrl}/analytics/monitoring/health`)).json()})}registerBeforeSendEventHook(t){this.beforeSendHooks.push(t);}registerAfterSendEventHook(t){this.afterSendHooks.push(t);}addEventTypeMapping(t,r){this.eventTypeMapping[t]=r;}parseVariableArgumentsPayload(t,r){let a={};for(let n=0,o=r.length;n<o;n++){let i=r[n];if(typeof i=="string")a[t[n]]=i;else if(typeof i=="object")return Object.assign(Object.assign({},a),i)}return a}isKeyAllowedEmpty(t,r){return ({[me.search]:["queryText"]}[t]||[]).indexOf(r)!==-1}removeEmptyPayloadValues(t,r){let a=n=>typeof n!="undefined"&&n!==null&&n!=="";return Object.keys(t).filter(n=>this.isKeyAllowedEmpty(r,n)||a(t[n])).reduce((n,o)=>Object.assign(Object.assign({},n),{[o]:t[o]}),{})}removeUnknownParameters(t){return Object.keys(t).filter(a=>{if(UR(a))return !0;console.log(a,"is not processed by coveoua");}).reduce((a,n)=>Object.assign(Object.assign({},a),{[n]:t[n]}),{})}processCustomParameters(t){let{custom:r}=t,a=ma(t,["custom"]),n=this.lowercaseKeys(r),o=BR(a);return Object.assign(Object.assign({},n),o)}lowercaseKeys(t){return Object.keys(t||{}).reduce((a,n)=>Object.assign(Object.assign({},a),{[n.toLowerCase()]:t[n]}),{})}validateParams(t){let{anonymizeIp:r}=t,a=ma(t,["anonymizeIp"]);return r!==void 0&&["0","false","undefined","null","{}","[]",""].indexOf(`${r}`.toLowerCase())==-1&&(a.anonymizeIp=1),a}ensureAnonymousUserWhenUsingApiKey(t){let{userId:r}=t,a=ma(t,["userId"]);return zR(this.options.token)&&!r?(a.userId="anonymous",a):t}get baseUrl(){return GR(this.options.endpoint,this.options.version)}},$l;(function(e){e.contextChanged="contextChanged",e.expandToFullUI="expandToFullUI";})($l||($l={}));var E;(function(e){e.interfaceLoad="interfaceLoad",e.interfaceChange="interfaceChange",e.didyoumeanAutomatic="didyoumeanAutomatic",e.didyoumeanClick="didyoumeanClick",e.resultsSort="resultsSort",e.searchboxSubmit="searchboxSubmit",e.searchboxClear="searchboxClear",e.searchboxAsYouType="searchboxAsYouType",e.breadcrumbFacet="breadcrumbFacet",e.breadcrumbResetAll="breadcrumbResetAll",e.documentQuickview="documentQuickview",e.documentOpen="documentOpen",e.omniboxAnalytics="omniboxAnalytics",e.omniboxFromLink="omniboxFromLink",e.searchFromLink="searchFromLink",e.triggerNotify="notify",e.triggerExecute="execute",e.triggerQuery="query",e.undoTriggerQuery="undoQuery",e.triggerRedirect="redirect",e.pagerResize="pagerResize",e.pagerNumber="pagerNumber",e.pagerNext="pagerNext",e.pagerPrevious="pagerPrevious",e.pagerScrolling="pagerScrolling",e.staticFilterClearAll="staticFilterClearAll",e.staticFilterSelect="staticFilterSelect",e.staticFilterDeselect="staticFilterDeselect",e.facetClearAll="facetClearAll",e.facetSearch="facetSearch",e.facetSelect="facetSelect",e.facetSelectAll="facetSelectAll",e.facetDeselect="facetDeselect",e.facetExclude="facetExclude",e.facetUnexclude="facetUnexclude",e.facetUpdateSort="facetUpdateSort",e.facetShowMore="showMoreFacetResults",e.facetShowLess="showLessFacetResults",e.queryError="query",e.queryErrorBack="errorBack",e.queryErrorClear="errorClearQuery",e.queryErrorRetry="errorRetry",e.recommendation="recommendation",e.recommendationInterfaceLoad="recommendationInterfaceLoad",e.recommendationOpen="recommendationOpen",e.likeSmartSnippet="likeSmartSnippet",e.dislikeSmartSnippet="dislikeSmartSnippet",e.expandSmartSnippet="expandSmartSnippet",e.collapseSmartSnippet="collapseSmartSnippet",e.openSmartSnippetFeedbackModal="openSmartSnippetFeedbackModal",e.closeSmartSnippetFeedbackModal="closeSmartSnippetFeedbackModal",e.sendSmartSnippetReason="sendSmartSnippetReason",e.expandSmartSnippetSuggestion="expandSmartSnippetSuggestion",e.collapseSmartSnippetSuggestion="collapseSmartSnippetSuggestion",e.showMoreSmartSnippetSuggestion="showMoreSmartSnippetSuggestion",e.showLessSmartSnippetSuggestion="showLessSmartSnippetSuggestion",e.openSmartSnippetSource="openSmartSnippetSource",e.openSmartSnippetSuggestionSource="openSmartSnippetSuggestionSource",e.openSmartSnippetInlineLink="openSmartSnippetInlineLink",e.openSmartSnippetSuggestionInlineLink="openSmartSnippetSuggestionInlineLink",e.recentQueryClick="recentQueriesClick",e.clearRecentQueries="clearRecentQueries",e.recentResultClick="recentResultClick",e.clearRecentResults="clearRecentResults",e.noResultsBack="noResultsBack",e.showMoreFoldedResults="showMoreFoldedResults",e.showLessFoldedResults="showLessFoldedResults",e.copyToClipboard="copyToClipboard",e.caseAttach="caseAttach",e.caseDetach="caseDetach";})(E||(E={}));var mm={[E.triggerNotify]:"queryPipelineTriggers",[E.triggerExecute]:"queryPipelineTriggers",[E.triggerQuery]:"queryPipelineTriggers",[E.triggerRedirect]:"queryPipelineTriggers",[E.queryError]:"errors",[E.queryErrorBack]:"errors",[E.queryErrorClear]:"errors",[E.queryErrorRetry]:"errors",[E.pagerNext]:"getMoreResults",[E.pagerPrevious]:"getMoreResults",[E.pagerNumber]:"getMoreResults",[E.pagerResize]:"getMoreResults",[E.pagerScrolling]:"getMoreResults",[E.facetSearch]:"facet",[E.facetShowLess]:"facet",[E.facetShowMore]:"facet",[E.recommendation]:"recommendation",[E.likeSmartSnippet]:"smartSnippet",[E.dislikeSmartSnippet]:"smartSnippet",[E.expandSmartSnippet]:"smartSnippet",[E.collapseSmartSnippet]:"smartSnippet",[E.openSmartSnippetFeedbackModal]:"smartSnippet",[E.closeSmartSnippetFeedbackModal]:"smartSnippet",[E.sendSmartSnippetReason]:"smartSnippet",[E.expandSmartSnippetSuggestion]:"smartSnippetSuggestions",[E.collapseSmartSnippetSuggestion]:"smartSnippetSuggestions",[E.showMoreSmartSnippetSuggestion]:"smartSnippetSuggestions",[E.showLessSmartSnippetSuggestion]:"smartSnippetSuggestions",[E.clearRecentQueries]:"recentQueries",[E.recentResultClick]:"recentlyClickedDocuments",[E.clearRecentResults]:"recentlyClickedDocuments",[E.showLessFoldedResults]:"folding",[$l.expandToFullUI]:"interface",[E.caseDetach]:"case"},Hl=class{constructor(){this.runtime=new lm,this.currentVisitorId="";}getPayload(){return Promise.resolve()}getParameters(){return Promise.resolve()}makeEvent(t){return Promise.resolve({eventType:t,payload:null,log:()=>Promise.resolve()})}sendEvent(){return Promise.resolve()}makeSearchEvent(){return this.makeEvent(me.search)}sendSearchEvent(){return Promise.resolve()}makeClickEvent(){return this.makeEvent(me.click)}sendClickEvent(){return Promise.resolve()}makeCustomEvent(){return this.makeEvent(me.custom)}sendCustomEvent(){return Promise.resolve()}makeViewEvent(){return this.makeEvent(me.view)}sendViewEvent(){return Promise.resolve()}getVisit(){return Promise.resolve({id:"",visitorId:""})}getHealth(){return Promise.resolve({status:""})}registerBeforeSendEventHook(){}registerAfterSendEventHook(){}addEventTypeMapping(){}};function JR(e){let t="";return e.filter(r=>{let a=r!==t;return t=r,a})}function XR(e){return e.map(t=>t.replace(/;/g,""))}function gm(e){let t=256,r=e.join(";");return r.length<=t?r:gm(e.slice(1))}var hm=e=>{let t=XR(e),r=JR(t);return gm(r)};function Sm(e){let t=typeof e.partialQueries=="string"?e.partialQueries:hm(e.partialQueries),r=typeof e.suggestions=="string"?e.suggestions:hm(e.suggestions);return Object.assign(Object.assign({},e),{partialQueries:t,suggestions:r})}var zl=class{constructor(t,r){this.opts=t,this.provider=r;let a=t.enableAnalytics===!1||dm();this.coveoAnalyticsClient=a?new Hl:new Dr(t);}disable(){this.coveoAnalyticsClient instanceof Dr&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new Hl;}enable(){this.coveoAnalyticsClient=new Dr(this.opts);}makeInterfaceLoad(){return this.makeSearchEvent(E.interfaceLoad)}logInterfaceLoad(){return F(this,void 0,void 0,function*(){return (yield this.makeInterfaceLoad()).log({searchUID:this.provider.getSearchUID()})})}makeRecommendationInterfaceLoad(){return this.makeSearchEvent(E.recommendationInterfaceLoad)}logRecommendationInterfaceLoad(){return F(this,void 0,void 0,function*(){return (yield this.makeRecommendationInterfaceLoad()).log({searchUID:this.provider.getSearchUID()})})}makeRecommendation(){return this.makeCustomEvent(E.recommendation)}logRecommendation(){return F(this,void 0,void 0,function*(){return (yield this.makeRecommendation()).log({searchUID:this.provider.getSearchUID()})})}makeRecommendationOpen(t,r){return this.makeClickEvent(E.recommendationOpen,t,r)}logRecommendationOpen(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeRecommendationOpen(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeStaticFilterClearAll(t){return this.makeSearchEvent(E.staticFilterClearAll,t)}logStaticFilterClearAll(t){return F(this,void 0,void 0,function*(){return (yield this.makeStaticFilterClearAll(t)).log({searchUID:this.provider.getSearchUID()})})}makeStaticFilterSelect(t){return this.makeSearchEvent(E.staticFilterSelect,t)}logStaticFilterSelect(t){return F(this,void 0,void 0,function*(){return (yield this.makeStaticFilterSelect(t)).log({searchUID:this.provider.getSearchUID()})})}makeStaticFilterDeselect(t){return this.makeSearchEvent(E.staticFilterDeselect,t)}logStaticFilterDeselect(t){return F(this,void 0,void 0,function*(){return (yield this.makeStaticFilterDeselect(t)).log({searchUID:this.provider.getSearchUID()})})}makeFetchMoreResults(){return this.makeCustomEvent(E.pagerScrolling,{type:"getMoreResults"})}logFetchMoreResults(){return F(this,void 0,void 0,function*(){return (yield this.makeFetchMoreResults()).log({searchUID:this.provider.getSearchUID()})})}makeInterfaceChange(t){return this.makeSearchEvent(E.interfaceChange,t)}logInterfaceChange(t){return F(this,void 0,void 0,function*(){return (yield this.makeInterfaceChange(t)).log({searchUID:this.provider.getSearchUID()})})}makeDidYouMeanAutomatic(){return this.makeSearchEvent(E.didyoumeanAutomatic)}logDidYouMeanAutomatic(){return F(this,void 0,void 0,function*(){return (yield this.makeDidYouMeanAutomatic()).log({searchUID:this.provider.getSearchUID()})})}makeDidYouMeanClick(){return this.makeSearchEvent(E.didyoumeanClick)}logDidYouMeanClick(){return F(this,void 0,void 0,function*(){return (yield this.makeDidYouMeanClick()).log({searchUID:this.provider.getSearchUID()})})}makeResultsSort(t){return this.makeSearchEvent(E.resultsSort,t)}logResultsSort(t){return F(this,void 0,void 0,function*(){return (yield this.makeResultsSort(t)).log({searchUID:this.provider.getSearchUID()})})}makeSearchboxSubmit(){return this.makeSearchEvent(E.searchboxSubmit)}logSearchboxSubmit(){return F(this,void 0,void 0,function*(){return (yield this.makeSearchboxSubmit()).log({searchUID:this.provider.getSearchUID()})})}makeSearchboxClear(){return this.makeSearchEvent(E.searchboxClear)}logSearchboxClear(){return F(this,void 0,void 0,function*(){return (yield this.makeSearchboxClear()).log({searchUID:this.provider.getSearchUID()})})}makeSearchboxAsYouType(){return this.makeSearchEvent(E.searchboxAsYouType)}logSearchboxAsYouType(){return F(this,void 0,void 0,function*(){return (yield this.makeSearchboxAsYouType()).log({searchUID:this.provider.getSearchUID()})})}makeBreadcrumbFacet(t){return this.makeSearchEvent(E.breadcrumbFacet,t)}logBreadcrumbFacet(t){return F(this,void 0,void 0,function*(){return (yield this.makeBreadcrumbFacet(t)).log({searchUID:this.provider.getSearchUID()})})}makeBreadcrumbResetAll(){return this.makeSearchEvent(E.breadcrumbResetAll)}logBreadcrumbResetAll(){return F(this,void 0,void 0,function*(){return (yield this.makeBreadcrumbResetAll()).log({searchUID:this.provider.getSearchUID()})})}makeDocumentQuickview(t,r){return this.makeClickEvent(E.documentQuickview,t,r)}logDocumentQuickview(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeDocumentQuickview(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeDocumentOpen(t,r){return this.makeClickEvent(E.documentOpen,t,r)}logDocumentOpen(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeDocumentOpen(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeOmniboxAnalytics(t){return this.makeSearchEvent(E.omniboxAnalytics,Sm(t))}logOmniboxAnalytics(t){return F(this,void 0,void 0,function*(){return (yield this.makeOmniboxAnalytics(t)).log({searchUID:this.provider.getSearchUID()})})}makeOmniboxFromLink(t){return this.makeSearchEvent(E.omniboxFromLink,Sm(t))}logOmniboxFromLink(t){return F(this,void 0,void 0,function*(){return (yield this.makeOmniboxFromLink(t)).log({searchUID:this.provider.getSearchUID()})})}makeSearchFromLink(){return this.makeSearchEvent(E.searchFromLink)}logSearchFromLink(){return F(this,void 0,void 0,function*(){return (yield this.makeSearchFromLink()).log({searchUID:this.provider.getSearchUID()})})}makeTriggerNotify(t){return this.makeCustomEvent(E.triggerNotify,t)}logTriggerNotify(t){return F(this,void 0,void 0,function*(){return (yield this.makeTriggerNotify(t)).log({searchUID:this.provider.getSearchUID()})})}makeTriggerExecute(t){return this.makeCustomEvent(E.triggerExecute,t)}logTriggerExecute(t){return F(this,void 0,void 0,function*(){return (yield this.makeTriggerExecute(t)).log({searchUID:this.provider.getSearchUID()})})}makeTriggerQuery(){return this.makeCustomEvent(E.triggerQuery,{query:this.provider.getSearchEventRequestPayload().queryText},"queryPipelineTriggers")}logTriggerQuery(){return F(this,void 0,void 0,function*(){return (yield this.makeTriggerQuery()).log({searchUID:this.provider.getSearchUID()})})}makeUndoTriggerQuery(t){return this.makeSearchEvent(E.undoTriggerQuery,t)}logUndoTriggerQuery(t){return F(this,void 0,void 0,function*(){return (yield this.makeUndoTriggerQuery(t)).log({searchUID:this.provider.getSearchUID()})})}makeTriggerRedirect(t){return this.makeCustomEvent(E.triggerRedirect,Object.assign(Object.assign({},t),{query:this.provider.getSearchEventRequestPayload().queryText}))}logTriggerRedirect(t){return F(this,void 0,void 0,function*(){return (yield this.makeTriggerRedirect(t)).log({searchUID:this.provider.getSearchUID()})})}makePagerResize(t){return this.makeCustomEvent(E.pagerResize,t)}logPagerResize(t){return F(this,void 0,void 0,function*(){return (yield this.makePagerResize(t)).log({searchUID:this.provider.getSearchUID()})})}makePagerNumber(t){return this.makeCustomEvent(E.pagerNumber,t)}logPagerNumber(t){return F(this,void 0,void 0,function*(){return (yield this.makePagerNumber(t)).log({searchUID:this.provider.getSearchUID()})})}makePagerNext(t){return this.makeCustomEvent(E.pagerNext,t)}logPagerNext(t){return F(this,void 0,void 0,function*(){return (yield this.makePagerNext(t)).log({searchUID:this.provider.getSearchUID()})})}makePagerPrevious(t){return this.makeCustomEvent(E.pagerPrevious,t)}logPagerPrevious(t){return F(this,void 0,void 0,function*(){return (yield this.makePagerPrevious(t)).log({searchUID:this.provider.getSearchUID()})})}makePagerScrolling(){return this.makeCustomEvent(E.pagerScrolling)}logPagerScrolling(){return F(this,void 0,void 0,function*(){return (yield this.makePagerScrolling()).log({searchUID:this.provider.getSearchUID()})})}makeFacetClearAll(t){return this.makeSearchEvent(E.facetClearAll,t)}logFacetClearAll(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetClearAll(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetSearch(t){return this.makeSearchEvent(E.facetSearch,t)}logFacetSearch(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetSearch(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetSelect(t){return this.makeSearchEvent(E.facetSelect,t)}logFacetSelect(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetSelect(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetDeselect(t){return this.makeSearchEvent(E.facetDeselect,t)}logFacetDeselect(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetDeselect(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetExclude(t){return this.makeSearchEvent(E.facetExclude,t)}logFacetExclude(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetExclude(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetUnexclude(t){return this.makeSearchEvent(E.facetUnexclude,t)}logFacetUnexclude(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetUnexclude(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetSelectAll(t){return this.makeSearchEvent(E.facetSelectAll,t)}logFacetSelectAll(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetSelectAll(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetUpdateSort(t){return this.makeSearchEvent(E.facetUpdateSort,t)}logFacetUpdateSort(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetUpdateSort(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetShowMore(t){return this.makeCustomEvent(E.facetShowMore,t)}logFacetShowMore(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetShowMore(t)).log({searchUID:this.provider.getSearchUID()})})}makeFacetShowLess(t){return this.makeCustomEvent(E.facetShowLess,t)}logFacetShowLess(t){return F(this,void 0,void 0,function*(){return (yield this.makeFacetShowLess(t)).log({searchUID:this.provider.getSearchUID()})})}makeQueryError(t){return this.makeCustomEvent(E.queryError,t)}logQueryError(t){return F(this,void 0,void 0,function*(){return (yield this.makeQueryError(t)).log({searchUID:this.provider.getSearchUID()})})}makeQueryErrorBack(){return F(this,void 0,void 0,function*(){let t=yield this.makeCustomEvent(E.queryErrorBack);return {description:t.description,log:()=>F(this,void 0,void 0,function*(){return yield t.log({searchUID:this.provider.getSearchUID()}),this.logSearchEvent(E.queryErrorBack)})}})}logQueryErrorBack(){return F(this,void 0,void 0,function*(){return (yield this.makeQueryErrorBack()).log({searchUID:this.provider.getSearchUID()})})}makeQueryErrorRetry(){return F(this,void 0,void 0,function*(){let t=yield this.makeCustomEvent(E.queryErrorRetry);return {description:t.description,log:()=>F(this,void 0,void 0,function*(){return yield t.log({searchUID:this.provider.getSearchUID()}),this.logSearchEvent(E.queryErrorRetry)})}})}logQueryErrorRetry(){return F(this,void 0,void 0,function*(){return (yield this.makeQueryErrorRetry()).log({searchUID:this.provider.getSearchUID()})})}makeQueryErrorClear(){return F(this,void 0,void 0,function*(){let t=yield this.makeCustomEvent(E.queryErrorClear);return {description:t.description,log:()=>F(this,void 0,void 0,function*(){return yield t.log({searchUID:this.provider.getSearchUID()}),this.logSearchEvent(E.queryErrorClear)})}})}logQueryErrorClear(){return F(this,void 0,void 0,function*(){return (yield this.makeQueryErrorClear()).log({searchUID:this.provider.getSearchUID()})})}makeLikeSmartSnippet(){return this.makeCustomEvent(E.likeSmartSnippet)}logLikeSmartSnippet(){return F(this,void 0,void 0,function*(){return (yield this.makeLikeSmartSnippet()).log({searchUID:this.provider.getSearchUID()})})}makeDislikeSmartSnippet(){return this.makeCustomEvent(E.dislikeSmartSnippet)}logDislikeSmartSnippet(){return F(this,void 0,void 0,function*(){return (yield this.makeDislikeSmartSnippet()).log({searchUID:this.provider.getSearchUID()})})}makeExpandSmartSnippet(){return this.makeCustomEvent(E.expandSmartSnippet)}logExpandSmartSnippet(){return F(this,void 0,void 0,function*(){return (yield this.makeExpandSmartSnippet()).log({searchUID:this.provider.getSearchUID()})})}makeCollapseSmartSnippet(){return this.makeCustomEvent(E.collapseSmartSnippet)}logCollapseSmartSnippet(){return F(this,void 0,void 0,function*(){return (yield this.makeCollapseSmartSnippet()).log({searchUID:this.provider.getSearchUID()})})}makeOpenSmartSnippetFeedbackModal(){return this.makeCustomEvent(E.openSmartSnippetFeedbackModal)}logOpenSmartSnippetFeedbackModal(){return F(this,void 0,void 0,function*(){return (yield this.makeOpenSmartSnippetFeedbackModal()).log({searchUID:this.provider.getSearchUID()})})}makeCloseSmartSnippetFeedbackModal(){return this.makeCustomEvent(E.closeSmartSnippetFeedbackModal)}logCloseSmartSnippetFeedbackModal(){return F(this,void 0,void 0,function*(){return (yield this.makeCloseSmartSnippetFeedbackModal()).log({searchUID:this.provider.getSearchUID()})})}makeSmartSnippetFeedbackReason(t,r){return this.makeCustomEvent(E.sendSmartSnippetReason,{reason:t,details:r})}logSmartSnippetFeedbackReason(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeSmartSnippetFeedbackReason(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeExpandSmartSnippetSuggestion(t){return this.makeCustomEvent(E.expandSmartSnippetSuggestion,"documentId"in t?t:{documentId:t})}logExpandSmartSnippetSuggestion(t){return F(this,void 0,void 0,function*(){return (yield this.makeExpandSmartSnippetSuggestion(t)).log({searchUID:this.provider.getSearchUID()})})}makeCollapseSmartSnippetSuggestion(t){return this.makeCustomEvent(E.collapseSmartSnippetSuggestion,"documentId"in t?t:{documentId:t})}logCollapseSmartSnippetSuggestion(t){return F(this,void 0,void 0,function*(){return (yield this.makeCollapseSmartSnippetSuggestion(t)).log({searchUID:this.provider.getSearchUID()})})}makeShowMoreSmartSnippetSuggestion(t){return this.makeCustomEvent(E.showMoreSmartSnippetSuggestion,t)}logShowMoreSmartSnippetSuggestion(t){return F(this,void 0,void 0,function*(){return (yield this.makeShowMoreSmartSnippetSuggestion(t)).log({searchUID:this.provider.getSearchUID()})})}makeShowLessSmartSnippetSuggestion(t){return this.makeCustomEvent(E.showLessSmartSnippetSuggestion,t)}logShowLessSmartSnippetSuggestion(t){return F(this,void 0,void 0,function*(){return (yield this.makeShowLessSmartSnippetSuggestion(t)).log({searchUID:this.provider.getSearchUID()})})}makeOpenSmartSnippetSource(t,r){return this.makeClickEvent(E.openSmartSnippetSource,t,r)}logOpenSmartSnippetSource(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeOpenSmartSnippetSource(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeOpenSmartSnippetSuggestionSource(t,r){return this.makeClickEvent(E.openSmartSnippetSuggestionSource,t,{contentIDKey:r.documentId.contentIdKey,contentIDValue:r.documentId.contentIdValue},r)}makeCopyToClipboard(t,r){return this.makeClickEvent(E.copyToClipboard,t,r)}logCopyToClipboard(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeCopyToClipboard(t,r)).log({searchUID:this.provider.getSearchUID()})})}logOpenSmartSnippetSuggestionSource(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeOpenSmartSnippetSuggestionSource(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeOpenSmartSnippetInlineLink(t,r){return this.makeClickEvent(E.openSmartSnippetInlineLink,t,{contentIDKey:r.contentIDKey,contentIDValue:r.contentIDValue},r)}logOpenSmartSnippetInlineLink(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeOpenSmartSnippetInlineLink(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeOpenSmartSnippetSuggestionInlineLink(t,r){return this.makeClickEvent(E.openSmartSnippetSuggestionInlineLink,t,{contentIDKey:r.documentId.contentIdKey,contentIDValue:r.documentId.contentIdValue},r)}logOpenSmartSnippetSuggestionInlineLink(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeOpenSmartSnippetSuggestionInlineLink(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeRecentQueryClick(){return this.makeSearchEvent(E.recentQueryClick)}logRecentQueryClick(){return F(this,void 0,void 0,function*(){return (yield this.makeRecentQueryClick()).log({searchUID:this.provider.getSearchUID()})})}makeClearRecentQueries(){return this.makeCustomEvent(E.clearRecentQueries)}logClearRecentQueries(){return F(this,void 0,void 0,function*(){return (yield this.makeClearRecentQueries()).log({searchUID:this.provider.getSearchUID()})})}makeRecentResultClick(t,r){return this.makeCustomEvent(E.recentResultClick,{info:t,identifier:r})}logRecentResultClick(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeRecentResultClick(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeClearRecentResults(){return this.makeCustomEvent(E.clearRecentResults)}logClearRecentResults(){return F(this,void 0,void 0,function*(){return (yield this.makeClearRecentResults()).log({searchUID:this.provider.getSearchUID()})})}makeNoResultsBack(){return this.makeSearchEvent(E.noResultsBack)}logNoResultsBack(){return F(this,void 0,void 0,function*(){return (yield this.makeNoResultsBack()).log({searchUID:this.provider.getSearchUID()})})}makeShowMoreFoldedResults(t,r){return this.makeClickEvent(E.showMoreFoldedResults,t,r)}logShowMoreFoldedResults(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeShowMoreFoldedResults(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeShowLessFoldedResults(){return this.makeCustomEvent(E.showLessFoldedResults)}logShowLessFoldedResults(){return F(this,void 0,void 0,function*(){return (yield this.makeShowLessFoldedResults()).log({searchUID:this.provider.getSearchUID()})})}makeEventDescription(t,r){var a;return {actionCause:r,customData:(a=t.payload)===null||a===void 0?void 0:a.customData}}makeCustomEvent(t,r,a=mm[t]){return F(this,void 0,void 0,function*(){let n=Object.assign(Object.assign({},this.provider.getBaseMetadata()),r),o=Object.assign(Object.assign({},yield this.getBaseEventRequest(n)),{eventType:a,eventValue:t}),i=yield this.coveoAnalyticsClient.makeCustomEvent(o);return {description:this.makeEventDescription(i,t),log:({searchUID:s})=>i.log({lastSearchQueryUid:s})}})}logCustomEvent(t,r,a=mm[t]){return F(this,void 0,void 0,function*(){return (yield this.makeCustomEvent(t,r,a)).log({searchUID:this.provider.getSearchUID()})})}makeCustomEventWithType(t,r,a){return F(this,void 0,void 0,function*(){let n=Object.assign(Object.assign({},this.provider.getBaseMetadata()),a),o=Object.assign(Object.assign({},yield this.getBaseEventRequest(n)),{eventType:r,eventValue:t}),i=yield this.coveoAnalyticsClient.makeCustomEvent(o);return {description:this.makeEventDescription(i,t),log:({searchUID:s})=>i.log({lastSearchQueryUid:s})}})}logCustomEventWithType(t,r,a){return F(this,void 0,void 0,function*(){return (yield this.makeCustomEventWithType(t,r,a)).log({searchUID:this.provider.getSearchUID()})})}logSearchEvent(t,r){return F(this,void 0,void 0,function*(){return (yield this.makeSearchEvent(t,r)).log({searchUID:this.provider.getSearchUID()})})}makeSearchEvent(t,r){return F(this,void 0,void 0,function*(){let a=yield this.getBaseSearchEventRequest(t,r),n=yield this.coveoAnalyticsClient.makeSearchEvent(a);return {description:this.makeEventDescription(n,t),log:({searchUID:o})=>n.log({searchQueryUid:o})}})}makeClickEvent(t,r,a,n){return F(this,void 0,void 0,function*(){let o=Object.assign(Object.assign(Object.assign({},r),yield this.getBaseEventRequest(Object.assign(Object.assign({},a),n))),{queryPipeline:this.provider.getPipeline(),actionCause:t}),i=yield this.coveoAnalyticsClient.makeClickEvent(o);return {description:this.makeEventDescription(i,t),log:({searchUID:s})=>i.log({searchQueryUid:s})}})}logClickEvent(t,r,a,n){return F(this,void 0,void 0,function*(){return (yield this.makeClickEvent(t,r,a,n)).log({searchUID:this.provider.getSearchUID()})})}getBaseSearchEventRequest(t,r){return F(this,void 0,void 0,function*(){return Object.assign(Object.assign(Object.assign({},yield this.getBaseEventRequest(r)),this.provider.getSearchEventRequestPayload()),{queryPipeline:this.provider.getPipeline(),actionCause:t})})}getBaseEventRequest(t){return F(this,void 0,void 0,function*(){let r=Object.assign(Object.assign({},this.provider.getBaseMetadata()),t);return Object.assign(Object.assign(Object.assign({},this.getOrigins()),this.getSplitTestRun()),{customData:r,language:this.provider.getLanguage(),facetState:this.provider.getFacetState?this.provider.getFacetState():[],anonymous:this.provider.getIsAnonymous(),clientId:yield this.getClientId()})})}getOrigins(){var t,r;return {originContext:(r=(t=this.provider).getOriginContext)===null||r===void 0?void 0:r.call(t),originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}}getClientId(){return this.coveoAnalyticsClient instanceof Dr?this.coveoAnalyticsClient.getCurrentVisitorId():void 0}getSplitTestRun(){let t=this.provider.getSplitTestRunName?this.provider.getSplitTestRunName():"",r=this.provider.getSplitTestRunVersion?this.provider.getSplitTestRunVersion():"";return Object.assign(Object.assign({},t&&{splitTestRunName:t}),r&&{splitTestRunVersion:r})}},ii={pageview:"pageview",event:"event"},Xi=Object.assign({},ii);Object.keys(Xi).map(e=>Xi[e]);var Rm;(function(e){e.click="click",e.flowStart="flowStart";})(Rm||(Rm={}));var bm;(function(e){e.enterInterface="ticket_create_start",e.fieldUpdate="ticket_field_update",e.fieldSuggestionClick="ticket_classification_click",e.suggestionClick="suggestion_click",e.suggestionRate="suggestion_rate",e.nextCaseStep="ticket_next_stage",e.caseCancelled="ticket_cancel",e.caseSolved="ticket_cancel",e.caseCreated="ticket_create";})(bm||(bm={}));var Fm;(function(e){e.quit="Quit",e.solved="Solved";})(Fm||(Fm={}));var Dt=(e,t)=>{if("productListing"in e&&e.productListing)return e.productListing.facets.results.find(r=>r.facetId===t);if("search"in e&&e.search)return e.search.response.facets.find(r=>r.facetId===t)},Wl=(e,t)=>{var r;return (r=e.facetSet[t])==null?void 0:r.request};function ZR(e,t){return !!t&&t.facetId in e.facetSet}var Zi=(e,t)=>{let r=Dt(e,t);if(ZR(e,r))return r},Yl=(e,t)=>{let r=Zi(e,t);return r?r.values.filter(a=>a.state==="selected"):[]},Vt=e=>"productListing"in e?e.productListing.isLoading:e.search.isLoading;function Xe(e){if(!e)return {parents:[],values:[]};let t=[],r=e;for(;r.length&&r[0].children.length;)t=[...t,...r],r=r[0].children;let a=r.find(n=>n.state==="selected");return a&&(t=[...t,a],r=[]),{parents:t,values:r}}function eb(e,t){return !!t&&t.facetId in e.categoryFacetSet}var Kl=(e,t)=>{let r=Dt(e,t);if(eb(e,r))return r},Gl=(e,t)=>{var r;return (r=e.categoryFacetSet[t])==null?void 0:r.request},Am=(e,t)=>{let r=Kl(e,t);return Xe(r==null?void 0:r.values).parents},Jl=(e,t)=>{let r=Gl(e,t);return Xe(r==null?void 0:r.currentValues).parents};function yt(){return {}}function Pm(e){return {request:e}}function vt(){return {}}function Im(e){return {request:e}}function Ct(){return {}}function Em(e){return {request:e,hasBreadcrumbs:!0}}function xt(){return {}}var Ja=(e,t)=>{let r=km(t,e),a=r?r.field:"",n=`${a}_${e}`;return {facetId:e,facetField:a,facetTitle:n}};function es(e,t){let{facetId:r,facetValue:a}=e,n=Ja(r,t),o=Om(t,r);return {...n,facetValue:o==="hierarchical"?wm(t,r):a}}function Rt(e){return {facetSet:e.facetSet||xt(),categoryFacetSet:e.categoryFacetSet||yt(),dateFacetSet:e.dateFacetSet||vt(),numericFacetSet:e.numericFacetSet||Ct()}}var Xl=e=>{let t=[];return ab(e).forEach((r,a)=>{let n=Om(e,r.facetId),o=cb(r,a+1);if(rb(r)){if(!!!Jl(e,r.facetId).length)return;t.push({...o,...sb(e,r.facetId),facetType:n,state:"selected"});return}r.currentValues.forEach((i,s)=>{if(i.state==="idle")return;let u=nb(i,s+1,n),c=tb(r)?ib(i):ob(i);t.push({...o,...u,...c});});}),t},tb=e=>e.type==="specific",rb=e=>e.type==="hierarchical",ab=e=>[...Object.values(e.facetSet),...Object.values(e.categoryFacetSet),...Object.values(e.dateFacetSet),...Object.values(e.numericFacetSet)].map(t=>t.request),nb=(e,t,r)=>({state:e.state,valuePosition:t,facetType:r}),ob=e=>({displayValue:`${e.start}..${e.end}`,value:`${e.start}..${e.end}`,start:e.start,end:e.end,endInclusive:e.endInclusive}),ib=e=>({displayValue:e.value,value:e.value}),wm=(e,t)=>Jl(e,t).map(a=>a.value).join(";"),sb=(e,t)=>{let r=1,a=wm(e,t);return {value:a,valuePosition:r,displayValue:a}},cb=(e,t)=>({title:`${e.field}_${e.facetId}`,field:e.field,id:e.facetId,facetPosition:t}),km=(e,t)=>{var r,a,n,o;return ((r=e.facetSet[t])==null?void 0:r.request)||((a=e.categoryFacetSet[t])==null?void 0:a.request)||((n=e.dateFacetSet[t])==null?void 0:n.request)||((o=e.numericFacetSet[t])==null?void 0:o.request)},Om=(e,t)=>{let r=km(e,t);return r?r.type:"specific"};var ve=()=>({q:"",enableQuerySyntax:!1});function Xa(){return {answerSnippet:"",documentId:{contentIdKey:"",contentIdValue:""},question:"",relatedQuestions:[],score:0}}function Ze(){return {response:{results:[],searchUid:"",totalCountFiltered:0,facets:[],queryCorrections:[],triggers:[],questionAnswer:Xa(),pipeline:"",splitTestRun:"",termsToHighlight:{}},duration:0,queryExecuted:"",error:null,automaticallyCorrected:!1,isLoading:!1,results:[],searchResponseId:"",requestId:"",questionAnswer:Xa()}}var Ee=()=>"default";var si="2.8.10";var ub=e=>{let t=e.configuration.search.locale.split("-")[0];return !t||t.length!==2?"en":t},Vr=class{constructor(t){this.getState=t;this.state=t();}getLanguage(){return ub(this.state)}getBaseMetadata(){let{context:t}=this.state,r=(t==null?void 0:t.contextValues)||{},a={};for(let[n,o]of Object.entries(r)){let i=`context_${n}`;a[i]=o;}return a.coveoHeadlessVersion=si,a}getOriginContext(){return this.state.configuration.analytics.originContext}getOriginLevel1(){return this.state.searchHub||Ee()}getOriginLevel2(){return this.state.configuration.analytics.originLevel2}getOriginLevel3(){return this.state.configuration.analytics.originLevel3}getIsAnonymous(){return this.state.configuration.analytics.anonymous}};var ts=class extends Vr{getFacetState(){return Xl(Rt(this.getState()))}getPipeline(){var t;return this.state.pipeline||((t=this.state.search)==null?void 0:t.response.pipeline)||ts.fallbackPipelineName}getSearchEventRequestPayload(){return {queryText:this.queryText,responseTime:this.responseTime,results:this.mapResultsToAnalyticsDocument(),numberOfResults:this.numberOfResults}}getSearchUID(){var r,a;let t=this.getState();return ((r=t.search)==null?void 0:r.searchResponseId)||((a=t.search)==null?void 0:a.response.searchUid)||Ze().response.searchUid}getSplitTestRunName(){var t;return (t=this.state.search)==null?void 0:t.response.splitTestRun}getSplitTestRunVersion(){var a;let t=!!this.getSplitTestRunName(),r=((a=this.state.search)==null?void 0:a.response.pipeline)||this.state.pipeline||ts.fallbackPipelineName;return t?r:void 0}mapResultsToAnalyticsDocument(){var t;return (t=this.state.search)==null?void 0:t.response.results.map(r=>({documentUri:r.uri,documentUriHash:r.raw.urihash}))}get queryText(){var t;return ((t=this.state.query)==null?void 0:t.q)||ve().q}get responseTime(){var t;return ((t=this.state.search)==null?void 0:t.duration)||Ze().duration}get numberOfResults(){var t;return ((t=this.state.search)==null?void 0:t.response.totalCountFiltered)||Ze().response.totalCountFiltered}},ga=ts;ga.fallbackPipelineName="default";var qm=({logger:e,getState:t,analyticsClientMiddleware:r=(o,i)=>i,preprocessRequest:a,provider:n=new ga(t)})=>{let o=t(),i=o.configuration.accessToken,s=o.configuration.analytics.apiBaseUrl,u=o.configuration.analytics.runtimeEnvironment,c=o.configuration.analytics.enabled,l=new zl({token:i,endpoint:s,runtimeEnvironment:u,preprocessRequest:a,beforeSendHooks:[r,(p,f)=>(e.info({...f,type:p,endpoint:s,token:i},"Analytics request"),f)]},n);return c||l.disable(),l},Fe=e=>new Dr(e).getCurrentVisitorId(),Zl=e=>{let t=new Dr(e);t.clear(),t.deleteHttpOnlyVisitorId();},bt=new Gi.HistoryStore,ed=()=>{let t=bt.getHistory().reverse().find(r=>r.name==="PageView"&&r.value);return t?t.value:""};function Nt(e){let{url:t,accessToken:r,organizationId:a,authentication:n,...o}=e;return o}var mr=e=>{let{response:t}=e;return t.body?lb(e):db(t)},lb=e=>fb(e)?mb(e):pb(e)?e.body:{message:"unknown",statusCode:0,type:"unknown"},db=e=>{let t=JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)));return {...t,message:`Client side error: ${t.message||""}`,statusCode:400,type:"ClientError"}};function pb(e){return e.body.statusCode!==void 0}function fb(e){return e.body.exception!==void 0}var mb=e=>({message:e.body.exception.code,statusCode:e.response.status,type:e.body.exception.code});var Hm=be(Dm()),zm=be(Bm());var li=class extends Error{constructor(){super();this.name="ExpiredToken",this.message="The token being used to perform the request is expired.";}},Za=class extends Error{constructor(t,r){super();this.name="Disconnected",this.message=`Client could not connect to the following URL: ${t}`,this.statusCode=r!=null?r:0;}};function _m(e){let t=[];for(let r in e){let a=encodeURIComponent(r),n=encodeURIComponent(e[r]);t.push(`${a}=${n}`);}return t.join("&")}function $m(e){return typeof e!="object"||!e?!1:Object.values(e).every(jb)}function jb(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Wm(e){return e===429}var at=class{static async call(t){let r=Ub(t),{origin:a,preprocessRequest:n,logger:o,requestMetadata:i}=t,s={...r,...n?await n(r,a,i):{}};o.info(s,"Platform request");let{url:u,...c}=s,l=async()=>{let p=await(0, Hm.default)(u,c);if(Wm(p.status))throw p;return p};try{let p=await(0, zm.backOff)(l,{retry:f=>{let d=f&&Wm(f.status);return d&&o.info("Platform retrying request"),d}});if(p.status===419)throw o.info("Platform renewing token"),new li;if(p.status===404)throw new Za(u,p.status);return o.info({response:p,requestInfo:s},"Platform response"),p}catch(p){return p.message==="Failed to fetch"?new Za(u):p}}};function Ym(e,t){let r=!t||!t.environment||t.environment==="prod"?"":t.environment,a=!t||!t.region||t.region==="us"?"":`-${t.region}`;return `https://${e}${r}${a}.cloud.coveo.com`}function as(e){return (e==null?void 0:e.multiRegionSubDomain)?`https://${e.multiRegionSubDomain}.org.coveo.com`:Ym("platform",e)}function ud(e){return Ym("analytics",e)}function Ub(e){let{url:t,method:r,requestParams:a,contentType:n,accessToken:o,signal:i}=e,s=e.method==="POST"||e.method==="PUT",u=Bb(a,n);return {url:t,method:r,headers:{"Content-Type":n,Authorization:`Bearer ${o}`,...e.headers},...s&&{body:u},signal:i}}function Bb(e,t){return t==="application/x-www-form-urlencoded"?$m(e)?_m(e):"":JSON.stringify(e)}var Km=TextDecoder;var ld=class{constructor(t){this._params={};this._basePath=t;}addParam(t,r){this._params={...this.params,[t]:r};}get basePath(){return this._basePath}get params(){return this._params}get hasParams(){return Object.entries(this._params).length}get href(){return this.hasParams?`${this.basePath}?${Object.entries(this.params).map(([t,r])=>`${t}=${encodeURIComponent(r)}`).join("&")}`:this.basePath}};function Gm(e){return ((e.headers.get("content-type")||"").split(";").find(a=>a.indexOf("charset=")!==-1)||"").split("=")[1]||"UTF-8"}var Mt=(e,t,r,a)=>({accessToken:e.accessToken,method:t,contentType:r,url:`${e.url}${a}?${_b(e)}${e.authentication?`&${$b(e)}`:""}`,origin:"searchApiFetch"}),_b=e=>`organizationId=${e.organizationId}`,$b=e=>`authentication=${encodeURIComponent(e.authentication)}`;var Jm=(e,t)=>{let r=new ld(`${e.url}${t}`);return r.addParam("access_token",e.accessToken),r.addParam("organizationId",e.organizationId),r.addParam("uniqueId",e.uniqueId),e.q!==void 0&&r.addParam("q",e.q),e.enableNavigation!==void 0&&r.addParam("enableNavigation",`${e.enableNavigation}`),e.requestedOutputSize!==void 0&&r.addParam("requestedOutputSize",`${e.requestedOutputSize}`),e.visitorId!==void 0&&r.addParam("visitorId",`${e.visitorId}`),r.href},Xm=async(e,t)=>{let r=await at.call({...Mt(e,"POST","application/x-www-form-urlencoded","/html"),requestParams:Nt(e),requestMetadata:{method:"html"},...t});if(r instanceof Error)throw r;let a=Gm(r),n=await r.arrayBuffer(),i=new Km(a).decode(n);return Hb(i)?{success:i}:{error:mr({response:r,body:i})}};function Hb(e){return typeof e=="string"}function zb(e){return {statusCode:e.statusCode,type:e.name,message:e.message}}function Wb(e){return {statusCode:e.code,type:e.name,message:e.message,ignored:!0}}function di(e,t){if(t&&e.name==="AbortError")return {error:Wb(e)};if(e instanceof Za)return {error:zb(e)};throw e}var pi=class{constructor(t){this.options=t;this.searchAbortController=null;}async plan(t){let r=await at.call({...Mt(t,"POST","application/json","/plan"),requestParams:Nt(t),requestMetadata:{method:"plan"},...this.options});if(r instanceof Error)return di(r);let a=await r.json();return Kb(a)?{success:a}:{error:mr({response:r,body:a})}}async querySuggest(t){let r=await at.call({...Mt(t,"POST","application/json","/querySuggest"),requestMetadata:{method:"querySuggest"},requestParams:Nt(t),...this.options});if(r instanceof Error)return di(r);let a=await r.json(),n={response:r,body:a};return Yb(a)?{success:(await this.options.postprocessQuerySuggestResponseMiddleware(n)).body}:{error:mr(n)}}async search(t,r){var i;this.searchAbortController&&(!(r==null?void 0:r.disableAbortWarning)&&this.options.logger.warn("Cancelling current pending search query"),this.searchAbortController.abort()),this.searchAbortController=this.getAbortControllerInstanceIfAvailable();let a=await at.call({...Mt(t,"POST","application/json",""),requestParams:Nt(t),requestMetadata:{method:"search",origin:r==null?void 0:r.origin},...this.options,signal:(i=this.searchAbortController)==null?void 0:i.signal});if(a instanceof Error)return di(a,r==null?void 0:r.disableAbortWarning);this.searchAbortController=null;let n=await a.json(),o={response:a,body:n};return pd(n)?(o.body=Jb(n),{success:(await this.options.postprocessSearchResponseMiddleware(o)).body}):{error:mr(o)}}async facetSearch(t){let r=await at.call({...Mt(t,"POST","application/json","/facet"),requestParams:Nt(t),requestMetadata:{method:"facetSearch"},...this.options});if(r instanceof Error)throw r;let a=await r.json(),n={response:r,body:a};return (await this.options.postprocessFacetSearchResponseMiddleware(n)).body}async recommendations(t){let r=await at.call({...Mt(t,"POST","application/json",""),requestParams:Nt(t),requestMetadata:{method:"recommendations"},...this.options});if(r instanceof Error)throw r;let a=await r.json();return pd(a)?{success:a}:{error:mr({response:r,body:a})}}async html(t){return Xm(t,{...this.options})}async productRecommendations(t){let r=await at.call({...Mt(t,"POST","application/json",""),requestParams:Nt(t),requestMetadata:{method:"productRecommendations"},...this.options});if(r instanceof Error)throw r;let a=await r.json();return pd(a)?{success:a}:{error:mr({response:r,body:a})}}async fieldDescriptions(t){let r=await at.call({...Mt(t,"GET","application/json","/fields"),requestParams:{},requestMetadata:{method:"fieldDescriptions"},...this.options});if(r instanceof Error)throw r;let a=await r.json();return Gb(a)?{success:a}:{error:mr({response:r,body:a})}}getAbortControllerInstanceIfAvailable(){if(typeof window=="undefined"){let t=Zm();return new t}return typeof AbortController=="undefined"?null:new AbortController}},eg=e=>e.success!==void 0,ge=e=>e.error!==void 0;function Yb(e){return e.completions!==void 0}function Kb(e){return e.preprocessingOutput!==void 0}function Gb(e){return e.fields!==void 0}function pd(e){return e.results!==void 0}function Jb(e){let t=Xa();return re(e.questionAnswer)?(e.questionAnswer=t,e):(e.questionAnswer={...t,...e.questionAnswer},e)}var tg=["uri","urihash","permanentid","ec_name","ec_brand","ec_category","ec_item_group_id","ec_price","ec_promo_price","ec_shortdesc","ec_thumbnails","ec_images","ec_in_stock","ec_rating","childResults","totalNumberOfChildResults"];var q=new O({required:!0,emptyAllowed:!1}),oe=new O({required:!1,emptyAllowed:!1}),ie=new O({required:!0,emptyAllowed:!0}),Ft=({message:e,name:t,stack:r})=>({message:e,name:t,stack:r}),ze=(e,t)=>{if("required"in t)return {payload:new Z({value:t}).validate({value:e}).value};let n=new L({options:{required:!0},values:t}).validate(e);if(n)throw new fa(n);return {payload:e}},y=(e,t)=>{try{return ze(e,t)}catch(r){return {payload:e,error:Ft(r)}}},we=(e,t,r,a)=>{let n=`Check the initialState of ${a}`;return rg(e,t,r,n,"Controller initialization error")},pe=(e,t,r,a)=>{let n=`Check the options of ${a}`;return rg(e,t,r,n,"Controller initialization error")},rg=(e,t,r,a,n)=>{try{return t.validate(r,a)}catch(o){throw e.logger.error(o,n),o}};var en=()=>({id:"",skus:[],maxNumberOfRecommendations:5,filter:{brand:"",category:""},additionalFields:[],recommendations:[],error:null,isLoading:!1,searchUid:"",duration:0});var fd=class extends Vr{constructor(){super(...arguments);this.initialState=en();}getPipeline(){return ""}getSearchEventRequestPayload(){return {queryText:"",responseTime:this.responseTime,results:this.mapResultsToAnalyticsDocument(),numberOfResults:this.numberOfResults}}getSearchUID(){var r;return ((r=this.getState().productRecommendations)==null?void 0:r.searchUid)||this.initialState.searchUid}mapResultsToAnalyticsDocument(){var t;return (t=this.state.productRecommendations)==null?void 0:t.recommendations.map(r=>({documentUri:r.documentUri,documentUriHash:r.documentUriHash,permanentid:r.permanentid}))}get responseTime(){var t;return ((t=this.state.productRecommendations)==null?void 0:t.duration)||this.initialState.duration}get numberOfResults(){var t;return ((t=this.state.productRecommendations)==null?void 0:t.recommendations.length)||this.initialState.recommendations.length}};new Gi.HistoryStore;var cg=be(md()),tn=(e,t=5)=>e+Math.random().toString(36).substring(2,2+t);function os(e){return Array.isArray(e)}function is(e){return e.trim()===""}function ug(e,t){return Object.values(e.reduce((r,a,n)=>({...r,[t(a,n)]:a}),{}))}function iF(e){return (typeof btoa!="undefined"?btoa:cg.btoa)(encodeURI(e))}function ss(e,t){let{[e]:r,...a}=t;return a}function rn(e){return iF(JSON.stringify(e))}var sF=new Set(["1",1,"yes",!0]);function cs(){if(typeof navigator=="undefined"||typeof window=="undefined")return !1;let e=navigator,t=window;return [e.globalPrivacyControl,e.doNotTrack,e.msDoNotTrack,t.doNotTrack].some(r=>sF.has(r))}function us(e){let t=lg(e),r=[e,...t].filter(n=>n.parentResult).map(n=>n.parentResult);return ug([e,...t,...r],n=>n.uniqueId)}function lg(e){return e.childResults?e.childResults.flatMap(t=>[t,...lg(t)]):[]}var nt=()=>"";var M=(a=>(a[a.Search=0]="Search",a[a.Custom=1]="Custom",a[a.Click=2]="Click",a))(M||{});function cF(e){return Object.assign(e,{instantlyCallable:!0})}function uF(e,t){let r=o=>cF(te(e,o)),a=r(async(o,{getState:i,extra:s})=>{let{analyticsClientMiddleware:u,preprocessRequest:c,logger:l}=s;return await(await t({getState:i,analyticsClientMiddleware:u,preprocessRequest:c,logger:l})).log({state:i(),extra:s})});return Object.assign(a,{prepare:async({getState:o,analyticsClientMiddleware:i,preprocessRequest:s,logger:u})=>{let{description:c,log:l}=await t({getState:o,analyticsClientMiddleware:i,preprocessRequest:s,logger:u});return {description:c,action:r(async(p,{getState:f,extra:d})=>await l({state:f(),extra:d}))}}}),a}var Q=(e,t,r,a=n=>new ga(n))=>uF(e,async({getState:n,analyticsClientMiddleware:o,preprocessRequest:i,logger:s})=>{let u=qm({getState:n,logger:s,analyticsClientMiddleware:o,preprocessRequest:i,provider:a(n)}),c=await r(u,n());return {description:c==null?void 0:c.description,log:async({state:l})=>{let p=await(c==null?void 0:c.log({searchUID:a(()=>l).getSearchUID()}));return s.info({client:u.coveoAnalyticsClient,response:p},"Analytics response"),{analyticsType:t}}}});var Ve=(e,t)=>{var o;let r=i=>{var s,u;return i+((u=(s=t.pagination)==null?void 0:s.firstResult)!=null?u:0)},a=-1,n=(o=t.search)==null?void 0:o.results;return a=pg(e,n),a<0&&(a=gF(e,n)),a<0&&(a=0),lF(e,r(a),t)};function lF(e,t,r){let a=e.raw.collection;return {collectionName:typeof a=="string"?a:"default",documentAuthor:fF(e),documentPosition:t+1,documentTitle:e.title,documentUri:e.uri,documentUriHash:e.raw.urihash,documentUrl:e.clickUri,rankingModifier:e.rankingModifier||"",sourceName:mF(e),queryPipeline:r.pipeline||nt()}}var Le=e=>(e.raw.permanentid||console.warn("Missing field permanentid on result. This might cause many issues with your Coveo deployment. See https://docs.coveo.com/en/1913 and https://docs.coveo.com/en/1640 for more information.",e),{contentIDKey:"permanentid",contentIDValue:e.raw.permanentid||""}),dg={urihash:new O,sourcetype:new O,permanentid:new O},fi={uniqueId:q,raw:new L({values:dg}),title:q,uri:q,clickUri:q,rankingModifier:new O({required:!1,emptyAllowed:!0})};function dF(e){return Object.assign({},...Object.keys(dg).map(t=>({[t]:e[t]})))}function pF(e){return Object.assign({},...Object.keys(fi).map(t=>({[t]:e[t]})),{raw:dF(e.raw)})}function fF(e){let t=e.raw.author;return re(t)?"unknown":Array.isArray(t)?t.join(";"):`${t}`}function mF(e){let t=e.raw.source;return re(t)?"unknown":t}var _e=e=>new Z(fi).validate(pF(e));function gF(e,t){for(let[r,a]of t.entries()){let n=us(a);if(pg(e,n)!==-1)return r}return -1}function pg(e,t=[]){return t.findIndex(({uniqueId:r})=>r===e.uniqueId)}var fg=()=>Q("analytics/productRecommendations/load",M.Search,e=>e.makeRecommendationInterfaceLoad(),e=>new fd(e));function hF(e){return e&&"childResults"in e&&"totalNumberOfChildResults"in e}var mg=S("productrecommendations/setId",e=>y(e,{id:q})),gg=S("productrecommendations/setSku",e=>y(e,{skus:new K({required:!0,min:1,each:oe})})),hg=S("productrecommendations/setBrand",e=>y(e,{brand:new O({required:!0,emptyAllowed:!0})})),Sg=S("productrecommendations/setCategory",e=>y(e,{category:new O({required:!0,emptyAllowed:!0})})),yg=S("productrecommendations/setAdditionalFields",e=>y(e,{additionalFields:new K({required:!0,each:oe})})),vg=S("productrecommendations/setMaxNumberOfRecommendations",e=>y(e,{number:new U({required:!0,max:50,min:1})})),an=te("productRecommendations/get",async(e,{getState:t,rejectWithValue:r,extra:{apiClient:a}})=>{let n=t(),o=new Date().getTime(),i=await a.productRecommendations(await SF(n)),s=new Date().getTime()-o;if(ge(i))return r(i.error);let u=n.productRecommendations.additionalFields||[];return {recommendations:i.success.results.map(c=>Cg(c,{additionalFields:u})),analyticsAction:fg(),searchUid:i.success.searchUid,duration:s}}),Cg=(e,{additionalFields:t})=>{let r=e.raw.ec_price,a=e.raw.ec_promo_price,n=e.raw.ec_in_stock,o={documentUri:e.uri,documentUriHash:e.raw.urihash,permanentid:e.raw.permanentid,clickUri:e.clickUri,ec_name:e.raw.ec_name,ec_brand:e.raw.ec_brand,ec_category:e.raw.ec_category,ec_item_group_id:e.raw.ec_item_group_id,ec_price:r,ec_shortdesc:e.raw.ec_shortdesc,ec_thumbnails:e.raw.ec_thumbnails,ec_images:e.raw.ec_images,ec_promo_price:a===void 0||r!==void 0&&a>=r?void 0:a,ec_in_stock:n===void 0?void 0:n.toLowerCase()==="yes"||n.toLowerCase()==="true",ec_rating:e.raw.ec_rating,additionalFields:t.reduce((i,s)=>({...i,[s]:e.raw[s]}),{}),childResults:[],totalNumberOfChildResults:0};return hF(e)&&(o.childResults=e.childResults.map(i=>Cg(i,{additionalFields:t})),o.totalNumberOfChildResults=e.totalNumberOfChildResults),o},SF=async e=>({accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.search.apiBaseUrl,locale:e.configuration.search.locale,timezone:e.configuration.search.timezone,...e.configuration.analytics.enabled&&{visitorId:await Fe(e.configuration.analytics)},recommendation:e.productRecommendations.id,numberOfResults:e.productRecommendations.maxNumberOfRecommendations,fieldsToInclude:[...tg,...e.productRecommendations.additionalFields||[]],mlParameters:{...e.productRecommendations.skus&&e.productRecommendations.skus.length>0&&{itemIds:e.productRecommendations.skus},...e.productRecommendations.filter.brand&&{brandFilter:e.productRecommendations.filter.brand},...e.productRecommendations.filter.category&&{categoryFilter:e.productRecommendations.filter.category}},actionsHistory:e.configuration.analytics.enabled?bt.getHistory():[],...e.context&&{context:e.context.contextValues},...e.dictionaryFieldContext&&{dictionaryFieldContext:e.dictionaryFieldContext.contextValues},...e.searchHub&&{searchHub:e.searchHub}});var Nr=async(e,t)=>({analytics:{clientId:await Fe(e),clientTimestamp:new Date().toISOString(),documentReferrer:e.originLevel3,originContext:e.originContext,...t&&{actionCause:t.actionCause,customData:t.customData},...e.userDisplayName&&{userDisplayName:e.userDisplayName},...e.documentLocation&&{documentLocation:e.documentLocation},...e.deviceId&&{deviceId:e.deviceId},...ed()&&{pageId:ed()}}});var Mr=()=>({duration:0,error:null,isLoading:!1,id:"Recommendation",recommendations:[],searchUid:"",splitTestRun:"",pipeline:""});var gd=class extends Vr{getPipeline(){var t;return this.state.pipeline||((t=this.state.recommendation)==null?void 0:t.pipeline)||"default"}getSearchEventRequestPayload(){return {queryText:ve().q,responseTime:this.responseTime,results:this.mapResultsToAnalyticsDocument(),numberOfResults:this.numberOfResults}}getSearchUID(){var r;return ((r=this.getState().recommendation)==null?void 0:r.searchUid)||Mr().searchUid}getSplitTestRunName(){var t;return (t=this.state.recommendation)==null?void 0:t.splitTestRun}getSplitTestRunVersion(){var a;let t=!!this.getSplitTestRunName(),r=((a=this.state.recommendation)==null?void 0:a.pipeline)||this.state.pipeline||"default";return t?r:void 0}get responseTime(){var t;return ((t=this.state.recommendation)==null?void 0:t.duration)||Mr().duration}mapResultsToAnalyticsDocument(){var t;return (t=this.state.recommendation)==null?void 0:t.recommendations.map(r=>({documentUri:r.uri,documentUriHash:r.raw.urihash}))}get numberOfResults(){var t;return ((t=this.state.recommendation)==null?void 0:t.recommendations.length)||Mr().recommendations.length}};var xg=()=>Q("analytics/recommendation/update",M.Search,e=>e.makeRecommendationInterfaceLoad(),e=>new gd(e));var Rg=S("recommendation/set",e=>y(e,{id:q})),nn=te("recommendation/get",async(e,{getState:t,rejectWithValue:r,extra:{apiClient:a}})=>{let n=t(),o=new Date().getTime(),i=await a.recommendations(await yF(n)),s=new Date().getTime()-o;return ge(i)?r(i.error):{recommendations:i.success.results,analyticsAction:xg(),duration:s,searchUid:i.success.searchUid,splitTestRun:i.success.splitTestRun,pipeline:i.success.pipeline}}),yF=async e=>({accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.search.apiBaseUrl,recommendation:e.recommendation.id,tab:e.configuration.analytics.originLevel2,referrer:e.configuration.analytics.originLevel3,timezone:e.configuration.search.timezone,locale:e.configuration.search.locale,actionsHistory:e.configuration.analytics.enabled?bt.getHistory():[],...e.advancedSearchQueries&&{aq:e.advancedSearchQueries.aq,cq:e.advancedSearchQueries.cq},...e.pipeline&&{pipeline:e.pipeline},...e.searchHub&&{searchHub:e.searchHub},...e.context&&{context:e.context.contextValues},...e.dictionaryFieldContext&&{dictionaryFieldContext:e.dictionaryFieldContext.contextValues},...e.fields&&{fieldsToInclude:e.fields.fieldsToInclude},...e.configuration.analytics.enabled&&{visitorId:await Fe(e.configuration.analytics)},...e.configuration.analytics.enabled&&await Nr(e.configuration.analytics),...e.configuration.search.authenticationProviders.length&&{authentication:e.configuration.search.authenticationProviders.join(",")},...e.pagination&&{numberOfResults:e.pagination.numberOfResults}});var ke=S("breadcrumb/deselectAll"),on=S("breadcrumb/deselectAllNonBreadcrumbs");var Qt=S("facet/updateFacetAutoSelection",e=>y(e,{allow:new J({required:!0})}));var ls=class extends ga{constructor(t){super(t);this.getState=t;}get activeInstantResultQuery(){let t=this.getState().instantResults;for(let r in t)for(let a in t[r].cache)if(t[r].cache[a].isActive)return t[r].q;return null}get activeInstantResultCache(){let t=this.getState().instantResults;for(let r in t)for(let a in t[r].cache)if(t[r].cache[a].isActive)return t[r].cache[a];return null}getSearchUID(){var r;return ((r=this.activeInstantResultCache)==null?void 0:r.searchUid)||super.getSearchUID()}getSearchEventRequestPayload(){let t=super.getSearchEventRequestPayload(),r=this.activeInstantResultQuery||t.queryText;return {...t,queryText:r}}};var bg=e=>Q("analytics/instantResult/open",M.Click,(t,r)=>(_e(e),t.makeDocumentOpen(Ve(e,r),Le(e))),t=>new ls(t)),Fg=()=>Q("analytics/instantResult/searchboxAsYouType",M.Search,e=>e.makeSearchboxAsYouType(),e=>new ls(e));var hd={id:q},vF={...hd,q:ie},sn=S("instantResults/register",e=>y(e,hd)),Qr=S("instantResults/updateQuery",e=>y(e,vF)),cn=S("instantResults/clearExpired",e=>y(e,hd));var ds=new U({required:!0,min:0}),un=S("pagination/registerNumberOfResults",e=>y(e,ds)),ln=S("pagination/updateNumberOfResults",e=>y(e,ds)),dn=S("pagination/registerPage",e=>y(e,ds)),Lt=S("pagination/updatePage",e=>y(e,ds)),pn=S("pagination/nextPage"),fn=S("pagination/previousPage");var ot=S("query/updateQuery",e=>y(e,{q:new O,enableQuerySyntax:new J}));var mn=async(e,t)=>{var r,a,n,o;return {accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.search.apiBaseUrl,locale:e.configuration.search.locale,debug:e.debug,tab:e.configuration.analytics.originLevel2,referrer:e.configuration.analytics.originLevel3,timezone:e.configuration.search.timezone,...e.configuration.analytics.enabled&&{visitorId:await Fe(e.configuration.analytics),actionsHistory:bt.getHistory()},...((r=e.advancedSearchQueries)==null?void 0:r.aq)&&{aq:e.advancedSearchQueries.aq},...((a=e.advancedSearchQueries)==null?void 0:a.cq)&&{cq:e.advancedSearchQueries.cq},...((n=e.advancedSearchQueries)==null?void 0:n.lq)&&{lq:e.advancedSearchQueries.lq},...((o=e.advancedSearchQueries)==null?void 0:o.dq)&&{dq:e.advancedSearchQueries.dq},...e.context&&{context:e.context.contextValues},...e.fields&&!e.fields.fetchAllFields&&{fieldsToInclude:e.fields.fieldsToInclude},...e.dictionaryFieldContext&&{dictionaryFieldContext:e.dictionaryFieldContext.contextValues},...e.pipeline&&{pipeline:e.pipeline},...e.query&&{q:e.query.q,enableQuerySyntax:e.query.enableQuerySyntax},...e.searchHub&&{searchHub:e.searchHub},...e.sortCriteria&&{sortCriteria:e.sortCriteria},...e.configuration.analytics.enabled&&await Nr(e.configuration.analytics,t),...e.excerptLength&&!re(e.excerptLength.length)&&{excerptLength:e.excerptLength.length},...e.configuration.search.authenticationProviders.length&&{authentication:e.configuration.search.authenticationProviders.join(",")}}};var gn=S("didYouMean/enable"),ps=S("didYouMean/disable"),jt=S("didYouMean/correction",e=>y(e,q));var fs=()=>Q("analytics/didyoumean/click",M.Search,e=>e.makeDidYouMeanClick()),Ag=()=>Q("analytics/didyoumean/automatic",M.Search,e=>e.makeDidYouMeanAutomatic());var Sd=S("history/undo"),yd=S("history/redo"),Lr=S("history/snapshot"),mi=te("history/back",async(e,{dispatch:t})=>{t(Sd()),await t(ce());}),ms=te("history/forward",async(e,{dispatch:t})=>{t(yd()),await t(ce());}),ce=te("history/change",async(e,{getState:t})=>t().history.present);var $e=()=>({cq:"",cqWasSet:!1,aq:"",aqWasSet:!1,lq:"",lqWasSet:!1,dq:"",dqWasSet:!1,defaultFilters:{cq:"",aq:"",lq:"",dq:""}});function it(){return {contextValues:{}}}var We=()=>!1;function Ut(){return {contextValues:{}}}function hn(){return {enabled:!0}}function hr(){return {freezeFacetOrder:!1,facets:{}}}function jr(){return []}function Sn(){return {}}function gs(e){return e?e.expiresAt&&Date.now()>=e.expiresAt:!1}function Ae(){return {firstResult:0,defaultNumberOfResults:10,numberOfResults:10,totalCountFiltered:0}}function Sa(){return {}}var Ur=(r=>(r.Ascending="ascending",r.Descending="descending",r))(Ur||{}),Bt=(o=>(o.Relevancy="relevancy",o.QRE="qre",o.Date="date",o.Field="field",o.NoSort="nosort",o))(Bt||{}),Sr=e=>{if(Ya(e))return e.map(t=>Sr(t)).join(",");switch(e.by){case"relevancy":case"qre":case"nosort":return e.by;case"date":return `date ${e.order}`;case"field":return `@${e.field} ${e.order}`;default:return ""}},gi=()=>({by:"relevancy"}),vd=e=>({by:"date",order:e}),Cd=(e,t)=>({by:"field",order:t,field:e}),xd=()=>({by:"qre"}),Rd=()=>({by:"nosort"}),Pg=new L({values:{by:new Tt({enum:Bt,required:!0}),order:new Tt({enum:Ur}),field:new O}});function et(){return Sr(gi())}function ya(){return {}}function va(){return {}}function hs(){return hi({})}function hi(e){var t,r;return {context:e.context||it(),dictionaryFieldContext:e.dictionaryFieldContext||Ut(),facetSet:e.facetSet||xt(),numericFacetSet:e.numericFacetSet||Ct(),dateFacetSet:e.dateFacetSet||vt(),categoryFacetSet:e.categoryFacetSet||yt(),pagination:e.pagination||Ae(),query:e.query||ve(),tabSet:e.tabSet||va(),advancedSearchQueries:e.advancedSearchQueries||$e(),staticFilterSet:e.staticFilterSet||ya(),querySet:e.querySet||Sa(),instantResults:e.instantResults||Sn(),sortCriteria:e.sortCriteria||et(),pipeline:e.pipeline||nt(),searchHub:e.searchHub||Ee(),facetOptions:e.facetOptions||hr(),facetOrder:(t=e.facetOrder)!=null?t:jr(),debug:(r=e.debug)!=null?r:We()}}var CF=new L({values:{undoneQuery:ie},options:{required:!0}}),Ss=()=>Q("analytics/trigger/query",M.Search,(e,t)=>{var r;return ((r=t.triggers)==null?void 0:r.queryModification.newQuery)?e.makeTriggerQuery():null}),ys=e=>Q("analytics/trigger/query/undo",M.Search,t=>(y(e,CF),t.makeUndoTriggerQuery(e))),vs=()=>Q("analytics/trigger/notify",M.Search,(e,t)=>{var r;return ((r=t.triggers)==null?void 0:r.notifications.length)?e.makeTriggerNotify({notifications:t.triggers.notifications}):null});var yn=S("trigger/query/ignore",e=>y(e,new O({emptyAllowed:!0,required:!0}))),Rs=S("trigger/query/modification",e=>y(e,new L({values:{originalQuery:oe,modification:oe}})));var bd=()=>Q("search/logFetchMoreResults",M.Search,e=>e.makeFetchMoreResults()),vn=e=>Q("search/queryError",M.Search,(t,r)=>{var a,n,o,i;return t.makeQueryError({query:((a=r.query)==null?void 0:a.q)||ve().q,aq:((n=r.advancedSearchQueries)==null?void 0:n.aq)||$e().aq,cq:((o=r.advancedSearchQueries)==null?void 0:o.cq)||$e().cq,dq:((i=r.advancedSearchQueries)==null?void 0:i.dq)||$e().dq,errorType:e.type,errorMessage:e.message})});var vi=be(bs()),Og=be(Ig());var Fs=be(bs()),wg=be(Eg());Fs.default.extend(wg.default);var Si="YYYY/MM/DD@HH:mm:ss",xF="1401-01-01";function Ca(e,t){let r=(0, Fs.default)(e,t);return !r.isValid()&&!t?(0, Fs.default)(e,Si):r}function yi(e){return e.format(Si)}function kg(e){return yi(Ca(e))===e}function As(e,t){let r=Ca(e,t);if(!r.isValid()){let a=". Please provide a date format string in the configuration options. See https://day.js.org/docs/en/parse/string-format for more information.",n=` with the format "${t}""`;throw new Error(`Could not parse the provided date "${e}"${t?n:a}`)}kd(r);}function kd(e){if(e.isBefore(xF))throw new Error(`Date is before year 1401, which is unsupported by the API: ${e}`)}vi.default.extend(Og.default);var qg=["past","now","next"],Tg=["minute","hour","day","week","month","quarter","year"],RF=e=>{let t=e==="now";return {amount:new U({required:!t,min:1}),unit:new O({required:!t,constrainTo:Tg}),period:new O({required:!0,constrainTo:qg})}};function xa(e){if(typeof e=="string"&&!_t(e))throw new Error(`The value "${e}" is not respecting the relative date format "period-amount-unit"`);let t=typeof e=="string"?Od(e):e;new Z(RF(t.period)).validate(t);let r=Vg(t),a=JSON.stringify(t);if(!r.isValid())throw new Error(`Date is invalid: ${a}`);kd(r);}function Dg(e){let{period:t,amount:r,unit:a}=e;switch(t){case"past":case"next":return `${t}-${r}-${a}`;case"now":return t}}function Vg(e){let{period:t,amount:r,unit:a}=e;switch(t){case"past":return (0, vi.default)().subtract(r,a);case"next":return (0, vi.default)().add(r,a);case"now":return (0, vi.default)()}}function Ci(e){return yi(Vg(Od(e)))}function Ng(e){return e.toLocaleLowerCase().split("-")}function _t(e){let[t,r,a]=Ng(e);if(t==="now")return !0;if(!qg.includes(t)||!Tg.includes(a))return !1;let n=parseInt(r);return !(isNaN(n)||n<=0)}function Mg(e){return !!e&&typeof e=="object"&&"period"in e}function Od(e){let[t,r,a]=Ng(e);return t==="now"?{period:"now"}:{period:t,amount:r?parseInt(r):void 0,unit:a||void 0}}function bF(e){return xa(e),Od(e)}function Qg(e){return e.type==="dateRange"}function Lg(e){return `start${e}`}function jg(e){return `end${e}`}var FF=()=>({dateFacetValueMap:{}});function AF(e,t,r){let a=e.start,n=e.end;return _t(a)&&(a=Ci(a),r.dateFacetValueMap[t][Lg(a)]=e.start),_t(n)&&(n=Ci(n),r.dateFacetValueMap[t][jg(n)]=e.end),{...e,start:a,end:n}}function PF(e,t){if(Qg(e)){let{facetId:r,currentValues:a}=e;return t.dateFacetValueMap[r]={},{...e,currentValues:a.map(n=>AF(n,r,t))}}return e}function Ps(e){var a;let t=FF();return {request:{...e,facets:(a=e.facets)==null?void 0:a.map(n=>PF(n,t))},mappings:t}}function IF(e,t,r){return {...e,start:r.dateFacetValueMap[t][Lg(e.start)]||e.start,end:r.dateFacetValueMap[t][jg(e.end)]||e.end}}function EF(e,t){return e.facetId in t.dateFacetValueMap}function wF(e,t){return EF(e,t)?{...e,values:e.values.map(r=>IF(r,e.facetId,t))}:e}function Ug(e,t){var r;return "success"in e?{success:{...e.success,facets:(r=e.success.facets)==null?void 0:r.map(n=>wF(n,t))}}:e}function Cn(e,t){let r={};e.forEach(o=>r[o.facetId]=o);let a=[];t.forEach(o=>{o in r&&(a.push(r[o]),delete r[o]);});let n=Object.values(r);return [...a,...n]}function yr(e){return Object.values(e).map(t=>t.request)}var Ra=1,xi=5e3;var st=async(e,t)=>{var i;let r=TF(e),a=kF(e),n=await mn(e,t),o=()=>e.pagination?e.pagination.firstResult+e.pagination.numberOfResults>xi?xi-e.pagination.firstResult:e.pagination.numberOfResults:void 0;return Ps({...n,...e.didYouMean&&{enableDidYouMean:e.didYouMean.enableDidYouMean},...r&&{cq:r},...a.length&&{facets:a},...e.pagination&&{numberOfResults:o(),firstResult:e.pagination.firstResult},...e.facetOptions&&{facetOptions:{freezeFacetOrder:e.facetOptions.freezeFacetOrder}},...((i=e.folding)==null?void 0:i.enabled)&&{filterField:e.folding.fields.collection,childField:e.folding.fields.parent,parentField:e.folding.fields.child,filterFieldRange:e.folding.filterFieldRange}})};function kF(e){var t;return Cn(OF(e),(t=e.facetOrder)!=null?t:[])}function OF(e){return qF(e).filter(({facetId:t})=>{var r,a,n;return (n=(a=(r=e.facetOptions)==null?void 0:r.facets[t])==null?void 0:a.enabled)!=null?n:!0})}function qF(e){var t,r,a,n;return [...yr((t=e.facetSet)!=null?t:{}),...Bg((r=e.numericFacetSet)!=null?r:{}),...Bg((a=e.dateFacetSet)!=null?a:{}),...yr((n=e.categoryFacetSet)!=null?n:{})]}function Bg(e){return yr(e).map(t=>{let a=t.currentValues.find(({state:n})=>n==="selected");return t.generateAutomaticRanges&&!a?{...t,currentValues:[]}:t})}function TF(e){var o;let t=((o=e.advancedSearchQueries)==null?void 0:o.cq.trim())||"",r=Object.values(e.tabSet||{}).find(i=>i.isActive),a=(r==null?void 0:r.expression.trim())||"",n=DF(e);return [t,a,...n].filter(i=>!!i).join(" AND ")}function DF(e){return Object.values(e.staticFilterSet||{}).map(r=>{let a=r.values.filter(o=>o.state==="selected"&&!!o.expression.trim()),n=a.map(o=>o.expression).join(" OR ");return a.length>1?`(${n})`:n})}var ba=class{constructor(t,r=a=>{this.dispatch(ot({q:a}));}){this.config=t;this.onUpdateQueryForCorrection=r;}async fetchFromAPI({mappings:t,request:r},a){var u;let n=new Date().getTime(),o=Ug(await this.extra.apiClient.search(r,a),t),i=new Date().getTime()-n,s=((u=this.getState().query)==null?void 0:u.q)||"";return {response:o,duration:i,queryExecuted:s,requestExecuted:r}}async process(t){var r,a,n;return (n=(a=(r=this.processQueryErrorOrContinue(t))!=null?r:await this.processQueryCorrectionsOrContinue(t))!=null?a:await this.processQueryTriggersOrContinue(t))!=null?n:this.processSuccessReponse(t)}processQueryErrorOrContinue(t){return ge(t.response)?(this.dispatch(vn(t.response.error)),this.rejectWithValue(t.response.error)):null}async processQueryCorrectionsOrContinue(t){var s;let r=this.getState(),a=this.getSuccessResponse(t);if(!a||((s=r.didYouMean)==null?void 0:s.enableDidYouMean)===!1||a.results.length!==0||a.queryCorrections.length===0)return null;let n=this.getCurrentQuery(),{correctedQuery:o}=a.queryCorrections[0],i=await this.automaticallyRetryQueryWithCorrection(o);return ge(i.response)?(this.dispatch(vn(i.response.error)),this.rejectWithValue(i.response.error)):(this.analyticsAction&&this.analyticsAction()(this.dispatch,()=>this.getStateAfterResponse(t.queryExecuted,t.duration,r,a),this.extra),this.dispatch(Lr(hi(this.getState()))),{...i,response:{...i.response.success,queryCorrections:a.queryCorrections},automaticallyCorrected:!0,originalQuery:n,analyticsAction:Ag()})}async processQueryTriggersOrContinue(t){var s,u;let r=this.getSuccessResponse(t);if(!r)return null;let a=((s=r.triggers.find(c=>c.type==="query"))==null?void 0:s.content)||"";if(!a)return null;if(((u=this.getState().triggers)==null?void 0:u.queryModification.queryToIgnore)===a)return this.dispatch(yn("")),null;this.analyticsAction&&await this.dispatch(this.analyticsAction);let o=this.getCurrentQuery(),i=await this.automaticallyRetryQueryWithTriggerModification(a);return ge(i.response)?(this.dispatch(vn(i.response.error)),this.rejectWithValue(i.response.error)):(this.dispatch(Lr(hi(this.getState()))),{...i,response:{...i.response.success},automaticallyCorrected:!1,originalQuery:o,analyticsAction:Ss()})}processSuccessReponse(t){return this.dispatch(Lr(hi(this.getState()))),{...t,response:this.getSuccessResponse(t),automaticallyCorrected:!1,originalQuery:this.getCurrentQuery(),analyticsAction:this.analyticsAction}}getSuccessResponse(t){return eg(t.response)?t.response.success:null}async automaticallyRetryQueryWithCorrection(t){this.onUpdateQueryForCorrection(t);let r=await this.fetchFromAPI(await st(this.getState()),{origin:"mainSearch"});return this.dispatch(jt(t)),r}async automaticallyRetryQueryWithTriggerModification(t){return this.dispatch(Rs({newQuery:t,originalQuery:this.getCurrentQuery()})),this.onUpdateQueryForCorrection(t),await this.fetchFromAPI(await st(this.getState()),{origin:"mainSearch"})}getStateAfterResponse(t,r,a,n){var o,i;return {...a,query:{q:t,enableQuerySyntax:(i=(o=a.query)==null?void 0:o.enableQuerySyntax)!=null?i:ve().enableQuerySyntax},search:{...Ze(),duration:r,response:n,results:n.results}}}getCurrentQuery(){var r;let t=this.getState();return ((r=t.query)==null?void 0:r.q)!==void 0?t.query.q:""}get extra(){return this.config.extra}getState(){return this.config.getState()}get dispatch(){return this.config.dispatch}get analyticsAction(){return this.config.analyticsAction}get rejectWithValue(){return this.config.rejectWithValue}};var Is=te("search/prepareForSearchWithQuery",(e,t)=>{let{dispatch:r}=t;y(e,{q:new O,enableQuerySyntax:new J,clearFilters:new J}),e.clearFilters&&(r(ke()),r(on())),r(Qt({allow:!0})),r(ot({q:e.q,enableQuerySyntax:e.enableQuerySyntax})),r(Lt(1));}),T=te("search/executeSearch",async(e,t)=>{let r=t.getState();_g(r);let{analyticsClientMiddleware:a,preprocessRequest:n,logger:o}=t.extra,{description:i}=await e.prepare({getState:()=>t.getState(),analyticsClientMiddleware:a,preprocessRequest:n,logger:o}),s=await st(r,i),u=new ba({...t,analyticsAction:e}),c=await u.fetchFromAPI(s,{origin:"mainSearch"});return await u.process(c)}),Ye=te("search/fetchPage",async(e,t)=>{let r=t.getState();_g(r);let{analyticsClientMiddleware:a,preprocessRequest:n,logger:o}=t.extra,{description:i}=await e.prepare({getState:()=>t.getState(),analyticsClientMiddleware:a,preprocessRequest:n,logger:o}),s=new ba({...t,analyticsAction:e}),u=await st(r,i),c=await s.fetchFromAPI(u,{origin:"mainSearch"});return await s.process(c)}),ct=te("search/fetchMoreResults",async(e,t)=>{let r=t.getState(),{analyticsClientMiddleware:a,preprocessRequest:n,logger:o}=t.extra,{description:i}=await bd().prepare({getState:()=>t.getState(),analyticsClientMiddleware:a,preprocessRequest:n,logger:o}),s=new ba({...t,analyticsAction:bd()}),u=await VF(r,i),c=await s.fetchFromAPI(u,{origin:"mainSearch"});return await s.process(c)}),Ke=te("search/fetchFacetValues",async(e,t)=>{let r=t.getState(),{analyticsClientMiddleware:a,preprocessRequest:n,logger:o}=t.extra,{description:i}=await e.prepare({getState:()=>t.getState(),analyticsClientMiddleware:a,preprocessRequest:n,logger:o}),s=new ba({...t,analyticsAction:e}),u=await MF(r,i),c=await s.fetchFromAPI(u,{origin:"facetValues"});return await s.process(c)}),Br=te("search/fetchInstantResults",async(e,t)=>{y(e,{id:q,q,maxResultsPerQuery:new U({required:!0,min:1}),cacheTimeout:new U});let{q:r,maxResultsPerQuery:a}=e,n=t.getState(),o=new ba({...t,analyticsAction:Fg()},c=>{t.dispatch(Qr({q:c,id:e.id}));}),i=await NF(n,r,a),s=await o.fetchFromAPI(i,{origin:"instantResults",disableAbortWarning:!0}),u=await o.process(s);return "response"in u?{results:u.response.results,searchUid:u.response.searchUid,analyticsAction:u.analyticsAction}:u}),VF=async(e,t)=>{var a,n,o,i;let r=await st(e,t);return r.request={...r.request,firstResult:((n=(a=e.pagination)==null?void 0:a.firstResult)!=null?n:0)+((i=(o=e.search)==null?void 0:o.results.length)!=null?i:0)},r},NF=async(e,t,r)=>{let a=await mn(e);return Ps({...a,...e.didYouMean&&{enableDidYouMean:e.didYouMean.enableDidYouMean},numberOfResults:r,q:t})},MF=async(e,t)=>{let r=await st(e,t);return r.request.numberOfResults=0,r},_g=e=>{var t;e.configuration.analytics.enabled&&bt.addElement({name:"Query",...((t=e.query)==null?void 0:t.q)&&{value:e.query.q},time:JSON.stringify(new Date)});};var Es=e=>t=>r=>{var o,i;let a=(o=r.payload)==null?void 0:o.analyticsAction;a!==void 0&&((i=r.payload)==null||delete i.analyticsAction);let n=t(r);return r.type===T.fulfilled.type&&a===void 0&&console.error("No analytics action associated with search:",r),r.type===nn.fulfilled&&a===void 0&&console.error("No analytics action associated with recommendation:",r),r.type===an.fulfilled&&a===void 0&&console.error("No analytics action associated with product recommendation:",r),a!==void 0&&e.dispatch(a),n};function QF(e){return e.instantlyCallable}var ws=()=>e=>t=>e(QF(t)?t():t);var ks=e=>()=>t=>r=>{var n;if(!r.error)return t(r);let a=r.error;if(((n=r.payload)==null?void 0:n.ignored)||e.error(a.stack||a.message||a.name||"Error",`Action dispatch error ${r.type}`,r),r.error.name!=="SchemaValidationError")return t(r)},Os=e=>t=>r=>a=>(e.debug({action:a,nextState:t.getState()},`Action dispatched: ${a.type}`),r(a));var qs=()=>({caseAssistId:"",locale:"en-US"});var Ts=()=>({status:{loading:!1,error:null,lastResponseId:""},fields:{}});var Ds=()=>({});var Vs=be(bs()),zg=be($g()),Wg=be(Hg());Vs.default.extend(Wg.default);Vs.default.extend(zg.default);var Nd="/rest/search/v2",Ns="/rest/ua",Ne=()=>({organizationId:"",accessToken:"",platformUrl:as(),search:{apiBaseUrl:`${as()}${Nd}`,locale:"en-US",timezone:Vs.default.tz.guess(),authenticationProviders:[]},analytics:{enabled:!0,apiBaseUrl:`${ud()}${Ns}`,originContext:"Search",originLevel2:"default",originLevel3:"default",anonymous:!1,deviceId:"",userDisplayName:"",documentLocation:""}});var Ms=()=>({status:{loading:!1,error:null,lastResponseId:""},documents:[]});function _r(){return {uniqueId:"",content:"",isLoading:!1,position:-1,resultsWithPreview:[]}}function Yg(e={}){return {configuration:Ne(),caseAssistConfiguration:qs(),caseField:Ts(),caseInput:Ds(),documentSuggestion:Ms(),debug:We(),version:"unit-testing-version",resultPreview:_r(),searchHub:Ee(),...e}}be(ri());var Fa=e=>e;function Md(){return {results:[],loading:!1}}var Qd=()=>({caseContext:{},caseId:"",caseNumber:""});var Qs=()=>({correctedQuery:"",wordCorrections:[],originalQuery:""});function Ri(){return {enableDidYouMean:!1,wasCorrectedTo:"",wasAutomaticallyCorrected:!1,queryCorrection:Qs(),originalQuery:""}}function Aa(){return {}}var Ld=["author","language","urihash","objecttype","collection","source","permanentid"],Gg=[...Ld,"date","filetype","parents"],UF=[...Gg,"ec_price","ec_name","ec_description","ec_brand","ec_category","ec_item_group_id","ec_shortdesc","ec_thumbnails","ec_images","ec_promo_price","ec_in_stock","ec_rating"],Pa=()=>({fieldsToInclude:Ld,fetchAllFields:!1,fieldsDescription:[]});var jd=()=>({insightId:""});var Ud=()=>({loading:!1,config:void 0});var Bd=()=>({});function xn(){return {}}var Ls=()=>({url:"",clientId:"",additionalFields:[],advancedParameters:{debug:!1},products:[],facets:{results:[]},error:null,isLoading:!1,responseId:""});var Ia=(r=>(r.Relevance="relevance",r.Fields="fields",r))(Ia||{}),Jg=(r=>(r.Ascending="asc",r.Descending="desc",r))(Jg||{}),Xg=()=>({by:"relevance"});function js(){return Xg()}function Zg(e={}){return {configuration:Ne(),productListing:Ls(),sort:js(),facetSearchSet:Aa(),categoryFacetSet:yt(),categoryFacetSearchSet:xn(),dateFacetSet:vt(),facetOptions:hr(),facetOrder:jr(),facetSet:xt(),numericFacetSet:Ct(),pagination:Ae(),version:"unit-testing-version",context:it(),...e}}function eh(e={}){return {configuration:Ne(),context:it(),dictionaryFieldContext:Ut(),searchHub:Ee(),productRecommendations:en(),version:"unit-testing-version",...e}}function th(e={}){return {configuration:Ne(),advancedSearchQueries:$e(),context:it(),dictionaryFieldContext:Ut(),fields:Pa(),searchHub:Ee(),pipeline:nt(),recommendation:Mr(),debug:We(),version:"unit-testing-version",pagination:Ae(),...e}}var rh=be(ri());var Us=e=>e,Bs=e=>e,_s=e=>e;function ah(e){return new pi({logger:(0, rh.default)({level:"silent"}),preprocessRequest:Fa,postprocessSearchResponseMiddleware:Us,postprocessFacetSearchResponseMiddleware:Bs,postprocessQuerySuggestResponseMiddleware:_s,...e})}var $s=e=>({past:[],present:e,future:[]}),BF=e=>{let{past:t,present:r,future:a}=e;if(!r||t.length===0)return e;let n=t[t.length-1];return {past:t.slice(0,t.length-1),present:n,future:[r,...a]}},_F=e=>{let{past:t,present:r,future:a}=e;if(!r||a.length===0)return e;let n=a[0],o=a.slice(1);return {past:[...t,r],present:n,future:o}},$F=e=>{let{action:t,state:r,reducer:a}=e,{past:n,present:o}=r,i=a(o,t);return o?o===i?r:{past:[...n,o],present:i,future:[]}:$s(i)},nh=e=>{let{actionTypes:t,reducer:r}=e,a=$s();return (n=a,o)=>{switch(o.type){case t.undo:return BF(n);case t.redo:return _F(n);case t.snapshot:return $F({state:n,reducer:r,action:o});default:return n}}};function Hs(){return {length:void 0}}var Rn=()=>({enabled:!1,fields:{collection:"foldingcollection",parent:"foldingparent",child:"foldingchild"},filterFieldRange:2,collections:{}});var bi=()=>({liked:!1,disliked:!1,expanded:!1,feedbackModalOpen:!1,relatedQuestions:[]});function zs(){return {queries:[],maxLength:10}}function Ws(){return {results:[],maxLength:10}}function Ys(){return {}}var Ks=()=>({redirectTo:"",query:"",executions:[],notifications:[],queryModification:{originalQuery:"",newQuery:"",queryToIgnore:""}});function Gs(e={}){return {configuration:Ne(),advancedSearchQueries:$e(),staticFilterSet:ya(),facetSet:xt(),dateFacetSet:vt(),numericFacetSet:Ct(),categoryFacetSet:yt(),facetSearchSet:Aa(),categoryFacetSearchSet:xn(),facetOptions:hr(),pagination:Ae(),query:ve(),querySet:Sa(),instantResults:Sn(),tabSet:va(),querySuggest:{},search:Ze(),sortCriteria:et(),context:it(),dictionaryFieldContext:Ut(),didYouMean:Ri(),fields:Pa(),history:$s(hs()),pipeline:nt(),facetOrder:jr(),searchHub:Ee(),debug:We(),resultPreview:_r(),version:"unit-testing-version",folding:Rn(),triggers:Ks(),questionAnswering:bi(),standaloneSearchBoxSet:Ys(),recentResults:Ws(),recentQueries:zs(),excerptLength:Hs(),...e}}function sh(e={}){let t=Fi(e,Gs);return {...t,executeFirstSearch:jest.fn(),executeFirstSearchAfterStandaloneSearchBoxRedirect:jest.fn(),apiClient:t.apiClient}}function ch(e={}){return Fi(e,th)}function uh(e={}){return Fi(e,eh)}function lh(e={}){return Fi(e,Zg)}function dh(e={}){return Fi(e,Yg)}function Fi(e={},t,r=HF){let a=(0, oh.default)({level:"silent"}),n=ph(e,t),{store:o,apiClient:i}=r(a,n),s=o(n),u=()=>{},{state:c,...l}=e;return {store:s,apiClient:i,state:ph(e,t),subscribe:jest.fn(()=>u),get dispatch(){return s.dispatch},get actions(){return s.getActions()},findAsyncAction(p){let f=this.actions.find(d=>d.type===p.type);return zF(f)?f:void 0},logger:a,addReducers:jest.fn(),enableAnalytics:jest.fn(),disableAnalytics:jest.fn(),...l}}function ph(e,t){let r=e.state||t();return r.configuration.analytics.enabled=!1,r}var HF=e=>{let t={apiClient:ah({logger:e}),validatePayload:ze,logger:e};return {store:(0, ih.default)([ws,ks(e),Es,zo.withExtraArgument(t),...$i(),Os(e)]),apiClient:t.apiClient}};function zF(e){return e?"meta"in e:!1}function Js(e={}){return {urihash:"",parents:"",sfid:"",sfparentid:"",sfinsertedbyid:"",documenttype:"",sfcreatedbyid:"",permanentid:"",date:0,objecttype:"",sourcetype:"",sftitle:"",size:0,sffeeditemid:"",clickableuri:"",sfcreatedby:"",source:"",collection:"",connectortype:"",filetype:"",sfcreatedbyname:"",sflikecount:0,language:[],...e}}function fh(e={}){return {title:"",uri:"",printableUri:"",clickUri:"",uniqueId:"",excerpt:"",firstSentences:"",summary:null,flags:"",hasHtmlVersion:!1,score:0,percentScore:0,rankingInfo:null,isTopResult:!1,isRecommendation:!1,titleHighlights:[],firstSentencesHighlights:[],excerptHighlights:[],printableUriHighlights:[],summaryHighlights:[],absentTerms:[],raw:Js(),...e}}var gh={};nl(gh,{escape:()=>bn,getHighlightedSuggestion:()=>_d,highlightString:()=>WF});function WF(e){if(is(e.openingDelimiter)||is(e.closingDelimiter))throw Error("delimiters should be a non-empty string");if(re(e.content)||is(e.content))return e.content;if(e.highlights.length===0)return bn(e.content);let t=e.content.length,r="",a=0;for(let n=0;n<e.highlights.length;n++){let o=e.highlights[n],i=o.offset,s=i+o.length;if(s>t)break;r+=bn(e.content.slice(a,i)),r+=e.openingDelimiter,r+=bn(e.content.slice(i,s)),r+=e.closingDelimiter,a=s;}return a!==t&&(r+=bn(e.content.slice(a))),r}function _d(e,t){return e=bn(e),e.replace(/\[(.*?)\]|\{(.*?)\}|\((.*?)\)/g,(r,a,n,o)=>a?$d(a,t.notMatchDelimiters):n?$d(n,t.exactMatchDelimiters):o?$d(o,t.correctionDelimiters):r)}function $d(e,t){return t?t.open+e+t.close:e}function bn(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},r="(?:"+Object.keys(t).join("|")+")",a=RegExp(r),n=RegExp(r,"g");return a.test(e)?e.replace(n,o=>t[o]):e}var Xs=()=>Q("analytics/interface/load",M.Search,e=>e.makeInterfaceLoad()),$r=()=>Q("analytics/interface/change",M.Search,(e,t)=>e.makeInterfaceChange({interfaceChangeTo:t.configuration.analytics.originLevel2})),Zs=()=>Q("analytics/interface/searchFromLink",M.Search,e=>e.makeSearchFromLink()),ec=e=>Q("analytics/interface/omniboxFromLink",M.Search,t=>t.makeOmniboxFromLink(e));var zd=()=>oe,vh=()=>q,$t=S("configuration/updateBasicConfiguration",e=>y(e,{accessToken:oe,organizationId:oe,platformUrl:oe})),ut=S("configuration/updateSearchConfiguration",e=>y(e,{apiBaseUrl:oe,pipeline:new O({required:!1,emptyAllowed:!0}),searchHub:oe,timezone:oe,locale:oe,authenticationProviders:new K({required:!1,each:q})})),Hr=S("configuration/updateAnalyticsConfiguration",e=>(cs()&&(e.enabled=!1),y(e,{enabled:new J({default:!0}),originContext:zd(),originLevel2:zd(),originLevel3:zd(),apiBaseUrl:oe,runtimeEnvironment:new de,anonymous:new J({default:!1}),deviceId:oe,userDisplayName:oe,documentLocation:oe}))),Fn=S("configuration/analytics/disable"),An=S("configuration/analytics/enable"),tc=S("configuration/analytics/originlevel2",e=>y(e,{originLevel2:vh()})),rc=S("configuration/analytics/originlevel3",e=>y(e,{originLevel3:vh()}));var vr=(e,t)=>{let r=e;return re(r[t])?re(e.raw[t])?null:e.raw[t]:r[t]},Ch=e=>t=>e.every(r=>!re(vr(t,r))),xh=e=>t=>e.every(r=>re(vr(t,r))),Rh=(e,t)=>r=>{let a=Fh(e,r);return t.some(n=>a.some(o=>`${o}`.toLowerCase()===n.toLowerCase()))},bh=(e,t)=>r=>{let a=Fh(e,r);return t.every(n=>a.every(o=>`${o}`.toLowerCase()!==n.toLowerCase()))},Fh=(e,t)=>{let r=vr(t,e);return os(r)?r:[r]};function ac(e){return e.search.response.searchUid!==""}function Ah(e,t,r){return e.search.results.find(a=>vr(a,t)===r)}function Ph(e){let t={...e},r,a=n=>(o,i)=>{let s=n(o,i);return r?r(s,i):s};return {get combinedReducer(){return a((0, g.combineReducers)(t))},containsAll(n){return Object.keys(n).every(i=>i in t)},add(n){Object.keys(n).filter(o=>!(o in t)).forEach(o=>t[o]=n[o]);},addCrossReducer(n){r=n;}}}var nc={q:new O,enableQuerySyntax:new J,aq:new O,cq:new O,firstResult:new U({min:0}),numberOfResults:new U({min:0}),sortCriteria:new O,f:new L,cf:new L,nf:new L,df:new L,debug:new J,sf:new L,tab:new O};var ue=S("searchParameters/restore",e=>y(e,nc));var zr=()=>new O({required:!1,emptyAllowed:!0}),oc=S("advancedSearchQueries/update",e=>y(e,{aq:zr(),cq:zr(),lq:zr(),dq:zr()})),ic=S("advancedSearchQueries/register",e=>y(e,{aq:zr(),cq:zr(),lq:zr(),dq:zr()}));k($e(),e=>{e.addCase(oc,(t,r)=>{let{aq:a,cq:n,lq:o,dq:i}=r.payload;De(a)||(t.aq=a,t.aqWasSet=!0),De(n)||(t.cq=n,t.cqWasSet=!0),De(o)||(t.lq=o,t.lqWasSet=!0),De(i)||(t.dq=i,t.dqWasSet=!0);}).addCase(ic,(t,r)=>{let{aq:a,cq:n,lq:o,dq:i}=r.payload;De(a)||(t.defaultFilters.aq=a,t.aqWasSet||(t.aq=a)),De(n)||(t.defaultFilters.cq=n,t.cqWasSet||(t.cq=n)),De(o)||(t.defaultFilters.lq=o,t.lqWasSet||(t.lq=o)),De(i)||(t.defaultFilters.dq=i,t.dqWasSet||(t.dq=i));}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.advancedSearchQueries)!=null?n:t}).addCase(ue,(t,r)=>{let{aq:a,cq:n}=r.payload;De(a)||(t.aq=a,t.aqWasSet=!0),De(n)||(t.cq=n,t.cqWasSet=!0);});});var Eh=new L({options:{required:!0},values:{articleLanguage:oe,articlePublishStatus:oe,articleVersionNumber:oe,caseId:q,knowledgeArticleId:oe,name:oe,permanentId:oe,resultUrl:oe,source:oe,title:q,uriHash:oe}}),wh=S("insight/attachToCase/setAttachedResults",e=>y(e,{results:new K({each:Eh}),loading:new J({required:!1,default:!1})})),kh=S("insight/attachToCase/attach",e=>qh(e)),Oh=S("insight/attachToCase/detach",e=>qh(e)),qh=e=>re(e.result.permanentId)&&re(e.result.uriHash)?{payload:e,error:Ft(new fa("Either permanentId or uriHash is required"))}:y(e,{result:Eh});k(Md(),e=>{e.addCase(wh,(t,r)=>{var o;let{results:a,loading:n}=r.payload;"results"in t&&((o=t.results)==null?void 0:o.length)>0||(t.results=a,n&&(t.loading=n));}).addCase(kh,(t,r)=>{(!re(r.payload.result.permanentId)||!re(r.payload.result.uriHash))&&(t.results=[...t.results,r.payload.result]);}).addCase(Oh,(t,r)=>{t.results=t.results.filter(a=>KF(a,r.payload.result));});});var KF=(e,t)=>{let r=!re(e.permanentId)&&(e==null?void 0:e.permanentId)===(t==null?void 0:t.permanentId),a=!re(e.uriHash)&&(e==null?void 0:e.uriHash)===(t==null?void 0:t.uriHash);return !(e.caseId===t.caseId)||!r&&!a};var Th=S("caseAssistConfiguration/set",e=>y(e,{caseAssistId:q,locale:oe}));k(qs(),e=>{e.addCase(Th,(t,r)=>{t.caseAssistId=r.payload.caseAssistId,t.locale=r.payload.locale;});});var Dh=S("insight/caseContext/set",e=>{let t=new L({options:{required:!0}}),r=y(e,t).error;if(r)return {payload:e,error:r};let a=Object.values(e),n=new K({each:ie}),o=y(a,n).error;return o?{payload:e,error:o}:{payload:e}}),Vh=S("insight/caseId/set",e=>{let r=y(e,ie).error;return r?{payload:e,error:r}:{payload:e}}),Nh=S("insight/caseNumber/set",e=>{let r=y(e,ie).error;return r?{payload:e,error:r}:{payload:e}});k(Qd(),e=>{e.addCase(Dh,(t,r)=>{t.caseContext=r.payload;}).addCase(Vh,(t,r)=>{t.caseId=r.payload;}).addCase(Nh,(t,r)=>{t.caseNumber=r.payload;});});var sc=e=>Object.keys(e).filter(t=>e[t].value!=="").reduce((t,r)=>({...t,[r]:e[r].value}),{});var Mh=S("caseAssist/caseField/register",e=>y(e,{fieldName:q,fieldValue:ie})),Qh=S("caseAssist/caseField/update",e=>y(e,{fieldName:q,fieldValue:ie})),cc=te("caseAssist/classifications/fetch",async(e,{getState:t,rejectWithValue:r,extra:{apiClient:a}})=>{let n=t(),o=await a.getCaseClassifications(await XF(n));return ge(o)?r(o.error):{response:o.success}}),XF=async e=>({accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.platformUrl,caseAssistId:e.caseAssistConfiguration.caseAssistId,...e.configuration.analytics.enabled&&{visitorId:await Fe(e.configuration.analytics)},fields:e.caseInput,context:e.caseField?sc(e.caseField.fields):void 0,locale:e.caseAssistConfiguration.locale,debug:e.debug});k(Ts(),e=>{e.addCase(Mh,(t,r)=>{let{fieldName:a,fieldValue:n}=r.payload;t.fields[a]={value:n,suggestions:[]};}).addCase(Qh,(t,r)=>{let{fieldName:a,fieldValue:n}=r.payload;t.fields[a].value=n;}).addCase(cc.rejected,(t,r)=>{var a;t.status.error=(a=r.payload)!=null?a:null,t.status.loading=!1;}).addCase(cc.fulfilled,(t,r)=>{let a={value:"",suggestions:[]};Object.entries(r.payload.response.fields).forEach(([n,o])=>{t.fields[n]||(t.fields[n]={...a}),t.fields[n].suggestions=o.predictions;}),t.status.lastResponseId=r.payload.response.responseId,t.status.error=null,t.status.loading=!1;}).addCase(cc.pending,t=>{t.status.loading=!0;});});var Lh=S("caseAssist/caseInput/update",e=>y(e,{fieldName:q,fieldValue:ie}));k(Ds(),e=>{e.addCase(Lh,(t,r)=>{t[r.payload.fieldName]={value:r.payload.fieldValue};});});var Pn=S("tab/register",e=>{let t=new L({values:{id:q,expression:ie}});return y(e,t)}),Cr=S("tab/updateActiveTab",e=>y(e,q));function tA(e,t){if(/^https:\/\/platform(dev|stg|hipaa)?(-)?(eu|au)?\.cloud\.coveo\.com/.test(e))return e.replace(/^(https:\/\/)platform/,"$1analytics")+Ns;let a=e.match(new RegExp(`^https://(${t}\\.org)\\.coveo.com`));return a?e.replace(a[1],"analytics.cloud")+Ns:e}var jh=k(Ne(),e=>e.addCase($t,(t,r)=>{r.payload.accessToken&&(t.accessToken=r.payload.accessToken),r.payload.organizationId&&(t.organizationId=r.payload.organizationId),r.payload.platformUrl&&(t.platformUrl=r.payload.platformUrl,t.search.apiBaseUrl=`${r.payload.platformUrl}${Nd}`,t.analytics.apiBaseUrl=tA(r.payload.platformUrl,t.organizationId));}).addCase(ut,(t,r)=>{r.payload.apiBaseUrl&&(t.search.apiBaseUrl=r.payload.apiBaseUrl),r.payload.locale&&(t.search.locale=r.payload.locale),r.payload.timezone&&(t.search.timezone=r.payload.timezone),r.payload.authenticationProviders&&(t.search.authenticationProviders=r.payload.authenticationProviders);}).addCase(Hr,(t,r)=>{re(r.payload.enabled)||(!r.payload.enabled&&t.analytics.enabled&&Zl(t.analytics),t.analytics.enabled=r.payload.enabled),re(r.payload.originContext)||(t.analytics.originContext=r.payload.originContext),re(r.payload.originLevel2)||(t.analytics.originLevel2=r.payload.originLevel2),re(r.payload.originLevel3)||(t.analytics.originLevel3=r.payload.originLevel3),re(r.payload.apiBaseUrl)||(t.analytics.apiBaseUrl=r.payload.apiBaseUrl),re(r.payload.runtimeEnvironment)||(t.analytics.runtimeEnvironment=r.payload.runtimeEnvironment),re(r.payload.anonymous)||(t.analytics.anonymous=r.payload.anonymous),re(r.payload.deviceId)||(t.analytics.deviceId=r.payload.deviceId),re(r.payload.userDisplayName)||(t.analytics.userDisplayName=r.payload.userDisplayName),re(r.payload.documentLocation)||(t.analytics.documentLocation=r.payload.documentLocation);}).addCase(Fn,t=>{t.analytics.enabled=!1,Zl(t.analytics);}).addCase(An,t=>{t.analytics.enabled=!0;}).addCase(tc,(t,r)=>{t.analytics.originLevel2=r.payload.originLevel2;}).addCase(rc,(t,r)=>{t.analytics.originLevel3=r.payload.originLevel3;}).addCase(Cr,(t,r)=>{t.analytics.originLevel2=r.payload;}).addCase(ue,(t,r)=>{t.analytics.originLevel2=r.payload.tab||t.analytics.originLevel2;}));var rA=new K({each:q,required:!0}),Uh=(e,t)=>(y(e,q),Wa(t)?y(t,q):y(t,rA),{payload:{contextKey:e,contextValue:t}}),In=S("context/set",e=>{for(let[t,r]of Object.entries(e))Uh(t,r);return {payload:e}}),En=S("context/add",e=>Uh(e.contextKey,e.contextValue)),wn=S("context/remove",e=>y(e,q));k(it(),e=>{e.addCase(In,(t,r)=>{t.contextValues=r.payload;}).addCase(En,(t,r)=>{t.contextValues[r.payload.contextKey]=r.payload.contextValue;}).addCase(wn,(t,r)=>{delete t.contextValues[r.payload];}).addCase(ce.fulfilled,(t,r)=>{!r.payload||(t.contextValues=r.payload.context.contextValues);});});var Wr=S("debug/enable"),kn=S("debug/disable");var _h=k(We(),e=>{e.addCase(Wr,()=>!0).addCase(kn,()=>!1).addCase(ue,(t,r)=>{var a;return (a=r.payload.debug)!=null?a:t});});var $h=k(si,e=>e);var On=S("dictionaryFieldContext/set",e=>{let t=new L({options:{required:!0}}),r=y(e,t).error;if(r)return {payload:e,error:r};let a=Object.values(e),n=new K({each:ie}),o=y(a,n).error;return o?{payload:e,error:o}:{payload:e}}),qn=S("dictionaryFieldContext/add",e=>{let t=new L({options:{required:!0},values:{field:ie,key:ie}});return y(e,t)}),Tn=S("dictionaryFieldContext/remove",e=>y(e,ie));k(Ut(),e=>{e.addCase(On,(t,r)=>{t.contextValues=r.payload;}).addCase(qn,(t,r)=>{let{field:a,key:n}=r.payload;t.contextValues[a]=n;}).addCase(Tn,(t,r)=>{delete t.contextValues[r.payload];}).addCase(ce.fulfilled,(t,r)=>{!r.payload||(t.contextValues=r.payload.dictionaryFieldContext.contextValues);});});var zh=k(Ri(),e=>{e.addCase(gn,t=>{t.enableDidYouMean=!0;}).addCase(ps,t=>{t.enableDidYouMean=!1;}).addCase(T.pending,t=>{t.queryCorrection=Qs(),t.wasAutomaticallyCorrected=!1,t.wasCorrectedTo="";}).addCase(T.fulfilled,(t,r)=>{t.queryCorrection=r.payload.response.queryCorrections[0]||Qs(),t.originalQuery=r.payload.originalQuery,t.wasAutomaticallyCorrected=r.payload.automaticallyCorrected;}).addCase(jt,(t,r)=>{t.wasCorrectedTo=r.payload;});});var uc=te("caseAssist/documentSuggestions/fetch",async(e,{getState:t,rejectWithValue:r,extra:{apiClient:a}})=>{let n=t(),o=await a.getDocumentSuggestions(await aA(n));return ge(o)?r(o.error):{response:o.success}}),aA=async e=>({accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.platformUrl,caseAssistId:e.caseAssistConfiguration.caseAssistId,...e.configuration.analytics.enabled&&{visitorId:await Fe(e.configuration.analytics)},fields:e.caseInput,context:e.caseField?sc(e.caseField.fields):void 0,locale:e.caseAssistConfiguration.locale,debug:e.debug});k(Ms(),e=>{e.addCase(uc.rejected,(t,r)=>{var a;t.status.error=(a=r.payload)!=null?a:null,t.status.loading=!1;}).addCase(uc.fulfilled,(t,r)=>{t.documents=r.payload.response.documents,t.status.lastResponseId=r.payload.response.responseId,t.status.error=null,t.status.loading=!1;}).addCase(uc.pending,t=>{t.status.loading=!0;});});var lc=S("excerptLength/set",e=>y(e,new U({min:0,required:!0})));k(Hs(),e=>{e.addCase(lc,(t,r)=>{t.length=r.payload;});});var ee=q;var oA={state:new de({required:!0}),numberOfResults:new U({required:!0,min:0}),value:new O({required:!0,emptyAllowed:!0}),path:new K({required:!0,each:q}),moreValuesAvailable:new J({required:!1})};function Wd(e){e.children.forEach(t=>{Wd(t);}),ze({state:e.state,numberOfResults:e.numberOfResults,value:e.value,path:e.path,moreValuesAvailable:e.moreValuesAvailable},oA);}var iA={facetId:ee,field:q,delimitingCharacter:new O({required:!1,emptyAllowed:!0}),filterFacetCount:new J({required:!1}),injectionDepth:new U({required:!1,min:0}),numberOfValues:new U({required:!1,min:1}),sortCriteria:new de({required:!1}),basePath:new K({required:!1,each:q}),filterByBasePath:new J({required:!1})},Ht=S("categoryFacet/register",e=>y(e,iA)),Yr=S("categoryFacet/toggleSelectValue",e=>{try{return ze(e.facetId,q),Wd(e.selection),{payload:e,error:null}}catch(t){return {payload:e,error:Ft(t)}}}),zt=S("categoryFacet/deselectAll",e=>y(e,ee)),Ea=S("categoryFacet/updateNumberOfValues",e=>y(e,{facetId:ee,numberOfValues:new U({required:!0,min:1})})),Dn=S("categoryFacet/updateSortCriterion",e=>y(e,{facetId:ee,criterion:new de}));var Wt=new O({regex:/^[a-zA-Z0-9-_]+$/}),Yt=new O({required:!0}),Yh=new K({each:new O}),Kh=new O,Gh=new J,Kt=new J,Gt=new U({min:0}),At=new U({min:1}),dc=new J({required:!0}),sA=new L,cA=new O,uA={captions:sA,numberOfValues:At,query:cA},Vn=new L({values:uA}),pc=new L({options:{required:!1},values:{type:new O({constrainTo:["simple"],emptyAllowed:!1,required:!0}),values:new K({required:!0,max:25,each:new O({emptyAllowed:!1,required:!0})})}}),Jh=new J;var fc={value:q,numberOfResults:new U({min:0}),state:q};var lA={facetId:ee,field:new O({required:!0,emptyAllowed:!0}),filterFacetCount:new J({required:!1}),injectionDepth:new U({required:!1,min:0}),numberOfValues:new U({required:!1,min:1}),sortCriteria:new de({required:!1}),allowedValues:pc},Jt=S("facet/register",e=>y(e,lA)),Xt=S("facet/toggleSelectValue",e=>y(e,{facetId:ee,selection:new L({values:fc})})),xe=S("facet/deselectAll",e=>y(e,ee)),Nn=S("facet/updateSortCriterion",e=>y(e,{facetId:ee,criterion:new de({required:!0})})),wa=S("facet/updateNumberOfValues",e=>y(e,{facetId:ee,numberOfValues:new U({required:!0,min:1})})),ka=S("facet/updateIsFieldExpanded",e=>y(e,{facetId:ee,isFieldExpanded:new J({required:!0})})),Kr=S("facet/updateFreezeCurrentValues",e=>y(e,{facetId:ee,freezeCurrentValues:new J({required:!0})}));function Oa(e){var o,i;let t=Xh(e.start,e),r=Xh(e.end,e),a=(o=e.endInclusive)!=null?o:!1,n=(i=e.state)!=null?i:"idle";return {start:t,end:r,endInclusive:a,state:n}}function Xh(e,t){let{dateFormat:r}=t;return Mg(e)?(xa(e),Dg(e)):typeof e=="string"&&_t(e)?(xa(e),e):(As(e,r),yi(Ca(e,r)))}var Mn=S("rangeFacet/updateSortCriterion",e=>y(e,{facetId:ee,criterion:new de({required:!0})}));var Qn={state:q,start:new U({required:!0}),end:new U({required:!0}),endInclusive:new J({required:!0}),numberOfResults:new U({required:!0,min:0})},Ln={start:q,end:q,endInclusive:new J({required:!0}),state:q,numberOfResults:new U({required:!0,min:0})},jn=e=>({facetId:ee,selection:typeof e.start=="string"?new L({values:Ln}):new L({values:Qn})});var dA={start:q,end:q,endInclusive:new J({required:!0}),state:q},pA={facetId:ee,field:q,currentValues:new K({required:!1,each:new L({values:dA})}),generateAutomaticRanges:new J({required:!0}),filterFacetCount:new J({required:!1}),injectionDepth:new U({required:!1,min:0}),numberOfValues:new U({required:!1,min:1}),sortCriteria:new de({required:!1}),rangeAlgorithm:new de({required:!1})};function Zh(e){return _t(e)?Ci(e):e}function mc(e){!e.currentValues||e.currentValues.forEach(t=>{let{start:r,end:a}=Oa(t);if(Ca(Zh(r)).isAfter(Ca(Zh(a))))throw new Error(`The start value is greater than the end value for the date range ${t.start} to ${t.end}`)});}var Zt=S("dateFacet/register",e=>{try{return ze(e,pA),mc(e),{payload:e,error:null}}catch(t){return {payload:e,error:Ft(t)}}}),er=S("dateFacet/toggleSelectValue",e=>y(e,{facetId:ee,selection:new L({values:Ln})})),xr=S("dateFacet/updateFacetValues",e=>{try{return ze(e,{facetId:ee,values:new K({each:new L({values:Ln})})}),mc({currentValues:e.values}),{payload:e,error:null}}catch(t){return {payload:e,error:Ft(t)}}}),gc=Mn,hc=xe;var fA={state:q,start:new U({required:!0}),end:new U({required:!0}),endInclusive:new J({required:!0})},mA={facetId:ee,field:q,currentValues:new K({required:!1,each:new L({values:fA})}),generateAutomaticRanges:new J({required:!0}),filterFacetCount:new J({required:!1}),injectionDepth:new U({required:!1,min:0}),numberOfValues:new U({required:!1,min:1}),sortCriteria:new de({required:!1}),rangeAlgorithm:new de({required:!1})};function Sc(e){!e.currentValues||e.currentValues.forEach(({start:t,end:r})=>{if(t>r)throw new Error(`The start value is greater than the end value for the numeric range ${t} to ${r}`)});}var tr=S("numericFacet/register",e=>{try{return y(e,mA),Sc(e),{payload:e,error:null}}catch(t){return {payload:e,error:Ft(t)}}}),rr=S("numericFacet/toggleSelectValue",e=>y(e,{facetId:ee,selection:new L({values:Qn})})),Rr=S("numericFacet/updateFacetValues",e=>{try{return ze(e,{facetId:ee,values:new K({each:new L({values:Qn})})}),Sc({currentValues:e.values}),{payload:e,error:null}}catch(t){return {payload:e,error:Ft(t)}}}),yc=Mn,vc=xe;var se=S("facetOptions/update",e=>y(e,{freezeFacetOrder:new J({required:!1})})),je=S("facetOptions/facet/enable",e=>y(e,ee)),ye=S("facetOptions/facet/disable",e=>y(e,ee));var eS=k(hr(),e=>{e.addCase(se,(t,r)=>({...t,...r.payload})).addCase(T.fulfilled,t=>{t.freezeFacetOrder=!1;}).addCase(T.rejected,t=>{t.freezeFacetOrder=!1;}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.facetOptions)!=null?n:t}).addCase(Ht,(t,r)=>{t.facets[r.payload.facetId]=hn();}).addCase(Jt,(t,r)=>{t.facets[r.payload.facetId]=hn();}).addCase(Zt,(t,r)=>{t.facets[r.payload.facetId]=hn();}).addCase(tr,(t,r)=>{t.facets[r.payload.facetId]=hn();}).addCase(je,(t,r)=>{t.facets[r.payload].enabled=!0;}).addCase(ye,(t,r)=>{t.facets[r.payload].enabled=!1;}).addCase(ue,(t,r)=>{var a,n,o,i;[...Object.keys((a=r.payload.f)!=null?a:{}),...Object.keys((n=r.payload.cf)!=null?n:{}),...Object.keys((o=r.payload.nf)!=null?o:{}),...Object.keys((i=r.payload.df)!=null?i:{})].forEach(s=>{s in t||(t.facets[s]=hn()),t.facets[s].enabled=!0;});});});var Ai={facetId:ee,captions:new L({options:{required:!1}}),numberOfValues:new U({required:!1,min:1}),query:new O({required:!1,emptyAllowed:!0})};var gA={path:new K({required:!0,each:q}),displayValue:ie,rawValue:ie,count:new U({required:!0,min:0})},Un=S("categoryFacet/selectSearchResult",e=>y(e,{facetId:ee,value:new L({values:gA})})),Bn=S("categoryFacetSearch/register",e=>y(e,Ai));function _n(e,t){var o;let{facetId:r,criterion:a}=t,n=(o=e[r])==null?void 0:o.request;!n||(n.sortCriteria=a);}function Pi(e){!e||(e.currentValues=e.currentValues.map(t=>({...t,state:"idle"})),e.preventAutoSelect=!0);}function Cc(e,t){!e||(e.numberOfValues=t);}function xc(e,t){let r=e[t];!r||(r.request.numberOfValues=r.initialNumberOfValues,r.request.currentValues=[],r.request.preventAutoSelect=!0);}function Yd(e,t,r){e.currentValues=hA(t,r),e.numberOfValues=t.length?1:r,e.preventAutoSelect=!0;}function hA(e,t){if(!e.length)return [];let r=tS(e[0],t),a=r;for(let n of e.splice(1)){let o=tS(n,t);a.children.push(o),a=o;}return a.state="selected",a.retrieveChildren=!0,[r]}function tS(e,t){return {value:e,retrieveCount:t,children:[],state:"idle",retrieveChildren:!1}}var rS=k(yt(),e=>{e.addCase(Ht,(t,r)=>{let a=r.payload,{facetId:n}=a;if(n in t)return;let o=yA(a),i=o.numberOfValues;t[n]={request:o,initialNumberOfValues:i};}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.categoryFacetSet)!=null?n:t}).addCase(ue,(t,r)=>{let a=r.payload.cf||{};Object.keys(t).forEach(n=>{let o=t[n].request,i=a[n]||[];(i.length||o.currentValues.length)&&Yd(o,i,t[n].initialNumberOfValues);});}).addCase(Dn,(t,r)=>{var i;let{facetId:a,criterion:n}=r.payload,o=(i=t[a])==null?void 0:i.request;!o||(o.sortCriteria=n);}).addCase(Yr,(t,r)=>{var p;let{facetId:a,selection:n,retrieveCount:o}=r.payload,i=(p=t[a])==null?void 0:p.request;if(!i)return;let{path:s}=n,u=s.slice(0,s.length-1),c=SA(i,u,o);if(c.length){let f=c[0];f.retrieveChildren=!0,f.state="selected",f.children=[];return}let l=aS(n.value,o);l.state="selected",c.push(l),i.numberOfValues=1;}).addCase(zt,(t,r)=>{let a=r.payload;xc(t,a);}).addCase(ke,t=>{Object.keys(t).forEach(r=>xc(t,r));}).addCase(Qt,(t,r)=>Object.keys(t).forEach(a=>{t[a].request.preventAutoSelect=!r.payload.allow;})).addCase(Ea,(t,r)=>{var i;let{facetId:a,numberOfValues:n}=r.payload,o=(i=t[a])==null?void 0:i.request;if(!!o){if(!o.currentValues.length)return Cc(o,n);vA(t,r.payload);}}).addCase(Un,(t,r)=>{let{facetId:a,value:n}=r.payload,o=t[a];if(!o)return;let i=[...n.path,n.rawValue];Yd(o.request,i,o.initialNumberOfValues);}).addCase(Ke.fulfilled,(t,r)=>{nS(t,r.payload.response.facets);}).addCase(T.fulfilled,(t,r)=>{nS(t,r.payload.response.facets);}).addCase(ye,(t,r)=>{xc(t,r.payload);});}),Ii={delimitingCharacter:";",filterFacetCount:!0,injectionDepth:1e3,numberOfValues:5,sortCriteria:"occurrences",basePath:[],filterByBasePath:!0};function SA(e,t,r){let a=e.currentValues;for(let n of t){let o=a[0];(!o||n!==o.value)&&(o=aS(n,r),a.length=0,a.push(o)),o.retrieveChildren=!1,o.state="idle",a=o.children;}return a}function yA(e){return {...Ii,currentValues:[],preventAutoSelect:!1,type:"hierarchical",...e}}function aS(e,t){return {value:e,state:"idle",children:[],retrieveChildren:!0,retrieveCount:t}}function nS(e,t){t.forEach(r=>{var i;if(!CA(e,r))return;let a=r.facetId,n=(i=e[a])==null?void 0:i.request;if(!n)return;let o=xA(n,r);n.currentValues=o?[]:n.currentValues,n.preventAutoSelect=!1;});}function vA(e,t){var o;let{facetId:r,numberOfValues:a}=t,n=(o=e[r])==null?void 0:o.request.currentValues[0];if(!!n){for(;n.children.length&&(n==null?void 0:n.state)!=="selected";)n=n.children[0];n.retrieveCount=a;}}function CA(e,t){return t.facetId in e}function xA(e,t){let r=Xe(e.currentValues).parents,a=Xe(t.values).parents;return r.length!==a.length}var oS=k(jr(),e=>{e.addCase(T.fulfilled,(t,r)=>r.payload.response.facets.map(a=>a.facetId)).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.facetOrder)!=null?n:t});});function Rc(e,t,r){let{facetId:a}=t;if(e[a])return;let n=!1,o={...ar,...t},i=r();e[a]={options:o,isLoading:n,response:i,initialNumberOfValues:o.numberOfValues,requestId:""};}function bc(e,t){let{facetId:r,...a}=t,n=e[r];!n||(n.options={...n.options,...a});}function Fc(e,t,r){let a=e[t];!a||(a.requestId=r,a.isLoading=!0);}function Ac(e,t){let r=e[t];!r||(r.isLoading=!1);}function Pc(e,t,r){let{facetId:a,response:n}=t,o=e[a];!o||o.requestId===r&&(o.isLoading=!1,o.response=n);}function Ei(e,t,r){let{facetId:a}=t,n=e[a];!n||(n.requestId="",n.isLoading=!1,n.response=r(),n.options.numberOfValues=n.initialNumberOfValues,n.options.query=ar.query);}function Ic(e,t){Object.keys(e).forEach(r=>Ei(e,{facetId:r},t));}var ar={captions:{},numberOfValues:10,query:""};var iS=async(e,t,r)=>{let a=t.categoryFacetSearchSet[e].options,n=t.categoryFacetSet[e].request,{captions:o,query:i,numberOfValues:s}=a,{field:u,delimitingCharacter:c,basePath:l,filterFacetCount:p}=n,f=RA(n),d=f.length?[f]:[],m=`*${i}*`;return {url:t.configuration.search.apiBaseUrl,accessToken:t.configuration.accessToken,organizationId:t.configuration.organizationId,...t.configuration.search.authenticationProviders.length&&{authentication:t.configuration.search.authenticationProviders.join(",")},basePath:l,captions:o,numberOfValues:s,query:m,field:u,delimitingCharacter:c,ignorePaths:d,filterFacetCount:p,type:"hierarchical",...r?{}:{searchContext:(await st(t)).request}}},RA=e=>{let t=[],r=e.currentValues[0];for(;r;)t.push(r.value),r=r.children[0];return t};var sS=async(e,t,r)=>{let{captions:a,query:n,numberOfValues:o}=t.facetSearchSet[e].options,{field:i,currentValues:s,filterFacetCount:u}=t.facetSet[e].request,c=s.filter(p=>p.state!=="idle").map(p=>p.value),l=`*${n}*`;return {url:t.configuration.search.apiBaseUrl,accessToken:t.configuration.accessToken,organizationId:t.configuration.organizationId,...t.configuration.search.authenticationProviders&&{authentication:t.configuration.search.authenticationProviders.join(",")},captions:a,numberOfValues:o,query:l,field:i,ignoreValues:c,filterFacetCount:u,type:"specific",...r?{}:{searchContext:(await st(t)).request}}};var cS=e=>async(t,{getState:r,extra:{apiClient:a,validatePayload:n}})=>{let o=r(),i;n(t,q),bA(o,t)?i=await sS(t,o,e):i=await iS(t,o,e);let s=await a.facetSearch(i);return {facetId:t,response:s}},Pt=te("facetSearch/executeSearch",cS(!1)),Kd=te("facetSearch/executeSearch",cS(!0)),$n=S("facetSearch/clearResults",e=>y(e,{facetId:ee})),bA=(e,t)=>e.facetSearchSet!==void 0&&e.facetSet!==void 0&&e.facetSet[t]!==void 0;var FA={facetId:ee,value:new L({values:{displayValue:ie,rawValue:ie,count:new U({required:!0,min:0})}})},Ec=S("facetSearch/register",e=>y(e,Ai)),Gr=S("facetSearch/update",e=>y(e,Ai)),qa=S("facetSearch/toggleSelectValue",e=>y(e,FA));var uS=k(xn(),e=>{e.addCase(Bn,(t,r)=>{let a=r.payload;Rc(t,a,Gd);}).addCase(Gr,(t,r)=>{bc(t,r.payload);}).addCase(Pt.pending,(t,r)=>{let a=r.meta.arg;Fc(t,a,r.meta.requestId);}).addCase(Pt.rejected,(t,r)=>{let a=r.meta.arg;Ac(t,a);}).addCase(Pt.fulfilled,(t,r)=>{Pc(t,r.payload,r.meta.requestId);}).addCase($n,(t,{payload:{facetId:r}})=>{Ei(t,{facetId:r},Gd);}).addCase(T.fulfilled,t=>{Ic(t,Gd);});});function Gd(){return {moreValuesAvailable:!1,values:[]}}var lS=k(Aa(),e=>{e.addCase(Ec,(t,r)=>{let a=r.payload;Rc(t,a,Jd);}).addCase(Gr,(t,r)=>{bc(t,r.payload);}).addCase(Pt.pending,(t,r)=>{let a=r.meta.arg;Fc(t,a,r.meta.requestId);}).addCase(Pt.rejected,(t,r)=>{let a=r.meta.arg;Ac(t,a);}).addCase(Pt.fulfilled,(t,r)=>{Pc(t,r.payload,r.meta.requestId);}).addCase($n,(t,{payload:r})=>{Ei(t,r,Jd);}).addCase(T.fulfilled,t=>{Ic(t,Jd);});});function Jd(){return {moreValuesAvailable:!1,values:[]}}var dS=S("productlisting/setUrl",e=>y(e,{url:new O({required:!0,url:!0})})),pS=S("productlisting/setAdditionalFields",e=>y(e,{additionalFields:new K({required:!0,each:new O({required:!0,emptyAllowed:!1})})})),lt=te("productlisting/fetch",async(e,{getState:t,dispatch:r,rejectWithValue:a,extra:n})=>{let o=t(),{apiClient:i}=n,s=await i.getProducts(await AA(o));return ge(s)?(r(vn(s.error)),a(s.error)):{response:s.success}}),AA=async e=>{var a,n,o;let t=IA(e),r=await Fe(e.configuration.analytics);return {accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,platformUrl:e.configuration.platformUrl,url:(a=e.productListing)==null?void 0:a.url,...e.configuration.analytics.enabled&&r?{clientId:r}:{},...((n=e.productListing.additionalFields)==null?void 0:n.length)?{additionalFields:e.productListing.additionalFields}:{},...e.productListing.advancedParameters&&PA(e.productListing.advancedParameters)?{advancedParameters:e.productListing.advancedParameters||{}}:{},...t.length&&{facets:{requests:t}},...e.pagination&&{pagination:{numberOfValues:e.pagination.numberOfResults,page:Math.ceil(e.pagination.firstResult/(e.pagination.numberOfResults||1))+1}},...(((o=e.sort)==null?void 0:o.by)||Ia.Relevance)!==Ia.Relevance&&{sort:e.sort},...e.context&&{userContext:e.context.contextValues}}};function PA(e){return e.debug}function IA(e){var t;return Cn(EA(e),(t=e.facetOrder)!=null?t:[])}function EA(e){var t,r,a,n;return [...yr((t=e.facetSet)!=null?t:{}),...yr((r=e.numericFacetSet)!=null?r:{}),...yr((a=e.dateFacetSet)!=null?a:{}),...yr((n=e.categoryFacetSet)!=null?n:{})]}var fS=k(xt(),e=>{e.addCase(Jt,(t,r)=>{let{facetId:a}=r.payload;a in t||(t[a]=Em(wA(r.payload)));}).addCase(ce.fulfilled,(t,r)=>{if(!!r.payload&&Object.keys(r.payload.facetSet).length!==0)return r.payload.facetSet}).addCase(ue,(t,r)=>{let a=r.payload.f||{};Object.keys(t).forEach(o=>{let{request:i}=t[o],s=a[o]||[],u=i.currentValues.filter(c=>!s.includes(c.value));i.currentValues=[...s.map(gS),...u.map(OA)],i.preventAutoSelect=s.length>0,i.numberOfValues=Math.max(s.length,i.numberOfValues);});}).addCase(Xt,(t,r)=>{var u;let{facetId:a,selection:n}=r.payload,o=(u=t[a])==null?void 0:u.request;if(!o)return;o.preventAutoSelect=!0;let i=o.currentValues.find(c=>c.value===n.value);if(!i){mS(o,n);return}let s=i.state==="selected";i.state=s?"idle":"selected",o.freezeCurrentValues=!0;}).addCase(Kr,(t,r)=>{var i;let{facetId:a,freezeCurrentValues:n}=r.payload,o=(i=t[a])==null?void 0:i.request;!o||(o.freezeCurrentValues=n);}).addCase(xe,(t,r)=>{var a;Pi((a=t[r.payload])==null?void 0:a.request);}).addCase(ke,t=>{Object.values(t).filter(r=>r.hasBreadcrumbs).forEach(({request:r})=>Pi(r));}).addCase(on,t=>{Object.values(t).filter(r=>!r.hasBreadcrumbs).forEach(({request:r})=>Pi(r));}).addCase(Qt,(t,r)=>Object.values(t).forEach(a=>{a.request.preventAutoSelect=!r.payload.allow;})).addCase(Nn,(t,r)=>{_n(t,r.payload);}).addCase(wa,(t,r)=>{var o;let{facetId:a,numberOfValues:n}=r.payload;Cc((o=t[a])==null?void 0:o.request,n);}).addCase(ka,(t,r)=>{var i;let{facetId:a,isFieldExpanded:n}=r.payload,o=(i=t[a])==null?void 0:i.request;!o||(o.isFieldExpanded=n);}).addCase(T.fulfilled,(t,r)=>{r.payload.response.facets.forEach(n=>{var o;return Xd((o=t[n.facetId])==null?void 0:o.request,n)});}).addCase(lt.fulfilled,(t,r)=>{var n,o;(((o=(n=r.payload.response)==null?void 0:n.facets)==null?void 0:o.results)||[]).forEach(i=>{var s;return Xd((s=t[i.facetId])==null?void 0:s.request,i)});}).addCase(Ke.fulfilled,(t,r)=>{r.payload.response.facets.forEach(n=>{var o;return Xd((o=t[n.facetId])==null?void 0:o.request,n)});}).addCase(qa,(t,r)=>{var l;let{facetId:a,value:n}=r.payload,o=(l=t[a])==null?void 0:l.request;if(!o)return;let{rawValue:i}=n,{currentValues:s}=o,u=s.find(p=>p.value===i);if(u){u.state="selected";return}let c=gS(i);mS(o,c),o.freezeCurrentValues=!0,o.preventAutoSelect=!0;}).addCase(ye,(t,r)=>{if(!(r.payload in t))return;let{request:a}=t[r.payload];Pi(a);});});function mS(e,t){let{currentValues:r}=e,a=r.findIndex(s=>s.state==="idle"),n=a===-1?r.length:a,o=r.slice(0,n),i=r.slice(n+1);e.currentValues=[...o,t,...i],e.numberOfValues=e.currentValues.length;}function Xd(e,t){!e||(e.currentValues=t.values.map(kA),e.freezeCurrentValues=!1,e.preventAutoSelect=!1);}var wi={filterFacetCount:!0,injectionDepth:1e3,numberOfValues:8,sortCriteria:"automatic"};function wA(e){return {...wi,type:"specific",currentValues:[],freezeCurrentValues:!1,isFieldExpanded:!1,preventAutoSelect:!1,...e}}function kA(e){let{value:t,state:r}=e;return {value:t,state:r}}function gS(e){return {value:e,state:"selected"}}function OA(e){return {...e,state:"idle"}}var wc={filterFacetCount:!0,injectionDepth:1e3,numberOfValues:8,sortCriteria:"ascending",rangeAlgorithm:"even"};function kc(e,t){let{request:r}=t,{facetId:a}=r;if(a in e)return;let n=hS(r);r.numberOfValues=n,e[a]=t;}function Oc(e,t,r){var n;let a=(n=e[t])==null?void 0:n.request;!a||(a.currentValues=r,a.numberOfValues=hS(a));}function qc(e,t,r){var i;let a=(i=e[t])==null?void 0:i.request;if(!a)return;let n=Zd(a.currentValues,r);if(!n)return;let o=n.state==="selected";n.state=o?"idle":"selected",a.preventAutoSelect=!0;}function Jr(e,t){var a;let r=(a=e[t])==null?void 0:a.request;!r||r.currentValues.forEach(n=>n.state="idle");}function Tc(e,t){Object.entries(e).forEach(([r,{request:a}])=>{let n=t[r]||[];a.currentValues.forEach(s=>{let u=!!Zd(n,s);return s.state=u?"selected":"idle",s});let o=n.filter(s=>!Zd(a.currentValues,s)),i=a.currentValues;i.push(...o),a.numberOfValues=Math.max(a.numberOfValues,i.length);});}function Hn(e,t,r){t.forEach(a=>{var s;let n=a.facetId,o=(s=e[n])==null?void 0:s.request;if(!o)return;let i=r(a.values);o.currentValues=i,o.preventAutoSelect=!1;});}function Zd(e,t){let{start:r,end:a}=t;return e.find(n=>n.start===r&&n.end===a)}function hS(e){let{generateAutomaticRanges:t,currentValues:r,numberOfValues:a}=e;return t?Math.max(a,r.length):r.length}var SS=k(vt(),e=>{e.addCase(Zt,(t,r)=>{let{payload:a}=r,n=qA(a);kc(t,Pm(n));}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.dateFacetSet)!=null?n:t}).addCase(ue,(t,r)=>{let a=r.payload.df||{};Tc(t,a);}).addCase(er,(t,r)=>{let{facetId:a,selection:n}=r.payload;qc(t,a,n);}).addCase(xr,(t,r)=>{let{facetId:a,values:n}=r.payload;Oc(t,a,n);}).addCase(hc,(t,r)=>{Jr(t,r.payload);}).addCase(ke,t=>{Object.keys(t).forEach(r=>{Jr(t,r);});}).addCase(gc,(t,r)=>{_n(t,r.payload);}).addCase(T.fulfilled,(t,r)=>{let a=r.payload.response.facets;Hn(t,a,yS);}).addCase(lt.fulfilled,(t,r)=>{var n,o;let a=((o=(n=r.payload.response)==null?void 0:n.facets)==null?void 0:o.results)||[];Hn(t,a,yS);}).addCase(ye,(t,r)=>{Jr(t,r.payload);});});function qA(e){return {...wc,currentValues:[],preventAutoSelect:!1,type:"dateRange",...e}}function yS(e){return e.map(t=>{let{numberOfResults:r,...a}=t;return a})}var vS=k(Ct(),e=>{e.addCase(tr,(t,r)=>{let{payload:a}=r,n=TA(a);kc(t,Im(n));}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.numericFacetSet)!=null?n:t}).addCase(ue,(t,r)=>{let a=r.payload.nf||{};Tc(t,a);}).addCase(rr,(t,r)=>{let{facetId:a,selection:n}=r.payload;qc(t,a,n);}).addCase(Rr,(t,r)=>{let{facetId:a,values:n}=r.payload;Oc(t,a,n);}).addCase(vc,(t,r)=>{Jr(t,r.payload);}).addCase(ke,t=>{Object.keys(t).forEach(r=>{Jr(t,r);});}).addCase(yc,(t,r)=>{_n(t,r.payload);}).addCase(T.fulfilled,(t,r)=>{let a=r.payload.response.facets;Hn(t,a,CS);}).addCase(lt.fulfilled,(t,r)=>{var n,o;let a=((o=(n=r.payload.response)==null?void 0:n.facets)==null?void 0:o.results)||[];Hn(t,a,CS);}).addCase(ye,(t,r)=>{Jr(t,r.payload);});});function TA(e){return {...wc,currentValues:[],preventAutoSelect:!1,type:"numericalRange",...e}}function CS(e){return e.map(t=>{let{numberOfResults:r,...a}=t;return a})}var ep={collectionField:new O({emptyAllowed:!1,required:!1}),parentField:new O({emptyAllowed:!1,required:!1}),childField:new O({emptyAllowed:!1,required:!1}),numberOfFoldedResults:new U({min:0,required:!1})},Xr=S("folding/register",e=>y(e,ep)),Zr=te("folding/loadCollection",async(e,{getState:t,rejectWithValue:r,extra:{apiClient:a}})=>{let n=t(),o=await mn(n),i=await a.search({...o,q:DA(n),enableQuerySyntax:!0,cq:`@${n.folding.fields.collection}="${e}"`,filterField:n.folding.fields.collection,childField:n.folding.fields.parent,parentField:n.folding.fields.child,filterFieldRange:100},{origin:"foldingCollection"});return ge(i)?r(i.error):{collectionId:e,results:i.success.results,rootResult:n.folding.collections[e].result}});function DA(e){return e.query.q===""?"":e.query.enableQuerySyntax?`${e.query.q} OR @uri`:`( <@- ${e.query.q} -@> ) OR @uri`}var tp=e=>Q("analytics/folding/showMore",M.Click,(t,r)=>(_e(e),t.makeShowMoreFoldedResults(Ve(e,r),Le(e)))),xS=Q("analytics/folding/showLess",M.Custom,e=>e.makeShowLessFoldedResults());var VA=new K({each:q,required:!0}),ea=S("fields/registerFieldsToInclude",e=>y(e,VA)),zn=S("fields/fetchall/enable"),Ta=S("fields/fetchall/disable"),Wn=te("fields/fetchDescription",async(e,{extra:t,getState:r,rejectWithValue:a})=>{let n=r(),{accessToken:o,organizationId:i}=n.configuration,{apiBaseUrl:s}=n.configuration.search,u=await t.apiClient.fieldDescriptions({accessToken:o,organizationId:i,url:s});return ge(u)?a(u.error):u.success.fields});var RS=k(Pa(),e=>e.addCase(ea,(t,r)=>{t.fieldsToInclude=[...new Set(t.fieldsToInclude.concat(r.payload))];}).addCase(zn,t=>{t.fetchAllFields=!0;}).addCase(Ta,t=>{t.fetchAllFields=!1;}).addCase(Wn.fulfilled,(t,{payload:r})=>{t.fieldsDescription=r;}).addCase(Xr,(t,{payload:r})=>{var n,o,i;let a=Rn().fields;t.fieldsToInclude.push((n=r.collectionField)!=null?n:a.collection,(o=r.parentField)!=null?o:a.parent,(i=r.childField)!=null?i:a.child);}));function NA(e,t){return e.raw[t.collection]}function rp(e,t){return e.raw[t.parent]}function ki(e,t){let r=e.raw[t.child];return os(r)?r[0]:r}function MA(e,t){return (e||t)!==void 0&&e===t}function bS(e,t,r,a=[]){let n=ki(e,r);return n?a.indexOf(n)!==-1?[]:t.filter(o=>{let i=ki(o,r)===ki(e,r);return rp(o,r)===n&&!i}).map(o=>({result:o,children:bS(o,t,r,[...a,n])})):[]}function QA(e,t){return e.find(r=>{let a=rp(r,t)===void 0,n=MA(rp(r,t),ki(r,t));return a||n})}function FS(e){return e.parentResult?FS(e.parentResult):e}function LA(e,t,r){var o;let a=us(e),n=(o=r!=null?r:QA(a,t))!=null?o:FS(e);return {result:n,children:bS(n,a,t),moreResultsAvailable:!0,isLoadingMoreResults:!1}}function Dc(e,t,r){let a={};return e.forEach(n=>{let o=NA(n,t);!o||!ki(n,t)&&!n.parentResult||(a[o]=LA(n,t,r));}),a}function AS(e,t){if(!e.collections[t])throw new Error(`Missing collection ${t} from ${Object.keys(e.collections)}: Folding most probably in an invalid state...`);return e.collections[t]}var PS=k(Rn(),e=>e.addCase(T.fulfilled,(t,{payload:r})=>{t.collections=t.enabled?Dc(r.response.results,t.fields):{};}).addCase(Ye.fulfilled,(t,{payload:r})=>{t.collections=t.enabled?Dc(r.response.results,t.fields):{};}).addCase(ct.fulfilled,(t,{payload:r})=>{t.collections=t.enabled?{...t.collections,...Dc(r.response.results,t.fields)}:{};}).addCase(Xr,(t,{payload:r})=>{var a,n,o,i;return t.enabled?t:{enabled:!0,collections:{},fields:{collection:(a=r.collectionField)!=null?a:t.fields.collection,parent:(n=r.parentField)!=null?n:t.fields.parent,child:(o=r.childField)!=null?o:t.fields.child},filterFieldRange:(i=r.numberOfFoldedResults)!=null?i:t.filterFieldRange}}).addCase(Zr.pending,(t,{meta:r})=>{let a=r.arg;AS(t,a).isLoadingMoreResults=!0;}).addCase(Zr.rejected,(t,{meta:r})=>{let a=r.arg;AS(t,a).isLoadingMoreResults=!1;}).addCase(Zr.fulfilled,(t,{payload:{collectionId:r,results:a,rootResult:n}})=>{let o=Dc(a,t.fields,n);if(!o||!o[r])throw new Error(`Unable to create collection ${r} from received results: ${JSON.stringify(a)}. Folding most probably in an invalid state... `);t.collections[r]=o[r],t.collections[r].moreResultsAvailable=!1;}));var wS=be(ES());function Da(e,t,r=(a,n)=>a===n){return e.length===t.length&&e.findIndex((a,n)=>!r(t[n],a))===-1}var Nc=(0, wS.createCustomEqual)(e=>(t,r)=>Array.isArray(t)&&Array.isArray(r)?t.length!==r.length?!1:t.every(a=>r.findIndex(n=>e(a,n))!==-1):e(t,r));var kS=k(hs(),e=>{e.addCase(Lr,(t,r)=>jA(t,r.payload)?void 0:r.payload);}),jA=(e,t)=>UA(e.context,t.context)&&BA(e.dictionaryFieldContext,t.dictionaryFieldContext)&&YA(e.advancedSearchQueries,t.advancedSearchQueries)&&_A(e.tabSet,t.tabSet)&&$A(e.staticFilterSet,t.staticFilterSet)&&ap(e.facetSet,t.facetSet)&&ap(e.dateFacetSet,t.dateFacetSet)&&ap(e.numericFacetSet,t.numericFacetSet)&&HA(e.categoryFacetSet,t.categoryFacetSet)&&zA(e.pagination,t.pagination)&&WA(e.query,t.query)&&KA(e,t)&&GA(e.pipeline,t.pipeline)&&JA(e.searchHub,t.searchHub)&&XA(e.facetOrder,t.facetOrder)&&ZA(e.debug,t.debug),UA=(e,t)=>JSON.stringify(e.contextValues)===JSON.stringify(t.contextValues),BA=(e,t)=>JSON.stringify(e.contextValues)===JSON.stringify(t.contextValues),_A=(e,t)=>{let r=OS(e),a=OS(t);return (r==null?void 0:r.id)===(a==null?void 0:a.id)},OS=e=>Object.values(e).find(t=>t.isActive),$A=(e,t)=>{for(let[r,a]of Object.entries(t)){if(!e[r])return !1;let n=qS(e[r]),o=qS(a);if(JSON.stringify(n)!==JSON.stringify(o))return !1}return !0},qS=e=>e.values.filter(t=>t.state!=="idle"),ap=(e,t)=>{for(let[r,a]of Object.entries(t)){if(!e[r])return !1;let n=e[r].request.currentValues.filter(i=>i.state==="selected"),o=a.request.currentValues.filter(i=>i.state==="selected");if(JSON.stringify(n)!==JSON.stringify(o))return !1}return !0},HA=(e,t)=>{var r;for(let[a,n]of Object.entries(t)){if(!e[a])return !1;let o=Xe((r=e[a])==null?void 0:r.request.currentValues).parents.map(({value:s})=>s),i=Xe(n==null?void 0:n.request.currentValues).parents.map(({value:s})=>s);if(JSON.stringify(o)!==JSON.stringify(i))return !1}return !0},zA=(e,t)=>e.firstResult===t.firstResult&&e.numberOfResults===t.numberOfResults,WA=(e,t)=>JSON.stringify(e)===JSON.stringify(t),YA=(e,t)=>JSON.stringify(e)===JSON.stringify(t),KA=(e,t)=>e.sortCriteria===t.sortCriteria,GA=(e,t)=>e===t,JA=(e,t)=>e===t,XA=(e,t)=>Da(e,t),ZA=(e,t)=>e===t;var TS=S("insightConfiguration/set",e=>y(e,{insightId:q}));k(jd(),e=>{e.addCase(TS,(t,r)=>{t.insightId=r.payload.insightId;});});var ta=S("searchHub/set",e=>y(e,new O({required:!0,emptyAllowed:!0})));var Mc=te("insight/interface/fetch",async(e,{getState:t,dispatch:r,rejectWithValue:a,extra:{apiClient:n}})=>{let o=t(),i=await n.getInterface(tP(o));return ge(i)?a(i.error):(r(ta(i.success.searchHub)),{response:i.success})}),tP=e=>({accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.platformUrl,insightId:e.insightConfiguration.insightId});k(Ud(),e=>{e.addCase(Mc.pending,t=>{t.loading=!0,t.error=void 0;}).addCase(Mc.rejected,(t,r)=>{t.loading=!1,t.error=r.payload;}).addCase(Mc.fulfilled,(t,r)=>{t.loading=!1,t.error=void 0;let{searchHub:a,...n}=r.payload.response;t.config=n;});});var DS=k(Sn(),e=>{e.addCase(sn,(t,r)=>{let{id:a}=r.payload;t[a]||(t[a]={q:"",cache:{}});}),e.addCase(Qr,(t,r)=>{let{q:a,id:n}=r.payload;!a||(t[n].q=a);}),e.addCase(cn,(t,r)=>{let{id:a}=r.payload;Object.entries(t[a].cache).forEach(([n,o])=>{gs(o)&&delete t[a].cache[n];});}),e.addCase(Br.pending,(t,r)=>{for(let n in t)for(let o in t[n].cache)t[n].cache[o].isActive=!1;if(!Qc(t,r.meta)){aP(t,r.meta);return}let a=Qc(t,r.meta);a.isLoading=!0,a.isActive=!0,a.error=null;}),e.addCase(Br.fulfilled,(t,r)=>{let{results:a,searchUid:n}=r.payload,{cacheTimeout:o}=r.meta.arg,i=Qc(t,r.meta);i.isActive=!0,i.searchUid=n,i.isLoading=!1,i.error=null,i.results=a,i.expiresAt=o?o+Date.now():0;}),e.addCase(Br.rejected,(t,r)=>{let a=Qc(t,r.meta);a.error=r.error||null,a.isLoading=!1,a.isActive=!1;});}),aP=(e,t)=>{let{q:r,id:a}=t.arg;e[a].cache[r]={isLoading:!0,error:null,results:[],expiresAt:0,isActive:!0,searchUid:""};},Qc=(e,t)=>{let{q:r,id:a}=t.arg;return e[a].cache[r]||null};var VS=k(Ae(),e=>{e.addCase(un,(t,r)=>{let a=np(t),n=r.payload;t.defaultNumberOfResults=t.numberOfResults=n,t.firstResult=Oi(a,n);}).addCase(ln,(t,r)=>{t.numberOfResults=r.payload,t.firstResult=0;}).addCase(dn,(t,r)=>{let a=r.payload;t.firstResult=Oi(a,t.numberOfResults);}).addCase(Lt,(t,r)=>{let a=r.payload;t.firstResult=Oi(a,t.numberOfResults);}).addCase(fn,t=>{let r=np(t),a=Math.max(r-1,Ra);t.firstResult=Oi(a,t.numberOfResults);}).addCase(pn,t=>{let r=np(t),a=nP(t),n=Math.min(r+1,a);t.firstResult=Oi(n,t.numberOfResults);}).addCase(ce.fulfilled,(t,r)=>{r.payload&&(t.numberOfResults=r.payload.pagination.numberOfResults,t.firstResult=r.payload.pagination.firstResult);}).addCase(ue,(t,r)=>{var a,n;t.firstResult=(a=r.payload.firstResult)!=null?a:t.firstResult,t.numberOfResults=(n=r.payload.numberOfResults)!=null?n:t.defaultNumberOfResults;}).addCase(T.fulfilled,(t,r)=>{let{response:a}=r.payload;t.totalCountFiltered=a.totalCountFiltered;}).addCase(lt.fulfilled,(t,r)=>{let{response:a}=r.payload;t.totalCountFiltered=a.pagination.totalCount;}).addCase(xe,t=>{It(t);}).addCase(Xt,t=>{It(t);}).addCase(zt,t=>{It(t);}).addCase(Yr,t=>{It(t);}).addCase(Un,t=>{It(t);}).addCase(er,t=>{It(t);}).addCase(rr,t=>{It(t);}).addCase(ke,t=>{It(t);}).addCase(xr,t=>{It(t);}).addCase(Rr,t=>{It(t);}).addCase(qa,t=>{It(t);});});function It(e){e.firstResult=Ae().firstResult;}function np(e){let{firstResult:t,numberOfResults:r}=e;return op(t,r)}function nP(e){let{totalCountFiltered:t,numberOfResults:r}=e;return ip(t,r)}function Oi(e,t){return (e-1)*t}function op(e,t){return Math.round(e/t)+1}function ip(e,t){let r=Math.min(e,xi);return Math.ceil(r/t)}var Yn=S("pipeline/set",e=>y(e,new O({required:!0,emptyAllowed:!0})));var NS=k(nt(),e=>{e.addCase(Yn,(t,r)=>r.payload).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.pipeline)!=null?n:t}).addCase(ut,(t,r)=>r.payload.pipeline||t);});k(Ls(),e=>{e.addCase(dS,(t,r)=>{t.url=r.payload.url;}).addCase(pS,(t,r)=>{t.additionalFields=r.payload.additionalFields;}).addCase(lt.rejected,(t,r)=>{t.error=r.payload?r.payload:null,t.isLoading=!1;}).addCase(lt.fulfilled,(t,r)=>{t.error=null,t.facets=r.payload.response.facets,t.products=r.payload.response.products,t.responseId=r.payload.response.responseId,t.isLoading=!1;}).addCase(lt.pending,t=>{t.isLoading=!0;});});k(en(),e=>{e.addCase(mg,(t,r)=>{t.id=r.payload.id;}).addCase(gg,(t,r)=>{t.skus=r.payload.skus;}).addCase(hg,(t,r)=>{t.filter.brand=r.payload.brand;}).addCase(Sg,(t,r)=>{t.filter.category=r.payload.category;}).addCase(vg,(t,r)=>{t.maxNumberOfRecommendations=r.payload.number;}).addCase(yg,(t,r)=>{t.additionalFields=r.payload.additionalFields;}).addCase(an.rejected,(t,r)=>{t.error=r.payload?r.payload:null,t.isLoading=!1;}).addCase(an.fulfilled,(t,r)=>{t.error=null,t.searchUid=r.payload.searchUid,t.recommendations=r.payload.recommendations,t.isLoading=!1;}).addCase(an.pending,t=>{t.isLoading=!0;});});var qi={id:q},Kn=S("querySuggest/register",e=>y(e,{...qi,count:new U({min:0})})),MS=S("querySuggest/unregister",e=>y(e,qi)),nr=S("querySuggest/selectSuggestion",e=>y(e,{...qi,expression:ie})),ra=S("querySuggest/clear",e=>y(e,qi)),aa=te("querySuggest/fetch",async(e,{getState:t,rejectWithValue:r,extra:{apiClient:a,validatePayload:n}})=>{n(e,qi);let o=e.id,i=await sP(o,t()),s=await a.querySuggest(i);return ge(s)?r(s.error):{id:o,q:i.q,...s.success}}),sP=async(e,t)=>({accessToken:t.configuration.accessToken,organizationId:t.configuration.organizationId,url:t.configuration.search.apiBaseUrl,count:t.querySuggest[e].count,q:t.querySet[e],locale:t.configuration.search.locale,timezone:t.configuration.search.timezone,actionsHistory:t.configuration.analytics.enabled?bt.getHistory():[],...t.context&&{context:t.context.contextValues},...t.pipeline&&{pipeline:t.pipeline},...t.searchHub&&{searchHub:t.searchHub},...t.configuration.analytics.enabled&&{visitorId:await Fe(t.configuration.analytics),...t.configuration.analytics.enabled&&await Nr(t.configuration.analytics)},...t.configuration.search.authenticationProviders.length&&{authentication:t.configuration.search.authenticationProviders.join(",")}});var QS={id:q,query:ie},Gn=S("querySet/register",e=>y(e,QS)),Va=S("querySet/update",e=>y(e,QS));var LS=k(Sa(),e=>{e.addCase(Gn,(t,r)=>{let{id:a,query:n}=r.payload;a in t||(t[a]=n);}).addCase(Va,(t,r)=>{let{id:a,query:n}=r.payload;sp(t,a,n);}).addCase(nr,(t,r)=>{let{id:a,expression:n}=r.payload;sp(t,a,n);}).addCase(T.fulfilled,(t,r)=>{let{queryExecuted:a}=r.payload;jS(t,a);}).addCase(ue,(t,r)=>{re(r.payload.q)||jS(t,r.payload.q);}).addCase(ce.fulfilled,(t,r)=>{if(!!r.payload)for(let[a,n]of Object.entries(r.payload.querySet))sp(t,a,n);});});function jS(e,t){Object.keys(e).forEach(r=>e[r]=t);}var sp=(e,t,r)=>{t in e&&(e[t]=r);};var US=k(Bd(),e=>e.addCase(Kn,(t,r)=>{let a=r.payload.id;a in t||(t[a]=cP(r.payload));}).addCase(MS,(t,r)=>{delete t[r.payload.id];}).addCase(aa.pending,(t,r)=>{let a=t[r.meta.arg.id];!a||(a.currentRequestId=r.meta.requestId,a.isLoading=!0);}).addCase(aa.fulfilled,(t,r)=>{let a=t[r.meta.arg.id];if(!a||r.meta.requestId!==a.currentRequestId)return;let{q:n}=r.payload;n&&a.partialQueries.push(n.replace(/;/,encodeURIComponent(";"))),a.responseId=r.payload.responseId,a.completions=r.payload.completions,a.isLoading=!1,a.error=null;}).addCase(aa.rejected,(t,r)=>{let a=t[r.meta.arg.id];!a||(a.error=r.payload||null,a.isLoading=!1);}).addCase(ra,(t,r)=>{let a=t[r.payload.id];!a||(a.responseId="",a.completions=[],a.partialQueries=[]);}));function cP(e){return {id:"",completions:[],responseId:"",count:5,currentRequestId:"",error:null,partialQueries:[],isLoading:!1,...e}}var BS=k(ve(),e=>e.addCase(ot,(t,r)=>({...t,...r.payload})).addCase(jt,(t,r)=>{t.q=r.payload;}).addCase(nr,(t,r)=>{t.q=r.payload.expression;}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.query)!=null?n:t}).addCase(ue,(t,r)=>{var a,n;t.q=(a=r.payload.q)!=null?a:t.q,t.enableQuerySyntax=(n=r.payload.enableQuerySyntax)!=null?n:t.enableQuerySyntax;}));var Lc=()=>new L({values:{questionAnswerId:q},options:{required:!0}}),cp=()=>new L({values:{linkText:ie,linkURL:ie},options:{required:!0}});function Jn(e){return y(e,Lc())}var Xn=S("smartSnippet/expand"),Zn=S("smartSnippet/collapse"),eo=S("smartSnippet/like"),to=S("smartSnippet/dislike"),ro=S("smartSnippet/feedbackModal/open"),na=S("smartSnippet/feedbackModal/close"),ao=S("smartSnippet/related/expand",e=>Jn(e)),no=S("smartSnippet/related/collapse",e=>Jn(e));var _S=(e,t)=>e.findIndex(r=>r.questionAnswerId===t.questionAnswerId);function $S({question:e,answerSnippet:t,documentId:{contentIdKey:r,contentIdValue:a}}){return rn({question:e,answerSnippet:t,contentIdKey:r,contentIdValue:a})}function uP(e,t){let r=$S(e);return t&&r===t.questionAnswerId?t:{contentIdKey:e.documentId.contentIdKey,contentIdValue:e.documentId.contentIdValue,expanded:!1,questionAnswerId:r}}var HS=k(bi(),e=>e.addCase(Xn,t=>{t.expanded=!0;}).addCase(Zn,t=>{t.expanded=!1;}).addCase(eo,t=>{t.liked=!0,t.disliked=!1,t.feedbackModalOpen=!1;}).addCase(to,t=>{t.liked=!1,t.disliked=!0;}).addCase(ro,t=>{t.feedbackModalOpen=!0;}).addCase(na,t=>{t.feedbackModalOpen=!1;}).addCase(T.fulfilled,(t,r)=>{let a=r.payload.response.questionAnswer.relatedQuestions.map((o,i)=>uP(o,t.relatedQuestions[i])),n=$S(r.payload.response.questionAnswer);return t.questionAnswerId===n?{...t,relatedQuestions:a}:{...bi(),relatedQuestions:a,questionAnswerId:n}}).addCase(ao,(t,r)=>{let a=_S(t.relatedQuestions,r.payload);a!==-1&&(t.relatedQuestions[a].expanded=!0);}).addCase(no,(t,r)=>{let a=_S(t.relatedQuestions,r.payload);a!==-1&&(t.relatedQuestions[a].expanded=!1);}));var lP={queries:new K({required:!0,each:new O({emptyAllowed:!1})}),maxLength:new U({required:!0,min:1,default:10})},oo=S("recentQueries/registerRecentQueries",e=>y(e,lP)),io=S("recentQueries/clearRecentQueries");var zS=k(zs(),e=>{e.addCase(oo,(t,r)=>{t.queries=r.payload.queries.slice(0,r.payload.maxLength),t.maxLength=r.payload.maxLength;}).addCase(io,t=>{t.queries=[];}).addCase(T.fulfilled,(t,r)=>{let a=r.payload.queryExecuted.trim(),n=r.payload.response.results;if(!a.length||!n.length)return;t.queries=t.queries.filter(i=>i!==a);let o=t.queries.slice(0,t.maxLength-1);t.queries=[a,...o];});});var dP={results:new K({required:!0,each:new L({values:fi})}),maxLength:new U({required:!0,min:1,default:10})},so=S("recentResults/registerRecentResults",e=>y(e,dP)),dt=S("recentResults/pushRecentResult",e=>(_e(e),{payload:e})),co=S("recentResults/clearRecentResults");k(Ws(),e=>{e.addCase(so,(t,r)=>{t.results=r.payload.results.slice(0,r.payload.maxLength),t.maxLength=r.payload.maxLength;}).addCase(co,t=>{t.results=[];}).addCase(dt,(t,r)=>{let a=r.payload;t.results=t.results.filter(o=>o.uniqueId!==a.uniqueId);let n=t.results.slice(0,t.maxLength-1);t.results=[a,...n];});});k(Mr(),e=>{e.addCase(Rg,(t,r)=>{t.id=r.payload.id;}).addCase(nn.rejected,(t,r)=>{t.error=r.payload?r.payload:null,t.isLoading=!1;}).addCase(nn.fulfilled,(t,r)=>{t.error=null,t.recommendations=r.payload.recommendations,t.duration=r.payload.duration,t.isLoading=!1,t.searchUid=r.payload.searchUid,t.splitTestRun=r.payload.splitTestRun,t.pipeline=r.payload.pipeline;}).addCase(nn.pending,t=>{t.isLoading=!0;});});async function jc(e,t){var s;let{search:r,accessToken:a,organizationId:n,analytics:o}=e.configuration,i=((s=e.query)==null?void 0:s.q)||"";return {url:r.apiBaseUrl,accessToken:a,organizationId:n,enableNavigation:!1,...o.enabled&&{visitorId:await Fe(e.configuration.analytics)},q:i,...t,requestedOutputSize:t.requestedOutputSize||0,...r.authenticationProviders.length&&{authentication:r.authenticationProviders.join(",")}}}var Na=te("resultPreview/fetchResultContent",async(e,{extra:t,getState:r,rejectWithValue:a})=>{let n=r(),o=await jc(n,e),i=await t.apiClient.html(o);return ge(i)?a(i.error):{content:i.success,uniqueId:e.uniqueId}}),uo=S("resultPreview/next"),lo=S("resultPreview/previous"),po=S("resultPreview/prepare",e=>y(e,{results:new K({required:!0})})),YS=2048,fo=te("resultPreview/updateContentURL",async(e,{getState:t,extra:r})=>{let a=t(),n=Jm(await e.buildResultPreviewRequest(a,{uniqueId:e.uniqueId,requestedOutputSize:e.requestedOutputSize}),e.path);return (n==null?void 0:n.length)>YS&&r.logger.error(`The content URL was truncated as it exceeds the maximum allowed length of ${YS} characters.`),{contentURL:n}});var up=e=>e.filter(t=>t.hasHtmlVersion).map(t=>t.uniqueId),KS=k(_r(),e=>{e.addCase(Na.pending,t=>{t.isLoading=!0;}).addCase(Na.fulfilled,(t,r)=>{let{content:a,uniqueId:n}=r.payload;t.position=t.resultsWithPreview.indexOf(n),t.content=a,t.uniqueId=n,t.isLoading=!1;}).addCase(T.fulfilled,(t,r)=>{let{content:a,isLoading:n,uniqueId:o,contentURL:i}=_r();t.content=a,t.isLoading=n,t.uniqueId=o,t.contentURL=i,t.resultsWithPreview=up(r.payload.response.results);}).addCase(ct.fulfilled,(t,r)=>{t.resultsWithPreview=t.resultsWithPreview.concat(up(r.payload.response.results));}).addCase(po,(t,r)=>{t.resultsWithPreview=up(r.payload.results);}).addCase(uo,t=>{if(t.isLoading)return;let r=t.position+1;r>t.resultsWithPreview.length-1&&(r=0),t.position=r;}).addCase(lo,t=>{if(t.isLoading)return;let r=t.position-1;r<0&&(r=t.resultsWithPreview.length-1),t.position=r;}).addCase(fo.fulfilled,(t,r)=>{t.contentURL=r.payload.contentURL;});});var GS=k(Ee(),e=>{e.addCase(ta,(t,r)=>r.payload).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.searchHub)!=null?n:t}).addCase(ut,(t,r)=>r.payload.searchHub||t);});function lp(e,t){var a;let r=(a=t.payload)!=null?a:null;r&&(e.response=Ze().response,e.results=[],e.questionAnswer=Xa()),e.error=r,e.isLoading=!1;}function dp(e,t){e.error=null,e.response=t.payload.response,e.queryExecuted=t.payload.queryExecuted,e.duration=t.payload.duration,e.isLoading=!1;}function fP(e,t){dp(e,t),e.results=t.payload.response.results,e.searchResponseId=t.payload.response.searchUid,e.questionAnswer=t.payload.response.questionAnswer;}function pp(e,t){e.isLoading=!0,e.requestId=t.meta.requestId;}var JS=k(Ze(),e=>{e.addCase(T.rejected,(t,r)=>lp(t,r)),e.addCase(ct.rejected,(t,r)=>lp(t,r)),e.addCase(Ye.rejected,(t,r)=>lp(t,r)),e.addCase(T.fulfilled,(t,r)=>{fP(t,r);}),e.addCase(ct.fulfilled,(t,r)=>{dp(t,r),t.results=[...t.results,...r.payload.response.results];}),e.addCase(Ye.fulfilled,(t,r)=>{dp(t,r),t.results=r.payload.response.results;}),e.addCase(Ke.fulfilled,(t,r)=>{t.response.facets=r.payload.response.facets,t.response.searchUid=r.payload.response.searchUid;}),e.addCase(T.pending,pp),e.addCase(ct.pending,pp),e.addCase(Ye.pending,pp);});var XS={by:new Tt({enum:Bt,required:!0})},mo=S("sortCriteria/register",e=>ZS(e)),go=S("sortCriteria/update",e=>ZS(e)),ZS=e=>Ya(e)?(e.forEach(t=>y(t,XS)),{payload:e}):y(e,XS);var ey=k(et(),e=>{e.addCase(mo,(t,r)=>Sr(r.payload)).addCase(go,(t,r)=>Sr(r.payload)).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.sortCriteria)!=null?n:t}).addCase(ue,(t,r)=>{var a;return (a=r.payload.sortCriteria)!=null?a:t});});var mP={by:new Tt({enum:Ia,required:!0})},ty=S("sort/register",e=>ay(e)),ry=S("sort/update",e=>ay(e)),ay=e=>y(e,mP);k(js(),e=>{e.addCase(ty,(t,r)=>r.payload).addCase(ry,(t,r)=>r.payload);});function ny(e){return e.type==="redirect"}var fp=class{constructor(t){this.response=t;}get basicExpression(){return this.response.parsedInput.basicExpression}get largeExpression(){return this.response.parsedInput.largeExpression}get redirectionUrl(){let t=this.response.preprocessingOutput.triggers.filter(ny);return t.length?t[0].content:null}};var ho=S("standaloneSearchBox/register",e=>y(e,{id:q,redirectionUrl:q})),So=S("standaloneSearchBox/reset",e=>y(e,{id:q})),yo=S("standaloneSearchBox/updateAnalyticsToSearchFromLink",e=>y(e,{id:q})),vo=S("standaloneSearchBox/updateAnalyticsToOmniboxFromLink"),oa=te("standaloneSearchBox/fetchRedirect",async(e,{dispatch:t,getState:r,rejectWithValue:a,extra:{apiClient:n,validatePayload:o}})=>{o(e,{id:new O({emptyAllowed:!1})});let i=await SP(r()),s=await n.plan(i);if(ge(s))return a(s.error);let{redirectionUrl:u}=new fp(s.success);return u&&t(hP(u)),u||""}),hP=e=>Q("analytics/standaloneSearchBox/redirect",M.Custom,t=>t.makeTriggerRedirect({redirectedTo:e})),SP=async e=>({accessToken:e.configuration.accessToken,organizationId:e.configuration.organizationId,url:e.configuration.search.apiBaseUrl,locale:e.configuration.search.locale,timezone:e.configuration.search.timezone,q:e.query.q,...e.context&&{context:e.context.contextValues},...e.pipeline&&{pipeline:e.pipeline},...e.searchHub&&{searchHub:e.searchHub},...e.configuration.analytics.enabled&&{visitorId:await Fe(e.configuration.analytics)},...e.configuration.analytics.enabled&&await Nr(e.configuration.analytics),...e.configuration.search.authenticationProviders.length&&{authentication:e.configuration.search.authenticationProviders.join(",")}});var oy=k(Ys(),e=>e.addCase(ho,(t,r)=>{let{id:a,redirectionUrl:n}=r.payload;a in t||(t[a]=iy(n));}).addCase(So,(t,r)=>{let{id:a}=r.payload,n=t[a];if(n){t[a]=iy(n.defaultRedirectionUrl);return}}).addCase(oa.pending,(t,r)=>{let a=t[r.meta.arg.id];!a||(a.isLoading=!0);}).addCase(oa.fulfilled,(t,r)=>{let a=r.payload,n=t[r.meta.arg.id];!n||(n.redirectTo=a||n.defaultRedirectionUrl,n.isLoading=!1);}).addCase(oa.rejected,(t,r)=>{let a=t[r.meta.arg.id];!a||(a.isLoading=!1);}).addCase(yo,(t,r)=>{let a=t[r.payload.id];!a||(a.analytics.cause="searchFromLink");}).addCase(vo,(t,r)=>{let a=t[r.payload.id];!a||(a.analytics.cause="omniboxFromLink",a.analytics.metadata=r.payload.metadata);}));function iy(e){return {defaultRedirectionUrl:e,redirectTo:"",isLoading:!1,analytics:{cause:"",metadata:null}}}var Co=q,mp=new L({options:{required:!0},values:{caption:ie,expression:ie,state:new O({constrainTo:["idle","selected"]})}}),Uc=new K({required:!0,each:mp});var xo=S("staticFilter/register",e=>y(e,{id:Co,values:Uc})),br=S("staticFilter/toggleSelect",e=>y(e,{id:Co,value:mp})),Ma=S("staticFilter/deselectAllFilterValues",e=>y(e,Co)),Ro=e=>Q("analytics/staticFilter/deselect",M.Search,t=>t.makeStaticFilterDeselect(e));k(ya(),e=>e.addCase(xo,(t,r)=>{let a=r.payload,{id:n}=a;n in t||(t[n]=a);}).addCase(br,(t,r)=>{let{id:a,value:n}=r.payload,o=t[a];if(!o)return;let i=o.values.find(u=>u.caption===n.caption);if(!i)return;let s=i.state==="selected";i.state=s?"idle":"selected";}).addCase(Ma,(t,r)=>{let a=r.payload,n=t[a];!n||n.values.forEach(o=>o.state="idle");}).addCase(ke,t=>{Object.values(t).forEach(r=>{r.values.forEach(a=>a.state="idle");});}).addCase(ue,(t,r)=>{let a=r.payload.sf||{};Object.entries(t).forEach(([n,o])=>{let i=a[n]||[];o.values.forEach(s=>{s.state=i.includes(s.caption)?"selected":"idle";});});}));var cy=k(va(),e=>{e.addCase(Pn,(t,r)=>{let a=r.payload,{id:n}=a;n in t||(t[n]={...a,isActive:!1});}).addCase(Cr,(t,r)=>{let a=r.payload;uy(t,a);}).addCase(ue,(t,r)=>{let a=r.payload.tab||"";uy(t,a);}).addCase(ce.fulfilled,(t,r)=>{var a,n;return (n=(a=r.payload)==null?void 0:a.tabSet)!=null?n:t});});function uy(e,t){t in e&&Object.keys(e).forEach(a=>{e[a].isActive=a===t;});}var ly=k(Ks(),e=>e.addCase(T.pending,t=>{t.query="",t.queryModification={originalQuery:"",newQuery:"",queryToIgnore:t.queryModification.queryToIgnore};}).addCase(T.fulfilled,(t,r)=>{var s;let a=[],o=[],i=[];r.payload.response.triggers.forEach(u=>{switch(u.type){case"redirect":a.push(u.content);break;case"query":break;case"execute":o.push({functionName:u.content.name,params:u.content.params});break;case"notify":i.push(u.content);break}}),t.redirectTo=(s=a[0])!=null?s:"",t.query=t.queryModification.newQuery,t.executions=o,t.notifications=i;}).addCase(Rs,(t,r)=>{t.queryModification={...r.payload,queryToIgnore:""};}).addCase(yn,(t,r)=>{t.queryModification.queryToIgnore=r.payload;}));var W=jh,or=VS,ir=fS,bo=lS,G=JS,$c=PS,sr=SS,Hc=oS,pt=vS,cr=rS,Oe=eS,Fo=uS,ft=BS,Ao=LS,Wc=DS,Yc=cy,Po=US,Kc=ey,Xc=zh,ia=RS,Io=NS,Eo=GS,wo=_h,Zc=KS,py=$h,sa=ly,ur=HS,eu=oy,ru=zS;var au=nh({actionTypes:{redo:yd.type,undo:Sd.type,snapshot:Lr.type},reducer:kS});function nu(e,t,r){var a,n,o;t===void 0&&(t=50),r===void 0&&(r={});var i=(a=r.isImmediate)!=null&&a,s=(n=r.callback)!=null&&n,u=r.maxWait,c=Date.now(),l=[];function p(){if(u!==void 0){var d=Date.now()-c;if(d+t>=u)return u-d}return t}var f=function(){var d=[].slice.call(arguments),m=this;return new Promise(function(h,v){var C=i&&o===void 0;if(o!==void 0&&clearTimeout(o),o=setTimeout(function(){if(o=void 0,c=Date.now(),!i){var b=e.apply(m,d);s&&s(b),l.forEach(function(P){return (0, P.resolve)(b)}),l=[];}},p()),C){var x=e.apply(m,d);return s&&s(x),h(x)}l.push({resolve:h,reject:v});})};return f.cancel=function(d){o!==void 0&&clearTimeout(o),l.forEach(function(m){return (0, m.reject)(d)}),l=[];},f}function my(e,t){let r=0,a=nu(()=>r=0,500);return n=>o=>async i=>{if(!(typeof i=="function"))return o(i);let u=await o(i);if(!yP(u))return u;if(typeof t!="function")return e.warn("Unable to renew the expired token because a renew function was not provided. Please specify the #renewAccessToken option when initializing the engine."),u;if(r>=5)return e.warn("Attempted to renew the token but was not successful. Please check the #renewAccessToken function."),u;r++,a();let c=await vP(t);n.dispatch($t({accessToken:c})),n.dispatch(i);}}function yP(e){var t;return ((t=e.error)==null?void 0:t.name)===new li().name}async function vP(e){try{return await e()}catch(t){return ""}}function gy({reducer:e,preloadedState:t,middlewares:r=[],thunkExtraArguments:a,name:n}){return Al({reducer:e,preloadedState:t,devTools:{stateSanitizer:o=>o.history?{...o,history:"<<OMIT>>"}:o,name:n,shouldHotReload:!1},middleware:o=>[...r,...o({thunk:{extraArgument:a}}),Os(a.logger)]})}var CP={configuration:W,version:py};function xP(e,t){var n;let{analyticsClientMiddleware:r,...a}=(n=e.configuration.analytics)!=null?n:{};return cs()?(t.info("Analytics disabled since doNotTrack is active."),{...a,enabled:!1}):e.configuration.analytics?a:null}function hy(e,t){let r=RP(e,t),{accessToken:a,organizationId:n,platformUrl:o}=e.configuration;r.dispatch($t({accessToken:a,organizationId:n,platformUrl:o}));let i=xP(e,r.logger);return i&&r.dispatch(Hr(i)),r}function RP(e,t){let{reducers:r}=e,a=Ph({...CP,...r});e.crossReducer&&a.addCrossReducer(e.crossReducer);let n=t.logger,o=bP(e,t,a);return {addReducers(i){a.containsAll(i)||(a.add(i),o.replaceReducer(a.combinedReducer));},dispatch:o.dispatch,subscribe:o.subscribe,enableAnalytics(){o.dispatch(An());},disableAnalytics(){o.dispatch(Fn());},get state(){return o.getState()},logger:n,store:o}}function bP(e,t,r){let{preloadedState:a,configuration:n}=e,o=n.name||"coveo-headless",i=FP(e,t.logger);return gy({preloadedState:a,reducer:r.combinedReducer,middlewares:i,thunkExtraArguments:t,name:o})}function FP(e,t){let{renewAccessToken:r}=e.configuration,a=my(t,r);return [ws,a,ks(t),Es].concat(e.middlewares||[])}var Sy=be(ri());function yy(e){return (0, Sy.default)({name:"@coveo/headless",level:(e==null?void 0:e.level)||"warn",formatters:{log:e==null?void 0:e.logFormatter},browser:{transmit:{send:(e==null?void 0:e.browserPostLogHook)||(()=>{})}}})}function vy(e,t){let r=AP(e),a=ze,n=PP(e);return {analyticsClientMiddleware:r,validatePayload:a,preprocessRequest:n,logger:t}}function AP(e){let{analytics:t}=e,r=(a,n)=>n;return (t==null?void 0:t.analyticsClientMiddleware)||r}function PP(e){return e.preprocessRequest||Fa}var Cy=be(md());var gp=(e,t,r,a,n,o)=>{let i=e[t];re(i)||re(n)||n!==i&&n!==a&&(o.warn(`Mismatch on access token (JWT Token) ${t} and engine configuration.`),o.warn(`To remove this warning, make sure that access token value [${i}] matches engine configuration value [${r}]`));},hp=(e,t)=>!(re(e)||t===e),Ti=e=>{try{let t=typeof atob!="undefined"?atob:Cy.atob,a=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=t(a);if(!n)return !1;let o=decodeURIComponent(n.split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(o)}catch(t){return !1}},xy=(e,t)=>(hp(e.searchHub,t.searchHub)&&(t.searchHub=e.searchHub),t),Ry=(e,t,r,a)=>(gp(e,"searchHub",t.searchHub,Ee(),r,a),xy(e,t)),by=(e,t)=>(hp(e.pipeline,t.pipeline)&&(t.pipeline=e.pipeline),t),Fy=(e,t,r,a)=>(gp(e,"pipeline",t.pipeline,nt(),r,a),by(e,t)),Ay=(e,t)=>(hp(e.userDisplayName,t.configuration.analytics.userDisplayName)&&(t.configuration.analytics.userDisplayName=e.userDisplayName),t),IP=(e,t,r,a)=>(gp(e,"userDisplayName",t.configuration.analytics.userDisplayName,Ne().analytics.userDisplayName,r,a),Ay(e,t)),Py=e=>k({},t=>{t.addCase(ta,(r,a)=>{let n=Ti(r.configuration.accessToken);return n?Ry(n,r,a.payload,e):r}).addCase(Yn,(r,a)=>{let n=Ti(r.configuration.accessToken);return n?Fy(n,r,a.payload,e):r}).addCase($t,(r,a)=>{if(r.configuration.accessToken!==a.payload.accessToken)return r;let{accessToken:n}=a.payload;if(!n)return r;let o=Ti(n);return o?[by,xy,Ay].reduce((i,s)=>s(o,i),r):r}).addCase(ut,(r,a)=>{var s;let n=Ti(r.configuration.accessToken);if(!n)return r;let o=Ry(n,r,a.payload.searchHub,e);return Fy(n,o,(s=a.payload)==null?void 0:s.pipeline,e)}).addCase(Hr,(r,a)=>{let n=Ti(r.configuration.accessToken);return n?IP(n,r,a.payload.userDisplayName,e):r});});var Iy={organizationId:q,accessToken:q,platformUrl:new O({required:!1,emptyAllowed:!1}),name:new O({required:!1,emptyAllowed:!1}),analytics:new L({options:{required:!1},values:{enabled:new J({required:!1}),originContext:new O({required:!1}),originLevel2:new O({required:!1}),originLevel3:new O({required:!1})}})};var wy=new Z({...Iy,search:new L({options:{required:!1},values:{pipeline:new O({required:!1,emptyAllowed:!0}),searchHub:oe,locale:oe,timezone:oe,authenticationProviders:new K({required:!1,each:q})}})});var EP={debug:wo,pipeline:Io,searchHub:Eo,search:G};function wP(e){let t=yy(e.loggerOptions);kP(e.configuration,t);let r=OP(e.configuration,t),a={...vy(e.configuration,t),apiClient:r},n={...e,reducers:EP,crossReducer:Py(t)},o=hy(n,a),{search:i}=e.configuration;return i&&o.dispatch(ut(i)),{...o,get state(){return o.state},executeFirstSearch(s=Xs()){if(ac(o.state))return;let c=T(s);o.dispatch(c);},executeFirstSearchAfterStandaloneSearchBoxRedirect(s){let{cause:u,metadata:c}=s,l=c&&u==="omniboxFromLink"?ec(c):Zs();this.executeFirstSearch(l);}}}function kP(e,t){try{wy.validate(e);}catch(r){throw t.error(r,"Search engine configuration error"),r}}function OP(e,t){let{search:r}=e;return new pi({logger:t,preprocessRequest:e.preprocessRequest||Fa,postprocessSearchResponseMiddleware:(r==null?void 0:r.preprocessSearchResponseMiddleware)||Us,postprocessFacetSearchResponseMiddleware:(r==null?void 0:r.preprocessFacetSearchResponseMiddleware)||Bs,postprocessQuerySuggestResponseMiddleware:(r==null?void 0:r.preprocessQuerySuggestResponseMiddleware)||_s})}function B(e){let t,r=new Map,a=()=>r.size===0,n=o=>{try{let i=JSON.stringify(o),s=t!==i;return t=i,s}catch(i){return console.warn('Could not detect if state has changed, check the controller "get state method"',i),!0}};return {subscribe(o){o();let i=Symbol(),s;return a()&&(t=JSON.stringify(this.state),s=e.subscribe(()=>{n(this.state)&&r.forEach(u=>u());})),r.set(i,o),()=>{r.delete(i),a()&&s&&s();}},get state(){return {}}}}function Ny(e){if(!UP(e));let t=B(e),{dispatch:r}=e;r(gn());let a=()=>e.state;return {...t,get state(){let n=a();return {originalQuery:n.didYouMean.originalQuery,wasCorrectedTo:n.didYouMean.wasCorrectedTo,wasAutomaticallyCorrected:n.didYouMean.wasAutomaticallyCorrected,queryCorrection:n.didYouMean.queryCorrection,hasQueryCorrection:n.didYouMean.queryCorrection.correctedQuery!==""||n.didYouMean.wasCorrectedTo!==""}},applyCorrection(){r(jt(this.state.queryCorrection.correctedQuery));}}}function UP(e){return e.addReducers({configuration:W,didYouMean:Xc}),!0}function BP(e){let t=Ny(e),{dispatch:r}=e;return {...t,get state(){return t.state},applyCorrection(){t.applyCorrection(),r(T(fs()));}}}var ko=e=>Q("analytics/facet/showMore",M.Search,(t,r)=>{y(e,ee);let a=Ja(e,Rt(r));return t.makeFacetShowMore(a)}),Oo=e=>Q("analytics/facet/showLess",M.Search,(t,r)=>{y(e,ee);let a=Ja(e,Rt(r));return t.makeFacetShowLess(a)}),lr=e=>Q("analytics/facet/sortChange",M.Search,(t,r)=>{y(e,{facetId:ee,criterion:new de({required:!0})});let{facetId:a,criterion:n}=e,o=Rt(r),s={...Ja(a,o),criteria:n};return t.makeFacetUpdateSort(s)}),Ue=e=>Q("analytics/facet/reset",M.Search,(t,r)=>{y(e,ee);let a=Rt(r),n=Ja(e,a);return t.makeFacetClearAll(n)}),Re=e=>Q("analytics/facet/select",M.Search,(t,r)=>{y(e,{facetId:ee,facetValue:q});let a=Rt(r),n=es(e,a);return t.makeFacetSelect(n)}),Et=e=>Q("analytics/facet/deselect",M.Search,(t,r)=>{y(e,{facetId:ee,facetValue:q});let a=Rt(r),n=es(e,a);return t.makeFacetDeselect(n)}),ou=e=>Q("analytics/facet/breadcrumb",M.Search,(t,r)=>{y(e,{facetId:ee,facetValue:q});let a=es(e,Rt(r));return t.makeBreadcrumbFacet(a)});var dr=(e,t)=>{var r,a;return (a=(r=e.facetOptions.facets[t])==null?void 0:r.enabled)!=null?a:!0};function My(e,t){let{field:r,state:a}=e;if(!_P(e))return r;let n=`${r}_`,o=$P(n,a);return zP(r,t),`${n}${o}`}function _P(e){let{field:t,state:r}=e;return Qy(r).some(n=>n&&t in n)}function $P(e,t){let a=Qy(t).map(n=>Object.keys(n||{})).reduce((n,o)=>n.concat(o),[]);return HP(a,e)+1}function Qy(e){let{facetSet:t,numericFacetSet:r,dateFacetSet:a,categoryFacetSet:n}=e;return [t,r,a,n]}function HP(e,t){let r=0,n=e.map(o=>{let i=o.split(t)[1],s=parseInt(i,10);return Number.isNaN(s)?r:s}).sort().pop();return n!=null?n:r}function zP(e,t){let r=`A facet with field "${e}" already exists.
|
|
3866
|
+
To avoid unexpected behaviour, configure the #id option on the facet controller.`;t.warn(r);}function Be(e,t){let{state:r,logger:a}=e,{field:n,facetId:o}=t;return o||My({field:n,state:r},a)}var Ly=["alphanumeric","occurrences"];var jy=new Z({field:Yt,basePath:Yh,delimitingCharacter:Kh,facetId:Wt,facetSearch:Vn,filterByBasePath:Gh,filterFacetCount:Kt,injectionDepth:Gt,numberOfValues:At,sortCriteria:new O({constrainTo:Ly})});function Uy(e,t){if(!WP(e));let r=B(e),{dispatch:a}=e,n=Be(e,t.options),o={...Ii,...ss("facetSearch",t.options),field:t.options.field,facetId:n},i={facetSearch:{...ar,...t.options.facetSearch},...o};pe(e,jy,i,"buildCategoryFacet");let s=()=>Gl(e.state,n),u=()=>Kl(e.state,n),c=()=>Vt(e.state),l=()=>dr(e.state,n);return a(Ht(o)),{...r,toggleSelect(p){let f=i.numberOfValues;a(Yr({facetId:n,selection:p,retrieveCount:f})),a(se({freezeFacetOrder:!0}));},deselectAll(){a(zt(n)),a(se({freezeFacetOrder:!0}));},sortBy(p){a(Dn({facetId:n,criterion:p})),a(se({freezeFacetOrder:!0}));},isSortedBy(p){return s().sortCriteria===p},showMoreValues(){let{numberOfValues:p}=i,{values:f}=this.state,d=f.length+p;a(Ea({facetId:n,numberOfValues:d})),a(se({freezeFacetOrder:!0}));},showLessValues(){let{numberOfValues:p}=i;a(Ea({facetId:n,numberOfValues:p})),a(se({freezeFacetOrder:!0}));},enable(){a(je(n));},disable(){a(ye(n));},get state(){let p=s(),f=u(),d=c(),m=l(),{parents:h,values:v}=Xe(f==null?void 0:f.values),C=h.length!==0,x=h.length>0?h[h.length-1].moreValuesAvailable:(f==null?void 0:f.moreValuesAvailable)||!1,b=v.length>i.numberOfValues;return {facetId:n,parents:h,values:v,isLoading:d,hasActiveValues:C,canShowMoreValues:x,canShowLessValues:b,sortCriteria:p.sortCriteria,enabled:m}}}}function WP(e){return e.addReducers({categoryFacetSet:cr,categoryFacetSearchSet:Fo,facetOptions:Oe,configuration:W,search:G}),!0}function qo(e,t){let r=e.dispatch,{options:a,getFacetSearch:n}=t,{facetId:o}=a;return {updateText(i){r(Gr({facetId:o,query:i,numberOfValues:n().initialNumberOfValues}));},showMoreResults(){let{initialNumberOfValues:i,options:s}=n();r(Gr({facetId:o,numberOfValues:s.numberOfValues+i})),r(t.isForFieldSuggestions?Kd(o):Pt(o));},search(){r(t.isForFieldSuggestions?Kd(o):Pt(o));},clear(){r($n({facetId:o}));},updateCaptions(i){r(Gr({facetId:o,captions:i}));},get state(){let{response:i,isLoading:s,options:u}=n(),{query:c}=u,l=i.values;return {...i,values:l,isLoading:s,query:c}}}}function By(e,t){let{dispatch:r}=e,a={...ar,...t.options},{facetId:n}=a,o=()=>e.state.categoryFacetSearchSet[n];r(Bn(a));let i=qo(e,{options:a,getFacetSearch:o,isForFieldSuggestions:t.isForFieldSuggestions});return {...i,select(s){r(Un({facetId:n,value:s}));},get state(){return i.state}}}function iu(e,t){let{dispatch:r}=e,a={...ar,...t.options},{facetId:n}=a,o=()=>e.state.categoryFacetSearchSet[n],i=By(e,{options:{...a},isForFieldSuggestions:t.isForFieldSuggestions});r(Bn(a));let s=qo(e,{options:a,getFacetSearch:o,isForFieldSuggestions:t.isForFieldSuggestions});return {...s,...i,select:u=>{i.select(u),r(se({freezeFacetOrder:!0})),r(T(Re({facetId:n,facetValue:u.rawValue})));},get state(){return {...s.state,...i.state}}}}function YP(e,t){if(!KP(e));let r=Uy(e,t),{dispatch:a}=e,n=()=>r.state.facetId,o=iu(e,{options:{facetId:n(),...t.options.facetSearch},isForFieldSuggestions:!1}),{state:i,...s}=o;return {...r,facetSearch:s,toggleSelect(u){r.toggleSelect(u);let c=GP(n(),u);a(T(c));},deselectAll(){r.deselectAll(),a(T(Ue(n())));},sortBy(u){r.sortBy(u),a(T(lr({facetId:n(),criterion:u})));},showMoreValues(){r.showMoreValues(),a(Ke(ko(n())));},showLessValues(){r.showLessValues(),a(Ke(Oo(n())));},get state(){return {...r.state,facetSearch:o.state}}}}function KP(e){return e.addReducers({categoryFacetSet:cr,categoryFacetSearchSet:Fo,configuration:W,search:G}),!0}function GP(e,t){let r={facetId:e,facetValue:t.value};return t.state==="selected"?Et(r):Re(r)}var Sp=e=>e.state==="selected",_y=(e,t)=>{let r={facetId:e,facetValue:t.value};return Sp(t)?Et(r):Re(r)};function su(e,t){let{dispatch:r}=e,{options:a,select:n,isForFieldSuggestions:o}=t,{facetId:i}=a,s=()=>e.state.facetSearchSet[i];r(Ec(a));let u=qo(e,{options:a,getFacetSearch:s,isForFieldSuggestions:o});return {...u,select(c){r(qa({facetId:i,value:c})),n(c);},singleSelect(c){r(xe(i)),r(qa({facetId:i,value:c})),n(c);},get state(){let{values:c}=u.state;return {...u.state,values:c.map(({count:l,displayValue:p,rawValue:f})=>({count:l,displayValue:p,rawValue:f}))}}}}var JP={facetId:ee,selection:new L({values:fc})},$y=te("facet/executeToggleSelect",({facetId:e,selection:t},r)=>{let{dispatch:a,extra:{validatePayload:n}}=r;n({facetId:e,selection:t},JP),a(Xt({facetId:e,selection:t})),a(se({freezeFacetOrder:!0}));});var cu=["score","alphanumeric","occurrences","automatic"];var Hy=new Z({facetId:Wt,field:Yt,filterFacetCount:Kt,injectionDepth:Gt,numberOfValues:At,sortCriteria:new O({constrainTo:cu}),facetSearch:Vn});function zy(e,t,r=Hy){if(!XP(e));let{dispatch:a}=e,n=B(e),o=Be(e,t.options),i={...wi,...ss("facetSearch",t.options),field:t.options.field,facetId:o},s={facetSearch:{...ar,...t.options.facetSearch},...i};pe(e,r,s,"buildFacet");let u=()=>Wl(e.state,o),c=()=>Zi(e.state,o),l=()=>Vt(e.state),p=()=>dr(e.state,o),f=()=>{let{currentValues:m}=u();return m.filter(h=>h.state!=="idle").length},d=()=>{let{currentValues:m}=u(),h=s.numberOfValues,v=!!m.find(C=>C.state==="idle");return h<m.length&&v};return a(Jt(i)),{...n,toggleSelect:m=>a($y({facetId:s.facetId,selection:m})),toggleSingleSelect:function(m){m.state==="idle"&&a(xe(o)),this.toggleSelect(m);},isValueSelected:Sp,deselectAll(){a(xe(o)),a(se({freezeFacetOrder:!0}));},sortBy(m){a(Nn({facetId:o,criterion:m})),a(se({freezeFacetOrder:!0}));},isSortedBy(m){return this.state.sortCriterion===m},showMoreValues(){let m=u().numberOfValues,h=s.numberOfValues,v=h-m%h,C=m+v;a(wa({facetId:o,numberOfValues:C})),a(ka({facetId:o,isFieldExpanded:!0})),a(se({freezeFacetOrder:!0}));},showLessValues(){let m=s.numberOfValues,h=Math.max(m,f());a(wa({facetId:o,numberOfValues:h})),a(ka({facetId:o,isFieldExpanded:!1})),a(se({freezeFacetOrder:!0}));},enable(){a(je(o));},disable(){a(ye(o));},get state(){let m=u(),h=c(),v=l(),C=p(),x=m.sortCriteria,b=h?h.values:[],P=b.some(X=>X.state!=="idle"),_=h?h.moreValuesAvailable:!1;return {facetId:o,values:b,sortCriterion:x,isLoading:v,hasActiveValues:P,canShowMoreValues:_,canShowLessValues:d(),enabled:C}}}}function XP(e){return e.addReducers({facetSet:ir,facetOptions:Oe,configuration:W,facetSearchSet:bo}),!0}var Wy=new Z({facetId:Wt,field:Yt,filterFacetCount:Kt,injectionDepth:Gt,numberOfValues:At,sortCriteria:new O({constrainTo:cu}),facetSearch:Vn,allowedValues:pc,hasBreadcrumbs:Jh});function ZP(e,t){if(!eI(e));let{dispatch:r}=e,a=zy(e,{...t,options:{...t.options,...t.options.allowedValues&&{allowedValues:{type:"simple",values:t.options.allowedValues}}}},Wy),n=()=>a.state.facetId,i=(()=>{let{facetSearch:c}=t.options;return su(e,{options:{facetId:n(),...c},select:l=>{r(se({freezeFacetOrder:!0})),r(T(Re({facetId:n(),facetValue:l.rawValue})));},isForFieldSuggestions:!1})})(),{state:s,...u}=i;return {...a,facetSearch:u,toggleSelect(c){a.toggleSelect(c),r(T(_y(n(),c)));},deselectAll(){a.deselectAll(),r(T(Ue(n())));},sortBy(c){a.sortBy(c),r(T(lr({facetId:n(),criterion:c})));},isSortedBy(c){return this.state.sortCriterion===c},showMoreValues(){a.showMoreValues(),r(Ke(ko(n())));},showLessValues(){a.showLessValues(),r(Ke(Oo(n())));},get state(){return {...a.state,facetSearch:i.state}}}}function eI(e){return e.addReducers({facetSet:ir,configuration:W,facetSearchSet:bo,search:G}),!0}var yp=e=>e.state==="selected",uu=(e,t)=>{let r=`${t.start}..${t.end}`,a={facetId:e,facetValue:r};return yp(t)?Et(a):Re(a)};var lu=S("rangeFacet/executeToggleSelect",e=>y(e,jn(e.selection)));var tI={facetId:ee,selection:new L({values:Ln})},Yy=te("dateFacet/executeToggleSelect",(e,{dispatch:t,extra:{validatePayload:r}})=>{r(e,tI),t(er(e)),t(lu(e)),t(se({freezeFacetOrder:!0}));});function du(e,t){let{facetId:r,getRequest:a}=t,n=B(e),o=e.dispatch,i=()=>dr(e.state,r);return {...n,isValueSelected:yp,deselectAll(){o(xe(r)),o(se({freezeFacetOrder:!0}));},sortBy(s){o(Mn({facetId:r,criterion:s})),o(se({freezeFacetOrder:!0}));},isSortedBy(s){return this.state.sortCriterion===s},enable(){o(je(r));},disable(){o(ye(r));},get state(){let s=a(),u=Dt(e.state,r),c=s.sortCriteria,l=u?u.values:[],p=Vt(e.state),f=i(),d=l.some(m=>m.state!=="idle");return {facetId:r,values:l,sortCriterion:c,hasActiveValues:d,isLoading:p,enabled:f}}}}function pu(e,t){if(!e.generateAutomaticRanges&&e.currentValues===void 0){let r=`currentValues should be specified for ${t} when generateAutomaticRanges is false.`;throw new Error(r)}}var fu=["idle","selected"];var mu=["ascending","descending"],gu=["even","equiprobable"];var rI={start:new O,end:new O,endInclusive:new J,state:new O({constrainTo:fu})},aI=new Z({facetId:Wt,field:Yt,generateAutomaticRanges:dc,filterFacetCount:Kt,injectionDepth:Gt,numberOfValues:At,currentValues:new K({each:new L({values:rI})}),sortCriteria:new O({constrainTo:mu}),rangeAlgorithm:new O({constrainTo:gu})});function hu(e,t){pe(e,aI,t,"buildDateFacet"),mc(t);}function Ky(e,t){if(!nI(e));pu(t.options,"buildDateFacet");let r=e.dispatch,a=Be(e,t.options),n={currentValues:[],...t.options,facetId:a};hu(e,n),r(Zt(n));let o=du(e,{facetId:a,getRequest:()=>e.state.dateFacetSet[a].request});return {...o,toggleSelect:i=>r(Yy({facetId:a,selection:i})),toggleSingleSelect:function(i){i.state==="idle"&&r(xe(a)),this.toggleSelect(i);},get state(){return o.state}}}function nI(e){return e.addReducers({configuration:W,search:G,dateFacetSet:sr,facetOptions:Oe}),!0}function oI(e,t){let r=Ky(e,t),a=e.dispatch,n=()=>r.state.facetId;return {...r,deselectAll(){r.deselectAll(),a(T(Ue(n())));},sortBy(o){r.sortBy(o),a(T(lr({facetId:n(),criterion:o})));},toggleSelect:o=>{r.toggleSelect(o),a(T(uu(n(),o)));},get state(){return r.state}}}var iI={facetId:ee,selection:new L({values:Qn})},sI="numericFacet/executeToggleSelect",Gy=te(sI,(e,{dispatch:t,extra:{validatePayload:r}})=>{r(e,iI),t(rr(e)),t(lu(e)),t(se({freezeFacetOrder:!0}));});var cI={start:new U,end:new U,endInclusive:new J,state:new O({constrainTo:fu})},uI=new Z({facetId:Wt,field:Yt,generateAutomaticRanges:dc,filterFacetCount:Kt,injectionDepth:Gt,numberOfValues:At,currentValues:new K({each:new L({values:cI})}),sortCriteria:new O({constrainTo:mu}),rangeAlgorithm:new O({constrainTo:gu})});function Su(e,t){pe(e,uI,t,"buildNumericFacet"),Sc(t);}function Di(e){return {endInclusive:!1,state:"idle",...e}}function Jy(e,t){if(!lI(e));pu(t.options,"buildNumericFacet");let r=e.dispatch,a=Be(e,t.options),n={currentValues:[],...t.options,facetId:a};Su(e,n),r(tr(n));let o=du(e,{facetId:a,getRequest:()=>e.state.numericFacetSet[a].request});return {...o,toggleSelect:i=>r(Gy({facetId:a,selection:i})),toggleSingleSelect(i){i.state==="idle"&&r(xe(a)),this.toggleSelect(i);},get state(){return o.state}}}function lI(e){return e.addReducers({numericFacetSet:pt,facetOptions:Oe,configuration:W,search:G}),!0}function dI(e,t){if(!pI(e));let r=Jy(e,t),a=e.dispatch,n=()=>r.state.facetId;return {...r,deselectAll(){r.deselectAll(),a(T(Ue(n())));},sortBy(o){r.sortBy(o),a(T(lr({facetId:n(),criterion:o})));},toggleSelect:o=>{r.toggleSelect(o),a(T(uu(n(),o)));},get state(){return {...r.state}}}}function pI(e){return e.addReducers({numericFacetSet:pt,configuration:W,search:G}),!0}function fI(e,t){return !!t&&t.facetId in e.numericFacetSet}var mI=(e,t)=>{let r=Dt(e,t);if(fI(e,r))return r},yu=(e,t)=>{let r=mI(e,t);return r?r.values.filter(a=>a.state==="selected"):[]};function Xy(e,t){var u;if(!gI(e));let r=B(e),{dispatch:a}=e,n=()=>e.state,o=Be(e,t.options),i={...t.options,currentValues:((u=t.initialState)==null?void 0:u.range)?[{...t.initialState.range,endInclusive:!0,state:"selected"}]:[],generateAutomaticRanges:!1,facetId:o};Su(e,i),a(tr(i));let s=()=>dr(e.state,o);return {...r,clear:()=>{a(Rr({facetId:o,values:[]})),a(se({freezeFacetOrder:!0}));},setRange:c=>{let l={...c,state:"selected",numberOfResults:0,endInclusive:!0},p=Rr({facetId:o,values:[l]});return p.error?!1:(a(p),a(se({freezeFacetOrder:!0})),!0)},enable(){a(je(o));},disable(){a(ye(o));},get state(){let c=Vt(n()),l=s(),p=yu(n(),o),f=p.length?p[0]:void 0;return {facetId:o,isLoading:c,range:f,enabled:l}}}}function gI(e){return e.addReducers({numericFacetSet:pt,facetOptions:Oe,configuration:W,search:G}),!0}function hI(e,t){if(!SI(e));let r=Xy(e,t),{dispatch:a}=e,n=()=>r.state.facetId;return {...r,clear:()=>{r.clear(),a(T(Ue(n())));},setRange:o=>{let i=r.setRange(o);return i&&a(T(Re({facetId:n(),facetValue:`${o.start}..${o.end}`}))),i},get state(){return {...r.state}}}}function SI(e){return e.addReducers({numericFacetSet:pt,configuration:W,search:G}),!0}function yI(e,t){return !!t&&t.facetId in e.dateFacetSet}var vI=(e,t)=>{let r=Dt(e,t);if(yI(e,r))return r},vu=(e,t)=>{let r=vI(e,t);return r?r.values.filter(a=>a.state==="selected"):[]};function Zy(e,t){var u;if(!CI(e));let r=B(e),{dispatch:a}=e,n=()=>e.state,o=Be(e,t.options),i={...t.options,currentValues:((u=t.initialState)==null?void 0:u.range)?[{...t.initialState.range,endInclusive:!0,state:"selected"}]:[],generateAutomaticRanges:!1,facetId:o};hu(e,i),a(Zt(i));let s=()=>dr(e.state,o);return {...r,clear:()=>{a(xr({facetId:o,values:[]})),a(se({freezeFacetOrder:!0}));},setRange:c=>{let l={...c,state:"selected",numberOfResults:0,endInclusive:!0},p=xr({facetId:o,values:[l]});return p.error?!1:(a(p),a(se({freezeFacetOrder:!0})),!0)},enable(){a(je(o));},disable(){a(ye(o));},get state(){let c=Vt(n()),l=s(),p=vu(n(),o),f=p.length?p[0]:void 0;return {facetId:o,isLoading:c,range:f,enabled:l}}}}function CI(e){return e.addReducers({dateFacetSet:sr,facetOptions:Oe,configuration:W,search:G}),!0}function xI(e,t){if(!RI(e));let r=Zy(e,t),{dispatch:a}=e,n=()=>r.state.facetId;return {...r,clear:()=>{r.clear(),a(T(Ue(n())));},setRange:o=>{let i=r.setRange(o);return i&&a(T(Re({facetId:n(),facetValue:`${o.start}..${o.end}`}))),i},get state(){return {...r.state}}}}function RI(e){return e.addReducers({dateFacetSet:sr,configuration:W,search:G}),!0}var Cu=()=>Q("history/analytics/forward",M.Search,e=>e.makeSearchEvent("historyForward")),xu=()=>Q("history/analytics/backward",M.Search,e=>e.makeSearchEvent("historyBackward")),Ru=()=>Q("history/analytics/noresultsback",M.Search,e=>e.makeNoResultsBack());function bI(e){if(!FI(e));let t=B(e),{dispatch:r}=e,a=()=>e.state,n=o=>o.past.length>0&&!re(o.present);return {...t,get state(){return a().history},async back(){!n(this.state)||(await r(mi()),r(T(xu())));},async forward(){!this.state.future.length||!this.state.present||(await r(ms()),r(T(Cu())));},async backOnNoResults(){!n(this.state)||(await r(mi()),r(T(Ru())));}}}function FI(e){return e.addReducers({history:au,configuration:W,facetOrder:Hc}),!0}function AI(e){return e.pagination.firstResult}function ev(e){return e.pagination.numberOfResults}function PI(e){return e.pagination.totalCountFiltered}var ca=e=>{let t=AI(e),r=ev(e);return op(t,r)},bu=e=>{let t=PI(e),r=ev(e);return ip(t,r)},vp=(e,t)=>{let r=ca(e),a=bu(e),n=II(r,t);return n=EI(n),n=wI(n,a),kI(n)};function II(e,t){let r=t%2==0,a=Math.floor(t/2),n=r?a-1:a,o=e-a,i=e+n;return {start:o,end:i}}function EI(e){let t=Math.max(Ra-e.start,0),r=e.start+t,a=e.end+t;return {start:r,end:a}}function wI(e,t){let r=Math.max(e.end-t,0),a=Math.max(e.start-r,Ra),n=e.end-r;return {start:a,end:n}}function kI(e){let t=[];for(let r=e.start;r<=e.end;++r)t.push(r);return t}var To=()=>Q("analytics/pager/resize",M.Search,(e,t)=>{var r;return e.makePagerResize({currentResultsPerPage:((r=t.pagination)==null?void 0:r.numberOfResults)||Ae().numberOfResults})}),Do=()=>Q("analytics/pager/number",M.Search,(e,t)=>e.makePagerNumber({pagerNumber:ca(t)})),Fu=()=>Q("analytics/pager/next",M.Search,(e,t)=>e.makePagerNext({pagerNumber:ca(t)})),Au=()=>Q("analytics/pager/previous",M.Search,(e,t)=>e.makePagerPrevious({pagerNumber:ca(t)}));var OI=new Z({numberOfPages:new U({default:5,min:0})}),qI=new Z({page:new U({min:1})});function tv(e,t={}){if(!TI(e));let r=B(e),{dispatch:a}=e,n=pe(e,OI,t.options,"buildPager"),i=we(e,qI,t.initialState,"buildPager").page;i&&a(dn(i));let s=()=>ca(e.state),u=()=>{let{numberOfPages:l}=n;return vp(e.state,l)},c=()=>bu(e.state);return {...r,get state(){let l=s(),p=c(),f=l>Ra&&p>0,d=l<p;return {currentPage:l,currentPages:u(),maxPage:p,hasPreviousPage:f,hasNextPage:d}},selectPage(l){a(Lt(l));},nextPage(){a(pn());},previousPage(){a(fn());},isCurrentPage(l){return l===this.state.currentPage}}}function TI(e){return e.addReducers({configuration:W,pagination:or}),!0}function DI(e,t={}){let{dispatch:r}=e,a=tv(e,t);return {...a,get state(){return a.state},selectPage(n){a.selectPage(n),r(Ye(Do()));},nextPage(){a.nextPage(),r(Ye(Fu()));},previousPage(){a.previousPage(),r(Ye(Au()));}}}function rv(e){if(!VI(e));let t=B(e),r=()=>e.state;return {...t,get state(){return {hasError:r().search.error!==null,error:r().search.error}}}}function VI(e){return e.addReducers({search:G}),!0}function NI(e){return rv(e)}function Vo(e){if(!MI(e));let t=B(e),r=()=>e.state;return {...t,get state(){let a=r();return {hasError:a.search.error!==null,isLoading:a.search.isLoading,hasResults:!!a.search.results.length,firstSearchExecuted:ac(a)}}}}function MI(e){return e.addReducers({search:G}),!0}function av(e){if(!QI(e));let t=B(e),r=Vo(e),a=()=>e.state,n=()=>{let o=a().search.duration/1e3;return Math.round((o+Number.EPSILON)*100)/100};return {...t,get state(){return {...r.state,durationInMilliseconds:a().search.duration,durationInSeconds:n(),firstResult:a().pagination.firstResult+1,hasDuration:a().search.duration!==0,hasQuery:a().search.queryExecuted!=="",lastResult:a().pagination.firstResult+a().search.results.length,query:a().search.queryExecuted,total:a().pagination.totalCountFiltered}}}}function QI(e){return e.addReducers({search:G,pagination:or}),!0}function LI(e){return av(e)}var jI=new Z({fieldsToInclude:new K({required:!1,each:new O({required:!0,emptyAllowed:!1})})});function nv(e,t){if(!UI(e));let r=B(e),a=Vo(e),{dispatch:n}=e,o=()=>e.state,i=pe(e,jI,t==null?void 0:t.options,"buildCoreResultList");i.fieldsToInclude&&n(ea(i.fieldsToInclude));let s=()=>e.state.search.results.length<e.state.search.response.totalCountFiltered,u=0,c=0,l=5,p=200,f=!1;return {...r,get state(){let m=o();return {...a.state,results:m.search.results,moreResultsAvailable:s(),searchResponseId:m.search.searchResponseId}},fetchMoreResults:()=>{if(e.state.search.isLoading)return;if(!s()){e.logger.info("No more results are available for the result list to fetch.");return}if(Date.now()-u<p){if(c++,c>=l){u=Date.now(),!f&&e.logger.error(`The result list method "fetchMoreResults" execution prevented because it has been triggered consecutively ${l} times, with little delay. Please verify the conditions under which the function is called.`),f=!0;return}}else c=0;f=!1,(t==null?void 0:t.fetchMoreResultsActionCreator)&&n(t==null?void 0:t.fetchMoreResultsActionCreator()).then(()=>u=Date.now());}}}function UI(e){return e.addReducers({search:G,configuration:W,fields:ia}),!0}function Cp(e,t){return nv(e,{...t,fetchMoreResultsActionCreator:ct})}var Pu=e=>Q("analytics/result/open",M.Click,(t,r)=>(_e(e),t.makeDocumentOpen(Ve(e,r),Le(e))));function mt(e,t,r){if(!BI(e));let a=1e3,n={selectionDelay:a,debounceWait:a,...t.options},o;return {select:nu(r,n.debounceWait,{isImmediate:!0}),beginDelayedSelect(){o=setTimeout(r,n.selectionDelay);},cancelPendingSelect(){o&&clearTimeout(o);}}}function BI(e){return e.addReducers({configuration:W}),!0}function _I(e,t){let r=!1,a=()=>{r||(r=!0,e.dispatch(Pu(t.options.result)));};return mt(e,t,()=>{a(),e.dispatch(dt(t.options.result));})}function $I(e,t){let r=!1,a=()=>{r||(r=!0,e.dispatch(bg(t.options.result)));};return mt(e,t,()=>{a(),e.dispatch(dt(t.options.result));})}var HI=new Z({numberOfResults:new U({min:0})});function ov(e,t={}){if(!zI(e));let r=B(e),{dispatch:a}=e,n=()=>e.state,i=we(e,HI,t.initialState,"buildResultsPerPage").numberOfResults;return i!==void 0&&a(un(i)),{...r,get state(){return {numberOfResults:n().pagination.numberOfResults}},set(s){a(ln(s));},isSetTo(s){return s===this.state.numberOfResults}}}function zI(e){return e.addReducers({pagination:or,configuration:W}),!0}function WI(e,t={}){if(!YI(e));let r=ov(e,t),{dispatch:a}=e;return {...r,get state(){return {...r.state}},set(n){r.set(n),a(Ye(To()));}}}function YI(e){return e.addReducers({pagination:or,configuration:W}),!0}var ua=()=>Q("analytics/searchbox/submit",M.Search,e=>e.makeSearchboxSubmit());var Iu=e=>Q("analytics/querySuggest",M.Search,(t,r)=>{let a=xp(r,e);return t.makeOmniboxAnalytics(a)});function xp(e,t){let{id:r,suggestion:a}=t,n=e.querySuggest&&e.querySuggest[r];if(!n)throw new Error(`Unable to determine the query suggest analytics metadata to send because no query suggest with id "${r}" was found. Please check the sent #id.`);let o=n.completions.map(c=>c.expression),i=n.partialQueries.length-1,s=n.partialQueries[i]||"",u=n.responseId;return {suggestionRanking:o.indexOf(a),partialQuery:s,partialQueries:n.partialQueries,suggestions:o,querySuggestResponseId:u}}var Eu={enableQuerySyntax:!1,numberOfSuggestions:5,clearFilters:!0},Rp={open:new O,close:new O},bp={id:q,numberOfSuggestions:new U({min:0}),enableQuerySyntax:new J,highlightOptions:new L({values:{notMatchDelimiters:new L({values:Rp}),exactMatchDelimiters:new L({values:Rp}),correctionDelimiters:new L({values:Rp})}}),clearFilters:new J},iv=new Z(bp);function sv(e,t){var c,l;if(!GI(e));let r=B(e),{dispatch:a}=e,n=()=>e.state,o=((c=t.options)==null?void 0:c.id)||tn("search_box"),i={id:o,highlightOptions:{...(l=t.options)==null?void 0:l.highlightOptions},...Eu,...t.options};pe(e,iv,i,"buildSearchBox"),a(Gn({id:o,query:e.state.query.q})),i.numberOfSuggestions&&a(Kn({id:o,count:i.numberOfSuggestions}));let s=()=>e.state.querySet[i.id],u=async p=>{let{enableQuerySyntax:f,clearFilters:d}=i;a(Is({q:s(),enableQuerySyntax:f,clearFilters:d})),await a(t.executeSearchActionCreator(p));};return {...r,updateText(p){a(Va({id:o,query:p})),this.showSuggestions();},clear(){a(Va({id:o,query:""})),a(ra({id:o}));},showSuggestions(){i.numberOfSuggestions&&a(t.fetchQuerySuggestionsActionCreator({id:o}));},selectSuggestion(p){a(nr({id:o,expression:p})),u(Iu({id:o,suggestion:p})).then(()=>{a(ra({id:o}));});},submit(p=ua()){u(p),a(ra({id:o}));},get state(){let p=n(),f=p.querySuggest[i.id],d=KI(f,i.highlightOptions),m=f?f.isLoading:!1;return {value:s(),suggestions:d,isLoading:p.search.isLoading,isLoadingSuggestions:m}}}}function KI(e,t){return e?e.completions.map(r=>({highlightedValue:_d(r.highlighted,t),rawValue:r.expression})):[]}function GI(e){return e.addReducers({query:ft,querySuggest:Po,configuration:W,querySet:Ao,search:G}),!0}function Fp(e,t={}){let r=sv(e,{...t,executeSearchActionCreator:T,fetchQuerySuggestionsActionCreator:aa});return {...r,submit(){r.submit(ua());},get state(){return r.state}}}var JI={searchBoxId:oe,maxResultsPerQuery:new U({required:!0,min:1}),cacheTimeout:new U},cv=new Z(JI);function XI(e,t){if(!ZI(e));let r=B(e),{dispatch:a}=e,n=()=>e.state,o={searchBoxId:t.options.searchBoxId||tn("instant-results-"),cacheTimeout:t.options.cacheTimeout||6e4,maxResultsPerQuery:t.options.maxResultsPerQuery};pe(e,cv,o,"buildInstantResults");let i=o.searchBoxId;a(sn({id:i}));let s=()=>n().instantResults[i],u=p=>s().cache[p],c=()=>s().q,l=()=>{let p=u(c());return p?p.isLoading?[]:p.results:[]};return {...r,updateQuery(p){if(!p)return;let f=u(p);(!f||!f.isLoading&&(f.error||gs(f)))&&a(Br({id:i,q:p,maxResultsPerQuery:o.maxResultsPerQuery,cacheTimeout:o.cacheTimeout})),a(Qr({id:i,q:p}));},clearExpired(){a(cn({id:i}));},get state(){let p=c(),f=u(p);return {q:p,isLoading:(f==null?void 0:f.isLoading)||!1,error:(f==null?void 0:f.error)||null,results:l()}}}}function ZI(e){return e.addReducers({instantResults:Wc}),!0}var No=()=>Q("analytics/sort/results",M.Search,(e,t)=>e.makeResultsSort({resultsSortBy:t.sortCriteria||et()}));function eE(e,t){if(!t)return;let r=new Z({criterion:new K({each:Pg})}),a=tE(t),n={...t,criterion:a};we(e,r,n,"buildSort");}function tE(e){return e.criterion?Ya(e.criterion)?e.criterion:[e.criterion]:[]}function uv(e,t){var i;if(!rE(e));let r=B(e),{dispatch:a}=e,n=()=>e.state;eE(e,t.initialState);let o=(i=t.initialState)==null?void 0:i.criterion;return o&&a(mo(o)),{...r,sortBy(s){a(go(s)),a(Lt(1));},isSortedBy(s){return this.state.sortCriteria===Sr(s)},get state(){return {sortCriteria:n().sortCriteria}}}}function rE(e){return e.addReducers({configuration:W,sortCriteria:Kc}),!0}function aE(e,t={}){let{dispatch:r}=e,a=uv(e,t),n=()=>r(T(No()));return {...a,get state(){return a.state},sortBy(o){a.sortBy(o),n();}}}var sE=new Z({expression:ie,id:q}),cE=new Z({isActive:new J});function pv(e,t){if(lE(t.options.id),!uE(e));let r=B(e),{dispatch:a}=e;pe(e,sE,t.options,"buildTab");let n=we(e,cE,t.initialState,"buildTab"),{id:o,expression:i}=t.options;return a(Pn({id:o,expression:i})),n.isActive&&a(Cr(o)),{...r,select(){a(Cr(o));},get state(){var u;return {isActive:(u=e.state.tabSet[o])==null?void 0:u.isActive}}}}function uE(e){return e.addReducers({configuration:W,tabSet:Yc}),!0}function lE(e){let t=Ne().analytics.originLevel2;if(e===t)throw new Error(`The #id option on the Tab controller cannot use the reserved value "${t}". Please specify a different value.`)}function dE(e,t){let{dispatch:r}=e,a=pv(e,t),n=()=>r(T($r()));return {...a,get state(){return a.state},select(){a.select(),n();}}}function fv(e){if(!pE(e));let t=B(e),r=()=>e.state;return {...t,sort(a){return Cn(a,this.state.facetIds)},get state(){return {facetIds:r().search.response.facets.map(o=>o.facetId)}}}}function pE(e){return e.addReducers({search:G,facetOptions:Oe}),!0}function fE(e){return fv(e)}var mE={categoryFacetId:ee,categoryFacetPath:new K({required:!0,each:q})},gE=(e,{categoryFacetId:t,categoryFacetPath:r})=>{let a=e.categoryFacetSet[t],n=a==null?void 0:a.request.field,o=`${n}_${t}`;return {categoryFacetId:t,categoryFacetPath:r,categoryFacetField:n,categoryFacetTitle:o}},wu=e=>Q("analytics/categoryFacet/breadcrumb",M.Search,(t,r)=>(y(e,mE),t.makeBreadcrumbFacet(gE(r,e))));var ku=()=>Q("analytics/facet/deselectAllBreadcrumbs",M.Search,e=>e.makeBreadcrumbResetAll());var Ou=(e,{facetId:t,selection:r})=>{let n=(e.dateFacetSet[t]||e.numericFacetSet[t]).request.field,o=`${n}_${t}`;return {facetId:t,facetField:n,facetTitle:o,facetRangeEndInclusive:r.endInclusive,facetRangeEnd:`${r.end}`,facetRangeStart:`${r.start}`}};var qu=e=>Q("analytics/dateFacet/breadcrumb",M.Search,(t,r)=>{y(e,jn(e.selection));let a=Ou(r,e);return t.makeBreadcrumbFacet(a)});var Tu=e=>Q("analytics/numericFacet/breadcrumb",M.Search,(t,r)=>{y(e,jn(e.selection));let a=Ou(r,e);return t.makeBreadcrumbFacet(a)});var Du=(e,t,r,a)=>Object.keys(t).map(n=>{let o=a(e.state,n).map(i=>({value:i,deselect:()=>r({facetId:n,selection:i})}));return {facetId:n,field:t[n].request.field,values:o}}).filter(n=>n.values.length);function mv(e){let t=B(e),{dispatch:r}=e;return {...t,get state(){return {facetBreadcrumbs:[],categoryFacetBreadcrumbs:[],numericFacetBreadcrumbs:[],dateFacetBreadcrumbs:[],staticFilterBreadcrumbs:[],hasBreadcrumbs:!1}},deselectAll:()=>{r(ke());},deselectBreadcrumb(a){a.deselect();}}}function hE(e){if(!SE(e));let t=mv(e),{dispatch:r}=e,a=()=>e.state,n=()=>Du(e,a().facetSet,({facetId:d,selection:m})=>{let h=ou({facetId:d,facetValue:m.value});r(Xt({facetId:d,selection:m})),r(Kr({facetId:d,freezeCurrentValues:!1})),r(T(h));},Yl),o=()=>Du(e,a().numericFacetSet,d=>{r(rr(d)),r(T(Tu(d)));},yu),i=()=>Du(e,a().dateFacetSet,d=>{r(er(d)),r(T(qu(d)));},vu),s=d=>{let m=Am(a(),d);return {facetId:d,field:a().categoryFacetSet[d].request.field,path:m,deselect:()=>{r(zt(d)),r(T(wu({categoryFacetPath:m.map(h=>h.value),categoryFacetId:d})));}}},u=()=>Object.keys(a().categoryFacetSet).map(s).filter(d=>d.path.length),c=()=>{let d=a().staticFilterSet||{};return Object.values(d).map(l)},l=d=>{let{id:m,values:h}=d,v=h.filter(C=>C.state==="selected").map(C=>p(m,C));return {id:m,values:v}},p=(d,m)=>({value:m,deselect:()=>{let{caption:h,expression:v}=m,C=Ro({staticFilterId:d,staticFilterValue:{caption:h,expression:v}});r(br({id:d,value:m})),r(T(C));}});function f(){return !![...n(),...o(),...i(),...u(),...c()].length}return {...t,get state(){return {facetBreadcrumbs:n(),categoryFacetBreadcrumbs:u(),numericFacetBreadcrumbs:o(),dateFacetBreadcrumbs:i(),staticFilterBreadcrumbs:c(),hasBreadcrumbs:f()}},deselectAll:()=>{t.deselectAll(),r(T(ku()));}}}function SE(e){return e.addReducers({configuration:W,search:G,facetSet:ir,numericFacetSet:pt,dateFacetSet:sr,categoryFacetSet:cr}),!0}var gv=new Z({...bp,redirectionUrl:new O({required:!0,emptyAllowed:!1})});function yE(e,t){if(!vE(e));let{dispatch:r}=e,a=()=>e.state,n=t.options.id||tn("standalone_search_box"),o={id:n,highlightOptions:{...t.options.highlightOptions},...Eu,...t.options};pe(e,gv,o,"buildStandaloneSearchBox");let i=Fp(e,{options:o});return r(ho({id:n,redirectionUrl:o.redirectionUrl})),{...i,updateText(s){i.updateText(s),r(yo({id:n}));},selectSuggestion(s){let u=xp(a(),{id:n,suggestion:s});r(nr({id:n,expression:s})),r(vo({id:n,metadata:u})),this.submit();},afterRedirection(){r(So({id:n}));},submit(){r(ot({q:this.state.value,enableQuerySyntax:o.enableQuerySyntax})),r(oa({id:n}));},get state(){let u=a().standaloneSearchBoxSet[n];return {...i.state,isLoading:u.isLoading,redirectTo:u.redirectTo,analytics:u.analytics}}}}function vE(e){return e.addReducers({standaloneSearchBoxSet:eu,configuration:W,query:ft,querySuggest:Po}),!0}function hv(e,t){return e.q!==t.q?ua():e.sortCriteria!==t.sortCriteria?No():e.firstResult!==t.firstResult?Do():e.numberOfResults!==t.numberOfResults?To():Vu(e.f,t.f)?Ap(e.f,t.f):Vu(e.cf,t.cf)?Ap(e.cf,t.cf):Vu(e.nf,t.nf)?yv(e.nf,t.nf):Vu(e.df,t.df)?yv(e.df,t.df):$r()}function Vu(e={},t={}){return JSON.stringify(e)!==JSON.stringify(t)}function Sv(e){let t={};return Object.keys(e).forEach(r=>t[r]=e[r].map(a=>`${a.start}..${a.end}`)),t}function Ap(e={},t={}){let r=Object.keys(e),a=Object.keys(t),n=r.filter(p=>!a.includes(p));if(n.length){let p=n[0];return e[p].length>1?Ue(p):Et({facetId:p,facetValue:e[p][0]})}let o=a.filter(p=>!r.includes(p));if(o.length){let p=o[0];return Re({facetId:p,facetValue:t[p][0]})}let i=a.find(p=>t[p].filter(f=>e[p].includes(f)));if(!i)return $r();let s=e[i],u=t[i],c=u.filter(p=>!s.includes(p));if(c.length)return Re({facetId:i,facetValue:c[0]});let l=s.filter(p=>!u.includes(p));return l.length?Et({facetId:i,facetValue:l[0]}):$r()}function yv(e={},t={}){return Ap(Sv(e),Sv(t))}function vv(e){var t,r,a,n,o,i;return {q:ve().q,enableQuerySyntax:ve().enableQuerySyntax,aq:(r=(t=e.advancedSearchQueries)==null?void 0:t.defaultFilters.aq)!=null?r:$e().defaultFilters.aq,cq:(n=(a=e.advancedSearchQueries)==null?void 0:a.defaultFilters.cq)!=null?n:$e().defaultFilters.cq,firstResult:Ae().firstResult,numberOfResults:(i=(o=e.pagination)==null?void 0:o.defaultNumberOfResults)!=null?i:Ae().defaultNumberOfResults,sortCriteria:et(),f:{},cf:{},nf:{},df:{},debug:We(),sf:{},tab:""}}var CE=new Z({parameters:new L({options:{required:!0},values:nc})});function Cv(e,t){let{dispatch:r}=e,a=B(e);return we(e,CE,t.initialState,"buildSearchParameterManager"),r(ue(t.initialState.parameters)),{...a,synchronize(n){let o=Nu(e,n);r(ue(o));},get state(){return {parameters:Pp(e)}}}}function Nu(e,t){return {...vv(e.state),...t}}function xv(e,t){return bE(e,t)}function Pp(e){let t=e.state;return {...xE(t),...RE(t),...FE(t),...AE(t),...IE(t),...EE(t),...wE(t)}}function xE(e){if(e.query===void 0)return {};let t=e.query.q;return t!==ve().q?{q:t}:{}}function RE(e){let t=Object.values(e.tabSet||{}).find(r=>r.isActive);return t?{tab:t.id}:{}}function bE(e,t){let r=e.state.tabSet,a=t.tab;if(!r||!Object.entries(r).length||!a)return !0;let n=a in r;return n||e.logger.warn(`The tab search parameter "${a}" is invalid. Ignoring change.`),n}function FE(e){if(e.sortCriteria===void 0)return {};let t=e.sortCriteria;return t!==et()?{sortCriteria:t}:{}}function AE(e){if(e.facetSet===void 0)return {};let t=Object.entries(e.facetSet).filter(([r])=>{var a,n,o;return (o=(n=(a=e.facetOptions)==null?void 0:a.facets[r])==null?void 0:n.enabled)!=null?o:!0}).map(([r,{request:a}])=>{let n=PE(a.currentValues);return n.length?{[r]:n}:{}}).reduce((r,a)=>({...r,...a}),{});return Object.keys(t).length?{f:t}:{}}function PE(e){return e.filter(t=>t.state==="selected").map(t=>t.value)}function IE(e){if(e.categoryFacetSet===void 0)return {};let t=Object.entries(e.categoryFacetSet).filter(([r])=>{var a,n,o;return (o=(n=(a=e.facetOptions)==null?void 0:a.facets[r])==null?void 0:n.enabled)!=null?o:!0}).map(([r,a])=>{let{parents:n}=Xe(a.request.currentValues),o=n.map(i=>i.value);return o.length?{[r]:o}:{}}).reduce((r,a)=>({...r,...a}),{});return Object.keys(t).length?{cf:t}:{}}function EE(e){if(e.numericFacetSet===void 0)return {};let t=Object.entries(e.numericFacetSet).filter(([r])=>{var a,n,o;return (o=(n=(a=e.facetOptions)==null?void 0:a.facets[r])==null?void 0:n.enabled)!=null?o:!0}).map(([r,{request:a}])=>{let n=Rv(a.currentValues);return n.length?{[r]:n}:{}}).reduce((r,a)=>({...r,...a}),{});return Object.keys(t).length?{nf:t}:{}}function wE(e){if(e.dateFacetSet===void 0)return {};let t=Object.entries(e.dateFacetSet).filter(([r])=>{var a,n,o;return (o=(n=(a=e.facetOptions)==null?void 0:a.facets[r])==null?void 0:n.enabled)!=null?o:!0}).map(([r,{request:a}])=>{let n=Rv(a.currentValues);return n.length?{[r]:n}:{}}).reduce((r,a)=>({...r,...a}),{});return Object.keys(t).length?{df:t}:{}}function Rv(e){return e.filter(t=>t.state==="selected")}function Ip(e,t){let{dispatch:r}=e,a=Cv(e,t);return {...a,synchronize(n){let o=bv(e),i=Nu(e,o),s=Nu(e,n);Nc(i,s)||!xv(e,s)||(a.synchronize(n),r(T(hv(i,s))));},get state(){return {parameters:bv(e)}}}}function bv(e){let t=e.state;return {...Pp(e),...kE(t),...OE(t),...qE(t),...TE(t),...DE(t),...ME(t),...VE(t)}}function kE(e){if(e.query===void 0)return {};let t=e.query.enableQuerySyntax;return t!==void 0&&t!==ve().enableQuerySyntax?{enableQuerySyntax:t}:{}}function OE(e){if(e.advancedSearchQueries===void 0)return {};let{aq:t,defaultFilters:r}=e.advancedSearchQueries;return t!==r.aq?{aq:t}:{}}function qE(e){if(e.advancedSearchQueries===void 0)return {};let{cq:t,defaultFilters:r}=e.advancedSearchQueries;return t!==r.cq?{cq:t}:{}}function TE(e){if(e.pagination===void 0)return {};let t=e.pagination.firstResult;return t!==Ae().firstResult?{firstResult:t}:{}}function DE(e){if(e.pagination===void 0)return {};let{numberOfResults:t,defaultNumberOfResults:r}=e.pagination;return t!==r?{numberOfResults:t}:{}}function VE(e){if(e.staticFilterSet===void 0)return {};let t=Object.entries(e.staticFilterSet).map(([r,a])=>{let n=NE(a.values);return n.length?{[r]:n}:{}}).reduce((r,a)=>({...r,...a}),{});return Object.keys(t).length?{sf:t}:{}}function NE(e){return e.filter(t=>t.state==="selected").map(t=>t.caption)}function ME(e){if(e.debug===void 0)return {};let t=e.debug;return t!==We()?{debug:t}:{}}var Mu="&",Vi="=",Ep="..";function Qu(){return {serialize:QE,deserialize:$E}}function QE(e){return Object.entries(e).map(LE).filter(t=>t).join(Mu)}function LE(e){let[t,r]=e;return Av(t)?t==="f"||t==="cf"||t==="sf"?jE(r)?BE(t,r):"":t==="nf"||t==="df"?UE(r)?_E(t,r):"":`${t}${Vi}${encodeURIComponent(r)}`:""}function jE(e){return wp(e)?Fv(e,r=>typeof r=="string"):!1}function UE(e){return wp(e)?Fv(e,r=>wp(r)&&"start"in r&&"end"in r):!1}function wp(e){return !!(e&&typeof e=="object")}function Fv(e,t){return Object.entries(e).filter(a=>{let n=a[1];return !Array.isArray(n)||!n.every(t)}).length===0}function BE(e,t){return Object.entries(t).map(([r,a])=>`${e}-${r}${Vi}${a.map(n=>encodeURIComponent(n)).join(",")}`).join(Mu)}function _E(e,t){return Object.entries(t).map(([r,a])=>{let n=a.map(({start:o,end:i})=>`${o}${Ep}${i}`).join(",");return `${e}-${r}${Vi}${n}`}).join(Mu)}function $E(e){return e.split(Mu).map(a=>HE(a)).map(zE).filter(JE).map(XE).reduce((a,n)=>{let[o,i]=n;if(Pv(o)){let s={...a[o],...i};return {...a,[o]:s}}return {...a,[o]:i}},{})}function HE(e){let[t,...r]=e.split(Vi),a=r.join(Vi);return [t,a]}function zE(e){let[t,r]=e,n=/^(f|cf|nf|df|sf)-(.+)$/.exec(t);if(!n)return e;let o=n[1],i=n[2],s=r.split(","),u=WE(o,s),c={[i]:u};return [o,JSON.stringify(c)]}function WE(e,t){return e==="nf"?YE(t):e==="df"?GE(t):t}function YE(e){return e.map(t=>t.split(Ep).map(parseFloat)).filter(t=>t.length===2&&t.every(Number.isFinite)).map(([t,r])=>Di({start:t,end:r,state:"selected"}))}function KE(e){try{return kg(e)?(As(e,Si),!0):_t(e)?(xa(e),!0):!1}catch(t){return !1}}function GE(e){return e.map(t=>t.split(Ep)).filter(t=>t.length===2&&t.every(r=>KE(r))).map(([t,r])=>Oa({start:t,end:r,state:"selected"}))}function JE(e){let t=Av(e[0]),r=e.length===2;return t&&r}function Av(e){return e in{q:!0,aq:!0,cq:!0,enableQuerySyntax:!0,firstResult:!0,numberOfResults:!0,sortCriteria:!0,f:!0,cf:!0,nf:!0,df:!0,debug:!0,sf:!0,tab:!0}}function XE(e){let[t,r]=e;return t==="enableQuerySyntax"?[t,r==="true"]:t==="debug"?[t,r==="true"]:t==="firstResult"?[t,parseInt(r)]:t==="numberOfResults"?[t,parseInt(r)]:Pv(t)?[t,ZE(r)]:[t,decodeURIComponent(r)]}function ZE(e){let t=JSON.parse(e),r={};return Object.entries(t).forEach(a=>{let[n,o]=a;r[n]=o.map(i=>Wa(i)?decodeURIComponent(i):i);}),r}function Pv(e){return ["f","cf","nf","df","sf"].includes(e)}var ew=new Z({fragment:new O});function tw(e,t){let r;function a(){r=e.state.search.requestId;}function n(){return r!==e.state.search.requestId}if(!aw(e));we(e,ew,t.initialState,"buildUrlManager");let o=B(e),i=t.initialState.fragment;a();let s=Ip(e,{initialState:{parameters:Lu(i)}});return {...o,subscribe(u){let c=()=>{let l=this.state.fragment;!rw(i,l)&&n()&&(i=l,u()),a();};return c(),e.subscribe(c)},get state(){return {fragment:Qu().serialize(s.state.parameters)}},synchronize(u){i=u;let c=Lu(u);s.synchronize(c);}}}function rw(e,t){if(e===t)return !0;let r=Lu(e),a=Lu(t);return Nc(r,a)}function Lu(e){return Qu().deserialize(e)}function aw(e){return e.addReducers({configuration:W}),!0}function nw(e){return Vo(e)}var Iv=e=>Q("analytics/resultPreview/open",M.Click,(t,r)=>{_e(e);let a=Ve(e,r),n=Le(e);return t.makeDocumentQuickview(a,n)});function Ev(e,t,r,a,n){if(!ow(e));let{dispatch:o}=e,i=()=>e.state,s=B(e),{result:u,maximumPreviewSize:c}=t.options,l=()=>{let{resultsWithPreview:f,position:d}=i().resultPreview;return f[d]},p=f=>{t.options.onlyContentURL?o(fo({uniqueId:f,requestedOutputSize:c,buildResultPreviewRequest:r,path:a})):o(Na({uniqueId:f,requestedOutputSize:c})),n&&n();};return {...s,fetchResultContent(){p(u.uniqueId);},next(){o(uo()),p(l());},previous(){o(lo()),p(l());},get state(){let f=i(),d=u.hasHtmlVersion,m=f.resultPreview,h=u.uniqueId===m.uniqueId?m.content:"",v=m.isLoading,C=m.contentURL,x=l();return {content:h,resultHasPreview:d,isLoading:v,contentURL:C,currentResultUniqueId:x}}}}function ow(e){return e.addReducers({configuration:W,resultPreview:Zc}),!0}function iw(e,t){if(!sw(e));let{dispatch:r}=e,a=()=>e.state,n=()=>a().search.results,s=Ev(e,t,jc,"/html",()=>{e.dispatch(Iv(t.options.result));});return r(po({results:n()})),{...s,get state(){return {...s.state,currentResult:n().findIndex(u=>u.uniqueId===s.state.currentResultUniqueId)+1,totalResults:n().length}}}}function sw(e){return e.addReducers({search:G}),!0}var cw=new Z(ep);function uw(e,t={}){var i;if(!lw(e));let r=Cp(e,t),{dispatch:a}=e,n=()=>e.state,o=((i=t.options)==null?void 0:i.folding)?pe(e,cw,t.options.folding,"buildFoldedResultList"):{};return a(Xr({...o})),{...r,loadCollection:s=>{a(Zr(s.result.raw[e.state.folding.fields.collection])),a(tp(s.result));},logShowMoreFoldedResults:s=>{a(tp(s));},logShowLessFoldedResults:()=>{a(xS());},findResultById(s){return kp(this.state.results,u=>u.result.uniqueId===s.result.uniqueId)},findResultByCollection(s){return kp(this.state.results,u=>u.result.raw.foldingcollection===s.result.raw.foldingcollection)},get state(){let s=n();return {...r.state,results:r.state.results.map(u=>{let c=u.raw[s.folding.fields.collection];return !c||!s.folding.collections[c]?{result:u,moreResultsAvailable:!1,isLoadingMoreResults:!1,children:[]}:s.folding.collections[c]})}}}}function lw(e){return e.addReducers({search:G,configuration:W,folding:$c,query:ft}),!0}function kp(e,t){for(let r=0;r<e.length;r++){let a=e[r];if(t(a))return a;if(a.children.length){let n=kp(a.children,t);if(n)return n}}return null}function fw(e){if(!mw(e));let t=B(e),{dispatch:r}=e,a=()=>e.state,n=()=>a().triggers.queryModification.newQuery,o=()=>a().triggers.queryModification.originalQuery;return {...t,get state(){return {newQuery:n(),originalQuery:o(),wasQueryModified:n()!==""}},undo(){r(yn(n())),r(ot({q:o()})),r(T(ys({undoneQuery:n()})));}}}function mw(e){return e.addReducers({triggers:sa,query:ft}),!0}function Sw(e){if(!yw(e));let t=B(e),{dispatch:r}=e,a=()=>e.state,n=a().triggers.notifications;return {...t,subscribe(o){let i=()=>{let s=!Da(n,this.state.notifications);n=this.state.notifications,s&&(o(),r(vs()));};return i(),e.subscribe(i)},get state(){return {notifications:a().triggers.notifications}}}}function yw(e){return e.addReducers({triggers:sa}),!0}function Fr(e,t){var a,n;let r=t!=null?t:(n=(a=e.search)==null?void 0:a.questionAnswer)==null?void 0:n.documentId;return r&&e.search&&Ah(e,r.contentIdKey,r.contentIdValue)}function Qa(e,t){var n,o,i,s,u;let r=(o=(n=e.questionAnswering)==null?void 0:n.relatedQuestions.findIndex(c=>c.questionAnswerId===t))!=null?o:-1;if(r===-1)return null;let a=(u=(s=(i=e.search)==null?void 0:i.questionAnswer)==null?void 0:s.relatedQuestions)==null?void 0:u[r];return a!=null?a:null}var ju=()=>Q("analytics/smartSnippet/expand",M.Custom,e=>e.makeExpandSmartSnippet()),Uu=()=>Q("analytics/smartSnippet/collapse",M.Custom,e=>e.makeCollapseSmartSnippet()),Bu=()=>Q("analytics/smartSnippet/like",M.Custom,e=>e.makeLikeSmartSnippet()),_u=()=>Q("analytics/smartSnippet/dislike",M.Custom,e=>e.makeDislikeSmartSnippet());function $u(){return Q("analytics/smartSnippet/source/open",M.Click,(e,t)=>{let r=Fr(t);return e.makeOpenSmartSnippetSource(Ve(r,t),Le(r))})}var Hu=e=>Q("analytics/smartSnippet/source/open",M.Click,(t,r)=>{y(e,cp());let a=Fr(r);return t.makeOpenSmartSnippetInlineLink(Ve(a,r),{...Le(a),...e})}),zu=()=>Q("analytics/smartSnippet/feedbackModal/open",M.Custom,e=>e.makeOpenSmartSnippetFeedbackModal()),Wu=()=>Q("analytics/smartSnippet/feedbackModal/close",M.Custom,e=>e.makeCloseSmartSnippetFeedbackModal()),Yu=e=>Q("analytics/smartSnippet/sendFeedback",M.Custom,t=>t.makeSmartSnippetFeedbackReason(e)),Ku=e=>Q("analytics/smartSnippet/sendFeedback",M.Custom,t=>t.makeSmartSnippetFeedbackReason("other",e)),Gu=e=>Q("analytics/smartSnippetSuggestion/expand",M.Custom,(t,r)=>{Jn(e);let a=Qa(r,e.questionAnswerId);return a?t.makeExpandSmartSnippetSuggestion({question:a.question,answerSnippet:a.answerSnippet,documentId:a.documentId}):null}),Ju=e=>Q("analytics/smartSnippetSuggestion/expand",M.Custom,(t,r)=>{Jn(e);let a=Qa(r,e.questionAnswerId);return a?t.makeCollapseSmartSnippetSuggestion({question:a.question,answerSnippet:a.answerSnippet,documentId:a.documentId}):null}),Xu=e=>Q("analytics/smartSnippet/source/open",M.Click,(t,r)=>{y(e,Lc());let a=Qa(r,e.questionAnswerId);if(!a)return null;let n=Fr(r,a.documentId);return n?t.makeOpenSmartSnippetSuggestionSource(Ve(n,r),{question:a.question,answerSnippet:a.answerSnippet,documentId:a.documentId}):null}),Zu=(e,t)=>Q("analytics/smartSnippet/source/open",M.Click,(r,a)=>{y(e,Lc()),y(t,cp());let n=Qa(a,e.questionAnswerId);if(!n)return null;let o=Fr(a,n.documentId);return o?r.makeOpenSmartSnippetSuggestionInlineLink(Ve(o,a),{question:n.question,answerSnippet:n.answerSnippet,documentId:n.documentId,linkText:t.linkText,linkURL:t.linkURL}):null});function el(e,t){if(!vw(e));let r=()=>e.state,a=new Set,n=l=>a.has(l)?!0:(a.add(l),!1),o=null,i=l=>{o!==l&&(o=l,u={},a.clear());},s=(l,p,f)=>{var d;return mt(e,{options:{selectionDelay:(d=t==null?void 0:t.options)==null?void 0:d.selectionDelay}},()=>{n(p)||e.dispatch(f?Zu({questionAnswerId:f},l):Hu(l));})},u={},c=(l,p)=>{let{searchResponseId:f}=r().search;i(f);let d=rn({...l,questionAnswerId:p});return d in u||(u[d]=s(l,d,p)),u[d]};return {selectInlineLink(l,p){var f;(f=c(l,p))==null||f.select();},beginDelayedSelectInlineLink(l,p){var f;(f=c(l,p))==null||f.beginDelayedSelect();},cancelPendingSelectInlineLink(l,p){var f;(f=c(l,p))==null||f.cancelPendingSelect();}}}function vw(e){return e.addReducers({search:G,questionAnswering:ur}),!0}function Cw(e,t){var u,c;if(!xw(e));let r=B(e),a=()=>e.state,n=()=>Fr(a()),o=null,i=mt(e,{options:{selectionDelay:(u=t==null?void 0:t.options)==null?void 0:u.selectionDelay}},()=>{let l=n();if(!l){o=null;return}let{searchResponseId:p}=a().search;o!==p&&(o=p,e.dispatch($u()),e.dispatch(dt(l)));}),s=el(e,{options:{selectionDelay:(c=t==null?void 0:t.options)==null?void 0:c.selectionDelay}});return {...r,get state(){let l=a();return {question:l.search.questionAnswer.question,answer:l.search.questionAnswer.answerSnippet,documentId:l.search.questionAnswer.documentId,expanded:l.questionAnswering.expanded,answerFound:l.search.questionAnswer.answerSnippet!=="",liked:l.questionAnswering.liked,disliked:l.questionAnswering.disliked,feedbackModalOpen:l.questionAnswering.feedbackModalOpen,source:n()}},expand(){e.dispatch(ju()),e.dispatch(Xn());},collapse(){e.dispatch(Uu()),e.dispatch(Zn());},like(){e.dispatch(Bu()),e.dispatch(eo());},dislike(){e.dispatch(_u()),e.dispatch(to());},openFeedbackModal(){e.dispatch(zu()),e.dispatch(ro());},closeFeedbackModal(){e.dispatch(Wu()),e.dispatch(na());},sendFeedback(l){e.dispatch(Yu(l)),e.dispatch(na());},sendDetailedFeedback(l){e.dispatch(Ku(l)),e.dispatch(na());},selectSource(){i.select();},beginDelayedSelectSource(){i.beginDelayedSelect();},cancelPendingSelectSource(){i.cancelPendingSelect();},selectInlineLink(l){s.selectInlineLink(l);},beginDelayedSelectInlineLink(l){s.beginDelayedSelectInlineLink(l);},cancelPendingSelectInlineLink(l){s.cancelPendingSelectInlineLink(l);}}}function xw(e){return e.addReducers({search:G,questionAnswering:ur}),!0}function wv(e,t){if(!Rw(e));let r=()=>e.state,a=p=>{let f=r(),d=Qa(f,p);return d?Fr(f,d.documentId):null},n=new Set,o=p=>n.has(p)?!0:(n.add(p),!1),i=null,s=p=>{i!==p&&(i=p,c={},n.clear());},u=(p,f)=>{var d;return mt(e,{options:{selectionDelay:(d=t==null?void 0:t.options)==null?void 0:d.selectionDelay}},()=>{o(f)||(e.dispatch(Xu({questionAnswerId:f})),e.dispatch(dt(p)));})},c={},l=p=>{let{searchResponseId:f}=r().search;s(f);let d=a(p);return d?(p in c||(c[p]=u(d,p)),c[p]):null};return {selectSource(p){var f;(f=l(p))==null||f.select();},beginDelayedSelectSource(p){var f;(f=l(p))==null||f.beginDelayedSelect();},cancelPendingSelectSource(p){var f;(f=l(p))==null||f.cancelPendingSelect();}}}function Rw(e){return e.addReducers({search:G,questionAnswering:ur}),!0}function bw(e,t){var s,u;if(!Fw(e));let r=B(e),a=()=>e.state,n=c=>{let{contentIdKey:l,contentIdValue:p}=c;return e.state.search.results.find(f=>vr(f,l)===p)},o=wv(e,{options:{selectionDelay:(s=t==null?void 0:t.options)==null?void 0:s.selectionDelay}}),i=el(e,{options:{selectionDelay:(u=t==null?void 0:t.options)==null?void 0:u.selectionDelay}});return {...r,get state(){let c=a();return {questions:c.search.questionAnswer.relatedQuestions.map((l,p)=>({question:l.question,answer:l.answerSnippet,documentId:l.documentId,questionAnswerId:c.questionAnswering.relatedQuestions[p].questionAnswerId,expanded:c.questionAnswering.relatedQuestions[p].expanded,source:n(l.documentId)}))}},expand(c){let l={questionAnswerId:c};e.dispatch(Gu(l)),e.dispatch(ao(l));},collapse(c){let l={questionAnswerId:c};e.dispatch(Ju(l)),e.dispatch(no(l));},selectSource(c){o.selectSource(c);},beginDelayedSelectSource(c){o.beginDelayedSelectSource(c);},cancelPendingSelectSource(c){o.cancelPendingSelectSource(c);},selectInlineLink(c,l){i.selectInlineLink(l,c);},beginDelayedSelectInlineLink(c,l){i.beginDelayedSelectInlineLink(l,c);},cancelPendingSelectInlineLink(c,l){i.cancelPendingSelectInlineLink(l,c);}}}function Fw(e){return e.addReducers({search:G,questionAnswering:ur}),!0}var kv=()=>Q("analytics/recentQueries/clear",M.Custom,e=>e.makeClearRecentQueries()),Ov=()=>Q("analytics/recentQueries/click",M.Search,e=>e.makeRecentQueryClick());var Aw={queries:[]},Pw={maxLength:10,clearFilters:!0},Iw=new Z({queries:new K({required:!0})}),Ew=new Z({maxLength:new U({required:!0,min:1}),clearFilters:new J});function ww(e,t){pe(e,Ew,t==null?void 0:t.options,"buildRecentQueriesList"),we(e,Iw,t==null?void 0:t.initialState,"buildRecentQueriesList");}function kw(e,t){if(!Ow(e));let r=B(e),{dispatch:a}=e,n=()=>e.state,o={...Pw,...t==null?void 0:t.options},i={...Aw,...t==null?void 0:t.initialState};ww(e,{options:o,initialState:i});let s={queries:i.queries,maxLength:o.maxLength};return a(oo(s)),{...r,get state(){let u=n();return {...u.recentQueries,analyticsEnabled:u.configuration.analytics.enabled}},clear(){a(kv()),a(io());},executeRecentQuery(u){let c=new U({required:!0,min:0,max:this.state.queries.length}).validate(u);if(c)throw new Error(c);a(Is({q:this.state.queries[u],clearFilters:o.clearFilters})),a(T(Ov()));}}}function Ow(e){return e.addReducers({search:G,recentQueries:ru}),!0}function Lw(e,t){if(!jw(e));let r=f=>{var d,m;return (m=(d=e.state.facetOptions.facets[f])==null?void 0:d.enabled)!=null?m:!1},a=f=>{var d,m,h,v,C,x,b,P,_,X,H,I,$,ne,N,A;return (A=(N=(H=(b=(h=(m=(d=e.state.facetSet)==null?void 0:d[f])==null?void 0:m.request)==null?void 0:h.currentValues)!=null?b:(x=(C=(v=e.state.categoryFacetSet)==null?void 0:v[f])==null?void 0:C.request)==null?void 0:x.currentValues)!=null?H:(X=(_=(P=e.state.numericFacetSet)==null?void 0:P[f])==null?void 0:_.request)==null?void 0:X.currentValues)!=null?N:(ne=($=(I=e.state.dateFacetSet)==null?void 0:I[f])==null?void 0:$.request)==null?void 0:ne.currentValues)!=null?A:null},n=f=>f in e.state.facetOptions.facets,o=()=>rn({isFacetRegistered:n(t.facetId),parentFacets:t.conditions.map(({parentFacetId:f})=>n(f)?{enabled:r(f),values:a(f)}:null)}),i=()=>{let f=o();return f===l?!1:(l=f,!0)},s=()=>t.conditions.some(f=>{if(!r(f.parentFacetId))return !1;let d=a(f.parentFacetId);return d===null?!1:f.condition(d)}),u=()=>{e.state.facetSet&&Object.entries(e.state.facetSet).forEach(([f,d])=>d.request.freezeCurrentValues&&e.dispatch(Kr({facetId:f,freezeCurrentValues:!1})));},c=()=>{if(!n(t.facetId))return;let f=r(t.facetId),d=s();f!==d&&(e.dispatch(d?je(t.facetId):ye(t.facetId)),u());};if(!t.conditions.length)return {stopWatching(){}};let l=o(),p=e.subscribe(()=>{i()&&c();});return c(),{stopWatching(){p();}}}function jw(e){return e.addReducers({facetOptions:Oe}),!0}function Xie(e){return e.addReducers({configuration:W,pipeline:Io,searchHub:Eo}),{updateSearchConfiguration:ut}}function Cse(e){return e.addReducers({dateFacetSet:sr}),{deselectAllDateFacetValues:hc,registerDateFacet:Zt,toggleSelectDateFacetValue:er,updateDateFacetSortCriterion:gc,updateDateFacetValues:xr}}function Vse(e){return e.addReducers({fields:ia}),{registerFieldsToInclude:ea,enableFetchAllFields:zn,disableFetchAllFields:Ta,fetchFieldsDescription:Wn}}function Wse(e){return e.addReducers({numericFacetSet:pt}),{deselectAllNumericFacetValues:vc,registerNumericFacet:tr,toggleSelectNumericFacetValue:rr,updateNumericFacetSortCriterion:yc,updateNumericFacetValues:Rr}}function fce(e){return e.addReducers({query:ft}),{updateQuery:ot}}function vce(e){return e.addReducers({querySet:Ao}),{registerQuerySetQuery:Gn,updateQuerySetQuery:Va}}function Qce(e){return e.addReducers({querySuggest:Po,querySet:Ao}),{clearQuerySuggest:ra,fetchQuerySuggestions:aa,registerQuerySuggest:Kn,selectQuerySuggestion:nr}}var Hw=new Z({content:new de({required:!0}),conditions:new de({required:!0}),priority:new U({required:!1,default:0,min:0}),fields:new K({required:!1,each:q})});function zw(e){if(!Ww(e));let t=[],r=a=>{a.forEach(n=>{if(Hw.validate(n),!n.conditions.every(i=>i instanceof Function))throw new fa("Each result template conditions should be a function that takes a result as an argument and returns a boolean")});};return {registerTemplates(...a){let n=[];r(a),a.forEach(o=>{let i={...o,priority:o.priority||0,fields:o.fields||[]};t.push(i),n.push(...i.fields);}),t.sort((o,i)=>i.priority-o.priority),n.length&&e.dispatch(ea(n));},selectTemplate(a){let n=t.find(o=>o.conditions.every(i=>i(a)));return n?n.content:null}}}function Ww(e){return e.addReducers({fields:ia}),!0}var Dv;(o=>{o.getResultProperty=vr,o.fieldsMustBeDefined=Ch,o.fieldsMustNotBeDefined=xh,o.fieldMustMatch=Rh,o.fieldMustNotMatch=bh;})(Dv||(Dv={}));function Yw(e){let{by:t,order:r}=e;switch(t){case Bt.Relevancy:return gi();case Bt.QRE:return xd();case Bt.NoSort:return Rd();case Bt.Date:if(!r)throw new Error('An order (i.e., ascending or descending) should be specified for a sort criterion sorted by "date"');return vd(r);default:if(!r)throw new Error(`An order (i.e., ascending or descending) should be specified for a sort criterion sorted by a field, such as "${t}"`);return Cd(t,r)}}function Kw(e){return e===void 0||e===Ur.Ascending||e===Ur.Descending}function Gw(e){let t=e.split(","),r=new Error(`Wrong criterion expression format for "${e}"`);if(!t.length)throw r;return t.map(a=>{let n=a.trim().split(" "),o=n[0].toLowerCase(),i=n[1]&&n[1].toLowerCase();if(n.length>2||o==="")throw r;if(!Kw(i))throw new Error(`Wrong criterion sort order "${i}" in expression "${e}". Order should either be "${Ur.Ascending}" or "${Ur.Descending}"`);return Yw({by:o,order:i})})}/*! *****************************************************************************
|
|
3867
|
+
Copyright (c) Microsoft Corporation.
|
|
3868
|
+
|
|
3869
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
3870
|
+
purpose with or without fee is hereby granted.
|
|
3871
|
+
|
|
3872
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3873
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3874
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3875
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3876
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3877
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3878
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
3879
|
+
***************************************************************************** */
|
|
3880
|
+
|
|
3881
|
+
/**
|
|
3882
|
+
* Binds the logging of document
|
|
3883
|
+
* @returns An unbind function for the events
|
|
3884
|
+
* @param engine A headless search engine instance.
|
|
3885
|
+
* @param result The result object
|
|
3886
|
+
* @param resultElement Parent result element
|
|
3887
|
+
* @param selector Optional. Css selector that selects all links to the document. Default: "a" tags with the clickUri as "href" parameter.
|
|
3888
|
+
*/
|
|
3889
|
+
function bindLogDocumentOpenOnResult(engine, result, resultElement, selector) {
|
|
3890
|
+
const interactiveResult = _I(engine, {
|
|
3891
|
+
options: { result },
|
|
3892
|
+
});
|
|
3893
|
+
const eventsMap = {
|
|
3894
|
+
contextmenu: () => interactiveResult.select(),
|
|
3895
|
+
click: () => interactiveResult.select(),
|
|
3896
|
+
mouseup: () => interactiveResult.select(),
|
|
3897
|
+
mousedown: () => interactiveResult.select(),
|
|
3898
|
+
touchstart: () => interactiveResult.beginDelayedSelect(),
|
|
3899
|
+
touchend: () => interactiveResult.cancelPendingSelect(),
|
|
3900
|
+
};
|
|
3901
|
+
const elements = resultElement.querySelectorAll(selector || 'a');
|
|
3902
|
+
elements.forEach((element) => {
|
|
3903
|
+
Object.keys(eventsMap).forEach((key) => element.addEventListener(key, eventsMap[key]));
|
|
3904
|
+
});
|
|
3905
|
+
return () => {
|
|
3906
|
+
elements.forEach((element) => {
|
|
3907
|
+
Object.keys(eventsMap).forEach((key) => element.removeEventListener(key, eventsMap[key]));
|
|
3908
|
+
});
|
|
3909
|
+
};
|
|
3910
|
+
}
|
|
3911
|
+
function buildStringTemplateFromResult(template, result, bindings) {
|
|
3912
|
+
return template.replace(/\${(.*?)}/g, (value) => {
|
|
3913
|
+
const key = value.substring(2, value.length - 1);
|
|
3914
|
+
let newValue = readFromObject(result, key);
|
|
3915
|
+
if (!newValue) {
|
|
3916
|
+
newValue = readFromObject(window, key);
|
|
3917
|
+
}
|
|
3918
|
+
if (!newValue) {
|
|
3919
|
+
bindings.engine.logger.warn(`${key} used in the href template is undefined for this result: ${result.uniqueId}`);
|
|
3920
|
+
return '';
|
|
3921
|
+
}
|
|
3922
|
+
return newValue;
|
|
3923
|
+
});
|
|
3924
|
+
}
|
|
3925
|
+
function getStringValueFromResultOrNull(result, field) {
|
|
3926
|
+
const value = Dv.getResultProperty(result, field);
|
|
3927
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
3928
|
+
return null;
|
|
3929
|
+
}
|
|
3930
|
+
return value;
|
|
3931
|
+
}
|
|
3932
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3933
|
+
function readFromObject(object, key) {
|
|
3934
|
+
const firstPeriodIndex = key.indexOf('.');
|
|
3935
|
+
if (object && firstPeriodIndex !== -1) {
|
|
3936
|
+
const newKey = key.substring(firstPeriodIndex + 1);
|
|
3937
|
+
key = key.substring(0, firstPeriodIndex);
|
|
3938
|
+
return readFromObject(object[key], newKey);
|
|
3939
|
+
}
|
|
3940
|
+
return object ? object[key] : undefined;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
class MissingResultParentError extends Error {
|
|
3944
|
+
constructor(elementName) {
|
|
3945
|
+
super(`The "${elementName}" element must be the child of an "atomic-result" element.`);
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
/**
|
|
3949
|
+
* A [StencilJS property decorator](https://stenciljs.com/) to be used for result template components.
|
|
3950
|
+
* This allows the Stencil component to fetch the current result from its rendered parent, the `atomic-result` component.
|
|
3951
|
+
*
|
|
3952
|
+
* Example:
|
|
3953
|
+
* @ResultContext() private result!: Result;
|
|
3954
|
+
*
|
|
3955
|
+
* For more information and examples, view the "Utilities" section of the readme.
|
|
3956
|
+
*/
|
|
3957
|
+
function ResultContext(opts = { folded: false }) {
|
|
3958
|
+
return (component, resultVariable) => {
|
|
3959
|
+
const { connectedCallback, componentWillRender, render } = component;
|
|
3960
|
+
component.connectedCallback = function () {
|
|
3961
|
+
const element = getElement(this);
|
|
3962
|
+
const event = buildCustomEvent(resultContextEventName, (result) => {
|
|
3963
|
+
if (opts.folded) {
|
|
3964
|
+
if (isFolded(result)) {
|
|
3965
|
+
this[resultVariable] = result;
|
|
3966
|
+
}
|
|
3967
|
+
else {
|
|
3968
|
+
this[resultVariable] = { children: [], result };
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
else {
|
|
3972
|
+
this[resultVariable] = isFolded(result) ? result.result : result;
|
|
3973
|
+
}
|
|
3974
|
+
});
|
|
3975
|
+
const canceled = element.dispatchEvent(event);
|
|
3976
|
+
if (canceled) {
|
|
3977
|
+
this.error = new MissingResultParentError(element.nodeName.toLowerCase());
|
|
3978
|
+
return;
|
|
3979
|
+
}
|
|
3980
|
+
return connectedCallback && connectedCallback.call(this);
|
|
3981
|
+
};
|
|
3982
|
+
component.componentWillRender = function () {
|
|
3983
|
+
if (this.error) {
|
|
3984
|
+
return;
|
|
3985
|
+
}
|
|
3986
|
+
return componentWillRender && componentWillRender.call(this);
|
|
3987
|
+
};
|
|
3988
|
+
component.render = function () {
|
|
3989
|
+
if (this.error) {
|
|
3990
|
+
const element = getElement(this);
|
|
3991
|
+
element.remove();
|
|
3992
|
+
console.error('Result component is in error and has been removed from the DOM', this.error, this, element);
|
|
3993
|
+
return;
|
|
3994
|
+
}
|
|
3995
|
+
return render && render.call(this);
|
|
3996
|
+
};
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
function InteractiveResultContext() {
|
|
4000
|
+
return (component, interactiveResultVariable) => {
|
|
4001
|
+
const { connectedCallback } = component;
|
|
4002
|
+
component.connectedCallback = function () {
|
|
4003
|
+
const element = getElement(this);
|
|
4004
|
+
const event = buildCustomEvent(interactiveResultContextEventName, (result) => {
|
|
4005
|
+
this[interactiveResultVariable] = result;
|
|
4006
|
+
});
|
|
4007
|
+
element.dispatchEvent(event);
|
|
4008
|
+
return connectedCallback && connectedCallback.call(this);
|
|
4009
|
+
};
|
|
4010
|
+
};
|
|
4011
|
+
}
|
|
4012
|
+
const resultContextEventName = 'atomic/resolveResult';
|
|
4013
|
+
const interactiveResultContextEventName = 'atomic/resolveInteractiveResult';
|
|
4014
|
+
/**
|
|
4015
|
+
* Retrieves `Result` on a rendered `atomic-result`.
|
|
4016
|
+
*
|
|
4017
|
+
* This method is useful for building custom result template elements, see [Create a Result List](https://docs.coveo.com/en/atomic/latest/usage/create-a-result-list/) for more information.
|
|
4018
|
+
*
|
|
4019
|
+
* You should use the method in the [connectedCallback lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).
|
|
4020
|
+
*
|
|
4021
|
+
* @param element The element that the event is dispatched to, which must be the child of a rendered "atomic-result".
|
|
4022
|
+
* @returns A promise that resolves on initialization of the parent "atomic-result" element, or rejects when there is no parent "atomic-result" element.
|
|
4023
|
+
*/
|
|
4024
|
+
function resultContext(element) {
|
|
4025
|
+
return new Promise((resolve, reject) => {
|
|
4026
|
+
const event = buildCustomEvent(resultContextEventName, (result) => {
|
|
4027
|
+
return resolve(result);
|
|
4028
|
+
});
|
|
4029
|
+
element.dispatchEvent(event);
|
|
4030
|
+
if (!closest(element, 'atomic-result')) {
|
|
4031
|
+
reject(new MissingResultParentError(element.nodeName.toLowerCase()));
|
|
4032
|
+
}
|
|
4033
|
+
});
|
|
4034
|
+
}
|
|
4035
|
+
function isFolded(result) {
|
|
4036
|
+
return 'children' in result;
|
|
4037
|
+
}
|
|
4038
|
+
const childTemplatesContextEventName = 'atomic/resolveChildTemplates';
|
|
4039
|
+
/**
|
|
4040
|
+
* A [StencilJS property decorator](https://stenciljs.com/) to be used for children result templates.
|
|
4041
|
+
* This allows the Stencil component to fetch children templates defined a level above.
|
|
4042
|
+
*/
|
|
4043
|
+
function ChildTemplatesContext() {
|
|
4044
|
+
return (component, resultTemplateProviderProp) => {
|
|
4045
|
+
const { componentWillRender } = component;
|
|
4046
|
+
component.componentWillRender = function () {
|
|
4047
|
+
const element = getElement(this);
|
|
4048
|
+
const event = buildCustomEvent(childTemplatesContextEventName, (resultTemplateProvider) => {
|
|
4049
|
+
const component = this;
|
|
4050
|
+
if (component.resultTemplateProvider) {
|
|
4051
|
+
return;
|
|
4052
|
+
}
|
|
4053
|
+
this[resultTemplateProviderProp] = resultTemplateProvider;
|
|
4054
|
+
});
|
|
4055
|
+
const canceled = element.dispatchEvent(event);
|
|
4056
|
+
if (canceled) {
|
|
4057
|
+
this[resultTemplateProviderProp] = null;
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
return componentWillRender && componentWillRender.call(this);
|
|
4061
|
+
};
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
const resultDisplayConfigContextEventName = 'atomic/resolveResultDisplayConfig';
|
|
4065
|
+
/**
|
|
4066
|
+
* A [StencilJS property decorator](https://stenciljs.com/) to fetch display properties for a result.
|
|
4067
|
+
*/
|
|
4068
|
+
function ResultDisplayConfigContext() {
|
|
4069
|
+
return (component, resultVariable) => {
|
|
4070
|
+
const { componentWillRender } = component;
|
|
4071
|
+
component.componentWillRender = function () {
|
|
4072
|
+
const element = getElement(this);
|
|
4073
|
+
const event = buildCustomEvent(resultDisplayConfigContextEventName, (config) => {
|
|
4074
|
+
this[resultVariable] = config;
|
|
4075
|
+
});
|
|
4076
|
+
const canceled = element.dispatchEvent(event);
|
|
4077
|
+
if (canceled) {
|
|
4078
|
+
return;
|
|
4079
|
+
}
|
|
4080
|
+
return componentWillRender && componentWillRender.call(this);
|
|
4081
|
+
};
|
|
4082
|
+
};
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
const searchBoxElements = ['atomic-search-box', 'atomic-insight-search-box'];
|
|
4086
|
+
/**
|
|
4087
|
+
* Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.
|
|
4088
|
+
* @param event Event sent from the registered query suggestions to the parent search box.
|
|
4089
|
+
* @param element Element on which to dispatch the event, which must be the child of a configured search box.
|
|
4090
|
+
*/
|
|
4091
|
+
const dispatchSearchBoxSuggestionsEvent = (event, element) => {
|
|
4092
|
+
element.dispatchEvent(buildCustomEvent('atomic/searchBoxSuggestion/register', event));
|
|
4093
|
+
if (!closest(element, searchBoxElements.join(', '))) {
|
|
4094
|
+
throw new Error(`The "${element.nodeName.toLowerCase()}" component was not handled, as it is not a child of the following elements: ${searchBoxElements.join(', ')}`);
|
|
4095
|
+
}
|
|
4096
|
+
};
|
|
4097
|
+
function elementHasNoQuery(el) {
|
|
4098
|
+
return !el.query;
|
|
4099
|
+
}
|
|
4100
|
+
function elementHasQuery(el) {
|
|
4101
|
+
return !!el.query;
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
function initializeBindings(element) {
|
|
4105
|
+
return initializeBindings$1(element);
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
export { initializeBindings as i, resultContext as r };
|