wineater-bot 3.9.0 → 3.9.2

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.
@@ -45,11 +45,13 @@ function bi(t, e, n = {}, s = {}) {
45
45
  const l = {
46
46
  event_type: t,
47
47
  store_id: e,
48
- user_id: r,
49
48
  session_id: c,
50
49
  event_time: u,
51
50
  data: n,
52
- meta: s,
51
+ meta: {
52
+ ...s,
53
+ user_id: r
54
+ },
53
55
  device_info: o,
54
56
  region: navigator.language.split("-")[1] || null,
55
57
  language: navigator.language.split("-")[0] || "en"
@@ -8057,7 +8059,7 @@ class ka {
8057
8059
 
8058
8060
  <div class="tile-top">
8059
8061
  ${p ? `<img src="${p}" alt="${d}" class="wine-image" />` : ""}
8060
- <div class="wine-price">${c(v)} ${J.getCurrency("label")}</div>
8062
+ ${v ? `<div class="wine-price">${c(v)} ${J.getCurrency("label")}</div>` : ""}
8061
8063
  <h3 class="wine-title">${d}</h3>
8062
8064
  </div>
8063
8065
 
@@ -1,4 +1,4 @@
1
- (function(Ke){typeof define=="function"&&define.amd?define(Ke):Ke()})(function(){"use strict";var ui,hi;function Ke(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Nt(t,e,n){console.log(t,n);let s="";if(n){const i=new Date;i.setTime(i.getTime()+n*24*60*60*1e3),s="; expires="+i.toUTCString()}document.cookie=t+"="+(e||"")+s+"; path=/; secure; samesite=strict"}function Ot(t){const e=t+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let i=n[s];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null}function Un(){const t="uniqueUserID";let e=Ot(t);return e||(e=Ke(),Nt(t,e,365)),e}function bi(t,e,n={},s={}){const i="https://admin-api.wineater.com/api/widget-events";let r=Ot("uniqueUserID");r||(r=Un());const o={user_agent:navigator.userAgent,screen_width:window.screen.width,screen_height:window.screen.height,language:navigator.language,platform:navigator.platform},u=new Date().toISOString();let c=Ot("sessionID");c||(c=Ke(),Nt("sessionID",c,1));const l={event_type:t,store_id:e,user_id:r,session_id:c,event_time:u,data:n,meta:s,device_info:o,region:navigator.language.split("-")[1]||null,language:navigator.language.split("-")[0]||"en"};return fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(a=>a.ok?a.json():a.json().then(d=>{throw new Error(d.message||"Failed to track widget event")})).catch(a=>{throw console.error("Widget event tracking error:",a),a})}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(b){try{return localStorage.getItem(b)||null}catch{return null}},getItem:function(b,f){var h=this;return new Promise(function(m,g){try{var S=h.getItemSync(b);f==null||f(null,S),m(S)}catch(k){f&&f(k,null),g(k)}})},setItem:function(b,f,h){return new Promise(function(m,g){try{localStorage.setItem(b,f),h&&h(null,f),m(f)}catch(S){h&&h(S,null),g(S)}})}},i=function(){return i=Object.assign||function(b){for(var f,h=1,m=arguments.length;h<m;h++)for(var g in f=arguments[h])Object.prototype.hasOwnProperty.call(f,g)&&(b[g]=f[g]);return b},i.apply(this,arguments)};function r(b,f,h,m){return new(h||(h=Promise))(function(g,S){function k(W){try{B(m.next(W))}catch(O){S(O)}}function A(W){try{B(m.throw(W))}catch(O){S(O)}}function B(W){var O;W.done?g(W.value):(O=W.value,O instanceof h?O:new h(function(q){q(O)})).then(k,A)}B((m=m.apply(b,f||[])).next())})}function o(b,f){var h,m,g,S,k={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return S={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function A(B){return function(W){return function(O){if(h)throw new TypeError("Generator is already executing.");for(;k;)try{if(h=1,m&&(g=2&O[0]?m.return:O[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,O[1])).done)return g;switch(m=0,g&&(O=[2&O[0],g.value]),O[0]){case 0:case 1:g=O;break;case 4:return k.label++,{value:O[1],done:!1};case 5:k.label++,m=O[1],O=[0];continue;case 7:O=k.ops.pop(),k.trys.pop();continue;default:if(g=k.trys,!((g=g.length>0&&g[g.length-1])||O[0]!==6&&O[0]!==2)){k=0;continue}if(O[0]===3&&(!g||O[1]>g[0]&&O[1]<g[3])){k.label=O[1];break}if(O[0]===6&&k.label<g[1]){k.label=g[1],g=O;break}if(g&&k.label<g[2]){k.label=g[2],k.ops.push(O);break}g[2]&&k.ops.pop(),k.trys.pop();continue}O=f.call(b,k)}catch(q){O=[6,q],m=0}finally{h=g=0}if(5&O[0])throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}([B,W])}}}function u(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))}var c=function b(f,h){if(f===h)return!0;if(f&&h&&typeof f=="object"&&typeof h=="object"){if(f.constructor!==h.constructor)return!1;var m,g,S;if(Array.isArray(f)){if((m=f.length)!=h.length)return!1;for(g=m;g--!=0;)if(!b(f[g],h[g]))return!1;return!0}if(f.constructor===RegExp)return f.source===h.source&&f.flags===h.flags;if(f.valueOf!==Object.prototype.valueOf)return f.valueOf()===h.valueOf();if(f.toString!==Object.prototype.toString)return f.toString()===h.toString();if((m=(S=Object.keys(f)).length)!==Object.keys(h).length)return!1;for(g=m;g--!=0;)if(!Object.prototype.hasOwnProperty.call(h,S[g]))return!1;for(g=m;g--!=0;){var k=S[g];if(!b(f[k],h[k]))return!1}return!0}return f!=f&&h!=h};function l(b,f){var h=Object.keys(f||{}).filter(function(m){var g=b==null?void 0:b[m],S=f==null?void 0:f[m];return!c(g,S)});return Object.keys(b||{}).filter(function(m){Object.keys(f||{}).includes(m)||h.push(m)}),Object.keys(h).length?h:null}var a,d;function p(b,f,h){var m="shortString",g=!0;typeof h=="number"&&(m="javaDouble",g=!1),b[m]=b[m]||{},b[m][f]=g?h+"":h}function v(b){return!!b&&typeof b=="object"&&b.value!==void 0}function w(b){return Object.fromEntries(Object.entries(b).map(function(f){var h=f[0],m=f[1];return[h,v(m)?m:{value:m}]}))}function y(b){return i(i({},b),{identity:b.identity?i(i({},b.identity),{traits:w(b.identity.traits||{})}):void 0})}(function(b){b.NONE="NONE",b.DEFAULT_FLAGS="DEFAULT_FLAGS",b.CACHE="CACHE",b.SERVER="SERVER"})(a||(a={}));var x,C=null,F="BULLET_TRAIN_DB",R="BULLET_TRAIN_EVENT",E="https://edge.api.flagsmith.com/api/v1/",N="flagsmith_value_",D="flagsmith_enabled_",L="flagsmith_trait_",I=function(){function b(f){var h=this;this._trigger=null,this._triggerLoadingState=null,this.timestamp=null,this.isLoading=!1,this.eventSource=null,this.getFlags=function(){var m=h,g=m.api,S=m.evaluationContext;h.log("Get Flags"),h.isLoading=!0,h.loadingState.isFetching||h.setLoadingState(i(i({},h.loadingState),{isFetching:!0}));var k="".concat(h.getContext().identity),A=function(B){var W,O,q,ee;if(B&&k==="".concat(h.getContext().identity)){var oe=B.flags,te=B.traits,ne=B.identifier;h.isLoading=!1;var ue={},he={};te=te||[],(oe=oe||[]).forEach(function(K){ue[K.feature.name.toLowerCase().replace(/ /g,"_")]={id:K.feature.id,enabled:K.enabled,value:K.feature_state_value}}),te.forEach(function(K){he[K.trait_key.toLowerCase().replace(/ /g,"_")]={transient:K.transient,value:K.trait_value}}),h.oldFlags=i({},h.flags);var ye=l(h.oldFlags,ue),Ze=l((W=h.evaluationContext.identity)===null||W===void 0?void 0:W.traits,he);if((ne||Object.keys(he).length)&&(h.evaluationContext.identity={traits:he},ne&&(h.evaluationContext.identity.identifier=ne)),h.flags=ue,h.updateStorage(),h._onChange(h.oldFlags,{isFromServer:!0,flagsChanged:ye,traitsChanged:Ze},h._loadedState(null,a.SERVER)),h.datadogRum)try{if(h.datadogRum.trackTraits){var et={};Object.keys(((O=h.evaluationContext.identity)===null||O===void 0?void 0:O.traits)||{}).map(function(K){et[L+K]=h.getTrait(K)});var qe=i(i(i({},h.datadogRum.client.getUser()),{id:h.datadogRum.client.getUser().id||((q=h.evaluationContext.identity)===null||q===void 0?void 0:q.identifier)}),et);h.log("Setting Datadog user",qe),h.datadogRum.client.setUser(qe)}}catch(K){console.error(K)}if(h.dtrum)try{var ie={javaDouble:{},date:{},shortString:{},javaLongOrObject:{}};Object.keys(h.flags).map(function(K){p(ie,N+K,h.getValue(K,{skipAnalytics:!0})),p(ie,D+K,h.hasFeature(K,{skipAnalytics:!0}))}),Object.keys(((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.traits)||{}).map(function(K){p(ie,L+K,h.getTrait(K))}),h.log("Sending javaLongOrObject traits to dynatrace",ie.javaLongOrObject),h.log("Sending date traits to dynatrace",ie.date),h.log("Sending shortString traits to dynatrace",ie.shortString),h.log("Sending javaDouble to dynatrace",ie.javaDouble),h.dtrum.sendSessionProperties(ie.javaLongOrObject,ie.date,ie.shortString,ie.javaDouble)}catch(K){console.error(K)}}};return S.identity?Promise.all([S.identity.traits&&Object.keys(S.identity.traits).length||!S.identity.identifier?h.getJSON(g+"identities/","POST",JSON.stringify({identifier:S.identity.identifier,transient:S.identity.transient,traits:Object.entries(S.identity.traits).map(function(B){var W=B[0],O=B[1];return{trait_key:W,trait_value:O==null?void 0:O.value,transient:O==null?void 0:O.transient}}).filter(function(B){return B.trait_value!==void 0||(h.log("Warning - attempted to set an undefined trait value for key",B.trait_key),!1)})})):h.getJSON(g+"identities/?identifier="+encodeURIComponent(S.identity.identifier)+(S.identity.transient?"&transient=true":""))]).then(function(B){return h.evaluationContext.identity=i(i({},h.evaluationContext.identity),{traits:{}}),A(B==null?void 0:B[0])}).catch(function(B){var W=B.message,O=new Error(W);return Promise.reject(O)}):h.getJSON(g+"flags/").then(function(B){return A({flags:B,traits:void 0})})},this.analyticsFlags=function(){var m=h.api;if(h.evaluationEvent&&h.evaluationContext.environment&&h.evaluationEvent[h.evaluationContext.environment.apiKey])return h.evaluationEvent&&Object.getOwnPropertyNames(h.evaluationEvent).length!==0&&Object.getOwnPropertyNames(h.evaluationEvent[h.evaluationContext.environment.apiKey]).length!==0?h.getJSON(m+"analytics/flags/","POST",JSON.stringify(h.evaluationEvent[h.evaluationContext.environment.apiKey])).then(function(g){if(h.evaluationContext.environment){var S=h.getState();h.evaluationEvent||(h.evaluationEvent={}),h.evaluationEvent[h.evaluationContext.environment.apiKey]={},h.setState(i(i({},S),{evaluationEvent:h.evaluationEvent})),h.updateEventStorage()}}).catch(function(g){h.log("Exception fetching evaluationEvent",g)}):void 0},this.datadogRum=null,this.loadingState={isLoading:!0,isFetching:!0,error:null,source:a.NONE},this.canUseStorage=!1,this.analyticsInterval=null,this.api=null,this.cacheFlags=!1,this.ts=null,this.enableAnalytics=!1,this.enableLogs=!1,this.evaluationContext={},this.evaluationEvent=null,this.flags=null,this.getFlagInterval=null,this.headers=null,this.initialised=!1,this.oldFlags=null,this.onChange=null,this.onError=null,this.ticks=null,this.timer=null,this.dtrum=null,this.withTraits=null,this.cacheOptions={ttl:0,skipAPI:!1,loadStale:!1},this.getValue=function(m,g,S){var k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=null;if(k&&(A=k.value),g!=null&&g.skipAnalytics||S||h.evaluateFlag(m,"VALUE"),A===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return A===null?(h.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(A)}catch{return g.fallback}return A},this.getTrait=function(m){var g,S;return((g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits)&&((S=h.evaluationContext.identity.traits[m.toLowerCase().replace(/ /g,"_")])===null||S===void 0?void 0:S.value)},this.getAllTraits=function(){var m;return Object.fromEntries(Object.entries(((m=h.evaluationContext.identity)===null||m===void 0?void 0:m.traits)||{}).map(function(g){var S=g[0],k=g[1];return[S,k==null?void 0:k.value]}))},this.setContext=function(m){var g=y(m);return h.evaluationContext=i(i({},g),{environment:g.environment||h.evaluationContext.environment}),h.initialised?h.getFlags():Promise.resolve()},this.getContext=function(){return h.evaluationContext},this.updateContext=function(m){return h.setContext(i(i({},h.getContext()),m))},this.setTrait=function(m,g){var S;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(S=h.evaluationContext.identity)===null||S===void 0?void 0:S.traits),w(Object.fromEntries([[m,g]])))})}))},this.setTraits=function(m){var g;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits),Object.fromEntries(Object.entries(m).map(function(S){var k=S[0],A=S[1];return[k,v(A)?A:{value:A}]})))})}));console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.")},this.hasFeature=function(m,g){var S=typeof g=="object",k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=!1;return!k&&S&&g.fallback!==void 0?A=g==null?void 0:g.fallback:k&&k.enabled&&(A=!0),(S&&!g.skipAnalytics||!g)&&h.evaluateFlag(m,"ENABLED"),A},this.getJSON=function(m,g,S){var k,A=h;A.evaluationContext;var B=A.headers,W={method:g||"GET",body:S,cache:"no-cache",headers:{}};h.evaluationContext.environment&&(W.headers["X-Environment-Key"]=h.evaluationContext.environment.apiKey),g&&g!=="GET"&&(W.headers["Content-Type"]="application/json; charset=utf-8"),B&&Object.assign(W.headers,B),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var O="".concat((k=h.evaluationContext.identity)===null||k===void 0?void 0:k.identifier);return d(m,W).then(function(q){var ee,oe,te="".concat((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(O===te){var ne=(oe=q.headers)===null||oe===void 0?void 0:oe.get("x-flagsmith-document-updated-at");if(ne)try{var ue=parseFloat(ne);if(isNaN(ue))return Promise.reject("Failed to parse x-flagsmith-document-updated-at");h.timestamp=ue}catch(he){h.log(he,"Failed to parse x-flagsmith-document-updated-at",ne)}return h.log("Fetch response: "+q.status+" "+(g||"GET")+0+m),q.text().then(function(he){var ye=he;try{ye=JSON.parse(he)}catch{}return!ye&&q.status&&(ye="API Response: ".concat(q.status)),q.status&&q.status>=200&&q.status<300?ye:Promise.reject(new Error(ye))})}h.log("Received response with identity mismatch, ignoring response. Requested: ".concat(O,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(h.datadogRum&&(h.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?h.datadogRum.client.addFeatureFlagEvaluation(N+m,h.getValue(m,{},!0)):h.datadogRum.client.addFeatureFlagEvaluation(D+m,h.hasFeature(m,!0)):console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")),h.enableAnalytics){if(!h.evaluationEvent||!h.evaluationContext.environment)return;h.evaluationEvent[h.evaluationContext.environment.apiKey]||(h.evaluationEvent[h.evaluationContext.environment.apiKey]={}),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]===void 0&&(h.evaluationEvent[h.evaluationContext.environment.apiKey][m]=0),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]+=1}h.updateEventStorage()},this._onChange=function(m,g,S){var k,A;h.setLoadingState(S),(k=h.onChange)===null||k===void 0||k.call(h,m,g,h.loadingState),(A=h._trigger)===null||A===void 0||A.call(h)},d=f.fetch?f.fetch:typeof fetch<"u"?fetch:Me==null?void 0:Me.fetch,this.canUseStorage=typeof window<"u"||!!f.browserlessStorage,this.log("Constructing flagsmith instance "+f),f.eventSource&&(x=f.eventSource),f.AsyncStorage&&(C=f.AsyncStorage)}return b.prototype.init=function(f){var h,m,g;return r(this,void 0,void 0,function(){var S,k,A,B,W,O,q,ee,oe,te,ne,ue,he,ye,Ze,et,qe,ie,K,wn,tt,di,nt,Sn,fi,pi,xn,gi,kn,st,Ve,mi,re=this;return o(this,function(pe){switch(pe.label){case 0:S=y(f.evaluationContext||this.evaluationContext),pe.label=1;case 1:if(pe.trys.push([1,13,,14]),k=f.environmentID,A=f.api,B=A===void 0?E:A,W=f.headers,O=f.onChange,q=f.cacheFlags,ee=f.datadogRum,oe=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,he=f.enableLogs,ye=f.enableDynatrace,Ze=f.enableAnalytics,et=f.realtime,qe=f.eventSourceUrl,ie=qe===void 0?"https://realtime.flagsmith.com/":qe,K=f.AsyncStorage,wn=f.identity,tt=f.traits,di=f.state,nt=f.cacheOptions,Sn=f.angularHttpClient,fi=f._trigger,pi=f._triggerLoadingState,S.environment=k?{apiKey:k}:S.environment,!S.environment||!S.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(S.identity=wn||tt?{identifier:wn,traits:tt?Object.fromEntries(Object.entries(tt).map(function(de){return[de[0],{value:de[1]}]})):{}}:S.identity,this.evaluationContext=S,this.api=B,this.headers=W,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=O,xn="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=fi||this._trigger,this._triggerLoadingState=pi||this._triggerLoadingState,this.onError=function(de){re.setLoadingState(i(i({},re.loadingState),{isFetching:!1,isLoading:!1,error:de})),oe==null||oe(de)},this.enableLogs=he||!1,this.cacheOptions=nt?{skipAPI:!!nt.skipAPI,ttl:nt.ttl||0,loadStale:!!nt.loadStale}:this.cacheOptions,!this.cacheOptions.ttl&&this.cacheOptions.skipAPI&&console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."),ne&&(d=ne),this.enableAnalytics=Ze||!1,this.flags=Object.assign({},te)||{},this.datadogRum=ee||null,this.initialised=!0,this.ticks=1e4,this.timer=this.enableLogs?new Date().valueOf():null,this.cacheFlags=C!==void 0&&!!q,K&&(C=K),et&&typeof window<"u"&&this.setupRealtime(ie,S.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:a.DEFAULT_FLAGS})),this.setState(di),this.log("Initialising with properties",f,this),ye&&(typeof dtrum>"u"?console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed."):this.dtrum=dtrum),Sn&&(d=function(de){return function(we,Se){var Ne=Se.headers,Y=Se.method,Ge=Se.body;return new Promise(function(Ae){switch(Y){case"GET":return de.get(we,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})});case"POST":case"PUT":return de.post(we,Ge,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})})}})}}(Sn)),C&&this.canUseStorage&&C.getItem(R).then(function(de){try{re.evaluationEvent=JSON.parse(de)||{}}catch{re.evaluationEvent={}}re.analyticsInterval=setInterval(re.analyticsFlags,re.ticks)}),this.enableAnalytics&&(this.analyticsInterval&&clearInterval(this.analyticsInterval),C&&this.canUseStorage&&C.getItem(R,function(de,we){if(we&&re.evaluationContext.environment){var Se=JSON.parse(we);if(Se[re.evaluationContext.environment.apiKey]){var Ne=re.getState();re.log("Retrieved events from cache",we),re.setState(i(i({},Ne),{evaluationEvent:Se[re.evaluationContext.environment.apiKey]}))}}})),!q)return[3,9];if(!C||!this.canUseStorage)return[3,8];gi=function(de,we){return r(re,void 0,void 0,function(){var Se,Ne,Y,Ge,Ae,Ee,En,vi,Tn,In,Cn,_n,Nn,On,Rn,Dn,Ln,An,Mn,Fn,Pn,Bn,jn,zn;return o(this,function(Oe){switch(Oe.label){case 0:if(!we)return[3,7];Se=null,Ne=null,Oe.label=1;case 1:return Oe.trys.push([1,5,,6]),Y=JSON.parse(we),Ge=!1,Ae=!1,Y&&Y.api===this.api&&((In=(Tn=Y.evaluationContext)===null||Tn===void 0?void 0:Tn.environment)===null||In===void 0?void 0:In.apiKey)===((Cn=this.evaluationContext.environment)===null||Cn===void 0?void 0:Cn.apiKey)&&(Ee=!0,this.evaluationContext.identity&&((Nn=(_n=Y.evaluationContext)===null||_n===void 0?void 0:_n.identity)===null||Nn===void 0?void 0:Nn.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((Rn=(On=Y.evaluationContext)===null||On===void 0?void 0:On.identity)===null||Rn===void 0?void 0:Rn.identifier)+" to "+this.evaluationContext.identity.identifier),Ee=!1),this.cacheOptions.ttl&&(!Y.ts||new Date().valueOf()-Y.ts>this.cacheOptions.ttl)&&(Y.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ee=!1):Y.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ae=!0,Ee=!0)),Ee&&(Ge=!0,Ne=l((Dn=this.evaluationContext.identity)===null||Dn===void 0?void 0:Dn.traits,(An=(Ln=Y.evaluationContext)===null||Ln===void 0?void 0:Ln.identity)===null||An===void 0?void 0:An.traits),Se=l(this.flags,Y.flags),this.setState(i(i({},Y),{evaluationContext:y(i(i({},Y.evaluationContext),{identity:!((Mn=Y.evaluationContext)===null||Mn===void 0)&&Mn.identity?i(i({},(Fn=Y.evaluationContext)===null||Fn===void 0?void 0:Fn.identity),{traits:i(i({},((Bn=(Pn=Y.evaluationContext)===null||Pn===void 0?void 0:Pn.identity)===null||Bn===void 0?void 0:Bn.traits)||{}),tt||{})}):void 0}))})),this.log("Retrieved flags from cache",Y))),Ge?(En=!ue&&(!this.cacheOptions.skipAPI||Ae),this._onChange(null,{isFromServer:!1,flagsChanged:Se,traitsChanged:Ne},this._loadedState(null,a.CACHE,En)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ge&&!Ae&&this.log("Skipping API, using cache"),En&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Oe.sent(),Oe.label=4;case 4:return[3,6];case 5:return vi=Oe.sent(),this.log("Exception fetching cached logs",vi),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Oe.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(jn=this.evaluationContext.identity)===null||jn===void 0?void 0:jn.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(xn);this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(zn=this.evaluationContext.identity)===null||zn===void 0?void 0:zn.traits)},this._loadedState(null,a.DEFAULT_FLAGS))}Oe.label=10;case 10:return[2]}})})},pe.label=2;case 2:return pe.trys.push([2,7,,8]),C.getItemSync?(kn=C.getItemSync(F),[3,5]):[3,3];case 3:return[4,C.getItem(F)];case 4:kn=pe.sent(),pe.label=5;case 5:return[4,gi(null,kn)];case 6:case 7:return pe.sent(),[3,8];case 8:return[3,12];case 9:return ue?[3,11]:[4,this.getFlags()];case 10:return pe.sent(),[3,12];case 11:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},te),traitsChanged:l({},(h=S.identity)===null||h===void 0?void 0:h.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else if(this.flags&&(st=null,Object.keys(this.flags).length===0&&(st=xn),this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(m=S.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(st,a.DEFAULT_FLAGS)),st))throw new Error(st);pe.label=12;case 12:return[3,14];case 13:throw Ve=pe.sent(),this.log("Error during initialisation ",Ve),mi=Ve instanceof Error?Ve:new Error("".concat(Ve)),(g=this.onError)===null||g===void 0||g.call(this,mi),Ve;case 14:return[2]}})})},b.prototype._loadedState=function(f,h,m){return f===void 0&&(f=null),m===void 0&&(m=!1),{error:f,isFetching:m,isLoading:!1,source:h}},b.prototype.getAllFlags=function(){return this.flags},b.prototype.identify=function(f,h,m){return this.evaluationContext.identity={identifier:f,transient:m,traits:this.evaluationContext.identity&&this.evaluationContext.identity.identifier==f?this.evaluationContext.identity.traits:{}},this.evaluationContext.identity.identifier=f,this.log("Identify: "+this.evaluationContext.identity.identifier),h&&(this.evaluationContext.identity.traits=Object.fromEntries(Object.entries(h).map(function(g){var S=g[0],k=g[1];return[S,v(k)?k:{value:k}]}))),this.initialised?this.getFlags():Promise.resolve()},b.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},b.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||E,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},b.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},b.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},b.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},b.prototype.log=function(){for(var f=[],h=0;h<arguments.length;h++)f[h]=arguments[h];this.enableLogs&&console.log.apply(this,u(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},b.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),C.setItem(F,f)}},b.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);C.setItem(R,f)}},b.prototype.setLoadingState=function(f){var h;c(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(h=this._triggerLoadingState)===null||h===void 0||h.call(this))},b.prototype.setupRealtime=function(f,h){var m=this,g=f+"sse/environments/"+h+"/stream";x?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new x(g),this.eventSource.addEventListener("environment_updated",function(S){var k;try{k=JSON.parse(S.data).updated_at}catch(A){m.log("Could not parse sse event",A)}k?!m.timestamp||k>m.timestamp?m.isLoading?m.log("updated_at is new, but flags are loading",S.data,m.timestamp):(m.log("updated_at is new, fetching flags",S.data,m.timestamp),m.getFlags()):m.log("updated_at is outdated, skipping get flags",S.data,m.timestamp):m.log("No updated_at received, fetching flags",S)})):this.log("Error, EventSource is undefined")},b}();function T(b){var f=b.fetch,h=b.AsyncStorage,m=b.eventSource;return new I({fetch:f,AsyncStorage:h,eventSource:m})}var P,H=(P=function(b,f){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,m){h.__proto__=m}||function(h,m){for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(h[g]=m[g])},P(b,f)},function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");function h(){this.constructor=b}P(b,f),b.prototype=f===null?Object.create(f):(h.prototype=f.prototype,new h)}),j=function(b){var f=typeof Symbol=="function"&&Symbol.iterator,h=f&&b[f],m=0;if(h)return h.call(b);if(b&&typeof b.length=="number")return{next:function(){return b&&m>=b.length&&(b=void 0),{value:b&&b[m++],done:!b}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(b,f){var h=typeof Symbol=="function"&&b[Symbol.iterator];if(!h)return b;var m,g,S=h.call(b),k=[];try{for(;(f===void 0||f-- >0)&&!(m=S.next()).done;)k.push(m.value)}catch(A){g={error:A}}finally{try{m&&!m.done&&(h=S.return)&&h.call(S)}finally{if(g)throw g.error}}return k},_=function(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))},M=function(b){function f(){return b.call(this,`EventSource not available.
1
+ (function(Ke){typeof define=="function"&&define.amd?define(Ke):Ke()})(function(){"use strict";var ui,hi;function Ke(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Nt(t,e,n){console.log(t,n);let s="";if(n){const i=new Date;i.setTime(i.getTime()+n*24*60*60*1e3),s="; expires="+i.toUTCString()}document.cookie=t+"="+(e||"")+s+"; path=/; secure; samesite=strict"}function Ot(t){const e=t+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let i=n[s];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null}function Un(){const t="uniqueUserID";let e=Ot(t);return e||(e=Ke(),Nt(t,e,365)),e}function bi(t,e,n={},s={}){const i="https://admin-api.wineater.com/api/widget-events";let r=Ot("uniqueUserID");r||(r=Un());const o={user_agent:navigator.userAgent,screen_width:window.screen.width,screen_height:window.screen.height,language:navigator.language,platform:navigator.platform},u=new Date().toISOString();let c=Ot("sessionID");c||(c=Ke(),Nt("sessionID",c,1));const l={event_type:t,store_id:e,session_id:c,event_time:u,data:n,meta:{...s,user_id:r},device_info:o,region:navigator.language.split("-")[1]||null,language:navigator.language.split("-")[0]||"en"};return fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(a=>a.ok?a.json():a.json().then(d=>{throw new Error(d.message||"Failed to track widget event")})).catch(a=>{throw console.error("Widget event tracking error:",a),a})}var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}};(function(t,e){(function(n,s){s(e)})(Me,function(n){var s={getItemSync:function(b){try{return localStorage.getItem(b)||null}catch{return null}},getItem:function(b,f){var h=this;return new Promise(function(m,g){try{var S=h.getItemSync(b);f==null||f(null,S),m(S)}catch(k){f&&f(k,null),g(k)}})},setItem:function(b,f,h){return new Promise(function(m,g){try{localStorage.setItem(b,f),h&&h(null,f),m(f)}catch(S){h&&h(S,null),g(S)}})}},i=function(){return i=Object.assign||function(b){for(var f,h=1,m=arguments.length;h<m;h++)for(var g in f=arguments[h])Object.prototype.hasOwnProperty.call(f,g)&&(b[g]=f[g]);return b},i.apply(this,arguments)};function r(b,f,h,m){return new(h||(h=Promise))(function(g,S){function k(W){try{B(m.next(W))}catch(O){S(O)}}function A(W){try{B(m.throw(W))}catch(O){S(O)}}function B(W){var O;W.done?g(W.value):(O=W.value,O instanceof h?O:new h(function(q){q(O)})).then(k,A)}B((m=m.apply(b,f||[])).next())})}function o(b,f){var h,m,g,S,k={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return S={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function A(B){return function(W){return function(O){if(h)throw new TypeError("Generator is already executing.");for(;k;)try{if(h=1,m&&(g=2&O[0]?m.return:O[0]?m.throw||((g=m.return)&&g.call(m),0):m.next)&&!(g=g.call(m,O[1])).done)return g;switch(m=0,g&&(O=[2&O[0],g.value]),O[0]){case 0:case 1:g=O;break;case 4:return k.label++,{value:O[1],done:!1};case 5:k.label++,m=O[1],O=[0];continue;case 7:O=k.ops.pop(),k.trys.pop();continue;default:if(g=k.trys,!((g=g.length>0&&g[g.length-1])||O[0]!==6&&O[0]!==2)){k=0;continue}if(O[0]===3&&(!g||O[1]>g[0]&&O[1]<g[3])){k.label=O[1];break}if(O[0]===6&&k.label<g[1]){k.label=g[1],g=O;break}if(g&&k.label<g[2]){k.label=g[2],k.ops.push(O);break}g[2]&&k.ops.pop(),k.trys.pop();continue}O=f.call(b,k)}catch(q){O=[6,q],m=0}finally{h=g=0}if(5&O[0])throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}([B,W])}}}function u(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))}var c=function b(f,h){if(f===h)return!0;if(f&&h&&typeof f=="object"&&typeof h=="object"){if(f.constructor!==h.constructor)return!1;var m,g,S;if(Array.isArray(f)){if((m=f.length)!=h.length)return!1;for(g=m;g--!=0;)if(!b(f[g],h[g]))return!1;return!0}if(f.constructor===RegExp)return f.source===h.source&&f.flags===h.flags;if(f.valueOf!==Object.prototype.valueOf)return f.valueOf()===h.valueOf();if(f.toString!==Object.prototype.toString)return f.toString()===h.toString();if((m=(S=Object.keys(f)).length)!==Object.keys(h).length)return!1;for(g=m;g--!=0;)if(!Object.prototype.hasOwnProperty.call(h,S[g]))return!1;for(g=m;g--!=0;){var k=S[g];if(!b(f[k],h[k]))return!1}return!0}return f!=f&&h!=h};function l(b,f){var h=Object.keys(f||{}).filter(function(m){var g=b==null?void 0:b[m],S=f==null?void 0:f[m];return!c(g,S)});return Object.keys(b||{}).filter(function(m){Object.keys(f||{}).includes(m)||h.push(m)}),Object.keys(h).length?h:null}var a,d;function p(b,f,h){var m="shortString",g=!0;typeof h=="number"&&(m="javaDouble",g=!1),b[m]=b[m]||{},b[m][f]=g?h+"":h}function v(b){return!!b&&typeof b=="object"&&b.value!==void 0}function w(b){return Object.fromEntries(Object.entries(b).map(function(f){var h=f[0],m=f[1];return[h,v(m)?m:{value:m}]}))}function y(b){return i(i({},b),{identity:b.identity?i(i({},b.identity),{traits:w(b.identity.traits||{})}):void 0})}(function(b){b.NONE="NONE",b.DEFAULT_FLAGS="DEFAULT_FLAGS",b.CACHE="CACHE",b.SERVER="SERVER"})(a||(a={}));var x,C=null,F="BULLET_TRAIN_DB",R="BULLET_TRAIN_EVENT",E="https://edge.api.flagsmith.com/api/v1/",N="flagsmith_value_",D="flagsmith_enabled_",L="flagsmith_trait_",I=function(){function b(f){var h=this;this._trigger=null,this._triggerLoadingState=null,this.timestamp=null,this.isLoading=!1,this.eventSource=null,this.getFlags=function(){var m=h,g=m.api,S=m.evaluationContext;h.log("Get Flags"),h.isLoading=!0,h.loadingState.isFetching||h.setLoadingState(i(i({},h.loadingState),{isFetching:!0}));var k="".concat(h.getContext().identity),A=function(B){var W,O,q,ee;if(B&&k==="".concat(h.getContext().identity)){var oe=B.flags,te=B.traits,ne=B.identifier;h.isLoading=!1;var ue={},he={};te=te||[],(oe=oe||[]).forEach(function(K){ue[K.feature.name.toLowerCase().replace(/ /g,"_")]={id:K.feature.id,enabled:K.enabled,value:K.feature_state_value}}),te.forEach(function(K){he[K.trait_key.toLowerCase().replace(/ /g,"_")]={transient:K.transient,value:K.trait_value}}),h.oldFlags=i({},h.flags);var ye=l(h.oldFlags,ue),Ze=l((W=h.evaluationContext.identity)===null||W===void 0?void 0:W.traits,he);if((ne||Object.keys(he).length)&&(h.evaluationContext.identity={traits:he},ne&&(h.evaluationContext.identity.identifier=ne)),h.flags=ue,h.updateStorage(),h._onChange(h.oldFlags,{isFromServer:!0,flagsChanged:ye,traitsChanged:Ze},h._loadedState(null,a.SERVER)),h.datadogRum)try{if(h.datadogRum.trackTraits){var et={};Object.keys(((O=h.evaluationContext.identity)===null||O===void 0?void 0:O.traits)||{}).map(function(K){et[L+K]=h.getTrait(K)});var qe=i(i(i({},h.datadogRum.client.getUser()),{id:h.datadogRum.client.getUser().id||((q=h.evaluationContext.identity)===null||q===void 0?void 0:q.identifier)}),et);h.log("Setting Datadog user",qe),h.datadogRum.client.setUser(qe)}}catch(K){console.error(K)}if(h.dtrum)try{var ie={javaDouble:{},date:{},shortString:{},javaLongOrObject:{}};Object.keys(h.flags).map(function(K){p(ie,N+K,h.getValue(K,{skipAnalytics:!0})),p(ie,D+K,h.hasFeature(K,{skipAnalytics:!0}))}),Object.keys(((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.traits)||{}).map(function(K){p(ie,L+K,h.getTrait(K))}),h.log("Sending javaLongOrObject traits to dynatrace",ie.javaLongOrObject),h.log("Sending date traits to dynatrace",ie.date),h.log("Sending shortString traits to dynatrace",ie.shortString),h.log("Sending javaDouble to dynatrace",ie.javaDouble),h.dtrum.sendSessionProperties(ie.javaLongOrObject,ie.date,ie.shortString,ie.javaDouble)}catch(K){console.error(K)}}};return S.identity?Promise.all([S.identity.traits&&Object.keys(S.identity.traits).length||!S.identity.identifier?h.getJSON(g+"identities/","POST",JSON.stringify({identifier:S.identity.identifier,transient:S.identity.transient,traits:Object.entries(S.identity.traits).map(function(B){var W=B[0],O=B[1];return{trait_key:W,trait_value:O==null?void 0:O.value,transient:O==null?void 0:O.transient}}).filter(function(B){return B.trait_value!==void 0||(h.log("Warning - attempted to set an undefined trait value for key",B.trait_key),!1)})})):h.getJSON(g+"identities/?identifier="+encodeURIComponent(S.identity.identifier)+(S.identity.transient?"&transient=true":""))]).then(function(B){return h.evaluationContext.identity=i(i({},h.evaluationContext.identity),{traits:{}}),A(B==null?void 0:B[0])}).catch(function(B){var W=B.message,O=new Error(W);return Promise.reject(O)}):h.getJSON(g+"flags/").then(function(B){return A({flags:B,traits:void 0})})},this.analyticsFlags=function(){var m=h.api;if(h.evaluationEvent&&h.evaluationContext.environment&&h.evaluationEvent[h.evaluationContext.environment.apiKey])return h.evaluationEvent&&Object.getOwnPropertyNames(h.evaluationEvent).length!==0&&Object.getOwnPropertyNames(h.evaluationEvent[h.evaluationContext.environment.apiKey]).length!==0?h.getJSON(m+"analytics/flags/","POST",JSON.stringify(h.evaluationEvent[h.evaluationContext.environment.apiKey])).then(function(g){if(h.evaluationContext.environment){var S=h.getState();h.evaluationEvent||(h.evaluationEvent={}),h.evaluationEvent[h.evaluationContext.environment.apiKey]={},h.setState(i(i({},S),{evaluationEvent:h.evaluationEvent})),h.updateEventStorage()}}).catch(function(g){h.log("Exception fetching evaluationEvent",g)}):void 0},this.datadogRum=null,this.loadingState={isLoading:!0,isFetching:!0,error:null,source:a.NONE},this.canUseStorage=!1,this.analyticsInterval=null,this.api=null,this.cacheFlags=!1,this.ts=null,this.enableAnalytics=!1,this.enableLogs=!1,this.evaluationContext={},this.evaluationEvent=null,this.flags=null,this.getFlagInterval=null,this.headers=null,this.initialised=!1,this.oldFlags=null,this.onChange=null,this.onError=null,this.ticks=null,this.timer=null,this.dtrum=null,this.withTraits=null,this.cacheOptions={ttl:0,skipAPI:!1,loadStale:!1},this.getValue=function(m,g,S){var k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=null;if(k&&(A=k.value),g!=null&&g.skipAnalytics||S||h.evaluateFlag(m,"VALUE"),A===null&&(g==null?void 0:g.fallback)!==void 0)return g.fallback;if(g!=null&&g.json)try{return A===null?(h.log("Tried to parse null flag as JSON: "+m),null):JSON.parse(A)}catch{return g.fallback}return A},this.getTrait=function(m){var g,S;return((g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits)&&((S=h.evaluationContext.identity.traits[m.toLowerCase().replace(/ /g,"_")])===null||S===void 0?void 0:S.value)},this.getAllTraits=function(){var m;return Object.fromEntries(Object.entries(((m=h.evaluationContext.identity)===null||m===void 0?void 0:m.traits)||{}).map(function(g){var S=g[0],k=g[1];return[S,k==null?void 0:k.value]}))},this.setContext=function(m){var g=y(m);return h.evaluationContext=i(i({},g),{environment:g.environment||h.evaluationContext.environment}),h.initialised?h.getFlags():Promise.resolve()},this.getContext=function(){return h.evaluationContext},this.updateContext=function(m){return h.setContext(i(i({},h.getContext()),m))},this.setTrait=function(m,g){var S;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(S=h.evaluationContext.identity)===null||S===void 0?void 0:S.traits),w(Object.fromEntries([[m,g]])))})}))},this.setTraits=function(m){var g;if(h.api)return h.setContext(i(i({},h.evaluationContext),{identity:i(i({},h.evaluationContext.identity),{traits:i(i({},(g=h.evaluationContext.identity)===null||g===void 0?void 0:g.traits),Object.fromEntries(Object.entries(m).map(function(S){var k=S[0],A=S[1];return[k,v(A)?A:{value:A}]})))})}));console.error("Attempted to setTraits a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true.")},this.hasFeature=function(m,g){var S=typeof g=="object",k=h.flags&&h.flags[m.toLowerCase().replace(/ /g,"_")],A=!1;return!k&&S&&g.fallback!==void 0?A=g==null?void 0:g.fallback:k&&k.enabled&&(A=!0),(S&&!g.skipAnalytics||!g)&&h.evaluateFlag(m,"ENABLED"),A},this.getJSON=function(m,g,S){var k,A=h;A.evaluationContext;var B=A.headers,W={method:g||"GET",body:S,cache:"no-cache",headers:{}};h.evaluationContext.environment&&(W.headers["X-Environment-Key"]=h.evaluationContext.environment.apiKey),g&&g!=="GET"&&(W.headers["Content-Type"]="application/json; charset=utf-8"),B&&Object.assign(W.headers,B),d||console.error("Flagsmith: fetch is undefined, please specify a fetch implementation into flagsmith.init to support SSR.");var O="".concat((k=h.evaluationContext.identity)===null||k===void 0?void 0:k.identifier);return d(m,W).then(function(q){var ee,oe,te="".concat((ee=h.evaluationContext.identity)===null||ee===void 0?void 0:ee.identifier);if(O===te){var ne=(oe=q.headers)===null||oe===void 0?void 0:oe.get("x-flagsmith-document-updated-at");if(ne)try{var ue=parseFloat(ne);if(isNaN(ue))return Promise.reject("Failed to parse x-flagsmith-document-updated-at");h.timestamp=ue}catch(he){h.log(he,"Failed to parse x-flagsmith-document-updated-at",ne)}return h.log("Fetch response: "+q.status+" "+(g||"GET")+0+m),q.text().then(function(he){var ye=he;try{ye=JSON.parse(he)}catch{}return!ye&&q.status&&(ye="API Response: ".concat(q.status)),q.status&&q.status>=200&&q.status<300?ye:Promise.reject(new Error(ye))})}h.log("Received response with identity mismatch, ignoring response. Requested: ".concat(O,", Current: ").concat(te))})},this.evaluateFlag=function(m,g){if(h.datadogRum&&(h.datadogRum.client.addFeatureFlagEvaluation?g==="VALUE"?h.datadogRum.client.addFeatureFlagEvaluation(N+m,h.getValue(m,{},!0)):h.datadogRum.client.addFeatureFlagEvaluation(D+m,h.hasFeature(m,!0)):console.error("Flagsmith: Your datadog RUM client does not support the function addFeatureFlagEvaluation, please update it.")),h.enableAnalytics){if(!h.evaluationEvent||!h.evaluationContext.environment)return;h.evaluationEvent[h.evaluationContext.environment.apiKey]||(h.evaluationEvent[h.evaluationContext.environment.apiKey]={}),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]===void 0&&(h.evaluationEvent[h.evaluationContext.environment.apiKey][m]=0),h.evaluationEvent[h.evaluationContext.environment.apiKey][m]+=1}h.updateEventStorage()},this._onChange=function(m,g,S){var k,A;h.setLoadingState(S),(k=h.onChange)===null||k===void 0||k.call(h,m,g,h.loadingState),(A=h._trigger)===null||A===void 0||A.call(h)},d=f.fetch?f.fetch:typeof fetch<"u"?fetch:Me==null?void 0:Me.fetch,this.canUseStorage=typeof window<"u"||!!f.browserlessStorage,this.log("Constructing flagsmith instance "+f),f.eventSource&&(x=f.eventSource),f.AsyncStorage&&(C=f.AsyncStorage)}return b.prototype.init=function(f){var h,m,g;return r(this,void 0,void 0,function(){var S,k,A,B,W,O,q,ee,oe,te,ne,ue,he,ye,Ze,et,qe,ie,K,wn,tt,di,nt,Sn,fi,pi,xn,gi,kn,st,Ve,mi,re=this;return o(this,function(pe){switch(pe.label){case 0:S=y(f.evaluationContext||this.evaluationContext),pe.label=1;case 1:if(pe.trys.push([1,13,,14]),k=f.environmentID,A=f.api,B=A===void 0?E:A,W=f.headers,O=f.onChange,q=f.cacheFlags,ee=f.datadogRum,oe=f.onError,te=f.defaultFlags,ne=f.fetch,ue=f.preventFetch,he=f.enableLogs,ye=f.enableDynatrace,Ze=f.enableAnalytics,et=f.realtime,qe=f.eventSourceUrl,ie=qe===void 0?"https://realtime.flagsmith.com/":qe,K=f.AsyncStorage,wn=f.identity,tt=f.traits,di=f.state,nt=f.cacheOptions,Sn=f.angularHttpClient,fi=f._trigger,pi=f._triggerLoadingState,S.environment=k?{apiKey:k}:S.environment,!S.environment||!S.environment.apiKey)throw new Error("Please provide `evaluationContext.environment` with non-empty `apiKey`");if(S.identity=wn||tt?{identifier:wn,traits:tt?Object.fromEntries(Object.entries(tt).map(function(de){return[de[0],{value:de[1]}]})):{}}:S.identity,this.evaluationContext=S,this.api=B,this.headers=W,this.getFlagInterval=null,this.analyticsInterval=null,this.onChange=O,xn="Wrong Flagsmith Configuration: preventFetch is true and no defaulFlags provided",this._trigger=fi||this._trigger,this._triggerLoadingState=pi||this._triggerLoadingState,this.onError=function(de){re.setLoadingState(i(i({},re.loadingState),{isFetching:!1,isLoading:!1,error:de})),oe==null||oe(de)},this.enableLogs=he||!1,this.cacheOptions=nt?{skipAPI:!!nt.skipAPI,ttl:nt.ttl||0,loadStale:!!nt.loadStale}:this.cacheOptions,!this.cacheOptions.ttl&&this.cacheOptions.skipAPI&&console.warn("Flagsmith: you have set a cache ttl of 0 and are skipping API calls, this means the API will not be hit unless you clear local storage."),ne&&(d=ne),this.enableAnalytics=Ze||!1,this.flags=Object.assign({},te)||{},this.datadogRum=ee||null,this.initialised=!0,this.ticks=1e4,this.timer=this.enableLogs?new Date().valueOf():null,this.cacheFlags=C!==void 0&&!!q,K&&(C=K),et&&typeof window<"u"&&this.setupRealtime(ie,S.environment.apiKey),Object.keys(this.flags).length&&(this.loadingState=i(i({},this.loadingState),{isLoading:!1,source:a.DEFAULT_FLAGS})),this.setState(di),this.log("Initialising with properties",f,this),ye&&(typeof dtrum>"u"?console.error("You have attempted to enable dynatrace but dtrum is undefined, please check you have the Dynatrace RUM JavaScript API installed."):this.dtrum=dtrum),Sn&&(d=function(de){return function(we,Se){var Ne=Se.headers,Y=Se.method,Ge=Se.body;return new Promise(function(Ae){switch(Y){case"GET":return de.get(we,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})});case"POST":case"PUT":return de.post(we,Ge,{headers:Ne}).subscribe(function(Ee){Ae({ok:!0,text:function(){return Promise.resolve(Ee)}})})}})}}(Sn)),C&&this.canUseStorage&&C.getItem(R).then(function(de){try{re.evaluationEvent=JSON.parse(de)||{}}catch{re.evaluationEvent={}}re.analyticsInterval=setInterval(re.analyticsFlags,re.ticks)}),this.enableAnalytics&&(this.analyticsInterval&&clearInterval(this.analyticsInterval),C&&this.canUseStorage&&C.getItem(R,function(de,we){if(we&&re.evaluationContext.environment){var Se=JSON.parse(we);if(Se[re.evaluationContext.environment.apiKey]){var Ne=re.getState();re.log("Retrieved events from cache",we),re.setState(i(i({},Ne),{evaluationEvent:Se[re.evaluationContext.environment.apiKey]}))}}})),!q)return[3,9];if(!C||!this.canUseStorage)return[3,8];gi=function(de,we){return r(re,void 0,void 0,function(){var Se,Ne,Y,Ge,Ae,Ee,En,vi,Tn,In,Cn,_n,Nn,On,Rn,Dn,Ln,An,Mn,Fn,Pn,Bn,jn,zn;return o(this,function(Oe){switch(Oe.label){case 0:if(!we)return[3,7];Se=null,Ne=null,Oe.label=1;case 1:return Oe.trys.push([1,5,,6]),Y=JSON.parse(we),Ge=!1,Ae=!1,Y&&Y.api===this.api&&((In=(Tn=Y.evaluationContext)===null||Tn===void 0?void 0:Tn.environment)===null||In===void 0?void 0:In.apiKey)===((Cn=this.evaluationContext.environment)===null||Cn===void 0?void 0:Cn.apiKey)&&(Ee=!0,this.evaluationContext.identity&&((Nn=(_n=Y.evaluationContext)===null||_n===void 0?void 0:_n.identity)===null||Nn===void 0?void 0:Nn.identifier)!==this.evaluationContext.identity.identifier&&(this.log("Ignoring cache, identity has changed from "+((Rn=(On=Y.evaluationContext)===null||On===void 0?void 0:On.identity)===null||Rn===void 0?void 0:Rn.identifier)+" to "+this.evaluationContext.identity.identifier),Ee=!1),this.cacheOptions.ttl&&(!Y.ts||new Date().valueOf()-Y.ts>this.cacheOptions.ttl)&&(Y.ts&&!this.cacheOptions.loadStale?(this.log("Ignoring cache, timestamp is too old ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ee=!1):Y.ts&&this.cacheOptions.loadStale&&(this.log("Loading stale cache, timestamp ts:"+Y.ts+" ttl: "+this.cacheOptions.ttl+" time elapsed since cache: "+(new Date().valueOf()-Y.ts)+"ms"),Ae=!0,Ee=!0)),Ee&&(Ge=!0,Ne=l((Dn=this.evaluationContext.identity)===null||Dn===void 0?void 0:Dn.traits,(An=(Ln=Y.evaluationContext)===null||Ln===void 0?void 0:Ln.identity)===null||An===void 0?void 0:An.traits),Se=l(this.flags,Y.flags),this.setState(i(i({},Y),{evaluationContext:y(i(i({},Y.evaluationContext),{identity:!((Mn=Y.evaluationContext)===null||Mn===void 0)&&Mn.identity?i(i({},(Fn=Y.evaluationContext)===null||Fn===void 0?void 0:Fn.identity),{traits:i(i({},((Bn=(Pn=Y.evaluationContext)===null||Pn===void 0?void 0:Pn.identity)===null||Bn===void 0?void 0:Bn.traits)||{}),tt||{})}):void 0}))})),this.log("Retrieved flags from cache",Y))),Ge?(En=!ue&&(!this.cacheOptions.skipAPI||Ae),this._onChange(null,{isFromServer:!1,flagsChanged:Se,traitsChanged:Ne},this._loadedState(null,a.CACHE,En)),this.oldFlags=this.flags,this.cacheOptions.skipAPI&&Ge&&!Ae&&this.log("Skipping API, using cache"),En&&this.getFlags(),[3,4]):[3,2];case 2:return ue?[3,4]:[4,this.getFlags()];case 3:Oe.sent(),Oe.label=4;case 4:return[3,6];case 5:return vi=Oe.sent(),this.log("Exception fetching cached logs",vi),[3,6];case 6:return[3,10];case 7:return ue?[3,9]:[4,this.getFlags()];case 8:return Oe.sent(),[3,10];case 9:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(jn=this.evaluationContext.identity)===null||jn===void 0?void 0:jn.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else{if(!this.flags)throw new Error(xn);this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(zn=this.evaluationContext.identity)===null||zn===void 0?void 0:zn.traits)},this._loadedState(null,a.DEFAULT_FLAGS))}Oe.label=10;case 10:return[2]}})})},pe.label=2;case 2:return pe.trys.push([2,7,,8]),C.getItemSync?(kn=C.getItemSync(F),[3,5]):[3,3];case 3:return[4,C.getItem(F)];case 4:kn=pe.sent(),pe.label=5;case 5:return[4,gi(null,kn)];case 6:case 7:return pe.sent(),[3,8];case 8:return[3,12];case 9:return ue?[3,11]:[4,this.getFlags()];case 10:return pe.sent(),[3,12];case 11:if(te)this._onChange(null,{isFromServer:!1,flagsChanged:l({},te),traitsChanged:l({},(h=S.identity)===null||h===void 0?void 0:h.traits)},this._loadedState(null,a.DEFAULT_FLAGS));else if(this.flags&&(st=null,Object.keys(this.flags).length===0&&(st=xn),this._onChange(null,{isFromServer:!1,flagsChanged:l({},this.flags),traitsChanged:l({},(m=S.identity)===null||m===void 0?void 0:m.traits)},this._loadedState(st,a.DEFAULT_FLAGS)),st))throw new Error(st);pe.label=12;case 12:return[3,14];case 13:throw Ve=pe.sent(),this.log("Error during initialisation ",Ve),mi=Ve instanceof Error?Ve:new Error("".concat(Ve)),(g=this.onError)===null||g===void 0||g.call(this,mi),Ve;case 14:return[2]}})})},b.prototype._loadedState=function(f,h,m){return f===void 0&&(f=null),m===void 0&&(m=!1),{error:f,isFetching:m,isLoading:!1,source:h}},b.prototype.getAllFlags=function(){return this.flags},b.prototype.identify=function(f,h,m){return this.evaluationContext.identity={identifier:f,transient:m,traits:this.evaluationContext.identity&&this.evaluationContext.identity.identifier==f?this.evaluationContext.identity.traits:{}},this.evaluationContext.identity.identifier=f,this.log("Identify: "+this.evaluationContext.identity.identifier),h&&(this.evaluationContext.identity.traits=Object.fromEntries(Object.entries(h).map(function(g){var S=g[0],k=g[1];return[S,v(k)?k:{value:k}]}))),this.initialised?this.getFlags():Promise.resolve()},b.prototype.getState=function(){return{api:this.api,flags:this.flags,ts:this.ts,evaluationContext:this.evaluationContext,evaluationEvent:this.evaluationEvent}},b.prototype.setState=function(f){f&&(this.initialised=!0,this.api=f.api||this.api||E,this.flags=f.flags||this.flags,this.evaluationContext=f.evaluationContext||this.evaluationContext,this.evaluationEvent=f.evaluationEvent||this.evaluationEvent,this.log("setState called",this))},b.prototype.logout=function(){return this.evaluationContext.identity=null,this.initialised?this.getFlags():Promise.resolve()},b.prototype.startListening=function(f){f===void 0&&(f=1e3),this.getFlagInterval&&clearInterval(this.getFlagInterval),this.getFlagInterval=setInterval(this.getFlags,f)},b.prototype.stopListening=function(){this.getFlagInterval&&(clearInterval(this.getFlagInterval),this.getFlagInterval=null)},b.prototype.log=function(){for(var f=[],h=0;h<arguments.length;h++)f[h]=arguments[h];this.enableLogs&&console.log.apply(this,u(["FLAGSMITH:",new Date().valueOf()-(this.timer||0),"ms"],f,!0))},b.prototype.updateStorage=function(){if(this.cacheFlags){this.ts=new Date().valueOf();var f=JSON.stringify(this.getState());this.log("Setting storage",f),C.setItem(F,f)}},b.prototype.updateEventStorage=function(){if(this.enableAnalytics){var f=JSON.stringify(this.getState().evaluationEvent);C.setItem(R,f)}},b.prototype.setLoadingState=function(f){var h;c(f,this.loadingState)||(this.loadingState=i({},f),this.log("Loading state changed",f),(h=this._triggerLoadingState)===null||h===void 0||h.call(this))},b.prototype.setupRealtime=function(f,h){var m=this,g=f+"sse/environments/"+h+"/stream";x?this.eventSource||(this.log("Creating event source with url "+g),this.eventSource=new x(g),this.eventSource.addEventListener("environment_updated",function(S){var k;try{k=JSON.parse(S.data).updated_at}catch(A){m.log("Could not parse sse event",A)}k?!m.timestamp||k>m.timestamp?m.isLoading?m.log("updated_at is new, but flags are loading",S.data,m.timestamp):(m.log("updated_at is new, fetching flags",S.data,m.timestamp),m.getFlags()):m.log("updated_at is outdated, skipping get flags",S.data,m.timestamp):m.log("No updated_at received, fetching flags",S)})):this.log("Error, EventSource is undefined")},b}();function T(b){var f=b.fetch,h=b.AsyncStorage,m=b.eventSource;return new I({fetch:f,AsyncStorage:h,eventSource:m})}var P,H=(P=function(b,f){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,m){h.__proto__=m}||function(h,m){for(var g in m)Object.prototype.hasOwnProperty.call(m,g)&&(h[g]=m[g])},P(b,f)},function(b,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");function h(){this.constructor=b}P(b,f),b.prototype=f===null?Object.create(f):(h.prototype=f.prototype,new h)}),j=function(b){var f=typeof Symbol=="function"&&Symbol.iterator,h=f&&b[f],m=0;if(h)return h.call(b);if(b&&typeof b.length=="number")return{next:function(){return b&&m>=b.length&&(b=void 0),{value:b&&b[m++],done:!b}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(b,f){var h=typeof Symbol=="function"&&b[Symbol.iterator];if(!h)return b;var m,g,S=h.call(b),k=[];try{for(;(f===void 0||f-- >0)&&!(m=S.next()).done;)k.push(m.value)}catch(A){g={error:A}}finally{try{m&&!m.done&&(h=S.return)&&h.call(S)}finally{if(g)throw g.error}}return k},_=function(b,f,h){if(h||arguments.length===2)for(var m,g=0,S=f.length;g<S;g++)!m&&g in f||(m||(m=Array.prototype.slice.call(f,0,g)),m[g]=f[g]);return b.concat(m||Array.prototype.slice.call(f))},M=function(b){function f(){return b.call(this,`EventSource not available.
2
2
  Consider loading an EventSource polyfill and making it available globally as EventSource, or passing one in as eventSourceClass to the ReconnectingEventSource constructor.`)||this}return H(f,b),f}(Error),V=function(){function b(f,h){var m=this;if(this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this._configuration=h!=null?Object.assign({},h):void 0,this.withCredentials=!1,this._eventSource=null,this._lastEventId=null,this._timer=null,this._listeners={open:[],error:[],message:[]},this.url=f.toString(),this.readyState=this.CONNECTING,this.max_retry_time=3e3,this.eventSourceClass=globalThis.FlagsmithEventSource,this._configuration!=null&&(this._configuration.lastEventId&&(this._lastEventId=this._configuration.lastEventId,delete this._configuration.lastEventId),this._configuration.max_retry_time&&(this.max_retry_time=this._configuration.max_retry_time,delete this._configuration.max_retry_time),this._configuration.eventSourceClass&&(this.eventSourceClass=this._configuration.eventSourceClass,delete this._configuration.eventSourceClass)),this.eventSourceClass==null||typeof this.eventSourceClass!="function")throw new M;this._onevent_wrapped=function(g){m._onevent(g)},this._start()}return b.prototype.dispatchEvent=function(f){throw new Error("Method not implemented.")},b.prototype._start=function(){var f,h,m=this,g=this.url;this._lastEventId&&(g.indexOf("?")===-1?g+="?":g+="&",g+="lastEventId="+encodeURIComponent(this._lastEventId)),this._eventSource=new this.eventSourceClass(g,this._configuration),this._eventSource.onopen=function(B){m._onopen(B)},this._eventSource.onerror=function(B){m._onerror(B)},this._eventSource.onmessage=function(B){m.onmessage(B)};try{for(var S=j(Object.keys(this._listeners)),k=S.next();!k.done;k=S.next()){var A=k.value;this._eventSource.addEventListener(A,this._onevent_wrapped)}}catch(B){f={error:B}}finally{try{k&&!k.done&&(h=S.return)&&h.call(S)}finally{if(f)throw f.error}}},b.prototype._onopen=function(f){this.readyState===0&&(this.readyState=1,this.onopen(f))},b.prototype._onerror=function(f){var h=this;if(this.readyState===1&&(this.readyState=0,this.onerror(f)),this._eventSource){this._eventSource.close(),this._eventSource=null;var m=Math.round(this.max_retry_time*Math.random());this._timer=setTimeout(function(){return h._start()},m)}},b.prototype._onevent=function(f){var h,m;f&&f.lastEventId&&(this._lastEventId=f.lastEventId);var g=this._listeners[f.type];if(g!=null)try{for(var S=j(_([],z(g),!1)),k=S.next();!k.done;k=S.next())k.value.call(this,f)}catch(A){h={error:A}}finally{try{k&&!k.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}f.type==="message"&&this.onmessage(f)},b.prototype.onopen=function(f){},b.prototype.onerror=function(f){},b.prototype.onmessage=function(f){},b.prototype.close=function(){this._timer&&(clearTimeout(this._timer),this._timer=null),this._eventSource&&(this._eventSource.close(),this._eventSource=null),this.readyState=2},b.prototype.addEventListener=function(f,h,m){this._listeners[f]==null&&(this._listeners[f]=[],this._eventSource!=null&&this._eventSource.addEventListener(f,this._onevent_wrapped));var g=this._listeners[f];g.includes(h)||(this._listeners[f]=_(_([],z(g),!1),[h],!1))},b.prototype.removeEventListener=function(f,h,m){var g=this._listeners[f];this._listeners[f]=g.filter(function(S){return S!==h})},b}();globalThis.FlagsmithEventSource=typeof EventSource<"u"?EventSource:null;var G=function(b,f){return f=f||{},new Promise(function(h,m){var g=new XMLHttpRequest,S=[],k=[],A={},B=function(){return{ok:(g.status/100|0)==2,statusText:g.statusText,status:g.status,url:g.responseURL,text:function(){return Promise.resolve(g.responseText)},json:function(){return Promise.resolve(g.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([g.response]))},clone:B,headers:{keys:function(){return S},entries:function(){return k},get:function(O){return A[O.toLowerCase()]},has:function(O){return O.toLowerCase()in A}}}};for(var W in g.open(f.method||"get",b,!0),g.onload=function(){g.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(O,q,ee){S.push(q=q.toLowerCase()),k.push([q,ee]),A[q]=A[q]?A[q]+","+ee:ee}),h(B())},g.onerror=m,g.withCredentials=f.credentials=="include",f.headers)g.setRequestHeader(W,f.headers[W]);g.send(f.body||null)})},$=T({AsyncStorage:s,fetch:G,eventSource:V});typeof window<"u"&&(window.flagsmith=$),n.createFlagsmithInstance=function(){return T({AsyncStorage:s,fetch:G,eventSource:V})},n.default=$,Object.defineProperty(n,"__esModule",{value:!0})})})(Hn,Hn.exports);var $n={},wi=function(t,e,n,s,i){var r=new Worker($n[e]||($n[e]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return r.onmessage=function(o){var u=o.data,c=u.$e$;if(c){var l=new Error(c[0]);l.code=c[1],l.stack=c[2],i(l,null)}else i(null,u)},r.postMessage(n,s),r},ae=Uint8Array,se=Uint16Array,it=Int32Array,rt=new ae([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ot=new ae([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Rt=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wn=function(t,e){for(var n=new se(31),s=0;s<31;++s)n[s]=e+=1<<t[s-1];for(var i=new it(n[30]),s=1;s<30;++s)for(var r=n[s];r<n[s+1];++r)i[r]=r-n[s]<<5|s;return{b:n,r:i}},qn=Wn(rt,2),Si=qn.b,at=qn.r;Si[28]=258,at[258]=28;for(var xi=Wn(ot,0),Dt=xi.r,ct=new se(32768),J=0;J<32768;++J){var Te=(J&43690)>>1|(J&21845)<<1;Te=(Te&52428)>>2|(Te&13107)<<2,Te=(Te&61680)>>4|(Te&3855)<<4,ct[J]=((Te&65280)>>8|(Te&255)<<8)>>1}for(var Fe=function(t,e,n){for(var s=t.length,i=0,r=new se(e);i<s;++i)t[i]&&++r[t[i]-1];var o=new se(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var u;if(n){u=new se(1<<e);var c=15-e;for(i=0;i<s;++i)if(t[i])for(var l=i<<4|t[i],a=e-t[i],d=o[t[i]-1]++<<a,p=d|(1<<a)-1;d<=p;++d)u[ct[d]>>c]=l}else for(u=new se(s),i=0;i<s;++i)t[i]&&(u[i]=ct[o[t[i]-1]++]>>15-t[i]);return u},Ie=new ae(288),J=0;J<144;++J)Ie[J]=8;for(var J=144;J<256;++J)Ie[J]=9;for(var J=256;J<280;++J)Ie[J]=7;for(var J=280;J<288;++J)Ie[J]=8;for(var Je=new ae(32),J=0;J<32;++J)Je[J]=5;var Vn=Fe(Ie,9,0),Gn=Fe(Je,5,0),Lt=function(t){return(t+7)/8|0},Kn=function(t,e,n){return(e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new ae(t.subarray(e,n))},ki=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Jn=function(t,e,n){var s=new Error(e||ki[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,Jn),!n)throw s;return s},ge=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8},Pe=function(t,e,n){n<<=e&7;var s=e/8|0;t[s]|=n,t[s+1]|=n>>8,t[s+2]|=n>>16},lt=function(t,e){for(var n=[],s=0;s<t.length;++s)t[s]&&n.push({s,f:t[s]});var i=n.length,r=n.slice();if(!i)return{t:Pt,l:0};if(i==1){var o=new ae(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(N,D){return N.f-D.f}),n.push({s:-1,f:25001});var u=n[0],c=n[1],l=0,a=1,d=2;for(n[0]={s:-1,f:u.f+c.f,l:u,r:c};a!=i-1;)u=n[n[l].f<n[d].f?l++:d++],c=n[l!=a&&n[l].f<n[d].f?l++:d++],n[a++]={s:-1,f:u.f+c.f,l:u,r:c};for(var p=r[0].s,s=1;s<i;++s)r[s].s>p&&(p=r[s].s);var v=new se(p+1),w=ut(n[a-1],v,0);if(w>e){var s=0,y=0,x=w-e,C=1<<x;for(r.sort(function(D,L){return v[L.s]-v[D.s]||D.f-L.f});s<i;++s){var F=r[s].s;if(v[F]>e)y+=C-(1<<w-v[F]),v[F]=e;else break}for(y>>=x;y>0;){var R=r[s].s;v[R]<e?y-=1<<e-v[R]++-1:++s}for(;s>=0&&y;--s){var E=r[s].s;v[E]==e&&(--v[E],++y)}w=e}return{t:new ae(v),l:w}},ut=function(t,e,n){return t.s==-1?Math.max(ut(t.l,e,n+1),ut(t.r,e,n+1)):e[t.s]=n},At=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new se(++e),s=0,i=t[0],r=1,o=function(c){n[s++]=c},u=1;u<=e;++u)if(t[u]==i&&u!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(i),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(i);r=1,i=t[u]}return{c:n.subarray(0,s),n:e}},Be=function(t,e){for(var n=0,s=0;s<e.length;++s)n+=t[s]*e[s];return n},Mt=function(t,e,n){var s=n.length,i=Lt(e+2);t[i]=s&255,t[i+1]=s>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<s;++r)t[i+r+4]=n[r];return(i+4+s)*8},Ft=function(t,e,n,s,i,r,o,u,c,l,a){ge(e,a++,n),++i[256];for(var d=lt(i,15),p=d.t,v=d.l,w=lt(r,15),y=w.t,x=w.l,C=At(p),F=C.c,R=C.n,E=At(y),N=E.c,D=E.n,L=new se(19),I=0;I<F.length;++I)++L[F[I]&31];for(var I=0;I<N.length;++I)++L[N[I]&31];for(var T=lt(L,7),P=T.t,H=T.l,j=19;j>4&&!P[Rt[j-1]];--j);var z=l+5<<3,_=Be(i,Ie)+Be(r,Je)+o,M=Be(i,p)+Be(r,y)+o+14+3*j+Be(L,P)+2*L[16]+3*L[17]+7*L[18];if(c>=0&&z<=_&&z<=M)return Mt(e,a,t.subarray(c,c+l));var V,G,$,b;if(ge(e,a,1+(M<_)),a+=2,M<_){V=Fe(p,v,0),G=p,$=Fe(y,x,0),b=y;var f=Fe(P,H,0);ge(e,a,R-257),ge(e,a+5,D-1),ge(e,a+10,j-4),a+=14;for(var I=0;I<j;++I)ge(e,a+3*I,P[Rt[I]]);a+=3*j;for(var h=[F,N],m=0;m<2;++m)for(var g=h[m],I=0;I<g.length;++I){var S=g[I]&31;ge(e,a,f[S]),a+=P[S],S>15&&(ge(e,a,g[I]>>5&127),a+=g[I]>>12)}}else V=Vn,G=Ie,$=Gn,b=Je;for(var I=0;I<u;++I){var k=s[I];if(k>255){var S=k>>18&31;Pe(e,a,V[S+257]),a+=G[S+257],S>7&&(ge(e,a,k>>23&31),a+=rt[S]);var A=k&31;Pe(e,a,$[A]),a+=b[A],A>3&&(Pe(e,a,k>>5&8191),a+=ot[A])}else Pe(e,a,V[k]),a+=G[k]}return Pe(e,a,V[256]),a+G[256]},Xn=new it([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Pt=new ae(0),Yn=function(t,e,n,s,i,r){var o=r.z||t.length,u=new ae(s+o+5*(1+Math.ceil(o/7e3))+i),c=u.subarray(s,u.length-i),l=r.l,a=(r.r||0)&7;if(e){a&&(c[0]=r.r>>3);for(var d=Xn[e-1],p=d>>13,v=d&8191,w=(1<<n)-1,y=r.p||new se(32768),x=r.h||new se(w+1),C=Math.ceil(n/3),F=2*C,R=function(ne){return(t[ne]^t[ne+1]<<C^t[ne+2]<<F)&w},E=new it(25e3),N=new se(288),D=new se(32),L=0,I=0,T=r.i||0,P=0,H=r.w||0,j=0;T+2<o;++T){var z=R(T),_=T&32767,M=x[z];if(y[_]=M,x[z]=_,H<=T){var V=o-T;if((L>7e3||P>24576)&&(V>423||!l)){a=Ft(t,c,0,E,N,D,I,P,j,T-j,a),P=L=I=0,j=T;for(var G=0;G<286;++G)N[G]=0;for(var G=0;G<30;++G)D[G]=0}var $=2,b=0,f=v,h=_-M&32767;if(V>2&&z==R(T-h))for(var m=Math.min(p,V)-1,g=Math.min(32767,T),S=Math.min(258,V);h<=g&&--f&&_!=M;){if(t[T+$]==t[T+$-h]){for(var k=0;k<S&&t[T+k]==t[T+k-h];++k);if(k>$){if($=k,b=h,k>m)break;for(var A=Math.min(h,k-2),B=0,G=0;G<A;++G){var W=T-h+G&32767,O=y[W],q=W-O&32767;q>B&&(B=q,M=W)}}}_=M,M=y[_],h+=_-M&32767}if(b){E[P++]=268435456|at[$]<<18|Dt[b];var ee=at[$]&31,oe=Dt[b]&31;I+=rt[ee]+ot[oe],++N[257+ee],++D[oe],H=T+$,++L}else E[P++]=t[T],++N[t[T]]}}for(T=Math.max(T,H);T<o;++T)E[P++]=t[T],++N[t[T]];a=Ft(t,c,l,E,N,D,I,P,j,T-j,a),l||(r.r=a&7|c[a/8|0]<<3,a-=7,r.h=x,r.p=y,r.i=T,r.w=H)}else{for(var T=r.w||0;T<o+l;T+=65535){var te=T+65535;te>=o&&(c[a/8|0]=l,te=o),a=Mt(c,a+1,t.subarray(T,te))}r.i=o}return Kn(u,0,s+Lt(a)+i)},Qn=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,s=9;--s;)n=(n&1&&-306674912)^n>>>1;t[e]=n}return t}(),Zn=function(){var t=-1;return{p:function(e){for(var n=t,s=0;s<e.length;++s)n=Qn[n&255^e[s]]^n>>>8;t=n},d:function(){return~t}}},Bt=function(t,e,n,s,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new ae(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return Yn(t,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,n,s,i)},Ei=function(t,e){var n={};for(var s in t)n[s]=t[s];for(var s in e)n[s]=e[s];return n},es=function(t,e,n){for(var s=t(),i=t.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<s.length;++o){var u=s[o],c=r[o];if(typeof u=="function"){e+=";"+c+"=";var l=u.toString();if(u.prototype)if(l.indexOf("[native code]")!=-1){var a=l.indexOf(" ",8)+1;e+=l.slice(a,l.indexOf("(",a))}else{e+=l;for(var d in u.prototype)e+=";"+c+".prototype."+d+"="+u.prototype[d].toString()}else e+=l}else n[c]=u}return e},ht=[],Ti=function(t){var e=[];for(var n in t)t[n].buffer&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e},Ii=function(t,e,n,s){if(!ht[n]){for(var i="",r={},o=t.length-1,u=0;u<o;++u)i=es(t[u],i,r);ht[n]={c:es(t[o],i,r),e:r}}var c=Ei({},ht[n].e);return wi(ht[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,c,Ti(c),s)},Ci=function(){return[ae,se,it,rt,ot,Rt,at,Dt,Vn,Ie,Gn,Je,ct,Xn,Pt,Fe,ge,Pe,lt,ut,At,Be,Mt,Ft,Lt,Kn,Yn,Bt,Oi,ts]},_i=function(){return[ns,ss,dt,Zn,Qn]},ts=function(t){return postMessage(t,[t.buffer])},Ni=function(t,e,n,s,i,r){var o=Ii(n,s,i,function(u,c){o.terminate(),r(u,c)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},dt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},ns=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&dt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var s=0;s<=n.length;++s)t[s+10]=n.charCodeAt(s)}},ss=function(t){return 10+(t.filename?t.filename.length+1:0)};function Oi(t,e){return Bt(t,e||{},0,0)}function Ri(t,e,n){return n||(n=e,e={}),typeof n!="function"&&Jn(7),Ni(t,e,[Ci,_i,function(){return[is]}],function(s){return ts(is(s.data[0],s.data[1]))},2,n)}function is(t,e){e||(e={});var n=Zn(),s=t.length;n.p(t);var i=Bt(t,e,ss(e),8),r=i.length;return ns(i,e),dt(i,r-8,n.d()),dt(i,r-4,s),i}var Di=typeof TextDecoder<"u"&&new TextDecoder,Li=0;try{Di.decode(Pt,{stream:!0}),Li=1}catch{}class rs{constructor(){this.idx=1,this.backDict={}}getKey(e){let n=!1;return this.backDict[e]||(n=!0,this.backDict[e]=this.idx++),[this.backDict[e],n]}}class Ai{constructor(e,n){this.app=e,this.isDictDisabled=n,this.dict=new rs}sendSetAttribute(e,n,s){if(this.isDictDisabled){const i=[12,e,n,s];return this.app.send(i)}else{const i=[51,e,this.applyDict(n),this.applyDict(s)];return this.app.send(i)}}applyDict(e){const[n,s]=this.dict.getKey(e);return s&&this.app.send([50,n,e]),n}clear(){this.dict=new rs}}class Mi{constructor(e,n){this.app=e,this.startParams=n,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=s=>{if(s.value.length){const i=Fi(s);if(i.type)return i}},this.durationInt=null}setConditions(e){this.conditions=e}async fetchConditions(e,n){try{const s=await fetch(`${this.app.options.ingestPoint}/v1/web/conditions/${e}`,{method:"GET",headers:{Authorization:`Bearer ${n}`}}),{conditions:i}=await s.json(),r=[];i.forEach(o=>{o.filters.forEach(c=>{let l;c.type==="fetch"?(l={type:"network_request",subConditions:[],name:o.name},c.filters.forEach(a=>{const d=this.createConditionFromFilter(a);d&&l.subConditions.push(d)})):l=this.createConditionFromFilter(c),l&&(l.type==="session_duration"&&this.processDuration(l.value[0],o.name),r.push({...l,name:o.name}))})}),this.conditions=r}catch{this.app.debug.error("Critical: cannot fetch start conditions")}}trigger(e){if(!this.hasStarted)try{this.hasStarted=!0,this.app.start(this.startParams,void 0,e)}catch(n){this.app.debug.error(n)}}processMessage(e){if(!this.hasStarted)switch(e[0]){case 78:this.jsExceptionEvent(e);break;case 27:this.customEvent(e);break;case 68:this.clickEvent(e);break;case 122:this.pageLocationEvent(e);break;case 83:this.networkRequest(e);break}}processFlags(e){const n=this.conditions.filter(s=>s.type==="feature_flag");n.length&&n.forEach(s=>{const i=je[s.operator];i&&e.find(r=>i(r.key,s.value))&&this.trigger(s.name)})}processDuration(e,n){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(n)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const n=this.conditions.filter(s=>s.type==="network_request");n.length&&n.forEach(s=>{const i=s.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let u;switch(o.key){case"url":u=e[3];break;case"status":u=e[6];break;case"method":u=e[2];break;case"duration":u=e[8];break}const c=je[o.operator];if(c&&c(u,o.value))return!0})&&this.trigger(s.name):i.length===0&&s.subConditions.length&&this.trigger(s.name)})}customEvent(e){const n=this.conditions.filter(s=>s.type==="custom_event");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[1],s.value)||i(e[2],s.value))&&this.trigger(s.name)})}clickEvent(e){const n=this.conditions.filter(s=>s.type==="click");n.length&&n.forEach(s=>{const i=je[s.operator];i&&(i(e[3],s.value)||i(e[4],s.value))&&this.trigger(s.name)})}pageLocationEvent(e){const n=this.conditions.filter(s=>s.type==="visited_url");n&&n.forEach(s=>{const i=je[s.operator];i&&i(e[1],s.value)&&this.trigger(s.name)})}jsExceptionEvent(e){const n=[e[1],e[2],e[3]],s=this.conditions.filter(i=>i.type==="exception");s&&s.forEach(i=>{const r=je[i.operator];r&&n.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const je={is:(t,e)=>e.some(n=>t.includes(n)),isAny:()=>!0,isNot:(t,e)=>!e.some(n=>t.includes(n)),contains:(t,e)=>e.some(n=>t.includes(n)),notContains:(t,e)=>!e.some(n=>t.includes(n)),startsWith:(t,e)=>e.some(n=>t.startsWith(n)),endsWith:(t,e)=>e.some(n=>t.endsWith(n)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},Fi=t=>{const e={on:"is",notOn:"isNot",">":"greaterThan","<":"lessThan","=":"is","<=":"lessOrEqual",">=":"greaterOrEqual"},n=i=>{if(Object.keys(e).includes(i))return e[i]};let s={type:"",operator:"",value:t.value,key:""};switch(t.type){case"click":s={type:"click",operator:n(t.operator),value:t.value,key:""};break;case"location":s={type:"visited_url",operator:t.operator,value:t.value,key:""};break;case"custom":s={type:"custom_event",operator:t.operator,value:t.value,key:""};break;case"metadata":s={type:t.source==="featureFlag"?"feature_flag":t.type,operator:t.operator,value:t.value,key:""};break;case"error":s={type:"exception",operator:t.operator,value:t.value,key:""};break;case"duration":s={type:"session_duration",value:t.value[0],key:""};break;case"fetchUrl":s={type:"network_request",key:"url",operator:t.operator,value:t.value};break;case"fetchStatusCode":s={type:"network_request",key:"status",operator:n(t.operator),value:t.value};break;case"fetchMethod":s={type:"network_request",key:"method",operator:n(t.operator),value:t.value};break;case"fetchDuration":s={type:"network_request",key:"duration",operator:n(t.operator),value:t.value};break}return s};class Pi{constructor(e){this.app=e,this.flags=[],this.storageKey="__openreplay_flags";const n=this.app.sessionStorage.getItem(this.storageKey);if(n){const s=n.split(";").filter(Boolean);this.flags=s.map(i=>JSON.parse(i))}}getFeatureFlag(e){return this.flags.find(n=>n.key===e)}isFlagEnabled(e){return this.flags.findIndex(n=>n.key===e)!==-1}onFlagsLoad(e){this.onFlagsCb=e}async reloadFlags(e){const n=this.app.sessionStorage.getItem(this.storageKey),s={};n&&n.split(";").filter(Boolean).forEach(a=>{const d=JSON.parse(a);s[d.key]={key:d.key,value:d.value}});const i=this.app.session.getInfo(),r=this.app.session.userInfo,o={projectID:i.projectID,userID:i.userID,metadata:i.metadata,referrer:document.referrer,os:r.userOS,device:r.userDevice,country:r.userCountry,state:r.userState,city:r.userCity,browser:r.userBrowser,persistFlags:s},u=e??this.app.session.getSessionToken(),c=await fetch(this.app.options.ingestPoint+"/v1/web/feature-flags",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(o)});if(c.status===200){const l=await c.json();return this.handleFlags(l.flags)}}handleFlags(e){var r;const n=[];e.forEach(o=>{o.is_persist&&n.push(o)});let s="";return this.diffPersist(n).forEach(o=>{s+=`${JSON.stringify(o)};`}),this.app.sessionStorage.setItem(this.storageKey,s),this.flags=e,(r=this.onFlagsCb)==null?void 0:r.call(this,e)}clearPersistFlags(){this.app.sessionStorage.removeItem(this.storageKey)}diffPersist(e){const n=this.app.sessionStorage.getItem(this.storageKey);if(!n)return e;const i=n.split(";").filter(Boolean).map(r=>JSON.parse(r));return e.filter(r=>i.findIndex(o=>o.key===r.key)===-1)}}const os={htmlmasked:"hidden",masked:"obscured"},me=!(typeof window>"u"),Bi=me&&navigator.userAgent.match(/firefox|fxios/i),ji=1e5;let jt=me?Date.now()-performance.now():0;function zt(){jt=Date.now()-performance.now()}function ze(){return jt}const fe=me&&performance.now?()=>Math.round(performance.now()+jt):()=>Date.now(),Ut="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function as(t){return t.trim().replace(/\s+/g," ")}function cs(t){return t.startsWith("https://")||t.startsWith("http://")}const ft="https://docs.openreplay.com",ls={};function Ce(t,e,n="/"){ls[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${ft}${n} for more information.`),ls[t]=!0)}function Ht(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&Ce('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function Re(t,e){const n=`data-openreplay-${e}`;return t.hasAttribute(n)?(os[e]&&Ce(`"${n}" attribute`,`"${os[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function zi(t){try{return!!t.contentDocument}catch{return!1}}function us(t){return t.toString(16).padStart(2,"0")}function Ui(t){const e=new Uint8Array((t||40)/2),n=window.crypto||window.msCrypto;return n?(n.getRandomValues(e),Array.from(e,us).join("")):Array.from({length:t||40},()=>us(Math.floor(Math.random()*16))).join("")}function Hi(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function $t(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function hs(t){const e=$t("MutationObserver");return new window[e](t)}function ds(t,e,n,s){const i=$t("addEventListener");try{t[i](e,n,s)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}function fs(t,e,n,s){const i=$t("removeEventListener");try{t[i](e,n,s)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}class $i{constructor(){this.taskQueue=[],this.isRunning=!1}addTask(e){this.taskQueue.push(e),this.runTasks()}runTasks(){if(this.isRunning||this.taskQueue.length===0)return;this.isRunning=!0;const e=()=>{if(this.taskQueue.length===0){this.isRunning=!1;return}const n=this.taskQueue.shift();Promise.resolve(n()).then(()=>{requestAnimationFrame(()=>e())})};e()}}const Wi=new $i;function qi(t){Wi.addTask(t)}function ps(t,e){const n={...t};for(const s in e)if(e.hasOwnProperty(s)){const i=e[s],r=t[s];typeof i=="object"&&!Array.isArray(i)&&i!==null?n[s]=ps(r||{},i):n[s]=i}return n}function De(t){return[0,t]}function Vi(t,e){return[5,t,e]}function Gi(t,e){return[6,t,e]}function Ki(){return[7]}function Ji(t,e,n,s,i){return[8,t,e,n,s,i]}function Xi(t,e,n){return[9,t,e,n]}function Yi(t,e,n){return[10,t,e,n]}function Qi(t){return[11,t]}function gs(t,e){return[13,t,e]}function Zi(t,e){return[14,t,e]}function er(t,e,n){return[16,t,e,n]}function tr(t,e,n){return[18,t,e,n]}function nr(t,e){return[19,t,e]}function sr(t,e){return[20,t,e]}function ir(t,e){return[22,t,e]}function rr(t,e,n,s,i,r,o,u,c){return[23,t,e,n,s,i,r,o,u,c]}function or(t,e,n){return[24,t,e,n]}function ar(t,e){return[27,t,e]}function cr(t){return[28,t]}function lr(t){return[29,t]}function ms(t,e){return[30,t,e]}function ur(t,e,n,s){return[49,t,e,n,s]}function hr(t,e){return[54,t,e]}function dr(t){return[55,t]}function vs(t,e,n,s){return[57,t,e,n,s]}function bs(t){return[58,t]}function Wt(t,e,n,s){return[60,t,e,n,s]}function fr(t,e,n){return[61,t,e,n]}function pr(t,e){return[63,t,e]}function gr(t,e){return[64,t,e]}function mr(t,e,n,s,i,r){return[68,t,e,n,s,i,r]}function qt(t,e){return[70,t,e]}function ys(t,e,n){return[71,t,e,n]}function Vt(t,e,n,s){return[73,t,e,n,s]}function ws(t,e){return[75,t,e]}function Ss(t,e){return[76,t,e]}function vr(t,e){return[77,t,e]}function Gt(t,e,n,s){return[78,t,e,n,s]}function pt(t,e,n,s,i,r,o,u,c){return[83,t,e,n,s,i,r,o,u,c]}function br(t,e,n,s,i,r){return[84,t,e,n,s,i,r]}function yr(t,e,n,s,i,r){return[112,t,e,n,s,i,r]}function xs(t,e,n){return[113,t,e,n]}function wr(t){return[114,t]}function Sr(t){return[115,t]}function ks(t,e,n,s,i,r,o,u,c,l){return[116,t,e,n,s,i,r,o,u,c,l]}function gt(t){return[117,t]}function Le(t){return[118,t]}function xr(t,e){return[119,t,e]}function kr(t){return[120,t]}function Er(t,e,n,s){return[122,t,e,n,s]}const Kt=me&&"performance"in window&&"memory"in performance?performance:{memory:{}},Jt=me?(navigator.deviceMemory||0)*1024:0,Xt=Kt.memory.jsHeapSizeLimit||0;function Tr(t,e){if(!Object.assign({capturePerformance:!0},e).capturePerformance)return;let s,i;const r=()=>{s===void 0||s===-1||(s++,requestAnimationFrame(r))};t.ticker.attach(()=>{i===void 0||i===-1||i++},0,!1);const o=()=>{s===void 0||i===void 0||(t.send(ur(s,i,Kt.memory.totalJSHeapSize||0,Kt.memory.usedJSHeapSize||0)),i=s=document.hidden?-1:0)};t.attachStartCallback(()=>{i=s=-1,o(),r()}),t.attachStopCallback(()=>{i=s=void 0}),t.ticker.attach(o,40,!1),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",o,!1,!1)}const Es="__or__watched_tags__";class Ir{constructor(e,n,s){this.sessionStorage=e,this.errLog=n,this.onTag=s,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Es)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&o.target){const u=o.target.__or_watcher_tagname;u&&this.onTagRendered(u),this.observer.unobserve(o.target)}})})}async fetchTags(e,n){return fetch(`${e}/v1/web/tags`,{method:"GET",headers:{Authorization:`Bearer ${n}`}}).then(s=>s.json()).then(({tags:s})=>{if(s&&s.length){this.setTags(s);const i=JSON.stringify(s);this.sessionStorage.setItem(Es,i||"")}}).catch(s=>this.errLog(s))}setTags(e){this.tags=e,this.intervals={},e.forEach(n=>{this.intervals[n.id]=setInterval(()=>{const s=document.querySelectorAll(n.selector);if(s.length>0){const i=s[0];i.__or_watcher_tagname=n.id,this.observer.observe(i)}},500)})}onTagRendered(e){this.intervals[e]&&clearInterval(this.intervals[e]),this.onTag(e)}clear(){this.tags.forEach(e=>{clearInterval(this.intervals[e.id])}),this.tags=[],this.intervals={},this.observer.disconnect()}}const Cr={position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"rgba(0, 0, 0, 0.40)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:999999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'},_r={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},mt={display:"flex","flex-direction":"column",gap:"unset","align-items":"center",padding:"unset",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',"border-radius":"2px",border:"1px solid #D9D9D9",background:"rgba(255, 255, 255, 0.75)",width:"22rem"},Nr={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},Or={borderTop:"1px solid rgba(0, 0, 0, 0.06)",borderBottom:"1px solid rgba(0, 0, 0, 0.06)",padding:"1.25rem 0rem",color:"rgba(0, 0, 0, 0.85)",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"400",lineHeight:"auto",whiteSpace:"pre-wrap"},Rr={display:"flex",padding:"0.4rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.625rem",borderRadius:"0.25rem",border:"1px solid #394EFF",background:"#394EFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",color:"#FFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"1rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.5rem",cursor:"pointer"},Ts={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},Ue={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Dr={padding:"0.5rem",gap:"0.5rem",fontFamily:"Verdana, sans-serif",fontSize:"16px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto",color:"white",display:"flex",alignItems:"center",width:"100%",borderRadius:"2px",background:"rgba(0, 0, 0, 0.75)",boxSizing:"border-box"},He={boxSizing:"border-box",display:"block",width:"100%",borderBottom:"1px solid #D9D9D9",background:"#FFF",padding:"0.65rem",alignSelf:"stretch",color:"#000",fontFamily:"Verdana, sans-serif",fontStyle:"normal",fontWeight:"400"},Lr={...He,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Is={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Cs={display:"flex",padding:"0.4rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.625rem",borderRadius:"0.25rem",border:"1px solid #394EFF",background:"#394EFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",color:"#FFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"1rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.5rem",width:"100%",boxSizing:"border-box",cursor:"pointer"},_s={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Ar={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Ns={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Mr={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #D2DFFF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",background:"#D2DFFF",fontSize:"13px",height:"24px",width:"24px"},Os={borderRadius:"0.375rem",border:"1px solid rgba(0, 0, 0, 0.06)",background:"#F5F7FF",boxShadow:"0px 2px 0px 0px rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",padding:"0.625rem 0.9375rem",gap:"0.5rem",alignSelf:"stretch"},Rs={fontWeight:"bold"},Fr={fontSize:"13px",lineHeight:"auto"},Ds={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Pr={...Ds,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Br={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},jr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},Ls={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class zr{constructor(e){this.app=e,this.mediaRecorder=null,this.recordedChunks=[],this.stream=null,this.recStartTs=null}async startRecording(e,n,s,i){this.recStartTs=this.app.timestamp();const r=n;try{this.stream=await navigator.mediaDevices.getUserMedia({video:i?{...r,frameRate:{ideal:e}}:!1,audio:s}),this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:"video/webm;codecs=vp9"}),this.recordedChunks=[],this.mediaRecorder.ondataavailable=o=>{o.data.size>0&&this.recordedChunks.push(o.data)},this.mediaRecorder.start()}catch(o){console.error(o)}}async stopRecording(){return new Promise(e=>{this.mediaRecorder&&(this.mediaRecorder.onstop=()=>{const n=new Blob(this.recordedChunks,{type:"video/webm"});e(n)},this.mediaRecorder.stop())})}async sendToAPI(){const e=await this.stopRecording();return fetch(`${this.app.options.ingestPoint}/v1/web/uxt/upload-url`,{headers:{Authorization:`Bearer ${this.app.session.getSessionToken()}`}}).then(n=>{if(n.ok)return n.json();throw new Error("Failed to get upload url")}).then(({url:n})=>fetch(n,{method:"PUT",headers:{"Content-Type":"video/webm"},body:e})).catch(console.error).finally(()=>{this.discard()})}async saveToFile(e="recorded-video.webm"){const n=await this.stopRecording(),s=URL.createObjectURL(n),i=document.createElement("a");i.style.display="none",i.href=s,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(s),document.body.removeChild(i)}discard(){var e,n;(e=this.mediaRecorder)==null||e.stop(),(n=this.stream)==null||n.getTracks().forEach(s=>s.stop())}}function Ur(t,e){e.onmousedown=function(n){const s=t.getBoundingClientRect(),i=n.clientX-s.left,r=n.clientY-s.top;t.style.position="fixed",t.style.zIndex=99999999999999,o(n.pageX,n.pageY);function o(l,a){let d=l-i,p=a-r;d<=5&&(d=5),p<=5&&(p=5),d>=window.innerWidth-s.width&&(d=window.innerWidth-s.width),p>=window.innerHeight-s.height&&(p=window.innerHeight-s.height),t.style.left=`${d}px`,t.style.top=`${p}px`}function u(l){o(l.pageX,l.pageY)}document.addEventListener("mousemove",u);const c=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",c)};document.addEventListener("mouseup",c)},e.ondragstart=function(){return!1}}function Hr(){const t=document.createElement("div");t.className="grid";for(let e=0;e<16;e++){const n=document.createElement("div");Object.assign(n.style,{width:"2px",height:"2px",borderRadius:"10px",background:"white"}),n.className="cell",t.appendChild(n)}return Object.assign(t.style,{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(4, 1fr)",gap:"2px",cursor:"grab"}),t}function $r(){const t=document.createElement("div");Object.assign(t.style,{width:"0",height:"0",borderLeft:"7px solid transparent",borderRight:"7px solid transparent",borderBottom:"7px solid white"});const e=document.createElement("div");return e.appendChild(t),Object.assign(e.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"16px",height:"16px",cursor:"pointer",marginLeft:"auto",transform:"rotate(180deg)"}),e}function Wr(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
3
3
  0% { transform: rotate(0deg); }
4
4
  100% { transform: rotate(360deg); }
@@ -961,7 +961,7 @@ margin: 5px 0;
961
961
 
962
962
  <div class="tile-top">
963
963
  ${p?`<img src="${p}" alt="${d}" class="wine-image" />`:""}
964
- <div class="wine-price">${c(v)} ${X.getCurrency("label")}</div>
964
+ ${v?`<div class="wine-price">${c(v)} ${X.getCurrency("label")}</div>`:""}
965
965
  <h3 class="wine-title">${d}</h3>
966
966
  </div>
967
967
 
package/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Chatbot</title>
7
- <script>window.wineaterData = {CLIENT_TOKEN: 'OjvAprylAugk5pKTHRIzZxcPPb6HMPr9qHhrazG0sF3uHjkrvBzufPZ65igfRJJa', TYPE: 'widget', WIDGET_TYPE: 'bar', WIDGET_WRAPPER: 'wineater-widget-conteiner'};</script>
7
+ <script>window.wineaterData = {CLIENT_TOKEN: 'Zp2mEPch8TaUtdXJ1oUYmtiW18EAeI8dZJRi7FMBCC3zzu6v41fxjUDRSIRK1Z1R', TYPE: 'widget', WIDGET_TYPE: 'store', WIDGET_WRAPPER: 'wineater-widget-conteiner'};</script>
8
8
  <!-- <script type="module" src="./dist/wineater-chatbot.umd.js"></script> -->
9
9
  <script type="module" src="./src/index.js"></script>
10
10
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "3.9.0",
3
+ "version": "3.9.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -80,11 +80,13 @@ function setUniqueUserCookie() {
80
80
  const payload = {
81
81
  event_type,
82
82
  store_id,
83
- user_id,
84
83
  session_id,
85
84
  event_time,
86
85
  data,
87
- meta,
86
+ meta: {
87
+ ...meta,
88
+ user_id
89
+ },
88
90
  device_info,
89
91
  region: navigator.language.split('-')[1] || null,
90
92
  language: navigator.language.split('-')[0] || 'en'
package/src/js/widget.js CHANGED
@@ -99,7 +99,7 @@ export class WineWidget {
99
99
 
100
100
  <div class="tile-top">
101
101
  ${image ? `<img src="${image}" alt="${title}" class="wine-image" />` : ''}
102
- <div class="wine-price">${formatPrice(price)} ${translator.getCurrency('label')}</div>
102
+ ${!!price ? `<div class="wine-price">${formatPrice(price)} ${translator.getCurrency('label')}</div>` : ''}
103
103
  <h3 class="wine-title">${title}</h3>
104
104
  </div>
105
105