@froomle/frontend-sdk 0.0.22 → 0.0.24

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.
@@ -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 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=new C(e._requestUri());u.setHeader(`Content-Type`,`application/json`);let d=e.buildRequestBody(t),f=JSON.stringify(d);u.setPostData(f);let p=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))};u.onError=function(e){p(`HTTP Request Error: `+e)},u.onStatus=function(e){(e<200||e>=300)&&p(`HTTP Status Error: `+e)};try{u.request(!0)}catch(e){let t=i.caught(e).unwrap();return p(`Failed to execute recommendation request: `+a.string(t)),c}let m=function(e){if(!l)try{let t=JSON.parse(e),n=k.fromRequestData(t);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();p(`Failed to parse recommendation response: `+a.string(t))}},h=u.get_responseData();return h==null?l||(u.onData=m):m(h),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 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=[];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;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;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 applyTransform(e,t,n){let r=e==null?``:e;switch(t==null?``:t.toLowerCase()){case`append`:return n.length>=1?r+n[0]:r;case`default`:return(r==null||r==``)&&n.length>=1?n[0]:r;case`lower`:return r.toLowerCase();case`prepend`:return n.length>=1?n[0]+r:r;case`replace`:return n.length>=2?_.replace(r,n[0],n[1]):r;case`trim`:return _.trim(r);case`upper`:return r.toUpperCase();case`urlencode`:return encodeURIComponent(r);default:return r}}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++,n=e.parseTransformPart(a[t]);n.name!=``&&(o=e.applyTransform(o,n.name,n.args))}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.11/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 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.11`}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 I(){return O.getConsent()>=1}function ne(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}function re(){let e=O.getChannel();if(e)return e}function ie(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 ae(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}function oe(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 se(e,t,n=`impression`,r){if(!I())return;let i=re()||`www-desktop`,a={event_type:n,page_type:O.getPageVisit(),action_item:e,action_item_type:t,channel:i,device_id:ne()},o=oe();if(o&&(a.user_group=o),r)for(let e in r)a[e]=r[e];try{fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({events:[a]})})}catch{}}var L=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateBody(){let t=[];for(let n of e.impressionQueue){let e=ie(n);if(!e)continue;let r=ae(n)||`article`,i=re()||`www-desktop`,a={event_type:`impression`,page_type:O.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ne()},o=oe(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=[],JSON.stringify({events:t})}static sendImpressions(){console.log(e.impressionQueue),e.impressionQueue.length!==0&&I()&&fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}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()}}};L.impressionQueue=[],L.observer=null,typeof document<`u`&&(L.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(L.impressionQueue.push(e.target),L.observer.unobserve(e.target))}),L.impressionQueue.length>0&&L.sendImpressions()}));var 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 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 uri(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[n]})}static sendPageVisit(){O.getPageVisit()&&(O.getContextItem()||e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()}))}},le=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 uri(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[r]})}static sendPageView(){O.getContextItem()&&O.getPageVisit()&&e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}},ue=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 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=(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`]);v&&y&&(g.list_name=v,g.request_id=y),O.getConsent()>=2&&O.getUserId()&&(g.user_id=O.getUserId());let b=(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`,x=JSON.stringify({events:[g]}),S=new Blob([x],{type:`application/json`}),C=e=>fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:x,...e?{keepalive:!0}:{}});if(m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);C(!0).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)}).finally(()=>{window.clearTimeout(n),t()});return}C(!1).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)})},!0))}};ue.listenerRegistered=!1;let de=M,R=F.setEnvironment,z=F.setPageVisit,B=F.setRequestDomain,V=F.setSafeRequest,H=typeof F.setChannel==`function`?F.setChannel:O.setChannel,U=F.setContextItem,W=F.setContextItemType,fe=O.addHistories;function pe(e,t){F.setCustomVariable(e,t)}function G(e){F.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function K(e){F.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(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=q);function J(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 me(e){return F.getRecommendations(e)}let Y=globalThis,X=`FroomleFrontendSdkState`,Z=`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 Y[X]=r,Y[Z]=n,r}function Q(){if(!Y[X])return he();let e=Y[X];return Y[Z]||(Y[Z]=e.readyPromise),e}function $(){return Y.FroomleFrontendSdk?Y.FroomleFrontendSdk:{RecommendationItem:D,RecommendationList:E,Recommendations:T,setPageVisit:z,setEnvironment:R,setConsent:q,setUserId:G,setDeviceId:K,setRequestDomain:B,setSafeRequest:V,setChannel:H,setContextItem:U,setContextItemType:W,setCustomVariable:pe,getRecommendations:me,sendEvent:se,addHistories:fe,init:Ce}}function ge(e){return{sdk:$(),mode:e,version:typeof F.getVersion==`function`?F.getVersion():void 0}}function _e(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,_e(`froomle:before-init`,ge(e)))}function ye(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,_e(`froomle:init`,ge(e)))}function be(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady($())),ye(e)}function xe(e){Q().rejectReady(e)}function Se(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`),P.domInit(de.fromDocument(document)).then(()=>{ue.registerClickables(),L.processDocument(),ce.sendPageVisit(),le.sendPageView(),be(e)}).catch(e=>{xe(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),L.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`&&L.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 Ce(){return Se(`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(R(r),i&&z(i),o&&(U(o),W(s||`article`)),t)K(t);else{let e=J(`froomle_device_id`);e&&K(e)}if(n)G(n);else{let e=J(`froomle_user_id`);e&&G(e)}a&&B(a),c&&V(c!==`false`),l&&H(l)}let t=J(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||q(e)}Se(`auto`)}return e.FroomleDomTree=de,e.RecoBackendV2=O,e.RecommendationItem=D,e.RecommendationList=E,e.Recommendations=T,e._RecommendationItemInternal=j,e.addHistories=fe,e.getRecommendations=me,e.init=Ce,e.sendEvent=se,e.setChannel=H,e.setConsent=q,e.setContextItem=U,e.setContextItemType=W,e.setCustomVariable=pe,e.setDeviceId=K,e.setEnvironment=R,e.setPageVisit=z,e.setRequestDomain=B,e.setSafeRequest=V,e.setUserId=G,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 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 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=new C(e._requestUri());u.setHeader(`Content-Type`,`application/json`);let d=e.buildRequestBody(t),f=JSON.stringify(d);u.setPostData(f);let p=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))};u.onError=function(e){p(`HTTP Request Error: `+e)},u.onStatus=function(e){(e<200||e>=300)&&p(`HTTP Status Error: `+e)};try{u.request(!0)}catch(e){let t=i.caught(e).unwrap();return p(`Failed to execute recommendation request: `+a.string(t)),c}let m=function(e){if(!l)try{let t=JSON.parse(e),n=k.fromRequestData(t);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();p(`Failed to parse recommendation response: `+a.string(t))}},h=u.get_responseData();return h==null?l||(u.onData=m):m(h),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 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=[];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 applyTransform(e,t,n){let r=e==null?``:e;switch(t==null?``:t.toLowerCase()){case`append`:return n.length>=1?r+n[0]:r;case`default`:return(r==null||r==``)&&n.length>=1?n[0]:r;case`lower`:return r.toLowerCase();case`prepend`:return n.length>=1?n[0]+r:r;case`replace`:return n.length>=2?_.replace(r,n[0],n[1]):r;case`trim`:return _.trim(r);case`upper`:return r.toUpperCase();case`urlencode`:return encodeURIComponent(r);default:return r}}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++,n=e.parseTransformPart(a[t]);n.name!=``&&(o=e.applyTransform(o,n.name,n.args))}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.11/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 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.11`}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 I(){return O.getConsent()>=1}function ne(){return O.getConsent()<2?`no-consent`:O.getDeviceId()}function re(){let e=O.getChannel();if(e)return e}function ie(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 ae(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}function oe(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 se(e,t,n=`impression`,r){if(!I())return;let i=re()||`www-desktop`,a={event_type:n,page_type:O.getPageVisit(),action_item:e,action_item_type:t,channel:i,device_id:ne()},o=oe();if(o&&(a.user_group=o),r)for(let e in r)a[e]=r[e];try{fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({events:[a]})})}catch{}}var L=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateBody(){let t=[];for(let n of e.impressionQueue){let e=ie(n);if(!e)continue;let r=ae(n)||`article`,i=re()||`www-desktop`,a={event_type:`impression`,page_type:O.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ne()},o=oe(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=[],JSON.stringify({events:t})}static sendImpressions(){console.log(e.impressionQueue),e.impressionQueue.length!==0&&I()&&fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}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()}}};L.impressionQueue=[],L.observer=null,typeof document<`u`&&(L.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(L.impressionQueue.push(e.target),L.observer.unobserve(e.target))}),L.impressionQueue.length>0&&L.sendImpressions()}));var 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 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 uri(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[n]})}static sendPageVisit(){O.getPageVisit()&&(O.getContextItem()||e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()}))}},le=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 uri(){return(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[r]})}static sendPageView(){O.getContextItem()&&O.getPageVisit()&&e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}},ue=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 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=(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`]);v&&y&&(g.list_name=v,g.request_id=y),O.getConsent()>=2&&O.getUserId()&&(g.user_id=O.getUserId());let b=(O.getSafeRequest()?`https://`:`http://`)+O.getRequestDomain()+`/api/`+O.getEnvironment()+`/events`,x=JSON.stringify({events:[g]}),S=new Blob([x],{type:`application/json`}),C=e=>fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:x,...e?{keepalive:!0}:{}});if(m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);C(!0).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)}).finally(()=>{window.clearTimeout(n),t()});return}C(!1).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)})},!0))}};ue.listenerRegistered=!1;let de=M,R=F.setEnvironment,z=F.setPageVisit,B=F.setRequestDomain,V=F.setSafeRequest,H=typeof F.setChannel==`function`?F.setChannel:O.setChannel,U=F.setContextItem,W=F.setContextItemType,fe=O.addHistories;function pe(e,t){F.setCustomVariable(e,t)}function G(e){F.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function K(e){F.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(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=q);function J(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 me(e){return F.getRecommendations(e)}let Y=globalThis,X=`FroomleFrontendSdkState`,Z=`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 Y[X]=r,Y[Z]=n,r}function Q(){if(!Y[X])return he();let e=Y[X];return Y[Z]||(Y[Z]=e.readyPromise),e}function $(){return Y.FroomleFrontendSdk?Y.FroomleFrontendSdk:{RecommendationItem:D,RecommendationList:E,Recommendations:T,setPageVisit:z,setEnvironment:R,setConsent:q,setUserId:G,setDeviceId:K,setRequestDomain:B,setSafeRequest:V,setChannel:H,setContextItem:U,setContextItemType:W,setCustomVariable:pe,getRecommendations:me,sendEvent:se,addHistories:fe,init:Ce}}function ge(e){return{sdk:$(),mode:e,version:typeof F.getVersion==`function`?F.getVersion():void 0}}function _e(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,_e(`froomle:before-init`,ge(e)))}function ye(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,_e(`froomle:init`,ge(e)))}function be(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady($())),ye(e)}function xe(e){Q().rejectReady(e)}function Se(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`),P.domInit(de.fromDocument(document)).then(()=>{ue.registerClickables(),L.processDocument(),ce.sendPageVisit(),le.sendPageView(),be(e)}).catch(e=>{xe(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),L.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`&&L.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 Ce(){return Se(`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(R(r),i&&z(i),o&&(U(o),W(s||`article`)),t)K(t);else{let e=J(`froomle_device_id`);e&&K(e)}if(n)G(n);else{let e=J(`froomle_user_id`);e&&G(e)}a&&B(a),c&&V(c!==`false`),l&&H(l)}let t=J(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||q(e)}Se(`auto`)}return e.FroomleDomTree=de,e.RecoBackendV2=O,e.RecommendationItem=D,e.RecommendationList=E,e.Recommendations=T,e._RecommendationItemInternal=j,e.addHistories=fe,e.getRecommendations=me,e.init=Ce,e.sendEvent=se,e.setChannel=H,e.setConsent=q,e.setContextItem=U,e.setContextItemType=W,e.setCustomVariable=pe,e.setDeviceId=K,e.setEnvironment=R,e.setPageVisit=z,e.setRequestDomain=B,e.setSafeRequest=V,e.setUserId=G,e})({});
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./src-DFZcimm2.cjs`);exports.RecommendationItem=e.C,exports.RecommendationList=e.w,exports.Recommendations=e.T,exports.addHistories=e.r,exports.fulfillRecommendations=e.t,exports.getRecommendations=e.i,exports.init=e.a,exports.proxyReco=e.n,exports.sendEvent=e.x,exports.setChannel=e.o,exports.setConsent=e.s,exports.setContextItem=e.c,exports.setContextItemType=e.l,exports.setCustomVariable=e.u,exports.setDeviceId=e.d,exports.setEnvironment=e.f,exports.setPageVisit=e.p,exports.setRequestDomain=e.m,exports.setSafeRequest=e.h,exports.setUserId=e.g;
1
+ const e=require(`./src-aTULHdWC.cjs`);exports.RecommendationItem=e.C,exports.RecommendationList=e.w,exports.Recommendations=e.T,exports.addHistories=e.r,exports.fulfillRecommendations=e.t,exports.getRecommendations=e.i,exports.init=e.a,exports.proxyReco=e.n,exports.sendEvent=e.x,exports.setChannel=e.o,exports.setConsent=e.s,exports.setContextItem=e.c,exports.setContextItemType=e.l,exports.setCustomVariable=e.u,exports.setDeviceId=e.d,exports.setEnvironment=e.f,exports.setPageVisit=e.p,exports.setRequestDomain=e.m,exports.setSafeRequest=e.h,exports.setUserId=e.g;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as RecommendationList, S as RecommendationItem, a as setConsent, c as setCustomVariable, d as setPageVisit, f as setRequestDomain, i as setChannel, l as setDeviceId, m as setUserId, n as getRecommendations, o as setContextItem, p as setSafeRequest, r as init, s as setContextItemType, t as addHistories, u as setEnvironment, w as Recommendations, y as sendEvent } from "./js-Dstnm_pz.js";
1
+ import { C as RecommendationList, S as RecommendationItem, a as setConsent, c as setCustomVariable, d as setPageVisit, f as setRequestDomain, i as setChannel, l as setDeviceId, m as setUserId, n as getRecommendations, o as setContextItem, p as setSafeRequest, r as init, s as setContextItemType, t as addHistories, u as setEnvironment, w as Recommendations, y as sendEvent } from "./js-BWOYniiw.js";
2
2
 
3
3
  //#region src/js/generated/internal/data/FroomleTuple.d.ts
4
4
  type FroomleTuple = {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{C as e,S as t,a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,w as g,y as _}from"./js-Dstnm_pz.js";import{n as v,t as y}from"./src-C-NQZ8wz.js";export{t as RecommendationItem,e as RecommendationList,g as Recommendations,m as addHistories,y as fulfillRecommendations,l as getRecommendations,f as init,v as proxyReco,_ as sendEvent,o as setChannel,n as setConsent,u as setContextItem,p as setContextItemType,r as setCustomVariable,s as setDeviceId,h as setEnvironment,i as setPageVisit,a as setRequestDomain,d as setSafeRequest,c as setUserId};
1
+ import{C as e,S as t,a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,w as g,y as _}from"./js-BWOYniiw.js";import{n as v,t as y}from"./src-CIFvHxry.js";export{t as RecommendationItem,e as RecommendationList,g as Recommendations,m as addHistories,y as fulfillRecommendations,l as getRecommendations,f as init,v as proxyReco,_ as sendEvent,o as setChannel,n as setConsent,u as setContextItem,p as setContextItemType,r as setCustomVariable,s as setDeviceId,h as setEnvironment,i as setPageVisit,a as setRequestDomain,d as setSafeRequest,c as setUserId};
@@ -2,4 +2,4 @@ var e=class e{static global(t){return e.globals[t]?e.globals[t]:e.globals[t]={}}
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+` : `+t.__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(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 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=new S(t._requestUri());u.setHeader(`Content-Type`,`application/json`);let d=t.buildRequestBody(e),f=JSON.stringify(d);u.setPostData(f);let p=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))};u.onError=function(e){p(`HTTP Request Error: `+e)},u.onStatus=function(e){(e<200||e>=300)&&p(`HTTP Status Error: `+e)};try{u.request(!0)}catch(e){let t=r.caught(e).unwrap();return p(`Failed to execute recommendation request: `+i.string(t)),c}let m=function(e){if(!l)try{let t=JSON.parse(e),n=O.fromRequestData(t);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();p(`Failed to parse recommendation response: `+i.string(t))}},h=u.get_responseData();return h==null?l||(u.onData=m):m(h),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 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=[];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;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;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 applyTransform(e,t,n){let r=e==null?``:e;switch(t==null?``:t.toLowerCase()){case`append`:return n.length>=1?r+n[0]:r;case`default`:return(r==null||r==``)&&n.length>=1?n[0]:r;case`lower`:return r.toLowerCase();case`prepend`:return n.length>=1?n[0]+r:r;case`replace`:return n.length>=2?g.replace(r,n[0],n[1]):r;case`trim`:return g.trim(r);case`upper`:return r.toUpperCase();case`urlencode`:return encodeURIComponent(r);default:return r}}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++,n=t.parseTransformPart(a[e]);n.name!=``&&(o=t.applyTransform(o,n.name,n.args))}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.11/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 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.11`}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 F(){return D.getConsent()>=1}function ne(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}function re(){let e=D.getChannel();if(e)return e}function ie(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 ae(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}function oe(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 se(e,t,n=`impression`,r){if(!F())return;let i=re()||`www-desktop`,a={event_type:n,page_type:D.getPageVisit(),action_item:e,action_item_type:t,channel:i,device_id:ne()},o=oe();if(o&&(a.user_group=o),r)for(let e in r)a[e]=r[e];try{fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({events:[a]})})}catch{}}var I=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateBody(){let t=[];for(let n of e.impressionQueue){let e=ie(n);if(!e)continue;let r=ae(n)||`article`,i=re()||`www-desktop`,a={event_type:`impression`,page_type:D.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ne()},o=oe(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=[],JSON.stringify({events:t})}static sendImpressions(){console.log(e.impressionQueue),e.impressionQueue.length!==0&&F()&&fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}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(F()){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(!F()||!(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()}}};I.impressionQueue=[],I.observer=null,typeof document<`u`&&(I.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(I.impressionQueue.push(e.target),I.observer.unobserve(e.target))}),I.impressionQueue.length>0&&I.sendImpressions()}));var ce=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[n]})}static sendPageVisit(){D.getPageVisit()&&(D.getContextItem()||e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()}))}},le=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[r]})}static sendPageView(){D.getContextItem()&&D.getPageVisit()&&e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}},L=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 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=(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`]);v&&y&&(g.list_name=v,g.request_id=y),D.getConsent()>=2&&D.getUserId()&&(g.user_id=D.getUserId());let b=(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`,x=JSON.stringify({events:[g]}),S=new Blob([x],{type:`application/json`}),C=e=>fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:x,...e?{keepalive:!0}:{}});if(m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);C(!0).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)}).finally(()=>{window.clearTimeout(n),t()});return}C(!1).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)})},!0))}};L.listenerRegistered=!1;const ue=j,R=P.setEnvironment,z=P.setPageVisit,B=P.setRequestDomain,V=P.setSafeRequest,H=typeof P.setChannel==`function`?P.setChannel:D.setChannel,U=P.setContextItem,W=P.setContextItemType,de=D.addHistories;function fe(e,t){P.setCustomVariable(e,t)}function G(e){P.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function K(e){P.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(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=q);function J(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 Y=globalThis,X=`FroomleFrontendSdkState`,Z=`FroomleFrontendSdkReady`;function me(){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 Y[X]=r,Y[Z]=n,r}function Q(){if(!Y[X])return me();let e=Y[X];return Y[Z]||(Y[Z]=e.readyPromise),e}function $(){return Y.FroomleFrontendSdk?Y.FroomleFrontendSdk:{RecommendationItem:E,RecommendationList:T,Recommendations:w,setPageVisit:z,setEnvironment:R,setConsent:q,setUserId:G,setDeviceId:K,setRequestDomain:B,setSafeRequest:V,setChannel:H,setContextItem:U,setContextItemType:W,setCustomVariable:fe,getRecommendations:pe,sendEvent:se,addHistories:de,init:Se}}function he(e){return{sdk:$(),mode:e,version:typeof P.getVersion==`function`?P.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 _e(e){let t=Q();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,ge(`froomle:before-init`,he(e)))}function ve(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,ge(`froomle:init`,he(e)))}function ye(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady($())),ve(e)}function be(e){Q().rejectReady(e)}function xe(e=`auto`){if(typeof document>`u`)return Promise.resolve($());let t=Q();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{_e(e),console.log(`froomle loads dom`),N.domInit(ue.fromDocument(document)).then(()=>{L.registerClickables(),I.processDocument(),ce.sendPageVisit(),le.sendPageView(),ye(e)}).catch(e=>{be(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),I.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`&&I.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 Se(){return xe(`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(R(r),i&&z(i),o&&(U(o),W(s||`article`)),t)K(t);else{let e=J(`froomle_device_id`);e&&K(e)}if(n)G(n);else{let e=J(`froomle_user_id`);e&&G(e)}a&&B(a),c&&V(c!==`false`),l&&H(l)}let t=J(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||q(e)}xe(`auto`)}export{T as C,E as S,ce as _,q as a,D as b,fe as c,z as d,B as f,le as g,L as h,H as i,K as l,G as m,pe as n,U as o,V as p,Se as r,W as s,de as t,R as u,I as v,w,A as x,se as y};
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 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=new S(t._requestUri());u.setHeader(`Content-Type`,`application/json`);let d=t.buildRequestBody(e),f=JSON.stringify(d);u.setPostData(f);let p=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))};u.onError=function(e){p(`HTTP Request Error: `+e)},u.onStatus=function(e){(e<200||e>=300)&&p(`HTTP Status Error: `+e)};try{u.request(!0)}catch(e){let t=r.caught(e).unwrap();return p(`Failed to execute recommendation request: `+i.string(t)),c}let m=function(e){if(!l)try{let t=JSON.parse(e),n=O.fromRequestData(t);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();p(`Failed to parse recommendation response: `+i.string(t))}},h=u.get_responseData();return h==null?l||(u.onData=m):m(h),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 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=[];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 applyTransform(e,t,n){let r=e==null?``:e;switch(t==null?``:t.toLowerCase()){case`append`:return n.length>=1?r+n[0]:r;case`default`:return(r==null||r==``)&&n.length>=1?n[0]:r;case`lower`:return r.toLowerCase();case`prepend`:return n.length>=1?n[0]+r:r;case`replace`:return n.length>=2?g.replace(r,n[0],n[1]):r;case`trim`:return g.trim(r);case`upper`:return r.toUpperCase();case`urlencode`:return encodeURIComponent(r);default:return r}}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++,n=t.parseTransformPart(a[e]);n.name!=``&&(o=t.applyTransform(o,n.name,n.args))}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.11/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 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.11`}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 F(){return D.getConsent()>=1}function ne(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}function re(){let e=D.getChannel();if(e)return e}function ie(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 ae(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}function oe(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 se(e,t,n=`impression`,r){if(!F())return;let i=re()||`www-desktop`,a={event_type:n,page_type:D.getPageVisit(),action_item:e,action_item_type:t,channel:i,device_id:ne()},o=oe();if(o&&(a.user_group=o),r)for(let e in r)a[e]=r[e];try{fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({events:[a]})})}catch{}}var I=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateBody(){let t=[];for(let n of e.impressionQueue){let e=ie(n);if(!e)continue;let r=ae(n)||`article`,i=re()||`www-desktop`,a={event_type:`impression`,page_type:D.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ne()},o=oe(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=[],JSON.stringify({events:t})}static sendImpressions(){console.log(e.impressionQueue),e.impressionQueue.length!==0&&F()&&fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}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(F()){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(!F()||!(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()}}};I.impressionQueue=[],I.observer=null,typeof document<`u`&&(I.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(I.impressionQueue.push(e.target),I.observer.unobserve(e.target))}),I.impressionQueue.length>0&&I.sendImpressions()}));var ce=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[n]})}static sendPageVisit(){D.getPageVisit()&&(D.getContextItem()||e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()}))}},le=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[r]})}static sendPageView(){D.getContextItem()&&D.getPageVisit()&&e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}},L=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 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=(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`]);v&&y&&(g.list_name=v,g.request_id=y),D.getConsent()>=2&&D.getUserId()&&(g.user_id=D.getUserId());let b=(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`,x=JSON.stringify({events:[g]}),S=new Blob([x],{type:`application/json`}),C=e=>fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:x,...e?{keepalive:!0}:{}});if(m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);C(!0).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)}).finally(()=>{window.clearTimeout(n),t()});return}C(!1).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)})},!0))}};L.listenerRegistered=!1;const ue=j,R=P.setEnvironment,z=P.setPageVisit,B=P.setRequestDomain,V=P.setSafeRequest,H=typeof P.setChannel==`function`?P.setChannel:D.setChannel,U=P.setContextItem,W=P.setContextItemType,de=D.addHistories;function fe(e,t){P.setCustomVariable(e,t)}function G(e){P.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function K(e){P.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(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=q);function J(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 Y=globalThis,X=`FroomleFrontendSdkState`,Z=`FroomleFrontendSdkReady`;function me(){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 Y[X]=r,Y[Z]=n,r}function Q(){if(!Y[X])return me();let e=Y[X];return Y[Z]||(Y[Z]=e.readyPromise),e}function $(){return Y.FroomleFrontendSdk?Y.FroomleFrontendSdk:{RecommendationItem:E,RecommendationList:T,Recommendations:w,setPageVisit:z,setEnvironment:R,setConsent:q,setUserId:G,setDeviceId:K,setRequestDomain:B,setSafeRequest:V,setChannel:H,setContextItem:U,setContextItemType:W,setCustomVariable:fe,getRecommendations:pe,sendEvent:se,addHistories:de,init:Se}}function he(e){return{sdk:$(),mode:e,version:typeof P.getVersion==`function`?P.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 _e(e){let t=Q();t.beforeInitEventDispatched||typeof window>`u`||(t.beforeInitEventDispatched=!0,ge(`froomle:before-init`,he(e)))}function ve(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,ge(`froomle:init`,he(e)))}function ye(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady($())),ve(e)}function be(e){Q().rejectReady(e)}function xe(e=`auto`){if(typeof document>`u`)return Promise.resolve($());let t=Q();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{_e(e),console.log(`froomle loads dom`),N.domInit(ue.fromDocument(document)).then(()=>{L.registerClickables(),I.processDocument(),ce.sendPageVisit(),le.sendPageView(),ye(e)}).catch(e=>{be(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),I.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`&&I.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 Se(){return xe(`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(R(r),i&&z(i),o&&(U(o),W(s||`article`)),t)K(t);else{let e=J(`froomle_device_id`);e&&K(e)}if(n)G(n);else{let e=J(`froomle_user_id`);e&&G(e)}a&&B(a),c&&V(c!==`false`),l&&H(l)}let t=J(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||q(e)}xe(`auto`)}export{T as C,E as S,ce as _,q as a,D as b,fe as c,z as d,B as f,le as g,L as h,H as i,K as l,G as m,pe as n,U as o,V as p,Se as r,W as s,de as t,R as u,I as v,w,A as x,se 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-DFZcimm2.cjs`);let l=require(`react`);l=s(l);function u({children:e,id:t}){let[n,r]=l.default.useState(!1);return n||(c.S.addHistories([t]),r(!0)),l.default.createElement(l.default.Fragment,null,e)}function d({children:e,value:t}){return l.default.createElement(l.default.Fragment,null,e)}d.displayName=`FroomleOrderItem`;function f({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(console.log(e.type.displayName),l.default.isValidElement(e)&&e.type===d){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.S.getOrder(t,n,o).then(e=>{i(e)}),a})())}function p(e){return(0,l.useEffect)(()=>{c.t().catch(()=>{}).finally(()=>{c._.registerClickables(),c.b.processDocument(),c.y.sendPageVisit(),c.v.sendPageView()})},[]),l.default.createElement(l.default.Fragment,null,e.children)}const m=(0,l.createContext)(null);function h(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 g(){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 _({reco:e,children:t,...n}){let r=(0,l.useRef)(null);return l.default.useEffect(()=>{let t=!1,n=e.__froomleList;return r.current&&n&&r.current.setAttribute(`data-froomle-reco`,n),Promise.resolve(e).then(e=>{if(t||!r.current)return;let n=h(e,`Id`,`item_id`),i=h(e,`ItemType`,`item_type`),a=h(e,`RequestId`,`request_id`),o=h(e,`UserGroup`,`user_group`)||g();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(m.Provider,{value:e},l.default.createElement(`div`,{ref:r,...n},t))}const v=()=>{let e=(0,l.useContext)(m);if(e===null)throw Error(`useFroomleReco must be used within a FroomleRecoProvider`);return e};function y(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=u,exports.FroomleOrder=f,exports.FroomleOrderItem=d,exports.FroomleReco=_,exports.FroomleSdkInit=p,exports.useCreateReco=y,exports.useReco=v;
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-aTULHdWC.cjs`);let l=require(`react`);l=s(l);function u({children:e,id:t}){let[n,r]=l.default.useState(!1);return n||(c.S.addHistories([t]),r(!0)),l.default.createElement(l.default.Fragment,null,e)}function d({children:e,value:t}){return l.default.createElement(l.default.Fragment,null,e)}d.displayName=`FroomleOrderItem`;function f({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(console.log(e.type.displayName),l.default.isValidElement(e)&&e.type===d){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.S.getOrder(t,n,o).then(e=>{i(e)}),a})())}function p(e){return(0,l.useEffect)(()=>{c.t().catch(()=>{}).finally(()=>{c._.registerClickables(),c.b.processDocument(),c.y.sendPageVisit(),c.v.sendPageView()})},[]),l.default.createElement(l.default.Fragment,null,e.children)}const m=(0,l.createContext)(null);function h(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 g(){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 _({reco:e,children:t,...n}){let r=(0,l.useRef)(null);return l.default.useEffect(()=>{let t=!1,n=e.__froomleList;return r.current&&n&&r.current.setAttribute(`data-froomle-reco`,n),Promise.resolve(e).then(e=>{if(t||!r.current)return;let n=h(e,`Id`,`item_id`),i=h(e,`ItemType`,`item_type`),a=h(e,`RequestId`,`request_id`),o=h(e,`UserGroup`,`user_group`)||g();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(m.Provider,{value:e},l.default.createElement(`div`,{ref:r,...n},t))}const v=()=>{let e=(0,l.useContext)(m);if(e===null)throw Error(`useFroomleReco must be used within a FroomleRecoProvider`);return e};function y(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=u,exports.FroomleOrder=f,exports.FroomleOrderItem=d,exports.FroomleReco=_,exports.FroomleSdkInit=p,exports.useCreateReco=y,exports.useReco=v;
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as RecommendationItem } from "./js-Dstnm_pz.js";
2
- import "./src-C-NQZ8wz.js";
1
+ import { S as RecommendationItem } from "./js-BWOYniiw.js";
2
+ import "./src-CIFvHxry.js";
3
3
  import React, { ReactNode } from "react";
4
4
 
5
5
  //#region src/react/Custom.d.ts
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- import{_ as e,b as t,g as n,h as r,v as i}from"./js-Dstnm_pz.js";import{n as a,t as o}from"./src-C-NQZ8wz.js";import s,{createContext as c,useContext as l,useEffect as u,useRef as d,useState as f}from"react";function p({children:e,id:n}){let[r,i]=s.useState(!1);return r||(t.addHistories([n]),i(!0)),s.createElement(s.Fragment,null,e)}function m({children:e,value:t}){return s.createElement(s.Fragment,null,e)}m.displayName=`FroomleOrderItem`;function h({children:e,list:n,category:r}){let[i,a]=s.useState(null);return s.createElement(s.Fragment,null,(()=>{let o=s.Children.toArray(e),c=[],l=[],u=[[]];for(let e of o)if(console.log(e.type.displayName),s.isValidElement(e)&&e.type===m){let t=e.props.value;c.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=c.indexOf(t);n!==-1&&(e.push(l[n]),e.push(...u[n+1]))}return e}else return t.getOrder(n,r,c).then(e=>{a(e)}),o})())}function g(t){return u(()=>{o().catch(()=>{}).finally(()=>{r.registerClickables(),i.processDocument(),e.sendPageVisit(),n.sendPageView()})},[]),s.createElement(s.Fragment,null,t.children)}const _=c(null);function v(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 y(){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 b({reco:e,children:t,...n}){let r=d(null);return s.useEffect(()=>{let t=!1,n=e.__froomleList;return r.current&&n&&r.current.setAttribute(`data-froomle-reco`,n),Promise.resolve(e).then(e=>{if(t||!r.current)return;let n=v(e,`Id`,`item_id`),i=v(e,`ItemType`,`item_type`),a=v(e,`RequestId`,`request_id`),o=v(e,`UserGroup`,`user_group`)||y();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]),s.createElement(_.Provider,{value:e},s.createElement(`div`,{ref:r,...n},t))}const x=()=>{let e=l(_);if(e===null)throw Error(`useFroomleReco must be used within a FroomleRecoProvider`);return e};function S(e){let t=d(null),[n,r]=f(0);if(!t.current){let{list:n,filters:r,...i}=e;t.current=a({list:n,filters:r,others:Object.entries(i).map(([e,t])=>({key:e,value:t}))})}return u(()=>{let e=!0;return Promise.resolve(t.current).then(()=>{e&&r(1)}).catch(()=>{e&&r(1)}),()=>{e=!1}},[]),t.current}export{p as FroomleCustomItem,h as FroomleOrder,m as FroomleOrderItem,b as FroomleReco,g as FroomleSdkInit,S as useCreateReco,x as useReco};
1
+ import{_ as e,b as t,g as n,h as r,v as i}from"./js-BWOYniiw.js";import{n as a,t as o}from"./src-CIFvHxry.js";import s,{createContext as c,useContext as l,useEffect as u,useRef as d,useState as f}from"react";function p({children:e,id:n}){let[r,i]=s.useState(!1);return r||(t.addHistories([n]),i(!0)),s.createElement(s.Fragment,null,e)}function m({children:e,value:t}){return s.createElement(s.Fragment,null,e)}m.displayName=`FroomleOrderItem`;function h({children:e,list:n,category:r}){let[i,a]=s.useState(null);return s.createElement(s.Fragment,null,(()=>{let o=s.Children.toArray(e),c=[],l=[],u=[[]];for(let e of o)if(console.log(e.type.displayName),s.isValidElement(e)&&e.type===m){let t=e.props.value;c.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=c.indexOf(t);n!==-1&&(e.push(l[n]),e.push(...u[n+1]))}return e}else return t.getOrder(n,r,c).then(e=>{a(e)}),o})())}function g(t){return u(()=>{o().catch(()=>{}).finally(()=>{r.registerClickables(),i.processDocument(),e.sendPageVisit(),n.sendPageView()})},[]),s.createElement(s.Fragment,null,t.children)}const _=c(null);function v(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 y(){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 b({reco:e,children:t,...n}){let r=d(null);return s.useEffect(()=>{let t=!1,n=e.__froomleList;return r.current&&n&&r.current.setAttribute(`data-froomle-reco`,n),Promise.resolve(e).then(e=>{if(t||!r.current)return;let n=v(e,`Id`,`item_id`),i=v(e,`ItemType`,`item_type`),a=v(e,`RequestId`,`request_id`),o=v(e,`UserGroup`,`user_group`)||y();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]),s.createElement(_.Provider,{value:e},s.createElement(`div`,{ref:r,...n},t))}const x=()=>{let e=l(_);if(e===null)throw Error(`useFroomleReco must be used within a FroomleRecoProvider`);return e};function S(e){let t=d(null),[n,r]=f(0);if(!t.current){let{list:n,filters:r,...i}=e;t.current=a({list:n,filters:r,others:Object.entries(i).map(([e,t])=>({key:e,value:t}))})}return u(()=>{let e=!0;return Promise.resolve(t.current).then(()=>{e&&r(1)}).catch(()=>{e&&r(1)}),()=>{e=!1}},[]),t.current}export{p as FroomleCustomItem,h as FroomleOrder,m as FroomleOrderItem,b as FroomleReco,g as FroomleSdkInit,S as useCreateReco,x as useReco};
@@ -1 +1 @@
1
- import{b as e,x as t}from"./js-Dstnm_pz.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};
1
+ import{b as e,x as t}from"./js-BWOYniiw.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};
@@ -2,4 +2,4 @@ var e=class e{static global(t){return e.globals[t]?e.globals[t]:e.globals[t]={}}
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+` : `+t.__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(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 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=new S(t._requestUri());u.setHeader(`Content-Type`,`application/json`);let d=t.buildRequestBody(e),f=JSON.stringify(d);u.setPostData(f);let p=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))};u.onError=function(e){p(`HTTP Request Error: `+e)},u.onStatus=function(e){(e<200||e>=300)&&p(`HTTP Status Error: `+e)};try{u.request(!0)}catch(e){let t=r.caught(e).unwrap();return p(`Failed to execute recommendation request: `+i.string(t)),c}let m=function(e){if(!l)try{let t=JSON.parse(e),n=O.fromRequestData(t);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();p(`Failed to parse recommendation response: `+i.string(t))}},h=u.get_responseData();return h==null?l||(u.onData=m):m(h),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 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=[];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;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;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 applyTransform(e,t,n){let r=e==null?``:e;switch(t==null?``:t.toLowerCase()){case`append`:return n.length>=1?r+n[0]:r;case`default`:return(r==null||r==``)&&n.length>=1?n[0]:r;case`lower`:return r.toLowerCase();case`prepend`:return n.length>=1?n[0]+r:r;case`replace`:return n.length>=2?g.replace(r,n[0],n[1]):r;case`trim`:return g.trim(r);case`upper`:return r.toUpperCase();case`urlencode`:return encodeURIComponent(r);default:return r}}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++,n=t.parseTransformPart(a[e]);n.name!=``&&(o=t.applyTransform(o,n.name,n.args))}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.11/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 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.11`}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 F(){return D.getConsent()>=1}function ne(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}function re(){let e=D.getChannel();if(e)return e}function ie(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 ae(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}function oe(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 se(e,t,n=`impression`,r){if(!F())return;let i=re()||`www-desktop`,a={event_type:n,page_type:D.getPageVisit(),action_item:e,action_item_type:t,channel:i,device_id:ne()},o=oe();if(o&&(a.user_group=o),r)for(let e in r)a[e]=r[e];try{fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({events:[a]})})}catch{}}var I=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateBody(){let t=[];for(let n of e.impressionQueue){let e=ie(n);if(!e)continue;let r=ae(n)||`article`,i=re()||`www-desktop`,a={event_type:`impression`,page_type:D.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ne()},o=oe(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=[],JSON.stringify({events:t})}static sendImpressions(){console.log(e.impressionQueue),e.impressionQueue.length!==0&&F()&&fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}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(F()){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(!F()||!(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()}}};I.impressionQueue=[],I.observer=null,typeof document<`u`&&(I.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(I.impressionQueue.push(e.target),I.observer.unobserve(e.target))}),I.impressionQueue.length>0&&I.sendImpressions()}));var ce=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[n]})}static sendPageVisit(){D.getPageVisit()&&(D.getContextItem()||e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()}))}},le=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[r]})}static sendPageView(){D.getContextItem()&&D.getPageVisit()&&e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}},L=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 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=(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`]);v&&y&&(g.list_name=v,g.request_id=y),D.getConsent()>=2&&D.getUserId()&&(g.user_id=D.getUserId());let b=(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`,x=JSON.stringify({events:[g]}),S=new Blob([x],{type:`application/json`}),C=e=>fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:x,...e?{keepalive:!0}:{}});if(m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);C(!0).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)}).finally(()=>{window.clearTimeout(n),t()});return}C(!1).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)})},!0))}};L.listenerRegistered=!1;const ue=j,R=P.setEnvironment,z=P.setPageVisit,B=P.setRequestDomain,V=P.setSafeRequest,H=typeof P.setChannel==`function`?P.setChannel:D.setChannel,U=P.setContextItem,W=P.setContextItemType,de=D.addHistories;function fe(e,t){P.setCustomVariable(e,t)}function G(e){P.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function K(e){P.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(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=q);function J(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 Y=globalThis,X=`FroomleFrontendSdkState`,Z=`FroomleFrontendSdkReady`;function me(){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 Y[X]=r,Y[Z]=n,r}function Q(){if(!Y[X])return me();let e=Y[X];return Y[Z]||(Y[Z]=e.readyPromise),e}function he(){return Y.FroomleFrontendSdk?Y.FroomleFrontendSdk:{RecommendationItem:E,RecommendationList:T,Recommendations:w,setPageVisit:z,setEnvironment:R,setConsent:q,setUserId:G,setDeviceId:K,setRequestDomain:B,setSafeRequest:V,setChannel:H,setContextItem:U,setContextItemType:W,setCustomVariable:fe,getRecommendations:pe,sendEvent:se,addHistories:de,init:Ce}}function ge(e){return{sdk:he(),mode:e,version:typeof P.getVersion==`function`?P.getVersion():void 0}}function _e(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,_e(`froomle:before-init`,ge(e)))}function ye(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,_e(`froomle:init`,ge(e)))}function be(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady(he())),ye(e)}function xe(e){Q().rejectReady(e)}function Se(e=`auto`){if(typeof document>`u`)return Promise.resolve(he());let t=Q();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{ve(e),console.log(`froomle loads dom`),N.domInit(ue.fromDocument(document)).then(()=>{L.registerClickables(),I.processDocument(),ce.sendPageVisit(),le.sendPageView(),be(e)}).catch(e=>{xe(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),I.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`&&I.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 Ce(){return Se(`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(R(r),i&&z(i),o&&(U(o),W(s||`article`)),t)K(t);else{let e=J(`froomle_device_id`);e&&K(e)}if(n)G(n);else{let e=J(`froomle_user_id`);e&&G(e)}a&&B(a),c&&V(c!==`false`),l&&H(l)}let t=J(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||q(e)}Se(`auto`)}function we(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const $=[];function Te(){var e;return typeof document>`u`?``:((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||``}function Ee(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 De(){let e=$.splice(0,$.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=>Ee(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 Oe(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 ke(e){let t=Oe(e).promise;we();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=Te();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,`C`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return ce}});
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 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=new S(t._requestUri());u.setHeader(`Content-Type`,`application/json`);let d=t.buildRequestBody(e),f=JSON.stringify(d);u.setPostData(f);let p=function(e){if(l)return;l=!0;let t=c;t._isFinished||(t._error=e,t._isFinished=!0,t._reject(e))};u.onError=function(e){p(`HTTP Request Error: `+e)},u.onStatus=function(e){(e<200||e>=300)&&p(`HTTP Status Error: `+e)};try{u.request(!0)}catch(e){let t=r.caught(e).unwrap();return p(`Failed to execute recommendation request: `+i.string(t)),c}let m=function(e){if(!l)try{let t=JSON.parse(e),n=O.fromRequestData(t);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();p(`Failed to parse recommendation response: `+i.string(t))}},h=u.get_responseData();return h==null?l||(u.onData=m):m(h),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 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=[];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 applyTransform(e,t,n){let r=e==null?``:e;switch(t==null?``:t.toLowerCase()){case`append`:return n.length>=1?r+n[0]:r;case`default`:return(r==null||r==``)&&n.length>=1?n[0]:r;case`lower`:return r.toLowerCase();case`prepend`:return n.length>=1?n[0]+r:r;case`replace`:return n.length>=2?g.replace(r,n[0],n[1]):r;case`trim`:return g.trim(r);case`upper`:return r.toUpperCase();case`urlencode`:return encodeURIComponent(r);default:return r}}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++,n=t.parseTransformPart(a[e]);n.name!=``&&(o=t.applyTransform(o,n.name,n.args))}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.11/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 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.11`}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 F(){return D.getConsent()>=1}function ne(){return D.getConsent()<2?`no-consent`:D.getDeviceId()}function re(){let e=D.getChannel();if(e)return e}function ie(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 ae(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}function oe(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 se(e,t,n=`impression`,r){if(!F())return;let i=re()||`www-desktop`,a={event_type:n,page_type:D.getPageVisit(),action_item:e,action_item_type:t,channel:i,device_id:ne()},o=oe();if(o&&(a.user_group=o),r)for(let e in r)a[e]=r[e];try{fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({events:[a]})})}catch{}}var I=class e{static queueIfNotPresent(t){e.impressionQueue.includes(t)||e.impressionQueue.push(t)}static generateBody(){let t=[];for(let n of e.impressionQueue){let e=ie(n);if(!e)continue;let r=ae(n)||`article`,i=re()||`www-desktop`,a={event_type:`impression`,page_type:D.getPageVisit(),action_item:e,action_item_type:r,channel:i,device_id:ne()},o=oe(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=[],JSON.stringify({events:t})}static sendImpressions(){console.log(e.impressionQueue),e.impressionQueue.length!==0&&F()&&fetch(te(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}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(F()){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(!F()||!(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()}}};I.impressionQueue=[],I.observer=null,typeof document<`u`&&(I.observer=new IntersectionObserver((e,t)=>{e.forEach(e=>{e.isIntersecting&&(I.impressionQueue.push(e.target),I.observer.unobserve(e.target))}),I.impressionQueue.length>0&&I.sendImpressions()}));var ce=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[n]})}static sendPageVisit(){D.getPageVisit()&&(D.getContextItem()||e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()}))}},le=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 uri(){return(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`}static generateBody(){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()),JSON.stringify({events:[r]})}static sendPageView(){D.getContextItem()&&D.getPageVisit()&&e.canTrackEvents()&&fetch(e.uri(),{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:e.generateBody()})}},L=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 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=(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`]);v&&y&&(g.list_name=v,g.request_id=y),D.getConsent()>=2&&D.getUserId()&&(g.user_id=D.getUserId());let b=(D.getSafeRequest()?`https://`:`http://`)+D.getRequestDomain()+`/api/`+D.getEnvironment()+`/events`,x=JSON.stringify({events:[g]}),S=new Blob([x],{type:`application/json`}),C=e=>fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:x,...e?{keepalive:!0}:{}});if(m&&d){let e=!1,t=()=>{e||(e=!0,window.location.assign(d))},n=window.setTimeout(t,200);C(!0).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)}).finally(()=>{window.clearTimeout(n),t()});return}C(!1).catch(()=>{typeof navigator<`u`&&typeof navigator.sendBeacon==`function`&&navigator.sendBeacon(b,S)})},!0))}};L.listenerRegistered=!1;const ue=j,R=P.setEnvironment,z=P.setPageVisit,B=P.setRequestDomain,V=P.setSafeRequest,H=typeof P.setChannel==`function`?P.setChannel:D.setChannel,U=P.setContextItem,W=P.setContextItemType,de=D.addHistories;function fe(e,t){P.setCustomVariable(e,t)}function G(e){P.setUserId(e),document.cookie=`froomle_user_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function K(e){P.setDeviceId(e),document.cookie=`froomle_device_id=${e}; max-age=${3600*24*365*20}; path=/; samesite=lax`}function q(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=q);function J(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 Y=globalThis,X=`FroomleFrontendSdkState`,Z=`FroomleFrontendSdkReady`;function me(){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 Y[X]=r,Y[Z]=n,r}function Q(){if(!Y[X])return me();let e=Y[X];return Y[Z]||(Y[Z]=e.readyPromise),e}function he(){return Y.FroomleFrontendSdk?Y.FroomleFrontendSdk:{RecommendationItem:E,RecommendationList:T,Recommendations:w,setPageVisit:z,setEnvironment:R,setConsent:q,setUserId:G,setDeviceId:K,setRequestDomain:B,setSafeRequest:V,setChannel:H,setContextItem:U,setContextItemType:W,setCustomVariable:fe,getRecommendations:pe,sendEvent:se,addHistories:de,init:Ce}}function ge(e){return{sdk:he(),mode:e,version:typeof P.getVersion==`function`?P.getVersion():void 0}}function _e(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,_e(`froomle:before-init`,ge(e)))}function ye(e){let t=Q();t.initEventDispatched||typeof window>`u`||(t.initEventDispatched=!0,_e(`froomle:init`,ge(e)))}function be(e){let t=Q();t.initialized||(t.initialized=!0,t.resolveReady(he())),ye(e)}function xe(e){Q().rejectReady(e)}function Se(e=`auto`){if(typeof document>`u`)return Promise.resolve(he());let t=Q();if(t.initStarted)return t.readyPromise;t.initStarted=!0;let n=()=>{ve(e),console.log(`froomle loads dom`),N.domInit(ue.fromDocument(document)).then(()=>{L.registerClickables(),I.processDocument(),ce.sendPageVisit(),le.sendPageView(),be(e)}).catch(e=>{xe(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),I.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`&&I.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 Ce(){return Se(`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(R(r),i&&z(i),o&&(U(o),W(s||`article`)),t)K(t);else{let e=J(`froomle_device_id`);e&&K(e)}if(n)G(n);else{let e=J(`froomle_user_id`);e&&G(e)}a&&B(a),c&&V(c!==`false`),l&&H(l)}let t=J(`froomle_consent`);if(t){let e=Number(t);Number.isNaN(e)||q(e)}Se(`auto`)}function we(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const $=[];function Te(){var e;return typeof document>`u`?``:((e=document.querySelector(`[data-froomle-user-group]`))==null?void 0:e.getAttribute(`data-froomle-user-group`))||``}function Ee(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 De(){let e=$.splice(0,$.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=>Ee(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 Oe(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 ke(e){let t=Oe(e).promise;we();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=Te();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,`C`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return ce}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@froomle/frontend-sdk",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "Froomle frontend SDK",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",