@froomle/frontend-sdk 0.0.30 → 0.1.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/CHANGELOG.md +107 -0
- package/dist/froomle.global.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/js-BJHOFA94.js +5 -0
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/{src-BGinSb_U.js → src-BzUJq6YD.js} +1 -1
- package/dist/src-EA0Sr8Ah.cjs +5 -0
- package/package.json +2 -1
- package/dist/js-BClW3EMu.js +0 -5
- package/dist/src-CVJOYhnj.cjs +0 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Customer-facing release notes for the Froomle frontend SDK.
|
|
4
|
+
|
|
5
|
+
This changelog focuses on shipped SDK behavior, public APIs, and integration capabilities. It intentionally leaves out test-only, CI-only, and internal refactor details unless they changed runtime behavior.
|
|
6
|
+
|
|
7
|
+
## 0.1.0 - 2026-03-27
|
|
8
|
+
- JS/TS module imports are now side-effect free. Module-based DOM placeholder integrations that rely on `data-froomle-*` attributes must now call `init()` explicitly after their SDK setters. Script-tag/global integrations keep their existing auto-init behavior.
|
|
9
|
+
- React integrations no longer trigger duplicate recommendation requests or duplicate automatic page-level events by overlapping with the declarative DOM integration path.
|
|
10
|
+
- Framework-managed recommendation wrappers now mark their own DOM ownership so declarative DOM filling ignores React-managed recommendation blocks instead of treating them as raw HTML placeholders.
|
|
11
|
+
- Removed the undocumented `RecoBackendV2` and `DomDomDom` exports from the shipped JS/global surfaces. Public integrations should use the documented root SDK APIs instead.
|
|
12
|
+
- Removed the undocumented `RecommendationList` and `Recommendations` constructors from the shipped root/global SDK surfaces. Use `getRecommendations(...)` directly and work with its returned object instead of importing SDK constructor names.
|
|
13
|
+
|
|
14
|
+
## 0.0.30 - 2026-03-25
|
|
15
|
+
- Improved compatibility for `@froomle/frontend-sdk/react` imports in older CommonJS and legacy TypeScript toolchains by adding a dedicated React compatibility entry alongside package exports.
|
|
16
|
+
|
|
17
|
+
## 0.0.29 - 2026-03-24
|
|
18
|
+
- Added the `defaultField(...)` HTML transform so placeholder bindings can fall back to another recommendation field when the primary value is empty.
|
|
19
|
+
|
|
20
|
+
## 0.0.28 - 2026-03-20
|
|
21
|
+
- Added manual retail event helpers for JS and React integrations: `sendItemInteraction`, `sendUserInteraction`, `sendAddToCart`, `sendRemoveFromCart`, and `sendPurchase`.
|
|
22
|
+
- These helpers reuse the current SDK context and consent rules so retail events can be sent without assembling raw event payloads by hand.
|
|
23
|
+
|
|
24
|
+
## 0.0.27 - 2026-03-12
|
|
25
|
+
- Added explicit click `action_item_type` overrides via `data-froomle-action-item-type`, so click events can report a different item type than the surrounding recommendation container.
|
|
26
|
+
|
|
27
|
+
## 0.0.26 - 2026-03-12
|
|
28
|
+
- Added the `X-Froomle-Client: frontend-sdk/<version>` header to outgoing recommendation and event requests.
|
|
29
|
+
- Unified event delivery through a shared transport layer so page visits, detail views, clicks, and impressions follow the same request behavior.
|
|
30
|
+
|
|
31
|
+
## 0.0.25 - 2026-03-11
|
|
32
|
+
- Added bearer-token support for recommendation requests through `setRecommendationsBearer(...)`, `clearRecommendationsBearer()`, `setRecommendationsBearerProvider(...)`, and `clearRecommendationsBearerProvider()`.
|
|
33
|
+
- Added token-provider refresh and retry support so protected recommendation APIs can recover from expired tokens.
|
|
34
|
+
|
|
35
|
+
## 0.0.24 - 2026-03-10
|
|
36
|
+
- HTML `data-froomle-reco-filter-*` and `data-froomle-variable-*` attributes can now carry array values via JSON or `;`-separated syntax.
|
|
37
|
+
- Single values now stay single values instead of being automatically coerced into arrays.
|
|
38
|
+
|
|
39
|
+
## 0.0.22 - 2026-03-08
|
|
40
|
+
- Added the `froomle:before-init` browser event for script-tag integrations.
|
|
41
|
+
- This event fires before auto-init work starts, so consent, user, and page-context setters can run before the first automatic request.
|
|
42
|
+
|
|
43
|
+
## 0.0.21 - 2026-03-08
|
|
44
|
+
- Added explicit and event-driven initialization for the script-tag SDK.
|
|
45
|
+
- Added `init()` for manual startup.
|
|
46
|
+
- Exposed post-init readiness through the `froomle:init` event and the global `FroomleFrontendSdkReady` promise, while preserving normal auto-init behavior.
|
|
47
|
+
|
|
48
|
+
## 0.0.20 - 2026-02-26
|
|
49
|
+
- Added inline expressions and template interpolation for HTML `data-froomle-param-*` bindings.
|
|
50
|
+
- Added built-in value transforms for HTML mappings, including `replace`, `prepend`, `append`, `default`, `trim`, `lower`, `upper`, and `urlencode`.
|
|
51
|
+
|
|
52
|
+
## 0.0.18 - 2026-02-25
|
|
53
|
+
- Improved asynchronous error handling so recommendation and order request failures can reject cleanly instead of leaving callers waiting indefinitely.
|
|
54
|
+
- React wrappers now keep their lifecycle moving even when recommendation resolution fails, which makes failure behavior more predictable.
|
|
55
|
+
|
|
56
|
+
## 0.0.17 - 2026-02-25
|
|
57
|
+
- `addHistories(...)` now accepts either plain item IDs or full history objects with explicit item types.
|
|
58
|
+
- Added a default item-type fallback so mixed history inputs can still be normalized into the request payload.
|
|
59
|
+
|
|
60
|
+
## 0.0.16 - 2026-02-24
|
|
61
|
+
- Added automatic filling and impression tracking for recommendation blocks inserted or updated after the initial page load.
|
|
62
|
+
- Removed the older `pageView` API path in favor of the newer page/context tracking model.
|
|
63
|
+
|
|
64
|
+
## 0.0.15 - 2026-02-23
|
|
65
|
+
- Introduced a 3-level consent model that separates no tracking, device-only tracking, and full tracking with user identity.
|
|
66
|
+
- Added configurable `channel` support across requests and events.
|
|
67
|
+
- Replaced the older detail-page `pageView` model with `context_item` and `context_item_type`.
|
|
68
|
+
- Improved page-visit, detail-view, and click event payloads so they respect consent and include richer context.
|
|
69
|
+
|
|
70
|
+
## 0.0.14 - 2026-02-23
|
|
71
|
+
- Standardized `user_group` propagation from recommendation responses into rendered items and follow-up events.
|
|
72
|
+
- Recommendation proxies and React wrappers now preserve `user_group` consistently, even when it is only returned at response level.
|
|
73
|
+
|
|
74
|
+
## 0.0.13 - 2026-02-23
|
|
75
|
+
- Added support for multiple filters per recommendation list.
|
|
76
|
+
- Added support for array-valued filters in recommendation requests.
|
|
77
|
+
- Added consent-aware event tracking and `user_group` propagation for page visits, detail views, impressions, and recommendation clicks across HTML and React integrations.
|
|
78
|
+
- Added `setPageView(...)` for detail-page tracking in this release line. This was later replaced by the context-item model introduced in `0.0.15` and finalized in `0.0.16`.
|
|
79
|
+
|
|
80
|
+
## 0.0.12 - 2026-02-19
|
|
81
|
+
- Added React 19 compatibility to the React package peer dependency range.
|
|
82
|
+
|
|
83
|
+
## 0.0.11 - 2026-02-18
|
|
84
|
+
- Introduced the first full public JS package structure with modular JS entrypoints.
|
|
85
|
+
- Added the framework-agnostic proxy recommendation flow built around `proxyReco(...)` and `fulfillRecommendations()`.
|
|
86
|
+
- Added the first full React helper layer with `FroomleSdkInit`, `FroomleReco`, `useReco`, and `useCreateReco`.
|
|
87
|
+
- Added custom-item and order helpers for React integrations.
|
|
88
|
+
- Added refreshed raw, HTML, and React sample apps.
|
|
89
|
+
|
|
90
|
+
## 0.0.9 - 2025-12-15
|
|
91
|
+
- Added the legacy PHP / Drupal 7 distribution and example environment.
|
|
92
|
+
- Added script-tag generation helpers and channel support for server-rendered integrations.
|
|
93
|
+
- Improved legacy ordering and recommendation demo templates.
|
|
94
|
+
|
|
95
|
+
## 0.0.5 - 2025-12-01
|
|
96
|
+
- Tightened PHP SDK activation so script injection only happens once the required page context is present.
|
|
97
|
+
- Fixed PHP bootstrap buffering so the SDK can activate more reliably in server-rendered pages.
|
|
98
|
+
- Expanded the Drupal example with working recommendation placeholders for titles and images.
|
|
99
|
+
|
|
100
|
+
## 0.0.4 - 2025-12-01
|
|
101
|
+
- Improved PHP bootstrap output handling and CLI compatibility.
|
|
102
|
+
- Reduced unwanted debug noise during PHP bootstrap output injection.
|
|
103
|
+
|
|
104
|
+
## v0.0.1-alpha.0 - 2025-12-01
|
|
105
|
+
- First alpha release of the new frontend SDK monorepo.
|
|
106
|
+
- Shipped the shared core with initial JS and PHP targets.
|
|
107
|
+
- Added early recommendation filling, impression handling, history support, ordering support, and sample HTML, PHP, and React Native integrations.
|
package/dist/froomle.global.js
CHANGED
|
@@ -2,4 +2,4 @@ var FroomleFrontendSdk=(function(e){var t=class e{static global(t){return e.glob
|
|
|
2
2
|
`;r+=` `;let o=n.hasOwnProperty!=null,s=null;for(s in n)o&&!n.hasOwnProperty(s)||s==`prototype`||s==`__class__`||s==`__super__`||s==`__interfaces__`||s==`__properties__`||(a.length!=2&&(a+=`,
|
|
3
3
|
`),a+=r+s+` : `+e.__string_rec(n[s],r));return r=r.substring(1),a+=`
|
|
4
4
|
`+r+`}`,a;case`string`:return n;default:return String(n)}}static __interfLoop(t,n){if(t==null)return!1;if(t==n)return!0;let r=t.__interfaces__;if(r!=null&&(t.__super__==null||t.__super__.__interfaces__!=r)){let t=0,i=r.length;for(;t<i;){let i=r[t++];if(i==n||e.__interfLoop(i,n))return!0}}return e.__interfLoop(t.__super__,n)}static __instanceof(n,r){if(r==null)return!1;switch(r){case Array:return n instanceof Array;case`$hxCoreType__Bool`:return typeof n==`boolean`;case`$hxCoreType__Dynamic`:return n!=null;case`$hxCoreType__Float`:return typeof n==`number`;case`$hxCoreType__Int`:return typeof n==`number`?(n|0)===n:!1;case String:return typeof n==`string`;default:if(n!=null){if(typeof r==`function`){if(e.__downcastCheck(n,r))return!0}else if(typeof r==`object`&&e.__isNativeObj(r)&&n instanceof r)return!0}else return!1;return r==`$hxCoreType__Class`&&n.__name__!=null||r==`$hxCoreType__Enum`&&n.__ename__!=null?!0:n.__enum__==null?!1:t.global(`$hxEnums`)[n.__enum__]==r}}static __downcastCheck(t,n){return t instanceof n?!0:n.__isInterface__?e.__interfLoop(e.getClass(t),n):!1}static __cast(t,n){if(t==null||e.__instanceof(t,n))return t;throw i.thrown(`Cannot cast `+a.string(t)+` to `+a.string(n))}static __nativeClassName(t){let n=e.__toStr.call(t).slice(8,-1);return n==`Object`||n==`Function`||n==`Math`||n==`JSON`?null:n}static __isNativeObj(t){return e.__nativeClassName(t)!=null}static __resolveNativeClass(e){return t.$global[e]}static get __name__(){return`js.Boot`}get __class__(){return e}};o.__toStr={}.toString,t.$global;let s=t.global(`$hxClasses`)[`js.Browser`]=class e{static get supported(){return this.get_supported()}static get_supported(){return typeof window<`u`&&window.location!==void 0?typeof window.location.protocol==`string`:!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest<`u`)return new XMLHttpRequest;if(typeof ActiveXObject<`u`)return new`ActiveXObject`(`Microsoft.XMLHTTP`);throw i.thrown(`Unable to create XMLHttpRequest object.`)}static get __name__(){return`js.Browser`}get __class__(){return e}};t.$global;let c=t.global(`$hxEnums`)[`haxe.io.Error`]={__ename__:`haxe.io.Error`,Blocked:{_hx_name:`Blocked`,_hx_index:0,__enum__:`haxe.io.Error`},Overflow:{_hx_name:`Overflow`,_hx_index:1,__enum__:`haxe.io.Error`},OutsideBounds:{_hx_name:`OutsideBounds`,_hx_index:2,__enum__:`haxe.io.Error`},Custom:Object.assign(e=>({_hx_index:3,__enum__:`haxe.io.Error`,e}),{_hx_name:`Custom`,__params__:[`e`]})};c.__constructs__=[c.Blocked,c.Overflow,c.OutsideBounds,c.Custom],c.__empty_constructs__=[c.Blocked,c.Overflow,c.OutsideBounds],t.$global;let l=t.global(`$hxEnums`)[`haxe.io.Encoding`]={__ename__:`haxe.io.Encoding`,UTF8:{_hx_name:`UTF8`,_hx_index:0,__enum__:`haxe.io.Encoding`},RawNative:{_hx_name:`RawNative`,_hx_index:1,__enum__:`haxe.io.Encoding`}};l.__constructs__=[l.UTF8,l.RawNative],l.__empty_constructs__=[l.UTF8,l.RawNative],t.$global;let u=t.global(`$hxClasses`)[`haxe.io.Bytes`]=class e extends t.inherits(){[t.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,n){if(e<0||t<0||e+t>this.length)throw i.thrown(c.OutsideBounds);n==null&&(n=l.UTF8);let r=``,a=this.b,o=e,s=e+t;switch(n._hx_index){case 0:for(;o<s;){let e=a[o++];if(e<128){if(e==0)break;r+=String.fromCodePoint(e)}else if(e<224){let t=(e&63)<<6|a[o++]&127;r+=String.fromCodePoint(t)}else if(e<240){let t=a[o++],n=(e&31)<<12|(t&127)<<6|a[o++]&127;r+=String.fromCodePoint(n)}else{let t=a[o++],n=a[o++],i=(e&15)<<18|(t&127)<<12|(n&127)<<6|a[o++]&127;r+=String.fromCodePoint(i)}}break;case 1:for(;o<s;){let e=a[o++]|a[o++]<<8;r+=String.fromCodePoint(e)}break}return r}static ofData(t){let n=t.hxBytes;return n==null?new e(t):n}static get __name__(){return`haxe.io.Bytes`}get __class__(){return e}};u.prototype.length=null,u.prototype.b=null,t.$global;let d=t.global(`$hxClasses`)[`haxe.http.HttpBase`]=class e extends t.inherits(){[t.new](e){this.url=e,this.headers=[],this.params=[],this.emptyOnData=t.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let n=0,r=this.headers.length;for(;n<r;){let r=n++;if(this.headers[r].name==e){this.headers[r]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return t.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,l.UTF8)),this.responseAsString}static get __name__(){return`haxe.http.HttpBase`}get __class__(){return e}};d.prototype.url=null,d.prototype.responseBytes=null,d.prototype.responseAsString=null,d.prototype.postData=null,d.prototype.postBytes=null,d.prototype.headers=null,d.prototype.params=null,d.prototype.emptyOnData=null,t.$global;let f=t.global(`$hxClasses`)[`haxe.iterators.MapKeyValueIterator`]=class e extends t.inherits(){[t.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return`haxe.iterators.MapKeyValueIterator`}get __class__(){return e}};f.prototype.map=null,f.prototype.keys=null,t.$global;let p=function(){};p.__isInterface__=!0,t.$global;let m=t.global(`$hxClasses`)[`genes.util.EsMap`]=class e extends t.inherits(){[t.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return e.adaptIterator(this.inst.keys())}iterator(){return e.adaptIterator(this.inst.values())}toString(){let t=[],n=e.adaptIterator(this.inst.keys());for(;n.hasNext();){let e=n.next();t.push(``+a.string(e)+` => `+a.string(this.inst.get(e)))}return`{`+t.join(`, `)+`}`}clear(){this.inst.clear()}static adaptIterator(e){let t,n,r=function(){let r=e.next();t=r.value,n=r.done};return{hasNext:function(){return n==null&&r(),!n},next:function(){n==null&&r();let e=t;return r(),e}}}static get __name__(){return`genes.util.EsMap`}get __class__(){return e}};m.prototype.inst=null,t.$global;let h=t.global(`$hxClasses`)[`haxe.ds.StringMap`]=class e extends t.inherits(m){[t.new](){super[t.new]()}copy(){let t=new e;return t.inst=new Map(this.inst),t}keyValueIterator(){return new f(this)}static get __name__(){return`haxe.ds.StringMap`}static get __interfaces__(){return[p]}static get __super__(){return m}get __class__(){return e}};t.$global;let g=t.global(`$hxClasses`).HxOverrides=class e{static cca(e,t){let n=e.charCodeAt(t);if(n==n)return n}static substr(e,t,n){if(n==null)n=e.length;else if(n<0)if(t==0)n=e.length+n;else return``;return e.substr(t,n)}static now(){return Date.now()}static get __name__(){return`HxOverrides`}get __class__(){return e}};typeof performance<`u`&&typeof performance.now==`function`&&(g.now=performance.now.bind(performance)),t.$global;let _=t.global(`$hxClasses`).StringTools=class e{static isSpace(e,t){let n=g.cca(e,t);return n>8&&n<14?!0:n==32}static ltrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,r);)++r;return r>0?g.substr(t,r,n-r):t}static rtrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,n-r-1);)++r;return r>0?g.substr(t,0,n-r):t}static trim(t){return e.ltrim(e.rtrim(t))}static replace(e,t,n){return e.split(t).join(n)}static get __name__(){return`StringTools`}get __class__(){return e}};t.$global;let v=t.global(`$hxClasses`).Lambda=class e{static exists(e,n){let r=t.getIterator(e);for(;r.hasNext();)if(n(r.next()))return!0;return!1}static get __name__(){return`Lambda`}get __class__(){return e}};t.$global;let y=t.global(`$hxClasses`).EReg=class e extends t.inherits(){[t.new](e,t){this.r=new RegExp(e,t.split(`u`).join(``))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw i.thrown(`EReg::matched`)}matchedPos(){if(this.r.m==null)throw i.thrown(`No string matched`);return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,n){if(n==null&&(n=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(n<0?e:g.substr(e,0,t+n));let r=this.r.m!=null;return r&&(this.r.s=e),r}else{let r=this.match(n<0?g.substr(e,t,null):g.substr(e,t,n));return r&&(this.r.s=e,this.r.m.index+=t),r}}map(e,t){let n=0,r=``;do{if(n>=e.length)break;if(!this.matchSub(e,n)){r+=a.string(g.substr(e,n,null));break}let i=this.matchedPos();r+=a.string(g.substr(e,n,i.pos-n)),r+=a.string(t(this)),i.len==0?(r+=a.string(g.substr(e,i.pos,1)),n=i.pos+1):n=i.pos+i.len}while(this.r.global);return!this.r.global&&n>0&&n<e.length&&(r+=a.string(g.substr(e,n,null))),r}static get __name__(){return`EReg`}get __class__(){return e}};y.prototype.r=null,t.$global;let b=t.global(`$hxClasses`)[`haxe.http.HttpJs`]=class e extends t.inherits(d){[t.new](e){this.async=!0,this.withCredentials=!1,super[t.new](e)}request(e){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let n=this.req=s.createXMLHttpRequest(),r=this,o=function(e){if(n.readyState!=4)return;let i;try{i=n.status}catch{i=null}if(i==0&&s.get_supported()&&t.$global.location!=null){let e=t.$global.location.protocol.toLowerCase();new y(`^(?:about|app|app-storage|.+-extension|file|res|widget):$`,``).match(e)&&(i=n.response==null?404:200)}if(i==null&&(i=null),i!=null&&r.onStatus(i),i!=null&&i>=200&&i<400){r.req=null;let e=n.getAllResponseHeaders().split(`\r
|
|
5
|
-
`),t=[],i=0,a=e;for(;i<a.length;){let e=a[i];++i,e!=``&&t.push(e)}e=t,r.responseHeaders=new h;let o=0;for(;o<e.length;){let t=e[o];++o;let n=t.split(`: `),i=n.shift(),a=n.length==1?n[0]:n.join(`: `);a=_.ltrim(_.rtrim(a)),r.responseHeaders.inst.set(i,a)}r.success(u.ofData(n.response))}else if(i==null||i==0&&n.response==null)r.req=null,r.onError(`Failed to connect or resolve host`);else if(i==null)r.req=null,r.responseBytes=n.response==null?null:u.ofData(n.response),r.onError(`Http Error #`+n.status);else switch(i){case 12007:r.req=null,r.onError(`Unknown host`);break;case 12029:r.req=null,r.onError(`Failed to connect to host`);break;default:r.req=null,r.responseBytes=n.response==null?null:u.ofData(n.response),r.onError(`Http Error #`+n.status)}};this.async&&(n.onreadystatechange=o);let c,l=this.postData,d=this.postBytes;if(l==null)if(d==null)c=null;else{let e=d;c=new Blob([e.b.bufferValue])}else c=d==null?l:null;if(c!=null)e=!0;else{let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,c=c==null?``:(c==null?`null`:a.string(c))+`&`;let r=n.name,i=(c==null?`null`:a.string(c))+encodeURIComponent(r)+`=`,o=n.value;c=i+encodeURIComponent(o)}}try{if(e)n.open(`POST`,this.url,this.async);else if(c!=null){let e=this.url.split(`?`).length<=1;n.open(`GET`,this.url+(e?`?`:`&`)+(c==null?`null`:a.string(c)),this.async),c=null}else n.open(`GET`,this.url,this.async);n.responseType=`arraybuffer`}catch(e){let t=i.caught(e).unwrap();this.req=null,this.onError(t.toString());return}n.withCredentials=this.withCredentials,!v.exists(this.headers,function(e){return e.name==`Content-Type`})&&e&&this.postData==null&&n.setRequestHeader(`Content-Type`,`application/x-www-form-urlencoded`);let f=0,p=this.headers;for(;f<p.length;){let e=p[f];++f,n.setRequestHeader(e.name,e.value)}n.send(c),this.async||o(null)}static get __name__(){return`haxe.http.HttpJs`}static get __super__(){return d}get __class__(){return e}};b.prototype.async=null,b.prototype.withCredentials=null,b.prototype.responseHeaders=null,b.prototype.req=null,t.$global;let x=t.global(`$hxClasses`).Type=class e{static createInstance(e,t){return new(Function.prototype.bind.apply(e,[null].concat(t)))}static get __name__(){return`Type`}get __class__(){return e}};t.$global;let S=t.global(`$hxClasses`).Reflect=class e{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let n;if(e==null)return null;{let r;return e.__properties__?(n=e.__properties__[`get_`+t],r=n):r=!1,r?e[n]():e[t]}}static setProperty(e,t,n){let r,i;e.__properties__?(r=e.__properties__[`set_`+t],i=r):i=!1,i?e[r](n):e[t]=n}static fields(e){let t=[];if(e!=null){let r=Object.prototype.hasOwnProperty;for(var n in e)n!=`__id__`&&n!=`hx__closures__`&&r.call(e,n)&&t.push(n)}return t}static compare(e,t){return e==t?0:e>t?1:-1}static get __name__(){return`Reflect`}get __class__(){return e}};t.$global;let C=t.global(`$hxClasses`)[`internal.http.FetchHttp`]=class e extends t.inherits(b){[t.new](e){this.responseStatus=0,super[t.new](e)}request(e){let n=t.$global,r=n.fetch,o=n.Headers,s=n.URLSearchParams;if(r==null){this.onError(`Fetch API not found.`);return}let c=x.createInstance(o,[]),l=0,u=this.headers;for(;l<u.length;){let e=u[l];++l,c.append(e.name,e.value)}let d=e?`POST`:`GET`,f=null;if(e)if(this.postData!=null)f=this.postData;else{f=x.createInstance(s,[]);let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,f.append(n.name,n.value)}}let p={method:d,headers:c,body:f},m=this,h=r(this.url,p).then(function(e){if(m.responseStatus=e.status,m.onStatus(e.status),e.ok)return e.text();throw i.thrown(`HTTP Error: `+a.string(e.status))}).then(function(e){m.onData(e)}),g=S.field(h,`catch`);g!=null&&g.apply(h,[function(e){m.onError(a.string(e))}])}static get __name__(){return`internal.http.FetchHttp`}static get __super__(){return b}get __class__(){return e}};C.prototype.responseStatus=null,t.$global;let w=t.global(`$hxClasses`)[`internal.data.UUID`]=class e{static randomHexChar(){return`0123456789abcdef`.charAt(a.random(16))}static v4(){let e=``,t=0;for(;t<36;)switch(t++){case 14:e+=`4`;break;case 19:e+=a.string(`0123456789abcdef`.charAt(8+a.random(4)));break;case 8:case 13:case 18:case 23:e+=`-`;break;default:e+=a.string(`0123456789abcdef`.charAt(a.random(16)))}return e}static get __name__(){return`internal.data.UUID`}get __class__(){return e}};w.HEX=`0123456789abcdef`,t.$global;let T=function(){};T.__isInterface__=!0;let E=function(){};E.__isInterface__=!0;let D=function(){};D.__isInterface__=!0,t.$global;let O=t.global(`$hxClasses`)[`internal.RecoBackendV2`]=class e extends t.inherits(){[t.new](){}static _requestUri(){return(e._safe_request?`https://`:`http://`)+e._req_domain+`/api/`+e._environment+`/recommendations/requests`}static noConsentBody(){return{device_id:`no-consent`,user_group:`no-consent`,version:`no-consent`}}static buildRequestBody(t){let n={lists:t,page_type:e._page_visit,channel:e._channel};if(e._consent>=2&&e._history.length>0&&(n.histories=e._buildHistories()),e._consent<2){let t=e.noConsentBody(),r=0,i=S.fields(t);for(;r<i.length;){let e=i[r];++r,n[e]=S.field(t,e)}}else e._user_id!=null&&(n.user_id=e._user_id),n.device_id=e._device_id;let r=0,i=e._others;for(;r<i.length;){let e=i[r];++r,n[e.key]=e.value}let o=S.field(n,`context_item`),s=S.field(n,`context_item_type`);return o!=null&&a.string(o)!=``&&(s==null||a.string(s)==``)&&(n.context_item_type=`article`),n}static _buildHistories(){return{pageviews:e._history}}static normalizeAccessToken(e){if(e==null)return null;let t=a.string(e);return t==``?null:t}static hasRecommendationsAccessTokenProvider(){return e._recommendations_access_token_provider!=null}static resolveRecommendationsAccessToken(t){if(!t){let t=e.normalizeAccessToken(e._recommendations_access_token);if(t!=null)return Promise.resolve(t)}if(!e.hasRecommendationsAccessTokenProvider())return Promise.resolve(e.normalizeAccessToken(e._recommendations_access_token));let n=null;try{n=e._recommendations_access_token_provider.apply(null,[{forceRefresh:t}])}catch(e){let t=i.caught(e).unwrap();return Promise.reject(t)}return Promise.resolve(n).then(function(t){let n=e.normalizeAccessToken(t);return e._recommendations_access_token=n,n})}static requestsToLists(e){let t=[],n=``,r=[],i=0,a=[],o=function(e,t,o){n=e,r=t,i=0,a=o},s=function(e){let t=[];if(e==null)return t;let n=0;for(;n<e.length;){let r=e[n];++n,!(r==null||r.key==null||r.key==``)&&t.push({key:r.key,value:r.value})}return t},c=function(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(S.compare),l.sort(S.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0},l=function(){let e={limit:i,list_name:n,list_size:i},o=0;for(;o<r.length;){let t=r[o];++o;let n=t.value;n instanceof Array||(n=[n]),e[t.key]=n}let s=0;for(;s<a.length;){let t=a[s];++s,e[t.key]=t.value}t.push(e)},u=0;for(;u<e.length;){let t=e[u];++u;let d=s(t.filters),f=t.others==null?[]:t.others;if(n==``){o(t.list,d,f),i+=1;continue}else (n!=t.list||!c(r,d)||!c(a,f))&&(l(),o(t.list,d,f));i+=1}return i!=0&&l(),t}static _requestRecos(t){let n=null,r=null,o=new Promise(function(e,t){n=e,r=t}),s=o;s._resolve=n,s._reject=r,s._isFinished=!1,s._result=null,s._error=null;let c=o,l=!1,u=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))},d=null;return d=function(n,r){if(l)return;let o=!1,s=!1,f=new C(e._requestUri());f.setHeader(`Content-Type`,`application/json`),f.setHeader(`X-Froomle-Client`,`frontend-sdk/0.0.30`);let p=e.normalizeAccessToken(n);p!=null&&f.setHeader(`Authorization`,`Bearer `+p);let m=e.buildRequestBody(t),h=JSON.stringify(m);f.setPostData(h),f.onError=function(e){o||s||l||(o=!0,u(`HTTP Request Error: `+e))},f.onStatus=function(t){if(!(o||l)){if(t==401&&r&&e.hasRecommendationsAccessTokenProvider()){o=!0,s=!0,e.resolveRecommendationsAccessToken(!0).then(function(e){return l?null:e==null?(u(`Recommendation access token provider returned no token during refresh.`),null):(d(e,!1),null)},function(e){return u(`Failed to refresh recommendation access token: `+a.string(e)),null});return}(t<200||t>=300)&&(o=!0,u(`HTTP Status Error: `+t))}};try{f.request(!0)}catch(e){let t=i.caught(e).unwrap();if(o||l)return;o=!0,u(`Failed to execute recommendation request: `+a.string(t));return}let g=function(e){if(!(o||s||l))try{let t=JSON.parse(e),n=k.fromRequestData(t);o=!0,l=!0;let r=c;r._isFinished||(r._result=n,r._error=null,r._isFinished=!0,r._resolve(n))}catch(e){let t=i.caught(e).unwrap();o=!0,u(`Failed to parse recommendation response: `+a.string(t))}},_=f.get_responseData();_==null?!o&&!s&&!l&&(f.onData=g):g(_)},e.resolveRecommendationsAccessToken(!1).then(function(t){return l?null:e.hasRecommendationsAccessTokenProvider()&&t==null?(u(`Recommendation access token provider returned no token.`),null):(d(t,e.hasRecommendationsAccessTokenProvider()),null)},function(e){return u(`Failed to resolve recommendation access token: `+a.string(e)),null}),c}static getOrder(t,n,r){let o={list_name:t,limit:r.length,list_size:r.length},s={};S.setProperty(s,n,r),S.setProperty(o,`order`,s);let c=null,l=null,u=new Promise(function(e,t){c=e,l=t}),d=u;d._resolve=c,d._reject=l,d._isFinished=!1,d._result=null,d._error=null;let f=u;return e.getRawRecommendations([o]).then(function(e){try{let t=[],n=e.lists();if(n!=null&&n.length>0){let e=n[0].items;if(e instanceof Array){let n=0,r=e;for(;n<r.length;){let e=r[n];++n;let i=e.get(`categories`);i!=null&&t.push(i)}}}let r=f;r._isFinished||(r._result=t,r._error=null,r._isFinished=!0,r._resolve(t))}catch(e){let t=i.caught(e).unwrap(),n=`Failed to build order response: `+a.string(t),r=f;r._isFinished||(r._error=n,r._isFinished=!0,r._reject(n))}},function(e){let t=f;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))}),f}static getRawRecommendations(t){return e._requestRecos(t)}static addHistories(t,n){if(n==null&&(n=`article`),t==null||t.length==0)return;let r=n!=null&&n!=``?n:`article`,i=0;for(;i<t.length;){let n=t[i];if(++i,typeof n==`string`){let t=a.string(n);t!=``&&e._history.push({id:t,item_type:r});continue}let o=n,s=S.field(o,`id`);if(s==null)continue;let c=a.string(s);if(c==``)continue;let l=S.field(o,`item_type`);(l==null||a.string(l)==``)&&(l=S.field(o,`itemType`));let u=l!=null&&a.string(l)!=``?a.string(l):r;e._history.push({id:c,item_type:u})}}static setOthers(t,n){let r=0,i=e._others;for(;r<i.length;){let e=i[r];if(++r,e.key==t){e.value=n;return}}e._others.push({key:t,value:n})}static setConsent(t){t>2&&(t=2),e._consent=t,t==2&&e.getDeviceId()==`no-consent`&&e.setDeviceId(w.v4())}static setChannel(t){e._channel=t}static setPageVisit(t){e._page_visit=t}static setEnvironment(t){e._environment=t}static setDeviceId(t){e._device_id=t}static setUserId(t){e._user_id=t}static setRequestDomain(t){e._req_domain=t}static setRecommendationsAccessToken(t){e._recommendations_access_token=e.normalizeAccessToken(t)}static clearRecommendationsAccessToken(){e._recommendations_access_token=null}static setRecommendationsAccessTokenProvider(t){e._recommendations_access_token_provider=t}static clearRecommendationsAccessTokenProvider(){e._recommendations_access_token_provider=null}static setSafeRequest(t){e._safe_request=t}static setContextItem(t){e.setOthers(`context_item`,t)}static setContextItemType(t){e.setOthers(`context_item_type`,t)}static getRequestDomain(){return e._req_domain}static getSafeRequest(){return e._safe_request}static getEnvironment(){return e._environment}static getPageVisit(){return e._page_visit}static getUserId(){return e._user_id}static getDeviceId(){return e._device_id}static getConsent(){return e._consent}static getChannel(){return e._channel}static getOthers(t){let n=0,r=e._others;for(;n<r.length;){let e=r[n];if(++n,t==e.key)return e.value}return null}static getContextItem(){return e.getOthers(`context_item`)}static getContextItemType(){return e.getOthers(`context_item_type`)}static get __name__(){return`internal.RecoBackendV2`}get __class__(){return e}};O._environment=null,O._device_id=`no-consent`,O._user_id=null,O._consent=0,O._req_domain=`europe-west1.froomle.com`,O._page_visit=null,O._channel=`www-desktop`,O._safe_request=!0,O._history=[],O._others=[],O._recommendations_access_token=null,O._recommendations_access_token_provider=null;let k=t.global(`$hxClasses`)[`internal._RecommendationsInternal`]=class e extends t.inherits(){[t.new](e,t,n,r,i){this.request_id=t,this.user_group=n,this.device_id=e,this.user_id=r,this._lists=i}items(){let e=[],t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i=0,a=r.items;for(;i<a.length;){let t=a[i];++i,e.push(t)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,n=this._lists;for(;t<n.length;){let r=n[t];if(++t,r.list_name==e)return r}return null}toJson(){let e={request_id:this.request_id,user_group:this.user_group,user_id:this.user_id,device_id:this.device_id,lists:[]},t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i={limit:r.limit,list_key:r.list_key,list_name:r.list_name,list_size:r.list_size,items:[]},a=0,s=r.items;for(;a<s.length;){let e=s[a];++a,i.items.push(o.__cast(e,j).getData())}e.lists.push(i)}return JSON.stringify(e)}static fromRequestData(t){let n=S.getProperty(t,`lists`),r=[],i=0;for(;i<n.length;){let e=n[i];++i;let a=S.getProperty(e,`items`),o=[],s=0;for(;s<a.length;){let e=a[s];++s,S.setProperty(e,`request_id`,S.getProperty(t,`request_id`)),S.setProperty(e,`user_group`,S.getProperty(t,`user_group`)),o.push(new j(e))}let c=new A({limit:S.getProperty(e,`limit`),list_key:S.getProperty(e,`list_key`),list_name:S.getProperty(e,`list_name`),list_size:S.getProperty(e,`list_size`),items:o,request_id:S.getProperty(t,`request_id`)});r.push(c)}return new e(S.getProperty(t,`device_id`),S.getProperty(t,`request_id`),S.getProperty(t,`user_group`),S.getProperty(t,`user_id`),r)}static get __name__(){return`internal._RecommendationsInternal`}static get __interfaces__(){return[T]}get __class__(){return e}};k.prototype.request_id=null,k.prototype.user_group=null,k.prototype.user_id=null,k.prototype.device_id=null,k.prototype._lists=null;let A=t.global(`$hxClasses`)[`internal._RecommendationsListInternal`]=class e extends t.inherits(){[t.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size,this.request_id=e.request_id}static get __name__(){return`internal._RecommendationsListInternal`}static get __interfaces__(){return[E]}get __class__(){return e}};A.prototype.limit=null,A.prototype.list_key=null,A.prototype.list_name=null,A.prototype.list_size=null,A.prototype.items=null,A.prototype.request_id=null;let j=t.global(`$hxClasses`)[`internal._RecommendationItemInternal`]=class e extends t.inherits(){[t.new](e){this.Id=S.getProperty(e,`item_id`),this.RequestId=S.getProperty(e,`request_id`),this.UserGroup=S.getProperty(e,`user_group`),this._data=e}getData(){return this._data}get(e){return this._data[e]}toJson(){return JSON.stringify(this._data)}static get __name__(){return`internal._RecommendationItemInternal`}static get __interfaces__(){return[D]}get __class__(){return e}};j.prototype.Id=null,j.prototype.RequestId=null,j.prototype.UserGroup=null,j.prototype._data=null,t.$global;let ee=function(){};ee.__isInterface__=!0,t.$global;let M=t.global(`$hxClasses`)[`internal.js.JSFroomleDomTree`]=class e extends t.inherits(){[t.new](){}getRoot(){return this.root}createElement(e){return this.root.ownerDocument.createElement(e)}toString(){return this.root.ownerDocument.documentElement.outerHTML}static fromHTML(t){let n=new DOMParser().parseFromString(t,`text/html`),r=new e;return r.root=n.documentElement,r}static fromDocument(t){let n=new e;return n.root=t.documentElement,n}static get __name__(){return`internal.js.JSFroomleDomTree`}static get __interfaces__(){return[ee]}get __class__(){return e}};M.prototype.root=null,t.$global;let N=t.global(`$hxClasses`).StringBuf=class e extends t.inherits(){[t.new](){this.b=``}static get __name__(){return`StringBuf`}get __class__(){return e}};N.prototype.b=null,t.$global;let P=t.global(`$hxClasses`)[`internal.domHandler.DomDomDom`]=class e extends t.inherits(){[t.new](){}static _fillRecoTargets(t){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;if(t==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let s=[],c=[],l=t.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c;f.push(t);let p=0;for(;p<f.length;){let e=f[p];++p;let t=0,n=[],r=0,i=e.attributes;for(;r<i.length;){let e=i[r];++r,n.push({name:e.name,value:e.value})}let a=n;for(;t<a.length;){let n=a[t];++t,n.name==`data-froomle-reco`&&s.push(e)}}let m=[],h=0;for(;h<s.length;){let e=s[h];++h;let t=e.getAttribute(`data-froomle-request-id`),n=e.getAttribute(`data-froomle-id`);!(t!=null&&t!=``)&&!(n!=null&&n!=``)&&m.push(e)}if(m.length<1){let e=null,t=null,n=new Promise(function(n,r){e=n,t=r}),r=n;return r._resolve=e,r._reject=t,r._isFinished=!1,r._result=null,r._error=null,n}let _=[],v=[],y=``,b=[],x=[],C=[],w=function(e,t){if(e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(S.compare),l.sort(S.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0},T=function(){let e={list_name:y,list_size:x.length,limit:x.length},t=0;for(;t<b.length;){let n=b[t];if(++t,n!=null&&n.key!=null&&n.key!=``){let t=n.value;t instanceof Array||(t=[t]),S.setProperty(e,n.key,t)}}let n=0;for(;n<C.length;){let t=C[n];++n,S.setProperty(e,t.key,t.value)}_.push(e),v.push(x)},E=function(e,t,n,r){y=e,b=t,x=[r],C=n},D=0;for(;D<m.length;){let e=m[D];++D;let t=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-reco-filter-`)){let n=g.substr(e.name,25,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},n=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-variable-`)){let n=g.substr(e.name,22,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},r=e.getAttribute(`data-froomle-reco`),i=t(e),a=n(e);if(y==``){E(r,i,a,e);continue}else if(r==y&&w(b,i)&&w(C,a)){x.push(e);continue}else{T(),E(r,i,a,e);continue}}y!=``&&T();let k;if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else try{k=O.getRawRecommendations(_)}catch{let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}return k.then(function(t){let n=t.lists(),r=n.length,i=0,a=r;for(;i<a;){let r=i++,a=n[r];a.items.length,v[r].length;let o=a.items.length,s=0,c=o;for(;s<c;){let n=s++,i=a.items[n],o=v[r][n];e._fillParameters(o,i,t.request_id)}}let s=o;s._isFinished||(s._result=!0,s._error=null,s._isFinished=!0,s._resolve(!0))}),o}static getAttrByPath(e,t,n){n==null&&(n=`fgh`);try{t=new y(`\\\\[(\\\\w+)\\\\]`,`g`).map(t,function(e){return`.`+e.matched(1)}),t=_.replace(t,`[`,`.`),t=_.replace(t,`]`,``),g.cca(t,0)==46&&(t=g.substr(t,1,null));let n=t.split(`.`),r=e.get(n[0]),i=1,o=n.length;for(;i<o;){let e=i++;if(r==null)return null;r=r instanceof Array&&a.parseInt(n[e])!=null?r[a.parseInt(n[e])]:S.field(r,n[e])}return r}catch{return n}}static stringifyValue(e,t){return t==null&&(t=``),e==null?t:a.string(e)}static isQuotedToken(e){if(e==null||e.length<2)return!1;let t=e.charAt(0),n=e.charAt(e.length-1);return t==`'`&&n==`'`?!0:t==`"`?n==`"`:!1}static unescapeQuotedValue(e){let t=e;return t=_.replace(t,`\\'`,`'`),t=_.replace(t,`\\"`,`"`),t=_.replace(t,`\\\\`,`\\`),t}static unquoteToken(t){let n=_.trim(t);if(!e.isQuotedToken(n))return n;let r=g.substr(n,1,n.length-2);return e.unescapeQuotedValue(r)}static splitTopLevel(e,t){if(t==null||t.length!=1)return[e];let n=t.charAt(0),r=[],i=new N,a=0,o=null,s=!1,c=0,l=e.length;for(;c<l;){let t=c++,l=e.charAt(t);if(s){i.b+=l==null?`null`:``+l,s=!1;continue}if(o!=null){if(l==`\\`){i.b+=l==null?`null`:``+l,s=!0;continue}l==o&&(o=null),i.b+=l==null?`null`:``+l;continue}if(l==`'`||l==`"`){o=l,i.b+=l==null?`null`:``+l;continue}if(l==`(`?++a:l==`)`&&a>0&&--a,a==0&&l==n){r.push(_.trim(i.b)),i=new N;continue}i.b+=l==null?`null`:``+l}return r.push(_.trim(i.b)),r}static parseTransformPart(t){let n=_.trim(t);if(n==``)return{name:``,args:[]};let r=n.indexOf(`(`);if(r==-1||!n.endsWith(`)`))return{name:n,args:[]};let i=_.trim(g.substr(n,0,r)),a=g.substr(n,r+1,n.length-r-2),o=[];if(_.trim(a)!=``){let t=0,n=e.splitTopLevel(a,`,`);for(;t<n.length;){let r=n[t];++t,o.push(e.unquoteToken(r))}}return{name:i,args:o}}static resolveSeedValue(t,n,r){let i=_.trim(t);return i==``?r:e.isQuotedToken(i)?e.unquoteToken(i):e.stringifyValue(e.getAttrByPath(n,i,r),r)}static resolveFieldPathValue(t,n){let r=_.trim(t);return r==``?``:e.stringifyValue(e.getAttrByPath(n,r,null),``)}static applyTransform(t,n,r,i){let a=t==null?``:t;switch(n==null?``:n.toLowerCase()){case`append`:return r.length>=1?a+r[0]:a;case`default`:return(a==null||a==``)&&r.length>=1?r[0]:a;case`defaultfield`:return(a==null||a==``)&&r.length>=1?e.resolveFieldPathValue(r[0],i):a;case`lower`:return a.toLowerCase();case`prepend`:return r.length>=1?r[0]+a:a;case`replace`:return r.length>=2?_.replace(a,r[0],r[1]):a;case`trim`:return _.trim(a);case`upper`:return a.toUpperCase();case`urlencode`:return encodeURIComponent(a);default:return a}}static evaluateExpression(t,n,r){let i=_.trim(t);if(i.startsWith(`=`)&&(i=_.trim(g.substr(i,1,null))),i==``)return r;let a=e.splitTopLevel(i,`|`);if(a.length==0)return r;let o=e.resolveSeedValue(a[0],n,r),s=1,c=a.length;for(;s<c;){let t=s++,r=e.parseTransformPart(a[t]);r.name!=``&&(o=e.applyTransform(o,r.name,r.args,n))}return o}static findTemplateExpressionEnd(e,t){let n=null,r=!1,i=0,a=t;for(;a<e.length;){let t=e.charAt(a);if(r){r=!1,++a;continue}if(n!=null){t==`\\`?r=!0:t==n&&(n=null),++a;continue}if(t==`'`||t==`"`){n=t,++a;continue}if(t==`$`&&a+1<e.length&&e.charAt(a+1)==`{`){++i,a+=2;continue}if(t==`}`){if(i==0)return a;--i}++a}return-1}static resolveTemplate(t,n,r){if(t.indexOf("${")==-1)return t;let i=``,o=0;for(;o<t.length;){let s=t.indexOf("${",o);if(s==-1){i+=a.string(g.substr(t,o,null));break}i+=a.string(g.substr(t,o,s-o));let c=e.findTemplateExpressionEnd(t,s+2);if(c==-1){i+=a.string(g.substr(t,s,null));break}let l=g.substr(t,s+2,c-s-2);i+=a.string(e.evaluateExpression(l,n,r)),o=c+1}return i}static resolveParamValue(t,n,r){r==null&&(r=``);let i=e.stringifyValue(r,``),a=t==null?``:t,o=_.trim(a);return o==``?i:a.indexOf("${")==-1?o.startsWith(`=`)?e.evaluateExpression(g.substr(o,1,null),n,i):e.stringifyValue(e.getAttrByPath(n,o,i),i):e.resolveTemplate(a,n,i)}static _buildHistories(e){let t=[],n=[],r=e.querySelectorAll(`[data-froomle-id]`),i=0,a=r.length;for(;i<a;){let e=i++,t=r.item(e);t instanceof HTMLElement&&n.push(t)}let o=n,s=0;for(;s<o.length;){let e=o[s];++s,t.push(e.getAttribute(`data-froomle-id`))}O.addHistories(t)}static fillParam(t,n,r,i,a){a==null&&(a=``);try{let o=e.resolveParamValue(r,i,a);n==`inner`?(t.textContent=o,t.textContent):t.setAttribute(n,o)}catch{}}static _fillParameters(t,n,r){t.setAttribute(`data-froomle-id`,n.get(`item_id`)),t.setAttribute(`data-froomle-request-id`,r);let i=n.get(`item_type`);i!=null&&a.string(i)!=``&&t.setAttribute(`data-froomle-item-type`,a.string(i)),n.UserGroup!=null&&n.UserGroup!=``&&t.setAttribute(`data-froomle-user-group`,n.UserGroup);let o=[],s=t.querySelectorAll(`*`),c=0,l=s.length;for(;c<l;){let e=c++,t=s.item(e);t instanceof HTMLElement&&o.push(t)}let u=o,d=0;for(;d<u.length;){let t=u[d];++d;let r=0,i=[],a=0,o=t.attributes;for(;a<o.length;){let e=o[a];++a,i.push({name:e.name,value:e.value})}let s=i;for(;r<s.length;){let i=s[r];if(++r,i.name.startsWith(`data-froomle-param-`)){let r=_.replace(i.name,`data-froomle-param-`,``),a=i.value;e.fillParam(t,r,a,n)}}}}static _orderElements(e){let t=function(t,n,r){let i=[],a=[],o=0,s=t.childNodes;for(;o<s.length;){let e=s[o];++o,a.push(e)}let c=a,l=0;for(;l<c.length;){let n=c[l];++l;try{if(n.getAttribute(`data-froomle-ordervalue`)!=null){i.push(n);let r=e.createElement(`span`);r.setAttribute(`data-froomle-tmp-node`,`tmp`),t.replaceChild(r,n)}}catch{}}let u=[],d=0;for(;d<i.length;){let e=i[d];++d,u.push(e.getAttribute(`data-froomle-ordervalue`))}return{el:t,key:n,values:u,orderChildren:i,list_name:r}},n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i,s=e.getRoot(),c=[],l=s.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c,p=[],m=0;for(;m<f.length;){let e=f[m];++m;let n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let r=o[n];++n,r.name.startsWith(`data-froomle-order-`)&&p.push(t(e,r.name.substring(19),r.value))}}if(p.length<1){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let h=[],g=0;for(;g<p.length;){let e=p[g];++g;let t={list_name:e.list_name,limit:e.values.length,list_size:e.values.length},n={};S.setProperty(n,e.key,e.values),S.setProperty(t,`order`,n),h.push(t)}if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}try{O.getRawRecommendations(h).then(function(e){let t=e.lists(),n=t.length,r=0,i=n;for(;r<i;){let n=r++,i=t[n],a=p[n];a.el.setAttribute(`data-froomle-request-id`,e.request_id);let o=[],s=0,c=i.items;for(;s<c.length;){let e=c[s];++s;let t=e.get(a.key);e.get(a.key);let n=a.values.length,r=0,i=n;for(;r<i;){let e=r++;if(t==a.values[e]){a.orderChildren.length;let t=a.orderChildren[e];o.push(t),a.orderChildren.splice(e,1),a.values.splice(e,1);break}}}o.length;let l=a.el,u=[],d=0,f=l.childNodes;for(;d<f.length;){let e=f[d];++d,u.push(e)}let m=u.length,h=0,g=m;for(;h<g;){let e=h++,t=a.el,n=[],r=0,i=t.childNodes;for(;r<i.length;){let e=i[r];++r,n.push(e)}let s=n[e],c=s,l;if(l=c instanceof HTMLElement?c.hasAttribute(`data-froomle-tmp-node`):!1,l&&(a.el.replaceChild(o[0],s),o.splice(0,1),o.length,o.length==0))break}}let a=o;a._isFinished||(a._result=!0,a._error=null,a._isFinished=!0,a._resolve(!0))})}catch{let e=o;e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1))}return o}static domInit(t){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;return e._orderElements(t).then(function(n){e._buildHistories(t.getRoot()),e._fillRecoTargets(t.getRoot()).then(function(e){let t=o;t._isFinished||(t._result=!0,t._error=null,t._isFinished=!0,t._resolve(!0))})}),o}static fillElementRecos(t){e._fillRecoTargets(t)}static runFromHtml(t){if(t==``)return``;let n;try{let e=new DOMParser().parseFromString(t,`text/html`),r=new M;r.root=e.documentElement,n=r}catch{return t}return e.domInit(n),n.toString()}static get __name__(){return`internal.domHandler.DomDomDom`}get __class__(){return e}};t.$global;let F=t.global(`$hxClasses`).FroomleSdk=class e{static register(){e.registered||e._env_set&&e._page_visit_set&&(e.registered=!0)}static buildScriptTag(){let e=`<script src="https://cdn.jsdelivr.net/npm/@froomle/frontend-sdk@0.0.30/dist/froomle.global.js" data-froomle-env="`+O.getEnvironment()+`" `,t=O.getPageVisit();t!=null&&(e+=`data-froomle-page-visit="`+t+`" `);let n=O.getContextItem();if(n!=null){e+=`data-froomle-context-item="`+n+`" `;let t=O.getContextItemType();(t==null||t==``)&&(t=`article`),e+=`data-froomle-context-item-type="`+t+`" `}let r=O.getDeviceId();r!=null&&(e+=`data-froomle-device-id="`+r+`" `);let i=O.getUserId();i!=null&&(e+=`data-froomle-user-id="`+i+`" `);let a=O.getConsent();a>0&&(e+=`data-froomle-consent="`+a+`" `);let o=O.getRequestDomain();o!=null&&(e+=`data-froomle-request-domain="`+o+`" `);let s=O.getChannel();return s!=null&&(e+=`data-froomle-channel="`+s+`" `),e+=`><\/script>`,e}static setEnvironment(t){O.setEnvironment(t),e._env_set=!0,e.register()}static setDeviceId(e){O.setDeviceId(e)}static setUserId(e){O.setUserId(e)}static setConsent(e){O.setConsent(e)}static setPageVisit(t){O.setPageVisit(t),e._page_visit_set=!0,e.register()}static setChannel(e){O.setChannel(e)}static setRequestDomain(e){O.setRequestDomain(e)}static setRecommendationsAccessToken(e){O.setRecommendationsAccessToken(e)}static clearRecommendationsAccessToken(){O.clearRecommendationsAccessToken()}static setRecommendationsAccessTokenProvider(e){O.setRecommendationsAccessTokenProvider(e)}static clearRecommendationsAccessTokenProvider(){O.clearRecommendationsAccessTokenProvider()}static setSafeRequest(e){O.setSafeRequest(e)}static setContextItem(e){O.setContextItem(e)}static setContextItemType(e){O.setContextItemType(e)}static setCustomVariable(e,t){O.setOthers(e,t)}static getUserId(){return O.getUserId()}static getDeviceId(){return O.getDeviceId()}static getEnvironment(){return O.getEnvironment()}static getSafeRequest(){return O.getSafeRequest()}static getPageVisit(){return O.getPageVisit()}static getConsent(){return O.getConsent()}static getRecommendations(e){return O.getRawRecommendations(e)}static getChannel(){return O.getChannel()}static getVersion(){return`0.0.30`}static runFromHtml(e){return P.runFromHtml(e)}static get __name__(){return`FroomleSdk`}get __class__(){return e}};F._env_set=!1,F._page_visit_set=!1,F.registered=!1;function te(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}function ne(){return`frontend-sdk/${F.getVersion()}`}function re(){return{"Content-Type":`application/json`,Accept:`application/json`,"X-Froomle-Client":ne()}}function ie(e){return JSON.stringify({events:e})}async function I(e,t={}){let n=ie(e),r=te(),{keepalive:i=!1,allowBeaconFallback:a=!1}=t;try{return await fetch(r,{method:`POST`,headers:re(),body:n,...i?{keepalive:!0}:{}}),`fetch`}catch(e){if(a&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(r,e))return`beacon`}throw e}}function ae(){if(O.getConsent()<2)return;let e=O.getUserId();if(e)return e}function oe(){let e=O.getContextItem();if(e)return e}function se(){let e=O.getContextItemType();if(e)return e}function L(){return O.getConsent()>=1}function ce(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}function le(){let e=O.getChannel();if(e)return e}function ue(e){var t;let n=e==null?void 0:e.getAttribute(`data-froomle-user-group`);if(n)return n;if(!(typeof document>`u`))return((t=document.querySelector(`[data-froomle-user-group]`))==null?void 0:t.getAttribute(`data-froomle-user-group`))||void 0}function de(e){let t={event_type:e,page_type:O.getPageVisit(),channel:le()||`www-desktop`,device_id:ce()},n=ue();n&&(t.user_group=n);let r=ae();return r&&(t.user_id=r),t}function fe(e,t){if(!t)return e;for(let n in t)e[n]=t[n];return e}function R(e){L()&&I([e]).catch(()=>{})}function z(e,t,n,r){let i=t||oe();if(!i)return null;let a=de(e);return a.action_item=i,a.action_item_type=n||se()||`article`,fe(a,r)}function pe(e,t,n=`impression`,r){let i=z(n,e,t,r);i&&R(i)}function me(e,t,n,r){let i=z(`item_interaction`,n?e:void 0,n&&typeof t==`string`?t:void 0,{interaction_type:n||e,...n?r:t});i&&R(i)}function he(e,t){let n=de(`user_interaction`);n.interaction_type=e,R(fe(n,t))}function ge(e,t,n,r){let i=z(`add_to_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function _e(e,t,n,r){let i=z(`remove_from_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function ve(e,t,n,r,i){let a=typeof e==`string`,o=z(`purchase`,a?e:void 0,a&&typeof t==`string`?t:void 0,{amount:a?n:e,purchased_price:a?r:t,...a?i:n});o&&R(o)}function ye(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-id`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item`));if(t)return t}function be(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-item-type`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item-type`));if(t)return t}var B=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateEvents(){let t=[];for(let n of e.impressionQueue){let e=ye(n);if(!e)continue;let r=be(n)||`article`,i=le()||`www-desktop`,a={event_type:`impression`,page_type:O.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ce()},o=ue(n);o&&(a.user_group=o),O.getConsent()>=2&&O.getUserId()&&(a.user_id=O.getUserId());let s=n.getAttribute(`data-froomle-reco`),c=n.getAttribute(`data-froomle-request-id`);s&&c&&(a.list_name=s,a.request_id=c),t.push(a)}return e.impressionQueue=[],t}static sendImpressions(){if(console.log(e.impressionQueue),e.impressionQueue.length===0||!L())return;let t=e.generateEvents();t.length!==0&&I(t).catch(()=>{})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(t){let n=t.getBoundingClientRect(),r=e.getViewPortRect();return n.right>r.left&&n.left<r.right&&n.bottom>r.top&&n.top<r.bottom}static addIntersectionImpressionListener(t){e.observer.observe(t)}static processDocument(){if(L()){console.log(`🚀 Processing document for impressions`);for(let t of document.querySelectorAll(`[data-froomle-id]`))e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}static processElement(t){if(!L()||!(t instanceof Element))return;let n=[];t.matches(`[data-froomle-id]`)&&n.push(t);for(let e of t.querySelectorAll(`[data-froomle-id]`))n.push(e);if(n.length!==0){for(let t of n)e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}};B.impressionQueue=[],B.observer=null,typeof document<`u`&&(B.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(B.impressionQueue.push(e.target),B.observer.unobserve(e.target))}),B.impressionQueue.length>0&&B.sendImpressions()}));var xe=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readChannel()||`www-desktop`,n={event_type:`page_visit`,page_type:O.getPageVisit(),channel:t,device_id:e.readDeviceId()},r=e.readUserGroup();return r&&(n.user_group=r),O.getConsent()>=2&&O.getUserId()&&(n.user_id=O.getUserId()),n}static sendPageVisit(){O.getPageVisit()&&(O.getContextItem()||e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{}))}},Se=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItemType(){let e=O.getContextItemType();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readActionItemType()||`article`,n=e.readChannel()||`www-desktop`,r={event_type:`detail_pageview`,page_type:O.getPageVisit(),action_item:O.getContextItem(),action_item_type:t,channel:n,device_id:e.readDeviceId()},i=e.readUserGroup();return i&&(r.user_group=i),O.getConsent()>=2&&O.getUserId()&&(r.user_id=O.getUserId()),r}static sendPageView(){O.getContextItem()&&O.getPageVisit()&&e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{})}},Ce=class e{static readAttributeFromChain(e,t){let n=e;for(;n;){for(let e of t){let t=n.getAttribute(e);if(t)return t}n=n.parentElement}}static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItem(t){return e.readAttributeFromChain(t,[`data-froomle-id`,`data-froomle-action-item`])}static readActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-item-type`,`data-froomle-action-item-type`])}static readExplicitActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-action-item-type`])}static readUserGroup(t){var n;let r=e.readAttributeFromChain(t,[`data-froomle-user-group`]);if(r)return r;if(!(typeof document>`u`))return((n=document.querySelector(`[data-froomle-user-group]`))==null?void 0:n.getAttribute(`data-froomle-user-group`))||void 0}static registerClickables(){e.listenerRegistered||(e.listenerRegistered=!0,document.addEventListener(`click`,t=>{if(!e.canTrackEvents())return;let n=t instanceof MouseEvent?t:null,r=t.target,i=r instanceof Element?r:r instanceof Node?r.parentElement:null;if(!i)return;let a=i.closest(`a`);if(!a)return;let o=a.closest(`[data-froomle-id]`);if(!o)return;let s=a.closest(`[data-froomle-reco]`),c=(s?e.readActionItem(s):void 0)||e.readActionItem(o);if(!c)return;let l=e.readExplicitActionItemType(a)||(s?e.readActionItemType(s):void 0)||e.readActionItemType(o)||`article`,u=e.readChannel()||`www-desktop`,d=a instanceof HTMLAnchorElement?a.href:null,f=a.getAttribute(`href`),p=typeof f==`string`&&f.trim().startsWith(`#`),m=!!d&&!p&&t.cancelable&&!t.defaultPrevented&&!a.hasAttribute(`download`)&&(!a.target||a.target===`_self`)&&!!n&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey,h=p&&t.cancelable&&!t.defaultPrevented;(m||h)&&t.preventDefault();let g={event_type:`click_on_recommendation`,page_type:O.getPageVisit(),action_item:c,action_item_type:l,channel:u,device_id:e.readDeviceId()},_=(s?e.readUserGroup(s):void 0)||e.readUserGroup(o);_&&(g.user_group=_);let v=(s?e.readAttributeFromChain(s,[`data-froomle-reco`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-reco`]),y=(s?e.readAttributeFromChain(s,[`data-froomle-request-id`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-request-id`]);if(v&&y&&(g.list_name=v,g.request_id=y),O.getConsent()>=2&&O.getUserId()&&(g.user_id=O.getUserId()),m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);I([g],{keepalive:!0,allowBeaconFallback:!0}).catch(()=>{}).finally(()=>{window.clearTimeout(n),t()});return}I([g],{allowBeaconFallback:!0}).catch(()=>{})},!0))}};Ce.listenerRegistered=!1;let we=M,V=F.setEnvironment,H=F.setPageVisit,U=F.setRequestDomain,W=F.setSafeRequest,G=typeof F.setChannel==`function`?F.setChannel:O.setChannel,Te=F.setRecommendationsAccessToken,Ee=F.clearRecommendationsAccessToken,De=F.setRecommendationsAccessTokenProvider,Oe=F.clearRecommendationsAccessTokenProvider,K=F.setContextItem,q=F.setContextItemType,ke=O.addHistories;function Ae(e,t){F.setCustomVariable(e,t)}function je(e){Te(e==null?null:e)}function Me(){Ee()}function Ne(e){De(e)}function Pe(){Oe()}function J(e){F.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Y(e){F.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function X(e){F.setConsent(e),document.cookie=`froomle_consent=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`,document.cookie=`froomle_device_id=${F.getDeviceId()}; max-age=${3600*24*365*20}; path=/; samesite=lax`}typeof window<`u`&&(window.setFroomleConsent=X);function Z(e){let t=document.cookie.split(`; `);for(let n of t){let[t,r]=n.split(`=`);if(t===e)return decodeURIComponent(r)}return null}function Fe(e){return F.getRecommendations(e)}let Q=globalThis,Ie=`FroomleFrontendSdkState`,Le=`FroomleFrontendSdkReady`;function Re(){let e=()=>{},t=()=>{},n=new Promise((n,r)=>{e=n,t=r}),r={initStarted:!1,initialized:!1,beforeInitEventDispatched:!1,initEventDispatched:!1,readyPromise:n,resolveReady:e,rejectReady:t};return Q[Ie]=r,Q[Le]=n,r}function $(){if(!Q[Ie])return Re();let e=Q[Ie];return Q[Le]||(Q[Le]=e.readyPromise),e}function ze(){return Q.FroomleFrontendSdk?Q.FroomleFrontendSdk:{RecommendationItem:D,RecommendationList:E,Recommendations:T,setPageVisit:H,setEnvironment:V,setConsent:X,setUserId:J,setDeviceId:Y,setRequestDomain:U,setSafeRequest:W,setChannel:G,setRecommendationsBearer:je,clearRecommendationsBearer:Me,setRecommendationsBearerProvider:Ne,clearRecommendationsBearerProvider:Pe,setContextItem:K,setContextItemType:q,setCustomVariable:Ae,getRecommendations:Fe,sendEvent:pe,sendItemInteraction:me,sendUserInteraction:he,sendAddToCart:ge,sendRemoveFromCart:_e,sendPurchase:ve,addHistories:ke,init:qe}}function Be(e){return{sdk:ze(),mode:e,version:typeof F.getVersion==`function`?F.getVersion():void 0}}function Ve(e,t){if(typeof window>`u`)return;if(typeof window.CustomEvent==`function`){window.dispatchEvent(new window.CustomEvent(e,{detail:t}));return}let n=document.createEvent(`CustomEvent`);n.initCustomEvent(e,!1,!1,t),window.dispatchEvent(n)}function He(e){let t=$();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,Ve(`froomle:before-init`,Be(e)))}function Ue(e){let t=$();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,Ve(`froomle:init`,Be(e)))}function We(e){let t=$();t.initialized||(t.initialized=!0,t.resolveReady(ze())),Ue(e)}function Ge(e){$().rejectReady(e)}function Ke(e=`auto`){if(typeof document>`u`)return Promise.resolve(ze());let t=$();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{He(e),console.log(`froomle loads dom`),P.domInit(we.fromDocument(document)).then(()=>{Ce.registerClickables(),B.processDocument(),xe.sendPageVisit(),Se.sendPageView(),We(e)}).catch(e=>{Ge(e)});function t(e){return e.matches(`[data-froomle-reco]`)||e.querySelector(`[data-froomle-reco]`)!==null}new MutationObserver(e=>{for(let n of e)if(n.type===`childList`&&n.addedNodes.forEach(e=>{e instanceof Element&&(t(e)&&P.fillElementRecos(e),B.processElement(e))}),n.type===`attributes`&&n.target instanceof Element)if(n.attributeName===`data-froomle-reco`){let e=n.target.getAttribute(`data-froomle-request-id`);(!e||e===``)&&P.fillElementRecos(n.target)}else if(n.attributeName===`data-froomle-request-id`){let e=n.target.getAttribute(`data-froomle-request-id`),t=n.target.getAttribute(`data-froomle-id`);n.target.getAttribute(`data-froomle-reco`)&&(!e||e===``)&&(!t||t===``)&&P.fillElementRecos(n.target)}else n.attributeName===`data-froomle-id`&&B.processElement(n.target)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-froomle-reco`,`data-froomle-request-id`,`data-froomle-id`]})},r=()=>{globalThis.setTimeout(n,0)};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r,{once:!0}):r(),t.readyPromise}function qe(){return Ke(`manual`)}if(!globalThis.froomleInitialized&&(globalThis.froomleInitialized=!0,typeof document<`u`)){$();let e=document.currentScript;if(e){let t=e.getAttribute(`data-froomle-device-id`),n=e.getAttribute(`data-froomle-user-id`),r=e.getAttribute(`data-froomle-env`),i=e.getAttribute(`data-froomle-page-visit`),a=e.getAttribute(`data-froomle-request-domain`),o=e.getAttribute(`data-froomle-context-item`),s=e.getAttribute(`data-froomle-context-item-type`),c=e.getAttribute(`data-froomle-safe-request`),l=e.getAttribute(`data-froomle-channel`);if(V(r),i&&H(i),o&&(K(o),q(s||`article`)),t)Y(t);else{let e=Z(`froomle_device_id`);e&&Y(e)}if(n)J(n);else{let e=Z(`froomle_user_id`);e&&J(e)}a&&U(a),c&&W(c!==`false`),l&&G(l)}let t=Z(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||X(e)}Ke(`auto`)}return e.FroomleDomTree=we,e.RecoBackendV2=O,e.RecommendationItem=D,e.RecommendationList=E,e.Recommendations=T,e._RecommendationItemInternal=j,e.addHistories=ke,e.clearRecommendationsBearer=Me,e.clearRecommendationsBearerProvider=Pe,e.getRecommendations=Fe,e.init=qe,e.sendAddToCart=ge,e.sendEvent=pe,e.sendItemInteraction=me,e.sendPurchase=ve,e.sendRemoveFromCart=_e,e.sendUserInteraction=he,e.setChannel=G,e.setConsent=X,e.setContextItem=K,e.setContextItemType=q,e.setCustomVariable=Ae,e.setDeviceId=Y,e.setEnvironment=V,e.setPageVisit=H,e.setRecommendationsBearer=je,e.setRecommendationsBearerProvider=Ne,e.setRequestDomain=U,e.setSafeRequest=W,e.setUserId=J,e})({});
|
|
5
|
+
`),t=[],i=0,a=e;for(;i<a.length;){let e=a[i];++i,e!=``&&t.push(e)}e=t,r.responseHeaders=new h;let o=0;for(;o<e.length;){let t=e[o];++o;let n=t.split(`: `),i=n.shift(),a=n.length==1?n[0]:n.join(`: `);a=_.ltrim(_.rtrim(a)),r.responseHeaders.inst.set(i,a)}r.success(u.ofData(n.response))}else if(i==null||i==0&&n.response==null)r.req=null,r.onError(`Failed to connect or resolve host`);else if(i==null)r.req=null,r.responseBytes=n.response==null?null:u.ofData(n.response),r.onError(`Http Error #`+n.status);else switch(i){case 12007:r.req=null,r.onError(`Unknown host`);break;case 12029:r.req=null,r.onError(`Failed to connect to host`);break;default:r.req=null,r.responseBytes=n.response==null?null:u.ofData(n.response),r.onError(`Http Error #`+n.status)}};this.async&&(n.onreadystatechange=o);let c,l=this.postData,d=this.postBytes;if(l==null)if(d==null)c=null;else{let e=d;c=new Blob([e.b.bufferValue])}else c=d==null?l:null;if(c!=null)e=!0;else{let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,c=c==null?``:(c==null?`null`:a.string(c))+`&`;let r=n.name,i=(c==null?`null`:a.string(c))+encodeURIComponent(r)+`=`,o=n.value;c=i+encodeURIComponent(o)}}try{if(e)n.open(`POST`,this.url,this.async);else if(c!=null){let e=this.url.split(`?`).length<=1;n.open(`GET`,this.url+(e?`?`:`&`)+(c==null?`null`:a.string(c)),this.async),c=null}else n.open(`GET`,this.url,this.async);n.responseType=`arraybuffer`}catch(e){let t=i.caught(e).unwrap();this.req=null,this.onError(t.toString());return}n.withCredentials=this.withCredentials,!v.exists(this.headers,function(e){return e.name==`Content-Type`})&&e&&this.postData==null&&n.setRequestHeader(`Content-Type`,`application/x-www-form-urlencoded`);let f=0,p=this.headers;for(;f<p.length;){let e=p[f];++f,n.setRequestHeader(e.name,e.value)}n.send(c),this.async||o(null)}static get __name__(){return`haxe.http.HttpJs`}static get __super__(){return d}get __class__(){return e}};b.prototype.async=null,b.prototype.withCredentials=null,b.prototype.responseHeaders=null,b.prototype.req=null,t.$global;let x=t.global(`$hxClasses`).Type=class e{static createInstance(e,t){return new(Function.prototype.bind.apply(e,[null].concat(t)))}static get __name__(){return`Type`}get __class__(){return e}};t.$global;let S=t.global(`$hxClasses`).Reflect=class e{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let n;if(e==null)return null;{let r;return e.__properties__?(n=e.__properties__[`get_`+t],r=n):r=!1,r?e[n]():e[t]}}static setProperty(e,t,n){let r,i;e.__properties__?(r=e.__properties__[`set_`+t],i=r):i=!1,i?e[r](n):e[t]=n}static fields(e){let t=[];if(e!=null){let r=Object.prototype.hasOwnProperty;for(var n in e)n!=`__id__`&&n!=`hx__closures__`&&r.call(e,n)&&t.push(n)}return t}static compare(e,t){return e==t?0:e>t?1:-1}static get __name__(){return`Reflect`}get __class__(){return e}};t.$global;let ee=t.global(`$hxClasses`)[`internal.http.FetchHttp`]=class e extends t.inherits(b){[t.new](e){this.responseStatus=0,super[t.new](e)}request(e){let n=t.$global,r=n.fetch,o=n.Headers,s=n.URLSearchParams;if(r==null){this.onError(`Fetch API not found.`);return}let c=x.createInstance(o,[]),l=0,u=this.headers;for(;l<u.length;){let e=u[l];++l,c.append(e.name,e.value)}let d=e?`POST`:`GET`,f=null;if(e)if(this.postData!=null)f=this.postData;else{f=x.createInstance(s,[]);let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,f.append(n.name,n.value)}}let p={method:d,headers:c,body:f},m=this,h=r(this.url,p).then(function(e){if(m.responseStatus=e.status,m.onStatus(e.status),e.ok)return e.text();throw i.thrown(`HTTP Error: `+a.string(e.status))}).then(function(e){m.onData(e)}),g=S.field(h,`catch`);g!=null&&g.apply(h,[function(e){m.onError(a.string(e))}])}static get __name__(){return`internal.http.FetchHttp`}static get __super__(){return b}get __class__(){return e}};ee.prototype.responseStatus=null,t.$global;let C=t.global(`$hxClasses`)[`internal.data.UUID`]=class e{static randomHexChar(){return`0123456789abcdef`.charAt(a.random(16))}static v4(){let e=``,t=0;for(;t<36;)switch(t++){case 14:e+=`4`;break;case 19:e+=a.string(`0123456789abcdef`.charAt(8+a.random(4)));break;case 8:case 13:case 18:case 23:e+=`-`;break;default:e+=a.string(`0123456789abcdef`.charAt(a.random(16)))}return e}static get __name__(){return`internal.data.UUID`}get __class__(){return e}};C.HEX=`0123456789abcdef`,t.$global;let w=t.global(`$hxClasses`)[`internal.RecoRequestGrouping`]=class e{static normalizeFilters(e){let t=[];if(e==null)return t;let n=0;for(;n<e.length;){let r=e[n];++n,!(r==null||r.key==null||r.key==``)&&t.push({key:r.key,value:r.value})}return t}static tuplesSame(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(S.compare),l.sort(S.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0}static groupSequential(t){let n=[],r=null,i=0;for(;i<t.length;){let a=t[i];if(++i,r==null){r={list_name:a.list_name,filters:a.filters,others:a.others,entries:[a.entry]};continue}if(r.list_name==a.list_name&&e.tuplesSame(r.filters,a.filters)&&e.tuplesSame(r.others,a.others)){r.entries.push(a.entry);continue}n.push(r),r={list_name:a.list_name,filters:a.filters,others:a.others,entries:[a.entry]}}return r!=null&&n.push(r),n}static toRequestLists(e){let t=[],n=0;for(;n<e.length;){let r=e[n];++n;let i={limit:r.entries.length,list_name:r.list_name,list_size:r.entries.length},a=0,o=r.filters;for(;a<o.length;){let e=o[a];++a;let t=e.value;t instanceof Array||(t=[t]),i[e.key]=t}let s=0,c=r.others;for(;s<c.length;){let e=c[s];++s,i[e.key]=e.value}t.push(i)}return t}static get __name__(){return`internal.RecoRequestGrouping`}get __class__(){return e}};t.$global;let T=function(){};T.__isInterface__=!0;let E=function(){};E.__isInterface__=!0;let D=function(){};D.__isInterface__=!0,t.$global;let O=t.global(`$hxClasses`)[`internal.RecommendationBackend`]=class e extends t.inherits(){[t.new](){}static _requestUri(){return(e._safe_request?`https://`:`http://`)+e._req_domain+`/api/`+e._environment+`/recommendations/requests`}static noConsentBody(){return{device_id:`no-consent`,user_group:`no-consent`,version:`no-consent`}}static buildRequestBody(t){let n={lists:t,page_type:e._page_visit,channel:e._channel};if(e._consent>=2&&e._history.length>0&&(n.histories=e._buildHistories()),e._consent<2){let t=e.noConsentBody(),r=0,i=S.fields(t);for(;r<i.length;){let e=i[r];++r,n[e]=S.field(t,e)}}else e._user_id!=null&&(n.user_id=e._user_id),n.device_id=e._device_id;let r=0,i=e._others;for(;r<i.length;){let e=i[r];++r,n[e.key]=e.value}let o=S.field(n,`context_item`),s=S.field(n,`context_item_type`);return o!=null&&a.string(o)!=``&&(s==null||a.string(s)==``)&&(n.context_item_type=`article`),n}static _buildHistories(){return{pageviews:e._history}}static normalizeAccessToken(e){if(e==null)return null;let t=a.string(e);return t==``?null:t}static hasRecommendationsAccessTokenProvider(){return e._recommendations_access_token_provider!=null}static resolveRecommendationsAccessToken(t){if(!t){let t=e.normalizeAccessToken(e._recommendations_access_token);if(t!=null)return Promise.resolve(t)}if(!e.hasRecommendationsAccessTokenProvider())return Promise.resolve(e.normalizeAccessToken(e._recommendations_access_token));let n=null;try{n=e._recommendations_access_token_provider.apply(null,[{forceRefresh:t}])}catch(e){let t=i.caught(e).unwrap();return Promise.reject(t)}return Promise.resolve(n).then(function(t){let n=e.normalizeAccessToken(t);return e._recommendations_access_token=n,n})}static requestsToLists(e){let t=Array(e.length),n=0,r=e.length;for(;n<r;){let r=n++,i=e[r];t[r]={list_name:i.list,filters:w.normalizeFilters(i.filters),others:i.others==null?[]:i.others,entry:i}}let i=t;return w.toRequestLists(w.groupSequential(i))}static _requestRecos(t){let n=null,r=null,o=new Promise(function(e,t){n=e,r=t}),s=o;s._resolve=n,s._reject=r,s._isFinished=!1,s._result=null,s._error=null;let c=o,l=!1,u=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))},d=null;return d=function(n,r){if(l)return;let o=!1,s=!1,f=new ee(e._requestUri());f.setHeader(`Content-Type`,`application/json`),f.setHeader(`X-Froomle-Client`,`frontend-sdk/0.1.0`);let p=e.normalizeAccessToken(n);p!=null&&f.setHeader(`Authorization`,`Bearer `+p);let m=e.buildRequestBody(t),h=JSON.stringify(m);f.setPostData(h),f.onError=function(e){o||s||l||(o=!0,u(`HTTP Request Error: `+e))},f.onStatus=function(t){if(!(o||l)){if(t==401&&r&&e.hasRecommendationsAccessTokenProvider()){o=!0,s=!0,e.resolveRecommendationsAccessToken(!0).then(function(e){return l?null:e==null?(u(`Recommendation access token provider returned no token during refresh.`),null):(d(e,!1),null)},function(e){return u(`Failed to refresh recommendation access token: `+a.string(e)),null});return}(t<200||t>=300)&&(o=!0,u(`HTTP Status Error: `+t))}};try{f.request(!0)}catch(e){let t=i.caught(e).unwrap();if(o||l)return;o=!0,u(`Failed to execute recommendation request: `+a.string(t));return}let g=function(e){if(!(o||s||l))try{let t=JSON.parse(e),n=k.fromRequestData(t);o=!0,l=!0;let r=c;r._isFinished||(r._result=n,r._error=null,r._isFinished=!0,r._resolve(n))}catch(e){let t=i.caught(e).unwrap();o=!0,u(`Failed to parse recommendation response: `+a.string(t))}},_=f.get_responseData();_==null?!o&&!s&&!l&&(f.onData=g):g(_)},e.resolveRecommendationsAccessToken(!1).then(function(t){return l?null:e.hasRecommendationsAccessTokenProvider()&&t==null?(u(`Recommendation access token provider returned no token.`),null):(d(t,e.hasRecommendationsAccessTokenProvider()),null)},function(e){return u(`Failed to resolve recommendation access token: `+a.string(e)),null}),c}static getOrder(t,n,r){let o={list_name:t,limit:r.length,list_size:r.length},s={};S.setProperty(s,n,r),S.setProperty(o,`order`,s);let c=null,l=null,u=new Promise(function(e,t){c=e,l=t}),d=u;d._resolve=c,d._reject=l,d._isFinished=!1,d._result=null,d._error=null;let f=u;return e.getRawRecommendations([o]).then(function(e){try{let t=[],n=e.lists();if(n!=null&&n.length>0){let e=n[0].items;if(e instanceof Array){let n=0,r=e;for(;n<r.length;){let e=r[n];++n;let i=e.get(`categories`);i!=null&&t.push(i)}}}let r=f;r._isFinished||(r._result=t,r._error=null,r._isFinished=!0,r._resolve(t))}catch(e){let t=i.caught(e).unwrap(),n=`Failed to build order response: `+a.string(t),r=f;r._isFinished||(r._error=n,r._isFinished=!0,r._reject(n))}},function(e){let t=f;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))}),f}static getRawRecommendations(t){return e._requestRecos(t)}static addHistories(t,n){if(n==null&&(n=`article`),t==null||t.length==0)return;let r=n!=null&&n!=``?n:`article`,i=0;for(;i<t.length;){let n=t[i];if(++i,typeof n==`string`){let t=a.string(n);t!=``&&e._history.push({id:t,item_type:r});continue}let o=n,s=S.field(o,`id`);if(s==null)continue;let c=a.string(s);if(c==``)continue;let l=S.field(o,`item_type`);(l==null||a.string(l)==``)&&(l=S.field(o,`itemType`));let u=l!=null&&a.string(l)!=``?a.string(l):r;e._history.push({id:c,item_type:u})}}static setOthers(t,n){let r=0,i=e._others;for(;r<i.length;){let e=i[r];if(++r,e.key==t){e.value=n;return}}e._others.push({key:t,value:n})}static setConsent(t){t>2&&(t=2),e._consent=t,t==2&&e.getDeviceId()==`no-consent`&&e.setDeviceId(C.v4())}static setChannel(t){e._channel=t}static setPageVisit(t){e._page_visit=t}static setEnvironment(t){e._environment=t}static setDeviceId(t){e._device_id=t}static setUserId(t){e._user_id=t}static setRequestDomain(t){e._req_domain=t}static setRecommendationsAccessToken(t){e._recommendations_access_token=e.normalizeAccessToken(t)}static clearRecommendationsAccessToken(){e._recommendations_access_token=null}static setRecommendationsAccessTokenProvider(t){e._recommendations_access_token_provider=t}static clearRecommendationsAccessTokenProvider(){e._recommendations_access_token_provider=null}static setSafeRequest(t){e._safe_request=t}static setContextItem(t){e.setOthers(`context_item`,t)}static setContextItemType(t){e.setOthers(`context_item_type`,t)}static getRequestDomain(){return e._req_domain}static getSafeRequest(){return e._safe_request}static getEnvironment(){return e._environment}static getPageVisit(){return e._page_visit}static getUserId(){return e._user_id}static getDeviceId(){return e._device_id}static getConsent(){return e._consent}static getChannel(){return e._channel}static getOthers(t){let n=0,r=e._others;for(;n<r.length;){let e=r[n];if(++n,t==e.key)return e.value}return null}static getContextItem(){return e.getOthers(`context_item`)}static getContextItemType(){return e.getOthers(`context_item_type`)}static get __name__(){return`internal.RecommendationBackend`}get __class__(){return e}};O._environment=null,O._device_id=`no-consent`,O._user_id=null,O._consent=0,O._req_domain=`europe-west1.froomle.com`,O._page_visit=null,O._channel=`www-desktop`,O._safe_request=!0,O._history=[],O._others=[],O._recommendations_access_token=null,O._recommendations_access_token_provider=null;let k=t.global(`$hxClasses`)[`internal._RecommendationsInternal`]=class e extends t.inherits(){[t.new](e,t,n,r,i){this.request_id=t,this.user_group=n,this.device_id=e,this.user_id=r,this._lists=i}items(){let e=[],t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i=0,a=r.items;for(;i<a.length;){let t=a[i];++i,e.push(t)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,n=this._lists;for(;t<n.length;){let r=n[t];if(++t,r.list_name==e)return r}return null}toJson(){let e={request_id:this.request_id,user_group:this.user_group,user_id:this.user_id,device_id:this.device_id,lists:[]},t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i={limit:r.limit,list_key:r.list_key,list_name:r.list_name,list_size:r.list_size,items:[]},a=0,s=r.items;for(;a<s.length;){let e=s[a];++a,i.items.push(o.__cast(e,j).getData())}e.lists.push(i)}return JSON.stringify(e)}static fromRequestData(t){let n=S.getProperty(t,`lists`),r=[],i=0;for(;i<n.length;){let e=n[i];++i;let a=S.getProperty(e,`items`),o=[],s=0;for(;s<a.length;){let e=a[s];++s,S.setProperty(e,`request_id`,S.getProperty(t,`request_id`)),S.setProperty(e,`user_group`,S.getProperty(t,`user_group`)),o.push(new j(e))}let c=new A({limit:S.getProperty(e,`limit`),list_key:S.getProperty(e,`list_key`),list_name:S.getProperty(e,`list_name`),list_size:S.getProperty(e,`list_size`),items:o,request_id:S.getProperty(t,`request_id`)});r.push(c)}return new e(S.getProperty(t,`device_id`),S.getProperty(t,`request_id`),S.getProperty(t,`user_group`),S.getProperty(t,`user_id`),r)}static get __name__(){return`internal._RecommendationsInternal`}static get __interfaces__(){return[T]}get __class__(){return e}};k.prototype.request_id=null,k.prototype.user_group=null,k.prototype.user_id=null,k.prototype.device_id=null,k.prototype._lists=null;let A=t.global(`$hxClasses`)[`internal._RecommendationsListInternal`]=class e extends t.inherits(){[t.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size,this.request_id=e.request_id}static get __name__(){return`internal._RecommendationsListInternal`}static get __interfaces__(){return[E]}get __class__(){return e}};A.prototype.limit=null,A.prototype.list_key=null,A.prototype.list_name=null,A.prototype.list_size=null,A.prototype.items=null,A.prototype.request_id=null;let j=t.global(`$hxClasses`)[`internal._RecommendationItemInternal`]=class e extends t.inherits(){[t.new](e){this.Id=S.getProperty(e,`item_id`),this.Rank=S.getProperty(e,`rank`),this.RequestId=S.getProperty(e,`request_id`),this.UserGroup=S.getProperty(e,`user_group`),this._data=e}getData(){return this._data}get(e){return this._data[e]}toJson(){return JSON.stringify(this._data)}static get __name__(){return`internal._RecommendationItemInternal`}static get __interfaces__(){return[D]}get __class__(){return e}};j.prototype.Id=null,j.prototype.Rank=null,j.prototype.RequestId=null,j.prototype.UserGroup=null,j.prototype._data=null,t.$global;let te=function(){};te.__isInterface__=!0,t.$global;let M=t.global(`$hxClasses`)[`internal.js.JSFroomleDomTree`]=class e extends t.inherits(){[t.new](){}getRoot(){return this.root}createElement(e){return this.root.ownerDocument.createElement(e)}toString(){return this.root.ownerDocument.documentElement.outerHTML}static fromHTML(t){let n=new DOMParser().parseFromString(t,`text/html`),r=new e;return r.root=n.documentElement,r}static fromDocument(t){let n=new e;return n.root=t.documentElement,n}static get __name__(){return`internal.js.JSFroomleDomTree`}static get __interfaces__(){return[te]}get __class__(){return e}};M.prototype.root=null,t.$global;let N=t.global(`$hxClasses`).StringBuf=class e extends t.inherits(){[t.new](){this.b=``}static get __name__(){return`StringBuf`}get __class__(){return e}};N.prototype.b=null,t.$global;let P=t.global(`$hxClasses`)[`internal.domHandler.DomRuntime`]=class e extends t.inherits(){[t.new](){}static warn(e){t.$global.console.warn(e)}static _fillRecoTargets(t){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;if(t==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let s=[],c=[],l=t.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c;f.push(t);let p=0;for(;p<f.length;){let e=f[p];++p;let t=0,n=[],r=0,i=e.attributes;for(;r<i.length;){let e=i[r];++r,n.push({name:e.name,value:e.value})}let a=n;for(;t<a.length;){let n=a[t];if(++t,n.name==`data-froomle-reco`){let t=e.getAttribute(`data-froomle-framework`);if(t!=null&&t!=``)continue;s.push(e)}}}let m=[],h=0;for(;h<s.length;){let e=s[h];++h;let t=e.getAttribute(`data-froomle-request-id`),n=e.getAttribute(`data-froomle-id`);!(t!=null&&t!=``)&&!(n!=null&&n!=``)&&m.push(e)}if(m.length<1){let e=null,t=null,n=new Promise(function(n,r){e=n,t=r}),r=n;return r._resolve=e,r._reject=t,r._isFinished=!1,r._result=null,r._error=null,n}let _=[],v=[],y=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-reco-filter-`)){let n=g.substr(e.name,25,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return w.normalizeFilters(t)},b=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-variable-`)){let n=g.substr(e.name,22,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},x=Array(m.length),S=0,ee=m.length;for(;S<ee;){let e=S++,t=m[e];x[e]={list_name:t.getAttribute(`data-froomle-reco`),filters:y(t),others:b(t),entry:t}}let C=w.groupSequential(x);_=w.toRequestLists(C);let T=Array(C.length),E=0,D=C.length;for(;E<D;){let e=E++;T[e]=C[e].entries}v=T;let k;if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else try{k=O.getRawRecommendations(_)}catch{let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}return k.then(function(t){let n=t.lists(),r=n.length,i=v.length,a=!1;r!=i&&(a=!0,e.warn(`Froomle SDK: recommendation list count mismatch. Expected `+i+` list(s) for DOM targets, but backend returned `+r+`.`));let s=r<i?r:i,c=0,l=s;for(;c<l;){let r=c++,i=n[r],o=v[r],s=o.length,l=i.items.length;l!=s&&(a=!0,e.warn(`Froomle SDK: recommendation item count mismatch for list "`+i.list_name+`". Expected `+s+` item(s) for DOM targets, but backend returned `+l+`.`));let u=l<s?l:s,d=0,f=u;for(;d<f;){let n=d++,r=i.items[n],a=o[n];e._fillParameters(a,r,t.request_id)}}let u=!a,d=o;d._isFinished||(d._result=u,d._error=null,d._isFinished=!0,d._resolve(u))}),o}static getAttrByPath(e,t,n){n==null&&(n=`fgh`);try{t=new y(`\\\\[(\\\\w+)\\\\]`,`g`).map(t,function(e){return`.`+e.matched(1)}),t=_.replace(t,`[`,`.`),t=_.replace(t,`]`,``),g.cca(t,0)==46&&(t=g.substr(t,1,null));let n=t.split(`.`),r=e.get(n[0]),i=1,o=n.length;for(;i<o;){let e=i++;if(r==null)return null;r=r instanceof Array&&a.parseInt(n[e])!=null?r[a.parseInt(n[e])]:S.field(r,n[e])}return r}catch{return n}}static stringifyValue(e,t){return t==null&&(t=``),e==null?t:a.string(e)}static isQuotedToken(e){if(e==null||e.length<2)return!1;let t=e.charAt(0),n=e.charAt(e.length-1);return t==`'`&&n==`'`?!0:t==`"`?n==`"`:!1}static unescapeQuotedValue(e){let t=e;return t=_.replace(t,`\\'`,`'`),t=_.replace(t,`\\"`,`"`),t=_.replace(t,`\\\\`,`\\`),t}static unquoteToken(t){let n=_.trim(t);if(!e.isQuotedToken(n))return n;let r=g.substr(n,1,n.length-2);return e.unescapeQuotedValue(r)}static splitTopLevel(e,t){if(t==null||t.length!=1)return[e];let n=t.charAt(0),r=[],i=new N,a=0,o=null,s=!1,c=0,l=e.length;for(;c<l;){let t=c++,l=e.charAt(t);if(s){i.b+=l==null?`null`:``+l,s=!1;continue}if(o!=null){if(l==`\\`){i.b+=l==null?`null`:``+l,s=!0;continue}l==o&&(o=null),i.b+=l==null?`null`:``+l;continue}if(l==`'`||l==`"`){o=l,i.b+=l==null?`null`:``+l;continue}if(l==`(`?++a:l==`)`&&a>0&&--a,a==0&&l==n){r.push(_.trim(i.b)),i=new N;continue}i.b+=l==null?`null`:``+l}return r.push(_.trim(i.b)),r}static parseTransformPart(t){let n=_.trim(t);if(n==``)return{name:``,args:[]};let r=n.indexOf(`(`);if(r==-1||!n.endsWith(`)`))return{name:n,args:[]};let i=_.trim(g.substr(n,0,r)),a=g.substr(n,r+1,n.length-r-2),o=[];if(_.trim(a)!=``){let t=0,n=e.splitTopLevel(a,`,`);for(;t<n.length;){let r=n[t];++t,o.push(e.unquoteToken(r))}}return{name:i,args:o}}static resolveSeedValue(t,n,r){let i=_.trim(t);return i==``?r:e.isQuotedToken(i)?e.unquoteToken(i):e.stringifyValue(e.getAttrByPath(n,i,r),r)}static resolveFieldPathValue(t,n){let r=_.trim(t);return r==``?``:e.stringifyValue(e.getAttrByPath(n,r,null),``)}static applyTransform(t,n,r,i){let a=t==null?``:t;switch(n==null?``:n.toLowerCase()){case`append`:return r.length>=1?a+r[0]:a;case`default`:return(a==null||a==``)&&r.length>=1?r[0]:a;case`defaultfield`:return(a==null||a==``)&&r.length>=1?e.resolveFieldPathValue(r[0],i):a;case`lower`:return a.toLowerCase();case`prepend`:return r.length>=1?r[0]+a:a;case`replace`:return r.length>=2?_.replace(a,r[0],r[1]):a;case`trim`:return _.trim(a);case`upper`:return a.toUpperCase();case`urlencode`:return encodeURIComponent(a);default:return a}}static evaluateExpression(t,n,r){let i=_.trim(t);if(i.startsWith(`=`)&&(i=_.trim(g.substr(i,1,null))),i==``)return r;let a=e.splitTopLevel(i,`|`);if(a.length==0)return r;let o=e.resolveSeedValue(a[0],n,r),s=1,c=a.length;for(;s<c;){let t=s++,r=e.parseTransformPart(a[t]);r.name!=``&&(o=e.applyTransform(o,r.name,r.args,n))}return o}static findTemplateExpressionEnd(e,t){let n=null,r=!1,i=0,a=t;for(;a<e.length;){let t=e.charAt(a);if(r){r=!1,++a;continue}if(n!=null){t==`\\`?r=!0:t==n&&(n=null),++a;continue}if(t==`'`||t==`"`){n=t,++a;continue}if(t==`$`&&a+1<e.length&&e.charAt(a+1)==`{`){++i,a+=2;continue}if(t==`}`){if(i==0)return a;--i}++a}return-1}static resolveTemplate(t,n,r){if(t.indexOf("${")==-1)return t;let i=``,o=0;for(;o<t.length;){let s=t.indexOf("${",o);if(s==-1){i+=a.string(g.substr(t,o,null));break}i+=a.string(g.substr(t,o,s-o));let c=e.findTemplateExpressionEnd(t,s+2);if(c==-1){i+=a.string(g.substr(t,s,null));break}let l=g.substr(t,s+2,c-s-2);i+=a.string(e.evaluateExpression(l,n,r)),o=c+1}return i}static resolveParamValue(t,n,r){r==null&&(r=``);let i=e.stringifyValue(r,``),a=t==null?``:t,o=_.trim(a);return o==``?i:a.indexOf("${")==-1?o.startsWith(`=`)?e.evaluateExpression(g.substr(o,1,null),n,i):e.stringifyValue(e.getAttrByPath(n,o,i),i):e.resolveTemplate(a,n,i)}static _buildHistories(e){let t=[],n=[],r=e.querySelectorAll(`[data-froomle-id]`),i=0,a=r.length;for(;i<a;){let e=i++,t=r.item(e);t instanceof HTMLElement&&n.push(t)}let o=n,s=0;for(;s<o.length;){let e=o[s];++s,t.push(e.getAttribute(`data-froomle-id`))}O.addHistories(t)}static fillParam(t,n,r,i,a){a==null&&(a=``);try{let o=e.resolveParamValue(r,i,a);n==`inner`?(t.textContent=o,t.textContent):t.setAttribute(n,o)}catch{}}static _fillParameters(t,n,r){t.setAttribute(`data-froomle-id`,n.get(`item_id`)),t.setAttribute(`data-froomle-request-id`,r);let i=n.get(`item_type`);i!=null&&a.string(i)!=``&&t.setAttribute(`data-froomle-item-type`,a.string(i)),n.UserGroup!=null&&n.UserGroup!=``&&t.setAttribute(`data-froomle-user-group`,n.UserGroup);let o=[],s=t.querySelectorAll(`*`),c=0,l=s.length;for(;c<l;){let e=c++,t=s.item(e);t instanceof HTMLElement&&o.push(t)}let u=o,d=0;for(;d<u.length;){let t=u[d];++d;let r=0,i=[],a=0,o=t.attributes;for(;a<o.length;){let e=o[a];++a,i.push({name:e.name,value:e.value})}let s=i;for(;r<s.length;){let i=s[r];if(++r,i.name.startsWith(`data-froomle-param-`)){let r=_.replace(i.name,`data-froomle-param-`,``),a=i.value;e.fillParam(t,r,a,n)}}}}static _orderElements(e){let t=function(t,n,r){let i=[],a=[],o=0,s=t.childNodes;for(;o<s.length;){let e=s[o];++o,a.push(e)}let c=a,l=0;for(;l<c.length;){let n=c[l];++l;try{if(n.getAttribute(`data-froomle-ordervalue`)!=null){i.push(n);let r=e.createElement(`span`);r.setAttribute(`data-froomle-tmp-node`,`tmp`),t.replaceChild(r,n)}}catch{}}let u=[],d=0;for(;d<i.length;){let e=i[d];++d,u.push(e.getAttribute(`data-froomle-ordervalue`))}return{el:t,key:n,values:u,orderChildren:i,list_name:r}},n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i,s=e.getRoot(),c=[],l=s.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c,p=[],m=0;for(;m<f.length;){let e=f[m];++m;let n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let r=o[n];++n,r.name.startsWith(`data-froomle-order-`)&&p.push(t(e,r.name.substring(19),r.value))}}if(p.length<1){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let h=[],g=0;for(;g<p.length;){let e=p[g];++g;let t={list_name:e.list_name,limit:e.values.length,list_size:e.values.length},n={};S.setProperty(n,e.key,e.values),S.setProperty(t,`order`,n),h.push(t)}if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}try{O.getRawRecommendations(h).then(function(e){let t=e.lists(),n=t.length,r=0,i=n;for(;r<i;){let n=r++,i=t[n],a=p[n];a.el.setAttribute(`data-froomle-request-id`,e.request_id);let o=[],s=0,c=i.items;for(;s<c.length;){let e=c[s];++s;let t=e.get(a.key);e.get(a.key);let n=a.values.length,r=0,i=n;for(;r<i;){let e=r++;if(t==a.values[e]){a.orderChildren.length;let t=a.orderChildren[e];o.push(t),a.orderChildren.splice(e,1),a.values.splice(e,1);break}}}let l=a.el,u=[],d=0,f=l.childNodes;for(;d<f.length;){let e=f[d];++d,u.push(e)}let m=u.length,h=0,g=m;for(;h<g;){let e=h++,t=a.el,n=[],r=0,i=t.childNodes;for(;r<i.length;){let e=i[r];++r,n.push(e)}let s=n[e],c=s,l;if(l=c instanceof HTMLElement?c.hasAttribute(`data-froomle-tmp-node`):!1,l&&(a.el.replaceChild(o[0],s),o.splice(0,1),o.length,o.length==0))break}}let a=o;a._isFinished||(a._result=!0,a._error=null,a._isFinished=!0,a._resolve(!0))})}catch{let e=o;e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1))}return o}static domInit(t){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;return e._orderElements(t).then(function(n){e._buildHistories(t.getRoot()),e._fillRecoTargets(t.getRoot()).then(function(e){let t=o;t._isFinished||(t._result=!0,t._error=null,t._isFinished=!0,t._resolve(!0))})}),o}static fillElementRecos(t){e._fillRecoTargets(t)}static runFromHtml(t){if(t==``)return``;let n;try{let e=new DOMParser().parseFromString(t,`text/html`),r=new M;r.root=e.documentElement,n=r}catch{return t}return e.domInit(n),n.toString()}static get __name__(){return`internal.domHandler.DomRuntime`}get __class__(){return e}};t.$global;let F=t.global(`$hxClasses`).FroomleSdk=class e{static register(){e.registered||e._env_set&&e._page_visit_set&&(e.registered=!0)}static buildScriptTag(){let e=`<script src="https://cdn.jsdelivr.net/npm/@froomle/frontend-sdk@0.1.0/dist/froomle.global.js" data-froomle-env="`+O.getEnvironment()+`" `,t=O.getPageVisit();t!=null&&(e+=`data-froomle-page-visit="`+t+`" `);let n=O.getContextItem();if(n!=null){e+=`data-froomle-context-item="`+n+`" `;let t=O.getContextItemType();(t==null||t==``)&&(t=`article`),e+=`data-froomle-context-item-type="`+t+`" `}let r=O.getDeviceId();r!=null&&(e+=`data-froomle-device-id="`+r+`" `);let i=O.getUserId();i!=null&&(e+=`data-froomle-user-id="`+i+`" `);let a=O.getConsent();a>0&&(e+=`data-froomle-consent="`+a+`" `);let o=O.getRequestDomain();o!=null&&(e+=`data-froomle-request-domain="`+o+`" `);let s=O.getChannel();return s!=null&&(e+=`data-froomle-channel="`+s+`" `),e+=`><\/script>`,e}static setEnvironment(t){O.setEnvironment(t),e._env_set=!0,e.register()}static setDeviceId(e){O.setDeviceId(e)}static setUserId(e){O.setUserId(e)}static setConsent(e){O.setConsent(e)}static setPageVisit(t){O.setPageVisit(t),e._page_visit_set=!0,e.register()}static setChannel(e){O.setChannel(e)}static setRequestDomain(e){O.setRequestDomain(e)}static setRecommendationsAccessToken(e){O.setRecommendationsAccessToken(e)}static clearRecommendationsAccessToken(){O.clearRecommendationsAccessToken()}static setRecommendationsAccessTokenProvider(e){O.setRecommendationsAccessTokenProvider(e)}static clearRecommendationsAccessTokenProvider(){O.clearRecommendationsAccessTokenProvider()}static setSafeRequest(e){O.setSafeRequest(e)}static setContextItem(e){O.setContextItem(e)}static setContextItemType(e){O.setContextItemType(e)}static setCustomVariable(e,t){O.setOthers(e,t)}static getUserId(){return O.getUserId()}static getDeviceId(){return O.getDeviceId()}static getEnvironment(){return O.getEnvironment()}static getSafeRequest(){return O.getSafeRequest()}static getPageVisit(){return O.getPageVisit()}static getConsent(){return O.getConsent()}static getRecommendations(e){return O.getRawRecommendations(e)}static getChannel(){return O.getChannel()}static getVersion(){return`0.1.0`}static runFromHtml(e){return P.runFromHtml(e)}static get __name__(){return`FroomleSdk`}get __class__(){return e}};F._env_set=!1,F._page_visit_set=!1,F.registered=!1;function ne(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}function re(){return`frontend-sdk/${F.getVersion()}`}function ie(){return{"Content-Type":`application/json`,Accept:`application/json`,"X-Froomle-Client":re()}}function ae(e){return JSON.stringify({events:e})}async function I(e,t={}){let n=ae(e),r=ne(),{keepalive:i=!1,allowBeaconFallback:a=!1}=t;try{return await fetch(r,{method:`POST`,headers:ie(),body:n,...i?{keepalive:!0}:{}}),`fetch`}catch(e){if(a&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(r,e))return`beacon`}throw e}}function oe(){if(O.getConsent()<2)return;let e=O.getUserId();if(e)return e}function se(){let e=O.getContextItem();if(e)return e}function ce(){let e=O.getContextItemType();if(e)return e}function L(){return O.getConsent()>=1}function le(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}function ue(){let e=O.getChannel();if(e)return e}function de(e){var t;let n=e==null?void 0:e.getAttribute(`data-froomle-user-group`);if(n)return n;if(!(typeof document>`u`))return((t=document.querySelector(`[data-froomle-user-group]`))==null?void 0:t.getAttribute(`data-froomle-user-group`))||void 0}function fe(e){let t={event_type:e,page_type:O.getPageVisit(),channel:ue()||`www-desktop`,device_id:le()},n=de();n&&(t.user_group=n);let r=oe();return r&&(t.user_id=r),t}function pe(e,t){if(!t)return e;for(let n in t)e[n]=t[n];return e}function R(e){L()&&I([e]).catch(()=>{})}function z(e,t,n,r){let i=t||se();if(!i)return null;let a=fe(e);return a.action_item=i,a.action_item_type=n||ce()||`article`,pe(a,r)}function me(e,t,n=`impression`,r){let i=z(n,e,t,r);i&&R(i)}function he(e,t,n,r){let i=z(`item_interaction`,n?e:void 0,n&&typeof t==`string`?t:void 0,{interaction_type:n||e,...n?r:t});i&&R(i)}function ge(e,t){let n=fe(`user_interaction`);n.interaction_type=e,R(pe(n,t))}function _e(e,t,n,r){let i=z(`add_to_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function ve(e,t,n,r){let i=z(`remove_from_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function ye(e,t,n,r,i){let a=typeof e==`string`,o=z(`purchase`,a?e:void 0,a&&typeof t==`string`?t:void 0,{amount:a?n:e,purchased_price:a?r:t,...a?i:n});o&&R(o)}function be(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-id`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item`));if(t)return t}function xe(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-item-type`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item-type`));if(t)return t}var B=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateEvents(){let t=[];for(let n of e.impressionQueue){let e=be(n);if(!e)continue;let r=xe(n)||`article`,i=ue()||`www-desktop`,a={event_type:`impression`,page_type:O.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:le()},o=de(n);o&&(a.user_group=o),O.getConsent()>=2&&O.getUserId()&&(a.user_id=O.getUserId());let s=n.getAttribute(`data-froomle-reco`),c=n.getAttribute(`data-froomle-request-id`);s&&c&&(a.list_name=s,a.request_id=c),t.push(a)}return e.impressionQueue=[],t}static sendImpressions(){if(e.impressionQueue.length===0||!L())return;let t=e.generateEvents();t.length!==0&&I(t).catch(()=>{})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(t){let n=t.getBoundingClientRect(),r=e.getViewPortRect();return n.right>r.left&&n.left<r.right&&n.bottom>r.top&&n.top<r.bottom}static addIntersectionImpressionListener(t){e.observer.observe(t)}static processDocument(){if(L()){for(let t of document.querySelectorAll(`[data-froomle-id]`))e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}static processElement(t){if(!L()||!(t instanceof Element))return;let n=[];t.matches(`[data-froomle-id]`)&&n.push(t);for(let e of t.querySelectorAll(`[data-froomle-id]`))n.push(e);if(n.length!==0){for(let t of n)e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}};B.impressionQueue=[],B.observer=null,typeof document<`u`&&(B.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(B.impressionQueue.push(e.target),B.observer.unobserve(e.target))}),B.impressionQueue.length>0&&B.sendImpressions()}));var Se=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readChannel()||`www-desktop`,n={event_type:`page_visit`,page_type:O.getPageVisit(),channel:t,device_id:e.readDeviceId()},r=e.readUserGroup();return r&&(n.user_group=r),O.getConsent()>=2&&O.getUserId()&&(n.user_id=O.getUserId()),n}static sendPageVisit(){O.getPageVisit()&&(O.getContextItem()||e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{}))}},Ce=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItemType(){let e=O.getContextItemType();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readActionItemType()||`article`,n=e.readChannel()||`www-desktop`,r={event_type:`detail_pageview`,page_type:O.getPageVisit(),action_item:O.getContextItem(),action_item_type:t,channel:n,device_id:e.readDeviceId()},i=e.readUserGroup();return i&&(r.user_group=i),O.getConsent()>=2&&O.getUserId()&&(r.user_id=O.getUserId()),r}static sendPageView(){O.getContextItem()&&O.getPageVisit()&&e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{})}},we=class e{static readAttributeFromChain(e,t){let n=e;for(;n;){for(let e of t){let t=n.getAttribute(e);if(t)return t}n=n.parentElement}}static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItem(t){return e.readAttributeFromChain(t,[`data-froomle-id`,`data-froomle-action-item`])}static readActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-item-type`,`data-froomle-action-item-type`])}static readExplicitActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-action-item-type`])}static readUserGroup(t){var n;let r=e.readAttributeFromChain(t,[`data-froomle-user-group`]);if(r)return r;if(!(typeof document>`u`))return((n=document.querySelector(`[data-froomle-user-group]`))==null?void 0:n.getAttribute(`data-froomle-user-group`))||void 0}static registerClickables(){e.listenerRegistered||(e.listenerRegistered=!0,document.addEventListener(`click`,t=>{if(!e.canTrackEvents())return;let n=t instanceof MouseEvent?t:null,r=t.target,i=r instanceof Element?r:r instanceof Node?r.parentElement:null;if(!i)return;let a=i.closest(`a`);if(!a)return;let o=a.closest(`[data-froomle-id]`);if(!o)return;let s=a.closest(`[data-froomle-reco]`),c=(s?e.readActionItem(s):void 0)||e.readActionItem(o);if(!c)return;let l=e.readExplicitActionItemType(a)||(s?e.readActionItemType(s):void 0)||e.readActionItemType(o)||`article`,u=e.readChannel()||`www-desktop`,d=a instanceof HTMLAnchorElement?a.href:null,f=a.getAttribute(`href`),p=typeof f==`string`&&f.trim().startsWith(`#`),m=!!d&&!p&&t.cancelable&&!t.defaultPrevented&&!a.hasAttribute(`download`)&&(!a.target||a.target===`_self`)&&!!n&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey,h=p&&t.cancelable&&!t.defaultPrevented;(m||h)&&t.preventDefault();let g={event_type:`click_on_recommendation`,page_type:O.getPageVisit(),action_item:c,action_item_type:l,channel:u,device_id:e.readDeviceId()},_=(s?e.readUserGroup(s):void 0)||e.readUserGroup(o);_&&(g.user_group=_);let v=(s?e.readAttributeFromChain(s,[`data-froomle-reco`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-reco`]),y=(s?e.readAttributeFromChain(s,[`data-froomle-request-id`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-request-id`]);if(v&&y&&(g.list_name=v,g.request_id=y),O.getConsent()>=2&&O.getUserId()&&(g.user_id=O.getUserId()),m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);I([g],{keepalive:!0,allowBeaconFallback:!0}).catch(()=>{}).finally(()=>{window.clearTimeout(n),t()});return}I([g],{allowBeaconFallback:!0}).catch(()=>{})},!0))}};we.listenerRegistered=!1;let V=globalThis,H=`FroomleFrontendSdkIntegrationMode`;function Te(){return V[H]||(V[H]={mode:null}),V[H]}function Ee(e){let t=Te();return t.mode?{accepted:t.mode===e,current:t.mode}:(t.mode=e,{accepted:!0,current:e})}let De=M,U=F.setEnvironment,W=F.setPageVisit,G=F.setRequestDomain,K=F.setSafeRequest,q=typeof F.setChannel==`function`?F.setChannel:O.setChannel,Oe=F.setRecommendationsAccessToken,ke=F.clearRecommendationsAccessToken,Ae=F.setRecommendationsAccessTokenProvider,je=F.clearRecommendationsAccessTokenProvider,J=F.setContextItem,Me=F.setContextItemType,Ne=O.addHistories;function Pe(e,t){F.setCustomVariable(e,t)}function Fe(e){Oe(e==null?null:e)}function Ie(){ke()}function Le(e){Ae(e)}function Re(){je()}function Y(e){F.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function X(e){F.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Z(e){F.setConsent(e),document.cookie=`froomle_consent=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`,document.cookie=`froomle_device_id=${F.getDeviceId()}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function ze(e){return F.getRecommendations(e)}let Q=globalThis,Be=`FroomleFrontendSdkState`,Ve=`FroomleFrontendSdkReady`;function He(){let e=()=>{},t=()=>{},n=new Promise((n,r)=>{e=n,t=r}),r={initStarted:!1,initialized:!1,beforeInitEventDispatched:!1,initEventDispatched:!1,readyPromise:n,resolveReady:e,rejectReady:t};return Q[Be]=r,Q[Ve]=n,r}function $(){if(!Q[Be])return He();let e=Q[Be];return Q[Ve]||(Q[Ve]=e.readyPromise),e}function Ue(){return Q.FroomleFrontendSdk?Q.FroomleFrontendSdk:{RecommendationItem:D,setPageVisit:W,setEnvironment:U,setConsent:Z,setUserId:Y,setDeviceId:X,setRequestDomain:G,setSafeRequest:K,setChannel:q,setRecommendationsBearer:Fe,clearRecommendationsBearer:Ie,setRecommendationsBearerProvider:Le,clearRecommendationsBearerProvider:Re,setContextItem:J,setContextItemType:Me,setCustomVariable:Pe,getRecommendations:ze,sendEvent:me,sendItemInteraction:he,sendUserInteraction:ge,sendAddToCart:_e,sendRemoveFromCart:ve,sendPurchase:ye,addHistories:Ne,init:Ze}}function We(e){return{sdk:Ue(),mode:e,version:typeof F.getVersion==`function`?F.getVersion():void 0}}function Ge(e,t){if(typeof window>`u`)return;if(typeof window.CustomEvent==`function`){window.dispatchEvent(new window.CustomEvent(e,{detail:t}));return}let n=document.createEvent(`CustomEvent`);n.initCustomEvent(e,!1,!1,t),window.dispatchEvent(n)}function Ke(e){let t=$();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,Ge(`froomle:before-init`,We(e)))}function qe(e){let t=$();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,Ge(`froomle:init`,We(e)))}function Je(e){let t=$();t.initialized||(t.initialized=!0,t.resolveReady(Ue())),qe(e)}function Ye(e){$().rejectReady(e)}function Xe(e=`auto`){if(typeof document>`u`||!Ee(`dom`).accepted)return Promise.resolve(Ue());let t=$();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{Ke(e),P.domInit(De.fromDocument(document)).then(()=>{we.registerClickables(),B.processDocument(),Se.sendPageVisit(),Ce.sendPageView(),Je(e)}).catch(e=>{Ye(e)});function t(e){return e.matches(`[data-froomle-reco]:not([data-froomle-framework])`)||e.querySelector(`[data-froomle-reco]:not([data-froomle-framework])`)!==null}new MutationObserver(e=>{for(let n of e)if(n.type===`childList`&&n.addedNodes.forEach(e=>{e instanceof Element&&(t(e)&&P.fillElementRecos(e),B.processElement(e))}),n.type===`attributes`&&n.target instanceof Element)if(n.attributeName===`data-froomle-reco`){if(n.target.hasAttribute(`data-froomle-framework`))continue;let e=n.target.getAttribute(`data-froomle-request-id`);(!e||e===``)&&P.fillElementRecos(n.target)}else if(n.attributeName===`data-froomle-request-id`){if(n.target.hasAttribute(`data-froomle-framework`))continue;let e=n.target.getAttribute(`data-froomle-request-id`),t=n.target.getAttribute(`data-froomle-id`);n.target.getAttribute(`data-froomle-reco`)&&(!e||e===``)&&(!t||t===``)&&P.fillElementRecos(n.target)}else n.attributeName===`data-froomle-id`&&B.processElement(n.target)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-froomle-reco`,`data-froomle-request-id`,`data-froomle-id`]})},r=()=>{globalThis.setTimeout(n,0)};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r,{once:!0}):r(),t.readyPromise}function Ze(){return Xe(`manual`)}function Qe(e){let t=document.cookie.split(`; `);for(let n of t){let[t,r]=n.split(`=`);if(t===e)return decodeURIComponent(r)}return null}if(typeof window<`u`&&(window.setFroomleConsent=Z),!globalThis.froomleInitialized&&(globalThis.froomleInitialized=!0,typeof document<`u`)){let e=document.currentScript;if(e){let t=e.getAttribute(`data-froomle-device-id`),n=e.getAttribute(`data-froomle-user-id`),r=e.getAttribute(`data-froomle-env`),i=e.getAttribute(`data-froomle-page-visit`),a=e.getAttribute(`data-froomle-request-domain`),o=e.getAttribute(`data-froomle-context-item`),s=e.getAttribute(`data-froomle-context-item-type`),c=e.getAttribute(`data-froomle-safe-request`),l=e.getAttribute(`data-froomle-channel`);if(U(r),i&&W(i),o&&(J(o),Me(s||`article`)),t)X(t);else{let e=Qe(`froomle_device_id`);e&&X(e)}if(n)Y(n);else{let e=Qe(`froomle_user_id`);e&&Y(e)}a&&G(a),c&&K(c!==`false`),l&&q(l)}let t=Qe(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||Z(e)}Xe(`auto`)}return e.RecommendationItem=D,e.addHistories=Ne,e.clearRecommendationsBearer=Ie,e.clearRecommendationsBearerProvider=Re,e.getRecommendations=ze,e.init=Ze,e.sendAddToCart=_e,e.sendEvent=me,e.sendItemInteraction=he,e.sendPurchase=ye,e.sendRemoveFromCart=ve,e.sendUserInteraction=ge,e.setChannel=q,e.setConsent=Z,e.setContextItem=J,e.setContextItemType=Me,e.setCustomVariable=Pe,e.setDeviceId=X,e.setEnvironment=U,e.setPageVisit=W,e.setRecommendationsBearer=Fe,e.setRecommendationsBearerProvider=Le,e.setRequestDomain=G,e.setSafeRequest=K,e.setUserId=Y,e})({});
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./src-
|
|
1
|
+
const e=require(`./src-EA0Sr8Ah.cjs`);exports.RecommendationItem=e.N,exports.addHistories=e.r,exports.clearRecommendationsBearer=e.i,exports.clearRecommendationsBearerProvider=e.a,exports.fulfillRecommendations=e.t,exports.getRecommendations=e.o,exports.init=e.s,exports.proxyReco=e.n,exports.sendAddToCart=e.E,exports.sendEvent=e.D,exports.sendItemInteraction=e.O,exports.sendPurchase=e.k,exports.sendRemoveFromCart=e.A,exports.sendUserInteraction=e.j,exports.setChannel=e.c,exports.setConsent=e.l,exports.setContextItem=e.u,exports.setContextItemType=e.d,exports.setCustomVariable=e.f,exports.setDeviceId=e.p,exports.setEnvironment=e.m,exports.setPageVisit=e.h,exports.setRecommendationsBearer=e.g,exports.setRecommendationsBearerProvider=e._,exports.setRequestDomain=e.v,exports.setSafeRequest=e.y,exports.setUserId=e.b;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as sendPurchase, E as sendItemInteraction, M as RecommendationItem, O as sendRemoveFromCart, T as sendEvent, _ as setSafeRequest, a as init, c as setContextItem, d as setDeviceId, f as setEnvironment, g as setRequestDomain, h as setRecommendationsBearerProvider, i as getRecommendations, k as sendUserInteraction, l as setContextItemType, m as setRecommendationsBearer, n as clearRecommendationsBearer, o as setChannel, p as setPageVisit, r as clearRecommendationsBearerProvider, s as setConsent, t as addHistories, u as setCustomVariable, v as setUserId, w as sendAddToCart } from "./js-BJHOFA94.js";
|
|
2
2
|
|
|
3
3
|
//#region src/js/generated/internal/data/FroomleTuple.d.ts
|
|
4
4
|
type FroomleTuple = {
|
|
@@ -21,4 +21,4 @@ type RecoRequest = {
|
|
|
21
21
|
declare function fulfillRecommendations(): Promise<void>;
|
|
22
22
|
declare function proxyReco(req: RecoRequest): RecommendationItem & PromiseLike<RecommendationItem>;
|
|
23
23
|
//#endregion
|
|
24
|
-
export { RecommendationItem,
|
|
24
|
+
export { RecommendationItem, addHistories, clearRecommendationsBearer, clearRecommendationsBearerProvider, fulfillRecommendations, getRecommendations, init, proxyReco, sendAddToCart, sendEvent, sendItemInteraction, sendPurchase, sendRemoveFromCart, sendUserInteraction, setChannel, setConsent, setContextItem, setContextItemType, setCustomVariable, setDeviceId, setEnvironment, setPageVisit, setRecommendationsBearer, setRecommendationsBearerProvider, setRequestDomain, setSafeRequest, setUserId };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{D as e,E as t,M as n,O as r,T as i,_ as a,a as o,c as s,d as c,f as l,g as u,h as d,i as f,k as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,w}from"./js-BJHOFA94.js";import{n as T,t as E}from"./src-BzUJq6YD.js";export{n as RecommendationItem,x as addHistories,g as clearRecommendationsBearer,y as clearRecommendationsBearerProvider,E as fulfillRecommendations,f as getRecommendations,o as init,T as proxyReco,w as sendAddToCart,i as sendEvent,t as sendItemInteraction,e as sendPurchase,r as sendRemoveFromCart,p as sendUserInteraction,_ as setChannel,b as setConsent,s as setContextItem,m as setContextItemType,S as setCustomVariable,c as setDeviceId,l as setEnvironment,v as setPageVisit,h as setRecommendationsBearer,d as setRecommendationsBearerProvider,u as setRequestDomain,a as setSafeRequest,C as setUserId};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var e=class e{static global(t){return e.globals[t]?e.globals[t]:e.globals[t]={}}static createStatic(e,t,n){let r=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return n!=null&&(r=n(),n=null),r},set:function(e){n!=null&&(r=n(),n=null),r=e}})}static iterator(t){if(Array.isArray(t)){let n=t;return function(){return e.mkIter(n)}}else return typeof t.iterator==`function`?t.iterator.bind(t):t.iterator}static getIterator(t){return Array.isArray(t)?e.mkIter(t):t.iterator()}static mkIter(e){return new t(e)}static extend(t){function n(){this[e.new].apply(this,arguments)}return Object.setPrototypeOf(n.prototype,t.prototype),n}static inherits(t,n){n==null&&(n=!1);function r(){n&&t&&r[e.init]&&r[e.init](),this[e.new].apply(this,arguments)}return n?r[e.init]=()=>{let n=t();n[e.init]&&n[e.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[e.init]=void 0}:t&&t[e.init]?(n=!0,r[e.init]=()=>{t[e.init]&&t[e.init](),Object.setPrototypeOf(r.prototype,t.prototype),r[e.init]=void 0}):t&&Object.setPrototypeOf(r.prototype,t.prototype),r}static bind(t,n){if(n==null)return null;n.__id__==null&&(n.__id__=e.fid++);let r=null;return t.hx__closures__==null?t.hx__closures__={}:r=t.hx__closures__[n.__id__],r==null&&(r=n.bind(t),t.hx__closures__[n.__id__]=r),r}static get __name__(){return`genes.Register`}get __class__(){return e}};e.$global=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:void 0,e.globals={},e.new=Symbol(),e.init=Symbol(),e.fid=0;const t=e.global(`$hxClasses`)[`genes._Register.ArrayIterator`]=class t extends e.inherits(){[e.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return`genes._Register.ArrayIterator`}get __class__(){return t}};t.prototype.array=null,t.prototype.current=null,e.$global;const n=e.global(`$hxClasses`)[`haxe.ValueException`]=class t extends e.inherits(()=>r,!0){[e.new](t,n,r){super[e.new](String(t),n,r),this.value=t}unwrap(){return this.value}static get __name__(){return`haxe.ValueException`}static get __super__(){return r}get __class__(){return t}};n.prototype.value=null,e.$global;const r=e.global(`$hxClasses`)[`haxe.Exception`]=class t extends e.inherits(()=>Error,!0){[e.new](e,t,n){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=n==null?this:n}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof t?e:e instanceof Error?new t(e.message,null,e):new n(e,null,e)}static thrown(e){return e instanceof t?e.get_native():e instanceof Error?e:new n(e)}static get __name__(){return`haxe.Exception`}static get __super__(){return Error}get __class__(){return t}};r.prototype.native=null,r.prototype.__skipStack=null,r.prototype.__nativeException=null,r.prototype.__previousException=null,e.$global;const i=e.global(`$hxClasses`).Std=class e{static string(e){return a.__string_rec(e,``)}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static random(e){return e<=0?0:Math.floor(Math.random()*e)}static get __name__(){return`Std`}get __class__(){return e}};Object.defineProperty(String.prototype,`__class__`,{value:String,enumerable:!1,writable:!0}),String.__name__=!0,Array.__name__=!0,e.$global;const a=e.global(`$hxClasses`)[`js.Boot`]=class t{static getClass(e){if(e==null)return null;if(e instanceof Array)return Array;{let n=e.__class__;if(n!=null)return n;let r=t.__nativeClassName(e);return r==null?null:t.__resolveNativeClass(r)}}static __string_rec(n,r){if(n==null)return`null`;if(r.length>=5)return`<...>`;let i=typeof n;switch(i==`function`&&(n.__name__||n.__ename__)&&(i=`object`),i){case`function`:return`<function>`;case`object`:if(n.__enum__){let i=e.global(`$hxEnums`)[n.__enum__].__constructs__[n._hx_index],a=i._hx_name;return i.__params__?(r+=` `,a+`(`+(function(e){var a;let o=[];{let e=0,a=i.__params__;for(;e<a.length;){let i=a[e];e+=1,o.push(t.__string_rec(n[i],r))}}return a=o,a})(this).join(`,`)+`)`):a}if(n instanceof Array){let e=`[`;r+=` `;let i=0,a=n.length;for(;i<a;){let a=i++;e+=(a>0?`,`:``)+t.__string_rec(n[a],r)}return e+=`]`,e}let i;try{i=n.toString}catch{return`???`}if(i!=null&&i!=Object.toString&&typeof i==`function`){let e=n.toString();if(e!=`[object Object]`)return e}let a=`{
|
|
2
|
+
`;r+=` `;let o=n.hasOwnProperty!=null,s=null;for(s in n)o&&!n.hasOwnProperty(s)||s==`prototype`||s==`__class__`||s==`__super__`||s==`__interfaces__`||s==`__properties__`||(a.length!=2&&(a+=`,
|
|
3
|
+
`),a+=r+s+` : `+t.__string_rec(n[s],r));return r=r.substring(1),a+=`
|
|
4
|
+
`+r+`}`,a;case`string`:return n;default:return String(n)}}static __interfLoop(e,n){if(e==null)return!1;if(e==n)return!0;let r=e.__interfaces__;if(r!=null&&(e.__super__==null||e.__super__.__interfaces__!=r)){let e=0,i=r.length;for(;e<i;){let i=r[e++];if(i==n||t.__interfLoop(i,n))return!0}}return t.__interfLoop(e.__super__,n)}static __instanceof(n,r){if(r==null)return!1;switch(r){case Array:return n instanceof Array;case`$hxCoreType__Bool`:return typeof n==`boolean`;case`$hxCoreType__Dynamic`:return n!=null;case`$hxCoreType__Float`:return typeof n==`number`;case`$hxCoreType__Int`:return typeof n==`number`?(n|0)===n:!1;case String:return typeof n==`string`;default:if(n!=null){if(typeof r==`function`){if(t.__downcastCheck(n,r))return!0}else if(typeof r==`object`&&t.__isNativeObj(r)&&n instanceof r)return!0}else return!1;return r==`$hxCoreType__Class`&&n.__name__!=null||r==`$hxCoreType__Enum`&&n.__ename__!=null?!0:n.__enum__==null?!1:e.global(`$hxEnums`)[n.__enum__]==r}}static __downcastCheck(e,n){return e instanceof n?!0:n.__isInterface__?t.__interfLoop(t.getClass(e),n):!1}static __cast(e,n){if(e==null||t.__instanceof(e,n))return e;throw r.thrown(`Cannot cast `+i.string(e)+` to `+i.string(n))}static __nativeClassName(e){let n=t.__toStr.call(e).slice(8,-1);return n==`Object`||n==`Function`||n==`Math`||n==`JSON`?null:n}static __isNativeObj(e){return t.__nativeClassName(e)!=null}static __resolveNativeClass(t){return e.$global[t]}static get __name__(){return`js.Boot`}get __class__(){return t}};a.__toStr={}.toString,e.$global;const o=e.global(`$hxClasses`)[`js.Browser`]=class e{static get supported(){return this.get_supported()}static get_supported(){return typeof window<`u`&&window.location!==void 0?typeof window.location.protocol==`string`:!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest<`u`)return new XMLHttpRequest;if(typeof ActiveXObject<`u`)return new`ActiveXObject`(`Microsoft.XMLHTTP`);throw r.thrown(`Unable to create XMLHttpRequest object.`)}static get __name__(){return`js.Browser`}get __class__(){return e}};e.$global;const s=e.global(`$hxEnums`)[`haxe.io.Error`]={__ename__:`haxe.io.Error`,Blocked:{_hx_name:`Blocked`,_hx_index:0,__enum__:`haxe.io.Error`},Overflow:{_hx_name:`Overflow`,_hx_index:1,__enum__:`haxe.io.Error`},OutsideBounds:{_hx_name:`OutsideBounds`,_hx_index:2,__enum__:`haxe.io.Error`},Custom:Object.assign(e=>({_hx_index:3,__enum__:`haxe.io.Error`,e}),{_hx_name:`Custom`,__params__:[`e`]})};s.__constructs__=[s.Blocked,s.Overflow,s.OutsideBounds,s.Custom],s.__empty_constructs__=[s.Blocked,s.Overflow,s.OutsideBounds],e.$global;const c=e.global(`$hxEnums`)[`haxe.io.Encoding`]={__ename__:`haxe.io.Encoding`,UTF8:{_hx_name:`UTF8`,_hx_index:0,__enum__:`haxe.io.Encoding`},RawNative:{_hx_name:`RawNative`,_hx_index:1,__enum__:`haxe.io.Encoding`}};c.__constructs__=[c.UTF8,c.RawNative],c.__empty_constructs__=[c.UTF8,c.RawNative],e.$global;const l=e.global(`$hxClasses`)[`haxe.io.Bytes`]=class t extends e.inherits(){[e.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,n){if(e<0||t<0||e+t>this.length)throw r.thrown(s.OutsideBounds);n==null&&(n=c.UTF8);let i=``,a=this.b,o=e,l=e+t;switch(n._hx_index){case 0:for(;o<l;){let e=a[o++];if(e<128){if(e==0)break;i+=String.fromCodePoint(e)}else if(e<224){let t=(e&63)<<6|a[o++]&127;i+=String.fromCodePoint(t)}else if(e<240){let t=a[o++],n=(e&31)<<12|(t&127)<<6|a[o++]&127;i+=String.fromCodePoint(n)}else{let t=a[o++],n=a[o++],r=(e&15)<<18|(t&127)<<12|(n&127)<<6|a[o++]&127;i+=String.fromCodePoint(r)}}break;case 1:for(;o<l;){let e=a[o++]|a[o++]<<8;i+=String.fromCodePoint(e)}break}return i}static ofData(e){let n=e.hxBytes;return n==null?new t(e):n}static get __name__(){return`haxe.io.Bytes`}get __class__(){return t}};l.prototype.length=null,l.prototype.b=null,e.$global;const u=e.global(`$hxClasses`)[`haxe.http.HttpBase`]=class t extends e.inherits(){[e.new](t){this.url=t,this.headers=[],this.params=[],this.emptyOnData=e.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let n=0,r=this.headers.length;for(;n<r;){let r=n++;if(this.headers[r].name==e){this.headers[r]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return e.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,c.UTF8)),this.responseAsString}static get __name__(){return`haxe.http.HttpBase`}get __class__(){return t}};u.prototype.url=null,u.prototype.responseBytes=null,u.prototype.responseAsString=null,u.prototype.postData=null,u.prototype.postBytes=null,u.prototype.headers=null,u.prototype.params=null,u.prototype.emptyOnData=null,e.$global;const d=e.global(`$hxClasses`)[`haxe.iterators.MapKeyValueIterator`]=class t extends e.inherits(){[e.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return`haxe.iterators.MapKeyValueIterator`}get __class__(){return t}};d.prototype.map=null,d.prototype.keys=null,e.$global;const f=function(){};f.__isInterface__=!0,e.$global;const p=e.global(`$hxClasses`)[`genes.util.EsMap`]=class t extends e.inherits(){[e.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return t.adaptIterator(this.inst.keys())}iterator(){return t.adaptIterator(this.inst.values())}toString(){let e=[],n=t.adaptIterator(this.inst.keys());for(;n.hasNext();){let t=n.next();e.push(``+i.string(t)+` => `+i.string(this.inst.get(t)))}return`{`+e.join(`, `)+`}`}clear(){this.inst.clear()}static adaptIterator(e){let t,n,r=function(){let r=e.next();t=r.value,n=r.done};return{hasNext:function(){return n==null&&r(),!n},next:function(){n==null&&r();let e=t;return r(),e}}}static get __name__(){return`genes.util.EsMap`}get __class__(){return t}};p.prototype.inst=null,e.$global;const m=e.global(`$hxClasses`)[`haxe.ds.StringMap`]=class t extends e.inherits(p){[e.new](){super[e.new]()}copy(){let e=new t;return e.inst=new Map(this.inst),e}keyValueIterator(){return new d(this)}static get __name__(){return`haxe.ds.StringMap`}static get __interfaces__(){return[f]}static get __super__(){return p}get __class__(){return t}};e.$global;const h=e.global(`$hxClasses`).HxOverrides=class e{static cca(e,t){let n=e.charCodeAt(t);if(n==n)return n}static substr(e,t,n){if(n==null)n=e.length;else if(n<0)if(t==0)n=e.length+n;else return``;return e.substr(t,n)}static now(){return Date.now()}static get __name__(){return`HxOverrides`}get __class__(){return e}};typeof performance<`u`&&typeof performance.now==`function`&&(h.now=performance.now.bind(performance)),e.$global;const g=e.global(`$hxClasses`).StringTools=class e{static isSpace(e,t){let n=h.cca(e,t);return n>8&&n<14?!0:n==32}static ltrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,r);)++r;return r>0?h.substr(t,r,n-r):t}static rtrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,n-r-1);)++r;return r>0?h.substr(t,0,n-r):t}static trim(t){return e.ltrim(e.rtrim(t))}static replace(e,t,n){return e.split(t).join(n)}static get __name__(){return`StringTools`}get __class__(){return e}};e.$global;const _=e.global(`$hxClasses`).Lambda=class t{static exists(t,n){let r=e.getIterator(t);for(;r.hasNext();)if(n(r.next()))return!0;return!1}static get __name__(){return`Lambda`}get __class__(){return t}};e.$global;const v=e.global(`$hxClasses`).EReg=class t extends e.inherits(){[e.new](e,t){this.r=new RegExp(e,t.split(`u`).join(``))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw r.thrown(`EReg::matched`)}matchedPos(){if(this.r.m==null)throw r.thrown(`No string matched`);return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,n){if(n==null&&(n=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(n<0?e:h.substr(e,0,t+n));let r=this.r.m!=null;return r&&(this.r.s=e),r}else{let r=this.match(n<0?h.substr(e,t,null):h.substr(e,t,n));return r&&(this.r.s=e,this.r.m.index+=t),r}}map(e,t){let n=0,r=``;do{if(n>=e.length)break;if(!this.matchSub(e,n)){r+=i.string(h.substr(e,n,null));break}let a=this.matchedPos();r+=i.string(h.substr(e,n,a.pos-n)),r+=i.string(t(this)),a.len==0?(r+=i.string(h.substr(e,a.pos,1)),n=a.pos+1):n=a.pos+a.len}while(this.r.global);return!this.r.global&&n>0&&n<e.length&&(r+=i.string(h.substr(e,n,null))),r}static get __name__(){return`EReg`}get __class__(){return t}};v.prototype.r=null,e.$global;const y=e.global(`$hxClasses`)[`haxe.http.HttpJs`]=class t extends e.inherits(u){[e.new](t){this.async=!0,this.withCredentials=!1,super[e.new](t)}request(t){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let n=this.req=o.createXMLHttpRequest(),a=this,s=function(t){if(n.readyState!=4)return;let r;try{r=n.status}catch{r=null}if(r==0&&o.get_supported()&&e.$global.location!=null){let t=e.$global.location.protocol.toLowerCase();new v(`^(?:about|app|app-storage|.+-extension|file|res|widget):$`,``).match(t)&&(r=n.response==null?404:200)}if(r==null&&(r=null),r!=null&&a.onStatus(r),r!=null&&r>=200&&r<400){a.req=null;let e=n.getAllResponseHeaders().split(`\r
|
|
5
|
+
`),t=[],r=0,i=e;for(;r<i.length;){let e=i[r];++r,e!=``&&t.push(e)}e=t,a.responseHeaders=new m;let o=0;for(;o<e.length;){let t=e[o];++o;let n=t.split(`: `),r=n.shift(),i=n.length==1?n[0]:n.join(`: `);i=g.ltrim(g.rtrim(i)),a.responseHeaders.inst.set(r,i)}a.success(l.ofData(n.response))}else if(r==null||r==0&&n.response==null)a.req=null,a.onError(`Failed to connect or resolve host`);else if(r==null)a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status);else switch(r){case 12007:a.req=null,a.onError(`Unknown host`);break;case 12029:a.req=null,a.onError(`Failed to connect to host`);break;default:a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status)}};this.async&&(n.onreadystatechange=s);let c,u=this.postData,d=this.postBytes;if(u==null)if(d==null)c=null;else{let e=d;c=new Blob([e.b.bufferValue])}else c=d==null?u:null;if(c!=null)t=!0;else{let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,c=c==null?``:(c==null?`null`:i.string(c))+`&`;let r=n.name,a=(c==null?`null`:i.string(c))+encodeURIComponent(r)+`=`,o=n.value;c=a+encodeURIComponent(o)}}try{if(t)n.open(`POST`,this.url,this.async);else if(c!=null){let e=this.url.split(`?`).length<=1;n.open(`GET`,this.url+(e?`?`:`&`)+(c==null?`null`:i.string(c)),this.async),c=null}else n.open(`GET`,this.url,this.async);n.responseType=`arraybuffer`}catch(e){let t=r.caught(e).unwrap();this.req=null,this.onError(t.toString());return}n.withCredentials=this.withCredentials,!_.exists(this.headers,function(e){return e.name==`Content-Type`})&&t&&this.postData==null&&n.setRequestHeader(`Content-Type`,`application/x-www-form-urlencoded`);let f=0,p=this.headers;for(;f<p.length;){let e=p[f];++f,n.setRequestHeader(e.name,e.value)}n.send(c),this.async||s(null)}static get __name__(){return`haxe.http.HttpJs`}static get __super__(){return u}get __class__(){return t}};y.prototype.async=null,y.prototype.withCredentials=null,y.prototype.responseHeaders=null,y.prototype.req=null,e.$global;const b=e.global(`$hxClasses`).Type=class e{static createInstance(e,t){return new(Function.prototype.bind.apply(e,[null].concat(t)))}static get __name__(){return`Type`}get __class__(){return e}};e.$global;const x=e.global(`$hxClasses`).Reflect=class e{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let n;if(e==null)return null;{let r;return e.__properties__?(n=e.__properties__[`get_`+t],r=n):r=!1,r?e[n]():e[t]}}static setProperty(e,t,n){let r,i;e.__properties__?(r=e.__properties__[`set_`+t],i=r):i=!1,i?e[r](n):e[t]=n}static fields(e){let t=[];if(e!=null){let r=Object.prototype.hasOwnProperty;for(var n in e)n!=`__id__`&&n!=`hx__closures__`&&r.call(e,n)&&t.push(n)}return t}static compare(e,t){return e==t?0:e>t?1:-1}static get __name__(){return`Reflect`}get __class__(){return e}};e.$global;const S=e.global(`$hxClasses`)[`internal.http.FetchHttp`]=class t extends e.inherits(y){[e.new](t){this.responseStatus=0,super[e.new](t)}request(t){let n=e.$global,a=n.fetch,o=n.Headers,s=n.URLSearchParams;if(a==null){this.onError(`Fetch API not found.`);return}let c=b.createInstance(o,[]),l=0,u=this.headers;for(;l<u.length;){let e=u[l];++l,c.append(e.name,e.value)}let d=t?`POST`:`GET`,f=null;if(t)if(this.postData!=null)f=this.postData;else{f=b.createInstance(s,[]);let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,f.append(n.name,n.value)}}let p={method:d,headers:c,body:f},m=this,h=a(this.url,p).then(function(e){if(m.responseStatus=e.status,m.onStatus(e.status),e.ok)return e.text();throw r.thrown(`HTTP Error: `+i.string(e.status))}).then(function(e){m.onData(e)}),g=x.field(h,`catch`);g!=null&&g.apply(h,[function(e){m.onError(i.string(e))}])}static get __name__(){return`internal.http.FetchHttp`}static get __super__(){return y}get __class__(){return t}};S.prototype.responseStatus=null,e.$global;const C=e.global(`$hxClasses`)[`internal.data.UUID`]=class e{static randomHexChar(){return`0123456789abcdef`.charAt(i.random(16))}static v4(){let e=``,t=0;for(;t<36;)switch(t++){case 14:e+=`4`;break;case 19:e+=i.string(`0123456789abcdef`.charAt(8+i.random(4)));break;case 8:case 13:case 18:case 23:e+=`-`;break;default:e+=i.string(`0123456789abcdef`.charAt(i.random(16)))}return e}static get __name__(){return`internal.data.UUID`}get __class__(){return e}};C.HEX=`0123456789abcdef`,e.$global;const w=e.global(`$hxClasses`)[`internal.RecoRequestGrouping`]=class e{static normalizeFilters(e){let t=[];if(e==null)return t;let n=0;for(;n<e.length;){let r=e[n];++n,!(r==null||r.key==null||r.key==``)&&t.push({key:r.key,value:r.value})}return t}static tuplesSame(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(x.compare),l.sort(x.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0}static groupSequential(t){let n=[],r=null,i=0;for(;i<t.length;){let a=t[i];if(++i,r==null){r={list_name:a.list_name,filters:a.filters,others:a.others,entries:[a.entry]};continue}if(r.list_name==a.list_name&&e.tuplesSame(r.filters,a.filters)&&e.tuplesSame(r.others,a.others)){r.entries.push(a.entry);continue}n.push(r),r={list_name:a.list_name,filters:a.filters,others:a.others,entries:[a.entry]}}return r!=null&&n.push(r),n}static toRequestLists(e){let t=[],n=0;for(;n<e.length;){let r=e[n];++n;let i={limit:r.entries.length,list_name:r.list_name,list_size:r.entries.length},a=0,o=r.filters;for(;a<o.length;){let e=o[a];++a;let t=e.value;t instanceof Array||(t=[t]),i[e.key]=t}let s=0,c=r.others;for(;s<c.length;){let e=c[s];++s,i[e.key]=e.value}t.push(i)}return t}static get __name__(){return`internal.RecoRequestGrouping`}get __class__(){return e}};e.$global;const T=function(){};T.__isInterface__=!0;const E=function(){};E.__isInterface__=!0;const D=function(){};D.__isInterface__=!0,e.$global;const O=e.global(`$hxClasses`)[`internal.RecommendationBackend`]=class t extends e.inherits(){[e.new](){}static _requestUri(){return(t._safe_request?`https://`:`http://`)+t._req_domain+`/api/`+t._environment+`/recommendations/requests`}static noConsentBody(){return{device_id:`no-consent`,user_group:`no-consent`,version:`no-consent`}}static buildRequestBody(e){let n={lists:e,page_type:t._page_visit,channel:t._channel};if(t._consent>=2&&t._history.length>0&&(n.histories=t._buildHistories()),t._consent<2){let e=t.noConsentBody(),r=0,i=x.fields(e);for(;r<i.length;){let t=i[r];++r,n[t]=x.field(e,t)}}else t._user_id!=null&&(n.user_id=t._user_id),n.device_id=t._device_id;let r=0,a=t._others;for(;r<a.length;){let e=a[r];++r,n[e.key]=e.value}let o=x.field(n,`context_item`),s=x.field(n,`context_item_type`);return o!=null&&i.string(o)!=``&&(s==null||i.string(s)==``)&&(n.context_item_type=`article`),n}static _buildHistories(){return{pageviews:t._history}}static normalizeAccessToken(e){if(e==null)return null;let t=i.string(e);return t==``?null:t}static hasRecommendationsAccessTokenProvider(){return t._recommendations_access_token_provider!=null}static resolveRecommendationsAccessToken(e){if(!e){let e=t.normalizeAccessToken(t._recommendations_access_token);if(e!=null)return Promise.resolve(e)}if(!t.hasRecommendationsAccessTokenProvider())return Promise.resolve(t.normalizeAccessToken(t._recommendations_access_token));let n=null;try{n=t._recommendations_access_token_provider.apply(null,[{forceRefresh:e}])}catch(e){let t=r.caught(e).unwrap();return Promise.reject(t)}return Promise.resolve(n).then(function(e){let n=t.normalizeAccessToken(e);return t._recommendations_access_token=n,n})}static requestsToLists(e){let t=Array(e.length),n=0,r=e.length;for(;n<r;){let r=n++,i=e[r];t[r]={list_name:i.list,filters:w.normalizeFilters(i.filters),others:i.others==null?[]:i.others,entry:i}}let i=t;return w.toRequestLists(w.groupSequential(i))}static _requestRecos(e){let n=null,a=null,o=new Promise(function(e,t){n=e,a=t}),s=o;s._resolve=n,s._reject=a,s._isFinished=!1,s._result=null,s._error=null;let c=o,l=!1,u=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))},d=null;return d=function(n,a){if(l)return;let o=!1,s=!1,f=new S(t._requestUri());f.setHeader(`Content-Type`,`application/json`),f.setHeader(`X-Froomle-Client`,`frontend-sdk/0.1.0`);let p=t.normalizeAccessToken(n);p!=null&&f.setHeader(`Authorization`,`Bearer `+p);let m=t.buildRequestBody(e),h=JSON.stringify(m);f.setPostData(h),f.onError=function(e){o||s||l||(o=!0,u(`HTTP Request Error: `+e))},f.onStatus=function(e){if(!(o||l)){if(e==401&&a&&t.hasRecommendationsAccessTokenProvider()){o=!0,s=!0,t.resolveRecommendationsAccessToken(!0).then(function(e){return l?null:e==null?(u(`Recommendation access token provider returned no token during refresh.`),null):(d(e,!1),null)},function(e){return u(`Failed to refresh recommendation access token: `+i.string(e)),null});return}(e<200||e>=300)&&(o=!0,u(`HTTP Status Error: `+e))}};try{f.request(!0)}catch(e){let t=r.caught(e).unwrap();if(o||l)return;o=!0,u(`Failed to execute recommendation request: `+i.string(t));return}let g=function(e){if(!(o||s||l))try{let t=JSON.parse(e),n=k.fromRequestData(t);o=!0,l=!0;let r=c;r._isFinished||(r._result=n,r._error=null,r._isFinished=!0,r._resolve(n))}catch(e){let t=r.caught(e).unwrap();o=!0,u(`Failed to parse recommendation response: `+i.string(t))}},_=f.get_responseData();_==null?!o&&!s&&!l&&(f.onData=g):g(_)},t.resolveRecommendationsAccessToken(!1).then(function(e){return l?null:t.hasRecommendationsAccessTokenProvider()&&e==null?(u(`Recommendation access token provider returned no token.`),null):(d(e,t.hasRecommendationsAccessTokenProvider()),null)},function(e){return u(`Failed to resolve recommendation access token: `+i.string(e)),null}),c}static getOrder(e,n,a){let o={list_name:e,limit:a.length,list_size:a.length},s={};x.setProperty(s,n,a),x.setProperty(o,`order`,s);let c=null,l=null,u=new Promise(function(e,t){c=e,l=t}),d=u;d._resolve=c,d._reject=l,d._isFinished=!1,d._result=null,d._error=null;let f=u;return t.getRawRecommendations([o]).then(function(e){try{let t=[],n=e.lists();if(n!=null&&n.length>0){let e=n[0].items;if(e instanceof Array){let n=0,r=e;for(;n<r.length;){let e=r[n];++n;let i=e.get(`categories`);i!=null&&t.push(i)}}}let r=f;r._isFinished||(r._result=t,r._error=null,r._isFinished=!0,r._resolve(t))}catch(e){let t=r.caught(e).unwrap(),n=`Failed to build order response: `+i.string(t),a=f;a._isFinished||(a._error=n,a._isFinished=!0,a._reject(n))}},function(e){let t=f;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))}),f}static getRawRecommendations(e){return t._requestRecos(e)}static addHistories(e,n){if(n==null&&(n=`article`),e==null||e.length==0)return;let r=n!=null&&n!=``?n:`article`,a=0;for(;a<e.length;){let n=e[a];if(++a,typeof n==`string`){let e=i.string(n);e!=``&&t._history.push({id:e,item_type:r});continue}let o=n,s=x.field(o,`id`);if(s==null)continue;let c=i.string(s);if(c==``)continue;let l=x.field(o,`item_type`);(l==null||i.string(l)==``)&&(l=x.field(o,`itemType`));let u=l!=null&&i.string(l)!=``?i.string(l):r;t._history.push({id:c,item_type:u})}}static setOthers(e,n){let r=0,i=t._others;for(;r<i.length;){let t=i[r];if(++r,t.key==e){t.value=n;return}}t._others.push({key:e,value:n})}static setConsent(e){e>2&&(e=2),t._consent=e,e==2&&t.getDeviceId()==`no-consent`&&t.setDeviceId(C.v4())}static setChannel(e){t._channel=e}static setPageVisit(e){t._page_visit=e}static setEnvironment(e){t._environment=e}static setDeviceId(e){t._device_id=e}static setUserId(e){t._user_id=e}static setRequestDomain(e){t._req_domain=e}static setRecommendationsAccessToken(e){t._recommendations_access_token=t.normalizeAccessToken(e)}static clearRecommendationsAccessToken(){t._recommendations_access_token=null}static setRecommendationsAccessTokenProvider(e){t._recommendations_access_token_provider=e}static clearRecommendationsAccessTokenProvider(){t._recommendations_access_token_provider=null}static setSafeRequest(e){t._safe_request=e}static setContextItem(e){t.setOthers(`context_item`,e)}static setContextItemType(e){t.setOthers(`context_item_type`,e)}static getRequestDomain(){return t._req_domain}static getSafeRequest(){return t._safe_request}static getEnvironment(){return t._environment}static getPageVisit(){return t._page_visit}static getUserId(){return t._user_id}static getDeviceId(){return t._device_id}static getConsent(){return t._consent}static getChannel(){return t._channel}static getOthers(e){let n=0,r=t._others;for(;n<r.length;){let t=r[n];if(++n,e==t.key)return t.value}return null}static getContextItem(){return t.getOthers(`context_item`)}static getContextItemType(){return t.getOthers(`context_item_type`)}static get __name__(){return`internal.RecommendationBackend`}get __class__(){return t}};O._environment=null,O._device_id=`no-consent`,O._user_id=null,O._consent=0,O._req_domain=`europe-west1.froomle.com`,O._page_visit=null,O._channel=`www-desktop`,O._safe_request=!0,O._history=[],O._others=[],O._recommendations_access_token=null,O._recommendations_access_token_provider=null;const k=e.global(`$hxClasses`)[`internal._RecommendationsInternal`]=class t extends e.inherits(){[e.new](e,t,n,r,i){this.request_id=t,this.user_group=n,this.device_id=e,this.user_id=r,this._lists=i}items(){let e=[],t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i=0,a=r.items;for(;i<a.length;){let t=a[i];++i,e.push(t)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,n=this._lists;for(;t<n.length;){let r=n[t];if(++t,r.list_name==e)return r}return null}toJson(){let e={request_id:this.request_id,user_group:this.user_group,user_id:this.user_id,device_id:this.device_id,lists:[]},t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i={limit:r.limit,list_key:r.list_key,list_name:r.list_name,list_size:r.list_size,items:[]},o=0,s=r.items;for(;o<s.length;){let e=s[o];++o,i.items.push(a.__cast(e,j).getData())}e.lists.push(i)}return JSON.stringify(e)}static fromRequestData(e){let n=x.getProperty(e,`lists`),r=[],i=0;for(;i<n.length;){let t=n[i];++i;let a=x.getProperty(t,`items`),o=[],s=0;for(;s<a.length;){let t=a[s];++s,x.setProperty(t,`request_id`,x.getProperty(e,`request_id`)),x.setProperty(t,`user_group`,x.getProperty(e,`user_group`)),o.push(new j(t))}let c=new A({limit:x.getProperty(t,`limit`),list_key:x.getProperty(t,`list_key`),list_name:x.getProperty(t,`list_name`),list_size:x.getProperty(t,`list_size`),items:o,request_id:x.getProperty(e,`request_id`)});r.push(c)}return new t(x.getProperty(e,`device_id`),x.getProperty(e,`request_id`),x.getProperty(e,`user_group`),x.getProperty(e,`user_id`),r)}static get __name__(){return`internal._RecommendationsInternal`}static get __interfaces__(){return[T]}get __class__(){return t}};k.prototype.request_id=null,k.prototype.user_group=null,k.prototype.user_id=null,k.prototype.device_id=null,k.prototype._lists=null;const A=e.global(`$hxClasses`)[`internal._RecommendationsListInternal`]=class t extends e.inherits(){[e.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size,this.request_id=e.request_id}static get __name__(){return`internal._RecommendationsListInternal`}static get __interfaces__(){return[E]}get __class__(){return t}};A.prototype.limit=null,A.prototype.list_key=null,A.prototype.list_name=null,A.prototype.list_size=null,A.prototype.items=null,A.prototype.request_id=null;const j=e.global(`$hxClasses`)[`internal._RecommendationItemInternal`]=class t extends e.inherits(){[e.new](e){this.Id=x.getProperty(e,`item_id`),this.Rank=x.getProperty(e,`rank`),this.RequestId=x.getProperty(e,`request_id`),this.UserGroup=x.getProperty(e,`user_group`),this._data=e}getData(){return this._data}get(e){return this._data[e]}toJson(){return JSON.stringify(this._data)}static get __name__(){return`internal._RecommendationItemInternal`}static get __interfaces__(){return[D]}get __class__(){return t}};j.prototype.Id=null,j.prototype.Rank=null,j.prototype.RequestId=null,j.prototype.UserGroup=null,j.prototype._data=null,e.$global;const ee=function(){};ee.__isInterface__=!0,e.$global;const M=e.global(`$hxClasses`)[`internal.js.JSFroomleDomTree`]=class t extends e.inherits(){[e.new](){}getRoot(){return this.root}createElement(e){return this.root.ownerDocument.createElement(e)}toString(){return this.root.ownerDocument.documentElement.outerHTML}static fromHTML(e){let n=new DOMParser().parseFromString(e,`text/html`),r=new t;return r.root=n.documentElement,r}static fromDocument(e){let n=new t;return n.root=e.documentElement,n}static get __name__(){return`internal.js.JSFroomleDomTree`}static get __interfaces__(){return[ee]}get __class__(){return t}};M.prototype.root=null,e.$global;const N=e.global(`$hxClasses`).StringBuf=class t extends e.inherits(){[e.new](){this.b=``}static get __name__(){return`StringBuf`}get __class__(){return t}};N.prototype.b=null,e.$global;const P=e.global(`$hxClasses`)[`internal.domHandler.DomRuntime`]=class t extends e.inherits(){[e.new](){}static warn(t){e.$global.console.warn(t)}static _fillRecoTargets(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;if(e==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let s=[],c=[],l=e.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c;f.push(e);let p=0;for(;p<f.length;){let e=f[p];++p;let t=0,n=[],r=0,i=e.attributes;for(;r<i.length;){let e=i[r];++r,n.push({name:e.name,value:e.value})}let a=n;for(;t<a.length;){let n=a[t];if(++t,n.name==`data-froomle-reco`){let t=e.getAttribute(`data-froomle-framework`);if(t!=null&&t!=``)continue;s.push(e)}}}let m=[],g=0;for(;g<s.length;){let e=s[g];++g;let t=e.getAttribute(`data-froomle-request-id`),n=e.getAttribute(`data-froomle-id`);!(t!=null&&t!=``)&&!(n!=null&&n!=``)&&m.push(e)}if(m.length<1){let e=null,t=null,n=new Promise(function(n,r){e=n,t=r}),r=n;return r._resolve=e,r._reject=t,r._isFinished=!1,r._result=null,r._error=null,n}let _=[],v=[],y=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-reco-filter-`)){let n=h.substr(e.name,25,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return w.normalizeFilters(t)},b=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-variable-`)){let n=h.substr(e.name,22,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},x=Array(m.length),S=0,C=m.length;for(;S<C;){let e=S++,t=m[e];x[e]={list_name:t.getAttribute(`data-froomle-reco`),filters:y(t),others:b(t),entry:t}}let T=w.groupSequential(x);_=w.toRequestLists(T);let E=Array(T.length),D=0,k=T.length;for(;D<k;){let e=D++;E[e]=T[e].entries}v=E;let A;if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else try{A=O.getRawRecommendations(_)}catch{let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}return A.then(function(e){let n=e.lists(),r=n.length,i=v.length,a=!1;r!=i&&(a=!0,t.warn(`Froomle SDK: recommendation list count mismatch. Expected `+i+` list(s) for DOM targets, but backend returned `+r+`.`));let s=r<i?r:i,c=0,l=s;for(;c<l;){let r=c++,i=n[r],o=v[r],s=o.length,l=i.items.length;l!=s&&(a=!0,t.warn(`Froomle SDK: recommendation item count mismatch for list "`+i.list_name+`". Expected `+s+` item(s) for DOM targets, but backend returned `+l+`.`));let u=l<s?l:s,d=0,f=u;for(;d<f;){let n=d++,r=i.items[n],a=o[n];t._fillParameters(a,r,e.request_id)}}let u=!a,d=o;d._isFinished||(d._result=u,d._error=null,d._isFinished=!0,d._resolve(u))}),o}static getAttrByPath(e,t,n){n==null&&(n=`fgh`);try{t=new v(`\\\\[(\\\\w+)\\\\]`,`g`).map(t,function(e){return`.`+e.matched(1)}),t=g.replace(t,`[`,`.`),t=g.replace(t,`]`,``),h.cca(t,0)==46&&(t=h.substr(t,1,null));let n=t.split(`.`),r=e.get(n[0]),a=1,o=n.length;for(;a<o;){let e=a++;if(r==null)return null;r=r instanceof Array&&i.parseInt(n[e])!=null?r[i.parseInt(n[e])]:x.field(r,n[e])}return r}catch{return n}}static stringifyValue(e,t){return t==null&&(t=``),e==null?t:i.string(e)}static isQuotedToken(e){if(e==null||e.length<2)return!1;let t=e.charAt(0),n=e.charAt(e.length-1);return t==`'`&&n==`'`?!0:t==`"`?n==`"`:!1}static unescapeQuotedValue(e){let t=e;return t=g.replace(t,`\\'`,`'`),t=g.replace(t,`\\"`,`"`),t=g.replace(t,`\\\\`,`\\`),t}static unquoteToken(e){let n=g.trim(e);if(!t.isQuotedToken(n))return n;let r=h.substr(n,1,n.length-2);return t.unescapeQuotedValue(r)}static splitTopLevel(e,t){if(t==null||t.length!=1)return[e];let n=t.charAt(0),r=[],i=new N,a=0,o=null,s=!1,c=0,l=e.length;for(;c<l;){let t=c++,l=e.charAt(t);if(s){i.b+=l==null?`null`:``+l,s=!1;continue}if(o!=null){if(l==`\\`){i.b+=l==null?`null`:``+l,s=!0;continue}l==o&&(o=null),i.b+=l==null?`null`:``+l;continue}if(l==`'`||l==`"`){o=l,i.b+=l==null?`null`:``+l;continue}if(l==`(`?++a:l==`)`&&a>0&&--a,a==0&&l==n){r.push(g.trim(i.b)),i=new N;continue}i.b+=l==null?`null`:``+l}return r.push(g.trim(i.b)),r}static parseTransformPart(e){let n=g.trim(e);if(n==``)return{name:``,args:[]};let r=n.indexOf(`(`);if(r==-1||!n.endsWith(`)`))return{name:n,args:[]};let i=g.trim(h.substr(n,0,r)),a=h.substr(n,r+1,n.length-r-2),o=[];if(g.trim(a)!=``){let e=0,n=t.splitTopLevel(a,`,`);for(;e<n.length;){let r=n[e];++e,o.push(t.unquoteToken(r))}}return{name:i,args:o}}static resolveSeedValue(e,n,r){let i=g.trim(e);return i==``?r:t.isQuotedToken(i)?t.unquoteToken(i):t.stringifyValue(t.getAttrByPath(n,i,r),r)}static resolveFieldPathValue(e,n){let r=g.trim(e);return r==``?``:t.stringifyValue(t.getAttrByPath(n,r,null),``)}static applyTransform(e,n,r,i){let a=e==null?``:e;switch(n==null?``:n.toLowerCase()){case`append`:return r.length>=1?a+r[0]:a;case`default`:return(a==null||a==``)&&r.length>=1?r[0]:a;case`defaultfield`:return(a==null||a==``)&&r.length>=1?t.resolveFieldPathValue(r[0],i):a;case`lower`:return a.toLowerCase();case`prepend`:return r.length>=1?r[0]+a:a;case`replace`:return r.length>=2?g.replace(a,r[0],r[1]):a;case`trim`:return g.trim(a);case`upper`:return a.toUpperCase();case`urlencode`:return encodeURIComponent(a);default:return a}}static evaluateExpression(e,n,r){let i=g.trim(e);if(i.startsWith(`=`)&&(i=g.trim(h.substr(i,1,null))),i==``)return r;let a=t.splitTopLevel(i,`|`);if(a.length==0)return r;let o=t.resolveSeedValue(a[0],n,r),s=1,c=a.length;for(;s<c;){let e=s++,r=t.parseTransformPart(a[e]);r.name!=``&&(o=t.applyTransform(o,r.name,r.args,n))}return o}static findTemplateExpressionEnd(e,t){let n=null,r=!1,i=0,a=t;for(;a<e.length;){let t=e.charAt(a);if(r){r=!1,++a;continue}if(n!=null){t==`\\`?r=!0:t==n&&(n=null),++a;continue}if(t==`'`||t==`"`){n=t,++a;continue}if(t==`$`&&a+1<e.length&&e.charAt(a+1)==`{`){++i,a+=2;continue}if(t==`}`){if(i==0)return a;--i}++a}return-1}static resolveTemplate(e,n,r){if(e.indexOf("${")==-1)return e;let a=``,o=0;for(;o<e.length;){let s=e.indexOf("${",o);if(s==-1){a+=i.string(h.substr(e,o,null));break}a+=i.string(h.substr(e,o,s-o));let c=t.findTemplateExpressionEnd(e,s+2);if(c==-1){a+=i.string(h.substr(e,s,null));break}let l=h.substr(e,s+2,c-s-2);a+=i.string(t.evaluateExpression(l,n,r)),o=c+1}return a}static resolveParamValue(e,n,r){r==null&&(r=``);let i=t.stringifyValue(r,``),a=e==null?``:e,o=g.trim(a);return o==``?i:a.indexOf("${")==-1?o.startsWith(`=`)?t.evaluateExpression(h.substr(o,1,null),n,i):t.stringifyValue(t.getAttrByPath(n,o,i),i):t.resolveTemplate(a,n,i)}static _buildHistories(e){let t=[],n=[],r=e.querySelectorAll(`[data-froomle-id]`),i=0,a=r.length;for(;i<a;){let e=i++,t=r.item(e);t instanceof HTMLElement&&n.push(t)}let o=n,s=0;for(;s<o.length;){let e=o[s];++s,t.push(e.getAttribute(`data-froomle-id`))}O.addHistories(t)}static fillParam(e,n,r,i,a){a==null&&(a=``);try{let o=t.resolveParamValue(r,i,a);n==`inner`?(e.textContent=o,e.textContent):e.setAttribute(n,o)}catch{}}static _fillParameters(e,n,r){e.setAttribute(`data-froomle-id`,n.get(`item_id`)),e.setAttribute(`data-froomle-request-id`,r);let a=n.get(`item_type`);a!=null&&i.string(a)!=``&&e.setAttribute(`data-froomle-item-type`,i.string(a)),n.UserGroup!=null&&n.UserGroup!=``&&e.setAttribute(`data-froomle-user-group`,n.UserGroup);let o=[],s=e.querySelectorAll(`*`),c=0,l=s.length;for(;c<l;){let e=c++,t=s.item(e);t instanceof HTMLElement&&o.push(t)}let u=o,d=0;for(;d<u.length;){let e=u[d];++d;let r=0,i=[],a=0,o=e.attributes;for(;a<o.length;){let e=o[a];++a,i.push({name:e.name,value:e.value})}let s=i;for(;r<s.length;){let i=s[r];if(++r,i.name.startsWith(`data-froomle-param-`)){let r=g.replace(i.name,`data-froomle-param-`,``),a=i.value;t.fillParam(e,r,a,n)}}}}static _orderElements(e){let t=function(t,n,r){let i=[],a=[],o=0,s=t.childNodes;for(;o<s.length;){let e=s[o];++o,a.push(e)}let c=a,l=0;for(;l<c.length;){let n=c[l];++l;try{if(n.getAttribute(`data-froomle-ordervalue`)!=null){i.push(n);let r=e.createElement(`span`);r.setAttribute(`data-froomle-tmp-node`,`tmp`),t.replaceChild(r,n)}}catch{}}let u=[],d=0;for(;d<i.length;){let e=i[d];++d,u.push(e.getAttribute(`data-froomle-ordervalue`))}return{el:t,key:n,values:u,orderChildren:i,list_name:r}},n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i,s=e.getRoot(),c=[],l=s.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c,p=[],m=0;for(;m<f.length;){let e=f[m];++m;let n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let r=o[n];++n,r.name.startsWith(`data-froomle-order-`)&&p.push(t(e,r.name.substring(19),r.value))}}if(p.length<1){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let h=[],g=0;for(;g<p.length;){let e=p[g];++g;let t={list_name:e.list_name,limit:e.values.length,list_size:e.values.length},n={};x.setProperty(n,e.key,e.values),x.setProperty(t,`order`,n),h.push(t)}if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}try{O.getRawRecommendations(h).then(function(e){let t=e.lists(),n=t.length,r=0,i=n;for(;r<i;){let n=r++,i=t[n],a=p[n];a.el.setAttribute(`data-froomle-request-id`,e.request_id);let o=[],s=0,c=i.items;for(;s<c.length;){let e=c[s];++s;let t=e.get(a.key);e.get(a.key);let n=a.values.length,r=0,i=n;for(;r<i;){let e=r++;if(t==a.values[e]){a.orderChildren.length;let t=a.orderChildren[e];o.push(t),a.orderChildren.splice(e,1),a.values.splice(e,1);break}}}let l=a.el,u=[],d=0,f=l.childNodes;for(;d<f.length;){let e=f[d];++d,u.push(e)}let m=u.length,h=0,g=m;for(;h<g;){let e=h++,t=a.el,n=[],r=0,i=t.childNodes;for(;r<i.length;){let e=i[r];++r,n.push(e)}let s=n[e],c=s,l;if(l=c instanceof HTMLElement?c.hasAttribute(`data-froomle-tmp-node`):!1,l&&(a.el.replaceChild(o[0],s),o.splice(0,1),o.length,o.length==0))break}}let a=o;a._isFinished||(a._result=!0,a._error=null,a._isFinished=!0,a._resolve(!0))})}catch{let e=o;e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1))}return o}static domInit(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;return t._orderElements(e).then(function(n){t._buildHistories(e.getRoot()),t._fillRecoTargets(e.getRoot()).then(function(e){let t=o;t._isFinished||(t._result=!0,t._error=null,t._isFinished=!0,t._resolve(!0))})}),o}static fillElementRecos(e){t._fillRecoTargets(e)}static runFromHtml(e){if(e==``)return``;let n;try{let t=new DOMParser().parseFromString(e,`text/html`),r=new M;r.root=t.documentElement,n=r}catch{return e}return t.domInit(n),n.toString()}static get __name__(){return`internal.domHandler.DomRuntime`}get __class__(){return t}};e.$global;const F=e.global(`$hxClasses`).FroomleSdk=class e{static register(){e.registered||e._env_set&&e._page_visit_set&&(e.registered=!0)}static buildScriptTag(){let e=`<script src="https://cdn.jsdelivr.net/npm/@froomle/frontend-sdk@0.1.0/dist/froomle.global.js" data-froomle-env="`+O.getEnvironment()+`" `,t=O.getPageVisit();t!=null&&(e+=`data-froomle-page-visit="`+t+`" `);let n=O.getContextItem();if(n!=null){e+=`data-froomle-context-item="`+n+`" `;let t=O.getContextItemType();(t==null||t==``)&&(t=`article`),e+=`data-froomle-context-item-type="`+t+`" `}let r=O.getDeviceId();r!=null&&(e+=`data-froomle-device-id="`+r+`" `);let i=O.getUserId();i!=null&&(e+=`data-froomle-user-id="`+i+`" `);let a=O.getConsent();a>0&&(e+=`data-froomle-consent="`+a+`" `);let o=O.getRequestDomain();o!=null&&(e+=`data-froomle-request-domain="`+o+`" `);let s=O.getChannel();return s!=null&&(e+=`data-froomle-channel="`+s+`" `),e+=`><\/script>`,e}static setEnvironment(t){O.setEnvironment(t),e._env_set=!0,e.register()}static setDeviceId(e){O.setDeviceId(e)}static setUserId(e){O.setUserId(e)}static setConsent(e){O.setConsent(e)}static setPageVisit(t){O.setPageVisit(t),e._page_visit_set=!0,e.register()}static setChannel(e){O.setChannel(e)}static setRequestDomain(e){O.setRequestDomain(e)}static setRecommendationsAccessToken(e){O.setRecommendationsAccessToken(e)}static clearRecommendationsAccessToken(){O.clearRecommendationsAccessToken()}static setRecommendationsAccessTokenProvider(e){O.setRecommendationsAccessTokenProvider(e)}static clearRecommendationsAccessTokenProvider(){O.clearRecommendationsAccessTokenProvider()}static setSafeRequest(e){O.setSafeRequest(e)}static setContextItem(e){O.setContextItem(e)}static setContextItemType(e){O.setContextItemType(e)}static setCustomVariable(e,t){O.setOthers(e,t)}static getUserId(){return O.getUserId()}static getDeviceId(){return O.getDeviceId()}static getEnvironment(){return O.getEnvironment()}static getSafeRequest(){return O.getSafeRequest()}static getPageVisit(){return O.getPageVisit()}static getConsent(){return O.getConsent()}static getRecommendations(e){return O.getRawRecommendations(e)}static getChannel(){return O.getChannel()}static getVersion(){return`0.1.0`}static runFromHtml(e){return P.runFromHtml(e)}static get __name__(){return`FroomleSdk`}get __class__(){return e}};F._env_set=!1,F._page_visit_set=!1,F.registered=!1;function te(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}function ne(){return`frontend-sdk/${F.getVersion()}`}function re(){return{"Content-Type":`application/json`,Accept:`application/json`,"X-Froomle-Client":ne()}}function ie(e){return JSON.stringify({events:e})}async function I(e,t={}){let n=ie(e),r=te(),{keepalive:i=!1,allowBeaconFallback:a=!1}=t;try{return await fetch(r,{method:`POST`,headers:re(),body:n,...i?{keepalive:!0}:{}}),`fetch`}catch(e){if(a&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(r,e))return`beacon`}throw e}}function ae(){if(O.getConsent()<2)return;let e=O.getUserId();if(e)return e}function oe(){let e=O.getContextItem();if(e)return e}function se(){let e=O.getContextItemType();if(e)return e}function L(){return O.getConsent()>=1}function ce(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}function le(){let e=O.getChannel();if(e)return e}function ue(e){var t;let n=e==null?void 0:e.getAttribute(`data-froomle-user-group`);if(n)return n;if(!(typeof document>`u`))return((t=document.querySelector(`[data-froomle-user-group]`))==null?void 0:t.getAttribute(`data-froomle-user-group`))||void 0}function de(e){let t={event_type:e,page_type:O.getPageVisit(),channel:le()||`www-desktop`,device_id:ce()},n=ue();n&&(t.user_group=n);let r=ae();return r&&(t.user_id=r),t}function fe(e,t){if(!t)return e;for(let n in t)e[n]=t[n];return e}function R(e){L()&&I([e]).catch(()=>{})}function z(e,t,n,r){let i=t||oe();if(!i)return null;let a=de(e);return a.action_item=i,a.action_item_type=n||se()||`article`,fe(a,r)}function B(e,t,n=`impression`,r){let i=z(n,e,t,r);i&&R(i)}function V(e,t,n,r){let i=z(`item_interaction`,n?e:void 0,n&&typeof t==`string`?t:void 0,{interaction_type:n||e,...n?r:t});i&&R(i)}function H(e,t){let n=de(`user_interaction`);n.interaction_type=e,R(fe(n,t))}function pe(e,t,n,r){let i=z(`add_to_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function me(e,t,n,r){let i=z(`remove_from_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function he(e,t,n,r,i){let a=typeof e==`string`,o=z(`purchase`,a?e:void 0,a&&typeof t==`string`?t:void 0,{amount:a?n:e,purchased_price:a?r:t,...a?i:n});o&&R(o)}function ge(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-id`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item`));if(t)return t}function _e(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-item-type`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item-type`));if(t)return t}var U=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateEvents(){let t=[];for(let n of e.impressionQueue){let e=ge(n);if(!e)continue;let r=_e(n)||`article`,i=le()||`www-desktop`,a={event_type:`impression`,page_type:O.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ce()},o=ue(n);o&&(a.user_group=o),O.getConsent()>=2&&O.getUserId()&&(a.user_id=O.getUserId());let s=n.getAttribute(`data-froomle-reco`),c=n.getAttribute(`data-froomle-request-id`);s&&c&&(a.list_name=s,a.request_id=c),t.push(a)}return e.impressionQueue=[],t}static sendImpressions(){if(e.impressionQueue.length===0||!L())return;let t=e.generateEvents();t.length!==0&&I(t).catch(()=>{})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(t){let n=t.getBoundingClientRect(),r=e.getViewPortRect();return n.right>r.left&&n.left<r.right&&n.bottom>r.top&&n.top<r.bottom}static addIntersectionImpressionListener(t){e.observer.observe(t)}static processDocument(){if(L()){for(let t of document.querySelectorAll(`[data-froomle-id]`))e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}static processElement(t){if(!L()||!(t instanceof Element))return;let n=[];t.matches(`[data-froomle-id]`)&&n.push(t);for(let e of t.querySelectorAll(`[data-froomle-id]`))n.push(e);if(n.length!==0){for(let t of n)e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}};U.impressionQueue=[],U.observer=null,typeof document<`u`&&(U.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(U.impressionQueue.push(e.target),U.observer.unobserve(e.target))}),U.impressionQueue.length>0&&U.sendImpressions()}));var ve=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readChannel()||`www-desktop`,n={event_type:`page_visit`,page_type:O.getPageVisit(),channel:t,device_id:e.readDeviceId()},r=e.readUserGroup();return r&&(n.user_group=r),O.getConsent()>=2&&O.getUserId()&&(n.user_id=O.getUserId()),n}static sendPageVisit(){O.getPageVisit()&&(O.getContextItem()||e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{}))}},ye=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItemType(){let e=O.getContextItemType();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readActionItemType()||`article`,n=e.readChannel()||`www-desktop`,r={event_type:`detail_pageview`,page_type:O.getPageVisit(),action_item:O.getContextItem(),action_item_type:t,channel:n,device_id:e.readDeviceId()},i=e.readUserGroup();return i&&(r.user_group=i),O.getConsent()>=2&&O.getUserId()&&(r.user_id=O.getUserId()),r}static sendPageView(){O.getContextItem()&&O.getPageVisit()&&e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{})}},W=class e{static readAttributeFromChain(e,t){let n=e;for(;n;){for(let e of t){let t=n.getAttribute(e);if(t)return t}n=n.parentElement}}static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItem(t){return e.readAttributeFromChain(t,[`data-froomle-id`,`data-froomle-action-item`])}static readActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-item-type`,`data-froomle-action-item-type`])}static readExplicitActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-action-item-type`])}static readUserGroup(t){var n;let r=e.readAttributeFromChain(t,[`data-froomle-user-group`]);if(r)return r;if(!(typeof document>`u`))return((n=document.querySelector(`[data-froomle-user-group]`))==null?void 0:n.getAttribute(`data-froomle-user-group`))||void 0}static registerClickables(){e.listenerRegistered||(e.listenerRegistered=!0,document.addEventListener(`click`,t=>{if(!e.canTrackEvents())return;let n=t instanceof MouseEvent?t:null,r=t.target,i=r instanceof Element?r:r instanceof Node?r.parentElement:null;if(!i)return;let a=i.closest(`a`);if(!a)return;let o=a.closest(`[data-froomle-id]`);if(!o)return;let s=a.closest(`[data-froomle-reco]`),c=(s?e.readActionItem(s):void 0)||e.readActionItem(o);if(!c)return;let l=e.readExplicitActionItemType(a)||(s?e.readActionItemType(s):void 0)||e.readActionItemType(o)||`article`,u=e.readChannel()||`www-desktop`,d=a instanceof HTMLAnchorElement?a.href:null,f=a.getAttribute(`href`),p=typeof f==`string`&&f.trim().startsWith(`#`),m=!!d&&!p&&t.cancelable&&!t.defaultPrevented&&!a.hasAttribute(`download`)&&(!a.target||a.target===`_self`)&&!!n&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey,h=p&&t.cancelable&&!t.defaultPrevented;(m||h)&&t.preventDefault();let g={event_type:`click_on_recommendation`,page_type:O.getPageVisit(),action_item:c,action_item_type:l,channel:u,device_id:e.readDeviceId()},_=(s?e.readUserGroup(s):void 0)||e.readUserGroup(o);_&&(g.user_group=_);let v=(s?e.readAttributeFromChain(s,[`data-froomle-reco`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-reco`]),y=(s?e.readAttributeFromChain(s,[`data-froomle-request-id`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-request-id`]);if(v&&y&&(g.list_name=v,g.request_id=y),O.getConsent()>=2&&O.getUserId()&&(g.user_id=O.getUserId()),m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);I([g],{keepalive:!0,allowBeaconFallback:!0}).catch(()=>{}).finally(()=>{window.clearTimeout(n),t()});return}I([g],{allowBeaconFallback:!0}).catch(()=>{})},!0))}};W.listenerRegistered=!1;const G=globalThis,K=`FroomleFrontendSdkIntegrationMode`;function be(){return G[K]||(G[K]={mode:null}),G[K]}function xe(e){let t=be();return t.mode?{accepted:t.mode===e,current:t.mode}:(t.mode=e,{accepted:!0,current:e})}const Se=M,Ce=F.setEnvironment,we=F.setPageVisit,Te=F.setRequestDomain,Ee=F.setSafeRequest,De=typeof F.setChannel==`function`?F.setChannel:O.setChannel,Oe=F.setRecommendationsAccessToken,ke=F.clearRecommendationsAccessToken,Ae=F.setRecommendationsAccessTokenProvider,je=F.clearRecommendationsAccessTokenProvider,Me=F.setContextItem,Ne=F.setContextItemType,Pe=O.addHistories;function Fe(e,t){F.setCustomVariable(e,t)}function Ie(e){Oe(e==null?null:e)}function Le(){ke()}function Re(e){Ae(e)}function ze(){je()}function Be(e){F.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Ve(e){F.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function He(e){F.setConsent(e),document.cookie=`froomle_consent=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`,document.cookie=`froomle_device_id=${F.getDeviceId()}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(e){return F.getRecommendations(e)}const J=globalThis,Y=`FroomleFrontendSdkState`,X=`FroomleFrontendSdkReady`;function Ue(){let e=()=>{},t=()=>{},n=new Promise((n,r)=>{e=n,t=r}),r={initStarted:!1,initialized:!1,beforeInitEventDispatched:!1,initEventDispatched:!1,readyPromise:n,resolveReady:e,rejectReady:t};return J[Y]=r,J[X]=n,r}function Z(){if(!J[Y])return Ue();let e=J[Y];return J[X]||(J[X]=e.readyPromise),e}function Q(){return J.FroomleFrontendSdk?J.FroomleFrontendSdk:{RecommendationItem:D,setPageVisit:we,setEnvironment:Ce,setConsent:He,setUserId:Be,setDeviceId:Ve,setRequestDomain:Te,setSafeRequest:Ee,setChannel:De,setRecommendationsBearer:Ie,clearRecommendationsBearer:Le,setRecommendationsBearerProvider:Re,clearRecommendationsBearerProvider:ze,setContextItem:Me,setContextItemType:Ne,setCustomVariable:Fe,getRecommendations:q,sendEvent:B,sendItemInteraction:V,sendUserInteraction:H,sendAddToCart:pe,sendRemoveFromCart:me,sendPurchase:he,addHistories:Pe,init:$}}function We(e){return{sdk:Q(),mode:e,version:typeof F.getVersion==`function`?F.getVersion():void 0}}function Ge(e,t){if(typeof window>`u`)return;if(typeof window.CustomEvent==`function`){window.dispatchEvent(new window.CustomEvent(e,{detail:t}));return}let n=document.createEvent(`CustomEvent`);n.initCustomEvent(e,!1,!1,t),window.dispatchEvent(n)}function Ke(e){let t=Z();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,Ge(`froomle:before-init`,We(e)))}function qe(e){let t=Z();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,Ge(`froomle:init`,We(e)))}function Je(e){let t=Z();t.initialized||(t.initialized=!0,t.resolveReady(Q())),qe(e)}function Ye(e){Z().rejectReady(e)}function Xe(e=`auto`){if(typeof document>`u`||!xe(`dom`).accepted)return Promise.resolve(Q());let t=Z();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{Ke(e),P.domInit(Se.fromDocument(document)).then(()=>{W.registerClickables(),U.processDocument(),ve.sendPageVisit(),ye.sendPageView(),Je(e)}).catch(e=>{Ye(e)});function t(e){return e.matches(`[data-froomle-reco]:not([data-froomle-framework])`)||e.querySelector(`[data-froomle-reco]:not([data-froomle-framework])`)!==null}new MutationObserver(e=>{for(let n of e)if(n.type===`childList`&&n.addedNodes.forEach(e=>{e instanceof Element&&(t(e)&&P.fillElementRecos(e),U.processElement(e))}),n.type===`attributes`&&n.target instanceof Element)if(n.attributeName===`data-froomle-reco`){if(n.target.hasAttribute(`data-froomle-framework`))continue;let e=n.target.getAttribute(`data-froomle-request-id`);(!e||e===``)&&P.fillElementRecos(n.target)}else if(n.attributeName===`data-froomle-request-id`){if(n.target.hasAttribute(`data-froomle-framework`))continue;let e=n.target.getAttribute(`data-froomle-request-id`),t=n.target.getAttribute(`data-froomle-id`);n.target.getAttribute(`data-froomle-reco`)&&(!e||e===``)&&(!t||t===``)&&P.fillElementRecos(n.target)}else n.attributeName===`data-froomle-id`&&U.processElement(n.target)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-froomle-reco`,`data-froomle-request-id`,`data-froomle-id`]})},r=()=>{globalThis.setTimeout(n,0)};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r,{once:!0}):r(),t.readyPromise}function $(){return Xe(`manual`)}export{O as A,U as C,he as D,V as E,D as M,me as O,ve as S,B as T,Ee as _,$ as a,W as b,Me as c,Ve as d,Ce as f,Te as g,Re as h,q as i,j,H as k,Ne as l,Ie as m,Le as n,De as o,we as p,ze as r,He as s,Pe as t,Fe as u,Be as v,pe as w,ye as x,xe as y};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./src-
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./src-EA0Sr8Ah.cjs`);let l=require(`react`);l=s(l);const u=new Set;function d({children:e,id:t}){return(0,l.useEffect)(()=>{!t||u.has(t)||(u.add(t),c.M.addHistories([t]))},[t]),l.default.createElement(l.default.Fragment,null,e)}function f({children:e,value:t}){return l.default.createElement(l.default.Fragment,null,e)}f.displayName=`FroomleOrderItem`;function p({children:e,list:t,category:n}){let[r,i]=l.default.useState(null);return l.default.createElement(l.default.Fragment,null,(()=>{let a=l.default.Children.toArray(e),o=[],s=[],u=[[]];for(let e of a)if(l.default.isValidElement(e)&&e.type===f){let t=e.props.value;o.push(t),s.push(e),u.push([])}else u[u.length-1].push(e);if(r){let e=[];for(let t of r){let n=o.indexOf(t);n!==-1&&(e.push(s[n]),e.push(...u[n+1]))}return e}else return c.M.getOrder(t,n,o).then(e=>{i(e)}),a})())}function m(e){return(0,l.useEffect)(()=>{let e=c.x(`framework`).accepted,t=globalThis.setTimeout(()=>{c.t().catch(()=>{}).finally(()=>{e&&(c.S.registerClickables(),c.T.processDocument(),c.w.sendPageVisit(),c.C.sendPageView())})},0);return()=>{globalThis.clearTimeout(t)}},[]),l.default.createElement(l.default.Fragment,null,e.children)}const h=(0,l.createContext)(null);function g(e,...t){for(let n of t){let t=e==null?void 0:e[n];if(t!=null&&t!==``&&t!==`undefined`)return String(t)}if(typeof(e==null?void 0:e.get)==`function`)for(let n of t){let t=e.get(n);if(t!=null&&t!==``&&t!==`undefined`)return String(t)}}function _(){var e;if(typeof document>`u`)return;let t=(e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`);if(t!=null&&t!==``&&t!==`undefined`)return String(t)}function v({reco:e,children:t,...n}){let r=(0,l.useRef)(null);return l.default.useEffect(()=>{let t=!1,n=e.__froomleList;return r.current&&(r.current.setAttribute(`data-froomle-framework`,`react`),n&&r.current.setAttribute(`data-froomle-reco`,n)),Promise.resolve(e).then(e=>{if(t||!r.current)return;let n=g(e,`Id`,`item_id`),i=g(e,`ItemType`,`item_type`),a=g(e,`RequestId`,`request_id`),o=g(e,`UserGroup`,`user_group`)||_();n&&r.current.setAttribute(`data-froomle-id`,n),i&&r.current.setAttribute(`data-froomle-item-type`,i),a&&r.current.setAttribute(`data-froomle-request-id`,a),o&&r.current.setAttribute(`data-froomle-user-group`,o)}).catch(()=>{}),()=>{t=!0}},[e]),l.default.createElement(h.Provider,{value:e},l.default.createElement(`div`,{ref:r,...n},t))}const y=()=>{let e=(0,l.useContext)(h);if(e===null)throw Error(`useFroomleReco must be used within a FroomleRecoProvider`);return e};function b(e){let t=(0,l.useRef)(null),[n,r]=(0,l.useState)(0);if(!t.current){let{list:n,filters:r,...i}=e;t.current=c.n({list:n,filters:r,others:Object.entries(i).map(([e,t])=>({key:e,value:t}))})}return(0,l.useEffect)(()=>{let e=!0;return Promise.resolve(t.current).then(()=>{e&&r(1)}).catch(()=>{e&&r(1)}),()=>{e=!1}},[]),t.current}exports.FroomleCustomItem=d,exports.FroomleOrder=p,exports.FroomleOrderItem=f,exports.FroomleReco=v,exports.FroomleSdkInit=m,exports.useCreateReco=b,exports.useReco=y;
|
package/dist/react.d.ts
CHANGED
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e,C as t,S as n,b as r,x as i,y as a}from"./js-BJHOFA94.js";import{n as o,t as s}from"./src-BzUJq6YD.js";import c,{createContext as l,useContext as u,useEffect as d,useRef as f,useState as p}from"react";const m=new Set;function h({children:t,id:n}){return d(()=>{!n||m.has(n)||(m.add(n),e.addHistories([n]))},[n]),c.createElement(c.Fragment,null,t)}function g({children:e,value:t}){return c.createElement(c.Fragment,null,e)}g.displayName=`FroomleOrderItem`;function _({children:t,list:n,category:r}){let[i,a]=c.useState(null);return c.createElement(c.Fragment,null,(()=>{let o=c.Children.toArray(t),s=[],l=[],u=[[]];for(let e of o)if(c.isValidElement(e)&&e.type===g){let t=e.props.value;s.push(t),l.push(e),u.push([])}else u[u.length-1].push(e);if(i){let e=[];for(let t of i){let n=s.indexOf(t);n!==-1&&(e.push(l[n]),e.push(...u[n+1]))}return e}else return e.getOrder(n,r,s).then(e=>{a(e)}),o})())}function v(e){return d(()=>{let e=a(`framework`).accepted,o=globalThis.setTimeout(()=>{s().catch(()=>{}).finally(()=>{e&&(r.registerClickables(),t.processDocument(),n.sendPageVisit(),i.sendPageView())})},0);return()=>{globalThis.clearTimeout(o)}},[]),c.createElement(c.Fragment,null,e.children)}const y=l(null);function b(e,...t){for(let n of t){let t=e==null?void 0:e[n];if(t!=null&&t!==``&&t!==`undefined`)return String(t)}if(typeof(e==null?void 0:e.get)==`function`)for(let n of t){let t=e.get(n);if(t!=null&&t!==``&&t!==`undefined`)return String(t)}}function x(){var e;if(typeof document>`u`)return;let t=(e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`);if(t!=null&&t!==``&&t!==`undefined`)return String(t)}function S({reco:e,children:t,...n}){let r=f(null);return c.useEffect(()=>{let t=!1,n=e.__froomleList;return r.current&&(r.current.setAttribute(`data-froomle-framework`,`react`),n&&r.current.setAttribute(`data-froomle-reco`,n)),Promise.resolve(e).then(e=>{if(t||!r.current)return;let n=b(e,`Id`,`item_id`),i=b(e,`ItemType`,`item_type`),a=b(e,`RequestId`,`request_id`),o=b(e,`UserGroup`,`user_group`)||x();n&&r.current.setAttribute(`data-froomle-id`,n),i&&r.current.setAttribute(`data-froomle-item-type`,i),a&&r.current.setAttribute(`data-froomle-request-id`,a),o&&r.current.setAttribute(`data-froomle-user-group`,o)}).catch(()=>{}),()=>{t=!0}},[e]),c.createElement(y.Provider,{value:e},c.createElement(`div`,{ref:r,...n},t))}const C=()=>{let e=u(y);if(e===null)throw Error(`useFroomleReco must be used within a FroomleRecoProvider`);return e};function w(e){let t=f(null),[n,r]=p(0);if(!t.current){let{list:n,filters:r,...i}=e;t.current=o({list:n,filters:r,others:Object.entries(i).map(([e,t])=>({key:e,value:t}))})}return d(()=>{let e=!0;return Promise.resolve(t.current).then(()=>{e&&r(1)}).catch(()=>{e&&r(1)}),()=>{e=!1}},[]),t.current}export{h as FroomleCustomItem,_ as FroomleOrder,g as FroomleOrderItem,S as FroomleReco,v as FroomleSdkInit,w as useCreateReco,C as useReco};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,
|
|
1
|
+
import{A as e,j as t}from"./js-BJHOFA94.js";function n(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const r=[];function i(){var e;return typeof document>`u`?``:((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||``}function a(e,t){var n;let r=e,i=((n=r==null?void 0:r.UserGroup)==null?typeof(r==null?void 0:r.get)==`function`?r.get(`user_group`):void 0:n)||t;if(i&&(r.UserGroup=i,typeof(r==null?void 0:r.getData)==`function`)){let e=r.getData();e&&(!e.user_group||e.user_group===``)&&(e.user_group=i)}}async function o(){let t=r.splice(0,r.length);if(t.length!==0)try{let n=t.map(e=>e.req),r=e.requestsToLists(n),i=await e.getRawRecommendations(r),o=i.user_group||``;typeof document<`u`&&o&&document.documentElement.setAttribute(`data-froomle-user-group`,o);let s=i.lists().reduce((e,t)=>[...e,...t.items],[]);s.forEach(e=>a(e,o)),t.forEach((e,t)=>{s[t]?e.deferred.resolve(s[t]):e.deferred.reject(Error(`No recommendation available`))})}catch(e){throw t.forEach(t=>{t.deferred.reject(e)}),e}}function s(e){let t,n,i={promise:new Promise((e,r)=>{t=e,n=r}),resolve:t,reject:n};return r.push({deferred:i,req:e}),i}function c(e){let r=s(e).promise;n();let a=function(e,t){return r.then(t=>(o.completeTarget=t,e?e(t):t),e=>t?t(e):Promise.reject(e))},o=new Proxy(new t({item_id:``,request_id:``,user_group:``}),{get(t,n,r){if(n===`then`)return a;if(n===`__froomleList`)return e.list;if(n===`get`){let e=Reflect.get(t,n,r);return function(...t){return e.apply(this,t)}}if(typeof n!=`string`)return Reflect.get(t,n,r);let i=Reflect.get(t,n,r);if(i!=null&&i!==``)return i;let o=t.get(n);return o!=null&&o!==``?o:``},set(e,t,n,r){if(t===`completeTarget`){if(Object.assign(e,n),!e.UserGroup){let t=i();if(t){e.UserGroup=t;let n=e.getData();n&&!n.user_group&&(n.user_group=t)}}return!0}return Reflect.set(e,t,n,r)},has(e,t){return e.get(t)!==void 0}});return o}export{c as n,o as t};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var e=class e{static global(t){return e.globals[t]?e.globals[t]:e.globals[t]={}}static createStatic(e,t,n){let r=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return n!=null&&(r=n(),n=null),r},set:function(e){n!=null&&(r=n(),n=null),r=e}})}static iterator(t){if(Array.isArray(t)){let n=t;return function(){return e.mkIter(n)}}else return typeof t.iterator==`function`?t.iterator.bind(t):t.iterator}static getIterator(t){return Array.isArray(t)?e.mkIter(t):t.iterator()}static mkIter(e){return new t(e)}static extend(t){function n(){this[e.new].apply(this,arguments)}return Object.setPrototypeOf(n.prototype,t.prototype),n}static inherits(t,n){n==null&&(n=!1);function r(){n&&t&&r[e.init]&&r[e.init](),this[e.new].apply(this,arguments)}return n?r[e.init]=()=>{let n=t();n[e.init]&&n[e.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[e.init]=void 0}:t&&t[e.init]?(n=!0,r[e.init]=()=>{t[e.init]&&t[e.init](),Object.setPrototypeOf(r.prototype,t.prototype),r[e.init]=void 0}):t&&Object.setPrototypeOf(r.prototype,t.prototype),r}static bind(t,n){if(n==null)return null;n.__id__==null&&(n.__id__=e.fid++);let r=null;return t.hx__closures__==null?t.hx__closures__={}:r=t.hx__closures__[n.__id__],r==null&&(r=n.bind(t),t.hx__closures__[n.__id__]=r),r}static get __name__(){return`genes.Register`}get __class__(){return e}};e.$global=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:void 0,e.globals={},e.new=Symbol(),e.init=Symbol(),e.fid=0;const t=e.global(`$hxClasses`)[`genes._Register.ArrayIterator`]=class t extends e.inherits(){[e.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return`genes._Register.ArrayIterator`}get __class__(){return t}};t.prototype.array=null,t.prototype.current=null,e.$global;const n=e.global(`$hxClasses`)[`haxe.ValueException`]=class t extends e.inherits(()=>r,!0){[e.new](t,n,r){super[e.new](String(t),n,r),this.value=t}unwrap(){return this.value}static get __name__(){return`haxe.ValueException`}static get __super__(){return r}get __class__(){return t}};n.prototype.value=null,e.$global;const r=e.global(`$hxClasses`)[`haxe.Exception`]=class t extends e.inherits(()=>Error,!0){[e.new](e,t,n){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=n==null?this:n}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof t?e:e instanceof Error?new t(e.message,null,e):new n(e,null,e)}static thrown(e){return e instanceof t?e.get_native():e instanceof Error?e:new n(e)}static get __name__(){return`haxe.Exception`}static get __super__(){return Error}get __class__(){return t}};r.prototype.native=null,r.prototype.__skipStack=null,r.prototype.__nativeException=null,r.prototype.__previousException=null,e.$global;const i=e.global(`$hxClasses`).Std=class e{static string(e){return a.__string_rec(e,``)}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static random(e){return e<=0?0:Math.floor(Math.random()*e)}static get __name__(){return`Std`}get __class__(){return e}};Object.defineProperty(String.prototype,`__class__`,{value:String,enumerable:!1,writable:!0}),String.__name__=!0,Array.__name__=!0,e.$global;const a=e.global(`$hxClasses`)[`js.Boot`]=class t{static getClass(e){if(e==null)return null;if(e instanceof Array)return Array;{let n=e.__class__;if(n!=null)return n;let r=t.__nativeClassName(e);return r==null?null:t.__resolveNativeClass(r)}}static __string_rec(n,r){if(n==null)return`null`;if(r.length>=5)return`<...>`;let i=typeof n;switch(i==`function`&&(n.__name__||n.__ename__)&&(i=`object`),i){case`function`:return`<function>`;case`object`:if(n.__enum__){let i=e.global(`$hxEnums`)[n.__enum__].__constructs__[n._hx_index],a=i._hx_name;return i.__params__?(r+=` `,a+`(`+(function(e){var a;let o=[];{let e=0,a=i.__params__;for(;e<a.length;){let i=a[e];e+=1,o.push(t.__string_rec(n[i],r))}}return a=o,a})(this).join(`,`)+`)`):a}if(n instanceof Array){let e=`[`;r+=` `;let i=0,a=n.length;for(;i<a;){let a=i++;e+=(a>0?`,`:``)+t.__string_rec(n[a],r)}return e+=`]`,e}let i;try{i=n.toString}catch{return`???`}if(i!=null&&i!=Object.toString&&typeof i==`function`){let e=n.toString();if(e!=`[object Object]`)return e}let a=`{
|
|
2
|
+
`;r+=` `;let o=n.hasOwnProperty!=null,s=null;for(s in n)o&&!n.hasOwnProperty(s)||s==`prototype`||s==`__class__`||s==`__super__`||s==`__interfaces__`||s==`__properties__`||(a.length!=2&&(a+=`,
|
|
3
|
+
`),a+=r+s+` : `+t.__string_rec(n[s],r));return r=r.substring(1),a+=`
|
|
4
|
+
`+r+`}`,a;case`string`:return n;default:return String(n)}}static __interfLoop(e,n){if(e==null)return!1;if(e==n)return!0;let r=e.__interfaces__;if(r!=null&&(e.__super__==null||e.__super__.__interfaces__!=r)){let e=0,i=r.length;for(;e<i;){let i=r[e++];if(i==n||t.__interfLoop(i,n))return!0}}return t.__interfLoop(e.__super__,n)}static __instanceof(n,r){if(r==null)return!1;switch(r){case Array:return n instanceof Array;case`$hxCoreType__Bool`:return typeof n==`boolean`;case`$hxCoreType__Dynamic`:return n!=null;case`$hxCoreType__Float`:return typeof n==`number`;case`$hxCoreType__Int`:return typeof n==`number`?(n|0)===n:!1;case String:return typeof n==`string`;default:if(n!=null){if(typeof r==`function`){if(t.__downcastCheck(n,r))return!0}else if(typeof r==`object`&&t.__isNativeObj(r)&&n instanceof r)return!0}else return!1;return r==`$hxCoreType__Class`&&n.__name__!=null||r==`$hxCoreType__Enum`&&n.__ename__!=null?!0:n.__enum__==null?!1:e.global(`$hxEnums`)[n.__enum__]==r}}static __downcastCheck(e,n){return e instanceof n?!0:n.__isInterface__?t.__interfLoop(t.getClass(e),n):!1}static __cast(e,n){if(e==null||t.__instanceof(e,n))return e;throw r.thrown(`Cannot cast `+i.string(e)+` to `+i.string(n))}static __nativeClassName(e){let n=t.__toStr.call(e).slice(8,-1);return n==`Object`||n==`Function`||n==`Math`||n==`JSON`?null:n}static __isNativeObj(e){return t.__nativeClassName(e)!=null}static __resolveNativeClass(t){return e.$global[t]}static get __name__(){return`js.Boot`}get __class__(){return t}};a.__toStr={}.toString,e.$global;const o=e.global(`$hxClasses`)[`js.Browser`]=class e{static get supported(){return this.get_supported()}static get_supported(){return typeof window<`u`&&window.location!==void 0?typeof window.location.protocol==`string`:!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest<`u`)return new XMLHttpRequest;if(typeof ActiveXObject<`u`)return new`ActiveXObject`(`Microsoft.XMLHTTP`);throw r.thrown(`Unable to create XMLHttpRequest object.`)}static get __name__(){return`js.Browser`}get __class__(){return e}};e.$global;const s=e.global(`$hxEnums`)[`haxe.io.Error`]={__ename__:`haxe.io.Error`,Blocked:{_hx_name:`Blocked`,_hx_index:0,__enum__:`haxe.io.Error`},Overflow:{_hx_name:`Overflow`,_hx_index:1,__enum__:`haxe.io.Error`},OutsideBounds:{_hx_name:`OutsideBounds`,_hx_index:2,__enum__:`haxe.io.Error`},Custom:Object.assign(e=>({_hx_index:3,__enum__:`haxe.io.Error`,e}),{_hx_name:`Custom`,__params__:[`e`]})};s.__constructs__=[s.Blocked,s.Overflow,s.OutsideBounds,s.Custom],s.__empty_constructs__=[s.Blocked,s.Overflow,s.OutsideBounds],e.$global;const c=e.global(`$hxEnums`)[`haxe.io.Encoding`]={__ename__:`haxe.io.Encoding`,UTF8:{_hx_name:`UTF8`,_hx_index:0,__enum__:`haxe.io.Encoding`},RawNative:{_hx_name:`RawNative`,_hx_index:1,__enum__:`haxe.io.Encoding`}};c.__constructs__=[c.UTF8,c.RawNative],c.__empty_constructs__=[c.UTF8,c.RawNative],e.$global;const l=e.global(`$hxClasses`)[`haxe.io.Bytes`]=class t extends e.inherits(){[e.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,n){if(e<0||t<0||e+t>this.length)throw r.thrown(s.OutsideBounds);n==null&&(n=c.UTF8);let i=``,a=this.b,o=e,l=e+t;switch(n._hx_index){case 0:for(;o<l;){let e=a[o++];if(e<128){if(e==0)break;i+=String.fromCodePoint(e)}else if(e<224){let t=(e&63)<<6|a[o++]&127;i+=String.fromCodePoint(t)}else if(e<240){let t=a[o++],n=(e&31)<<12|(t&127)<<6|a[o++]&127;i+=String.fromCodePoint(n)}else{let t=a[o++],n=a[o++],r=(e&15)<<18|(t&127)<<12|(n&127)<<6|a[o++]&127;i+=String.fromCodePoint(r)}}break;case 1:for(;o<l;){let e=a[o++]|a[o++]<<8;i+=String.fromCodePoint(e)}break}return i}static ofData(e){let n=e.hxBytes;return n==null?new t(e):n}static get __name__(){return`haxe.io.Bytes`}get __class__(){return t}};l.prototype.length=null,l.prototype.b=null,e.$global;const u=e.global(`$hxClasses`)[`haxe.http.HttpBase`]=class t extends e.inherits(){[e.new](t){this.url=t,this.headers=[],this.params=[],this.emptyOnData=e.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let n=0,r=this.headers.length;for(;n<r;){let r=n++;if(this.headers[r].name==e){this.headers[r]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return e.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,c.UTF8)),this.responseAsString}static get __name__(){return`haxe.http.HttpBase`}get __class__(){return t}};u.prototype.url=null,u.prototype.responseBytes=null,u.prototype.responseAsString=null,u.prototype.postData=null,u.prototype.postBytes=null,u.prototype.headers=null,u.prototype.params=null,u.prototype.emptyOnData=null,e.$global;const d=e.global(`$hxClasses`)[`haxe.iterators.MapKeyValueIterator`]=class t extends e.inherits(){[e.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return`haxe.iterators.MapKeyValueIterator`}get __class__(){return t}};d.prototype.map=null,d.prototype.keys=null,e.$global;const f=function(){};f.__isInterface__=!0,e.$global;const p=e.global(`$hxClasses`)[`genes.util.EsMap`]=class t extends e.inherits(){[e.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return t.adaptIterator(this.inst.keys())}iterator(){return t.adaptIterator(this.inst.values())}toString(){let e=[],n=t.adaptIterator(this.inst.keys());for(;n.hasNext();){let t=n.next();e.push(``+i.string(t)+` => `+i.string(this.inst.get(t)))}return`{`+e.join(`, `)+`}`}clear(){this.inst.clear()}static adaptIterator(e){let t,n,r=function(){let r=e.next();t=r.value,n=r.done};return{hasNext:function(){return n==null&&r(),!n},next:function(){n==null&&r();let e=t;return r(),e}}}static get __name__(){return`genes.util.EsMap`}get __class__(){return t}};p.prototype.inst=null,e.$global;const m=e.global(`$hxClasses`)[`haxe.ds.StringMap`]=class t extends e.inherits(p){[e.new](){super[e.new]()}copy(){let e=new t;return e.inst=new Map(this.inst),e}keyValueIterator(){return new d(this)}static get __name__(){return`haxe.ds.StringMap`}static get __interfaces__(){return[f]}static get __super__(){return p}get __class__(){return t}};e.$global;const h=e.global(`$hxClasses`).HxOverrides=class e{static cca(e,t){let n=e.charCodeAt(t);if(n==n)return n}static substr(e,t,n){if(n==null)n=e.length;else if(n<0)if(t==0)n=e.length+n;else return``;return e.substr(t,n)}static now(){return Date.now()}static get __name__(){return`HxOverrides`}get __class__(){return e}};typeof performance<`u`&&typeof performance.now==`function`&&(h.now=performance.now.bind(performance)),e.$global;const g=e.global(`$hxClasses`).StringTools=class e{static isSpace(e,t){let n=h.cca(e,t);return n>8&&n<14?!0:n==32}static ltrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,r);)++r;return r>0?h.substr(t,r,n-r):t}static rtrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,n-r-1);)++r;return r>0?h.substr(t,0,n-r):t}static trim(t){return e.ltrim(e.rtrim(t))}static replace(e,t,n){return e.split(t).join(n)}static get __name__(){return`StringTools`}get __class__(){return e}};e.$global;const _=e.global(`$hxClasses`).Lambda=class t{static exists(t,n){let r=e.getIterator(t);for(;r.hasNext();)if(n(r.next()))return!0;return!1}static get __name__(){return`Lambda`}get __class__(){return t}};e.$global;const v=e.global(`$hxClasses`).EReg=class t extends e.inherits(){[e.new](e,t){this.r=new RegExp(e,t.split(`u`).join(``))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw r.thrown(`EReg::matched`)}matchedPos(){if(this.r.m==null)throw r.thrown(`No string matched`);return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,n){if(n==null&&(n=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(n<0?e:h.substr(e,0,t+n));let r=this.r.m!=null;return r&&(this.r.s=e),r}else{let r=this.match(n<0?h.substr(e,t,null):h.substr(e,t,n));return r&&(this.r.s=e,this.r.m.index+=t),r}}map(e,t){let n=0,r=``;do{if(n>=e.length)break;if(!this.matchSub(e,n)){r+=i.string(h.substr(e,n,null));break}let a=this.matchedPos();r+=i.string(h.substr(e,n,a.pos-n)),r+=i.string(t(this)),a.len==0?(r+=i.string(h.substr(e,a.pos,1)),n=a.pos+1):n=a.pos+a.len}while(this.r.global);return!this.r.global&&n>0&&n<e.length&&(r+=i.string(h.substr(e,n,null))),r}static get __name__(){return`EReg`}get __class__(){return t}};v.prototype.r=null,e.$global;const y=e.global(`$hxClasses`)[`haxe.http.HttpJs`]=class t extends e.inherits(u){[e.new](t){this.async=!0,this.withCredentials=!1,super[e.new](t)}request(t){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let n=this.req=o.createXMLHttpRequest(),a=this,s=function(t){if(n.readyState!=4)return;let r;try{r=n.status}catch{r=null}if(r==0&&o.get_supported()&&e.$global.location!=null){let t=e.$global.location.protocol.toLowerCase();new v(`^(?:about|app|app-storage|.+-extension|file|res|widget):$`,``).match(t)&&(r=n.response==null?404:200)}if(r==null&&(r=null),r!=null&&a.onStatus(r),r!=null&&r>=200&&r<400){a.req=null;let e=n.getAllResponseHeaders().split(`\r
|
|
5
|
+
`),t=[],r=0,i=e;for(;r<i.length;){let e=i[r];++r,e!=``&&t.push(e)}e=t,a.responseHeaders=new m;let o=0;for(;o<e.length;){let t=e[o];++o;let n=t.split(`: `),r=n.shift(),i=n.length==1?n[0]:n.join(`: `);i=g.ltrim(g.rtrim(i)),a.responseHeaders.inst.set(r,i)}a.success(l.ofData(n.response))}else if(r==null||r==0&&n.response==null)a.req=null,a.onError(`Failed to connect or resolve host`);else if(r==null)a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status);else switch(r){case 12007:a.req=null,a.onError(`Unknown host`);break;case 12029:a.req=null,a.onError(`Failed to connect to host`);break;default:a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status)}};this.async&&(n.onreadystatechange=s);let c,u=this.postData,d=this.postBytes;if(u==null)if(d==null)c=null;else{let e=d;c=new Blob([e.b.bufferValue])}else c=d==null?u:null;if(c!=null)t=!0;else{let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,c=c==null?``:(c==null?`null`:i.string(c))+`&`;let r=n.name,a=(c==null?`null`:i.string(c))+encodeURIComponent(r)+`=`,o=n.value;c=a+encodeURIComponent(o)}}try{if(t)n.open(`POST`,this.url,this.async);else if(c!=null){let e=this.url.split(`?`).length<=1;n.open(`GET`,this.url+(e?`?`:`&`)+(c==null?`null`:i.string(c)),this.async),c=null}else n.open(`GET`,this.url,this.async);n.responseType=`arraybuffer`}catch(e){let t=r.caught(e).unwrap();this.req=null,this.onError(t.toString());return}n.withCredentials=this.withCredentials,!_.exists(this.headers,function(e){return e.name==`Content-Type`})&&t&&this.postData==null&&n.setRequestHeader(`Content-Type`,`application/x-www-form-urlencoded`);let f=0,p=this.headers;for(;f<p.length;){let e=p[f];++f,n.setRequestHeader(e.name,e.value)}n.send(c),this.async||s(null)}static get __name__(){return`haxe.http.HttpJs`}static get __super__(){return u}get __class__(){return t}};y.prototype.async=null,y.prototype.withCredentials=null,y.prototype.responseHeaders=null,y.prototype.req=null,e.$global;const b=e.global(`$hxClasses`).Type=class e{static createInstance(e,t){return new(Function.prototype.bind.apply(e,[null].concat(t)))}static get __name__(){return`Type`}get __class__(){return e}};e.$global;const x=e.global(`$hxClasses`).Reflect=class e{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let n;if(e==null)return null;{let r;return e.__properties__?(n=e.__properties__[`get_`+t],r=n):r=!1,r?e[n]():e[t]}}static setProperty(e,t,n){let r,i;e.__properties__?(r=e.__properties__[`set_`+t],i=r):i=!1,i?e[r](n):e[t]=n}static fields(e){let t=[];if(e!=null){let r=Object.prototype.hasOwnProperty;for(var n in e)n!=`__id__`&&n!=`hx__closures__`&&r.call(e,n)&&t.push(n)}return t}static compare(e,t){return e==t?0:e>t?1:-1}static get __name__(){return`Reflect`}get __class__(){return e}};e.$global;const S=e.global(`$hxClasses`)[`internal.http.FetchHttp`]=class t extends e.inherits(y){[e.new](t){this.responseStatus=0,super[e.new](t)}request(t){let n=e.$global,a=n.fetch,o=n.Headers,s=n.URLSearchParams;if(a==null){this.onError(`Fetch API not found.`);return}let c=b.createInstance(o,[]),l=0,u=this.headers;for(;l<u.length;){let e=u[l];++l,c.append(e.name,e.value)}let d=t?`POST`:`GET`,f=null;if(t)if(this.postData!=null)f=this.postData;else{f=b.createInstance(s,[]);let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,f.append(n.name,n.value)}}let p={method:d,headers:c,body:f},m=this,h=a(this.url,p).then(function(e){if(m.responseStatus=e.status,m.onStatus(e.status),e.ok)return e.text();throw r.thrown(`HTTP Error: `+i.string(e.status))}).then(function(e){m.onData(e)}),g=x.field(h,`catch`);g!=null&&g.apply(h,[function(e){m.onError(i.string(e))}])}static get __name__(){return`internal.http.FetchHttp`}static get __super__(){return y}get __class__(){return t}};S.prototype.responseStatus=null,e.$global;const C=e.global(`$hxClasses`)[`internal.data.UUID`]=class e{static randomHexChar(){return`0123456789abcdef`.charAt(i.random(16))}static v4(){let e=``,t=0;for(;t<36;)switch(t++){case 14:e+=`4`;break;case 19:e+=i.string(`0123456789abcdef`.charAt(8+i.random(4)));break;case 8:case 13:case 18:case 23:e+=`-`;break;default:e+=i.string(`0123456789abcdef`.charAt(i.random(16)))}return e}static get __name__(){return`internal.data.UUID`}get __class__(){return e}};C.HEX=`0123456789abcdef`,e.$global;const w=e.global(`$hxClasses`)[`internal.RecoRequestGrouping`]=class e{static normalizeFilters(e){let t=[];if(e==null)return t;let n=0;for(;n<e.length;){let r=e[n];++n,!(r==null||r.key==null||r.key==``)&&t.push({key:r.key,value:r.value})}return t}static tuplesSame(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(x.compare),l.sort(x.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0}static groupSequential(t){let n=[],r=null,i=0;for(;i<t.length;){let a=t[i];if(++i,r==null){r={list_name:a.list_name,filters:a.filters,others:a.others,entries:[a.entry]};continue}if(r.list_name==a.list_name&&e.tuplesSame(r.filters,a.filters)&&e.tuplesSame(r.others,a.others)){r.entries.push(a.entry);continue}n.push(r),r={list_name:a.list_name,filters:a.filters,others:a.others,entries:[a.entry]}}return r!=null&&n.push(r),n}static toRequestLists(e){let t=[],n=0;for(;n<e.length;){let r=e[n];++n;let i={limit:r.entries.length,list_name:r.list_name,list_size:r.entries.length},a=0,o=r.filters;for(;a<o.length;){let e=o[a];++a;let t=e.value;t instanceof Array||(t=[t]),i[e.key]=t}let s=0,c=r.others;for(;s<c.length;){let e=c[s];++s,i[e.key]=e.value}t.push(i)}return t}static get __name__(){return`internal.RecoRequestGrouping`}get __class__(){return e}};e.$global;const T=function(){};T.__isInterface__=!0;const E=function(){};E.__isInterface__=!0;const D=function(){};D.__isInterface__=!0,e.$global;const O=e.global(`$hxClasses`)[`internal.RecommendationBackend`]=class t extends e.inherits(){[e.new](){}static _requestUri(){return(t._safe_request?`https://`:`http://`)+t._req_domain+`/api/`+t._environment+`/recommendations/requests`}static noConsentBody(){return{device_id:`no-consent`,user_group:`no-consent`,version:`no-consent`}}static buildRequestBody(e){let n={lists:e,page_type:t._page_visit,channel:t._channel};if(t._consent>=2&&t._history.length>0&&(n.histories=t._buildHistories()),t._consent<2){let e=t.noConsentBody(),r=0,i=x.fields(e);for(;r<i.length;){let t=i[r];++r,n[t]=x.field(e,t)}}else t._user_id!=null&&(n.user_id=t._user_id),n.device_id=t._device_id;let r=0,a=t._others;for(;r<a.length;){let e=a[r];++r,n[e.key]=e.value}let o=x.field(n,`context_item`),s=x.field(n,`context_item_type`);return o!=null&&i.string(o)!=``&&(s==null||i.string(s)==``)&&(n.context_item_type=`article`),n}static _buildHistories(){return{pageviews:t._history}}static normalizeAccessToken(e){if(e==null)return null;let t=i.string(e);return t==``?null:t}static hasRecommendationsAccessTokenProvider(){return t._recommendations_access_token_provider!=null}static resolveRecommendationsAccessToken(e){if(!e){let e=t.normalizeAccessToken(t._recommendations_access_token);if(e!=null)return Promise.resolve(e)}if(!t.hasRecommendationsAccessTokenProvider())return Promise.resolve(t.normalizeAccessToken(t._recommendations_access_token));let n=null;try{n=t._recommendations_access_token_provider.apply(null,[{forceRefresh:e}])}catch(e){let t=r.caught(e).unwrap();return Promise.reject(t)}return Promise.resolve(n).then(function(e){let n=t.normalizeAccessToken(e);return t._recommendations_access_token=n,n})}static requestsToLists(e){let t=Array(e.length),n=0,r=e.length;for(;n<r;){let r=n++,i=e[r];t[r]={list_name:i.list,filters:w.normalizeFilters(i.filters),others:i.others==null?[]:i.others,entry:i}}let i=t;return w.toRequestLists(w.groupSequential(i))}static _requestRecos(e){let n=null,a=null,o=new Promise(function(e,t){n=e,a=t}),s=o;s._resolve=n,s._reject=a,s._isFinished=!1,s._result=null,s._error=null;let c=o,l=!1,u=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))},d=null;return d=function(n,a){if(l)return;let o=!1,s=!1,f=new S(t._requestUri());f.setHeader(`Content-Type`,`application/json`),f.setHeader(`X-Froomle-Client`,`frontend-sdk/0.1.0`);let p=t.normalizeAccessToken(n);p!=null&&f.setHeader(`Authorization`,`Bearer `+p);let m=t.buildRequestBody(e),h=JSON.stringify(m);f.setPostData(h),f.onError=function(e){o||s||l||(o=!0,u(`HTTP Request Error: `+e))},f.onStatus=function(e){if(!(o||l)){if(e==401&&a&&t.hasRecommendationsAccessTokenProvider()){o=!0,s=!0,t.resolveRecommendationsAccessToken(!0).then(function(e){return l?null:e==null?(u(`Recommendation access token provider returned no token during refresh.`),null):(d(e,!1),null)},function(e){return u(`Failed to refresh recommendation access token: `+i.string(e)),null});return}(e<200||e>=300)&&(o=!0,u(`HTTP Status Error: `+e))}};try{f.request(!0)}catch(e){let t=r.caught(e).unwrap();if(o||l)return;o=!0,u(`Failed to execute recommendation request: `+i.string(t));return}let g=function(e){if(!(o||s||l))try{let t=JSON.parse(e),n=k.fromRequestData(t);o=!0,l=!0;let r=c;r._isFinished||(r._result=n,r._error=null,r._isFinished=!0,r._resolve(n))}catch(e){let t=r.caught(e).unwrap();o=!0,u(`Failed to parse recommendation response: `+i.string(t))}},_=f.get_responseData();_==null?!o&&!s&&!l&&(f.onData=g):g(_)},t.resolveRecommendationsAccessToken(!1).then(function(e){return l?null:t.hasRecommendationsAccessTokenProvider()&&e==null?(u(`Recommendation access token provider returned no token.`),null):(d(e,t.hasRecommendationsAccessTokenProvider()),null)},function(e){return u(`Failed to resolve recommendation access token: `+i.string(e)),null}),c}static getOrder(e,n,a){let o={list_name:e,limit:a.length,list_size:a.length},s={};x.setProperty(s,n,a),x.setProperty(o,`order`,s);let c=null,l=null,u=new Promise(function(e,t){c=e,l=t}),d=u;d._resolve=c,d._reject=l,d._isFinished=!1,d._result=null,d._error=null;let f=u;return t.getRawRecommendations([o]).then(function(e){try{let t=[],n=e.lists();if(n!=null&&n.length>0){let e=n[0].items;if(e instanceof Array){let n=0,r=e;for(;n<r.length;){let e=r[n];++n;let i=e.get(`categories`);i!=null&&t.push(i)}}}let r=f;r._isFinished||(r._result=t,r._error=null,r._isFinished=!0,r._resolve(t))}catch(e){let t=r.caught(e).unwrap(),n=`Failed to build order response: `+i.string(t),a=f;a._isFinished||(a._error=n,a._isFinished=!0,a._reject(n))}},function(e){let t=f;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))}),f}static getRawRecommendations(e){return t._requestRecos(e)}static addHistories(e,n){if(n==null&&(n=`article`),e==null||e.length==0)return;let r=n!=null&&n!=``?n:`article`,a=0;for(;a<e.length;){let n=e[a];if(++a,typeof n==`string`){let e=i.string(n);e!=``&&t._history.push({id:e,item_type:r});continue}let o=n,s=x.field(o,`id`);if(s==null)continue;let c=i.string(s);if(c==``)continue;let l=x.field(o,`item_type`);(l==null||i.string(l)==``)&&(l=x.field(o,`itemType`));let u=l!=null&&i.string(l)!=``?i.string(l):r;t._history.push({id:c,item_type:u})}}static setOthers(e,n){let r=0,i=t._others;for(;r<i.length;){let t=i[r];if(++r,t.key==e){t.value=n;return}}t._others.push({key:e,value:n})}static setConsent(e){e>2&&(e=2),t._consent=e,e==2&&t.getDeviceId()==`no-consent`&&t.setDeviceId(C.v4())}static setChannel(e){t._channel=e}static setPageVisit(e){t._page_visit=e}static setEnvironment(e){t._environment=e}static setDeviceId(e){t._device_id=e}static setUserId(e){t._user_id=e}static setRequestDomain(e){t._req_domain=e}static setRecommendationsAccessToken(e){t._recommendations_access_token=t.normalizeAccessToken(e)}static clearRecommendationsAccessToken(){t._recommendations_access_token=null}static setRecommendationsAccessTokenProvider(e){t._recommendations_access_token_provider=e}static clearRecommendationsAccessTokenProvider(){t._recommendations_access_token_provider=null}static setSafeRequest(e){t._safe_request=e}static setContextItem(e){t.setOthers(`context_item`,e)}static setContextItemType(e){t.setOthers(`context_item_type`,e)}static getRequestDomain(){return t._req_domain}static getSafeRequest(){return t._safe_request}static getEnvironment(){return t._environment}static getPageVisit(){return t._page_visit}static getUserId(){return t._user_id}static getDeviceId(){return t._device_id}static getConsent(){return t._consent}static getChannel(){return t._channel}static getOthers(e){let n=0,r=t._others;for(;n<r.length;){let t=r[n];if(++n,e==t.key)return t.value}return null}static getContextItem(){return t.getOthers(`context_item`)}static getContextItemType(){return t.getOthers(`context_item_type`)}static get __name__(){return`internal.RecommendationBackend`}get __class__(){return t}};O._environment=null,O._device_id=`no-consent`,O._user_id=null,O._consent=0,O._req_domain=`europe-west1.froomle.com`,O._page_visit=null,O._channel=`www-desktop`,O._safe_request=!0,O._history=[],O._others=[],O._recommendations_access_token=null,O._recommendations_access_token_provider=null;const k=e.global(`$hxClasses`)[`internal._RecommendationsInternal`]=class t extends e.inherits(){[e.new](e,t,n,r,i){this.request_id=t,this.user_group=n,this.device_id=e,this.user_id=r,this._lists=i}items(){let e=[],t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i=0,a=r.items;for(;i<a.length;){let t=a[i];++i,e.push(t)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,n=this._lists;for(;t<n.length;){let r=n[t];if(++t,r.list_name==e)return r}return null}toJson(){let e={request_id:this.request_id,user_group:this.user_group,user_id:this.user_id,device_id:this.device_id,lists:[]},t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i={limit:r.limit,list_key:r.list_key,list_name:r.list_name,list_size:r.list_size,items:[]},o=0,s=r.items;for(;o<s.length;){let e=s[o];++o,i.items.push(a.__cast(e,j).getData())}e.lists.push(i)}return JSON.stringify(e)}static fromRequestData(e){let n=x.getProperty(e,`lists`),r=[],i=0;for(;i<n.length;){let t=n[i];++i;let a=x.getProperty(t,`items`),o=[],s=0;for(;s<a.length;){let t=a[s];++s,x.setProperty(t,`request_id`,x.getProperty(e,`request_id`)),x.setProperty(t,`user_group`,x.getProperty(e,`user_group`)),o.push(new j(t))}let c=new A({limit:x.getProperty(t,`limit`),list_key:x.getProperty(t,`list_key`),list_name:x.getProperty(t,`list_name`),list_size:x.getProperty(t,`list_size`),items:o,request_id:x.getProperty(e,`request_id`)});r.push(c)}return new t(x.getProperty(e,`device_id`),x.getProperty(e,`request_id`),x.getProperty(e,`user_group`),x.getProperty(e,`user_id`),r)}static get __name__(){return`internal._RecommendationsInternal`}static get __interfaces__(){return[T]}get __class__(){return t}};k.prototype.request_id=null,k.prototype.user_group=null,k.prototype.user_id=null,k.prototype.device_id=null,k.prototype._lists=null;const A=e.global(`$hxClasses`)[`internal._RecommendationsListInternal`]=class t extends e.inherits(){[e.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size,this.request_id=e.request_id}static get __name__(){return`internal._RecommendationsListInternal`}static get __interfaces__(){return[E]}get __class__(){return t}};A.prototype.limit=null,A.prototype.list_key=null,A.prototype.list_name=null,A.prototype.list_size=null,A.prototype.items=null,A.prototype.request_id=null;const j=e.global(`$hxClasses`)[`internal._RecommendationItemInternal`]=class t extends e.inherits(){[e.new](e){this.Id=x.getProperty(e,`item_id`),this.Rank=x.getProperty(e,`rank`),this.RequestId=x.getProperty(e,`request_id`),this.UserGroup=x.getProperty(e,`user_group`),this._data=e}getData(){return this._data}get(e){return this._data[e]}toJson(){return JSON.stringify(this._data)}static get __name__(){return`internal._RecommendationItemInternal`}static get __interfaces__(){return[D]}get __class__(){return t}};j.prototype.Id=null,j.prototype.Rank=null,j.prototype.RequestId=null,j.prototype.UserGroup=null,j.prototype._data=null,e.$global;const ee=function(){};ee.__isInterface__=!0,e.$global;const M=e.global(`$hxClasses`)[`internal.js.JSFroomleDomTree`]=class t extends e.inherits(){[e.new](){}getRoot(){return this.root}createElement(e){return this.root.ownerDocument.createElement(e)}toString(){return this.root.ownerDocument.documentElement.outerHTML}static fromHTML(e){let n=new DOMParser().parseFromString(e,`text/html`),r=new t;return r.root=n.documentElement,r}static fromDocument(e){let n=new t;return n.root=e.documentElement,n}static get __name__(){return`internal.js.JSFroomleDomTree`}static get __interfaces__(){return[ee]}get __class__(){return t}};M.prototype.root=null,e.$global;const N=e.global(`$hxClasses`).StringBuf=class t extends e.inherits(){[e.new](){this.b=``}static get __name__(){return`StringBuf`}get __class__(){return t}};N.prototype.b=null,e.$global;const P=e.global(`$hxClasses`)[`internal.domHandler.DomRuntime`]=class t extends e.inherits(){[e.new](){}static warn(t){e.$global.console.warn(t)}static _fillRecoTargets(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;if(e==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let s=[],c=[],l=e.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c;f.push(e);let p=0;for(;p<f.length;){let e=f[p];++p;let t=0,n=[],r=0,i=e.attributes;for(;r<i.length;){let e=i[r];++r,n.push({name:e.name,value:e.value})}let a=n;for(;t<a.length;){let n=a[t];if(++t,n.name==`data-froomle-reco`){let t=e.getAttribute(`data-froomle-framework`);if(t!=null&&t!=``)continue;s.push(e)}}}let m=[],g=0;for(;g<s.length;){let e=s[g];++g;let t=e.getAttribute(`data-froomle-request-id`),n=e.getAttribute(`data-froomle-id`);!(t!=null&&t!=``)&&!(n!=null&&n!=``)&&m.push(e)}if(m.length<1){let e=null,t=null,n=new Promise(function(n,r){e=n,t=r}),r=n;return r._resolve=e,r._reject=t,r._isFinished=!1,r._result=null,r._error=null,n}let _=[],v=[],y=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-reco-filter-`)){let n=h.substr(e.name,25,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return w.normalizeFilters(t)},b=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-variable-`)){let n=h.substr(e.name,22,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},x=Array(m.length),S=0,C=m.length;for(;S<C;){let e=S++,t=m[e];x[e]={list_name:t.getAttribute(`data-froomle-reco`),filters:y(t),others:b(t),entry:t}}let T=w.groupSequential(x);_=w.toRequestLists(T);let E=Array(T.length),D=0,k=T.length;for(;D<k;){let e=D++;E[e]=T[e].entries}v=E;let A;if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else try{A=O.getRawRecommendations(_)}catch{let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}return A.then(function(e){let n=e.lists(),r=n.length,i=v.length,a=!1;r!=i&&(a=!0,t.warn(`Froomle SDK: recommendation list count mismatch. Expected `+i+` list(s) for DOM targets, but backend returned `+r+`.`));let s=r<i?r:i,c=0,l=s;for(;c<l;){let r=c++,i=n[r],o=v[r],s=o.length,l=i.items.length;l!=s&&(a=!0,t.warn(`Froomle SDK: recommendation item count mismatch for list "`+i.list_name+`". Expected `+s+` item(s) for DOM targets, but backend returned `+l+`.`));let u=l<s?l:s,d=0,f=u;for(;d<f;){let n=d++,r=i.items[n],a=o[n];t._fillParameters(a,r,e.request_id)}}let u=!a,d=o;d._isFinished||(d._result=u,d._error=null,d._isFinished=!0,d._resolve(u))}),o}static getAttrByPath(e,t,n){n==null&&(n=`fgh`);try{t=new v(`\\\\[(\\\\w+)\\\\]`,`g`).map(t,function(e){return`.`+e.matched(1)}),t=g.replace(t,`[`,`.`),t=g.replace(t,`]`,``),h.cca(t,0)==46&&(t=h.substr(t,1,null));let n=t.split(`.`),r=e.get(n[0]),a=1,o=n.length;for(;a<o;){let e=a++;if(r==null)return null;r=r instanceof Array&&i.parseInt(n[e])!=null?r[i.parseInt(n[e])]:x.field(r,n[e])}return r}catch{return n}}static stringifyValue(e,t){return t==null&&(t=``),e==null?t:i.string(e)}static isQuotedToken(e){if(e==null||e.length<2)return!1;let t=e.charAt(0),n=e.charAt(e.length-1);return t==`'`&&n==`'`?!0:t==`"`?n==`"`:!1}static unescapeQuotedValue(e){let t=e;return t=g.replace(t,`\\'`,`'`),t=g.replace(t,`\\"`,`"`),t=g.replace(t,`\\\\`,`\\`),t}static unquoteToken(e){let n=g.trim(e);if(!t.isQuotedToken(n))return n;let r=h.substr(n,1,n.length-2);return t.unescapeQuotedValue(r)}static splitTopLevel(e,t){if(t==null||t.length!=1)return[e];let n=t.charAt(0),r=[],i=new N,a=0,o=null,s=!1,c=0,l=e.length;for(;c<l;){let t=c++,l=e.charAt(t);if(s){i.b+=l==null?`null`:``+l,s=!1;continue}if(o!=null){if(l==`\\`){i.b+=l==null?`null`:``+l,s=!0;continue}l==o&&(o=null),i.b+=l==null?`null`:``+l;continue}if(l==`'`||l==`"`){o=l,i.b+=l==null?`null`:``+l;continue}if(l==`(`?++a:l==`)`&&a>0&&--a,a==0&&l==n){r.push(g.trim(i.b)),i=new N;continue}i.b+=l==null?`null`:``+l}return r.push(g.trim(i.b)),r}static parseTransformPart(e){let n=g.trim(e);if(n==``)return{name:``,args:[]};let r=n.indexOf(`(`);if(r==-1||!n.endsWith(`)`))return{name:n,args:[]};let i=g.trim(h.substr(n,0,r)),a=h.substr(n,r+1,n.length-r-2),o=[];if(g.trim(a)!=``){let e=0,n=t.splitTopLevel(a,`,`);for(;e<n.length;){let r=n[e];++e,o.push(t.unquoteToken(r))}}return{name:i,args:o}}static resolveSeedValue(e,n,r){let i=g.trim(e);return i==``?r:t.isQuotedToken(i)?t.unquoteToken(i):t.stringifyValue(t.getAttrByPath(n,i,r),r)}static resolveFieldPathValue(e,n){let r=g.trim(e);return r==``?``:t.stringifyValue(t.getAttrByPath(n,r,null),``)}static applyTransform(e,n,r,i){let a=e==null?``:e;switch(n==null?``:n.toLowerCase()){case`append`:return r.length>=1?a+r[0]:a;case`default`:return(a==null||a==``)&&r.length>=1?r[0]:a;case`defaultfield`:return(a==null||a==``)&&r.length>=1?t.resolveFieldPathValue(r[0],i):a;case`lower`:return a.toLowerCase();case`prepend`:return r.length>=1?r[0]+a:a;case`replace`:return r.length>=2?g.replace(a,r[0],r[1]):a;case`trim`:return g.trim(a);case`upper`:return a.toUpperCase();case`urlencode`:return encodeURIComponent(a);default:return a}}static evaluateExpression(e,n,r){let i=g.trim(e);if(i.startsWith(`=`)&&(i=g.trim(h.substr(i,1,null))),i==``)return r;let a=t.splitTopLevel(i,`|`);if(a.length==0)return r;let o=t.resolveSeedValue(a[0],n,r),s=1,c=a.length;for(;s<c;){let e=s++,r=t.parseTransformPart(a[e]);r.name!=``&&(o=t.applyTransform(o,r.name,r.args,n))}return o}static findTemplateExpressionEnd(e,t){let n=null,r=!1,i=0,a=t;for(;a<e.length;){let t=e.charAt(a);if(r){r=!1,++a;continue}if(n!=null){t==`\\`?r=!0:t==n&&(n=null),++a;continue}if(t==`'`||t==`"`){n=t,++a;continue}if(t==`$`&&a+1<e.length&&e.charAt(a+1)==`{`){++i,a+=2;continue}if(t==`}`){if(i==0)return a;--i}++a}return-1}static resolveTemplate(e,n,r){if(e.indexOf("${")==-1)return e;let a=``,o=0;for(;o<e.length;){let s=e.indexOf("${",o);if(s==-1){a+=i.string(h.substr(e,o,null));break}a+=i.string(h.substr(e,o,s-o));let c=t.findTemplateExpressionEnd(e,s+2);if(c==-1){a+=i.string(h.substr(e,s,null));break}let l=h.substr(e,s+2,c-s-2);a+=i.string(t.evaluateExpression(l,n,r)),o=c+1}return a}static resolveParamValue(e,n,r){r==null&&(r=``);let i=t.stringifyValue(r,``),a=e==null?``:e,o=g.trim(a);return o==``?i:a.indexOf("${")==-1?o.startsWith(`=`)?t.evaluateExpression(h.substr(o,1,null),n,i):t.stringifyValue(t.getAttrByPath(n,o,i),i):t.resolveTemplate(a,n,i)}static _buildHistories(e){let t=[],n=[],r=e.querySelectorAll(`[data-froomle-id]`),i=0,a=r.length;for(;i<a;){let e=i++,t=r.item(e);t instanceof HTMLElement&&n.push(t)}let o=n,s=0;for(;s<o.length;){let e=o[s];++s,t.push(e.getAttribute(`data-froomle-id`))}O.addHistories(t)}static fillParam(e,n,r,i,a){a==null&&(a=``);try{let o=t.resolveParamValue(r,i,a);n==`inner`?(e.textContent=o,e.textContent):e.setAttribute(n,o)}catch{}}static _fillParameters(e,n,r){e.setAttribute(`data-froomle-id`,n.get(`item_id`)),e.setAttribute(`data-froomle-request-id`,r);let a=n.get(`item_type`);a!=null&&i.string(a)!=``&&e.setAttribute(`data-froomle-item-type`,i.string(a)),n.UserGroup!=null&&n.UserGroup!=``&&e.setAttribute(`data-froomle-user-group`,n.UserGroup);let o=[],s=e.querySelectorAll(`*`),c=0,l=s.length;for(;c<l;){let e=c++,t=s.item(e);t instanceof HTMLElement&&o.push(t)}let u=o,d=0;for(;d<u.length;){let e=u[d];++d;let r=0,i=[],a=0,o=e.attributes;for(;a<o.length;){let e=o[a];++a,i.push({name:e.name,value:e.value})}let s=i;for(;r<s.length;){let i=s[r];if(++r,i.name.startsWith(`data-froomle-param-`)){let r=g.replace(i.name,`data-froomle-param-`,``),a=i.value;t.fillParam(e,r,a,n)}}}}static _orderElements(e){let t=function(t,n,r){let i=[],a=[],o=0,s=t.childNodes;for(;o<s.length;){let e=s[o];++o,a.push(e)}let c=a,l=0;for(;l<c.length;){let n=c[l];++l;try{if(n.getAttribute(`data-froomle-ordervalue`)!=null){i.push(n);let r=e.createElement(`span`);r.setAttribute(`data-froomle-tmp-node`,`tmp`),t.replaceChild(r,n)}}catch{}}let u=[],d=0;for(;d<i.length;){let e=i[d];++d,u.push(e.getAttribute(`data-froomle-ordervalue`))}return{el:t,key:n,values:u,orderChildren:i,list_name:r}},n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i,s=e.getRoot(),c=[],l=s.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c,p=[],m=0;for(;m<f.length;){let e=f[m];++m;let n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let r=o[n];++n,r.name.startsWith(`data-froomle-order-`)&&p.push(t(e,r.name.substring(19),r.value))}}if(p.length<1){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let h=[],g=0;for(;g<p.length;){let e=p[g];++g;let t={list_name:e.list_name,limit:e.values.length,list_size:e.values.length},n={};x.setProperty(n,e.key,e.values),x.setProperty(t,`order`,n),h.push(t)}if(O.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(O.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}try{O.getRawRecommendations(h).then(function(e){let t=e.lists(),n=t.length,r=0,i=n;for(;r<i;){let n=r++,i=t[n],a=p[n];a.el.setAttribute(`data-froomle-request-id`,e.request_id);let o=[],s=0,c=i.items;for(;s<c.length;){let e=c[s];++s;let t=e.get(a.key);e.get(a.key);let n=a.values.length,r=0,i=n;for(;r<i;){let e=r++;if(t==a.values[e]){a.orderChildren.length;let t=a.orderChildren[e];o.push(t),a.orderChildren.splice(e,1),a.values.splice(e,1);break}}}let l=a.el,u=[],d=0,f=l.childNodes;for(;d<f.length;){let e=f[d];++d,u.push(e)}let m=u.length,h=0,g=m;for(;h<g;){let e=h++,t=a.el,n=[],r=0,i=t.childNodes;for(;r<i.length;){let e=i[r];++r,n.push(e)}let s=n[e],c=s,l;if(l=c instanceof HTMLElement?c.hasAttribute(`data-froomle-tmp-node`):!1,l&&(a.el.replaceChild(o[0],s),o.splice(0,1),o.length,o.length==0))break}}let a=o;a._isFinished||(a._result=!0,a._error=null,a._isFinished=!0,a._resolve(!0))})}catch{let e=o;e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1))}return o}static domInit(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;return t._orderElements(e).then(function(n){t._buildHistories(e.getRoot()),t._fillRecoTargets(e.getRoot()).then(function(e){let t=o;t._isFinished||(t._result=!0,t._error=null,t._isFinished=!0,t._resolve(!0))})}),o}static fillElementRecos(e){t._fillRecoTargets(e)}static runFromHtml(e){if(e==``)return``;let n;try{let t=new DOMParser().parseFromString(e,`text/html`),r=new M;r.root=t.documentElement,n=r}catch{return e}return t.domInit(n),n.toString()}static get __name__(){return`internal.domHandler.DomRuntime`}get __class__(){return t}};e.$global;const F=e.global(`$hxClasses`).FroomleSdk=class e{static register(){e.registered||e._env_set&&e._page_visit_set&&(e.registered=!0)}static buildScriptTag(){let e=`<script src="https://cdn.jsdelivr.net/npm/@froomle/frontend-sdk@0.1.0/dist/froomle.global.js" data-froomle-env="`+O.getEnvironment()+`" `,t=O.getPageVisit();t!=null&&(e+=`data-froomle-page-visit="`+t+`" `);let n=O.getContextItem();if(n!=null){e+=`data-froomle-context-item="`+n+`" `;let t=O.getContextItemType();(t==null||t==``)&&(t=`article`),e+=`data-froomle-context-item-type="`+t+`" `}let r=O.getDeviceId();r!=null&&(e+=`data-froomle-device-id="`+r+`" `);let i=O.getUserId();i!=null&&(e+=`data-froomle-user-id="`+i+`" `);let a=O.getConsent();a>0&&(e+=`data-froomle-consent="`+a+`" `);let o=O.getRequestDomain();o!=null&&(e+=`data-froomle-request-domain="`+o+`" `);let s=O.getChannel();return s!=null&&(e+=`data-froomle-channel="`+s+`" `),e+=`><\/script>`,e}static setEnvironment(t){O.setEnvironment(t),e._env_set=!0,e.register()}static setDeviceId(e){O.setDeviceId(e)}static setUserId(e){O.setUserId(e)}static setConsent(e){O.setConsent(e)}static setPageVisit(t){O.setPageVisit(t),e._page_visit_set=!0,e.register()}static setChannel(e){O.setChannel(e)}static setRequestDomain(e){O.setRequestDomain(e)}static setRecommendationsAccessToken(e){O.setRecommendationsAccessToken(e)}static clearRecommendationsAccessToken(){O.clearRecommendationsAccessToken()}static setRecommendationsAccessTokenProvider(e){O.setRecommendationsAccessTokenProvider(e)}static clearRecommendationsAccessTokenProvider(){O.clearRecommendationsAccessTokenProvider()}static setSafeRequest(e){O.setSafeRequest(e)}static setContextItem(e){O.setContextItem(e)}static setContextItemType(e){O.setContextItemType(e)}static setCustomVariable(e,t){O.setOthers(e,t)}static getUserId(){return O.getUserId()}static getDeviceId(){return O.getDeviceId()}static getEnvironment(){return O.getEnvironment()}static getSafeRequest(){return O.getSafeRequest()}static getPageVisit(){return O.getPageVisit()}static getConsent(){return O.getConsent()}static getRecommendations(e){return O.getRawRecommendations(e)}static getChannel(){return O.getChannel()}static getVersion(){return`0.1.0`}static runFromHtml(e){return P.runFromHtml(e)}static get __name__(){return`FroomleSdk`}get __class__(){return e}};F._env_set=!1,F._page_visit_set=!1,F.registered=!1;function te(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}function ne(){return`frontend-sdk/${F.getVersion()}`}function re(){return{"Content-Type":`application/json`,Accept:`application/json`,"X-Froomle-Client":ne()}}function ie(e){return JSON.stringify({events:e})}async function I(e,t={}){let n=ie(e),r=te(),{keepalive:i=!1,allowBeaconFallback:a=!1}=t;try{return await fetch(r,{method:`POST`,headers:re(),body:n,...i?{keepalive:!0}:{}}),`fetch`}catch(e){if(a&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(r,e))return`beacon`}throw e}}function ae(){if(O.getConsent()<2)return;let e=O.getUserId();if(e)return e}function oe(){let e=O.getContextItem();if(e)return e}function se(){let e=O.getContextItemType();if(e)return e}function L(){return O.getConsent()>=1}function ce(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}function le(){let e=O.getChannel();if(e)return e}function ue(e){var t;let n=e==null?void 0:e.getAttribute(`data-froomle-user-group`);if(n)return n;if(!(typeof document>`u`))return((t=document.querySelector(`[data-froomle-user-group]`))==null?void 0:t.getAttribute(`data-froomle-user-group`))||void 0}function de(e){let t={event_type:e,page_type:O.getPageVisit(),channel:le()||`www-desktop`,device_id:ce()},n=ue();n&&(t.user_group=n);let r=ae();return r&&(t.user_id=r),t}function fe(e,t){if(!t)return e;for(let n in t)e[n]=t[n];return e}function R(e){L()&&I([e]).catch(()=>{})}function z(e,t,n,r){let i=t||oe();if(!i)return null;let a=de(e);return a.action_item=i,a.action_item_type=n||se()||`article`,fe(a,r)}function B(e,t,n=`impression`,r){let i=z(n,e,t,r);i&&R(i)}function V(e,t,n,r){let i=z(`item_interaction`,n?e:void 0,n&&typeof t==`string`?t:void 0,{interaction_type:n||e,...n?r:t});i&&R(i)}function H(e,t){let n=de(`user_interaction`);n.interaction_type=e,R(fe(n,t))}function U(e,t,n,r){let i=z(`add_to_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function pe(e,t,n,r){let i=z(`remove_from_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&R(i)}function me(e,t,n,r,i){let a=typeof e==`string`,o=z(`purchase`,a?e:void 0,a&&typeof t==`string`?t:void 0,{amount:a?n:e,purchased_price:a?r:t,...a?i:n});o&&R(o)}function he(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-id`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item`));if(t)return t}function ge(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-item-type`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item-type`));if(t)return t}var W=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateEvents(){let t=[];for(let n of e.impressionQueue){let e=he(n);if(!e)continue;let r=ge(n)||`article`,i=le()||`www-desktop`,a={event_type:`impression`,page_type:O.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ce()},o=ue(n);o&&(a.user_group=o),O.getConsent()>=2&&O.getUserId()&&(a.user_id=O.getUserId());let s=n.getAttribute(`data-froomle-reco`),c=n.getAttribute(`data-froomle-request-id`);s&&c&&(a.list_name=s,a.request_id=c),t.push(a)}return e.impressionQueue=[],t}static sendImpressions(){if(e.impressionQueue.length===0||!L())return;let t=e.generateEvents();t.length!==0&&I(t).catch(()=>{})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(t){let n=t.getBoundingClientRect(),r=e.getViewPortRect();return n.right>r.left&&n.left<r.right&&n.bottom>r.top&&n.top<r.bottom}static addIntersectionImpressionListener(t){e.observer.observe(t)}static processDocument(){if(L()){for(let t of document.querySelectorAll(`[data-froomle-id]`))e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}static processElement(t){if(!L()||!(t instanceof Element))return;let n=[];t.matches(`[data-froomle-id]`)&&n.push(t);for(let e of t.querySelectorAll(`[data-froomle-id]`))n.push(e);if(n.length!==0){for(let t of n)e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}};W.impressionQueue=[],W.observer=null,typeof document<`u`&&(W.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(W.impressionQueue.push(e.target),W.observer.unobserve(e.target))}),W.impressionQueue.length>0&&W.sendImpressions()}));var _e=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readChannel()||`www-desktop`,n={event_type:`page_visit`,page_type:O.getPageVisit(),channel:t,device_id:e.readDeviceId()},r=e.readUserGroup();return r&&(n.user_group=r),O.getConsent()>=2&&O.getUserId()&&(n.user_id=O.getUserId()),n}static sendPageVisit(){O.getPageVisit()&&(O.getContextItem()||e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{}))}},ve=class e{static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItemType(){let e=O.getContextItemType();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readActionItemType()||`article`,n=e.readChannel()||`www-desktop`,r={event_type:`detail_pageview`,page_type:O.getPageVisit(),action_item:O.getContextItem(),action_item_type:t,channel:n,device_id:e.readDeviceId()},i=e.readUserGroup();return i&&(r.user_group=i),O.getConsent()>=2&&O.getUserId()&&(r.user_id=O.getUserId()),r}static sendPageView(){O.getContextItem()&&O.getPageVisit()&&e.canTrackEvents()&&I([e.generateEvent()]).catch(()=>{})}},G=class e{static readAttributeFromChain(e,t){let n=e;for(;n;){for(let e of t){let t=n.getAttribute(e);if(t)return t}n=n.parentElement}}static canTrackEvents(){return O.getConsent()>=1}static readDeviceId(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}static readChannel(){let e=O.getChannel();if(e)return e}static readActionItem(t){return e.readAttributeFromChain(t,[`data-froomle-id`,`data-froomle-action-item`])}static readActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-item-type`,`data-froomle-action-item-type`])}static readExplicitActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-action-item-type`])}static readUserGroup(t){var n;let r=e.readAttributeFromChain(t,[`data-froomle-user-group`]);if(r)return r;if(!(typeof document>`u`))return((n=document.querySelector(`[data-froomle-user-group]`))==null?void 0:n.getAttribute(`data-froomle-user-group`))||void 0}static registerClickables(){e.listenerRegistered||(e.listenerRegistered=!0,document.addEventListener(`click`,t=>{if(!e.canTrackEvents())return;let n=t instanceof MouseEvent?t:null,r=t.target,i=r instanceof Element?r:r instanceof Node?r.parentElement:null;if(!i)return;let a=i.closest(`a`);if(!a)return;let o=a.closest(`[data-froomle-id]`);if(!o)return;let s=a.closest(`[data-froomle-reco]`),c=(s?e.readActionItem(s):void 0)||e.readActionItem(o);if(!c)return;let l=e.readExplicitActionItemType(a)||(s?e.readActionItemType(s):void 0)||e.readActionItemType(o)||`article`,u=e.readChannel()||`www-desktop`,d=a instanceof HTMLAnchorElement?a.href:null,f=a.getAttribute(`href`),p=typeof f==`string`&&f.trim().startsWith(`#`),m=!!d&&!p&&t.cancelable&&!t.defaultPrevented&&!a.hasAttribute(`download`)&&(!a.target||a.target===`_self`)&&!!n&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey,h=p&&t.cancelable&&!t.defaultPrevented;(m||h)&&t.preventDefault();let g={event_type:`click_on_recommendation`,page_type:O.getPageVisit(),action_item:c,action_item_type:l,channel:u,device_id:e.readDeviceId()},_=(s?e.readUserGroup(s):void 0)||e.readUserGroup(o);_&&(g.user_group=_);let v=(s?e.readAttributeFromChain(s,[`data-froomle-reco`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-reco`]),y=(s?e.readAttributeFromChain(s,[`data-froomle-request-id`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-request-id`]);if(v&&y&&(g.list_name=v,g.request_id=y),O.getConsent()>=2&&O.getUserId()&&(g.user_id=O.getUserId()),m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);I([g],{keepalive:!0,allowBeaconFallback:!0}).catch(()=>{}).finally(()=>{window.clearTimeout(n),t()});return}I([g],{allowBeaconFallback:!0}).catch(()=>{})},!0))}};G.listenerRegistered=!1;const K=globalThis,q=`FroomleFrontendSdkIntegrationMode`;function ye(){return K[q]||(K[q]={mode:null}),K[q]}function be(e){let t=ye();return t.mode?{accepted:t.mode===e,current:t.mode}:(t.mode=e,{accepted:!0,current:e})}const xe=M,Se=F.setEnvironment,Ce=F.setPageVisit,we=F.setRequestDomain,Te=F.setSafeRequest,Ee=typeof F.setChannel==`function`?F.setChannel:O.setChannel,De=F.setRecommendationsAccessToken,Oe=F.clearRecommendationsAccessToken,ke=F.setRecommendationsAccessTokenProvider,Ae=F.clearRecommendationsAccessTokenProvider,je=F.setContextItem,Me=F.setContextItemType,Ne=O.addHistories;function Pe(e,t){F.setCustomVariable(e,t)}function Fe(e){De(e==null?null:e)}function Ie(){Oe()}function Le(e){ke(e)}function Re(){Ae()}function ze(e){F.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Be(e){F.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Ve(e){F.setConsent(e),document.cookie=`froomle_consent=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`,document.cookie=`froomle_device_id=${F.getDeviceId()}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function He(e){return F.getRecommendations(e)}const J=globalThis,Y=`FroomleFrontendSdkState`,X=`FroomleFrontendSdkReady`;function Ue(){let e=()=>{},t=()=>{},n=new Promise((n,r)=>{e=n,t=r}),r={initStarted:!1,initialized:!1,beforeInitEventDispatched:!1,initEventDispatched:!1,readyPromise:n,resolveReady:e,rejectReady:t};return J[Y]=r,J[X]=n,r}function Z(){if(!J[Y])return Ue();let e=J[Y];return J[X]||(J[X]=e.readyPromise),e}function Q(){return J.FroomleFrontendSdk?J.FroomleFrontendSdk:{RecommendationItem:D,setPageVisit:Ce,setEnvironment:Se,setConsent:Ve,setUserId:ze,setDeviceId:Be,setRequestDomain:we,setSafeRequest:Te,setChannel:Ee,setRecommendationsBearer:Fe,clearRecommendationsBearer:Ie,setRecommendationsBearerProvider:Le,clearRecommendationsBearerProvider:Re,setContextItem:je,setContextItemType:Me,setCustomVariable:Pe,getRecommendations:He,sendEvent:B,sendItemInteraction:V,sendUserInteraction:H,sendAddToCart:U,sendRemoveFromCart:pe,sendPurchase:me,addHistories:Ne,init:Ze}}function We(e){return{sdk:Q(),mode:e,version:typeof F.getVersion==`function`?F.getVersion():void 0}}function Ge(e,t){if(typeof window>`u`)return;if(typeof window.CustomEvent==`function`){window.dispatchEvent(new window.CustomEvent(e,{detail:t}));return}let n=document.createEvent(`CustomEvent`);n.initCustomEvent(e,!1,!1,t),window.dispatchEvent(n)}function Ke(e){let t=Z();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,Ge(`froomle:before-init`,We(e)))}function qe(e){let t=Z();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,Ge(`froomle:init`,We(e)))}function Je(e){let t=Z();t.initialized||(t.initialized=!0,t.resolveReady(Q())),qe(e)}function Ye(e){Z().rejectReady(e)}function Xe(e=`auto`){if(typeof document>`u`||!be(`dom`).accepted)return Promise.resolve(Q());let t=Z();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{Ke(e),P.domInit(xe.fromDocument(document)).then(()=>{G.registerClickables(),W.processDocument(),_e.sendPageVisit(),ve.sendPageView(),Je(e)}).catch(e=>{Ye(e)});function t(e){return e.matches(`[data-froomle-reco]:not([data-froomle-framework])`)||e.querySelector(`[data-froomle-reco]:not([data-froomle-framework])`)!==null}new MutationObserver(e=>{for(let n of e)if(n.type===`childList`&&n.addedNodes.forEach(e=>{e instanceof Element&&(t(e)&&P.fillElementRecos(e),W.processElement(e))}),n.type===`attributes`&&n.target instanceof Element)if(n.attributeName===`data-froomle-reco`){if(n.target.hasAttribute(`data-froomle-framework`))continue;let e=n.target.getAttribute(`data-froomle-request-id`);(!e||e===``)&&P.fillElementRecos(n.target)}else if(n.attributeName===`data-froomle-request-id`){if(n.target.hasAttribute(`data-froomle-framework`))continue;let e=n.target.getAttribute(`data-froomle-request-id`),t=n.target.getAttribute(`data-froomle-id`);n.target.getAttribute(`data-froomle-reco`)&&(!e||e===``)&&(!t||t===``)&&P.fillElementRecos(n.target)}else n.attributeName===`data-froomle-id`&&W.processElement(n.target)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-froomle-reco`,`data-froomle-request-id`,`data-froomle-id`]})},r=()=>{globalThis.setTimeout(n,0)};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r,{once:!0}):r(),t.readyPromise}function Ze(){return Xe(`manual`)}function Qe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const $=[];function $e(){var e;return typeof document>`u`?``:((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||``}function et(e,t){var n;let r=e,i=((n=r==null?void 0:r.UserGroup)==null?typeof(r==null?void 0:r.get)==`function`?r.get(`user_group`):void 0:n)||t;if(i&&(r.UserGroup=i,typeof(r==null?void 0:r.getData)==`function`)){let e=r.getData();e&&(!e.user_group||e.user_group===``)&&(e.user_group=i)}}async function tt(){let e=$.splice(0,$.length);if(e.length!==0)try{let t=e.map(e=>e.req),n=O.requestsToLists(t),r=await O.getRawRecommendations(n),i=r.user_group||``;typeof document<`u`&&i&&document.documentElement.setAttribute(`data-froomle-user-group`,i);let a=r.lists().reduce((e,t)=>[...e,...t.items],[]);a.forEach(e=>et(e,i)),e.forEach((e,t)=>{a[t]?e.deferred.resolve(a[t]):e.deferred.reject(Error(`No recommendation available`))})}catch(t){throw e.forEach(e=>{e.deferred.reject(t)}),t}}function nt(e){let t,n,r={promise:new Promise((e,r)=>{t=e,n=r}),resolve:t,reject:n};return $.push({deferred:r,req:e}),r}function rt(e){let t=nt(e).promise;Qe();let n=function(e,n){return t.then(t=>(r.completeTarget=t,e?e(t):t),e=>n?n(e):Promise.reject(e))},r=new Proxy(new j({item_id:``,request_id:``,user_group:``}),{get(t,r,i){if(r===`then`)return n;if(r===`__froomleList`)return e.list;if(r===`get`){let e=Reflect.get(t,r,i);return function(...t){return e.apply(this,t)}}if(typeof r!=`string`)return Reflect.get(t,r,i);let a=Reflect.get(t,r,i);if(a!=null&&a!==``)return a;let o=t.get(r);return o!=null&&o!==``?o:``},set(e,t,n,r){if(t===`completeTarget`){if(Object.assign(e,n),!e.UserGroup){let t=$e();if(t){e.UserGroup=t;let n=e.getData();n&&!n.user_group&&(n.user_group=t)}}return!0}return Reflect.set(e,t,n,r)},has(e,t){return e.get(t)!==void 0}});return r}Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Le}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return be}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return Te}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@froomle/frontend-sdk",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Froomle frontend SDK",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"dist",
|
|
31
31
|
"react",
|
|
32
32
|
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
33
34
|
"LICENSE"
|
|
34
35
|
],
|
|
35
36
|
"scripts": {
|
package/dist/js-BClW3EMu.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var e=class e{static global(t){return e.globals[t]?e.globals[t]:e.globals[t]={}}static createStatic(e,t,n){let r=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return n!=null&&(r=n(),n=null),r},set:function(e){n!=null&&(r=n(),n=null),r=e}})}static iterator(t){if(Array.isArray(t)){let n=t;return function(){return e.mkIter(n)}}else return typeof t.iterator==`function`?t.iterator.bind(t):t.iterator}static getIterator(t){return Array.isArray(t)?e.mkIter(t):t.iterator()}static mkIter(e){return new t(e)}static extend(t){function n(){this[e.new].apply(this,arguments)}return Object.setPrototypeOf(n.prototype,t.prototype),n}static inherits(t,n){n==null&&(n=!1);function r(){n&&t&&r[e.init]&&r[e.init](),this[e.new].apply(this,arguments)}return n?r[e.init]=()=>{let n=t();n[e.init]&&n[e.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[e.init]=void 0}:t&&t[e.init]?(n=!0,r[e.init]=()=>{t[e.init]&&t[e.init](),Object.setPrototypeOf(r.prototype,t.prototype),r[e.init]=void 0}):t&&Object.setPrototypeOf(r.prototype,t.prototype),r}static bind(t,n){if(n==null)return null;n.__id__==null&&(n.__id__=e.fid++);let r=null;return t.hx__closures__==null?t.hx__closures__={}:r=t.hx__closures__[n.__id__],r==null&&(r=n.bind(t),t.hx__closures__[n.__id__]=r),r}static get __name__(){return`genes.Register`}get __class__(){return e}};e.$global=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:void 0,e.globals={},e.new=Symbol(),e.init=Symbol(),e.fid=0;const t=e.global(`$hxClasses`)[`genes._Register.ArrayIterator`]=class t extends e.inherits(){[e.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return`genes._Register.ArrayIterator`}get __class__(){return t}};t.prototype.array=null,t.prototype.current=null,e.$global;const n=e.global(`$hxClasses`)[`haxe.ValueException`]=class t extends e.inherits(()=>r,!0){[e.new](t,n,r){super[e.new](String(t),n,r),this.value=t}unwrap(){return this.value}static get __name__(){return`haxe.ValueException`}static get __super__(){return r}get __class__(){return t}};n.prototype.value=null,e.$global;const r=e.global(`$hxClasses`)[`haxe.Exception`]=class t extends e.inherits(()=>Error,!0){[e.new](e,t,n){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=n==null?this:n}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof t?e:e instanceof Error?new t(e.message,null,e):new n(e,null,e)}static thrown(e){return e instanceof t?e.get_native():e instanceof Error?e:new n(e)}static get __name__(){return`haxe.Exception`}static get __super__(){return Error}get __class__(){return t}};r.prototype.native=null,r.prototype.__skipStack=null,r.prototype.__nativeException=null,r.prototype.__previousException=null,e.$global;const i=e.global(`$hxClasses`).Std=class e{static string(e){return a.__string_rec(e,``)}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static random(e){return e<=0?0:Math.floor(Math.random()*e)}static get __name__(){return`Std`}get __class__(){return e}};Object.defineProperty(String.prototype,`__class__`,{value:String,enumerable:!1,writable:!0}),String.__name__=!0,Array.__name__=!0,e.$global;const a=e.global(`$hxClasses`)[`js.Boot`]=class t{static getClass(e){if(e==null)return null;if(e instanceof Array)return Array;{let n=e.__class__;if(n!=null)return n;let r=t.__nativeClassName(e);return r==null?null:t.__resolveNativeClass(r)}}static __string_rec(n,r){if(n==null)return`null`;if(r.length>=5)return`<...>`;let i=typeof n;switch(i==`function`&&(n.__name__||n.__ename__)&&(i=`object`),i){case`function`:return`<function>`;case`object`:if(n.__enum__){let i=e.global(`$hxEnums`)[n.__enum__].__constructs__[n._hx_index],a=i._hx_name;return i.__params__?(r+=` `,a+`(`+(function(e){var a;let o=[];{let e=0,a=i.__params__;for(;e<a.length;){let i=a[e];e+=1,o.push(t.__string_rec(n[i],r))}}return a=o,a})(this).join(`,`)+`)`):a}if(n instanceof Array){let e=`[`;r+=` `;let i=0,a=n.length;for(;i<a;){let a=i++;e+=(a>0?`,`:``)+t.__string_rec(n[a],r)}return e+=`]`,e}let i;try{i=n.toString}catch{return`???`}if(i!=null&&i!=Object.toString&&typeof i==`function`){let e=n.toString();if(e!=`[object Object]`)return e}let a=`{
|
|
2
|
-
`;r+=` `;let o=n.hasOwnProperty!=null,s=null;for(s in n)o&&!n.hasOwnProperty(s)||s==`prototype`||s==`__class__`||s==`__super__`||s==`__interfaces__`||s==`__properties__`||(a.length!=2&&(a+=`,
|
|
3
|
-
`),a+=r+s+` : `+t.__string_rec(n[s],r));return r=r.substring(1),a+=`
|
|
4
|
-
`+r+`}`,a;case`string`:return n;default:return String(n)}}static __interfLoop(e,n){if(e==null)return!1;if(e==n)return!0;let r=e.__interfaces__;if(r!=null&&(e.__super__==null||e.__super__.__interfaces__!=r)){let e=0,i=r.length;for(;e<i;){let i=r[e++];if(i==n||t.__interfLoop(i,n))return!0}}return t.__interfLoop(e.__super__,n)}static __instanceof(n,r){if(r==null)return!1;switch(r){case Array:return n instanceof Array;case`$hxCoreType__Bool`:return typeof n==`boolean`;case`$hxCoreType__Dynamic`:return n!=null;case`$hxCoreType__Float`:return typeof n==`number`;case`$hxCoreType__Int`:return typeof n==`number`?(n|0)===n:!1;case String:return typeof n==`string`;default:if(n!=null){if(typeof r==`function`){if(t.__downcastCheck(n,r))return!0}else if(typeof r==`object`&&t.__isNativeObj(r)&&n instanceof r)return!0}else return!1;return r==`$hxCoreType__Class`&&n.__name__!=null||r==`$hxCoreType__Enum`&&n.__ename__!=null?!0:n.__enum__==null?!1:e.global(`$hxEnums`)[n.__enum__]==r}}static __downcastCheck(e,n){return e instanceof n?!0:n.__isInterface__?t.__interfLoop(t.getClass(e),n):!1}static __cast(e,n){if(e==null||t.__instanceof(e,n))return e;throw r.thrown(`Cannot cast `+i.string(e)+` to `+i.string(n))}static __nativeClassName(e){let n=t.__toStr.call(e).slice(8,-1);return n==`Object`||n==`Function`||n==`Math`||n==`JSON`?null:n}static __isNativeObj(e){return t.__nativeClassName(e)!=null}static __resolveNativeClass(t){return e.$global[t]}static get __name__(){return`js.Boot`}get __class__(){return t}};a.__toStr={}.toString,e.$global;const o=e.global(`$hxClasses`)[`js.Browser`]=class e{static get supported(){return this.get_supported()}static get_supported(){return typeof window<`u`&&window.location!==void 0?typeof window.location.protocol==`string`:!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest<`u`)return new XMLHttpRequest;if(typeof ActiveXObject<`u`)return new`ActiveXObject`(`Microsoft.XMLHTTP`);throw r.thrown(`Unable to create XMLHttpRequest object.`)}static get __name__(){return`js.Browser`}get __class__(){return e}};e.$global;const s=e.global(`$hxEnums`)[`haxe.io.Error`]={__ename__:`haxe.io.Error`,Blocked:{_hx_name:`Blocked`,_hx_index:0,__enum__:`haxe.io.Error`},Overflow:{_hx_name:`Overflow`,_hx_index:1,__enum__:`haxe.io.Error`},OutsideBounds:{_hx_name:`OutsideBounds`,_hx_index:2,__enum__:`haxe.io.Error`},Custom:Object.assign(e=>({_hx_index:3,__enum__:`haxe.io.Error`,e}),{_hx_name:`Custom`,__params__:[`e`]})};s.__constructs__=[s.Blocked,s.Overflow,s.OutsideBounds,s.Custom],s.__empty_constructs__=[s.Blocked,s.Overflow,s.OutsideBounds],e.$global;const c=e.global(`$hxEnums`)[`haxe.io.Encoding`]={__ename__:`haxe.io.Encoding`,UTF8:{_hx_name:`UTF8`,_hx_index:0,__enum__:`haxe.io.Encoding`},RawNative:{_hx_name:`RawNative`,_hx_index:1,__enum__:`haxe.io.Encoding`}};c.__constructs__=[c.UTF8,c.RawNative],c.__empty_constructs__=[c.UTF8,c.RawNative],e.$global;const l=e.global(`$hxClasses`)[`haxe.io.Bytes`]=class t extends e.inherits(){[e.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,n){if(e<0||t<0||e+t>this.length)throw r.thrown(s.OutsideBounds);n==null&&(n=c.UTF8);let i=``,a=this.b,o=e,l=e+t;switch(n._hx_index){case 0:for(;o<l;){let e=a[o++];if(e<128){if(e==0)break;i+=String.fromCodePoint(e)}else if(e<224){let t=(e&63)<<6|a[o++]&127;i+=String.fromCodePoint(t)}else if(e<240){let t=a[o++],n=(e&31)<<12|(t&127)<<6|a[o++]&127;i+=String.fromCodePoint(n)}else{let t=a[o++],n=a[o++],r=(e&15)<<18|(t&127)<<12|(n&127)<<6|a[o++]&127;i+=String.fromCodePoint(r)}}break;case 1:for(;o<l;){let e=a[o++]|a[o++]<<8;i+=String.fromCodePoint(e)}break}return i}static ofData(e){let n=e.hxBytes;return n==null?new t(e):n}static get __name__(){return`haxe.io.Bytes`}get __class__(){return t}};l.prototype.length=null,l.prototype.b=null,e.$global;const u=e.global(`$hxClasses`)[`haxe.http.HttpBase`]=class t extends e.inherits(){[e.new](t){this.url=t,this.headers=[],this.params=[],this.emptyOnData=e.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let n=0,r=this.headers.length;for(;n<r;){let r=n++;if(this.headers[r].name==e){this.headers[r]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return e.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,c.UTF8)),this.responseAsString}static get __name__(){return`haxe.http.HttpBase`}get __class__(){return t}};u.prototype.url=null,u.prototype.responseBytes=null,u.prototype.responseAsString=null,u.prototype.postData=null,u.prototype.postBytes=null,u.prototype.headers=null,u.prototype.params=null,u.prototype.emptyOnData=null,e.$global;const d=e.global(`$hxClasses`)[`haxe.iterators.MapKeyValueIterator`]=class t extends e.inherits(){[e.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return`haxe.iterators.MapKeyValueIterator`}get __class__(){return t}};d.prototype.map=null,d.prototype.keys=null,e.$global;const f=function(){};f.__isInterface__=!0,e.$global;const p=e.global(`$hxClasses`)[`genes.util.EsMap`]=class t extends e.inherits(){[e.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return t.adaptIterator(this.inst.keys())}iterator(){return t.adaptIterator(this.inst.values())}toString(){let e=[],n=t.adaptIterator(this.inst.keys());for(;n.hasNext();){let t=n.next();e.push(``+i.string(t)+` => `+i.string(this.inst.get(t)))}return`{`+e.join(`, `)+`}`}clear(){this.inst.clear()}static adaptIterator(e){let t,n,r=function(){let r=e.next();t=r.value,n=r.done};return{hasNext:function(){return n==null&&r(),!n},next:function(){n==null&&r();let e=t;return r(),e}}}static get __name__(){return`genes.util.EsMap`}get __class__(){return t}};p.prototype.inst=null,e.$global;const m=e.global(`$hxClasses`)[`haxe.ds.StringMap`]=class t extends e.inherits(p){[e.new](){super[e.new]()}copy(){let e=new t;return e.inst=new Map(this.inst),e}keyValueIterator(){return new d(this)}static get __name__(){return`haxe.ds.StringMap`}static get __interfaces__(){return[f]}static get __super__(){return p}get __class__(){return t}};e.$global;const h=e.global(`$hxClasses`).HxOverrides=class e{static cca(e,t){let n=e.charCodeAt(t);if(n==n)return n}static substr(e,t,n){if(n==null)n=e.length;else if(n<0)if(t==0)n=e.length+n;else return``;return e.substr(t,n)}static now(){return Date.now()}static get __name__(){return`HxOverrides`}get __class__(){return e}};typeof performance<`u`&&typeof performance.now==`function`&&(h.now=performance.now.bind(performance)),e.$global;const g=e.global(`$hxClasses`).StringTools=class e{static isSpace(e,t){let n=h.cca(e,t);return n>8&&n<14?!0:n==32}static ltrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,r);)++r;return r>0?h.substr(t,r,n-r):t}static rtrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,n-r-1);)++r;return r>0?h.substr(t,0,n-r):t}static trim(t){return e.ltrim(e.rtrim(t))}static replace(e,t,n){return e.split(t).join(n)}static get __name__(){return`StringTools`}get __class__(){return e}};e.$global;const _=e.global(`$hxClasses`).Lambda=class t{static exists(t,n){let r=e.getIterator(t);for(;r.hasNext();)if(n(r.next()))return!0;return!1}static get __name__(){return`Lambda`}get __class__(){return t}};e.$global;const v=e.global(`$hxClasses`).EReg=class t extends e.inherits(){[e.new](e,t){this.r=new RegExp(e,t.split(`u`).join(``))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw r.thrown(`EReg::matched`)}matchedPos(){if(this.r.m==null)throw r.thrown(`No string matched`);return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,n){if(n==null&&(n=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(n<0?e:h.substr(e,0,t+n));let r=this.r.m!=null;return r&&(this.r.s=e),r}else{let r=this.match(n<0?h.substr(e,t,null):h.substr(e,t,n));return r&&(this.r.s=e,this.r.m.index+=t),r}}map(e,t){let n=0,r=``;do{if(n>=e.length)break;if(!this.matchSub(e,n)){r+=i.string(h.substr(e,n,null));break}let a=this.matchedPos();r+=i.string(h.substr(e,n,a.pos-n)),r+=i.string(t(this)),a.len==0?(r+=i.string(h.substr(e,a.pos,1)),n=a.pos+1):n=a.pos+a.len}while(this.r.global);return!this.r.global&&n>0&&n<e.length&&(r+=i.string(h.substr(e,n,null))),r}static get __name__(){return`EReg`}get __class__(){return t}};v.prototype.r=null,e.$global;const y=e.global(`$hxClasses`)[`haxe.http.HttpJs`]=class t extends e.inherits(u){[e.new](t){this.async=!0,this.withCredentials=!1,super[e.new](t)}request(t){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let n=this.req=o.createXMLHttpRequest(),a=this,s=function(t){if(n.readyState!=4)return;let r;try{r=n.status}catch{r=null}if(r==0&&o.get_supported()&&e.$global.location!=null){let t=e.$global.location.protocol.toLowerCase();new v(`^(?:about|app|app-storage|.+-extension|file|res|widget):$`,``).match(t)&&(r=n.response==null?404:200)}if(r==null&&(r=null),r!=null&&a.onStatus(r),r!=null&&r>=200&&r<400){a.req=null;let e=n.getAllResponseHeaders().split(`\r
|
|
5
|
-
`),t=[],r=0,i=e;for(;r<i.length;){let e=i[r];++r,e!=``&&t.push(e)}e=t,a.responseHeaders=new m;let o=0;for(;o<e.length;){let t=e[o];++o;let n=t.split(`: `),r=n.shift(),i=n.length==1?n[0]:n.join(`: `);i=g.ltrim(g.rtrim(i)),a.responseHeaders.inst.set(r,i)}a.success(l.ofData(n.response))}else if(r==null||r==0&&n.response==null)a.req=null,a.onError(`Failed to connect or resolve host`);else if(r==null)a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status);else switch(r){case 12007:a.req=null,a.onError(`Unknown host`);break;case 12029:a.req=null,a.onError(`Failed to connect to host`);break;default:a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status)}};this.async&&(n.onreadystatechange=s);let c,u=this.postData,d=this.postBytes;if(u==null)if(d==null)c=null;else{let e=d;c=new Blob([e.b.bufferValue])}else c=d==null?u:null;if(c!=null)t=!0;else{let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,c=c==null?``:(c==null?`null`:i.string(c))+`&`;let r=n.name,a=(c==null?`null`:i.string(c))+encodeURIComponent(r)+`=`,o=n.value;c=a+encodeURIComponent(o)}}try{if(t)n.open(`POST`,this.url,this.async);else if(c!=null){let e=this.url.split(`?`).length<=1;n.open(`GET`,this.url+(e?`?`:`&`)+(c==null?`null`:i.string(c)),this.async),c=null}else n.open(`GET`,this.url,this.async);n.responseType=`arraybuffer`}catch(e){let t=r.caught(e).unwrap();this.req=null,this.onError(t.toString());return}n.withCredentials=this.withCredentials,!_.exists(this.headers,function(e){return e.name==`Content-Type`})&&t&&this.postData==null&&n.setRequestHeader(`Content-Type`,`application/x-www-form-urlencoded`);let f=0,p=this.headers;for(;f<p.length;){let e=p[f];++f,n.setRequestHeader(e.name,e.value)}n.send(c),this.async||s(null)}static get __name__(){return`haxe.http.HttpJs`}static get __super__(){return u}get __class__(){return t}};y.prototype.async=null,y.prototype.withCredentials=null,y.prototype.responseHeaders=null,y.prototype.req=null,e.$global;const b=e.global(`$hxClasses`).Type=class e{static createInstance(e,t){return new(Function.prototype.bind.apply(e,[null].concat(t)))}static get __name__(){return`Type`}get __class__(){return e}};e.$global;const x=e.global(`$hxClasses`).Reflect=class e{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let n;if(e==null)return null;{let r;return e.__properties__?(n=e.__properties__[`get_`+t],r=n):r=!1,r?e[n]():e[t]}}static setProperty(e,t,n){let r,i;e.__properties__?(r=e.__properties__[`set_`+t],i=r):i=!1,i?e[r](n):e[t]=n}static fields(e){let t=[];if(e!=null){let r=Object.prototype.hasOwnProperty;for(var n in e)n!=`__id__`&&n!=`hx__closures__`&&r.call(e,n)&&t.push(n)}return t}static compare(e,t){return e==t?0:e>t?1:-1}static get __name__(){return`Reflect`}get __class__(){return e}};e.$global;const S=e.global(`$hxClasses`)[`internal.http.FetchHttp`]=class t extends e.inherits(y){[e.new](t){this.responseStatus=0,super[e.new](t)}request(t){let n=e.$global,a=n.fetch,o=n.Headers,s=n.URLSearchParams;if(a==null){this.onError(`Fetch API not found.`);return}let c=b.createInstance(o,[]),l=0,u=this.headers;for(;l<u.length;){let e=u[l];++l,c.append(e.name,e.value)}let d=t?`POST`:`GET`,f=null;if(t)if(this.postData!=null)f=this.postData;else{f=b.createInstance(s,[]);let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,f.append(n.name,n.value)}}let p={method:d,headers:c,body:f},m=this,h=a(this.url,p).then(function(e){if(m.responseStatus=e.status,m.onStatus(e.status),e.ok)return e.text();throw r.thrown(`HTTP Error: `+i.string(e.status))}).then(function(e){m.onData(e)}),g=x.field(h,`catch`);g!=null&&g.apply(h,[function(e){m.onError(i.string(e))}])}static get __name__(){return`internal.http.FetchHttp`}static get __super__(){return y}get __class__(){return t}};S.prototype.responseStatus=null,e.$global;const C=e.global(`$hxClasses`)[`internal.data.UUID`]=class e{static randomHexChar(){return`0123456789abcdef`.charAt(i.random(16))}static v4(){let e=``,t=0;for(;t<36;)switch(t++){case 14:e+=`4`;break;case 19:e+=i.string(`0123456789abcdef`.charAt(8+i.random(4)));break;case 8:case 13:case 18:case 23:e+=`-`;break;default:e+=i.string(`0123456789abcdef`.charAt(i.random(16)))}return e}static get __name__(){return`internal.data.UUID`}get __class__(){return e}};C.HEX=`0123456789abcdef`,e.$global;const w=function(){};w.__isInterface__=!0;const T=function(){};T.__isInterface__=!0;const E=function(){};E.__isInterface__=!0,e.$global;const D=e.global(`$hxClasses`)[`internal.RecoBackendV2`]=class t extends e.inherits(){[e.new](){}static _requestUri(){return(t._safe_request?`https://`:`http://`)+t._req_domain+`/api/`+t._environment+`/recommendations/requests`}static noConsentBody(){return{device_id:`no-consent`,user_group:`no-consent`,version:`no-consent`}}static buildRequestBody(e){let n={lists:e,page_type:t._page_visit,channel:t._channel};if(t._consent>=2&&t._history.length>0&&(n.histories=t._buildHistories()),t._consent<2){let e=t.noConsentBody(),r=0,i=x.fields(e);for(;r<i.length;){let t=i[r];++r,n[t]=x.field(e,t)}}else t._user_id!=null&&(n.user_id=t._user_id),n.device_id=t._device_id;let r=0,a=t._others;for(;r<a.length;){let e=a[r];++r,n[e.key]=e.value}let o=x.field(n,`context_item`),s=x.field(n,`context_item_type`);return o!=null&&i.string(o)!=``&&(s==null||i.string(s)==``)&&(n.context_item_type=`article`),n}static _buildHistories(){return{pageviews:t._history}}static normalizeAccessToken(e){if(e==null)return null;let t=i.string(e);return t==``?null:t}static hasRecommendationsAccessTokenProvider(){return t._recommendations_access_token_provider!=null}static resolveRecommendationsAccessToken(e){if(!e){let e=t.normalizeAccessToken(t._recommendations_access_token);if(e!=null)return Promise.resolve(e)}if(!t.hasRecommendationsAccessTokenProvider())return Promise.resolve(t.normalizeAccessToken(t._recommendations_access_token));let n=null;try{n=t._recommendations_access_token_provider.apply(null,[{forceRefresh:e}])}catch(e){let t=r.caught(e).unwrap();return Promise.reject(t)}return Promise.resolve(n).then(function(e){let n=t.normalizeAccessToken(e);return t._recommendations_access_token=n,n})}static requestsToLists(e){let t=[],n=``,r=[],i=0,a=[],o=function(e,t,o){n=e,r=t,i=0,a=o},s=function(e){let t=[];if(e==null)return t;let n=0;for(;n<e.length;){let r=e[n];++n,!(r==null||r.key==null||r.key==``)&&t.push({key:r.key,value:r.value})}return t},c=function(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(x.compare),l.sort(x.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0},l=function(){let e={limit:i,list_name:n,list_size:i},o=0;for(;o<r.length;){let t=r[o];++o;let n=t.value;n instanceof Array||(n=[n]),e[t.key]=n}let s=0;for(;s<a.length;){let t=a[s];++s,e[t.key]=t.value}t.push(e)},u=0;for(;u<e.length;){let t=e[u];++u;let d=s(t.filters),f=t.others==null?[]:t.others;if(n==``){o(t.list,d,f),i+=1;continue}else (n!=t.list||!c(r,d)||!c(a,f))&&(l(),o(t.list,d,f));i+=1}return i!=0&&l(),t}static _requestRecos(e){let n=null,a=null,o=new Promise(function(e,t){n=e,a=t}),s=o;s._resolve=n,s._reject=a,s._isFinished=!1,s._result=null,s._error=null;let c=o,l=!1,u=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))},d=null;return d=function(n,a){if(l)return;let o=!1,s=!1,f=new S(t._requestUri());f.setHeader(`Content-Type`,`application/json`),f.setHeader(`X-Froomle-Client`,`frontend-sdk/0.0.30`);let p=t.normalizeAccessToken(n);p!=null&&f.setHeader(`Authorization`,`Bearer `+p);let m=t.buildRequestBody(e),h=JSON.stringify(m);f.setPostData(h),f.onError=function(e){o||s||l||(o=!0,u(`HTTP Request Error: `+e))},f.onStatus=function(e){if(!(o||l)){if(e==401&&a&&t.hasRecommendationsAccessTokenProvider()){o=!0,s=!0,t.resolveRecommendationsAccessToken(!0).then(function(e){return l?null:e==null?(u(`Recommendation access token provider returned no token during refresh.`),null):(d(e,!1),null)},function(e){return u(`Failed to refresh recommendation access token: `+i.string(e)),null});return}(e<200||e>=300)&&(o=!0,u(`HTTP Status Error: `+e))}};try{f.request(!0)}catch(e){let t=r.caught(e).unwrap();if(o||l)return;o=!0,u(`Failed to execute recommendation request: `+i.string(t));return}let g=function(e){if(!(o||s||l))try{let t=JSON.parse(e),n=O.fromRequestData(t);o=!0,l=!0;let r=c;r._isFinished||(r._result=n,r._error=null,r._isFinished=!0,r._resolve(n))}catch(e){let t=r.caught(e).unwrap();o=!0,u(`Failed to parse recommendation response: `+i.string(t))}},_=f.get_responseData();_==null?!o&&!s&&!l&&(f.onData=g):g(_)},t.resolveRecommendationsAccessToken(!1).then(function(e){return l?null:t.hasRecommendationsAccessTokenProvider()&&e==null?(u(`Recommendation access token provider returned no token.`),null):(d(e,t.hasRecommendationsAccessTokenProvider()),null)},function(e){return u(`Failed to resolve recommendation access token: `+i.string(e)),null}),c}static getOrder(e,n,a){let o={list_name:e,limit:a.length,list_size:a.length},s={};x.setProperty(s,n,a),x.setProperty(o,`order`,s);let c=null,l=null,u=new Promise(function(e,t){c=e,l=t}),d=u;d._resolve=c,d._reject=l,d._isFinished=!1,d._result=null,d._error=null;let f=u;return t.getRawRecommendations([o]).then(function(e){try{let t=[],n=e.lists();if(n!=null&&n.length>0){let e=n[0].items;if(e instanceof Array){let n=0,r=e;for(;n<r.length;){let e=r[n];++n;let i=e.get(`categories`);i!=null&&t.push(i)}}}let r=f;r._isFinished||(r._result=t,r._error=null,r._isFinished=!0,r._resolve(t))}catch(e){let t=r.caught(e).unwrap(),n=`Failed to build order response: `+i.string(t),a=f;a._isFinished||(a._error=n,a._isFinished=!0,a._reject(n))}},function(e){let t=f;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))}),f}static getRawRecommendations(e){return t._requestRecos(e)}static addHistories(e,n){if(n==null&&(n=`article`),e==null||e.length==0)return;let r=n!=null&&n!=``?n:`article`,a=0;for(;a<e.length;){let n=e[a];if(++a,typeof n==`string`){let e=i.string(n);e!=``&&t._history.push({id:e,item_type:r});continue}let o=n,s=x.field(o,`id`);if(s==null)continue;let c=i.string(s);if(c==``)continue;let l=x.field(o,`item_type`);(l==null||i.string(l)==``)&&(l=x.field(o,`itemType`));let u=l!=null&&i.string(l)!=``?i.string(l):r;t._history.push({id:c,item_type:u})}}static setOthers(e,n){let r=0,i=t._others;for(;r<i.length;){let t=i[r];if(++r,t.key==e){t.value=n;return}}t._others.push({key:e,value:n})}static setConsent(e){e>2&&(e=2),t._consent=e,e==2&&t.getDeviceId()==`no-consent`&&t.setDeviceId(C.v4())}static setChannel(e){t._channel=e}static setPageVisit(e){t._page_visit=e}static setEnvironment(e){t._environment=e}static setDeviceId(e){t._device_id=e}static setUserId(e){t._user_id=e}static setRequestDomain(e){t._req_domain=e}static setRecommendationsAccessToken(e){t._recommendations_access_token=t.normalizeAccessToken(e)}static clearRecommendationsAccessToken(){t._recommendations_access_token=null}static setRecommendationsAccessTokenProvider(e){t._recommendations_access_token_provider=e}static clearRecommendationsAccessTokenProvider(){t._recommendations_access_token_provider=null}static setSafeRequest(e){t._safe_request=e}static setContextItem(e){t.setOthers(`context_item`,e)}static setContextItemType(e){t.setOthers(`context_item_type`,e)}static getRequestDomain(){return t._req_domain}static getSafeRequest(){return t._safe_request}static getEnvironment(){return t._environment}static getPageVisit(){return t._page_visit}static getUserId(){return t._user_id}static getDeviceId(){return t._device_id}static getConsent(){return t._consent}static getChannel(){return t._channel}static getOthers(e){let n=0,r=t._others;for(;n<r.length;){let t=r[n];if(++n,e==t.key)return t.value}return null}static getContextItem(){return t.getOthers(`context_item`)}static getContextItemType(){return t.getOthers(`context_item_type`)}static get __name__(){return`internal.RecoBackendV2`}get __class__(){return t}};D._environment=null,D._device_id=`no-consent`,D._user_id=null,D._consent=0,D._req_domain=`europe-west1.froomle.com`,D._page_visit=null,D._channel=`www-desktop`,D._safe_request=!0,D._history=[],D._others=[],D._recommendations_access_token=null,D._recommendations_access_token_provider=null;const O=e.global(`$hxClasses`)[`internal._RecommendationsInternal`]=class t extends e.inherits(){[e.new](e,t,n,r,i){this.request_id=t,this.user_group=n,this.device_id=e,this.user_id=r,this._lists=i}items(){let e=[],t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i=0,a=r.items;for(;i<a.length;){let t=a[i];++i,e.push(t)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,n=this._lists;for(;t<n.length;){let r=n[t];if(++t,r.list_name==e)return r}return null}toJson(){let e={request_id:this.request_id,user_group:this.user_group,user_id:this.user_id,device_id:this.device_id,lists:[]},t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i={limit:r.limit,list_key:r.list_key,list_name:r.list_name,list_size:r.list_size,items:[]},o=0,s=r.items;for(;o<s.length;){let e=s[o];++o,i.items.push(a.__cast(e,A).getData())}e.lists.push(i)}return JSON.stringify(e)}static fromRequestData(e){let n=x.getProperty(e,`lists`),r=[],i=0;for(;i<n.length;){let t=n[i];++i;let a=x.getProperty(t,`items`),o=[],s=0;for(;s<a.length;){let t=a[s];++s,x.setProperty(t,`request_id`,x.getProperty(e,`request_id`)),x.setProperty(t,`user_group`,x.getProperty(e,`user_group`)),o.push(new A(t))}let c=new k({limit:x.getProperty(t,`limit`),list_key:x.getProperty(t,`list_key`),list_name:x.getProperty(t,`list_name`),list_size:x.getProperty(t,`list_size`),items:o,request_id:x.getProperty(e,`request_id`)});r.push(c)}return new t(x.getProperty(e,`device_id`),x.getProperty(e,`request_id`),x.getProperty(e,`user_group`),x.getProperty(e,`user_id`),r)}static get __name__(){return`internal._RecommendationsInternal`}static get __interfaces__(){return[w]}get __class__(){return t}};O.prototype.request_id=null,O.prototype.user_group=null,O.prototype.user_id=null,O.prototype.device_id=null,O.prototype._lists=null;const k=e.global(`$hxClasses`)[`internal._RecommendationsListInternal`]=class t extends e.inherits(){[e.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size,this.request_id=e.request_id}static get __name__(){return`internal._RecommendationsListInternal`}static get __interfaces__(){return[T]}get __class__(){return t}};k.prototype.limit=null,k.prototype.list_key=null,k.prototype.list_name=null,k.prototype.list_size=null,k.prototype.items=null,k.prototype.request_id=null;const A=e.global(`$hxClasses`)[`internal._RecommendationItemInternal`]=class t extends e.inherits(){[e.new](e){this.Id=x.getProperty(e,`item_id`),this.RequestId=x.getProperty(e,`request_id`),this.UserGroup=x.getProperty(e,`user_group`),this._data=e}getData(){return this._data}get(e){return this._data[e]}toJson(){return JSON.stringify(this._data)}static get __name__(){return`internal._RecommendationItemInternal`}static get __interfaces__(){return[E]}get __class__(){return t}};A.prototype.Id=null,A.prototype.RequestId=null,A.prototype.UserGroup=null,A.prototype._data=null,e.$global;const ee=function(){};ee.__isInterface__=!0,e.$global;const j=e.global(`$hxClasses`)[`internal.js.JSFroomleDomTree`]=class t extends e.inherits(){[e.new](){}getRoot(){return this.root}createElement(e){return this.root.ownerDocument.createElement(e)}toString(){return this.root.ownerDocument.documentElement.outerHTML}static fromHTML(e){let n=new DOMParser().parseFromString(e,`text/html`),r=new t;return r.root=n.documentElement,r}static fromDocument(e){let n=new t;return n.root=e.documentElement,n}static get __name__(){return`internal.js.JSFroomleDomTree`}static get __interfaces__(){return[ee]}get __class__(){return t}};j.prototype.root=null,e.$global;const M=e.global(`$hxClasses`).StringBuf=class t extends e.inherits(){[e.new](){this.b=``}static get __name__(){return`StringBuf`}get __class__(){return t}};M.prototype.b=null,e.$global;const N=e.global(`$hxClasses`)[`internal.domHandler.DomDomDom`]=class t extends e.inherits(){[e.new](){}static _fillRecoTargets(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;if(e==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let s=[],c=[],l=e.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c;f.push(e);let p=0;for(;p<f.length;){let e=f[p];++p;let t=0,n=[],r=0,i=e.attributes;for(;r<i.length;){let e=i[r];++r,n.push({name:e.name,value:e.value})}let a=n;for(;t<a.length;){let n=a[t];++t,n.name==`data-froomle-reco`&&s.push(e)}}let m=[],g=0;for(;g<s.length;){let e=s[g];++g;let t=e.getAttribute(`data-froomle-request-id`),n=e.getAttribute(`data-froomle-id`);!(t!=null&&t!=``)&&!(n!=null&&n!=``)&&m.push(e)}if(m.length<1){let e=null,t=null,n=new Promise(function(n,r){e=n,t=r}),r=n;return r._resolve=e,r._reject=t,r._isFinished=!1,r._result=null,r._error=null,n}let _=[],v=[],y=``,b=[],S=[],C=[],w=function(e,t){if(e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(x.compare),l.sort(x.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0},T=function(){let e={list_name:y,list_size:S.length,limit:S.length},t=0;for(;t<b.length;){let n=b[t];if(++t,n!=null&&n.key!=null&&n.key!=``){let t=n.value;t instanceof Array||(t=[t]),x.setProperty(e,n.key,t)}}let n=0;for(;n<C.length;){let t=C[n];++n,x.setProperty(e,t.key,t.value)}_.push(e),v.push(S)},E=function(e,t,n,r){y=e,b=t,S=[r],C=n},O=0;for(;O<m.length;){let e=m[O];++O;let t=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-reco-filter-`)){let n=h.substr(e.name,25,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},n=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-variable-`)){let n=h.substr(e.name,22,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},r=e.getAttribute(`data-froomle-reco`),i=t(e),a=n(e);if(y==``){E(r,i,a,e);continue}else if(r==y&&w(b,i)&&w(C,a)){S.push(e);continue}else{T(),E(r,i,a,e);continue}}y!=``&&T();let k;if(D.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(D.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else try{k=D.getRawRecommendations(_)}catch{let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}return k.then(function(e){let n=e.lists(),r=n.length,i=0,a=r;for(;i<a;){let r=i++,a=n[r];a.items.length,v[r].length;let o=a.items.length,s=0,c=o;for(;s<c;){let n=s++,i=a.items[n],o=v[r][n];t._fillParameters(o,i,e.request_id)}}let s=o;s._isFinished||(s._result=!0,s._error=null,s._isFinished=!0,s._resolve(!0))}),o}static getAttrByPath(e,t,n){n==null&&(n=`fgh`);try{t=new v(`\\\\[(\\\\w+)\\\\]`,`g`).map(t,function(e){return`.`+e.matched(1)}),t=g.replace(t,`[`,`.`),t=g.replace(t,`]`,``),h.cca(t,0)==46&&(t=h.substr(t,1,null));let n=t.split(`.`),r=e.get(n[0]),a=1,o=n.length;for(;a<o;){let e=a++;if(r==null)return null;r=r instanceof Array&&i.parseInt(n[e])!=null?r[i.parseInt(n[e])]:x.field(r,n[e])}return r}catch{return n}}static stringifyValue(e,t){return t==null&&(t=``),e==null?t:i.string(e)}static isQuotedToken(e){if(e==null||e.length<2)return!1;let t=e.charAt(0),n=e.charAt(e.length-1);return t==`'`&&n==`'`?!0:t==`"`?n==`"`:!1}static unescapeQuotedValue(e){let t=e;return t=g.replace(t,`\\'`,`'`),t=g.replace(t,`\\"`,`"`),t=g.replace(t,`\\\\`,`\\`),t}static unquoteToken(e){let n=g.trim(e);if(!t.isQuotedToken(n))return n;let r=h.substr(n,1,n.length-2);return t.unescapeQuotedValue(r)}static splitTopLevel(e,t){if(t==null||t.length!=1)return[e];let n=t.charAt(0),r=[],i=new M,a=0,o=null,s=!1,c=0,l=e.length;for(;c<l;){let t=c++,l=e.charAt(t);if(s){i.b+=l==null?`null`:``+l,s=!1;continue}if(o!=null){if(l==`\\`){i.b+=l==null?`null`:``+l,s=!0;continue}l==o&&(o=null),i.b+=l==null?`null`:``+l;continue}if(l==`'`||l==`"`){o=l,i.b+=l==null?`null`:``+l;continue}if(l==`(`?++a:l==`)`&&a>0&&--a,a==0&&l==n){r.push(g.trim(i.b)),i=new M;continue}i.b+=l==null?`null`:``+l}return r.push(g.trim(i.b)),r}static parseTransformPart(e){let n=g.trim(e);if(n==``)return{name:``,args:[]};let r=n.indexOf(`(`);if(r==-1||!n.endsWith(`)`))return{name:n,args:[]};let i=g.trim(h.substr(n,0,r)),a=h.substr(n,r+1,n.length-r-2),o=[];if(g.trim(a)!=``){let e=0,n=t.splitTopLevel(a,`,`);for(;e<n.length;){let r=n[e];++e,o.push(t.unquoteToken(r))}}return{name:i,args:o}}static resolveSeedValue(e,n,r){let i=g.trim(e);return i==``?r:t.isQuotedToken(i)?t.unquoteToken(i):t.stringifyValue(t.getAttrByPath(n,i,r),r)}static resolveFieldPathValue(e,n){let r=g.trim(e);return r==``?``:t.stringifyValue(t.getAttrByPath(n,r,null),``)}static applyTransform(e,n,r,i){let a=e==null?``:e;switch(n==null?``:n.toLowerCase()){case`append`:return r.length>=1?a+r[0]:a;case`default`:return(a==null||a==``)&&r.length>=1?r[0]:a;case`defaultfield`:return(a==null||a==``)&&r.length>=1?t.resolveFieldPathValue(r[0],i):a;case`lower`:return a.toLowerCase();case`prepend`:return r.length>=1?r[0]+a:a;case`replace`:return r.length>=2?g.replace(a,r[0],r[1]):a;case`trim`:return g.trim(a);case`upper`:return a.toUpperCase();case`urlencode`:return encodeURIComponent(a);default:return a}}static evaluateExpression(e,n,r){let i=g.trim(e);if(i.startsWith(`=`)&&(i=g.trim(h.substr(i,1,null))),i==``)return r;let a=t.splitTopLevel(i,`|`);if(a.length==0)return r;let o=t.resolveSeedValue(a[0],n,r),s=1,c=a.length;for(;s<c;){let e=s++,r=t.parseTransformPart(a[e]);r.name!=``&&(o=t.applyTransform(o,r.name,r.args,n))}return o}static findTemplateExpressionEnd(e,t){let n=null,r=!1,i=0,a=t;for(;a<e.length;){let t=e.charAt(a);if(r){r=!1,++a;continue}if(n!=null){t==`\\`?r=!0:t==n&&(n=null),++a;continue}if(t==`'`||t==`"`){n=t,++a;continue}if(t==`$`&&a+1<e.length&&e.charAt(a+1)==`{`){++i,a+=2;continue}if(t==`}`){if(i==0)return a;--i}++a}return-1}static resolveTemplate(e,n,r){if(e.indexOf("${")==-1)return e;let a=``,o=0;for(;o<e.length;){let s=e.indexOf("${",o);if(s==-1){a+=i.string(h.substr(e,o,null));break}a+=i.string(h.substr(e,o,s-o));let c=t.findTemplateExpressionEnd(e,s+2);if(c==-1){a+=i.string(h.substr(e,s,null));break}let l=h.substr(e,s+2,c-s-2);a+=i.string(t.evaluateExpression(l,n,r)),o=c+1}return a}static resolveParamValue(e,n,r){r==null&&(r=``);let i=t.stringifyValue(r,``),a=e==null?``:e,o=g.trim(a);return o==``?i:a.indexOf("${")==-1?o.startsWith(`=`)?t.evaluateExpression(h.substr(o,1,null),n,i):t.stringifyValue(t.getAttrByPath(n,o,i),i):t.resolveTemplate(a,n,i)}static _buildHistories(e){let t=[],n=[],r=e.querySelectorAll(`[data-froomle-id]`),i=0,a=r.length;for(;i<a;){let e=i++,t=r.item(e);t instanceof HTMLElement&&n.push(t)}let o=n,s=0;for(;s<o.length;){let e=o[s];++s,t.push(e.getAttribute(`data-froomle-id`))}D.addHistories(t)}static fillParam(e,n,r,i,a){a==null&&(a=``);try{let o=t.resolveParamValue(r,i,a);n==`inner`?(e.textContent=o,e.textContent):e.setAttribute(n,o)}catch{}}static _fillParameters(e,n,r){e.setAttribute(`data-froomle-id`,n.get(`item_id`)),e.setAttribute(`data-froomle-request-id`,r);let a=n.get(`item_type`);a!=null&&i.string(a)!=``&&e.setAttribute(`data-froomle-item-type`,i.string(a)),n.UserGroup!=null&&n.UserGroup!=``&&e.setAttribute(`data-froomle-user-group`,n.UserGroup);let o=[],s=e.querySelectorAll(`*`),c=0,l=s.length;for(;c<l;){let e=c++,t=s.item(e);t instanceof HTMLElement&&o.push(t)}let u=o,d=0;for(;d<u.length;){let e=u[d];++d;let r=0,i=[],a=0,o=e.attributes;for(;a<o.length;){let e=o[a];++a,i.push({name:e.name,value:e.value})}let s=i;for(;r<s.length;){let i=s[r];if(++r,i.name.startsWith(`data-froomle-param-`)){let r=g.replace(i.name,`data-froomle-param-`,``),a=i.value;t.fillParam(e,r,a,n)}}}}static _orderElements(e){let t=function(t,n,r){let i=[],a=[],o=0,s=t.childNodes;for(;o<s.length;){let e=s[o];++o,a.push(e)}let c=a,l=0;for(;l<c.length;){let n=c[l];++l;try{if(n.getAttribute(`data-froomle-ordervalue`)!=null){i.push(n);let r=e.createElement(`span`);r.setAttribute(`data-froomle-tmp-node`,`tmp`),t.replaceChild(r,n)}}catch{}}let u=[],d=0;for(;d<i.length;){let e=i[d];++d,u.push(e.getAttribute(`data-froomle-ordervalue`))}return{el:t,key:n,values:u,orderChildren:i,list_name:r}},n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i,s=e.getRoot(),c=[],l=s.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c,p=[],m=0;for(;m<f.length;){let e=f[m];++m;let n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let r=o[n];++n,r.name.startsWith(`data-froomle-order-`)&&p.push(t(e,r.name.substring(19),r.value))}}if(p.length<1){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let h=[],g=0;for(;g<p.length;){let e=p[g];++g;let t={list_name:e.list_name,limit:e.values.length,list_size:e.values.length},n={};x.setProperty(n,e.key,e.values),x.setProperty(t,`order`,n),h.push(t)}if(D.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(D.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}try{D.getRawRecommendations(h).then(function(e){let t=e.lists(),n=t.length,r=0,i=n;for(;r<i;){let n=r++,i=t[n],a=p[n];a.el.setAttribute(`data-froomle-request-id`,e.request_id);let o=[],s=0,c=i.items;for(;s<c.length;){let e=c[s];++s;let t=e.get(a.key);e.get(a.key);let n=a.values.length,r=0,i=n;for(;r<i;){let e=r++;if(t==a.values[e]){a.orderChildren.length;let t=a.orderChildren[e];o.push(t),a.orderChildren.splice(e,1),a.values.splice(e,1);break}}}o.length;let l=a.el,u=[],d=0,f=l.childNodes;for(;d<f.length;){let e=f[d];++d,u.push(e)}let m=u.length,h=0,g=m;for(;h<g;){let e=h++,t=a.el,n=[],r=0,i=t.childNodes;for(;r<i.length;){let e=i[r];++r,n.push(e)}let s=n[e],c=s,l;if(l=c instanceof HTMLElement?c.hasAttribute(`data-froomle-tmp-node`):!1,l&&(a.el.replaceChild(o[0],s),o.splice(0,1),o.length,o.length==0))break}}let a=o;a._isFinished||(a._result=!0,a._error=null,a._isFinished=!0,a._resolve(!0))})}catch{let e=o;e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1))}return o}static domInit(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;return t._orderElements(e).then(function(n){t._buildHistories(e.getRoot()),t._fillRecoTargets(e.getRoot()).then(function(e){let t=o;t._isFinished||(t._result=!0,t._error=null,t._isFinished=!0,t._resolve(!0))})}),o}static fillElementRecos(e){t._fillRecoTargets(e)}static runFromHtml(e){if(e==``)return``;let n;try{let t=new DOMParser().parseFromString(e,`text/html`),r=new j;r.root=t.documentElement,n=r}catch{return e}return t.domInit(n),n.toString()}static get __name__(){return`internal.domHandler.DomDomDom`}get __class__(){return t}};e.$global;const P=e.global(`$hxClasses`).FroomleSdk=class e{static register(){e.registered||e._env_set&&e._page_visit_set&&(e.registered=!0)}static buildScriptTag(){let e=`<script src="https://cdn.jsdelivr.net/npm/@froomle/frontend-sdk@0.0.30/dist/froomle.global.js" data-froomle-env="`+D.getEnvironment()+`" `,t=D.getPageVisit();t!=null&&(e+=`data-froomle-page-visit="`+t+`" `);let n=D.getContextItem();if(n!=null){e+=`data-froomle-context-item="`+n+`" `;let t=D.getContextItemType();(t==null||t==``)&&(t=`article`),e+=`data-froomle-context-item-type="`+t+`" `}let r=D.getDeviceId();r!=null&&(e+=`data-froomle-device-id="`+r+`" `);let i=D.getUserId();i!=null&&(e+=`data-froomle-user-id="`+i+`" `);let a=D.getConsent();a>0&&(e+=`data-froomle-consent="`+a+`" `);let o=D.getRequestDomain();o!=null&&(e+=`data-froomle-request-domain="`+o+`" `);let s=D.getChannel();return s!=null&&(e+=`data-froomle-channel="`+s+`" `),e+=`><\/script>`,e}static setEnvironment(t){D.setEnvironment(t),e._env_set=!0,e.register()}static setDeviceId(e){D.setDeviceId(e)}static setUserId(e){D.setUserId(e)}static setConsent(e){D.setConsent(e)}static setPageVisit(t){D.setPageVisit(t),e._page_visit_set=!0,e.register()}static setChannel(e){D.setChannel(e)}static setRequestDomain(e){D.setRequestDomain(e)}static setRecommendationsAccessToken(e){D.setRecommendationsAccessToken(e)}static clearRecommendationsAccessToken(){D.clearRecommendationsAccessToken()}static setRecommendationsAccessTokenProvider(e){D.setRecommendationsAccessTokenProvider(e)}static clearRecommendationsAccessTokenProvider(){D.clearRecommendationsAccessTokenProvider()}static setSafeRequest(e){D.setSafeRequest(e)}static setContextItem(e){D.setContextItem(e)}static setContextItemType(e){D.setContextItemType(e)}static setCustomVariable(e,t){D.setOthers(e,t)}static getUserId(){return D.getUserId()}static getDeviceId(){return D.getDeviceId()}static getEnvironment(){return D.getEnvironment()}static getSafeRequest(){return D.getSafeRequest()}static getPageVisit(){return D.getPageVisit()}static getConsent(){return D.getConsent()}static getRecommendations(e){return D.getRawRecommendations(e)}static getChannel(){return D.getChannel()}static getVersion(){return`0.0.30`}static runFromHtml(e){return N.runFromHtml(e)}static get __name__(){return`FroomleSdk`}get __class__(){return e}};P._env_set=!1,P._page_visit_set=!1,P.registered=!1;function te(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}function ne(){return`frontend-sdk/${P.getVersion()}`}function re(){return{"Content-Type":`application/json`,Accept:`application/json`,"X-Froomle-Client":ne()}}function ie(e){return JSON.stringify({events:e})}async function F(e,t={}){let n=ie(e),r=te(),{keepalive:i=!1,allowBeaconFallback:a=!1}=t;try{return await fetch(r,{method:`POST`,headers:re(),body:n,...i?{keepalive:!0}:{}}),`fetch`}catch(e){if(a&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(r,e))return`beacon`}throw e}}function ae(){if(D.getConsent()<2)return;let e=D.getUserId();if(e)return e}function oe(){let e=D.getContextItem();if(e)return e}function se(){let e=D.getContextItemType();if(e)return e}function I(){return D.getConsent()>=1}function ce(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}function le(){let e=D.getChannel();if(e)return e}function ue(e){var t;let n=e==null?void 0:e.getAttribute(`data-froomle-user-group`);if(n)return n;if(!(typeof document>`u`))return((t=document.querySelector(`[data-froomle-user-group]`))==null?void 0:t.getAttribute(`data-froomle-user-group`))||void 0}function de(e){let t={event_type:e,page_type:D.getPageVisit(),channel:le()||`www-desktop`,device_id:ce()},n=ue();n&&(t.user_group=n);let r=ae();return r&&(t.user_id=r),t}function fe(e,t){if(!t)return e;for(let n in t)e[n]=t[n];return e}function L(e){I()&&F([e]).catch(()=>{})}function R(e,t,n,r){let i=t||oe();if(!i)return null;let a=de(e);return a.action_item=i,a.action_item_type=n||se()||`article`,fe(a,r)}function pe(e,t,n=`impression`,r){let i=R(n,e,t,r);i&&L(i)}function me(e,t,n,r){let i=R(`item_interaction`,n?e:void 0,n&&typeof t==`string`?t:void 0,{interaction_type:n||e,...n?r:t});i&&L(i)}function he(e,t){let n=de(`user_interaction`);n.interaction_type=e,L(fe(n,t))}function ge(e,t,n,r){let i=R(`add_to_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&L(i)}function _e(e,t,n,r){let i=R(`remove_from_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&L(i)}function ve(e,t,n,r,i){let a=typeof e==`string`,o=R(`purchase`,a?e:void 0,a&&typeof t==`string`?t:void 0,{amount:a?n:e,purchased_price:a?r:t,...a?i:n});o&&L(o)}function ye(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-id`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item`));if(t)return t}function be(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-item-type`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item-type`));if(t)return t}var z=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateEvents(){let t=[];for(let n of e.impressionQueue){let e=ye(n);if(!e)continue;let r=be(n)||`article`,i=le()||`www-desktop`,a={event_type:`impression`,page_type:D.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ce()},o=ue(n);o&&(a.user_group=o),D.getConsent()>=2&&D.getUserId()&&(a.user_id=D.getUserId());let s=n.getAttribute(`data-froomle-reco`),c=n.getAttribute(`data-froomle-request-id`);s&&c&&(a.list_name=s,a.request_id=c),t.push(a)}return e.impressionQueue=[],t}static sendImpressions(){if(console.log(e.impressionQueue),e.impressionQueue.length===0||!I())return;let t=e.generateEvents();t.length!==0&&F(t).catch(()=>{})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(t){let n=t.getBoundingClientRect(),r=e.getViewPortRect();return n.right>r.left&&n.left<r.right&&n.bottom>r.top&&n.top<r.bottom}static addIntersectionImpressionListener(t){e.observer.observe(t)}static processDocument(){if(I()){console.log(`🚀 Processing document for impressions`);for(let t of document.querySelectorAll(`[data-froomle-id]`))e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}static processElement(t){if(!I()||!(t instanceof Element))return;let n=[];t.matches(`[data-froomle-id]`)&&n.push(t);for(let e of t.querySelectorAll(`[data-froomle-id]`))n.push(e);if(n.length!==0){for(let t of n)e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}};z.impressionQueue=[],z.observer=null,typeof document<`u`&&(z.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(z.impressionQueue.push(e.target),z.observer.unobserve(e.target))}),z.impressionQueue.length>0&&z.sendImpressions()}));var xe=class e{static canTrackEvents(){return D.getConsent()>=1}static readDeviceId(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}static readChannel(){let e=D.getChannel();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readChannel()||`www-desktop`,n={event_type:`page_visit`,page_type:D.getPageVisit(),channel:t,device_id:e.readDeviceId()},r=e.readUserGroup();return r&&(n.user_group=r),D.getConsent()>=2&&D.getUserId()&&(n.user_id=D.getUserId()),n}static sendPageVisit(){D.getPageVisit()&&(D.getContextItem()||e.canTrackEvents()&&F([e.generateEvent()]).catch(()=>{}))}},Se=class e{static canTrackEvents(){return D.getConsent()>=1}static readDeviceId(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}static readChannel(){let e=D.getChannel();if(e)return e}static readActionItemType(){let e=D.getContextItemType();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readActionItemType()||`article`,n=e.readChannel()||`www-desktop`,r={event_type:`detail_pageview`,page_type:D.getPageVisit(),action_item:D.getContextItem(),action_item_type:t,channel:n,device_id:e.readDeviceId()},i=e.readUserGroup();return i&&(r.user_group=i),D.getConsent()>=2&&D.getUserId()&&(r.user_id=D.getUserId()),r}static sendPageView(){D.getContextItem()&&D.getPageVisit()&&e.canTrackEvents()&&F([e.generateEvent()]).catch(()=>{})}},B=class e{static readAttributeFromChain(e,t){let n=e;for(;n;){for(let e of t){let t=n.getAttribute(e);if(t)return t}n=n.parentElement}}static canTrackEvents(){return D.getConsent()>=1}static readDeviceId(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}static readChannel(){let e=D.getChannel();if(e)return e}static readActionItem(t){return e.readAttributeFromChain(t,[`data-froomle-id`,`data-froomle-action-item`])}static readActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-item-type`,`data-froomle-action-item-type`])}static readExplicitActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-action-item-type`])}static readUserGroup(t){var n;let r=e.readAttributeFromChain(t,[`data-froomle-user-group`]);if(r)return r;if(!(typeof document>`u`))return((n=document.querySelector(`[data-froomle-user-group]`))==null?void 0:n.getAttribute(`data-froomle-user-group`))||void 0}static registerClickables(){e.listenerRegistered||(e.listenerRegistered=!0,document.addEventListener(`click`,t=>{if(!e.canTrackEvents())return;let n=t instanceof MouseEvent?t:null,r=t.target,i=r instanceof Element?r:r instanceof Node?r.parentElement:null;if(!i)return;let a=i.closest(`a`);if(!a)return;let o=a.closest(`[data-froomle-id]`);if(!o)return;let s=a.closest(`[data-froomle-reco]`),c=(s?e.readActionItem(s):void 0)||e.readActionItem(o);if(!c)return;let l=e.readExplicitActionItemType(a)||(s?e.readActionItemType(s):void 0)||e.readActionItemType(o)||`article`,u=e.readChannel()||`www-desktop`,d=a instanceof HTMLAnchorElement?a.href:null,f=a.getAttribute(`href`),p=typeof f==`string`&&f.trim().startsWith(`#`),m=!!d&&!p&&t.cancelable&&!t.defaultPrevented&&!a.hasAttribute(`download`)&&(!a.target||a.target===`_self`)&&!!n&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey,h=p&&t.cancelable&&!t.defaultPrevented;(m||h)&&t.preventDefault();let g={event_type:`click_on_recommendation`,page_type:D.getPageVisit(),action_item:c,action_item_type:l,channel:u,device_id:e.readDeviceId()},_=(s?e.readUserGroup(s):void 0)||e.readUserGroup(o);_&&(g.user_group=_);let v=(s?e.readAttributeFromChain(s,[`data-froomle-reco`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-reco`]),y=(s?e.readAttributeFromChain(s,[`data-froomle-request-id`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-request-id`]);if(v&&y&&(g.list_name=v,g.request_id=y),D.getConsent()>=2&&D.getUserId()&&(g.user_id=D.getUserId()),m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);F([g],{keepalive:!0,allowBeaconFallback:!0}).catch(()=>{}).finally(()=>{window.clearTimeout(n),t()});return}F([g],{allowBeaconFallback:!0}).catch(()=>{})},!0))}};B.listenerRegistered=!1;const Ce=j,V=P.setEnvironment,H=P.setPageVisit,U=P.setRequestDomain,W=P.setSafeRequest,G=typeof P.setChannel==`function`?P.setChannel:D.setChannel,we=P.setRecommendationsAccessToken,Te=P.clearRecommendationsAccessToken,Ee=P.setRecommendationsAccessTokenProvider,De=P.clearRecommendationsAccessTokenProvider,K=P.setContextItem,q=P.setContextItemType,Oe=D.addHistories;function ke(e,t){P.setCustomVariable(e,t)}function Ae(e){we(e==null?null:e)}function je(){Te()}function Me(e){Ee(e)}function Ne(){De()}function J(e){P.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Y(e){P.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function X(e){P.setConsent(e),document.cookie=`froomle_consent=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`,document.cookie=`froomle_device_id=${P.getDeviceId()}; max-age=${3600*24*365*20}; path=/; samesite=lax`}typeof window<`u`&&(window.setFroomleConsent=X);function Pe(e){let t=document.cookie.split(`; `);for(let n of t){let[t,r]=n.split(`=`);if(t===e)return decodeURIComponent(r)}return null}function Fe(e){return P.getRecommendations(e)}const Z=globalThis,Ie=`FroomleFrontendSdkState`,Le=`FroomleFrontendSdkReady`;function Re(){let e=()=>{},t=()=>{},n=new Promise((n,r)=>{e=n,t=r}),r={initStarted:!1,initialized:!1,beforeInitEventDispatched:!1,initEventDispatched:!1,readyPromise:n,resolveReady:e,rejectReady:t};return Z[Ie]=r,Z[Le]=n,r}function Q(){if(!Z[Ie])return Re();let e=Z[Ie];return Z[Le]||(Z[Le]=e.readyPromise),e}function $(){return Z.FroomleFrontendSdk?Z.FroomleFrontendSdk:{RecommendationItem:E,RecommendationList:T,Recommendations:w,setPageVisit:H,setEnvironment:V,setConsent:X,setUserId:J,setDeviceId:Y,setRequestDomain:U,setSafeRequest:W,setChannel:G,setRecommendationsBearer:Ae,clearRecommendationsBearer:je,setRecommendationsBearerProvider:Me,clearRecommendationsBearerProvider:Ne,setContextItem:K,setContextItemType:q,setCustomVariable:ke,getRecommendations:Fe,sendEvent:pe,sendItemInteraction:me,sendUserInteraction:he,sendAddToCart:ge,sendRemoveFromCart:_e,sendPurchase:ve,addHistories:Oe,init:Ke}}function ze(e){return{sdk:$(),mode:e,version:typeof P.getVersion==`function`?P.getVersion():void 0}}function Be(e,t){if(typeof window>`u`)return;if(typeof window.CustomEvent==`function`){window.dispatchEvent(new window.CustomEvent(e,{detail:t}));return}let n=document.createEvent(`CustomEvent`);n.initCustomEvent(e,!1,!1,t),window.dispatchEvent(n)}function Ve(e){let t=Q();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,Be(`froomle:before-init`,ze(e)))}function He(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,Be(`froomle:init`,ze(e)))}function Ue(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady($())),He(e)}function We(e){Q().rejectReady(e)}function Ge(e=`auto`){if(typeof document>`u`)return Promise.resolve($());let t=Q();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{Ve(e),console.log(`froomle loads dom`),N.domInit(Ce.fromDocument(document)).then(()=>{B.registerClickables(),z.processDocument(),xe.sendPageVisit(),Se.sendPageView(),Ue(e)}).catch(e=>{We(e)});function t(e){return e.matches(`[data-froomle-reco]`)||e.querySelector(`[data-froomle-reco]`)!==null}new MutationObserver(e=>{for(let n of e)if(n.type===`childList`&&n.addedNodes.forEach(e=>{e instanceof Element&&(t(e)&&N.fillElementRecos(e),z.processElement(e))}),n.type===`attributes`&&n.target instanceof Element)if(n.attributeName===`data-froomle-reco`){let e=n.target.getAttribute(`data-froomle-request-id`);(!e||e===``)&&N.fillElementRecos(n.target)}else if(n.attributeName===`data-froomle-request-id`){let e=n.target.getAttribute(`data-froomle-request-id`),t=n.target.getAttribute(`data-froomle-id`);n.target.getAttribute(`data-froomle-reco`)&&(!e||e===``)&&(!t||t===``)&&N.fillElementRecos(n.target)}else n.attributeName===`data-froomle-id`&&z.processElement(n.target)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-froomle-reco`,`data-froomle-request-id`,`data-froomle-id`]})},r=()=>{globalThis.setTimeout(n,0)};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r,{once:!0}):r(),t.readyPromise}function Ke(){return Ge(`manual`)}if(!globalThis.froomleInitialized&&(globalThis.froomleInitialized=!0,typeof document<`u`)){Q();let e=document.currentScript;if(e){let t=e.getAttribute(`data-froomle-device-id`),n=e.getAttribute(`data-froomle-user-id`),r=e.getAttribute(`data-froomle-env`),i=e.getAttribute(`data-froomle-page-visit`),a=e.getAttribute(`data-froomle-request-domain`),o=e.getAttribute(`data-froomle-context-item`),s=e.getAttribute(`data-froomle-context-item-type`),c=e.getAttribute(`data-froomle-safe-request`),l=e.getAttribute(`data-froomle-channel`);if(V(r),i&&H(i),o&&(K(o),q(s||`article`)),t)Y(t);else{let e=Pe(`froomle_device_id`);e&&Y(e)}if(n)J(n);else{let e=Pe(`froomle_user_id`);e&&J(e)}a&&U(a),c&&W(c!==`false`),l&&G(l)}let t=Pe(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||X(e)}Ge(`auto`)}export{A,ge as C,_e as D,ve as E,T as M,w as N,he as O,z as S,me as T,W as _,Ke as a,Se as b,K as c,Y as d,V as f,U as g,Me as h,Fe as i,E as j,D as k,q as l,Ae as m,je as n,G as o,H as p,Ne as r,X as s,Oe as t,ke as u,J as v,pe as w,xe as x,B as y};
|
package/dist/src-CVJOYhnj.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var e=class e{static global(t){return e.globals[t]?e.globals[t]:e.globals[t]={}}static createStatic(e,t,n){let r=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return n!=null&&(r=n(),n=null),r},set:function(e){n!=null&&(r=n(),n=null),r=e}})}static iterator(t){if(Array.isArray(t)){let n=t;return function(){return e.mkIter(n)}}else return typeof t.iterator==`function`?t.iterator.bind(t):t.iterator}static getIterator(t){return Array.isArray(t)?e.mkIter(t):t.iterator()}static mkIter(e){return new t(e)}static extend(t){function n(){this[e.new].apply(this,arguments)}return Object.setPrototypeOf(n.prototype,t.prototype),n}static inherits(t,n){n==null&&(n=!1);function r(){n&&t&&r[e.init]&&r[e.init](),this[e.new].apply(this,arguments)}return n?r[e.init]=()=>{let n=t();n[e.init]&&n[e.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[e.init]=void 0}:t&&t[e.init]?(n=!0,r[e.init]=()=>{t[e.init]&&t[e.init](),Object.setPrototypeOf(r.prototype,t.prototype),r[e.init]=void 0}):t&&Object.setPrototypeOf(r.prototype,t.prototype),r}static bind(t,n){if(n==null)return null;n.__id__==null&&(n.__id__=e.fid++);let r=null;return t.hx__closures__==null?t.hx__closures__={}:r=t.hx__closures__[n.__id__],r==null&&(r=n.bind(t),t.hx__closures__[n.__id__]=r),r}static get __name__(){return`genes.Register`}get __class__(){return e}};e.$global=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:void 0,e.globals={},e.new=Symbol(),e.init=Symbol(),e.fid=0;const t=e.global(`$hxClasses`)[`genes._Register.ArrayIterator`]=class t extends e.inherits(){[e.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return`genes._Register.ArrayIterator`}get __class__(){return t}};t.prototype.array=null,t.prototype.current=null,e.$global;const n=e.global(`$hxClasses`)[`haxe.ValueException`]=class t extends e.inherits(()=>r,!0){[e.new](t,n,r){super[e.new](String(t),n,r),this.value=t}unwrap(){return this.value}static get __name__(){return`haxe.ValueException`}static get __super__(){return r}get __class__(){return t}};n.prototype.value=null,e.$global;const r=e.global(`$hxClasses`)[`haxe.Exception`]=class t extends e.inherits(()=>Error,!0){[e.new](e,t,n){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=n==null?this:n}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof t?e:e instanceof Error?new t(e.message,null,e):new n(e,null,e)}static thrown(e){return e instanceof t?e.get_native():e instanceof Error?e:new n(e)}static get __name__(){return`haxe.Exception`}static get __super__(){return Error}get __class__(){return t}};r.prototype.native=null,r.prototype.__skipStack=null,r.prototype.__nativeException=null,r.prototype.__previousException=null,e.$global;const i=e.global(`$hxClasses`).Std=class e{static string(e){return a.__string_rec(e,``)}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static random(e){return e<=0?0:Math.floor(Math.random()*e)}static get __name__(){return`Std`}get __class__(){return e}};Object.defineProperty(String.prototype,`__class__`,{value:String,enumerable:!1,writable:!0}),String.__name__=!0,Array.__name__=!0,e.$global;const a=e.global(`$hxClasses`)[`js.Boot`]=class t{static getClass(e){if(e==null)return null;if(e instanceof Array)return Array;{let n=e.__class__;if(n!=null)return n;let r=t.__nativeClassName(e);return r==null?null:t.__resolveNativeClass(r)}}static __string_rec(n,r){if(n==null)return`null`;if(r.length>=5)return`<...>`;let i=typeof n;switch(i==`function`&&(n.__name__||n.__ename__)&&(i=`object`),i){case`function`:return`<function>`;case`object`:if(n.__enum__){let i=e.global(`$hxEnums`)[n.__enum__].__constructs__[n._hx_index],a=i._hx_name;return i.__params__?(r+=` `,a+`(`+(function(e){var a;let o=[];{let e=0,a=i.__params__;for(;e<a.length;){let i=a[e];e+=1,o.push(t.__string_rec(n[i],r))}}return a=o,a})(this).join(`,`)+`)`):a}if(n instanceof Array){let e=`[`;r+=` `;let i=0,a=n.length;for(;i<a;){let a=i++;e+=(a>0?`,`:``)+t.__string_rec(n[a],r)}return e+=`]`,e}let i;try{i=n.toString}catch{return`???`}if(i!=null&&i!=Object.toString&&typeof i==`function`){let e=n.toString();if(e!=`[object Object]`)return e}let a=`{
|
|
2
|
-
`;r+=` `;let o=n.hasOwnProperty!=null,s=null;for(s in n)o&&!n.hasOwnProperty(s)||s==`prototype`||s==`__class__`||s==`__super__`||s==`__interfaces__`||s==`__properties__`||(a.length!=2&&(a+=`,
|
|
3
|
-
`),a+=r+s+` : `+t.__string_rec(n[s],r));return r=r.substring(1),a+=`
|
|
4
|
-
`+r+`}`,a;case`string`:return n;default:return String(n)}}static __interfLoop(e,n){if(e==null)return!1;if(e==n)return!0;let r=e.__interfaces__;if(r!=null&&(e.__super__==null||e.__super__.__interfaces__!=r)){let e=0,i=r.length;for(;e<i;){let i=r[e++];if(i==n||t.__interfLoop(i,n))return!0}}return t.__interfLoop(e.__super__,n)}static __instanceof(n,r){if(r==null)return!1;switch(r){case Array:return n instanceof Array;case`$hxCoreType__Bool`:return typeof n==`boolean`;case`$hxCoreType__Dynamic`:return n!=null;case`$hxCoreType__Float`:return typeof n==`number`;case`$hxCoreType__Int`:return typeof n==`number`?(n|0)===n:!1;case String:return typeof n==`string`;default:if(n!=null){if(typeof r==`function`){if(t.__downcastCheck(n,r))return!0}else if(typeof r==`object`&&t.__isNativeObj(r)&&n instanceof r)return!0}else return!1;return r==`$hxCoreType__Class`&&n.__name__!=null||r==`$hxCoreType__Enum`&&n.__ename__!=null?!0:n.__enum__==null?!1:e.global(`$hxEnums`)[n.__enum__]==r}}static __downcastCheck(e,n){return e instanceof n?!0:n.__isInterface__?t.__interfLoop(t.getClass(e),n):!1}static __cast(e,n){if(e==null||t.__instanceof(e,n))return e;throw r.thrown(`Cannot cast `+i.string(e)+` to `+i.string(n))}static __nativeClassName(e){let n=t.__toStr.call(e).slice(8,-1);return n==`Object`||n==`Function`||n==`Math`||n==`JSON`?null:n}static __isNativeObj(e){return t.__nativeClassName(e)!=null}static __resolveNativeClass(t){return e.$global[t]}static get __name__(){return`js.Boot`}get __class__(){return t}};a.__toStr={}.toString,e.$global;const o=e.global(`$hxClasses`)[`js.Browser`]=class e{static get supported(){return this.get_supported()}static get_supported(){return typeof window<`u`&&window.location!==void 0?typeof window.location.protocol==`string`:!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest<`u`)return new XMLHttpRequest;if(typeof ActiveXObject<`u`)return new`ActiveXObject`(`Microsoft.XMLHTTP`);throw r.thrown(`Unable to create XMLHttpRequest object.`)}static get __name__(){return`js.Browser`}get __class__(){return e}};e.$global;const s=e.global(`$hxEnums`)[`haxe.io.Error`]={__ename__:`haxe.io.Error`,Blocked:{_hx_name:`Blocked`,_hx_index:0,__enum__:`haxe.io.Error`},Overflow:{_hx_name:`Overflow`,_hx_index:1,__enum__:`haxe.io.Error`},OutsideBounds:{_hx_name:`OutsideBounds`,_hx_index:2,__enum__:`haxe.io.Error`},Custom:Object.assign(e=>({_hx_index:3,__enum__:`haxe.io.Error`,e}),{_hx_name:`Custom`,__params__:[`e`]})};s.__constructs__=[s.Blocked,s.Overflow,s.OutsideBounds,s.Custom],s.__empty_constructs__=[s.Blocked,s.Overflow,s.OutsideBounds],e.$global;const c=e.global(`$hxEnums`)[`haxe.io.Encoding`]={__ename__:`haxe.io.Encoding`,UTF8:{_hx_name:`UTF8`,_hx_index:0,__enum__:`haxe.io.Encoding`},RawNative:{_hx_name:`RawNative`,_hx_index:1,__enum__:`haxe.io.Encoding`}};c.__constructs__=[c.UTF8,c.RawNative],c.__empty_constructs__=[c.UTF8,c.RawNative],e.$global;const l=e.global(`$hxClasses`)[`haxe.io.Bytes`]=class t extends e.inherits(){[e.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,n){if(e<0||t<0||e+t>this.length)throw r.thrown(s.OutsideBounds);n==null&&(n=c.UTF8);let i=``,a=this.b,o=e,l=e+t;switch(n._hx_index){case 0:for(;o<l;){let e=a[o++];if(e<128){if(e==0)break;i+=String.fromCodePoint(e)}else if(e<224){let t=(e&63)<<6|a[o++]&127;i+=String.fromCodePoint(t)}else if(e<240){let t=a[o++],n=(e&31)<<12|(t&127)<<6|a[o++]&127;i+=String.fromCodePoint(n)}else{let t=a[o++],n=a[o++],r=(e&15)<<18|(t&127)<<12|(n&127)<<6|a[o++]&127;i+=String.fromCodePoint(r)}}break;case 1:for(;o<l;){let e=a[o++]|a[o++]<<8;i+=String.fromCodePoint(e)}break}return i}static ofData(e){let n=e.hxBytes;return n==null?new t(e):n}static get __name__(){return`haxe.io.Bytes`}get __class__(){return t}};l.prototype.length=null,l.prototype.b=null,e.$global;const u=e.global(`$hxClasses`)[`haxe.http.HttpBase`]=class t extends e.inherits(){[e.new](t){this.url=t,this.headers=[],this.params=[],this.emptyOnData=e.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let n=0,r=this.headers.length;for(;n<r;){let r=n++;if(this.headers[r].name==e){this.headers[r]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return e.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,c.UTF8)),this.responseAsString}static get __name__(){return`haxe.http.HttpBase`}get __class__(){return t}};u.prototype.url=null,u.prototype.responseBytes=null,u.prototype.responseAsString=null,u.prototype.postData=null,u.prototype.postBytes=null,u.prototype.headers=null,u.prototype.params=null,u.prototype.emptyOnData=null,e.$global;const d=e.global(`$hxClasses`)[`haxe.iterators.MapKeyValueIterator`]=class t extends e.inherits(){[e.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return`haxe.iterators.MapKeyValueIterator`}get __class__(){return t}};d.prototype.map=null,d.prototype.keys=null,e.$global;const f=function(){};f.__isInterface__=!0,e.$global;const p=e.global(`$hxClasses`)[`genes.util.EsMap`]=class t extends e.inherits(){[e.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return t.adaptIterator(this.inst.keys())}iterator(){return t.adaptIterator(this.inst.values())}toString(){let e=[],n=t.adaptIterator(this.inst.keys());for(;n.hasNext();){let t=n.next();e.push(``+i.string(t)+` => `+i.string(this.inst.get(t)))}return`{`+e.join(`, `)+`}`}clear(){this.inst.clear()}static adaptIterator(e){let t,n,r=function(){let r=e.next();t=r.value,n=r.done};return{hasNext:function(){return n==null&&r(),!n},next:function(){n==null&&r();let e=t;return r(),e}}}static get __name__(){return`genes.util.EsMap`}get __class__(){return t}};p.prototype.inst=null,e.$global;const m=e.global(`$hxClasses`)[`haxe.ds.StringMap`]=class t extends e.inherits(p){[e.new](){super[e.new]()}copy(){let e=new t;return e.inst=new Map(this.inst),e}keyValueIterator(){return new d(this)}static get __name__(){return`haxe.ds.StringMap`}static get __interfaces__(){return[f]}static get __super__(){return p}get __class__(){return t}};e.$global;const h=e.global(`$hxClasses`).HxOverrides=class e{static cca(e,t){let n=e.charCodeAt(t);if(n==n)return n}static substr(e,t,n){if(n==null)n=e.length;else if(n<0)if(t==0)n=e.length+n;else return``;return e.substr(t,n)}static now(){return Date.now()}static get __name__(){return`HxOverrides`}get __class__(){return e}};typeof performance<`u`&&typeof performance.now==`function`&&(h.now=performance.now.bind(performance)),e.$global;const g=e.global(`$hxClasses`).StringTools=class e{static isSpace(e,t){let n=h.cca(e,t);return n>8&&n<14?!0:n==32}static ltrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,r);)++r;return r>0?h.substr(t,r,n-r):t}static rtrim(t){let n=t.length,r=0;for(;r<n&&e.isSpace(t,n-r-1);)++r;return r>0?h.substr(t,0,n-r):t}static trim(t){return e.ltrim(e.rtrim(t))}static replace(e,t,n){return e.split(t).join(n)}static get __name__(){return`StringTools`}get __class__(){return e}};e.$global;const _=e.global(`$hxClasses`).Lambda=class t{static exists(t,n){let r=e.getIterator(t);for(;r.hasNext();)if(n(r.next()))return!0;return!1}static get __name__(){return`Lambda`}get __class__(){return t}};e.$global;const v=e.global(`$hxClasses`).EReg=class t extends e.inherits(){[e.new](e,t){this.r=new RegExp(e,t.split(`u`).join(``))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw r.thrown(`EReg::matched`)}matchedPos(){if(this.r.m==null)throw r.thrown(`No string matched`);return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,n){if(n==null&&(n=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(n<0?e:h.substr(e,0,t+n));let r=this.r.m!=null;return r&&(this.r.s=e),r}else{let r=this.match(n<0?h.substr(e,t,null):h.substr(e,t,n));return r&&(this.r.s=e,this.r.m.index+=t),r}}map(e,t){let n=0,r=``;do{if(n>=e.length)break;if(!this.matchSub(e,n)){r+=i.string(h.substr(e,n,null));break}let a=this.matchedPos();r+=i.string(h.substr(e,n,a.pos-n)),r+=i.string(t(this)),a.len==0?(r+=i.string(h.substr(e,a.pos,1)),n=a.pos+1):n=a.pos+a.len}while(this.r.global);return!this.r.global&&n>0&&n<e.length&&(r+=i.string(h.substr(e,n,null))),r}static get __name__(){return`EReg`}get __class__(){return t}};v.prototype.r=null,e.$global;const y=e.global(`$hxClasses`)[`haxe.http.HttpJs`]=class t extends e.inherits(u){[e.new](t){this.async=!0,this.withCredentials=!1,super[e.new](t)}request(t){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let n=this.req=o.createXMLHttpRequest(),a=this,s=function(t){if(n.readyState!=4)return;let r;try{r=n.status}catch{r=null}if(r==0&&o.get_supported()&&e.$global.location!=null){let t=e.$global.location.protocol.toLowerCase();new v(`^(?:about|app|app-storage|.+-extension|file|res|widget):$`,``).match(t)&&(r=n.response==null?404:200)}if(r==null&&(r=null),r!=null&&a.onStatus(r),r!=null&&r>=200&&r<400){a.req=null;let e=n.getAllResponseHeaders().split(`\r
|
|
5
|
-
`),t=[],r=0,i=e;for(;r<i.length;){let e=i[r];++r,e!=``&&t.push(e)}e=t,a.responseHeaders=new m;let o=0;for(;o<e.length;){let t=e[o];++o;let n=t.split(`: `),r=n.shift(),i=n.length==1?n[0]:n.join(`: `);i=g.ltrim(g.rtrim(i)),a.responseHeaders.inst.set(r,i)}a.success(l.ofData(n.response))}else if(r==null||r==0&&n.response==null)a.req=null,a.onError(`Failed to connect or resolve host`);else if(r==null)a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status);else switch(r){case 12007:a.req=null,a.onError(`Unknown host`);break;case 12029:a.req=null,a.onError(`Failed to connect to host`);break;default:a.req=null,a.responseBytes=n.response==null?null:l.ofData(n.response),a.onError(`Http Error #`+n.status)}};this.async&&(n.onreadystatechange=s);let c,u=this.postData,d=this.postBytes;if(u==null)if(d==null)c=null;else{let e=d;c=new Blob([e.b.bufferValue])}else c=d==null?u:null;if(c!=null)t=!0;else{let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,c=c==null?``:(c==null?`null`:i.string(c))+`&`;let r=n.name,a=(c==null?`null`:i.string(c))+encodeURIComponent(r)+`=`,o=n.value;c=a+encodeURIComponent(o)}}try{if(t)n.open(`POST`,this.url,this.async);else if(c!=null){let e=this.url.split(`?`).length<=1;n.open(`GET`,this.url+(e?`?`:`&`)+(c==null?`null`:i.string(c)),this.async),c=null}else n.open(`GET`,this.url,this.async);n.responseType=`arraybuffer`}catch(e){let t=r.caught(e).unwrap();this.req=null,this.onError(t.toString());return}n.withCredentials=this.withCredentials,!_.exists(this.headers,function(e){return e.name==`Content-Type`})&&t&&this.postData==null&&n.setRequestHeader(`Content-Type`,`application/x-www-form-urlencoded`);let f=0,p=this.headers;for(;f<p.length;){let e=p[f];++f,n.setRequestHeader(e.name,e.value)}n.send(c),this.async||s(null)}static get __name__(){return`haxe.http.HttpJs`}static get __super__(){return u}get __class__(){return t}};y.prototype.async=null,y.prototype.withCredentials=null,y.prototype.responseHeaders=null,y.prototype.req=null,e.$global;const b=e.global(`$hxClasses`).Type=class e{static createInstance(e,t){return new(Function.prototype.bind.apply(e,[null].concat(t)))}static get __name__(){return`Type`}get __class__(){return e}};e.$global;const x=e.global(`$hxClasses`).Reflect=class e{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let n;if(e==null)return null;{let r;return e.__properties__?(n=e.__properties__[`get_`+t],r=n):r=!1,r?e[n]():e[t]}}static setProperty(e,t,n){let r,i;e.__properties__?(r=e.__properties__[`set_`+t],i=r):i=!1,i?e[r](n):e[t]=n}static fields(e){let t=[];if(e!=null){let r=Object.prototype.hasOwnProperty;for(var n in e)n!=`__id__`&&n!=`hx__closures__`&&r.call(e,n)&&t.push(n)}return t}static compare(e,t){return e==t?0:e>t?1:-1}static get __name__(){return`Reflect`}get __class__(){return e}};e.$global;const S=e.global(`$hxClasses`)[`internal.http.FetchHttp`]=class t extends e.inherits(y){[e.new](t){this.responseStatus=0,super[e.new](t)}request(t){let n=e.$global,a=n.fetch,o=n.Headers,s=n.URLSearchParams;if(a==null){this.onError(`Fetch API not found.`);return}let c=b.createInstance(o,[]),l=0,u=this.headers;for(;l<u.length;){let e=u[l];++l,c.append(e.name,e.value)}let d=t?`POST`:`GET`,f=null;if(t)if(this.postData!=null)f=this.postData;else{f=b.createInstance(s,[]);let e=0,t=this.params;for(;e<t.length;){let n=t[e];++e,f.append(n.name,n.value)}}let p={method:d,headers:c,body:f},m=this,h=a(this.url,p).then(function(e){if(m.responseStatus=e.status,m.onStatus(e.status),e.ok)return e.text();throw r.thrown(`HTTP Error: `+i.string(e.status))}).then(function(e){m.onData(e)}),g=x.field(h,`catch`);g!=null&&g.apply(h,[function(e){m.onError(i.string(e))}])}static get __name__(){return`internal.http.FetchHttp`}static get __super__(){return y}get __class__(){return t}};S.prototype.responseStatus=null,e.$global;const C=e.global(`$hxClasses`)[`internal.data.UUID`]=class e{static randomHexChar(){return`0123456789abcdef`.charAt(i.random(16))}static v4(){let e=``,t=0;for(;t<36;)switch(t++){case 14:e+=`4`;break;case 19:e+=i.string(`0123456789abcdef`.charAt(8+i.random(4)));break;case 8:case 13:case 18:case 23:e+=`-`;break;default:e+=i.string(`0123456789abcdef`.charAt(i.random(16)))}return e}static get __name__(){return`internal.data.UUID`}get __class__(){return e}};C.HEX=`0123456789abcdef`,e.$global;const w=function(){};w.__isInterface__=!0;const T=function(){};T.__isInterface__=!0;const E=function(){};E.__isInterface__=!0,e.$global;const D=e.global(`$hxClasses`)[`internal.RecoBackendV2`]=class t extends e.inherits(){[e.new](){}static _requestUri(){return(t._safe_request?`https://`:`http://`)+t._req_domain+`/api/`+t._environment+`/recommendations/requests`}static noConsentBody(){return{device_id:`no-consent`,user_group:`no-consent`,version:`no-consent`}}static buildRequestBody(e){let n={lists:e,page_type:t._page_visit,channel:t._channel};if(t._consent>=2&&t._history.length>0&&(n.histories=t._buildHistories()),t._consent<2){let e=t.noConsentBody(),r=0,i=x.fields(e);for(;r<i.length;){let t=i[r];++r,n[t]=x.field(e,t)}}else t._user_id!=null&&(n.user_id=t._user_id),n.device_id=t._device_id;let r=0,a=t._others;for(;r<a.length;){let e=a[r];++r,n[e.key]=e.value}let o=x.field(n,`context_item`),s=x.field(n,`context_item_type`);return o!=null&&i.string(o)!=``&&(s==null||i.string(s)==``)&&(n.context_item_type=`article`),n}static _buildHistories(){return{pageviews:t._history}}static normalizeAccessToken(e){if(e==null)return null;let t=i.string(e);return t==``?null:t}static hasRecommendationsAccessTokenProvider(){return t._recommendations_access_token_provider!=null}static resolveRecommendationsAccessToken(e){if(!e){let e=t.normalizeAccessToken(t._recommendations_access_token);if(e!=null)return Promise.resolve(e)}if(!t.hasRecommendationsAccessTokenProvider())return Promise.resolve(t.normalizeAccessToken(t._recommendations_access_token));let n=null;try{n=t._recommendations_access_token_provider.apply(null,[{forceRefresh:e}])}catch(e){let t=r.caught(e).unwrap();return Promise.reject(t)}return Promise.resolve(n).then(function(e){let n=t.normalizeAccessToken(e);return t._recommendations_access_token=n,n})}static requestsToLists(e){let t=[],n=``,r=[],i=0,a=[],o=function(e,t,o){n=e,r=t,i=0,a=o},s=function(e){let t=[];if(e==null)return t;let n=0;for(;n<e.length;){let r=e[n];++n,!(r==null||r.key==null||r.key==``)&&t.push({key:r.key,value:r.value})}return t},c=function(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(x.compare),l.sort(x.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0},l=function(){let e={limit:i,list_name:n,list_size:i},o=0;for(;o<r.length;){let t=r[o];++o;let n=t.value;n instanceof Array||(n=[n]),e[t.key]=n}let s=0;for(;s<a.length;){let t=a[s];++s,e[t.key]=t.value}t.push(e)},u=0;for(;u<e.length;){let t=e[u];++u;let d=s(t.filters),f=t.others==null?[]:t.others;if(n==``){o(t.list,d,f),i+=1;continue}else (n!=t.list||!c(r,d)||!c(a,f))&&(l(),o(t.list,d,f));i+=1}return i!=0&&l(),t}static _requestRecos(e){let n=null,a=null,o=new Promise(function(e,t){n=e,a=t}),s=o;s._resolve=n,s._reject=a,s._isFinished=!1,s._result=null,s._error=null;let c=o,l=!1,u=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))},d=null;return d=function(n,a){if(l)return;let o=!1,s=!1,f=new S(t._requestUri());f.setHeader(`Content-Type`,`application/json`),f.setHeader(`X-Froomle-Client`,`frontend-sdk/0.0.30`);let p=t.normalizeAccessToken(n);p!=null&&f.setHeader(`Authorization`,`Bearer `+p);let m=t.buildRequestBody(e),h=JSON.stringify(m);f.setPostData(h),f.onError=function(e){o||s||l||(o=!0,u(`HTTP Request Error: `+e))},f.onStatus=function(e){if(!(o||l)){if(e==401&&a&&t.hasRecommendationsAccessTokenProvider()){o=!0,s=!0,t.resolveRecommendationsAccessToken(!0).then(function(e){return l?null:e==null?(u(`Recommendation access token provider returned no token during refresh.`),null):(d(e,!1),null)},function(e){return u(`Failed to refresh recommendation access token: `+i.string(e)),null});return}(e<200||e>=300)&&(o=!0,u(`HTTP Status Error: `+e))}};try{f.request(!0)}catch(e){let t=r.caught(e).unwrap();if(o||l)return;o=!0,u(`Failed to execute recommendation request: `+i.string(t));return}let g=function(e){if(!(o||s||l))try{let t=JSON.parse(e),n=O.fromRequestData(t);o=!0,l=!0;let r=c;r._isFinished||(r._result=n,r._error=null,r._isFinished=!0,r._resolve(n))}catch(e){let t=r.caught(e).unwrap();o=!0,u(`Failed to parse recommendation response: `+i.string(t))}},_=f.get_responseData();_==null?!o&&!s&&!l&&(f.onData=g):g(_)},t.resolveRecommendationsAccessToken(!1).then(function(e){return l?null:t.hasRecommendationsAccessTokenProvider()&&e==null?(u(`Recommendation access token provider returned no token.`),null):(d(e,t.hasRecommendationsAccessTokenProvider()),null)},function(e){return u(`Failed to resolve recommendation access token: `+i.string(e)),null}),c}static getOrder(e,n,a){let o={list_name:e,limit:a.length,list_size:a.length},s={};x.setProperty(s,n,a),x.setProperty(o,`order`,s);let c=null,l=null,u=new Promise(function(e,t){c=e,l=t}),d=u;d._resolve=c,d._reject=l,d._isFinished=!1,d._result=null,d._error=null;let f=u;return t.getRawRecommendations([o]).then(function(e){try{let t=[],n=e.lists();if(n!=null&&n.length>0){let e=n[0].items;if(e instanceof Array){let n=0,r=e;for(;n<r.length;){let e=r[n];++n;let i=e.get(`categories`);i!=null&&t.push(i)}}}let r=f;r._isFinished||(r._result=t,r._error=null,r._isFinished=!0,r._resolve(t))}catch(e){let t=r.caught(e).unwrap(),n=`Failed to build order response: `+i.string(t),a=f;a._isFinished||(a._error=n,a._isFinished=!0,a._reject(n))}},function(e){let t=f;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))}),f}static getRawRecommendations(e){return t._requestRecos(e)}static addHistories(e,n){if(n==null&&(n=`article`),e==null||e.length==0)return;let r=n!=null&&n!=``?n:`article`,a=0;for(;a<e.length;){let n=e[a];if(++a,typeof n==`string`){let e=i.string(n);e!=``&&t._history.push({id:e,item_type:r});continue}let o=n,s=x.field(o,`id`);if(s==null)continue;let c=i.string(s);if(c==``)continue;let l=x.field(o,`item_type`);(l==null||i.string(l)==``)&&(l=x.field(o,`itemType`));let u=l!=null&&i.string(l)!=``?i.string(l):r;t._history.push({id:c,item_type:u})}}static setOthers(e,n){let r=0,i=t._others;for(;r<i.length;){let t=i[r];if(++r,t.key==e){t.value=n;return}}t._others.push({key:e,value:n})}static setConsent(e){e>2&&(e=2),t._consent=e,e==2&&t.getDeviceId()==`no-consent`&&t.setDeviceId(C.v4())}static setChannel(e){t._channel=e}static setPageVisit(e){t._page_visit=e}static setEnvironment(e){t._environment=e}static setDeviceId(e){t._device_id=e}static setUserId(e){t._user_id=e}static setRequestDomain(e){t._req_domain=e}static setRecommendationsAccessToken(e){t._recommendations_access_token=t.normalizeAccessToken(e)}static clearRecommendationsAccessToken(){t._recommendations_access_token=null}static setRecommendationsAccessTokenProvider(e){t._recommendations_access_token_provider=e}static clearRecommendationsAccessTokenProvider(){t._recommendations_access_token_provider=null}static setSafeRequest(e){t._safe_request=e}static setContextItem(e){t.setOthers(`context_item`,e)}static setContextItemType(e){t.setOthers(`context_item_type`,e)}static getRequestDomain(){return t._req_domain}static getSafeRequest(){return t._safe_request}static getEnvironment(){return t._environment}static getPageVisit(){return t._page_visit}static getUserId(){return t._user_id}static getDeviceId(){return t._device_id}static getConsent(){return t._consent}static getChannel(){return t._channel}static getOthers(e){let n=0,r=t._others;for(;n<r.length;){let t=r[n];if(++n,e==t.key)return t.value}return null}static getContextItem(){return t.getOthers(`context_item`)}static getContextItemType(){return t.getOthers(`context_item_type`)}static get __name__(){return`internal.RecoBackendV2`}get __class__(){return t}};D._environment=null,D._device_id=`no-consent`,D._user_id=null,D._consent=0,D._req_domain=`europe-west1.froomle.com`,D._page_visit=null,D._channel=`www-desktop`,D._safe_request=!0,D._history=[],D._others=[],D._recommendations_access_token=null,D._recommendations_access_token_provider=null;const O=e.global(`$hxClasses`)[`internal._RecommendationsInternal`]=class t extends e.inherits(){[e.new](e,t,n,r,i){this.request_id=t,this.user_group=n,this.device_id=e,this.user_id=r,this._lists=i}items(){let e=[],t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i=0,a=r.items;for(;i<a.length;){let t=a[i];++i,e.push(t)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,n=this._lists;for(;t<n.length;){let r=n[t];if(++t,r.list_name==e)return r}return null}toJson(){let e={request_id:this.request_id,user_group:this.user_group,user_id:this.user_id,device_id:this.device_id,lists:[]},t=0,n=this._lists;for(;t<n.length;){let r=n[t];++t;let i={limit:r.limit,list_key:r.list_key,list_name:r.list_name,list_size:r.list_size,items:[]},o=0,s=r.items;for(;o<s.length;){let e=s[o];++o,i.items.push(a.__cast(e,A).getData())}e.lists.push(i)}return JSON.stringify(e)}static fromRequestData(e){let n=x.getProperty(e,`lists`),r=[],i=0;for(;i<n.length;){let t=n[i];++i;let a=x.getProperty(t,`items`),o=[],s=0;for(;s<a.length;){let t=a[s];++s,x.setProperty(t,`request_id`,x.getProperty(e,`request_id`)),x.setProperty(t,`user_group`,x.getProperty(e,`user_group`)),o.push(new A(t))}let c=new k({limit:x.getProperty(t,`limit`),list_key:x.getProperty(t,`list_key`),list_name:x.getProperty(t,`list_name`),list_size:x.getProperty(t,`list_size`),items:o,request_id:x.getProperty(e,`request_id`)});r.push(c)}return new t(x.getProperty(e,`device_id`),x.getProperty(e,`request_id`),x.getProperty(e,`user_group`),x.getProperty(e,`user_id`),r)}static get __name__(){return`internal._RecommendationsInternal`}static get __interfaces__(){return[w]}get __class__(){return t}};O.prototype.request_id=null,O.prototype.user_group=null,O.prototype.user_id=null,O.prototype.device_id=null,O.prototype._lists=null;const k=e.global(`$hxClasses`)[`internal._RecommendationsListInternal`]=class t extends e.inherits(){[e.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size,this.request_id=e.request_id}static get __name__(){return`internal._RecommendationsListInternal`}static get __interfaces__(){return[T]}get __class__(){return t}};k.prototype.limit=null,k.prototype.list_key=null,k.prototype.list_name=null,k.prototype.list_size=null,k.prototype.items=null,k.prototype.request_id=null;const A=e.global(`$hxClasses`)[`internal._RecommendationItemInternal`]=class t extends e.inherits(){[e.new](e){this.Id=x.getProperty(e,`item_id`),this.RequestId=x.getProperty(e,`request_id`),this.UserGroup=x.getProperty(e,`user_group`),this._data=e}getData(){return this._data}get(e){return this._data[e]}toJson(){return JSON.stringify(this._data)}static get __name__(){return`internal._RecommendationItemInternal`}static get __interfaces__(){return[E]}get __class__(){return t}};A.prototype.Id=null,A.prototype.RequestId=null,A.prototype.UserGroup=null,A.prototype._data=null,e.$global;const ee=function(){};ee.__isInterface__=!0,e.$global;const j=e.global(`$hxClasses`)[`internal.js.JSFroomleDomTree`]=class t extends e.inherits(){[e.new](){}getRoot(){return this.root}createElement(e){return this.root.ownerDocument.createElement(e)}toString(){return this.root.ownerDocument.documentElement.outerHTML}static fromHTML(e){let n=new DOMParser().parseFromString(e,`text/html`),r=new t;return r.root=n.documentElement,r}static fromDocument(e){let n=new t;return n.root=e.documentElement,n}static get __name__(){return`internal.js.JSFroomleDomTree`}static get __interfaces__(){return[ee]}get __class__(){return t}};j.prototype.root=null,e.$global;const M=e.global(`$hxClasses`).StringBuf=class t extends e.inherits(){[e.new](){this.b=``}static get __name__(){return`StringBuf`}get __class__(){return t}};M.prototype.b=null,e.$global;const N=e.global(`$hxClasses`)[`internal.domHandler.DomDomDom`]=class t extends e.inherits(){[e.new](){}static _fillRecoTargets(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;if(e==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let s=[],c=[],l=e.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c;f.push(e);let p=0;for(;p<f.length;){let e=f[p];++p;let t=0,n=[],r=0,i=e.attributes;for(;r<i.length;){let e=i[r];++r,n.push({name:e.name,value:e.value})}let a=n;for(;t<a.length;){let n=a[t];++t,n.name==`data-froomle-reco`&&s.push(e)}}let m=[],g=0;for(;g<s.length;){let e=s[g];++g;let t=e.getAttribute(`data-froomle-request-id`),n=e.getAttribute(`data-froomle-id`);!(t!=null&&t!=``)&&!(n!=null&&n!=``)&&m.push(e)}if(m.length<1){let e=null,t=null,n=new Promise(function(n,r){e=n,t=r}),r=n;return r._resolve=e,r._reject=t,r._isFinished=!1,r._result=null,r._error=null,n}let _=[],v=[],y=``,b=[],S=[],C=[],w=function(e,t){if(e.length!=t.length)return!1;let n=Array(e.length),r=0,i=e.length;for(;r<i;){let t=r++;n[t]=JSON.stringify(e[t])}let a=n,o=Array(t.length),s=0,c=t.length;for(;s<c;){let e=s++;o[e]=JSON.stringify(t[e])}let l=o;a.sort(x.compare),l.sort(x.compare);let u=0,d=a.length;for(;u<d;){let e=u++;if(a[e]!=l[e])return!1}return!0},T=function(){let e={list_name:y,list_size:S.length,limit:S.length},t=0;for(;t<b.length;){let n=b[t];if(++t,n!=null&&n.key!=null&&n.key!=``){let t=n.value;t instanceof Array||(t=[t]),x.setProperty(e,n.key,t)}}let n=0;for(;n<C.length;){let t=C[n];++n,x.setProperty(e,t.key,t.value)}_.push(e),v.push(S)},E=function(e,t,n,r){y=e,b=t,S=[r],C=n},O=0;for(;O<m.length;){let e=m[O];++O;let t=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-reco-filter-`)){let n=h.substr(e.name,25,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},n=function(e){let t=[],n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let e=o[n];if(++n,e.name.startsWith(`data-froomle-variable-`)){let n=h.substr(e.name,22,null),r=e.value;try{r=JSON.parse(e.value)}catch{r=e.value.indexOf(`;`)==-1?e.value:e.value.split(`;`)}t.push({key:n,value:r})}}return t},r=e.getAttribute(`data-froomle-reco`),i=t(e),a=n(e);if(y==``){E(r,i,a,e);continue}else if(r==y&&w(b,i)&&w(C,a)){S.push(e);continue}else{T(),E(r,i,a,e);continue}}y!=``&&T();let k;if(D.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(D.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else try{k=D.getRawRecommendations(_)}catch{let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}return k.then(function(e){let n=e.lists(),r=n.length,i=0,a=r;for(;i<a;){let r=i++,a=n[r];a.items.length,v[r].length;let o=a.items.length,s=0,c=o;for(;s<c;){let n=s++,i=a.items[n],o=v[r][n];t._fillParameters(o,i,e.request_id)}}let s=o;s._isFinished||(s._result=!0,s._error=null,s._isFinished=!0,s._resolve(!0))}),o}static getAttrByPath(e,t,n){n==null&&(n=`fgh`);try{t=new v(`\\\\[(\\\\w+)\\\\]`,`g`).map(t,function(e){return`.`+e.matched(1)}),t=g.replace(t,`[`,`.`),t=g.replace(t,`]`,``),h.cca(t,0)==46&&(t=h.substr(t,1,null));let n=t.split(`.`),r=e.get(n[0]),a=1,o=n.length;for(;a<o;){let e=a++;if(r==null)return null;r=r instanceof Array&&i.parseInt(n[e])!=null?r[i.parseInt(n[e])]:x.field(r,n[e])}return r}catch{return n}}static stringifyValue(e,t){return t==null&&(t=``),e==null?t:i.string(e)}static isQuotedToken(e){if(e==null||e.length<2)return!1;let t=e.charAt(0),n=e.charAt(e.length-1);return t==`'`&&n==`'`?!0:t==`"`?n==`"`:!1}static unescapeQuotedValue(e){let t=e;return t=g.replace(t,`\\'`,`'`),t=g.replace(t,`\\"`,`"`),t=g.replace(t,`\\\\`,`\\`),t}static unquoteToken(e){let n=g.trim(e);if(!t.isQuotedToken(n))return n;let r=h.substr(n,1,n.length-2);return t.unescapeQuotedValue(r)}static splitTopLevel(e,t){if(t==null||t.length!=1)return[e];let n=t.charAt(0),r=[],i=new M,a=0,o=null,s=!1,c=0,l=e.length;for(;c<l;){let t=c++,l=e.charAt(t);if(s){i.b+=l==null?`null`:``+l,s=!1;continue}if(o!=null){if(l==`\\`){i.b+=l==null?`null`:``+l,s=!0;continue}l==o&&(o=null),i.b+=l==null?`null`:``+l;continue}if(l==`'`||l==`"`){o=l,i.b+=l==null?`null`:``+l;continue}if(l==`(`?++a:l==`)`&&a>0&&--a,a==0&&l==n){r.push(g.trim(i.b)),i=new M;continue}i.b+=l==null?`null`:``+l}return r.push(g.trim(i.b)),r}static parseTransformPart(e){let n=g.trim(e);if(n==``)return{name:``,args:[]};let r=n.indexOf(`(`);if(r==-1||!n.endsWith(`)`))return{name:n,args:[]};let i=g.trim(h.substr(n,0,r)),a=h.substr(n,r+1,n.length-r-2),o=[];if(g.trim(a)!=``){let e=0,n=t.splitTopLevel(a,`,`);for(;e<n.length;){let r=n[e];++e,o.push(t.unquoteToken(r))}}return{name:i,args:o}}static resolveSeedValue(e,n,r){let i=g.trim(e);return i==``?r:t.isQuotedToken(i)?t.unquoteToken(i):t.stringifyValue(t.getAttrByPath(n,i,r),r)}static resolveFieldPathValue(e,n){let r=g.trim(e);return r==``?``:t.stringifyValue(t.getAttrByPath(n,r,null),``)}static applyTransform(e,n,r,i){let a=e==null?``:e;switch(n==null?``:n.toLowerCase()){case`append`:return r.length>=1?a+r[0]:a;case`default`:return(a==null||a==``)&&r.length>=1?r[0]:a;case`defaultfield`:return(a==null||a==``)&&r.length>=1?t.resolveFieldPathValue(r[0],i):a;case`lower`:return a.toLowerCase();case`prepend`:return r.length>=1?r[0]+a:a;case`replace`:return r.length>=2?g.replace(a,r[0],r[1]):a;case`trim`:return g.trim(a);case`upper`:return a.toUpperCase();case`urlencode`:return encodeURIComponent(a);default:return a}}static evaluateExpression(e,n,r){let i=g.trim(e);if(i.startsWith(`=`)&&(i=g.trim(h.substr(i,1,null))),i==``)return r;let a=t.splitTopLevel(i,`|`);if(a.length==0)return r;let o=t.resolveSeedValue(a[0],n,r),s=1,c=a.length;for(;s<c;){let e=s++,r=t.parseTransformPart(a[e]);r.name!=``&&(o=t.applyTransform(o,r.name,r.args,n))}return o}static findTemplateExpressionEnd(e,t){let n=null,r=!1,i=0,a=t;for(;a<e.length;){let t=e.charAt(a);if(r){r=!1,++a;continue}if(n!=null){t==`\\`?r=!0:t==n&&(n=null),++a;continue}if(t==`'`||t==`"`){n=t,++a;continue}if(t==`$`&&a+1<e.length&&e.charAt(a+1)==`{`){++i,a+=2;continue}if(t==`}`){if(i==0)return a;--i}++a}return-1}static resolveTemplate(e,n,r){if(e.indexOf("${")==-1)return e;let a=``,o=0;for(;o<e.length;){let s=e.indexOf("${",o);if(s==-1){a+=i.string(h.substr(e,o,null));break}a+=i.string(h.substr(e,o,s-o));let c=t.findTemplateExpressionEnd(e,s+2);if(c==-1){a+=i.string(h.substr(e,s,null));break}let l=h.substr(e,s+2,c-s-2);a+=i.string(t.evaluateExpression(l,n,r)),o=c+1}return a}static resolveParamValue(e,n,r){r==null&&(r=``);let i=t.stringifyValue(r,``),a=e==null?``:e,o=g.trim(a);return o==``?i:a.indexOf("${")==-1?o.startsWith(`=`)?t.evaluateExpression(h.substr(o,1,null),n,i):t.stringifyValue(t.getAttrByPath(n,o,i),i):t.resolveTemplate(a,n,i)}static _buildHistories(e){let t=[],n=[],r=e.querySelectorAll(`[data-froomle-id]`),i=0,a=r.length;for(;i<a;){let e=i++,t=r.item(e);t instanceof HTMLElement&&n.push(t)}let o=n,s=0;for(;s<o.length;){let e=o[s];++s,t.push(e.getAttribute(`data-froomle-id`))}D.addHistories(t)}static fillParam(e,n,r,i,a){a==null&&(a=``);try{let o=t.resolveParamValue(r,i,a);n==`inner`?(e.textContent=o,e.textContent):e.setAttribute(n,o)}catch{}}static _fillParameters(e,n,r){e.setAttribute(`data-froomle-id`,n.get(`item_id`)),e.setAttribute(`data-froomle-request-id`,r);let a=n.get(`item_type`);a!=null&&i.string(a)!=``&&e.setAttribute(`data-froomle-item-type`,i.string(a)),n.UserGroup!=null&&n.UserGroup!=``&&e.setAttribute(`data-froomle-user-group`,n.UserGroup);let o=[],s=e.querySelectorAll(`*`),c=0,l=s.length;for(;c<l;){let e=c++,t=s.item(e);t instanceof HTMLElement&&o.push(t)}let u=o,d=0;for(;d<u.length;){let e=u[d];++d;let r=0,i=[],a=0,o=e.attributes;for(;a<o.length;){let e=o[a];++a,i.push({name:e.name,value:e.value})}let s=i;for(;r<s.length;){let i=s[r];if(++r,i.name.startsWith(`data-froomle-param-`)){let r=g.replace(i.name,`data-froomle-param-`,``),a=i.value;t.fillParam(e,r,a,n)}}}}static _orderElements(e){let t=function(t,n,r){let i=[],a=[],o=0,s=t.childNodes;for(;o<s.length;){let e=s[o];++o,a.push(e)}let c=a,l=0;for(;l<c.length;){let n=c[l];++l;try{if(n.getAttribute(`data-froomle-ordervalue`)!=null){i.push(n);let r=e.createElement(`span`);r.setAttribute(`data-froomle-tmp-node`,`tmp`),t.replaceChild(r,n)}}catch{}}let u=[],d=0;for(;d<i.length;){let e=i[d];++d,u.push(e.getAttribute(`data-froomle-ordervalue`))}return{el:t,key:n,values:u,orderChildren:i,list_name:r}},n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i,s=e.getRoot(),c=[],l=s.querySelectorAll(`*`),u=0,d=l.length;for(;u<d;){let e=u++,t=l.item(e);t instanceof HTMLElement&&c.push(t)}let f=c,p=[],m=0;for(;m<f.length;){let e=f[m];++m;let n=0,r=[],i=0,a=e.attributes;for(;i<a.length;){let e=a[i];++i,r.push({name:e.name,value:e.value})}let o=r;for(;n<o.length;){let r=o[n];++n,r.name.startsWith(`data-froomle-order-`)&&p.push(t(e,r.name.substring(19),r.value))}}if(p.length<1){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}let h=[],g=0;for(;g<p.length;){let e=p[g];++g;let t={list_name:e.list_name,limit:e.values.length,list_size:e.values.length},n={};x.setProperty(n,e.key,e.values),x.setProperty(t,`order`,n),h.push(t)}if(D.getPageVisit()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}else if(D.getEnvironment()==null){let e=o;return e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1)),o}try{D.getRawRecommendations(h).then(function(e){let t=e.lists(),n=t.length,r=0,i=n;for(;r<i;){let n=r++,i=t[n],a=p[n];a.el.setAttribute(`data-froomle-request-id`,e.request_id);let o=[],s=0,c=i.items;for(;s<c.length;){let e=c[s];++s;let t=e.get(a.key);e.get(a.key);let n=a.values.length,r=0,i=n;for(;r<i;){let e=r++;if(t==a.values[e]){a.orderChildren.length;let t=a.orderChildren[e];o.push(t),a.orderChildren.splice(e,1),a.values.splice(e,1);break}}}o.length;let l=a.el,u=[],d=0,f=l.childNodes;for(;d<f.length;){let e=f[d];++d,u.push(e)}let m=u.length,h=0,g=m;for(;h<g;){let e=h++,t=a.el,n=[],r=0,i=t.childNodes;for(;r<i.length;){let e=i[r];++r,n.push(e)}let s=n[e],c=s,l;if(l=c instanceof HTMLElement?c.hasAttribute(`data-froomle-tmp-node`):!1,l&&(a.el.replaceChild(o[0],s),o.splice(0,1),o.length,o.length==0))break}}let a=o;a._isFinished||(a._result=!0,a._error=null,a._isFinished=!0,a._resolve(!0))})}catch{let e=o;e._isFinished||(e._result=!1,e._error=null,e._isFinished=!0,e._resolve(!1))}return o}static domInit(e){let n=null,r=null,i=new Promise(function(e,t){n=e,r=t}),a=i;a._resolve=n,a._reject=r,a._isFinished=!1,a._result=null,a._error=null;let o=i;return t._orderElements(e).then(function(n){t._buildHistories(e.getRoot()),t._fillRecoTargets(e.getRoot()).then(function(e){let t=o;t._isFinished||(t._result=!0,t._error=null,t._isFinished=!0,t._resolve(!0))})}),o}static fillElementRecos(e){t._fillRecoTargets(e)}static runFromHtml(e){if(e==``)return``;let n;try{let t=new DOMParser().parseFromString(e,`text/html`),r=new j;r.root=t.documentElement,n=r}catch{return e}return t.domInit(n),n.toString()}static get __name__(){return`internal.domHandler.DomDomDom`}get __class__(){return t}};e.$global;const P=e.global(`$hxClasses`).FroomleSdk=class e{static register(){e.registered||e._env_set&&e._page_visit_set&&(e.registered=!0)}static buildScriptTag(){let e=`<script src="https://cdn.jsdelivr.net/npm/@froomle/frontend-sdk@0.0.30/dist/froomle.global.js" data-froomle-env="`+D.getEnvironment()+`" `,t=D.getPageVisit();t!=null&&(e+=`data-froomle-page-visit="`+t+`" `);let n=D.getContextItem();if(n!=null){e+=`data-froomle-context-item="`+n+`" `;let t=D.getContextItemType();(t==null||t==``)&&(t=`article`),e+=`data-froomle-context-item-type="`+t+`" `}let r=D.getDeviceId();r!=null&&(e+=`data-froomle-device-id="`+r+`" `);let i=D.getUserId();i!=null&&(e+=`data-froomle-user-id="`+i+`" `);let a=D.getConsent();a>0&&(e+=`data-froomle-consent="`+a+`" `);let o=D.getRequestDomain();o!=null&&(e+=`data-froomle-request-domain="`+o+`" `);let s=D.getChannel();return s!=null&&(e+=`data-froomle-channel="`+s+`" `),e+=`><\/script>`,e}static setEnvironment(t){D.setEnvironment(t),e._env_set=!0,e.register()}static setDeviceId(e){D.setDeviceId(e)}static setUserId(e){D.setUserId(e)}static setConsent(e){D.setConsent(e)}static setPageVisit(t){D.setPageVisit(t),e._page_visit_set=!0,e.register()}static setChannel(e){D.setChannel(e)}static setRequestDomain(e){D.setRequestDomain(e)}static setRecommendationsAccessToken(e){D.setRecommendationsAccessToken(e)}static clearRecommendationsAccessToken(){D.clearRecommendationsAccessToken()}static setRecommendationsAccessTokenProvider(e){D.setRecommendationsAccessTokenProvider(e)}static clearRecommendationsAccessTokenProvider(){D.clearRecommendationsAccessTokenProvider()}static setSafeRequest(e){D.setSafeRequest(e)}static setContextItem(e){D.setContextItem(e)}static setContextItemType(e){D.setContextItemType(e)}static setCustomVariable(e,t){D.setOthers(e,t)}static getUserId(){return D.getUserId()}static getDeviceId(){return D.getDeviceId()}static getEnvironment(){return D.getEnvironment()}static getSafeRequest(){return D.getSafeRequest()}static getPageVisit(){return D.getPageVisit()}static getConsent(){return D.getConsent()}static getRecommendations(e){return D.getRawRecommendations(e)}static getChannel(){return D.getChannel()}static getVersion(){return`0.0.30`}static runFromHtml(e){return N.runFromHtml(e)}static get __name__(){return`FroomleSdk`}get __class__(){return e}};P._env_set=!1,P._page_visit_set=!1,P.registered=!1;function te(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}function ne(){return`frontend-sdk/${P.getVersion()}`}function re(){return{"Content-Type":`application/json`,Accept:`application/json`,"X-Froomle-Client":ne()}}function ie(e){return JSON.stringify({events:e})}async function F(e,t={}){let n=ie(e),r=te(),{keepalive:i=!1,allowBeaconFallback:a=!1}=t;try{return await fetch(r,{method:`POST`,headers:re(),body:n,...i?{keepalive:!0}:{}}),`fetch`}catch(e){if(a&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=new Blob([n],{type:`application/json`});if(navigator.sendBeacon(r,e))return`beacon`}throw e}}function ae(){if(D.getConsent()<2)return;let e=D.getUserId();if(e)return e}function oe(){let e=D.getContextItem();if(e)return e}function se(){let e=D.getContextItemType();if(e)return e}function I(){return D.getConsent()>=1}function ce(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}function le(){let e=D.getChannel();if(e)return e}function ue(e){var t;let n=e==null?void 0:e.getAttribute(`data-froomle-user-group`);if(n)return n;if(!(typeof document>`u`))return((t=document.querySelector(`[data-froomle-user-group]`))==null?void 0:t.getAttribute(`data-froomle-user-group`))||void 0}function de(e){let t={event_type:e,page_type:D.getPageVisit(),channel:le()||`www-desktop`,device_id:ce()},n=ue();n&&(t.user_group=n);let r=ae();return r&&(t.user_id=r),t}function fe(e,t){if(!t)return e;for(let n in t)e[n]=t[n];return e}function L(e){I()&&F([e]).catch(()=>{})}function R(e,t,n,r){let i=t||oe();if(!i)return null;let a=de(e);return a.action_item=i,a.action_item_type=n||se()||`article`,fe(a,r)}function pe(e,t,n=`impression`,r){let i=R(n,e,t,r);i&&L(i)}function me(e,t,n,r){let i=R(`item_interaction`,n?e:void 0,n&&typeof t==`string`?t:void 0,{interaction_type:n||e,...n?r:t});i&&L(i)}function he(e,t){let n=de(`user_interaction`);n.interaction_type=e,L(fe(n,t))}function ge(e,t,n,r){let i=R(`add_to_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&L(i)}function _e(e,t,n,r){let i=R(`remove_from_cart`,typeof e==`string`?e:void 0,typeof e==`string`&&typeof t==`string`?t:void 0,{amount:typeof e==`number`?e:n,...typeof e==`number`?t:r});i&&L(i)}function ve(e,t,n,r,i){let a=typeof e==`string`,o=R(`purchase`,a?e:void 0,a&&typeof t==`string`?t:void 0,{amount:a?n:e,purchased_price:a?r:t,...a?i:n});o&&L(o)}function ye(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-id`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item`));if(t)return t}function be(e){let t=(e==null?void 0:e.getAttribute(`data-froomle-item-type`))||(e==null?void 0:e.getAttribute(`data-froomle-action-item-type`));if(t)return t}var z=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateEvents(){let t=[];for(let n of e.impressionQueue){let e=ye(n);if(!e)continue;let r=be(n)||`article`,i=le()||`www-desktop`,a={event_type:`impression`,page_type:D.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ce()},o=ue(n);o&&(a.user_group=o),D.getConsent()>=2&&D.getUserId()&&(a.user_id=D.getUserId());let s=n.getAttribute(`data-froomle-reco`),c=n.getAttribute(`data-froomle-request-id`);s&&c&&(a.list_name=s,a.request_id=c),t.push(a)}return e.impressionQueue=[],t}static sendImpressions(){if(console.log(e.impressionQueue),e.impressionQueue.length===0||!I())return;let t=e.generateEvents();t.length!==0&&F(t).catch(()=>{})}static getViewPortRect(){let e=window.innerWidth||document.documentElement.clientWidth,t=window.innerHeight||document.documentElement.clientHeight;return{left:0,top:0,x:0,y:0,toJSON(){},right:e,bottom:t,width:e,height:t}}static intersectsWithViewPortRect(t){let n=t.getBoundingClientRect(),r=e.getViewPortRect();return n.right>r.left&&n.left<r.right&&n.bottom>r.top&&n.top<r.bottom}static addIntersectionImpressionListener(t){e.observer.observe(t)}static processDocument(){if(I()){console.log(`🚀 Processing document for impressions`);for(let t of document.querySelectorAll(`[data-froomle-id]`))e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}static processElement(t){if(!I()||!(t instanceof Element))return;let n=[];t.matches(`[data-froomle-id]`)&&n.push(t);for(let e of t.querySelectorAll(`[data-froomle-id]`))n.push(e);if(n.length!==0){for(let t of n)e.intersectsWithViewPortRect(t)?e.queueIfNotPresent(t):e.addIntersectionImpressionListener(t);e.sendImpressions()}}};z.impressionQueue=[],z.observer=null,typeof document<`u`&&(z.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(z.impressionQueue.push(e.target),z.observer.unobserve(e.target))}),z.impressionQueue.length>0&&z.sendImpressions()}));var xe=class e{static canTrackEvents(){return D.getConsent()>=1}static readDeviceId(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}static readChannel(){let e=D.getChannel();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readChannel()||`www-desktop`,n={event_type:`page_visit`,page_type:D.getPageVisit(),channel:t,device_id:e.readDeviceId()},r=e.readUserGroup();return r&&(n.user_group=r),D.getConsent()>=2&&D.getUserId()&&(n.user_id=D.getUserId()),n}static sendPageVisit(){D.getPageVisit()&&(D.getContextItem()||e.canTrackEvents()&&F([e.generateEvent()]).catch(()=>{}))}},Se=class e{static canTrackEvents(){return D.getConsent()>=1}static readDeviceId(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}static readChannel(){let e=D.getChannel();if(e)return e}static readActionItemType(){let e=D.getContextItemType();if(e)return e}static readUserGroup(){var e;if(!(typeof document>`u`))return((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||void 0}static generateEvent(){let t=e.readActionItemType()||`article`,n=e.readChannel()||`www-desktop`,r={event_type:`detail_pageview`,page_type:D.getPageVisit(),action_item:D.getContextItem(),action_item_type:t,channel:n,device_id:e.readDeviceId()},i=e.readUserGroup();return i&&(r.user_group=i),D.getConsent()>=2&&D.getUserId()&&(r.user_id=D.getUserId()),r}static sendPageView(){D.getContextItem()&&D.getPageVisit()&&e.canTrackEvents()&&F([e.generateEvent()]).catch(()=>{})}},B=class e{static readAttributeFromChain(e,t){let n=e;for(;n;){for(let e of t){let t=n.getAttribute(e);if(t)return t}n=n.parentElement}}static canTrackEvents(){return D.getConsent()>=1}static readDeviceId(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}static readChannel(){let e=D.getChannel();if(e)return e}static readActionItem(t){return e.readAttributeFromChain(t,[`data-froomle-id`,`data-froomle-action-item`])}static readActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-item-type`,`data-froomle-action-item-type`])}static readExplicitActionItemType(t){return e.readAttributeFromChain(t,[`data-froomle-action-item-type`])}static readUserGroup(t){var n;let r=e.readAttributeFromChain(t,[`data-froomle-user-group`]);if(r)return r;if(!(typeof document>`u`))return((n=document.querySelector(`[data-froomle-user-group]`))==null?void 0:n.getAttribute(`data-froomle-user-group`))||void 0}static registerClickables(){e.listenerRegistered||(e.listenerRegistered=!0,document.addEventListener(`click`,t=>{if(!e.canTrackEvents())return;let n=t instanceof MouseEvent?t:null,r=t.target,i=r instanceof Element?r:r instanceof Node?r.parentElement:null;if(!i)return;let a=i.closest(`a`);if(!a)return;let o=a.closest(`[data-froomle-id]`);if(!o)return;let s=a.closest(`[data-froomle-reco]`),c=(s?e.readActionItem(s):void 0)||e.readActionItem(o);if(!c)return;let l=e.readExplicitActionItemType(a)||(s?e.readActionItemType(s):void 0)||e.readActionItemType(o)||`article`,u=e.readChannel()||`www-desktop`,d=a instanceof HTMLAnchorElement?a.href:null,f=a.getAttribute(`href`),p=typeof f==`string`&&f.trim().startsWith(`#`),m=!!d&&!p&&t.cancelable&&!t.defaultPrevented&&!a.hasAttribute(`download`)&&(!a.target||a.target===`_self`)&&!!n&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey,h=p&&t.cancelable&&!t.defaultPrevented;(m||h)&&t.preventDefault();let g={event_type:`click_on_recommendation`,page_type:D.getPageVisit(),action_item:c,action_item_type:l,channel:u,device_id:e.readDeviceId()},_=(s?e.readUserGroup(s):void 0)||e.readUserGroup(o);_&&(g.user_group=_);let v=(s?e.readAttributeFromChain(s,[`data-froomle-reco`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-reco`]),y=(s?e.readAttributeFromChain(s,[`data-froomle-request-id`]):void 0)||e.readAttributeFromChain(o,[`data-froomle-request-id`]);if(v&&y&&(g.list_name=v,g.request_id=y),D.getConsent()>=2&&D.getUserId()&&(g.user_id=D.getUserId()),m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);F([g],{keepalive:!0,allowBeaconFallback:!0}).catch(()=>{}).finally(()=>{window.clearTimeout(n),t()});return}F([g],{allowBeaconFallback:!0}).catch(()=>{})},!0))}};B.listenerRegistered=!1;const Ce=j,V=P.setEnvironment,H=P.setPageVisit,U=P.setRequestDomain,W=P.setSafeRequest,G=typeof P.setChannel==`function`?P.setChannel:D.setChannel,we=P.setRecommendationsAccessToken,Te=P.clearRecommendationsAccessToken,Ee=P.setRecommendationsAccessTokenProvider,De=P.clearRecommendationsAccessTokenProvider,K=P.setContextItem,q=P.setContextItemType,Oe=D.addHistories;function ke(e,t){P.setCustomVariable(e,t)}function Ae(e){we(e==null?null:e)}function je(){Te()}function Me(e){Ee(e)}function Ne(){De()}function J(e){P.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function Y(e){P.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function X(e){P.setConsent(e),document.cookie=`froomle_consent=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`,document.cookie=`froomle_device_id=${P.getDeviceId()}; max-age=${3600*24*365*20}; path=/; samesite=lax`}typeof window<`u`&&(window.setFroomleConsent=X);function Z(e){let t=document.cookie.split(`; `);for(let n of t){let[t,r]=n.split(`=`);if(t===e)return decodeURIComponent(r)}return null}function Pe(e){return P.getRecommendations(e)}const Q=globalThis,Fe=`FroomleFrontendSdkState`,Ie=`FroomleFrontendSdkReady`;function Le(){let e=()=>{},t=()=>{},n=new Promise((n,r)=>{e=n,t=r}),r={initStarted:!1,initialized:!1,beforeInitEventDispatched:!1,initEventDispatched:!1,readyPromise:n,resolveReady:e,rejectReady:t};return Q[Fe]=r,Q[Ie]=n,r}function $(){if(!Q[Fe])return Le();let e=Q[Fe];return Q[Ie]||(Q[Ie]=e.readyPromise),e}function Re(){return Q.FroomleFrontendSdk?Q.FroomleFrontendSdk:{RecommendationItem:E,RecommendationList:T,Recommendations:w,setPageVisit:H,setEnvironment:V,setConsent:X,setUserId:J,setDeviceId:Y,setRequestDomain:U,setSafeRequest:W,setChannel:G,setRecommendationsBearer:Ae,clearRecommendationsBearer:je,setRecommendationsBearerProvider:Me,clearRecommendationsBearerProvider:Ne,setContextItem:K,setContextItemType:q,setCustomVariable:ke,getRecommendations:Pe,sendEvent:pe,sendItemInteraction:me,sendUserInteraction:he,sendAddToCart:ge,sendRemoveFromCart:_e,sendPurchase:ve,addHistories:Oe,init:Ke}}function ze(e){return{sdk:Re(),mode:e,version:typeof P.getVersion==`function`?P.getVersion():void 0}}function Be(e,t){if(typeof window>`u`)return;if(typeof window.CustomEvent==`function`){window.dispatchEvent(new window.CustomEvent(e,{detail:t}));return}let n=document.createEvent(`CustomEvent`);n.initCustomEvent(e,!1,!1,t),window.dispatchEvent(n)}function Ve(e){let t=$();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,Be(`froomle:before-init`,ze(e)))}function He(e){let t=$();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,Be(`froomle:init`,ze(e)))}function Ue(e){let t=$();t.initialized||(t.initialized=!0,t.resolveReady(Re())),He(e)}function We(e){$().rejectReady(e)}function Ge(e=`auto`){if(typeof document>`u`)return Promise.resolve(Re());let t=$();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{Ve(e),console.log(`froomle loads dom`),N.domInit(Ce.fromDocument(document)).then(()=>{B.registerClickables(),z.processDocument(),xe.sendPageVisit(),Se.sendPageView(),Ue(e)}).catch(e=>{We(e)});function t(e){return e.matches(`[data-froomle-reco]`)||e.querySelector(`[data-froomle-reco]`)!==null}new MutationObserver(e=>{for(let n of e)if(n.type===`childList`&&n.addedNodes.forEach(e=>{e instanceof Element&&(t(e)&&N.fillElementRecos(e),z.processElement(e))}),n.type===`attributes`&&n.target instanceof Element)if(n.attributeName===`data-froomle-reco`){let e=n.target.getAttribute(`data-froomle-request-id`);(!e||e===``)&&N.fillElementRecos(n.target)}else if(n.attributeName===`data-froomle-request-id`){let e=n.target.getAttribute(`data-froomle-request-id`),t=n.target.getAttribute(`data-froomle-id`);n.target.getAttribute(`data-froomle-reco`)&&(!e||e===``)&&(!t||t===``)&&N.fillElementRecos(n.target)}else n.attributeName===`data-froomle-id`&&z.processElement(n.target)}).observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-froomle-reco`,`data-froomle-request-id`,`data-froomle-id`]})},r=()=>{globalThis.setTimeout(n,0)};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,r,{once:!0}):r(),t.readyPromise}function Ke(){return Ge(`manual`)}if(!globalThis.froomleInitialized&&(globalThis.froomleInitialized=!0,typeof document<`u`)){$();let e=document.currentScript;if(e){let t=e.getAttribute(`data-froomle-device-id`),n=e.getAttribute(`data-froomle-user-id`),r=e.getAttribute(`data-froomle-env`),i=e.getAttribute(`data-froomle-page-visit`),a=e.getAttribute(`data-froomle-request-domain`),o=e.getAttribute(`data-froomle-context-item`),s=e.getAttribute(`data-froomle-context-item-type`),c=e.getAttribute(`data-froomle-safe-request`),l=e.getAttribute(`data-froomle-channel`);if(V(r),i&&H(i),o&&(K(o),q(s||`article`)),t)Y(t);else{let e=Z(`froomle_device_id`);e&&Y(e)}if(n)J(n);else{let e=Z(`froomle_user_id`);e&&J(e)}a&&U(a),c&&W(c!==`false`),l&&G(l)}let t=Z(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||X(e)}Ge(`auto`)}function qe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const Je=[];function Ye(){var e;return typeof document>`u`?``:((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||``}function Xe(e,t){var n;let r=e,i=((n=r==null?void 0:r.UserGroup)==null?typeof(r==null?void 0:r.get)==`function`?r.get(`user_group`):void 0:n)||t;if(i&&(r.UserGroup=i,typeof(r==null?void 0:r.getData)==`function`)){let e=r.getData();e&&(!e.user_group||e.user_group===``)&&(e.user_group=i)}}async function Ze(){let e=Je.splice(0,Je.length);if(e.length!==0)try{let t=e.map(e=>e.req),n=D.requestsToLists(t),r=await D.getRawRecommendations(n),i=r.user_group||``;typeof document<`u`&&i&&document.documentElement.setAttribute(`data-froomle-user-group`,i);let a=r.lists().reduce((e,t)=>[...e,...t.items],[]);a.forEach(e=>Xe(e,i)),e.forEach((e,t)=>{a[t]?e.deferred.resolve(a[t]):e.deferred.reject(Error(`No recommendation available`))})}catch(t){throw e.forEach(e=>{e.deferred.reject(t)}),t}}function Qe(e){let t,n,r={promise:new Promise((e,r)=>{t=e,n=r}),resolve:t,reject:n};return Je.push({deferred:r,req:e}),r}function $e(e){let t=Qe(e).promise;qe();let n=function(e,n){return t.then(t=>(r.completeTarget=t,e?e(t):t),e=>n?n(e):Promise.reject(e))},r=new Proxy(new A({item_id:``,request_id:``,user_group:``}),{get(t,r,i){if(r===`then`)return n;if(r===`__froomleList`)return e.list;if(r===`get`){let e=Reflect.get(t,r,i);return function(...t){return e.apply(this,t)}}if(typeof r!=`string`)return Reflect.get(t,r,i);let a=Reflect.get(t,r,i);if(a!=null&&a!==``)return a;let o=t.get(r);return o!=null&&o!==``?o:``},set(e,t,n,r){if(t===`completeTarget`){if(Object.assign(e,n),!e.UserGroup){let t=Ye();if(t){e.UserGroup=t;let n=e.getData();n&&!n.user_group&&(n.user_group=t)}}return!0}return Reflect.set(e,t,n,r)},has(e,t){return e.get(t)!==void 0}});return r}Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return W}});
|