wineater-bot 1.8.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(te,ve){typeof exports=="object"&&typeof module<"u"?ve(exports):typeof define=="function"&&define.amd?define(["exports"],ve):(te=typeof globalThis<"u"?globalThis:te||self,ve(te.WineaterChatbot={}))})(this,function(te){"use strict";var wn,vn,kn,Tn;const ve=`
1
+ (function(te,ve){typeof exports=="object"&&typeof module<"u"?ve(exports):typeof define=="function"&&define.amd?define(["exports"],ve):(te=typeof globalThis<"u"?globalThis:te||self,ve(te.WineaterChatbot={}))})(this,function(te){"use strict";var vn,kn,Tn,In,xn,En;const ve=`
2
2
  @font-face {
3
3
  font-family: 'Poppins';
4
4
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -32,8 +32,6 @@
32
32
  position: fixed;
33
33
  bottom: 20px;
34
34
  right: 20px;
35
- /* Other styles for the bottom-right button */
36
- /* ... */
37
35
  }
38
36
 
39
37
  .chat-icon-right-center {
@@ -41,35 +39,31 @@
41
39
  top: 50%;
42
40
  right: -85px;
43
41
  transform: translateY(-50%) rotate(90deg);
44
- /* Additional styling for the button */
45
- /* ... */
46
42
  }
47
43
 
48
44
  #chat-icon img {
49
- width: 40px; /* Adjust icon size as needed */
45
+ width: 40px;
50
46
  height: auto;
51
47
  margin-right: 8px;
52
48
  }
53
49
 
54
50
  #chat-icon span {
55
51
  color: black; /* Text color */
56
- font-family: 'Poppins', sans-serif; /* Font family from your style guide */
57
- /* Add more text styles if needed */
52
+ font-family: 'Poppins', sans-serif;
58
53
  }
59
54
 
60
55
  /* Chat window styles */
61
56
  #chat-window {
62
57
  position: fixed;
63
- bottom: 20px; /* Set to the desired distance from the bottom */
64
- right: 20px; /* Set to the desired distance from the right */
65
- width: 350px; /* Width of the chat window */
58
+ bottom: 20px;
59
+ right: 20px;
60
+ width: 350px;
66
61
  background-color: white;
67
62
  border-radius: 8px;
68
63
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
69
- display: none; /* Initially hidden */
64
+ display: none;
70
65
  }
71
66
 
72
- /* Header of the chat window */
73
67
  #chat-header {
74
68
  background-color: #fff;
75
69
  color: white;
@@ -79,34 +73,30 @@
79
73
  display: flex;
80
74
  justify-content: space-between;
81
75
  align-items: center;
82
- position: relative; /* Needed for absolute positioning of the close button */
83
76
  }
84
77
 
85
- /* Powered by and logo styles */
86
78
  #powered-by {
87
79
  display: flex;
88
80
  align-items: center;
89
- background-color: #fff; /* White background */
81
+ background-color: #fff;
90
82
  width: 100%;
91
- border-radius: 16px; /* Rounded corners for the container */
83
+ border-radius: 16px;
92
84
  }
93
85
 
94
86
  #powered-by a span {
95
87
  font-family: 'Poppins', sans-serif;
96
- color: #7E27ED; /* Text color - using the primary color from your style guide */
97
- margin-right: 8px; /* Space between the text and the logo */
88
+ color: #7E27ED;
89
+ margin-right: 8px;
98
90
  }
99
91
 
100
92
  #chatbot-logo {
101
- height: 20px; /* Adjust the logo size as needed */
102
- width: auto; /* Keep the logo's aspect ratio */
93
+ height: 20px;
94
+ width: auto;
103
95
  }
104
96
 
105
-
106
- /* Style for the close button */
107
97
  #close-btn {
108
- font-size: 24px; /* Size of the close button */
109
- color: #7E27ED; /* Text color - using the primary color from your style guide */
98
+ font-size: 24px;
99
+ color: #7E27ED;
110
100
  cursor: pointer;
111
101
  padding: 0 10px;
112
102
  line-height: 24px;
@@ -118,67 +108,80 @@
118
108
  height: 400px;
119
109
  overflow-y: auto;
120
110
  padding: 15px;
121
- background: #f7f7f7; /* Light grey background for the message area */
111
+ background: #f7f7f7;
122
112
  }
123
113
 
124
114
  /* Input area */
125
115
  #input-container {
126
- border-top: 2px solid #ececec; /* Light border for input area */
127
- background-color: white; /* White background for input area */
116
+ border-top: 2px solid #ececec;
117
+ background-color: white;
128
118
  padding: 12px;
129
119
  display: flex;
130
- align-items: center; /* Align button and input vertically */
131
- gap: 10px; /* Adds space between input and button */
120
+ align-items: center;
121
+ gap: 10px;
132
122
  }
133
123
 
134
124
  #input-container input {
135
125
  flex-grow: 1;
136
- border: 2px solid #B928EB; /* Input border color based on style guide */
126
+ border: 2px solid #B928EB;
137
127
  padding: 10px;
138
128
  border-radius: 4px;
139
- font-family: 'Poppins', sans-serif; /* Use Poppins font */
129
+ font-family: 'Poppins', sans-serif;
140
130
  }
141
131
 
142
132
  #input-container button {
143
- padding: 10px 20px; /* Larger padding for a larger button */
144
- background-color: #7E27ED; /* Button background color from style guide */
133
+ padding: 10px 20px;
134
+ background-color: #7E27ED;
145
135
  border: none;
146
136
  color: white;
147
137
  border-radius: 4px;
148
- font-family: 'Poppins', sans-serif; /* Use Poppins font */
149
- font-size: 1rem; /* Adjust font size as needed */
138
+ font-family: 'Poppins', sans-serif;
139
+ font-size: 1rem;
150
140
  cursor: pointer;
151
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Add subtle shadow for depth */
152
- transition: background-color 0.3s ease; /* Smooth transition for background color */
141
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
142
+ transition: background-color 0.3s ease;
153
143
  }
154
144
 
155
145
  #input-container button:hover {
156
- background-color: #2FC0BF; /* Hover color based on style guide */
157
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); /* Darker shadow for hover state */
146
+ background-color: #2FC0BF;
147
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
158
148
  }
159
149
 
160
150
  /* Message bubble styling */
161
151
  .message {
162
152
  margin: 8px 0;
163
153
  padding: 12px;
164
- background-color: #e0e0e0; /* Light grey for message bubbles */
154
+ background-color: #e0e0e0;
165
155
  border-radius: 16px;
166
156
  font-size: 14px;
167
157
  line-height: 1.4;
168
158
  }
169
159
 
170
160
  .message.user {
171
- background-color: #B928EB; /* User message bubble color */
161
+ background-color: #B928EB;
172
162
  color: white;
173
163
  align-self: flex-end;
174
164
  }
175
165
 
176
166
  .message.api {
177
- background-color: #e0e0e0; /* API message bubble color */
167
+ background-color: #e0e0e0;
178
168
  color: black;
179
169
  align-self: flex-start;
180
170
  }
181
171
 
172
+ /* Dish item styling */
173
+ .dish-message {
174
+ border: 2px solid #7E27ED; /* Bold yellow border */
175
+ cursor: pointer;
176
+ padding: 14px;
177
+ font-weight: bold;
178
+ font-size: 16px;
179
+ border-radius: 12px;
180
+ color: #333;
181
+ margin-top: 10px;
182
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Light shadow for depth */
183
+ }
184
+
182
185
  /* Wine item styling */
183
186
  .wine-item {
184
187
  display: flex;
@@ -187,7 +190,7 @@
187
190
  border-radius: 8px;
188
191
  padding: 10px;
189
192
  margin-top: 10px;
190
- background: white; /* White background for wine items */
193
+ background: white;
191
194
  }
192
195
 
193
196
  .wine-item a {
@@ -195,14 +198,14 @@
195
198
  }
196
199
 
197
200
  .wine-item img {
198
- width: 80px; /* Smaller wine image size */
201
+ width: 80px;
199
202
  height: auto;
200
- border-radius: 4px; /* Rounded corners for images */
203
+ border-radius: 4px;
201
204
  margin-right: 12px;
202
205
  }
203
206
 
204
207
  .wine-item div {
205
- font-size: 0.9rem; /* Smaller font size for wine info */
208
+ font-size: 0.9rem;
206
209
  }
207
210
 
208
211
  /* Ensure the chat window is visible when the 'visible' class is added */
@@ -212,14 +215,14 @@
212
215
 
213
216
  /* Loader Styles */
214
217
  .loader {
215
- display: none; /* Loader is hidden by default */
216
- border: 4px solid #f3f3f3; /* Light grey */
217
- border-top: 4px solid #3498db; /* Blue, could be your primary color */
218
+ display: none;
219
+ border: 4px solid #f3f3f3;
220
+ border-top: 4px solid #3498db;
218
221
  border-radius: 50%;
219
222
  width: 40px;
220
223
  height: 40px;
221
224
  animation: spin 2s linear infinite;
222
- margin: 20px auto; /* Centered horizontally */
225
+ margin: 20px auto;
223
226
  }
224
227
 
225
228
  .loader.visible {
@@ -236,8 +239,8 @@
236
239
  display: flex;
237
240
  justify-content: center;
238
241
  align-items: center;
239
- height: 0; /* Adjust as needed */
240
- visibility: hidden; /* Start off invisible */
242
+ height: 0;
243
+ visibility: hidden;
241
244
  background-color: #f7f7f7;
242
245
  }
243
246
 
@@ -246,13 +249,12 @@
246
249
  width: 8px;
247
250
  height: 8px;
248
251
  margin: 0 4px;
249
- background-color: #3498db; /* Or use a color from your style guide */
252
+ background-color: #3498db;
250
253
  border-radius: 50%;
251
254
  opacity: 0.4;
252
255
  animation: typing 1.5s infinite;
253
256
  }
254
257
 
255
- /* Animation keyframes */
256
258
  @keyframes typing {
257
259
  0% { transform: translateY(0); }
258
260
  20% { transform: translateY(-10px); }
@@ -262,7 +264,7 @@
262
264
  100% { transform: translateY(0); }
263
265
  }
264
266
 
265
- /* To stagger the animation for each dot */
267
+ /* Staggered animation for typing dots */
266
268
  .typing-indicator span:nth-child(1) {
267
269
  animation-delay: 0s;
268
270
  }
@@ -277,16 +279,16 @@
277
279
  .typing-indicator.visible {
278
280
  visibility: visible;
279
281
  height: 50px;
280
- }`,Kt=document.createElement("style");Kt.textContent=ve,document.head.appendChild(Kt);function Nn(){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 Ce(t,e,s){console.log(t,s);let n="";if(s){const i=new Date;i.setTime(i.getTime()+s*24*60*60*1e3),n="; expires="+i.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/; secure; samesite=strict"}function j(t){const e=t+"=",s=document.cookie.split(";");for(let n=0;n<s.length;n++){let i=s[n];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 _n(t){document.cookie=t+"=; Max-Age=-99999999;"}function On(){const t="uniqueUserID";let e=j(t);return e||(e=Nn(),Ce(t,e,365)),e}function le(t,e){fetch("https://api.wineater.com/proxy/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:t,properties:e})}).then(i=>{i.ok||console.error("Mixpanel tracking failed",i)}).catch(i=>{console.error("Mixpanel tracking error",i)})}function Jt(){le("Chatbot Opened",{distinct_id:j("uniqueUserID"),client:j("chatbotToken")})}function Rn(t){le("Chatbot Opened Auto",{distinct_id:j("uniqueUserID"),url:t,client:j("chatbotToken")})}function Yt(){le("Chatbot Closed",{distinct_id:j("uniqueUserID"),client:j("chatbotToken")})}function Dn(t){le("Message Sent",{distinct_id:j("uniqueUserID"),message_content:t,client:j("chatbotToken")})}function Mn(t){le("Products Got",{distinct_id:j("uniqueUserID"),products:t,client:j("chatbotToken")})}function An(t){le("Product Clicked",{distinct_id:j("uniqueUserID"),product_id:t,client:j("chatbotToken")})}var Qt={},Ln=function(t,e,s,n,i){var r=new Worker(Qt[e]||(Qt[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 l=o.data,a=l.$e$;if(a){var h=new Error(a[0]);h.code=a[1],h.stack=a[2],i(h,null)}else i(null,l)},r.postMessage(s,n),r},W=Uint8Array,z=Uint16Array,Ne=Int32Array,_e=new W([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]),Oe=new W([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]),et=new W([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zt=function(t,e){for(var s=new z(31),n=0;n<31;++n)s[n]=e+=1<<t[n-1];for(var i=new Ne(s[30]),n=1;n<30;++n)for(var r=s[n];r<s[n+1];++r)i[r]=r-s[n]<<5|n;return{b:s,r:i}},es=Zt(_e,2),Pn=es.b,Re=es.r;Pn[28]=258,Re[258]=28;for(var Fn=Zt(Oe,0),tt=Fn.r,De=new z(32768),L=0;L<32768;++L){var se=(L&43690)>>1|(L&21845)<<1;se=(se&52428)>>2|(se&13107)<<2,se=(se&61680)>>4|(se&3855)<<4,De[L]=((se&65280)>>8|(se&255)<<8)>>1}for(var he=function(t,e,s){for(var n=t.length,i=0,r=new z(e);i<n;++i)t[i]&&++r[t[i]-1];var o=new z(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var l;if(s){l=new z(1<<e);var a=15-e;for(i=0;i<n;++i)if(t[i])for(var h=i<<4|t[i],c=e-t[i],u=o[t[i]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)l[De[u]>>a]=h}else for(l=new z(n),i=0;i<n;++i)t[i]&&(l[i]=De[o[t[i]-1]++]>>15-t[i]);return l},ne=new W(288),L=0;L<144;++L)ne[L]=8;for(var L=144;L<256;++L)ne[L]=9;for(var L=256;L<280;++L)ne[L]=7;for(var L=280;L<288;++L)ne[L]=8;for(var ke=new W(32),L=0;L<32;++L)ke[L]=5;var ts=he(ne,9,0),ss=he(ke,5,0),st=function(t){return(t+7)/8|0},ns=function(t,e,s){return(e==null||e<0)&&(e=0),(s==null||s>t.length)&&(s=t.length),new W(t.subarray(e,s))},Bn=["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"],is=function(t,e,s){var n=new Error(e||Bn[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,is),!s)throw n;return n},X=function(t,e,s){s<<=e&7;var n=e/8|0;t[n]|=s,t[n+1]|=s>>8},ue=function(t,e,s){s<<=e&7;var n=e/8|0;t[n]|=s,t[n+1]|=s>>8,t[n+2]|=s>>16},Me=function(t,e){for(var s=[],n=0;n<t.length;++n)t[n]&&s.push({s:n,f:t[n]});var i=s.length,r=s.slice();if(!i)return{t:ot,l:0};if(i==1){var o=new W(s[0].s+1);return o[s[0].s]=1,{t:o,l:1}}s.sort(function(w,k){return w.f-k.f}),s.push({s:-1,f:25001});var l=s[0],a=s[1],h=0,c=1,u=2;for(s[0]={s:-1,f:l.f+a.f,l,r:a};c!=i-1;)l=s[s[h].f<s[u].f?h++:u++],a=s[h!=c&&s[h].f<s[u].f?h++:u++],s[c++]={s:-1,f:l.f+a.f,l,r:a};for(var d=r[0].s,n=1;n<i;++n)r[n].s>d&&(d=r[n].s);var f=new z(d+1),g=Ae(s[c-1],f,0);if(g>e){var n=0,p=0,y=g-e,E=1<<y;for(r.sort(function(k,x){return f[x.s]-f[k.s]||k.f-x.f});n<i;++n){var N=r[n].s;if(f[N]>e)p+=E-(1<<g-f[N]),f[N]=e;else break}for(p>>=y;p>0;){var T=r[n].s;f[T]<e?p-=1<<e-f[T]++-1:++n}for(;n>=0&&p;--n){var m=r[n].s;f[m]==e&&(--f[m],++p)}g=e}return{t:new W(f),l:g}},Ae=function(t,e,s){return t.s==-1?Math.max(Ae(t.l,e,s+1),Ae(t.r,e,s+1)):e[t.s]=s},nt=function(t){for(var e=t.length;e&&!t[--e];);for(var s=new z(++e),n=0,i=t[0],r=1,o=function(a){s[n++]=a},l=1;l<=e;++l)if(t[l]==i&&l!=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[l]}return{c:s.subarray(0,n),n:e}},de=function(t,e){for(var s=0,n=0;n<e.length;++n)s+=t[n]*e[n];return s},it=function(t,e,s){var n=s.length,i=st(e+2);t[i]=n&255,t[i+1]=n>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<n;++r)t[i+r+4]=s[r];return(i+4+n)*8},rt=function(t,e,s,n,i,r,o,l,a,h,c){X(e,c++,s),++i[256];for(var u=Me(i,15),d=u.t,f=u.l,g=Me(r,15),p=g.t,y=g.l,E=nt(d),N=E.c,T=E.n,m=nt(p),w=m.c,k=m.n,x=new z(19),S=0;S<N.length;++S)++x[N[S]&31];for(var S=0;S<w.length;++S)++x[w[S]&31];for(var b=Me(x,7),_=b.t,M=b.l,O=19;O>4&&!_[et[O-1]];--O);var D=h+5<<3,v=de(i,ne)+de(r,ke)+o,I=de(i,d)+de(r,p)+o+14+3*O+de(x,_)+2*x[16]+3*x[17]+7*x[18];if(a>=0&&D<=v&&D<=I)return it(e,c,t.subarray(a,a+h));var A,P,R,U;if(X(e,c,1+(I<v)),c+=2,I<v){A=he(d,f,0),P=d,R=he(p,y,0),U=p;var $t=he(_,M,0);X(e,c,T-257),X(e,c+5,k-1),X(e,c+10,O-4),c+=14;for(var S=0;S<O;++S)X(e,c+3*S,_[et[S]]);c+=3*O;for(var Q=[N,w],Ee=0;Ee<2;++Ee)for(var Se=Q[Ee],S=0;S<Se.length;++S){var Z=Se[S]&31;X(e,c,$t[Z]),c+=_[Z],Z>15&&(X(e,c,Se[S]>>5&127),c+=Se[S]>>12)}}else A=ts,P=ne,R=ss,U=ke;for(var S=0;S<l;++S){var H=n[S];if(H>255){var Z=H>>18&31;ue(e,c,A[Z+257]),c+=P[Z+257],Z>7&&(X(e,c,H>>23&31),c+=_e[Z]);var we=H&31;ue(e,c,R[we]),c+=U[we],we>3&&(ue(e,c,H>>5&8191),c+=Oe[we])}else ue(e,c,A[H]),c+=P[H]}return ue(e,c,A[256]),c+P[256]},rs=new Ne([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ot=new W(0),os=function(t,e,s,n,i,r){var o=r.z||t.length,l=new W(n+o+5*(1+Math.ceil(o/7e3))+i),a=l.subarray(n,l.length-i),h=r.l,c=(r.r||0)&7;if(e){c&&(a[0]=r.r>>3);for(var u=rs[e-1],d=u>>13,f=u&8191,g=(1<<s)-1,p=r.p||new z(32768),y=r.h||new z(g+1),E=Math.ceil(s/3),N=2*E,T=function(Gt){return(t[Gt]^t[Gt+1]<<E^t[Gt+2]<<N)&g},m=new Ne(25e3),w=new z(288),k=new z(32),x=0,S=0,b=r.i||0,_=0,M=r.w||0,O=0;b+2<o;++b){var D=T(b),v=b&32767,I=y[D];if(p[v]=I,y[D]=v,M<=b){var A=o-b;if((x>7e3||_>24576)&&(A>423||!h)){c=rt(t,a,0,m,w,k,S,_,O,b-O,c),_=x=S=0,O=b;for(var P=0;P<286;++P)w[P]=0;for(var P=0;P<30;++P)k[P]=0}var R=2,U=0,$t=f,Q=v-I&32767;if(A>2&&D==T(b-Q))for(var Ee=Math.min(d,A)-1,Se=Math.min(32767,b),Z=Math.min(258,A);Q<=Se&&--$t&&v!=I;){if(t[b+R]==t[b+R-Q]){for(var H=0;H<Z&&t[b+H]==t[b+H-Q];++H);if(H>R){if(R=H,U=Q,H>Ee)break;for(var we=Math.min(Q,H-2),In=0,P=0;P<we;++P){var Vt=b-Q+P&32767,$o=p[Vt],xn=Vt-$o&32767;xn>In&&(In=xn,I=Vt)}}}v=I,I=p[v],Q+=v-I&32767}if(U){m[_++]=268435456|Re[R]<<18|tt[U];var En=Re[R]&31,Cn=tt[U]&31;S+=_e[En]+Oe[Cn],++w[257+En],++k[Cn],M=b+R,++x}else m[_++]=t[b],++w[t[b]]}}for(b=Math.max(b,M);b<o;++b)m[_++]=t[b],++w[t[b]];c=rt(t,a,h,m,w,k,S,_,O,b-O,c),h||(r.r=c&7|a[c/8|0]<<3,c-=7,r.h=y,r.p=p,r.i=b,r.w=M)}else{for(var b=r.w||0;b<o+h;b+=65535){var Xt=b+65535;Xt>=o&&(a[c/8|0]=h,Xt=o),c=it(a,c+1,t.subarray(b,Xt))}r.i=o}return ns(l,0,n+st(c)+i)},as=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var s=e,n=9;--n;)s=(s&1&&-306674912)^s>>>1;t[e]=s}return t}(),cs=function(){var t=-1;return{p:function(e){for(var s=t,n=0;n<e.length;++n)s=as[s&255^e[n]]^s>>>8;t=s},d:function(){return~t}}},at=function(t,e,s,n,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new W(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return os(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,s,n,i)},Un=function(t,e){var s={};for(var n in t)s[n]=t[n];for(var n in e)s[n]=e[n];return s},ls=function(t,e,s){for(var n=t(),i=t.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<n.length;++o){var l=n[o],a=r[o];if(typeof l=="function"){e+=";"+a+"=";var h=l.toString();if(l.prototype)if(h.indexOf("[native code]")!=-1){var c=h.indexOf(" ",8)+1;e+=h.slice(c,h.indexOf("(",c))}else{e+=h;for(var u in l.prototype)e+=";"+a+".prototype."+u+"="+l.prototype[u].toString()}else e+=h}else s[a]=l}return e},Le=[],Hn=function(t){var e=[];for(var s in t)t[s].buffer&&e.push((t[s]=new t[s].constructor(t[s])).buffer);return e},jn=function(t,e,s,n){if(!Le[s]){for(var i="",r={},o=t.length-1,l=0;l<o;++l)i=ls(t[l],i,r);Le[s]={c:ls(t[o],i,r),e:r}}var a=Un({},Le[s].e);return Ln(Le[s].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",s,a,Hn(a),n)},zn=function(){return[W,z,Ne,_e,Oe,et,Re,tt,ts,ne,ss,ke,De,rs,ot,he,X,ue,Me,Ae,nt,de,it,rt,st,ns,os,at,$n,hs]},Wn=function(){return[us,ds,Pe,cs,as]},hs=function(t){return postMessage(t,[t.buffer])},qn=function(t,e,s,n,i,r){var o=jn(s,n,i,function(l,a){o.terminate(),r(l,a)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},Pe=function(t,e,s){for(;s;++e)t[e]=s,s>>>=8},us=function(t,e){var s=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&&Pe(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),s){t[3]=8;for(var n=0;n<=s.length;++n)t[n+10]=s.charCodeAt(n)}},ds=function(t){return 10+(t.filename?t.filename.length+1:0)};function $n(t,e){return at(t,e||{},0,0)}function Vn(t,e,s){return s||(s=e,e={}),typeof s!="function"&&is(7),qn(t,e,[zn,Wn,function(){return[fs]}],function(n){return hs(fs(n.data[0],n.data[1]))},2,s)}function fs(t,e){e||(e={});var s=cs(),n=t.length;s.p(t);var i=at(t,e,ds(e),8),r=i.length;return us(i,e),Pe(i,r-8,s.d()),Pe(i,r-4,n),i}var Xn=typeof TextDecoder<"u"&&new TextDecoder,Gn=0;try{Xn.decode(ot,{stream:!0}),Gn=1}catch{}class ps{constructor(){this.idx=1,this.backDict={}}getKey(e){let s=!1;return this.backDict[e]||(s=!0,this.backDict[e]=this.idx++),[this.backDict[e],s]}}class Kn{constructor(e,s){this.app=e,this.isDictDisabled=s,this.dict=new ps}sendSetAttribute(e,s,n){if(this.isDictDisabled){const i=[12,e,s,n];return this.app.send(i)}else{const i=[51,e,this.applyDict(s),this.applyDict(n)];return this.app.send(i)}}applyDict(e){const[s,n]=this.dict.getKey(e);return n&&this.app.send([50,s,e]),s}clear(){this.dict=new ps}}class Jn{constructor(e,s){this.app=e,this.startParams=s,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=n=>{if(n.value.length){const i=Yn(n);if(i.type)return i}},this.durationInt=null}setConditions(e){this.conditions=e}async fetchConditions(e,s){try{const n=await fetch(`${this.app.options.ingestPoint}/v1/web/conditions/${e}`,{method:"GET",headers:{Authorization:`Bearer ${s}`}}),{conditions:i}=await n.json(),r=[];i.forEach(o=>{o.filters.forEach(a=>{let h;a.type==="fetch"?(h={type:"network_request",subConditions:[],name:o.name},a.filters.forEach(c=>{const u=this.createConditionFromFilter(c);u&&h.subConditions.push(u)})):h=this.createConditionFromFilter(a),h&&(h.type==="session_duration"&&this.processDuration(h.value[0],o.name),r.push({...h,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(s){this.app.debug.error(s)}}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 s=this.conditions.filter(n=>n.type==="feature_flag");s.length&&s.forEach(n=>{const i=fe[n.operator];i&&e.find(r=>i(r.key,n.value))&&this.trigger(n.name)})}processDuration(e,s){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(s)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const s=this.conditions.filter(n=>n.type==="network_request");s.length&&s.forEach(n=>{const i=n.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let l;switch(o.key){case"url":l=e[3];break;case"status":l=e[6];break;case"method":l=e[2];break;case"duration":l=e[8];break}const a=fe[o.operator];if(a&&a(l,o.value))return!0})&&this.trigger(n.name):i.length===0&&n.subConditions.length&&this.trigger(n.name)})}customEvent(e){const s=this.conditions.filter(n=>n.type==="custom_event");s.length&&s.forEach(n=>{const i=fe[n.operator];i&&(i(e[1],n.value)||i(e[2],n.value))&&this.trigger(n.name)})}clickEvent(e){const s=this.conditions.filter(n=>n.type==="click");s.length&&s.forEach(n=>{const i=fe[n.operator];i&&(i(e[3],n.value)||i(e[4],n.value))&&this.trigger(n.name)})}pageLocationEvent(e){const s=this.conditions.filter(n=>n.type==="visited_url");s&&s.forEach(n=>{const i=fe[n.operator];i&&i(e[1],n.value)&&this.trigger(n.name)})}jsExceptionEvent(e){const s=[e[1],e[2],e[3]],n=this.conditions.filter(i=>i.type==="exception");n&&n.forEach(i=>{const r=fe[i.operator];r&&s.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const fe={is:(t,e)=>e.some(s=>t.includes(s)),isAny:()=>!0,isNot:(t,e)=>!e.some(s=>t.includes(s)),contains:(t,e)=>e.some(s=>t.includes(s)),notContains:(t,e)=>!e.some(s=>t.includes(s)),startsWith:(t,e)=>e.some(s=>t.startsWith(s)),endsWith:(t,e)=>e.some(s=>t.endsWith(s)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},Yn=t=>{const e={on:"is",notOn:"isNot",">":"greaterThan","<":"lessThan","=":"is","<=":"lessOrEqual",">=":"greaterOrEqual"},s=i=>{if(Object.keys(e).includes(i))return e[i]};let n={type:"",operator:"",value:t.value,key:""};switch(t.type){case"click":n={type:"click",operator:s(t.operator),value:t.value,key:""};break;case"location":n={type:"visited_url",operator:t.operator,value:t.value,key:""};break;case"custom":n={type:"custom_event",operator:t.operator,value:t.value,key:""};break;case"metadata":n={type:t.source==="featureFlag"?"feature_flag":t.type,operator:t.operator,value:t.value,key:""};break;case"error":n={type:"exception",operator:t.operator,value:t.value,key:""};break;case"duration":n={type:"session_duration",value:t.value[0],key:""};break;case"fetchUrl":n={type:"network_request",key:"url",operator:t.operator,value:t.value};break;case"fetchStatusCode":n={type:"network_request",key:"status",operator:s(t.operator),value:t.value};break;case"fetchMethod":n={type:"network_request",key:"method",operator:s(t.operator),value:t.value};break;case"fetchDuration":n={type:"network_request",key:"duration",operator:s(t.operator),value:t.value};break}return n};class Qn{constructor(e){this.app=e,this.flags=[],this.storageKey="__openreplay_flags";const s=this.app.sessionStorage.getItem(this.storageKey);if(s){const n=s.split(";").filter(Boolean);this.flags=n.map(i=>JSON.parse(i))}}getFeatureFlag(e){return this.flags.find(s=>s.key===e)}isFlagEnabled(e){return this.flags.findIndex(s=>s.key===e)!==-1}onFlagsLoad(e){this.onFlagsCb=e}async reloadFlags(e){const s=this.app.sessionStorage.getItem(this.storageKey),n={};s&&s.split(";").filter(Boolean).forEach(c=>{const u=JSON.parse(c);n[u.key]={key:u.key,value:u.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:n},l=e??this.app.session.getSessionToken(),a=await fetch(this.app.options.ingestPoint+"/v1/web/feature-flags",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify(o)});if(a.status===200){const h=await a.json();return this.handleFlags(h.flags)}}handleFlags(e){var r;const s=[];e.forEach(o=>{o.is_persist&&s.push(o)});let n="";return this.diffPersist(s).forEach(o=>{n+=`${JSON.stringify(o)};`}),this.app.sessionStorage.setItem(this.storageKey,n),this.flags=e,(r=this.onFlagsCb)==null?void 0:r.call(this,e)}clearPersistFlags(){this.app.sessionStorage.removeItem(this.storageKey)}diffPersist(e){const s=this.app.sessionStorage.getItem(this.storageKey);if(!s)return e;const i=s.split(";").filter(Boolean).map(r=>JSON.parse(r));return e.filter(r=>i.findIndex(o=>o.key===r.key)===-1)}}const gs={htmlmasked:"hidden",masked:"obscured"},G=!(typeof window>"u"),Zn=G&&navigator.userAgent.match(/firefox|fxios/i),ei=1e5;let ct=G?Date.now()-performance.now():0;function lt(){ct=Date.now()-performance.now()}function pe(){return ct}const V=G&&performance.now?()=>Math.round(performance.now()+ct):()=>Date.now(),ht="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function ms(t){return t.trim().replace(/\s+/g," ")}function bs(t){return t.startsWith("https://")||t.startsWith("http://")}const Fe="https://docs.openreplay.com",ys={};function ie(t,e,s="/"){ys[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${Fe}${s} for more information.`),ys[t]=!0)}function ut(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&ie('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function oe(t,e){const s=`data-openreplay-${e}`;return t.hasAttribute(s)?(gs[e]&&ie(`"${s}" attribute`,`"${gs[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function ti(t){try{return!!t.contentDocument}catch{return!1}}function Ss(t){return t.toString(16).padStart(2,"0")}function si(t){const e=new Uint8Array((t||40)/2),s=window.crypto||window.msCrypto;return s?(s.getRandomValues(e),Array.from(e,Ss).join("")):Array.from({length:t||40},()=>Ss(Math.floor(Math.random()*16))).join("")}function ni(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function dt(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function ws(t){const e=dt("MutationObserver");return new window[e](t)}function vs(t,e,s,n){const i=dt("addEventListener");try{t[i](e,s,n)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}function ks(t,e,s,n){const i=dt("removeEventListener");try{t[i](e,s,n)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}class ii{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 s=this.taskQueue.shift();Promise.resolve(s()).then(()=>{requestAnimationFrame(()=>e())})};e()}}const ri=new ii;function oi(t){ri.addTask(t)}function Ts(t,e){const s={...t};for(const n in e)if(e.hasOwnProperty(n)){const i=e[n],r=t[n];typeof i=="object"&&!Array.isArray(i)&&i!==null?s[n]=Ts(r||{},i):s[n]=i}return s}function ae(t){return[0,t]}function ai(t,e){return[5,t,e]}function ci(t,e){return[6,t,e]}function li(){return[7]}function hi(t,e,s,n,i){return[8,t,e,s,n,i]}function ui(t,e,s){return[9,t,e,s]}function di(t,e,s){return[10,t,e,s]}function fi(t){return[11,t]}function Is(t,e){return[13,t,e]}function pi(t,e){return[14,t,e]}function gi(t,e,s){return[16,t,e,s]}function mi(t,e,s){return[18,t,e,s]}function bi(t,e){return[19,t,e]}function yi(t,e){return[20,t,e]}function Si(t,e){return[22,t,e]}function wi(t,e,s,n,i,r,o,l,a){return[23,t,e,s,n,i,r,o,l,a]}function vi(t,e,s){return[24,t,e,s]}function ki(t,e){return[27,t,e]}function Ti(t){return[28,t]}function Ii(t){return[29,t]}function xs(t,e){return[30,t,e]}function xi(t,e,s,n){return[49,t,e,s,n]}function Ei(t,e){return[54,t,e]}function Ci(t){return[55,t]}function Es(t,e,s,n){return[57,t,e,s,n]}function Cs(t){return[58,t]}function ft(t,e,s,n){return[60,t,e,s,n]}function Ni(t,e,s){return[61,t,e,s]}function _i(t,e){return[63,t,e]}function Oi(t,e){return[64,t,e]}function Ri(t,e,s,n,i,r){return[68,t,e,s,n,i,r]}function pt(t,e){return[70,t,e]}function Ns(t,e,s){return[71,t,e,s]}function gt(t,e,s,n){return[73,t,e,s,n]}function _s(t,e){return[75,t,e]}function Os(t,e){return[76,t,e]}function Di(t,e){return[77,t,e]}function mt(t,e,s,n){return[78,t,e,s,n]}function Be(t,e,s,n,i,r,o,l,a){return[83,t,e,s,n,i,r,o,l,a]}function Mi(t,e,s,n,i,r){return[84,t,e,s,n,i,r]}function Ai(t,e,s,n,i,r){return[112,t,e,s,n,i,r]}function Rs(t,e,s){return[113,t,e,s]}function Li(t){return[114,t]}function Pi(t){return[115,t]}function Ds(t,e,s,n,i,r,o,l,a,h){return[116,t,e,s,n,i,r,o,l,a,h]}function Ue(t){return[117,t]}function ce(t){return[118,t]}function Fi(t,e){return[119,t,e]}function Bi(t){return[120,t]}function Ui(t,e,s,n){return[122,t,e,s,n]}const bt=G&&"performance"in window&&"memory"in performance?performance:{memory:{}},yt=G?(navigator.deviceMemory||0)*1024:0,St=bt.memory.jsHeapSizeLimit||0;function Hi(t,e){if(!Object.assign({capturePerformance:!0},e).capturePerformance)return;let n,i;const r=()=>{n===void 0||n===-1||(n++,requestAnimationFrame(r))};t.ticker.attach(()=>{i===void 0||i===-1||i++},0,!1);const o=()=>{n===void 0||i===void 0||(t.send(xi(n,i,bt.memory.totalJSHeapSize||0,bt.memory.usedJSHeapSize||0)),i=n=document.hidden?-1:0)};t.attachStartCallback(()=>{i=n=-1,o(),r()}),t.attachStopCallback(()=>{i=n=void 0}),t.ticker.attach(o,40,!1),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",o,!1,!1)}const Ms="__or__watched_tags__";class ji{constructor(e,s,n){this.sessionStorage=e,this.errLog=s,this.onTag=n,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Ms)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&o.target){const l=o.target.__or_watcher_tagname;l&&this.onTagRendered(l),this.observer.unobserve(o.target)}})})}async fetchTags(e,s){return fetch(`${e}/v1/web/tags`,{method:"GET",headers:{Authorization:`Bearer ${s}`}}).then(n=>n.json()).then(({tags:n})=>{if(n&&n.length){this.setTags(n);const i=JSON.stringify(n);this.sessionStorage.setItem(Ms,i||"")}}).catch(n=>this.errLog(n))}setTags(e){this.tags=e,this.intervals={},e.forEach(s=>{this.intervals[s.id]=setInterval(()=>{const n=document.querySelectorAll(s.selector);if(n.length>0){const i=n[0];i.__or_watcher_tagname=s.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 zi={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"'},Wi={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},He={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"},qi={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},$i={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"},Vi={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"},As={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},ge={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Xi={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"},me={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"},Gi={...me,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Ls={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Ps={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"},Fs={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Ki={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Bs={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Ji={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"},Us={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"},Hs={fontWeight:"bold"},Yi={fontSize:"13px",lineHeight:"auto"},js={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},Qi={...js,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},Zi={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},er={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},zs={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class tr{constructor(e){this.app=e,this.mediaRecorder=null,this.recordedChunks=[],this.stream=null,this.recStartTs=null}async startRecording(e,s,n,i){this.recStartTs=this.app.timestamp();const r=s;try{this.stream=await navigator.mediaDevices.getUserMedia({video:i?{...r,frameRate:{ideal:e}}:!1,audio:n}),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 s=new Blob(this.recordedChunks,{type:"video/webm"});e(s)},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(s=>{if(s.ok)return s.json();throw new Error("Failed to get upload url")}).then(({url:s})=>fetch(s,{method:"PUT",headers:{"Content-Type":"video/webm"},body:e})).catch(console.error).finally(()=>{this.discard()})}async saveToFile(e="recorded-video.webm"){const s=await this.stopRecording(),n=URL.createObjectURL(s),i=document.createElement("a");i.style.display="none",i.href=n,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(n),document.body.removeChild(i)}discard(){var e,s;(e=this.mediaRecorder)==null||e.stop(),(s=this.stream)==null||s.getTracks().forEach(n=>n.stop())}}function sr(t,e){e.onmousedown=function(s){const n=t.getBoundingClientRect(),i=s.clientX-n.left,r=s.clientY-n.top;t.style.position="fixed",t.style.zIndex=99999999999999,o(s.pageX,s.pageY);function o(h,c){let u=h-i,d=c-r;u<=5&&(u=5),d<=5&&(d=5),u>=window.innerWidth-n.width&&(u=window.innerWidth-n.width),d>=window.innerHeight-n.height&&(d=window.innerHeight-n.height),t.style.left=`${u}px`,t.style.top=`${d}px`}function l(h){o(h.pageX,h.pageY)}document.addEventListener("mousemove",l);const a=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a)},e.ondragstart=function(){return!1}}function nr(){const t=document.createElement("div");t.className="grid";for(let e=0;e<16;e++){const s=document.createElement("div");Object.assign(s.style,{width:"2px",height:"2px",borderRadius:"10px",background:"white"}),s.className="cell",t.appendChild(s)}return Object.assign(t.style,{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(4, 1fr)",gap:"2px",cursor:"grab"}),t}function ir(){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 rr(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
282
+ }`,Kt=document.createElement("style");Kt.textContent=ve,document.head.appendChild(Kt);function Rn(){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 Ce(t,e,s){console.log(t,s);let n="";if(s){const i=new Date;i.setTime(i.getTime()+s*24*60*60*1e3),n="; expires="+i.toUTCString()}document.cookie=t+"="+(e||"")+n+"; path=/; secure; samesite=strict"}function j(t){const e=t+"=",s=document.cookie.split(";");for(let n=0;n<s.length;n++){let i=s[n];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 Dn(t){document.cookie=t+"=; Max-Age=-99999999;"}function Mn(){const t="uniqueUserID";let e=j(t);return e||(e=Rn(),Ce(t,e,365)),e}function le(t,e){fetch("https://api.wineater.com/proxy/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:t,properties:e})}).then(i=>{i.ok||console.error("Mixpanel tracking failed",i)}).catch(i=>{console.error("Mixpanel tracking error",i)})}function Jt(){le("Chatbot Opened",{distinct_id:j("uniqueUserID"),client:j("chatbotToken")})}function An(t){le("Chatbot Opened Auto",{distinct_id:j("uniqueUserID"),url:t,client:j("chatbotToken")})}function Yt(){le("Chatbot Closed",{distinct_id:j("uniqueUserID"),client:j("chatbotToken")})}function Pn(t){le("Message Sent",{distinct_id:j("uniqueUserID"),message_content:t,client:j("chatbotToken")})}function Ln(t){le("Products Got",{distinct_id:j("uniqueUserID"),products:t,client:j("chatbotToken")})}function Fn(t){le("Product Clicked",{distinct_id:j("uniqueUserID"),product_id:t,client:j("chatbotToken")})}var Qt={},Bn=function(t,e,s,n,i){var r=new Worker(Qt[e]||(Qt[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 l=o.data,a=l.$e$;if(a){var h=new Error(a[0]);h.code=a[1],h.stack=a[2],i(h,null)}else i(null,l)},r.postMessage(s,n),r},W=Uint8Array,z=Uint16Array,Ne=Int32Array,_e=new W([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]),Oe=new W([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]),tt=new W([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zt=function(t,e){for(var s=new z(31),n=0;n<31;++n)s[n]=e+=1<<t[n-1];for(var i=new Ne(s[30]),n=1;n<30;++n)for(var r=s[n];r<s[n+1];++r)i[r]=r-s[n]<<5|n;return{b:s,r:i}},es=Zt(_e,2),Un=es.b,Re=es.r;Un[28]=258,Re[258]=28;for(var Hn=Zt(Oe,0),st=Hn.r,De=new z(32768),P=0;P<32768;++P){var se=(P&43690)>>1|(P&21845)<<1;se=(se&52428)>>2|(se&13107)<<2,se=(se&61680)>>4|(se&3855)<<4,De[P]=((se&65280)>>8|(se&255)<<8)>>1}for(var he=function(t,e,s){for(var n=t.length,i=0,r=new z(e);i<n;++i)t[i]&&++r[t[i]-1];var o=new z(e);for(i=1;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var l;if(s){l=new z(1<<e);var a=15-e;for(i=0;i<n;++i)if(t[i])for(var h=i<<4|t[i],c=e-t[i],u=o[t[i]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)l[De[u]>>a]=h}else for(l=new z(n),i=0;i<n;++i)t[i]&&(l[i]=De[o[t[i]-1]++]>>15-t[i]);return l},ne=new W(288),P=0;P<144;++P)ne[P]=8;for(var P=144;P<256;++P)ne[P]=9;for(var P=256;P<280;++P)ne[P]=7;for(var P=280;P<288;++P)ne[P]=8;for(var ke=new W(32),P=0;P<32;++P)ke[P]=5;var ts=he(ne,9,0),ss=he(ke,5,0),nt=function(t){return(t+7)/8|0},ns=function(t,e,s){return(e==null||e<0)&&(e=0),(s==null||s>t.length)&&(s=t.length),new W(t.subarray(e,s))},jn=["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"],is=function(t,e,s){var n=new Error(e||jn[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,is),!s)throw n;return n},G=function(t,e,s){s<<=e&7;var n=e/8|0;t[n]|=s,t[n+1]|=s>>8},ue=function(t,e,s){s<<=e&7;var n=e/8|0;t[n]|=s,t[n+1]|=s>>8,t[n+2]|=s>>16},Me=function(t,e){for(var s=[],n=0;n<t.length;++n)t[n]&&s.push({s:n,f:t[n]});var i=s.length,r=s.slice();if(!i)return{t:at,l:0};if(i==1){var o=new W(s[0].s+1);return o[s[0].s]=1,{t:o,l:1}}s.sort(function(w,k){return w.f-k.f}),s.push({s:-1,f:25001});var l=s[0],a=s[1],h=0,c=1,u=2;for(s[0]={s:-1,f:l.f+a.f,l,r:a};c!=i-1;)l=s[s[h].f<s[u].f?h++:u++],a=s[h!=c&&s[h].f<s[u].f?h++:u++],s[c++]={s:-1,f:l.f+a.f,l,r:a};for(var d=r[0].s,n=1;n<i;++n)r[n].s>d&&(d=r[n].s);var f=new z(d+1),g=Ae(s[c-1],f,0);if(g>e){var n=0,p=0,y=g-e,E=1<<y;for(r.sort(function(k,x){return f[x.s]-f[k.s]||k.f-x.f});n<i;++n){var N=r[n].s;if(f[N]>e)p+=E-(1<<g-f[N]),f[N]=e;else break}for(p>>=y;p>0;){var T=r[n].s;f[T]<e?p-=1<<e-f[T]++-1:++n}for(;n>=0&&p;--n){var m=r[n].s;f[m]==e&&(--f[m],++p)}g=e}return{t:new W(f),l:g}},Ae=function(t,e,s){return t.s==-1?Math.max(Ae(t.l,e,s+1),Ae(t.r,e,s+1)):e[t.s]=s},it=function(t){for(var e=t.length;e&&!t[--e];);for(var s=new z(++e),n=0,i=t[0],r=1,o=function(a){s[n++]=a},l=1;l<=e;++l)if(t[l]==i&&l!=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[l]}return{c:s.subarray(0,n),n:e}},de=function(t,e){for(var s=0,n=0;n<e.length;++n)s+=t[n]*e[n];return s},rt=function(t,e,s){var n=s.length,i=nt(e+2);t[i]=n&255,t[i+1]=n>>8,t[i+2]=t[i]^255,t[i+3]=t[i+1]^255;for(var r=0;r<n;++r)t[i+r+4]=s[r];return(i+4+n)*8},ot=function(t,e,s,n,i,r,o,l,a,h,c){G(e,c++,s),++i[256];for(var u=Me(i,15),d=u.t,f=u.l,g=Me(r,15),p=g.t,y=g.l,E=it(d),N=E.c,T=E.n,m=it(p),w=m.c,k=m.n,x=new z(19),S=0;S<N.length;++S)++x[N[S]&31];for(var S=0;S<w.length;++S)++x[w[S]&31];for(var b=Me(x,7),_=b.t,M=b.l,O=19;O>4&&!_[tt[O-1]];--O);var D=h+5<<3,v=de(i,ne)+de(r,ke)+o,I=de(i,d)+de(r,p)+o+14+3*O+de(x,_)+2*x[16]+3*x[17]+7*x[18];if(a>=0&&D<=v&&D<=I)return rt(e,c,t.subarray(a,a+h));var A,L,R,U;if(G(e,c,1+(I<v)),c+=2,I<v){A=he(d,f,0),L=d,R=he(p,y,0),U=p;var $t=he(_,M,0);G(e,c,T-257),G(e,c+5,k-1),G(e,c+10,O-4),c+=14;for(var S=0;S<O;++S)G(e,c+3*S,_[tt[S]]);c+=3*O;for(var Q=[N,w],Ee=0;Ee<2;++Ee)for(var Se=Q[Ee],S=0;S<Se.length;++S){var Z=Se[S]&31;G(e,c,$t[Z]),c+=_[Z],Z>15&&(G(e,c,Se[S]>>5&127),c+=Se[S]>>12)}}else A=ts,L=ne,R=ss,U=ke;for(var S=0;S<l;++S){var H=n[S];if(H>255){var Z=H>>18&31;ue(e,c,A[Z+257]),c+=L[Z+257],Z>7&&(G(e,c,H>>23&31),c+=_e[Z]);var we=H&31;ue(e,c,R[we]),c+=U[we],we>3&&(ue(e,c,H>>5&8191),c+=Oe[we])}else ue(e,c,A[H]),c+=L[H]}return ue(e,c,A[256]),c+L[256]},rs=new Ne([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),at=new W(0),os=function(t,e,s,n,i,r){var o=r.z||t.length,l=new W(n+o+5*(1+Math.ceil(o/7e3))+i),a=l.subarray(n,l.length-i),h=r.l,c=(r.r||0)&7;if(e){c&&(a[0]=r.r>>3);for(var u=rs[e-1],d=u>>13,f=u&8191,g=(1<<s)-1,p=r.p||new z(32768),y=r.h||new z(g+1),E=Math.ceil(s/3),N=2*E,T=function(Gt){return(t[Gt]^t[Gt+1]<<E^t[Gt+2]<<N)&g},m=new Ne(25e3),w=new z(288),k=new z(32),x=0,S=0,b=r.i||0,_=0,M=r.w||0,O=0;b+2<o;++b){var D=T(b),v=b&32767,I=y[D];if(p[v]=I,y[D]=v,M<=b){var A=o-b;if((x>7e3||_>24576)&&(A>423||!h)){c=ot(t,a,0,m,w,k,S,_,O,b-O,c),_=x=S=0,O=b;for(var L=0;L<286;++L)w[L]=0;for(var L=0;L<30;++L)k[L]=0}var R=2,U=0,$t=f,Q=v-I&32767;if(A>2&&D==T(b-Q))for(var Ee=Math.min(d,A)-1,Se=Math.min(32767,b),Z=Math.min(258,A);Q<=Se&&--$t&&v!=I;){if(t[b+R]==t[b+R-Q]){for(var H=0;H<Z&&t[b+H]==t[b+H-Q];++H);if(H>R){if(R=H,U=Q,H>Ee)break;for(var we=Math.min(Q,H-2),Cn=0,L=0;L<we;++L){var Vt=b-Q+L&32767,Qo=p[Vt],Nn=Vt-Qo&32767;Nn>Cn&&(Cn=Nn,I=Vt)}}}v=I,I=p[v],Q+=v-I&32767}if(U){m[_++]=268435456|Re[R]<<18|st[U];var _n=Re[R]&31,On=st[U]&31;S+=_e[_n]+Oe[On],++w[257+_n],++k[On],M=b+R,++x}else m[_++]=t[b],++w[t[b]]}}for(b=Math.max(b,M);b<o;++b)m[_++]=t[b],++w[t[b]];c=ot(t,a,h,m,w,k,S,_,O,b-O,c),h||(r.r=c&7|a[c/8|0]<<3,c-=7,r.h=y,r.p=p,r.i=b,r.w=M)}else{for(var b=r.w||0;b<o+h;b+=65535){var Xt=b+65535;Xt>=o&&(a[c/8|0]=h,Xt=o),c=rt(a,c+1,t.subarray(b,Xt))}r.i=o}return ns(l,0,n+nt(c)+i)},as=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var s=e,n=9;--n;)s=(s&1&&-306674912)^s>>>1;t[e]=s}return t}(),cs=function(){var t=-1;return{p:function(e){for(var s=t,n=0;n<e.length;++n)s=as[s&255^e[n]]^s>>>8;t=s},d:function(){return~t}}},ct=function(t,e,s,n,i){if(!i&&(i={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),o=new W(r.length+t.length);o.set(r),o.set(t,r.length),t=o,i.w=r.length}return os(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,s,n,i)},zn=function(t,e){var s={};for(var n in t)s[n]=t[n];for(var n in e)s[n]=e[n];return s},ls=function(t,e,s){for(var n=t(),i=t.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<n.length;++o){var l=n[o],a=r[o];if(typeof l=="function"){e+=";"+a+"=";var h=l.toString();if(l.prototype)if(h.indexOf("[native code]")!=-1){var c=h.indexOf(" ",8)+1;e+=h.slice(c,h.indexOf("(",c))}else{e+=h;for(var u in l.prototype)e+=";"+a+".prototype."+u+"="+l.prototype[u].toString()}else e+=h}else s[a]=l}return e},Pe=[],Wn=function(t){var e=[];for(var s in t)t[s].buffer&&e.push((t[s]=new t[s].constructor(t[s])).buffer);return e},qn=function(t,e,s,n){if(!Pe[s]){for(var i="",r={},o=t.length-1,l=0;l<o;++l)i=ls(t[l],i,r);Pe[s]={c:ls(t[o],i,r),e:r}}var a=zn({},Pe[s].e);return Bn(Pe[s].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",s,a,Wn(a),n)},$n=function(){return[W,z,Ne,_e,Oe,tt,Re,st,ts,ne,ss,ke,De,rs,at,he,G,ue,Me,Ae,it,de,rt,ot,nt,ns,os,ct,Gn,hs]},Vn=function(){return[us,ds,Le,cs,as]},hs=function(t){return postMessage(t,[t.buffer])},Xn=function(t,e,s,n,i,r){var o=qn(s,n,i,function(l,a){o.terminate(),r(l,a)});return o.postMessage([t,e],e.consume?[t.buffer]:[]),function(){o.terminate()}},Le=function(t,e,s){for(;s;++e)t[e]=s,s>>>=8},us=function(t,e){var s=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&&Le(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),s){t[3]=8;for(var n=0;n<=s.length;++n)t[n+10]=s.charCodeAt(n)}},ds=function(t){return 10+(t.filename?t.filename.length+1:0)};function Gn(t,e){return ct(t,e||{},0,0)}function Kn(t,e,s){return s||(s=e,e={}),typeof s!="function"&&is(7),Xn(t,e,[$n,Vn,function(){return[fs]}],function(n){return hs(fs(n.data[0],n.data[1]))},2,s)}function fs(t,e){e||(e={});var s=cs(),n=t.length;s.p(t);var i=ct(t,e,ds(e),8),r=i.length;return us(i,e),Le(i,r-8,s.d()),Le(i,r-4,n),i}var Jn=typeof TextDecoder<"u"&&new TextDecoder,Yn=0;try{Jn.decode(at,{stream:!0}),Yn=1}catch{}class ps{constructor(){this.idx=1,this.backDict={}}getKey(e){let s=!1;return this.backDict[e]||(s=!0,this.backDict[e]=this.idx++),[this.backDict[e],s]}}class Qn{constructor(e,s){this.app=e,this.isDictDisabled=s,this.dict=new ps}sendSetAttribute(e,s,n){if(this.isDictDisabled){const i=[12,e,s,n];return this.app.send(i)}else{const i=[51,e,this.applyDict(s),this.applyDict(n)];return this.app.send(i)}}applyDict(e){const[s,n]=this.dict.getKey(e);return n&&this.app.send([50,s,e]),s}clear(){this.dict=new ps}}class Zn{constructor(e,s){this.app=e,this.startParams=s,this.conditions=[],this.hasStarted=!1,this.createConditionFromFilter=n=>{if(n.value.length){const i=ei(n);if(i.type)return i}},this.durationInt=null}setConditions(e){this.conditions=e}async fetchConditions(e,s){try{const n=await fetch(`${this.app.options.ingestPoint}/v1/web/conditions/${e}`,{method:"GET",headers:{Authorization:`Bearer ${s}`}}),{conditions:i}=await n.json(),r=[];i.forEach(o=>{o.filters.forEach(a=>{let h;a.type==="fetch"?(h={type:"network_request",subConditions:[],name:o.name},a.filters.forEach(c=>{const u=this.createConditionFromFilter(c);u&&h.subConditions.push(u)})):h=this.createConditionFromFilter(a),h&&(h.type==="session_duration"&&this.processDuration(h.value[0],o.name),r.push({...h,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(s){this.app.debug.error(s)}}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 s=this.conditions.filter(n=>n.type==="feature_flag");s.length&&s.forEach(n=>{const i=fe[n.operator];i&&e.find(r=>i(r.key,n.value))&&this.trigger(n.name)})}processDuration(e,s){this.durationInt=setInterval(()=>{performance.now()>e&&this.trigger(s)},1e3),this.app.attachStopCallback(()=>{this.durationInt&&clearInterval(this.durationInt)})}networkRequest(e){const s=this.conditions.filter(n=>n.type==="network_request");s.length&&s.forEach(n=>{const i=n.subConditions.filter(r=>r.operator!=="isAny");i.length?i.every(o=>{let l;switch(o.key){case"url":l=e[3];break;case"status":l=e[6];break;case"method":l=e[2];break;case"duration":l=e[8];break}const a=fe[o.operator];if(a&&a(l,o.value))return!0})&&this.trigger(n.name):i.length===0&&n.subConditions.length&&this.trigger(n.name)})}customEvent(e){const s=this.conditions.filter(n=>n.type==="custom_event");s.length&&s.forEach(n=>{const i=fe[n.operator];i&&(i(e[1],n.value)||i(e[2],n.value))&&this.trigger(n.name)})}clickEvent(e){const s=this.conditions.filter(n=>n.type==="click");s.length&&s.forEach(n=>{const i=fe[n.operator];i&&(i(e[3],n.value)||i(e[4],n.value))&&this.trigger(n.name)})}pageLocationEvent(e){const s=this.conditions.filter(n=>n.type==="visited_url");s&&s.forEach(n=>{const i=fe[n.operator];i&&i(e[1],n.value)&&this.trigger(n.name)})}jsExceptionEvent(e){const s=[e[1],e[2],e[3]],n=this.conditions.filter(i=>i.type==="exception");n&&n.forEach(i=>{const r=fe[i.operator];r&&s.some(o=>r(o,i.value))&&this.trigger(i.name)})}}const fe={is:(t,e)=>e.some(s=>t.includes(s)),isAny:()=>!0,isNot:(t,e)=>!e.some(s=>t.includes(s)),contains:(t,e)=>e.some(s=>t.includes(s)),notContains:(t,e)=>!e.some(s=>t.includes(s)),startsWith:(t,e)=>e.some(s=>t.startsWith(s)),endsWith:(t,e)=>e.some(s=>t.endsWith(s)),greaterThan:(t,e)=>t>e,greaterOrEqual:(t,e)=>t>=e,lessOrEqual:(t,e)=>t<=e,lessThan:(t,e)=>t<e},ei=t=>{const e={on:"is",notOn:"isNot",">":"greaterThan","<":"lessThan","=":"is","<=":"lessOrEqual",">=":"greaterOrEqual"},s=i=>{if(Object.keys(e).includes(i))return e[i]};let n={type:"",operator:"",value:t.value,key:""};switch(t.type){case"click":n={type:"click",operator:s(t.operator),value:t.value,key:""};break;case"location":n={type:"visited_url",operator:t.operator,value:t.value,key:""};break;case"custom":n={type:"custom_event",operator:t.operator,value:t.value,key:""};break;case"metadata":n={type:t.source==="featureFlag"?"feature_flag":t.type,operator:t.operator,value:t.value,key:""};break;case"error":n={type:"exception",operator:t.operator,value:t.value,key:""};break;case"duration":n={type:"session_duration",value:t.value[0],key:""};break;case"fetchUrl":n={type:"network_request",key:"url",operator:t.operator,value:t.value};break;case"fetchStatusCode":n={type:"network_request",key:"status",operator:s(t.operator),value:t.value};break;case"fetchMethod":n={type:"network_request",key:"method",operator:s(t.operator),value:t.value};break;case"fetchDuration":n={type:"network_request",key:"duration",operator:s(t.operator),value:t.value};break}return n};class ti{constructor(e){this.app=e,this.flags=[],this.storageKey="__openreplay_flags";const s=this.app.sessionStorage.getItem(this.storageKey);if(s){const n=s.split(";").filter(Boolean);this.flags=n.map(i=>JSON.parse(i))}}getFeatureFlag(e){return this.flags.find(s=>s.key===e)}isFlagEnabled(e){return this.flags.findIndex(s=>s.key===e)!==-1}onFlagsLoad(e){this.onFlagsCb=e}async reloadFlags(e){const s=this.app.sessionStorage.getItem(this.storageKey),n={};s&&s.split(";").filter(Boolean).forEach(c=>{const u=JSON.parse(c);n[u.key]={key:u.key,value:u.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:n},l=e??this.app.session.getSessionToken(),a=await fetch(this.app.options.ingestPoint+"/v1/web/feature-flags",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify(o)});if(a.status===200){const h=await a.json();return this.handleFlags(h.flags)}}handleFlags(e){var r;const s=[];e.forEach(o=>{o.is_persist&&s.push(o)});let n="";return this.diffPersist(s).forEach(o=>{n+=`${JSON.stringify(o)};`}),this.app.sessionStorage.setItem(this.storageKey,n),this.flags=e,(r=this.onFlagsCb)==null?void 0:r.call(this,e)}clearPersistFlags(){this.app.sessionStorage.removeItem(this.storageKey)}diffPersist(e){const s=this.app.sessionStorage.getItem(this.storageKey);if(!s)return e;const i=s.split(";").filter(Boolean).map(r=>JSON.parse(r));return e.filter(r=>i.findIndex(o=>o.key===r.key)===-1)}}const gs={htmlmasked:"hidden",masked:"obscured"},K=!(typeof window>"u"),si=K&&navigator.userAgent.match(/firefox|fxios/i),ni=1e5;let lt=K?Date.now()-performance.now():0;function ht(){lt=Date.now()-performance.now()}function pe(){return lt}const X=K&&performance.now?()=>Math.round(performance.now()+lt):()=>Date.now(),ut="repeat"in String.prototype?t=>"*".repeat(t.length):t=>t.replace(/./g,"*");function ms(t){return t.trim().replace(/\s+/g," ")}function bs(t){return t.startsWith("https://")||t.startsWith("http://")}const Fe="https://docs.openreplay.com",ys={};function ie(t,e,s="/"){ys[t]||(console.warn(`OpenReplay: ${t} is deprecated. ${e?`Please, use ${e} instead.`:""} Visit ${Fe}${s} for more information.`),ys[t]=!0)}function dt(t){let e=t.getAttribute("data-openreplay-label");return e!==null||(e=t.getAttribute("data-asayer-label"),e!==null&&ie('"data-asayer-label" attribute','"data-openreplay-label" attribute',"/")),e}function oe(t,e){const s=`data-openreplay-${e}`;return t.hasAttribute(s)?(gs[e]&&ie(`"${s}" attribute`,`"${gs[e]}" attribute`,"/installation/sanitize-data"),!0):!1}function ii(t){try{return!!t.contentDocument}catch{return!1}}function Ss(t){return t.toString(16).padStart(2,"0")}function ri(t){const e=new Uint8Array((t||40)/2),s=window.crypto||window.msCrypto;return s?(s.getRandomValues(e),Array.from(e,Ss).join("")):Array.from({length:t||40},()=>Ss(Math.floor(Math.random()*16))).join("")}function oi(){try{return window.self&&window.top&&window.self!==window.top}catch{return!0}}function ft(t){return window.Zone&&"__symbol__"in window.Zone?window.Zone.__symbol__(t):t}function ws(t){const e=ft("MutationObserver");return new window[e](t)}function vs(t,e,s,n){const i=ft("addEventListener");try{t[i](e,s,n)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}function ks(t,e,s,n){const i=ft("removeEventListener");try{t[i](e,s,n)}catch(r){const o=r.message;console.debug(`Openreplay: ${o}; if this error is caused by an IframeObserver, ignore it`)}}class ai{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 s=this.taskQueue.shift();Promise.resolve(s()).then(()=>{requestAnimationFrame(()=>e())})};e()}}const ci=new ai;function li(t){ci.addTask(t)}function Ts(t,e){const s={...t};for(const n in e)if(e.hasOwnProperty(n)){const i=e[n],r=t[n];typeof i=="object"&&!Array.isArray(i)&&i!==null?s[n]=Ts(r||{},i):s[n]=i}return s}function ae(t){return[0,t]}function hi(t,e){return[5,t,e]}function ui(t,e){return[6,t,e]}function di(){return[7]}function fi(t,e,s,n,i){return[8,t,e,s,n,i]}function pi(t,e,s){return[9,t,e,s]}function gi(t,e,s){return[10,t,e,s]}function mi(t){return[11,t]}function Is(t,e){return[13,t,e]}function bi(t,e){return[14,t,e]}function yi(t,e,s){return[16,t,e,s]}function Si(t,e,s){return[18,t,e,s]}function wi(t,e){return[19,t,e]}function vi(t,e){return[20,t,e]}function ki(t,e){return[22,t,e]}function Ti(t,e,s,n,i,r,o,l,a){return[23,t,e,s,n,i,r,o,l,a]}function Ii(t,e,s){return[24,t,e,s]}function xi(t,e){return[27,t,e]}function Ei(t){return[28,t]}function Ci(t){return[29,t]}function xs(t,e){return[30,t,e]}function Ni(t,e,s,n){return[49,t,e,s,n]}function _i(t,e){return[54,t,e]}function Oi(t){return[55,t]}function Es(t,e,s,n){return[57,t,e,s,n]}function Cs(t){return[58,t]}function pt(t,e,s,n){return[60,t,e,s,n]}function Ri(t,e,s){return[61,t,e,s]}function Di(t,e){return[63,t,e]}function Mi(t,e){return[64,t,e]}function Ai(t,e,s,n,i,r){return[68,t,e,s,n,i,r]}function gt(t,e){return[70,t,e]}function Ns(t,e,s){return[71,t,e,s]}function mt(t,e,s,n){return[73,t,e,s,n]}function _s(t,e){return[75,t,e]}function Os(t,e){return[76,t,e]}function Pi(t,e){return[77,t,e]}function bt(t,e,s,n){return[78,t,e,s,n]}function Be(t,e,s,n,i,r,o,l,a){return[83,t,e,s,n,i,r,o,l,a]}function Li(t,e,s,n,i,r){return[84,t,e,s,n,i,r]}function Fi(t,e,s,n,i,r){return[112,t,e,s,n,i,r]}function Rs(t,e,s){return[113,t,e,s]}function Bi(t){return[114,t]}function Ui(t){return[115,t]}function Ds(t,e,s,n,i,r,o,l,a,h){return[116,t,e,s,n,i,r,o,l,a,h]}function Ue(t){return[117,t]}function ce(t){return[118,t]}function Hi(t,e){return[119,t,e]}function ji(t){return[120,t]}function zi(t,e,s,n){return[122,t,e,s,n]}const yt=K&&"performance"in window&&"memory"in performance?performance:{memory:{}},St=K?(navigator.deviceMemory||0)*1024:0,wt=yt.memory.jsHeapSizeLimit||0;function Wi(t,e){if(!Object.assign({capturePerformance:!0},e).capturePerformance)return;let n,i;const r=()=>{n===void 0||n===-1||(n++,requestAnimationFrame(r))};t.ticker.attach(()=>{i===void 0||i===-1||i++},0,!1);const o=()=>{n===void 0||i===void 0||(t.send(Ni(n,i,yt.memory.totalJSHeapSize||0,yt.memory.usedJSHeapSize||0)),i=n=document.hidden?-1:0)};t.attachStartCallback(()=>{i=n=-1,o(),r()}),t.attachStopCallback(()=>{i=n=void 0}),t.ticker.attach(o,40,!1),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",o,!1,!1)}const Ms="__or__watched_tags__";class qi{constructor(e,s,n){this.sessionStorage=e,this.errLog=s,this.onTag=n,this.intervals={},this.tags=[];const i=JSON.parse(e.getItem(Ms)??"[]");this.setTags(i),this.observer=new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&o.target){const l=o.target.__or_watcher_tagname;l&&this.onTagRendered(l),this.observer.unobserve(o.target)}})})}async fetchTags(e,s){return fetch(`${e}/v1/web/tags`,{method:"GET",headers:{Authorization:`Bearer ${s}`}}).then(n=>n.json()).then(({tags:n})=>{if(n&&n.length){this.setTags(n);const i=JSON.stringify(n);this.sessionStorage.setItem(Ms,i||"")}}).catch(n=>this.errLog(n))}setTags(e){this.tags=e,this.intervals={},e.forEach(s=>{this.intervals[s.id]=setInterval(()=>{const n=document.querySelectorAll(s.selector);if(n.length>0){const i=n[0];i.__or_watcher_tagname=s.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 $i={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"'},Vi={display:"flex",flexDirection:"column",gap:"2rem",alignItems:"center",padding:"1.5rem",borderRadius:"2px",border:"1px solid #D9D9D9",background:"#FFF",width:"22rem"},He={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"},Xi={fontFamily:"Verdana, sans-serif",fontSize:"1.25rem",fontStyle:"normal",fontWeight:"500",lineHeight:"1.75rem",color:"rgba(0, 0, 0, 0.85)"},Gi={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"},Ki={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"},As={fontFamily:"Verdana, sans-serif",fontSize:"13px",fontWeight:"500",lineHeight:"auto",display:"flex",justifyContent:"space-between",width:"100%",cursor:"pointer"},ge={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"0.625rem",fontSize:"13px",lineHeight:"auto"},Ji={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"},me={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"},Yi={...me,display:"flex",flexDirection:"column",alignItems:"center",gap:"0.625rem"},Ps={fontSize:"1.25rem",fontWeight:"500",cursor:"pointer",color:"#394EFF"},Ls={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"},Fs={marginTop:"1rem",marginBottom:"1rem",cursor:"pointer",display:"block",fontWeight:"500",fontSize:"13px!important",lineHeight:"auto"},Qi={display:"flex",justifyContent:"space-between",alignItems:"center",gap:"1rem",padding:"0.5rem",width:"100%",boxSizing:"border-box"},Bs={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em",outline:"1px solid #394EFF",fontSize:"13px",height:"24px",width:"24px"},Zi={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"},Us={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"},Hs={fontWeight:"bold"},er={fontSize:"13px",lineHeight:"auto"},js={marginRight:"0.5rem",cursor:"pointer",color:"#394EFF",textAlign:"center",fontFamily:"Verdana, sans-serif",fontSize:"13px",fontStyle:"normal",fontWeight:"500",lineHeight:"auto"},tr={...js,display:"flex",padding:"0.25rem 0.9375rem",justifyContent:"center",alignItems:"center",gap:"0.5rem",borderRadius:"0.25rem",border:"1px solid #394EFF"},sr={display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",boxSizing:"border-box"},nr={border:"4px solid rgba(255, 255, 255, 0.4)",width:"16px",height:"16px",borderRadius:"50%",borderLeftColor:"#fff",animation:"spin 0.5s linear infinite"},zs={Standard:{width:1280,height:720},High:{width:1920,height:1080}};class ir{constructor(e){this.app=e,this.mediaRecorder=null,this.recordedChunks=[],this.stream=null,this.recStartTs=null}async startRecording(e,s,n,i){this.recStartTs=this.app.timestamp();const r=s;try{this.stream=await navigator.mediaDevices.getUserMedia({video:i?{...r,frameRate:{ideal:e}}:!1,audio:n}),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 s=new Blob(this.recordedChunks,{type:"video/webm"});e(s)},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(s=>{if(s.ok)return s.json();throw new Error("Failed to get upload url")}).then(({url:s})=>fetch(s,{method:"PUT",headers:{"Content-Type":"video/webm"},body:e})).catch(console.error).finally(()=>{this.discard()})}async saveToFile(e="recorded-video.webm"){const s=await this.stopRecording(),n=URL.createObjectURL(s),i=document.createElement("a");i.style.display="none",i.href=n,i.download=e,document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(n),document.body.removeChild(i)}discard(){var e,s;(e=this.mediaRecorder)==null||e.stop(),(s=this.stream)==null||s.getTracks().forEach(n=>n.stop())}}function rr(t,e){e.onmousedown=function(s){const n=t.getBoundingClientRect(),i=s.clientX-n.left,r=s.clientY-n.top;t.style.position="fixed",t.style.zIndex=99999999999999,o(s.pageX,s.pageY);function o(h,c){let u=h-i,d=c-r;u<=5&&(u=5),d<=5&&(d=5),u>=window.innerWidth-n.width&&(u=window.innerWidth-n.width),d>=window.innerHeight-n.height&&(d=window.innerHeight-n.height),t.style.left=`${u}px`,t.style.top=`${d}px`}function l(h){o(h.pageX,h.pageY)}document.addEventListener("mousemove",l);const a=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",a)};document.addEventListener("mouseup",a)},e.ondragstart=function(){return!1}}function or(){const t=document.createElement("div");t.className="grid";for(let e=0;e<16;e++){const s=document.createElement("div");Object.assign(s.style,{width:"2px",height:"2px",borderRadius:"10px",background:"white"}),s.className="cell",t.appendChild(s)}return Object.assign(t.style,{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(4, 1fr)",gap:"2px",cursor:"grab"}),t}function ar(){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 cr(){const t=document.createElement("style");t.type="text/css",t.innerText=`@keyframes spin {
281
283
  0% { transform: rotate(0deg); }
282
284
  100% { transform: rotate(360deg); }
283
- }`,document.head.appendChild(t)}function or(){rr();const t=document.createElement("div");return t.classList.add("spinner"),Object.assign(t.style,er),t}function C(t,e,s,n,i){const r=document.createElement(t);return r.className=e,Object.assign(r.style,s),n&&(r.textContent=n),i&&(r.id=i),r}const je="or_uxt_test_start",wt="or_uxt_task_index",vt="or_uxt_session_id",ar="or_uxt_test_id";class cr{constructor(e,s,n,i,r,o,l,a,h){this.ingestPoint=e,this.getTimestamp=s,this.token=n,this.testId=i,this.storageKey=r,this.setStorageKey=o,this.removeStorageKey=l,this.getStorageKey=a,this.getSessionId=h,this.durations={testStart:0,tasks:[]},this.getDurations=()=>this.durations,this.setDurations=u=>{this.durations.testStart=u.testStart,this.durations.tasks=u.tasks},this.signalTask=(u,d,f)=>{if(!u)return console.error("User Testing: No Task ID Given");const g=this.durations.tasks.find(E=>E.taskId===u),p=this.getTimestamp(),y=g?p-g.started:0;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/task`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,taskId:u,status:d,duration:y,timestamp:p,taskAnswer:f})})},this.signalTest=u=>{const d=this.getTimestamp();if(u==="begin"&&this.testId){const p=this.getSessionId();this.setStorageKey(vt,p),this.setStorageKey(this.storageKey,this.testId.toString()),this.setStorageKey(je,d.toString())}else this.removeStorageKey(this.storageKey),this.removeStorageKey(wt),this.removeStorageKey(je);const f=this.durations.testStart||d,g=d-f;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/test`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,status:u,duration:g,timestamp:d})})};const c=this.getStorageKey(je);c&&(this.durations.testStart=parseInt(c,10))}}class lr{constructor(e,s){this.app=e,this.storageKey=s,this.bg=C("div","bg",zi,void 0,"__or_ut_bg"),this.container=C("div","container",Wi,void 0,"__or_ut_ct"),this.widgetGuidelinesVisible=!0,this.widgetTasksVisible=!1,this.widgetVisible=!0,this.isActive=!1,this.descriptionSection=null,this.taskSection=null,this.endSection=null,this.stopButton=null,this.stopButtonContainer=null,this.test=null,this.testId=null,this.signalManager=null,this.getTest=(o,l,a)=>{this.testId=o;const h=this.app.options.ingestPoint;return fetch(`${h}/v1/web/uxt/test/${o}`,{headers:{Authorization:`Bearer ${l}`}}).then(c=>c.json()).then(({test:c})=>{this.isActive=!0,this.test=c,this.signalManager=new cr(this.app.options.ingestPoint,()=>this.app.timestamp(),l,o,this.storageKey,(u,d)=>this.app.localStorage.setItem(u,d),u=>this.app.localStorage.removeItem(u),u=>this.app.localStorage.getItem(u),()=>this.app.getSessionID()),this.createGreeting(c.title,c.reqMic,c.reqCamera),a&&((c.reqMic||c.reqCamera)&&this.userRecorder.startRecording(30,zs.Standard,c.reqMic,c.reqCamera),this.showWidget(c.description,c.tasks,!0),this.showTaskSection())}).then(()=>o).catch(c=>{console.log("OR: Error fetching test",c)})},this.hideTaskSection=()=>!1,this.showTaskSection=()=>!0,this.collapseWidget=()=>!1,this.removeGreeting=()=>!1,this.toggleDescriptionVisibility=()=>{},this.currentTaskIndex=0,this.userRecorder=new tr(e);const n=this.app.getSessionID(),i=this.app.localStorage.getItem(vt);n!==i&&(this.app.localStorage.removeItem(this.storageKey),this.app.localStorage.removeItem(vt),this.app.localStorage.removeItem(ar),this.app.localStorage.removeItem(wt),this.app.localStorage.removeItem(je));const r=this.app.localStorage.getItem(wt);r&&(this.currentTaskIndex=parseInt(r,10))}getTestId(){return this.testId}createGreeting(e,s,n){const i=C("div","title",qi,e),r=C("div","description",$i,`Welcome, you're here to help us improve, not to be judged. Your insights matter!
285
+ }`,document.head.appendChild(t)}function lr(){cr();const t=document.createElement("div");return t.classList.add("spinner"),Object.assign(t.style,nr),t}function C(t,e,s,n,i){const r=document.createElement(t);return r.className=e,Object.assign(r.style,s),n&&(r.textContent=n),i&&(r.id=i),r}const je="or_uxt_test_start",vt="or_uxt_task_index",kt="or_uxt_session_id",hr="or_uxt_test_id";class ur{constructor(e,s,n,i,r,o,l,a,h){this.ingestPoint=e,this.getTimestamp=s,this.token=n,this.testId=i,this.storageKey=r,this.setStorageKey=o,this.removeStorageKey=l,this.getStorageKey=a,this.getSessionId=h,this.durations={testStart:0,tasks:[]},this.getDurations=()=>this.durations,this.setDurations=u=>{this.durations.testStart=u.testStart,this.durations.tasks=u.tasks},this.signalTask=(u,d,f)=>{if(!u)return console.error("User Testing: No Task ID Given");const g=this.durations.tasks.find(E=>E.taskId===u),p=this.getTimestamp(),y=g?p-g.started:0;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/task`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,taskId:u,status:d,duration:y,timestamp:p,taskAnswer:f})})},this.signalTest=u=>{const d=this.getTimestamp();if(u==="begin"&&this.testId){const p=this.getSessionId();this.setStorageKey(kt,p),this.setStorageKey(this.storageKey,this.testId.toString()),this.setStorageKey(je,d.toString())}else this.removeStorageKey(this.storageKey),this.removeStorageKey(vt),this.removeStorageKey(je);const f=this.durations.testStart||d,g=d-f;return fetch(`${this.ingestPoint}/v1/web/uxt/signals/test`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`},body:JSON.stringify({testId:this.testId,status:u,duration:g,timestamp:d})})};const c=this.getStorageKey(je);c&&(this.durations.testStart=parseInt(c,10))}}class dr{constructor(e,s){this.app=e,this.storageKey=s,this.bg=C("div","bg",$i,void 0,"__or_ut_bg"),this.container=C("div","container",Vi,void 0,"__or_ut_ct"),this.widgetGuidelinesVisible=!0,this.widgetTasksVisible=!1,this.widgetVisible=!0,this.isActive=!1,this.descriptionSection=null,this.taskSection=null,this.endSection=null,this.stopButton=null,this.stopButtonContainer=null,this.test=null,this.testId=null,this.signalManager=null,this.getTest=(o,l,a)=>{this.testId=o;const h=this.app.options.ingestPoint;return fetch(`${h}/v1/web/uxt/test/${o}`,{headers:{Authorization:`Bearer ${l}`}}).then(c=>c.json()).then(({test:c})=>{this.isActive=!0,this.test=c,this.signalManager=new ur(this.app.options.ingestPoint,()=>this.app.timestamp(),l,o,this.storageKey,(u,d)=>this.app.localStorage.setItem(u,d),u=>this.app.localStorage.removeItem(u),u=>this.app.localStorage.getItem(u),()=>this.app.getSessionID()),this.createGreeting(c.title,c.reqMic,c.reqCamera),a&&((c.reqMic||c.reqCamera)&&this.userRecorder.startRecording(30,zs.Standard,c.reqMic,c.reqCamera),this.showWidget(c.description,c.tasks,!0),this.showTaskSection())}).then(()=>o).catch(c=>{console.log("OR: Error fetching test",c)})},this.hideTaskSection=()=>!1,this.showTaskSection=()=>!0,this.collapseWidget=()=>!1,this.removeGreeting=()=>!1,this.toggleDescriptionVisibility=()=>{},this.currentTaskIndex=0,this.userRecorder=new ir(e);const n=this.app.getSessionID(),i=this.app.localStorage.getItem(kt);n!==i&&(this.app.localStorage.removeItem(this.storageKey),this.app.localStorage.removeItem(kt),this.app.localStorage.removeItem(hr),this.app.localStorage.removeItem(vt),this.app.localStorage.removeItem(je));const r=this.app.localStorage.getItem(vt);r&&(this.currentTaskIndex=parseInt(r,10))}getTestId(){return this.testId}createGreeting(e,s,n){const i=C("div","title",Xi,e),r=C("div","description",Gi,`Welcome, you're here to help us improve, not to be judged. Your insights matter!
284
286
 
285
287
  📹 We're recording this browser tab to learn from your experience.
286
- 🎤 Please enable mic and camera if asked, to give us a complete picture.`),o=C("div","button",Vi,"Read guidelines to begin");this.removeGreeting=()=>((s||n)&&this.userRecorder.startRecording(30,zs.Standard,s,n),this.container.removeChild(o),this.container.removeChild(r),this.container.removeChild(i),!1),o.onclick=()=>{var a,h,c,u;this.removeGreeting();const l=(a=this.signalManager)==null?void 0:a.getDurations();l&&this.signalManager&&(l.testStart=this.app.timestamp(),this.signalManager.setDurations(l)),(h=this.signalManager)==null||h.signalTest("begin"),this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,He),this.showWidget(((c=this.test)==null?void 0:c.guidelines)||"",((u=this.test)==null?void 0:u.tasks)||[])},this.container.append(i,r,o),this.bg.appendChild(this.container),document.body.appendChild(this.bg)}showWidget(e,s,n){this.container.innerHTML="",Object.assign(this.bg.style,{position:"fixed",zIndex:99999999999999,right:"8px",left:"unset",width:"fit-content",top:"8px",height:"fit-content",background:"unset",display:"unset",alignItems:"unset",justifyContent:"unset"});const i=this.createTitleSection();this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,He);const r=this.createDescriptionSection(e),o=this.createTasksSection(s),l=C("div","stop_bn_or",Fs,"Abort Session"),a=C("div","stop_ct_or",{fontSize:"13px!important"});a.style.fontSize="13px",a.append(l),this.container.append(i,r,o,a),this.taskSection=o,this.descriptionSection=r,this.stopButton=l,this.stopButtonContainer=a,l.onclick=()=>{var h;this.userRecorder.discard(),(h=this.signalManager)==null||h.signalTest("skipped"),document.body.removeChild(this.bg),window.close()},n?this.toggleDescriptionVisibility():this.hideTaskSection()}createTitleSection(){var l;const e=C("div","title",Xi),s=nr(),n=C("div","title_text",{maxWidth:"19rem",overflow:"hidden",textOverflow:"ellipsis",width:"100%",fontSize:16,lineHeight:"auto",cursor:"pointer"},(l=this.test)==null?void 0:l.title),i=ir();e.append(s,n,i);const r=a=>(this.widgetVisible=a,this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,this.widgetVisible?He:{border:"none",background:"none",padding:0}),this.taskSection&&Object.assign(this.taskSection.style,this.widgetVisible?me:{display:"none"}),this.descriptionSection&&Object.assign(this.descriptionSection.style,this.widgetVisible?me:{display:"none"}),this.endSection&&Object.assign(this.endSection.style,this.widgetVisible?me:{display:"none"}),this.stopButton&&Object.assign(this.stopButton.style,this.widgetVisible?Fs:{display:"none"}),a),o=()=>{Object.assign(i.style,{transform:this.widgetVisible?"rotate(0deg)":"rotate(180deg)"}),r(!this.widgetVisible)};return n.onclick=o,i.onclick=o,sr(this.bg,s),this.collapseWidget=()=>r(!1),e}createDescriptionSection(e){const s=C("div","description_section_or",me),n=C("div","description_s_title_or",As),i=C("div","title",{fontSize:13,fontWeight:500,lineHeight:"auto"},"Introduction & Guidelines"),r=C("div","icon",Ls,"-"),o=C("div","content",ge),l=C("div","text_description",{maxHeight:"250px",overflowY:"auto",whiteSpace:"pre-wrap",fontSize:13,color:"#454545",lineHeight:"auto"});l.innerHTML=e;const a=C("div","button_begin_or",Ps,"Begin Test");n.append(i,r),o.append(l,a),s.append(n,o);const h=()=>{this.widgetGuidelinesVisible=!this.widgetGuidelinesVisible,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ge:{display:"none"})};return n.onclick=h,this.toggleDescriptionVisibility=()=>{this.widgetGuidelinesVisible=!1,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ge:{display:"none"}),o.removeChild(a)},a.onclick=()=>{var c,u,d;if(h(),this.test){const f=(c=this.signalManager)==null?void 0:c.getDurations(),g=f?f.tasks.findIndex(p=>this.test&&p.taskId===this.test.tasks[0].task_id):null;f&&g===-1&&(f.tasks.push({taskId:this.test.tasks[0].task_id,started:this.app.timestamp()}),(u=this.signalManager)==null||u.setDurations(f)),(d=this.signalManager)==null||d.signalTask(this.test.tasks[0].task_id,"begin")}this.showTaskSection(),o.removeChild(a)},s}createTasksSection(e){this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,He);const s=C("div","task_section_or",me),n=C("div","description_t_title_or",As),i=C("div","title",{fontSize:"13px",fontWeight:"500",lineHeight:"auto"},"Tasks"),r=C("div","icon",Ls,"-"),o=C("div","content",ge),l=C("div","pagination",Ki),a=C("div","taskCard",Us),h=C("div","taskText",Hs),c=C("div","taskDescription",Yi),u=C("div","taskButtons",Zi),d=C("div","taskText",Hs);d.textContent="Your answer";const f=C("textarea","taskDescription",{resize:"vertical"}),g=C("div","inputArea",Us);g.append(d,f);const p=C("div","closePanelButton",js,"Collapse Panel"),y=C("div","nextButton",Qi,"Done, Next");n.append(i,r),a.append(h,c),u.append(p,y),o.append(l,a,g,u),s.append(n,o);const E=()=>{const m=e[this.currentTaskIndex];h.textContent=m.title,c.textContent=m.description,m.allow_typing?g.style.display="flex":g.style.display="none"};e.forEach((m,w)=>{const k=C("span",`or_task_${w}`,{outline:"1px solid #efefef",fontSize:"13px",height:"24px",width:"24px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em"},(w+1).toString());k.id=`or_task_${w}`,l.append(k)});const N=()=>{this.widgetTasksVisible=!this.widgetTasksVisible,r.textContent=this.widgetTasksVisible?"-":"+",Object.assign(o.style,this.widgetTasksVisible?ge:{display:"none"})};this.hideTaskSection=()=>(r.textContent="+",Object.assign(o.style,{display:"none"}),this.widgetTasksVisible=!1,!1),this.showTaskSection=()=>(r.textContent="-",Object.assign(o.style,ge),this.widgetTasksVisible=!0,!0);const T=()=>{const m=document.getElementById(`or_task_${this.currentTaskIndex}`);m&&Object.assign(m.style,Bs);for(let w=0;w<this.currentTaskIndex;w++){const k=document.getElementById(`or_task_${w}`);k&&Object.assign(k.style,Ji)}};return n.onclick=N,p.onclick=this.collapseWidget,y.onclick=()=>{var w,k,x,S;const m=e[this.currentTaskIndex].allow_typing?f.value:void 0;if(f.value="",(w=this.signalManager)==null||w.signalTask(e[this.currentTaskIndex].task_id,"done",m),this.currentTaskIndex<e.length-1){this.currentTaskIndex++,E();const b=(k=this.signalManager)==null?void 0:k.getDurations();b&&b.tasks.findIndex(_=>_.taskId===e[this.currentTaskIndex].task_id)===-1&&(b.tasks.push({taskId:e[this.currentTaskIndex].task_id,started:this.app.timestamp()}),(x=this.signalManager)==null||x.setDurations(b)),(S=this.signalManager)==null||S.signalTask(e[this.currentTaskIndex].task_id,"begin"),T()}else this.showEndSection();this.app.localStorage.setItem("or_uxt_task_index",this.currentTaskIndex.toString())},setTimeout(()=>{const m=document.getElementById("or_task_0");m&&Object.assign(m.style,Bs),E(),T()},1),s}showEndSection(){var l,a,h,c;let e=!0;(l=this.signalManager)==null||l.signalTest("done");const s=C("div","end_section_or",Gi),n=C("div","end_title_or",{fontSize:"1.25rem",fontWeight:"500"},"Thank you! 👍"),i=C("div","end_description_or",{},((a=this.test)==null?void 0:a.conclusion)??`Thank you for participating in our usability test. Your feedback has been captured and will be used to enhance our website.
288
+ 🎤 Please enable mic and camera if asked, to give us a complete picture.`),o=C("div","button",Ki,"Read guidelines to begin");this.removeGreeting=()=>((s||n)&&this.userRecorder.startRecording(30,zs.Standard,s,n),this.container.removeChild(o),this.container.removeChild(r),this.container.removeChild(i),!1),o.onclick=()=>{var a,h,c,u;this.removeGreeting();const l=(a=this.signalManager)==null?void 0:a.getDurations();l&&this.signalManager&&(l.testStart=this.app.timestamp(),this.signalManager.setDurations(l)),(h=this.signalManager)==null||h.signalTest("begin"),this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,He),this.showWidget(((c=this.test)==null?void 0:c.guidelines)||"",((u=this.test)==null?void 0:u.tasks)||[])},this.container.append(i,r,o),this.bg.appendChild(this.container),document.body.appendChild(this.bg)}showWidget(e,s,n){this.container.innerHTML="",Object.assign(this.bg.style,{position:"fixed",zIndex:99999999999999,right:"8px",left:"unset",width:"fit-content",top:"8px",height:"fit-content",background:"unset",display:"unset",alignItems:"unset",justifyContent:"unset"});const i=this.createTitleSection();this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,He);const r=this.createDescriptionSection(e),o=this.createTasksSection(s),l=C("div","stop_bn_or",Fs,"Abort Session"),a=C("div","stop_ct_or",{fontSize:"13px!important"});a.style.fontSize="13px",a.append(l),this.container.append(i,r,o,a),this.taskSection=o,this.descriptionSection=r,this.stopButton=l,this.stopButtonContainer=a,l.onclick=()=>{var h;this.userRecorder.discard(),(h=this.signalManager)==null||h.signalTest("skipped"),document.body.removeChild(this.bg),window.close()},n?this.toggleDescriptionVisibility():this.hideTaskSection()}createTitleSection(){var l;const e=C("div","title",Ji),s=or(),n=C("div","title_text",{maxWidth:"19rem",overflow:"hidden",textOverflow:"ellipsis",width:"100%",fontSize:16,lineHeight:"auto",cursor:"pointer"},(l=this.test)==null?void 0:l.title),i=ar();e.append(s,n,i);const r=a=>(this.widgetVisible=a,this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,this.widgetVisible?He:{border:"none",background:"none",padding:0}),this.taskSection&&Object.assign(this.taskSection.style,this.widgetVisible?me:{display:"none"}),this.descriptionSection&&Object.assign(this.descriptionSection.style,this.widgetVisible?me:{display:"none"}),this.endSection&&Object.assign(this.endSection.style,this.widgetVisible?me:{display:"none"}),this.stopButton&&Object.assign(this.stopButton.style,this.widgetVisible?Fs:{display:"none"}),a),o=()=>{Object.assign(i.style,{transform:this.widgetVisible?"rotate(0deg)":"rotate(180deg)"}),r(!this.widgetVisible)};return n.onclick=o,i.onclick=o,rr(this.bg,s),this.collapseWidget=()=>r(!1),e}createDescriptionSection(e){const s=C("div","description_section_or",me),n=C("div","description_s_title_or",As),i=C("div","title",{fontSize:13,fontWeight:500,lineHeight:"auto"},"Introduction & Guidelines"),r=C("div","icon",Ps,"-"),o=C("div","content",ge),l=C("div","text_description",{maxHeight:"250px",overflowY:"auto",whiteSpace:"pre-wrap",fontSize:13,color:"#454545",lineHeight:"auto"});l.innerHTML=e;const a=C("div","button_begin_or",Ls,"Begin Test");n.append(i,r),o.append(l,a),s.append(n,o);const h=()=>{this.widgetGuidelinesVisible=!this.widgetGuidelinesVisible,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ge:{display:"none"})};return n.onclick=h,this.toggleDescriptionVisibility=()=>{this.widgetGuidelinesVisible=!1,r.textContent=this.widgetGuidelinesVisible?"-":"+",Object.assign(o.style,this.widgetGuidelinesVisible?ge:{display:"none"}),o.removeChild(a)},a.onclick=()=>{var c,u,d;if(h(),this.test){const f=(c=this.signalManager)==null?void 0:c.getDurations(),g=f?f.tasks.findIndex(p=>this.test&&p.taskId===this.test.tasks[0].task_id):null;f&&g===-1&&(f.tasks.push({taskId:this.test.tasks[0].task_id,started:this.app.timestamp()}),(u=this.signalManager)==null||u.setDurations(f)),(d=this.signalManager)==null||d.signalTask(this.test.tasks[0].task_id,"begin")}this.showTaskSection(),o.removeChild(a)},s}createTasksSection(e){this.container.style.fontFamily='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',Object.assign(this.container.style,He);const s=C("div","task_section_or",me),n=C("div","description_t_title_or",As),i=C("div","title",{fontSize:"13px",fontWeight:"500",lineHeight:"auto"},"Tasks"),r=C("div","icon",Ps,"-"),o=C("div","content",ge),l=C("div","pagination",Qi),a=C("div","taskCard",Us),h=C("div","taskText",Hs),c=C("div","taskDescription",er),u=C("div","taskButtons",sr),d=C("div","taskText",Hs);d.textContent="Your answer";const f=C("textarea","taskDescription",{resize:"vertical"}),g=C("div","inputArea",Us);g.append(d,f);const p=C("div","closePanelButton",js,"Collapse Panel"),y=C("div","nextButton",tr,"Done, Next");n.append(i,r),a.append(h,c),u.append(p,y),o.append(l,a,g,u),s.append(n,o);const E=()=>{const m=e[this.currentTaskIndex];h.textContent=m.title,c.textContent=m.description,m.allow_typing?g.style.display="flex":g.style.display="none"};e.forEach((m,w)=>{const k=C("span",`or_task_${w}`,{outline:"1px solid #efefef",fontSize:"13px",height:"24px",width:"24px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",borderRadius:"6.25em"},(w+1).toString());k.id=`or_task_${w}`,l.append(k)});const N=()=>{this.widgetTasksVisible=!this.widgetTasksVisible,r.textContent=this.widgetTasksVisible?"-":"+",Object.assign(o.style,this.widgetTasksVisible?ge:{display:"none"})};this.hideTaskSection=()=>(r.textContent="+",Object.assign(o.style,{display:"none"}),this.widgetTasksVisible=!1,!1),this.showTaskSection=()=>(r.textContent="-",Object.assign(o.style,ge),this.widgetTasksVisible=!0,!0);const T=()=>{const m=document.getElementById(`or_task_${this.currentTaskIndex}`);m&&Object.assign(m.style,Bs);for(let w=0;w<this.currentTaskIndex;w++){const k=document.getElementById(`or_task_${w}`);k&&Object.assign(k.style,Zi)}};return n.onclick=N,p.onclick=this.collapseWidget,y.onclick=()=>{var w,k,x,S;const m=e[this.currentTaskIndex].allow_typing?f.value:void 0;if(f.value="",(w=this.signalManager)==null||w.signalTask(e[this.currentTaskIndex].task_id,"done",m),this.currentTaskIndex<e.length-1){this.currentTaskIndex++,E();const b=(k=this.signalManager)==null?void 0:k.getDurations();b&&b.tasks.findIndex(_=>_.taskId===e[this.currentTaskIndex].task_id)===-1&&(b.tasks.push({taskId:e[this.currentTaskIndex].task_id,started:this.app.timestamp()}),(x=this.signalManager)==null||x.setDurations(b)),(S=this.signalManager)==null||S.signalTask(e[this.currentTaskIndex].task_id,"begin"),T()}else this.showEndSection();this.app.localStorage.setItem("or_uxt_task_index",this.currentTaskIndex.toString())},setTimeout(()=>{const m=document.getElementById("or_task_0");m&&Object.assign(m.style,Bs),E(),T()},1),s}showEndSection(){var l,a,h,c;let e=!0;(l=this.signalManager)==null||l.signalTest("done");const s=C("div","end_section_or",Yi),n=C("div","end_title_or",{fontSize:"1.25rem",fontWeight:"500"},"Thank you! 👍"),i=C("div","end_description_or",{},((a=this.test)==null?void 0:a.conclusion)??`Thank you for participating in our usability test. Your feedback has been captured and will be used to enhance our website.
287
289
 
288
- We appreciate your time and valuable input.`),r=C("div","end_button_or",Ps,"Submitting Feedback"),o=or();r.appendChild(o),(h=this.test)!=null&&h.reqMic||(c=this.test)!=null&&c.reqCamera?this.userRecorder.sendToAPI().then(()=>{r.removeChild(o),r.textContent="End Session",e=!1}).catch(u=>{console.error(u),r.removeChild(o),r.textContent="End Session",e=!1}):(r.removeChild(o),r.textContent="End Session",e=!1),this.taskSection&&this.container.removeChild(this.taskSection),this.descriptionSection&&this.container.removeChild(this.descriptionSection),this.stopButton&&this.stopButtonContainer&&this.container.removeChild(this.stopButtonContainer),r.onclick=()=>{e||(window.close(),document.body.removeChild(this.bg))},s.append(n,i,r),this.endSection=s,this.container.append(s)}}function Ws(t){return!!t&&t.nodeType!=null}function kt(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function ee(t){return t.nodeType===Node.ELEMENT_NODE}function hr(t){return t.nodeType===Node.COMMENT_NODE}function Tt(t){return t.nodeType===Node.TEXT_NODE}function ze(t){return t.nodeType===Node.DOCUMENT_NODE}function We(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function F(t,e){return t.localName===e}class ur{constructor(e,s){this.app=e,this.options=s,this.snapshots={},this.intervals=[],this.restartTracking=()=>{this.clear(),this.app.nodes.scanTree(this.captureCanvas)},this.captureCanvas=n=>{const i=this.app.nodes.getID(n);if(!i||!F(n,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!F(n,"canvas")||this.snapshots[i])return;new IntersectionObserver(l=>{l.forEach(a=>{a.isIntersecting&&(a.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(a.target,i):this.snapshots[i]&&(this.snapshots[i].paused=!0))})}).observe(n)},this.recordCanvas=(n,i)=>{const r=this.app.timestamp();this.snapshots[i]={images:[],createdAt:r,paused:!1,dummy:document.createElement("canvas")};const o=Fi(i.toString(),r);this.app.send(o);const l=h=>{dr(h,this.options.quality,this.snapshots[i].dummy,this.options.fixedScaling,this.fileExt,c=>{c&&(this.snapshots[i].images.push({id:this.app.timestamp(),data:c}),this.snapshots[i].images.length>9&&(this.sendSnaps(this.snapshots[i].images,i,this.snapshots[i].createdAt),this.snapshots[i].images=[]))})},a=setInterval(()=>{const h=this.app.nodes.getID(n),c=h?this.app.nodes.getNode(h):void 0;!c||!F(c,"canvas")||c!==n?(this.app.debug.log("Canvas element not in sync"),clearInterval(a)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{l(c)}):l(c))},this.interval);this.intervals.push(a)},this.fileExt=s.fileExt??"webp",this.interval=1e3/s.fps}startTracking(){setTimeout(()=>{this.app.nodes.scanTree(this.captureCanvas),this.app.nodes.attachNodeCallback(e=>{this.captureCanvas(e)})},500)}sendSnaps(e,s,n){if(Object.keys(this.snapshots).length===0)return;const i=new FormData;e.forEach(r=>{const o=r.data;o&&(i.append("snapshot",o,`${n}_${s}_${r.id}.${this.fileExt}`),this.options.isDebug&&fr(o,`${n}_${s}_${r.id}.${this.fileExt}`))}),fetch(this.app.options.ingestPoint+"/v1/web/images",{method:"POST",headers:{Authorization:`Bearer ${this.app.session.getSessionToken()??""}`},body:i}).then(()=>!0).catch(r=>{this.app.debug.error("error saving canvas",r)})}clear(){this.intervals.forEach(e=>clearInterval(e)),this.snapshots={}}}const qs={low:.35,medium:.55,high:.8};function dr(t,e="medium",s,n=!1,i,r){const o=`image/${i}`;if(n){const l=window.devicePixelRatio||1;s.width=t.width/l,s.height=t.height/l;const a=s.getContext("2d");if(!a)return"";a.clearRect(0,0,s.width,s.height),a.drawImage(t,0,0,s.width,s.height),s.toBlob(r,o,qs[e])}else t.toBlob(r,o,qs[e])}function fr(t,e){const s=URL.createObjectURL(t),n=document.createElement("a");n.href=s,n.download=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}const Te={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class pr{constructor(e=Te.Silent){this.shouldLog=s=>this.level>=s,this.log=(...s)=>{this.shouldLog(Te.Log)&&console.log(...s)},this.warn=(...s)=>{this.shouldLog(Te.Warnings)&&console.warn(...s)},this.error=(...s)=>{this.shouldLog(Te.Errors)&&console.error(...s)},this.level=e}}class gr{constructor(e){this.node_id=e,this.nodes=[],this.totalNodeAmount=0,this.nodeCallbacks=[],this.elementListeners=new Map,this.nextNodeId=0,this.scanTree=s=>{this.nodes.forEach(n=>s(n))}}syntheticMode(e){const i=99999999*e;if(i>9007199254740900)throw new Error("Placeholder id overflow");this.nextNodeId=i}attachNodeCallback(e){this.nodeCallbacks.push(e)}attachNodeListener(e,s,n,i=!0){const r=this.getID(e);if(r===void 0)return;vs(e,s,n,i);let o=this.elementListeners.get(r);o===void 0&&(o=[],this.elementListeners.set(r,o)),o.push([s,n,i])}registerNode(e){let s=e[this.node_id];const n=s===void 0;return n&&(s=this.nextNodeId,this.totalNodeAmount++,this.nextNodeId++,this.nodes[s]=e,e[this.node_id]=s),[s,n]}unregisterNode(e){const s=e[this.node_id];if(s!==void 0){e[this.node_id]=void 0,delete e[this.node_id],delete this.nodes[s];const n=this.elementListeners.get(s);n!==void 0&&(this.elementListeners.delete(s),n.forEach(i=>ks(e,i[0],i[1],i[2]))),this.totalNodeAmount--}return s}cleanTree(){for(let e=0;e<this.nodes.length;e++){const s=this.nodes[e];s&&!document.contains(s)&&this.unregisterNode(s)}}callNodeCallbacks(e,s){this.nodeCallbacks.forEach(n=>n(e,s))}getID(e){if(e)return e[this.node_id]}getNode(e){return this.nodes[e]}getNodeCount(){return this.totalNodeAmount}clear(){for(let e=0;e<this.nodes.length;e++){const s=this.nodes[e];s&&this.unregisterNode(s)}this.nextNodeId=0,this.nodes.length=0}}function It(t){if(hr(t))return!0;if(Tt(t))return!1;if(!ee(t))return!0;const e=t.tagName.toUpperCase();if(e==="LINK"){const s=t.getAttribute("rel"),n=t.getAttribute("as");return!(s!=null&&s.includes("stylesheet")||n==="style"||n==="font")}return e==="SCRIPT"||e==="NOSCRIPT"||e==="META"||e==="TITLE"||e==="BASE"}function xt(t){return We(t)?!0:!It(t)}var K;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(K||(K={}));class Et{constructor(e,s=!1){this.app=e,this.isTopContext=s,this.commited=[],this.recents=new Map,this.indexes=[],this.attributesMap=new Map,this.textSet=new Set,this.observer=ws(this.app.safe(n=>{for(const i of n){const r=i.target,o=i.type;if(!xt(r))continue;if(o==="childList"){for(let a=0;a<i.removedNodes.length;a++)xt(i.removedNodes[a])&&this.bindNode(i.removedNodes[a]);for(let a=0;a<i.addedNodes.length;a++)this.bindTree(i.addedNodes[a]);continue}const l=this.app.nodes.getID(r);if(l!==void 0){if(this.recents.has(l)||this.recents.set(l,K.Changed),o==="attributes"){const a=i.attributeName;if(a===null)continue;let h=this.attributesMap.get(l);h===void 0&&this.attributesMap.set(l,h=new Set),h.add(a);continue}if(o==="characterData"){this.textSet.add(l);continue}}}this.commitNodes()}))}clear(){this.commited.length=0,this.recents.clear(),this.indexes.length=1,this.attributesMap.clear(),this.textSet.clear()}sendNodeAttribute(e,s,n,i){if(kt(s)){n.substr(0,6)==="xlink:"&&(n=n.substr(6)),i===null?this.app.send(Is(e,n)):n==="href"?(i.length>1e5&&(i=""),this.app.send(ft(e,n,i,this.app.getBaseHref()))):this.app.attributeSender.sendSetAttribute(e,n,i);return}if(!(n==="src"||n==="srcset"||n==="integrity"||n==="crossorigin"||n==="autocomplete"||n.substr(0,2)==="on")&&!(n==="value"&&F(s,"input")&&s.type!=="button"&&s.type!=="reset"&&s.type!=="submit")){if(i===null){this.app.send(Is(e,n));return}if(n==="style"||n==="href"&&F(s,"link")){this.app.send(ft(e,n,i,this.app.getBaseHref()));return}(n==="href"||i.length>1e5)&&(i=""),this.app.attributeSender.sendSetAttribute(e,n,i)}}sendNodeData(e,s,n){if(F(s,"style")){this.app.send(Ni(e,n,this.app.getBaseHref()));return}n=this.app.sanitizer.sanitize(e,n),this.app.send(pi(e,n))}bindNode(e){const[s,n]=this.app.nodes.registerNode(e);n?this.recents.set(s,K.New):this.recents.get(s)!==K.New&&this.recents.set(s,K.Removed)}bindTree(e){if(!xt(e))return;this.bindNode(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:n=>(this.app.nodes.getID(n)!==void 0&&this.app.debug.error("! Node is already bound",n),It(n)||this.app.nodes.getID(n)!==void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT)},!1);for(;s.nextNode();)this.bindNode(s.currentNode)}unbindTree(e){const s=this.app.nodes.unregisterNode(e);if(s!==void 0&&this.recents.get(s)===K.Removed){this.app.send(fi(s));const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:l=>It(l)||this.app.nodes.getID(l)===void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},!1);let i=0;const r=this.app.nodes.getNodeCount();for(;n.nextNode();)i+=1,this.app.nodes.unregisterNode(n.currentNode);const o=Math.floor(i/r*100);o>30&&this.app.send(Pi(o))}}_commitNode(e,s){if(We(s))return!0;const n=s.parentNode;let i;if(!F(s,"html")||!this.isTopContext){if(n===null)return this.unbindTree(s),!1;if(i=this.app.nodes.getID(n),i===void 0)return this.unbindTree(s),!1;if(!this.commitNode(i))return this.unbindTree(s),!1;if(this.app.sanitizer.handleNode(e,i,s),this.app.sanitizer.isHidden(i))return!1}let r=s.previousSibling;for(;r!==null;){const c=this.app.nodes.getID(r);if(c!==void 0){this.commitNode(c),this.indexes[e]=this.indexes[c]+1;break}r=r.previousSibling}r===null&&(this.indexes[e]=0);const o=this.recents.get(e),l=o===K.New,a=this.indexes[e];if(a===void 0)throw"commitNode: missing node index";if(l){if(ee(s)){let c=s;if(i!==void 0){if(this.app.sanitizer.isHidden(e)){const u=c.clientWidth,d=c.clientHeight;c=s.cloneNode(),c.style.width=`${u}px`,c.style.height=`${d}px`}this.app.send(hi(e,i,a,c.tagName,kt(s)))}for(let u=0;u<c.attributes.length;u++){const d=c.attributes[u];this.sendNodeAttribute(e,c,d.nodeName,d.value)}}else Tt(s)&&(this.app.send(ui(e,i,a)),this.sendNodeData(e,n,s.data));return!0}o===K.Removed&&i!==void 0&&this.app.send(di(e,i,a));const h=this.attributesMap.get(e);if(h!==void 0){if(!ee(s))throw"commitNode: node is not an element";for(const c of h)this.sendNodeAttribute(e,s,c,s.getAttribute(c))}if(this.textSet.has(e)){if(!Tt(s))throw"commitNode: node is not a text";this.sendNodeData(e,n,s.data)}return!0}commitNode(e){const s=this.app.nodes.getNode(e);if(s===void 0)return!1;const n=this.commited[e];return n!==void 0?n:this.commited[e]=this._commitNode(e,s)}commitNodes(e=!1){let s;this.recents.forEach((n,i)=>{this.commitNode(i),n===K.New&&(s=this.app.nodes.getNode(i))&&this.app.nodes.callNodeCallbacks(s,e)}),this.clear()}observeRoot(e,s,n=e){this.observer.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1}),this.bindTree(n),s(this.app.nodes.getID(e)),this.commitNodes(!0)}disconnect(){this.observer.disconnect(),this.clear()}}class $s extends Et{observe(e){const s=e.contentDocument,n=this.app.nodes.getID(e);!s||n===void 0||this.observeRoot(s,i=>{if(i===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(pt(n,i))})}syntheticObserve(e,s){this.observeRoot(s,n=>{if(n===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(pt(e,n))})}}class mr extends Et{observe(e){const s=e.shadowRoot,n=this.app.nodes.getID(e);!s||n===void 0||this.observeRoot(s,i=>{if(i===void 0){this.app.debug.error("OpenReplay: Shadow Root was not bound");return}this.app.send(pt(n,i))})}}class br{constructor(){this.states=new Map}calcOffset(e){let s=0,n=0;if(e.parent&&([s,n]=this.calcOffset(e.parent)),!e.offset){const{left:o,top:l}=e.iFrame.getBoundingClientRect();e.offset=[o,l]}const[i,r]=e.offset;return[s+i,n+r]}getDocumentOffset(e){const s=this.states.get(e);return s?this.calcOffset(s):[0,0]}observe(e){var l;const s=e.contentDocument;if(!s)return;const n=e.ownerDocument,i=this.states.get(n),r={offset:null,iFrame:e,parent:i||null,clear:()=>{var a;n.removeEventListener("scroll",o),(a=n.defaultView)==null||a.removeEventListener("resize",o)}},o=()=>{r.offset=null};n.addEventListener("scroll",o),(l=n.defaultView)==null||l.addEventListener("resize",o),this.states.set(s,r)}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}}const Ct=G?Element.prototype.attachShadow:()=>new ShadowRoot;class yr extends Et{constructor(e,s){super(e,!0),this.iframeOffsets=new br,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},s),this.app.nodes.attachNodeCallback(n=>{F(n,"iframe")&&(this.options.captureIFrames&&!oe(n,"obscured")||oe(n,"capture"))&&this.handleIframe(n)}),this.app.nodes.attachNodeCallback(n=>{ee(n)&&n.shadowRoot!==null&&this.handleShadowRoot(n.shadowRoot)})}attachContextCallback(e){this.contextCallbacks.push(e)}getDocumentOffset(e){return this.iframeOffsets.getDocumentOffset(e)}handleIframe(e){let s=null;const n=this.app.safe(()=>setTimeout(()=>{if(this.app.nodes.getID(e)===void 0||!ti(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==s){const l=new $s(this.app);this.iframeObservers.push(l),l.observe(e),s=o,this.iframeOffsets.observe(e)}r&&r===r.window&&!this.contextsSet.has(r)&&(this.contextsSet.add(r),this.contextCallbacks.forEach(l=>l(r)))},100));e.addEventListener("load",n),n()}handleShadowRoot(e){const s=new mr(this.app);this.shadowRootObservers.push(s),s.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const s=Ct.apply(this,arguments);return e.handleShadowRoot(s),s},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(li()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,s){const n=this;Element.prototype.attachShadow=function(){const r=Ct.apply(this,arguments);return n.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(s);const i=new $s(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=Ct,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var qe;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(qe||(qe={}));const Sr=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class wr{constructor(e,s){this.app=e,this.obscured=new Set,this.hidden=new Set,this.options=Object.assign({obscureTextEmails:!0,obscureTextNumbers:!1},s)}handleNode(e,s,n){if((this.obscured.has(s)||ee(n)&&(oe(n,"masked")||oe(n,"obscured")))&&this.obscured.add(e),(this.hidden.has(s)||ee(n)&&(oe(n,"htmlmasked")||oe(n,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&ee(n)){const i=this.options.domSanitizer(n);i===qe.Obscured&&this.obscured.add(e),i===qe.Hidden&&this.hidden.add(e)}}sanitize(e,s){return this.obscured.has(e)?Sr(s):(this.options.obscureTextNumbers&&(s=s.replace(/\d/g,"0")),this.options.obscureTextEmails&&(s=s.replace(/^\w+([+.-]\w+)*@\w+([.-]\w+)*\.\w{2,3}$/g,n=>{const[i,r]=n.split("@"),[o,l]=r.split(".");return`${ht(i)}@${ht(o)}.${ht(l)}`})),s)}isObscured(e){return this.obscured.has(e)}isHidden(e){return this.hidden.has(e)}getInnerTextSecure(e){const s=this.app.nodes.getID(e);return s?this.sanitize(s,e.innerText):""}clear(){this.obscured.clear(),this.hidden.clear()}}class vr{constructor(e,s){this.app=e,this.options=s,this.metadata={},this.userID=null,this.callbacks=[],this.timestamp=0,this.createTabId()}attachUpdateCallback(e){this.callbacks.push(e)}handleUpdate(e){e.userID==null&&delete e.userID,e.sessionID==null&&delete e.sessionID,this.callbacks.forEach(s=>s(e))}assign(e){e.userID!==void 0&&(this.userID=e.userID),e.metadata!==void 0&&Object.entries(e.metadata).forEach(([s,n])=>this.metadata[s]=n),e.sessionID!==void 0&&(this.sessionID=e.sessionID),e.timestamp!==void 0&&(this.timestamp=e.timestamp),e.projectID!==void 0&&(this.projectID=e.projectID),this.handleUpdate(e)}setMetadata(e,s){this.metadata[e]=s,this.handleUpdate({metadata:{[e]:s}})}setUserID(e){this.userID=e,this.handleUpdate({userID:e})}setUserInfo(e){this.userInfo=e}getPageNumber(){const e=this.app.sessionStorage.getItem(this.options.session_pageno_key);if(e!=null)return parseInt(e)}incPageNo(){let e=this.getPageNumber();return e===void 0?e=0:e++,this.app.sessionStorage.setItem(this.options.session_pageno_key,e.toString()),e}getSessionToken(){return this.app.sessionStorage.getItem(this.options.session_token_key)||void 0}setSessionToken(e){this.app.sessionStorage.setItem(this.options.session_token_key,e)}applySessionHash(e){const s=decodeURI(e).split("&");let n=e,i="100500";s.length==2&&([i,n]=s),!(!i||!n)&&(this.app.sessionStorage.setItem(this.options.session_token_key,n),this.app.sessionStorage.setItem(this.options.session_pageno_key,i))}getSessionHash(){const e=this.getPageNumber(),s=this.getSessionToken();if(!(e===void 0||s===void 0))return encodeURI(String(e)+"&"+s)}getTabId(){return this.tabId||this.createTabId(),this.tabId}regenerateTabId(){const e=si(12);this.app.sessionStorage.setItem(this.options.session_tabid_key,e),this.tabId=e}createTabId(){const e=this.app.sessionStorage.getItem(this.options.session_tabid_key);e?this.tabId=e:this.regenerateTabId()}getInfo(){return{sessionID:this.sessionID,metadata:this.metadata,userID:this.userID,timestamp:this.timestamp,projectID:this.projectID}}reset(){this.app.sessionStorage.removeItem(this.options.session_token_key),this.metadata={},this.userID=null,this.sessionID=void 0,this.timestamp=0}}function kr(t,e){let s=0;return()=>{s++>=e&&(s=0,t())}}class Tr{constructor(e){this.app=e,this.timer=null,this.callbacks=[]}attach(e,s=0,n=!0,i){i&&(e=e.bind(i)),n&&(e=this.app.safe(e)),this.callbacks.unshift(s?kr(e,s):e)-1}start(){this.timer===null&&(this.timer=setInterval(()=>this.callbacks.forEach(e=>{e&&e()}),30))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}}const Ie="canceled",Vs="or_uxt_active",Nt="or_buffer_1",re=t=>({reason:t,success:!1}),Ir=t=>({...t,success:!0});var B;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(B||(B={}));const Xs="https://api.openreplay.com/ingest";function _t(){const t=new Date().getTimezoneOffset()*-1,e=t>=0?"+":"-",s=Math.floor(Math.abs(t)/60),n=Math.abs(t)%60;return`UTC${e}${String(s).padStart(2,"0")}:${String(n).padStart(2,"0")}`}const xr=t=>new Promise(e=>setTimeout(e,t)),q={ask:"never-gonna-give-you-up",resp:"never-gonna-let-you-down",reg:"never-gonna-run-around-and-desert-you",iframeSignal:"never-gonna-make-you-cry",iframeId:"never-gonna-say-goodbye",iframeBatch:"never-gonna-tell-a-lie-and-hurt-you"};class Er{constructor(e,s,n,i,r){this.signalError=i,this.insideIframe=r,this.messages=[],this.bufferedMessages1=[],this.bufferedMessages2=[],this.startCallbacks=[],this.stopCallbacks=[],this.commitCallbacks=[],this.activityState=B.NotActive,this.version="14.0.4",this.socketMode=!1,this.compressionThreshold=24*1e3,this.bc=null,this.canvasRecorder=null,this.conditionsManager=null,this.canStart=!1,this.rootId=null,this.pageFrames=[],this.frameOderNumber=0,this.initialHostName=location.hostname,this.startTimeout=null,this.coldStartCommitN=0,this.delay=0,this.coldInterval=null,this.orderNumber=0,this.coldStartTs=0,this.singleBuffer=!1,this.onSessionSent=()=>{},this.restartCanvasTracking=()=>{var a;(a=this.canvasRecorder)==null||a.restartTracking()},this.flushBuffer=async a=>new Promise(h=>{let c=!1;const u=[a.shift()];for(;!c;){const d=a[0];!d||d[0]===0?c=!0:u.push(a.shift())}this.postToWorker(u),h(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(n).findIndex(a=>["fixedCanvasScaling","disableCanvas"].includes(a))!==-1&&(console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.'),n={...n,canvas:{__save_canvas_locally:n.__save_canvas_locally,fixedCanvasScaling:n.fixedCanvasScaling,disableCanvas:n.disableCanvas}}),this.networkOptions=n.network;const o={revID:"",node_id:"__openreplay_id",session_token_key:"__openreplay_token",session_pageno_key:"__openreplay_pageno",session_reset_key:"__openreplay_reset",session_tabid_key:"__openreplay_tabid",local_uuid_key:"__openreplay_uuid",ingestPoint:Xs,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Te.Silent,__save_canvas_locally:!1,localStorage:null,sessionStorage:null,disableStringDict:!1,forceSingleTab:!1,assistSocketHost:"",fixedCanvasScaling:!1,disableCanvas:!1,captureIFrames:!0,obscureTextEmails:!0,obscureTextNumbers:!1,crossdomain:{parentDomain:"*"},canvas:{disableCanvas:!1,fixedCanvasScaling:!1,__save_canvas_locally:!1,useAnimationFrame:!1}};if(this.options=Ts(o,n),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const a=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${a}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new wr(this,n),this.nodes=new gr(this.options.node_id),this.observer=new yr(this,n),this.ticker=new Tr(this),this.ticker.attach(()=>this.commit()),this.debug=new pr(this.options.__debug__),this.session=new vr(this,this.options),this.attributeSender=new Kn(this,!!this.options.disableStringDict),this.featureFlags=new Qn(this),this.tagWatcher=new ji(this.sessionStorage,this.debug.error,a=>{this.send(Bi(a))}),this.session.attachUpdateCallback(({userID:a,metadata:h})=>{a!=null&&this.send(Ti(a)),h!=null&&Object.entries(h).forEach(([c,u])=>this.send(xs(c,u)))}),s!=null&&this.session.applySessionHash(s),this.initWorker();const l=this.session.getTabId();if(this.insideIframe){const a=c=>{const{data:u}=c;u.line===q.iframeId&&(this.rootId=u.id,this.session.setSessionToken(u.token),this.frameOderNumber=u.frameOrderNumber,this.debug.log("starting iframe tracking",u),this.allowAppStart())};window.addEventListener("message",a),this.attachStopCallback(()=>{window.removeEventListener("message",a)});const h=this.initialHostName;window.parent.postMessage({line:q.iframeSignal,source:l,context:this.contextId,domain:h},"*")}else{let a=0;const h=c=>{const{data:u}=c;if(u.line===q.iframeSignal){const d=u.domain,f=Array.from(document.querySelectorAll("iframe"));this.pageFrames=f,(async()=>{let p=0;for(;p<10;){const y=this.checkNodeId(f,d);if(y){this.waitStarted().then(()=>{var T;a++;const E=this.session.getSessionToken(),N={line:q.iframeId,context:this.contextId,domain:d,id:y,token:E,frameOrderNumber:a};this.debug.log("iframe_data",N),(T=c.source)==null||T.postMessage(N,"*")}).catch(console.error),p=10;break}p++,await xr(100)}})()}if(u.line===q.iframeBatch){const f=u.messages.map(g=>{if(g[0]===20){let p=g;return this.pageFrames.forEach(y=>{if(y.dataset.domain===c.data.domain){const[E,N,T]=g,{left:m,top:w}=y.getBoundingClientRect();p=[E,N+m,T+w]}}),p}if(g[0]===68){let p=g;return this.pageFrames.forEach(y=>{if(y.dataset.domain===c.data.domain){const[E,N,T,m,w,k,x]=g,{left:S,top:b,width:_,height:M}=y.getBoundingClientRect(),O=document.documentElement.scrollWidth,D=document.documentElement.scrollHeight,v=k/100*_+S,I=x/100*M+b,A=v/O,P=I/D;p=[E,N,T,m,w,Math.round(A*1e3)/10,Math.round(P*1e3)/10]}}),p}return g});this.messages.push(...f)}};window.addEventListener("message",h),this.attachStopCallback(()=>{window.removeEventListener("message",h)})}this.bc!==null&&(this.bc.postMessage({line:q.ask,source:l,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=a=>{if(a.data.context!==this.contextId){if(a.data.line===q.resp){const h=a.data.token;this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===q.reg){const h=a.data.token;this.session.regenerateTabId(),this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===q.ask){const h=this.session.getSessionToken();h&&this.bc&&this.bc.postMessage({line:a.data.source===l?q.reg:q.resp,token:h,source:l,context:this.contextId})}}})}allowAppStart(){this.canStart=!0,this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}checkNodeId(e,s){for(const n of e)if(n.dataset.domain===s)return n[this.options.node_id];return null}initWorker(){try{this.worker=new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=250,h,r){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.pageNo=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.lastBatchNum=0,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){if(this.busy||!this.token)this.queue.push(t);else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}else this.busy=!1}retry(t,s,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s,i)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s,i){const e=i?.toString().replace(/^([^_]+)_([^_]+).*/,"$1_$2_$3");this.busy=!0;const n={Authorization:`Bearer ${this.token}`};s&&(n["Content-Encoding"]="gzip"),null!==this.token?fetch(`${this.ingestURL}?batch=${this.pageNo??"noPageNum"}_${e??"noBatchNum"}`,{body:t,method:"POST",headers:n,keepalive:t.length<65536}).then((e=>{if(401===e.status)return this.busy=!1,void this.onUnauthorised();e.status>=400?this.retry(t,s,`${i??"noBatchNum"}_network:${e.status}`):(this.attemptsCount=0,this.sendNext())})).catch((e=>{console.warn("OpenReplay:",e),this.retry(t,s,`${i??"noBatchNum"}_reject:${e.message}`)})):setTimeout((()=>{this.sendBatch(t,s,`${i??"noBatchNum"}_newToken`)}),500)}sendCompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!0,s)}sendUncompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if("q_end"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){return new Promise((t=>{u=h.Stopping,null!==l&&(clearInterval(l),l=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive,t(null)}),100)}))}function g(){u!==h.Stopped&&(postMessage("a_stop"),c().then((()=>{postMessage("a_start")})))}let p,l=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),void c().then((()=>{u=h.Stopped}));if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Compressed batch."),void g();s.batch&&r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Uncompressed batch."),void g();s.batch&&r.sendUncompressed(s.batch)}return"start"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{g()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])}),s.pageNo),a=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:"queue_empty"}))),null===l&&(l=setInterval(o,1e4)),u=h.Active):"auth"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("OR WebWorker: writer not initialised. Received auth."),void g()):(console.debug("OR WebWorker: sender not initialised. Received auth."),void g()):void 0}if(a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?p=setTimeout((()=>g()),18e5):clearTimeout(p)),t.writeMessage(s)}))}else postMessage("not_init"),g()}else o()}else o()};'],{type:"text/javascript"}))),this.worker.onerror=s=>{this._debug("webworker_error",s)},this.worker.onmessage=({data:s})=>{this.handleWorkerMsg(s)};const e=()=>{this.worker&&this.worker.postMessage(null)};this.attachEventListener(window,"beforeunload",e,!1),this.attachEventListener(document.body,"mouseleave",e,!1,!1),this.attachEventListener(document,"visibilitychange",e,!1)}catch(e){this._debug("worker_start",e)}}handleWorkerMsg(e){var s;if(e==="a_stop")this.stop(!1);else if(e==="a_start")this.start({},!0);else if(e==="not_init")this.debug.warn("OR WebWorker: writer not initialised. Restarting tracker");else if(e.type==="failure")this.stop(!1),this.debug.error("worker_failed",e.reason),this._debug("worker_failed",e.reason);else if(e.type==="compress"){const n=e.batch;n.byteLength>this.compressionThreshold?Vn(e.batch,{mtime:0},(r,o)=>{var l,a;r?(this.debug.error("Openreplay compression error:",r),(l=this.worker)==null||l.postMessage({type:"uncompressed",batch:n})):(a=this.worker)==null||a.postMessage({type:"compressed",batch:o})}):(s=this.worker)==null||s.postMessage({type:"uncompressed",batch:n})}else e.type==="queue_empty"&&this.onSessionSent()}_debug(e,s){this.options.__debug_report_edp!==null&&fetch(this.options.__debug_report_edp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e,error:`${s}`})}),this.debug.error("OpenReplay error: ",e,s)}send(e,s=!1){var n;this.activityState!==B.NotActive&&(this.activityState===B.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(n=this.conditionsManager)==null||n.processMessage(e)):this.messages.push(e),this.activityState===B.Active&&s&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(ce(this.session.getTabId())),this.messages.unshift(ae(this.timestamp())),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}if(!(this.worker===void 0||!this.messages.length)){if(this.insideIframe){window.parent.postMessage({line:q.iframeBatch,messages:this.messages,domain:this.initialHostName},"*"),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}try{oi(()=>{var e;this.messages.unshift(ce(this.session.getTabId())),this.messages.unshift(ae(this.timestamp())),(e=this.worker)==null||e.postMessage(this.messages),this.commitCallbacks.forEach(s=>s(this.messages)),this.messages.length=0})}catch(e){this._debug("worker_commit",e),this.stop(!0),setTimeout(()=>{this.start()},500)}}}_cStartCommit(){this.coldStartCommitN+=1,this.coldStartCommitN===2&&(this.bufferedMessages1.push(ae(this.timestamp())),this.bufferedMessages1.push(ce(this.session.getTabId())),this.bufferedMessages2.push(ae(this.timestamp())),this.bufferedMessages2.push(ce(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===B.ColdStart?this._cStartCommit():this._nCommit()}postToWorker(e){var s;(s=this.worker)==null||s.postMessage(e),this.commitCallbacks.forEach(n=>n(e)),e.length=0}timestamp(){return V()+this.delay}safe(e){const s=this;return function(...n){try{e.apply(this,n)}catch(i){s._debug("safe_fn_call",i)}}}attachCommitCallback(e){this.commitCallbacks.push(e)}attachStartCallback(e,s=!1){s&&(e=this.safe(e)),this.startCallbacks.push(e)}attachStopCallback(e,s=!1){s&&(e=this.safe(e)),this.stopCallbacks.push(e)}attachEventListener(e,s,n,i=!0,r=!0){i&&(n=this.safe(n));const o=()=>e?vs(e,s,n,r):null,l=()=>e?ks(e,s,n,r):null;this.attachStartCallback(o,i),this.attachStopCallback(l,i)}checkRequiredVersion(e){const s=e.split(/[.-]/),n=this.version.split(/[.-]/);for(let i=0;i<3;i++){if(isNaN(Number(n[i]))||isNaN(Number(s[i])))return!1;if(Number(n[i])>Number(s[i]))return!0;if(Number(n[i])<Number(s[i]))return!1}return!0}getTrackerInfo(){return{userUUID:this.localStorage.getItem(this.options.local_uuid_key),projectKey:this.projectKey,revID:this.revID,trackerVersion:this.version,isSnippet:this.options.__is_snippet}}getSessionInfo(){return{...this.session.getInfo(),...this.getTrackerInfo()}}getSessionToken(){return this.session.getSessionToken()}getSessionID(){return this.session.getInfo().sessionID||void 0}getSessionURL(e){const{projectID:s,sessionID:n,timestamp:i}=this.session.getInfo();if(!s||!n){this.debug.error("OpenReplay error: Unable to build session URL");return}const r=this.options.ingestPoint,a=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${s}/session/${n}`);if(e!=null&&e.withCurrentTime){const h=V()-i;return`${a}?jumpto=${h}`}return a}getHost(){return new URL(this.options.ingestPoint).host}getProjectKey(){return this.projectKey}getBaseHref(){var e,s;return typeof this.options.resourceBaseHref=="string"?this.options.resourceBaseHref:(this.options.resourceBaseHref,document.baseURI?document.baseURI:((s=(e=document.head)==null?void 0:e.getElementsByTagName("base")[0])==null?void 0:s.getAttribute("href"))||location.origin+location.pathname)}resolveResourceURL(e){const s=new URL(this.getBaseHref());return s.pathname+="/"+new URL(e).pathname,s.pathname.replace(/\/+/g,"/"),s.toString()}isServiceURL(e){return e.startsWith(this.options.ingestPoint)}active(){return this.activityState===B.Active}resetNextPageSession(e){e?this.sessionStorage.setItem(this.options.session_reset_key,"t"):this.sessionStorage.removeItem(this.options.session_reset_key)}checkSessionToken(e){const s=this.sessionStorage.getItem(this.options.session_reset_key)!==null,n=e||s,i=this.session.getSessionToken();return n||!i}async coldStart(e={},s){this.singleBuffer=!1;const n=1e3,i=this.checkSessionToken(e.forceNew);s&&await this.setupConditionalStart(e);const r=()=>{this.orderNumber+=1,lt(),this.coldStartTs=V(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(ae(this.timestamp())),this.bufferedMessages1.push(ce(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(ae(this.timestamp())),this.bufferedMessages2.push(ce(this.session.getTabId()))),this.stop(!1),this.activityState=B.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata}),i||(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(Ue(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*n),r()}async setupConditionalStart(e){var d,f;this.conditionsManager=new Jn(this,e);const s=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:V(),doNotRecord:!0,bufferDiff:0,userID:this.session.getInfo().userID,token:void 0,deviceMemory:yt,jsHeapSizeLimit:St,timezone:_t(),width:window.screen.width,height:window.screen.height})}),{token:n,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,projectID:c}=await s.json();this.session.assign({projectID:c}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});const u={sessionToken:n,userUUID:"",sessionID:""};this.startCallbacks.forEach(g=>g(u)),await((d=this.conditionsManager)==null?void 0:d.fetchConditions(c,n)),await this.featureFlags.reloadFlags(n),await this.tagWatcher.fetchTags(this.options.ingestPoint,n),(f=this.conditionsManager)==null||f.processFlags(this.featureFlags.flags)}offlineRecording(e={},s){this.onSessionSent=s,this.singleBuffer=!0;const n=this.checkSessionToken(e.forceNew);lt(),this.coldStartTs=V();const i=this.localStorage.getItem(Nt);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(Nt)}this.bufferedMessages1.push(ae(this.timestamp())),this.bufferedMessages1.push(ce(this.session.getTabId())),this.activityState=B.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r={sessionToken:"",userUUID:"",sessionID:""};return this.startCallbacks.forEach(o=>o(r)),n||this.send(Ue(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(Nt,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var d,f;this.stop(!1);const e=V();(d=this.worker)==null||d.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:this.coldStartTs,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const s=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:e,doNotRecord:!1,bufferDiff:e-this.coldStartTs,userID:this.session.getInfo().userID,token:void 0,deviceMemory:yt,jsHeapSizeLimit:St,timezone:_t()})}),{token:n,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,beaconSizeLimit:c,projectID:u}=await s.json();for((f=this.worker)==null||f.postMessage({type:"auth",token:n,beaconSizeLimit:c}),this.session.assign({projectID:u}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});this.bufferedMessages1.length>0;)await this.flushBuffer(this.bufferedMessages1);this.postToWorker([["q_end"]]),this.clearBuffers()}async _start(e={},s=!1,n){const i=this.activityState===B.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const a="No worker found: perhaps, CSP is not set.";return this.signalError(a,[]),Promise.resolve(re(a))}if(this.activityState===B.Active||this.activityState===B.Starting)return Promise.resolve(re("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=B.Starting,i||lt(),e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r=V();this.worker.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:i?this.coldStartTs:r,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const o=this.session.getSessionToken(),l=this.checkSessionToken(e.forceNew);this.sessionStorage.removeItem(this.options.session_reset_key),this.debug.log("OpenReplay: starting session; need new session id?",l,"session token: ",o);try{const a=await window.fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:r,doNotRecord:!1,bufferDiff:r-this.coldStartTs,userID:this.session.getInfo().userID,token:l?void 0:o,deviceMemory:yt,jsHeapSizeLimit:St,timezone:_t(),condition:n,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(a.status!==200){const v=await a.text(),I=v===Ie?Ie:`Server error: ${a.status}. ${v}`;return re(I)}if(!this.worker){const v="no worker found after start request (this should not happen in real world)";return this.signalError(v,[]),re(v)}const{token:h,userUUID:c,projectID:u,beaconSizeLimit:d,compressionThreshold:f,delay:g,sessionID:p,startTimestamp:y,userBrowser:E,userCity:N,userCountry:T,userDevice:m,userOS:w,userState:k,canvasEnabled:x,canvasQuality:S,canvasFPS:b,assistOnly:_}=await a.json();if(typeof h!="string"||typeof c!="string"||typeof y!="number"&&typeof y<"u"||typeof p!="string"||typeof g!="number"||typeof d!="number"&&typeof d<"u"){const v=`Incorrect server response: ${JSON.stringify(a)}`;return this.signalError(v,[]),re(v)}this.delay=g,this.session.setSessionToken(h),this.session.setUserInfo({userBrowser:E,userCity:N,userCountry:T,userDevice:m,userOS:w,userState:k}),this.session.assign({sessionID:p,timestamp:y||r,projectID:u}),_?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:h,beaconSizeLimit:d}),!l&&h===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(Ue(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([v,I])=>this.send(xs(v,I))),this.localStorage.setItem(this.options.local_uuid_key,c),this.compressionThreshold=f;const M={sessionToken:h,userUUID:c,sessionID:p};if(this.startCallbacks.forEach(v=>v(M)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,h),this.activityState=B.Active,x&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new ur(this,{fps:b,quality:S,isDebug:this.options.canvas.__save_canvas_locally,fixedScaling:this.options.canvas.fixedCanvasScaling,useAnimationFrame:this.options.canvas.useAnimationFrame}),this.canvasRecorder.startTracking()),i){const v=this.bufferedMessages1.length>this.bufferedMessages2.length?this.bufferedMessages1:this.bufferedMessages2;for(;v.length>0;)await this.flushBuffer(v);this.clearBuffers(),this.commit()}else this.insideIframe&&this.rootId?this.observer.crossdomainObserve(this.rootId,this.frameOderNumber):this.observer.observe(),this.ticker.start();this.uxtManager=this.uxtManager?this.uxtManager:new lr(this,Vs);let O;const D=this.localStorage.getItem(Vs);if(D&&(O=parseInt(D,10)),location!=null&&location.search){const v=new URLSearchParams(location.search);if(v.has("oruxt")){const I=v.get("oruxt");O=I?parseInt(I,10):void 0}}return O&&(this.uxtManager.isActive?this.onUxtCb.forEach(v=>v(O)):this.uxtManager.getTest(O,h,!!D).then(v=>{v&&this.onUxtCb.forEach(I=>I(v))})),Ir(M)}catch(a){if(this.stop(),this.session.reset(),a===Ie)return this.signalError(Ie,[]),re(Ie);this._debug("session_start",a);const h=a instanceof Error?a.message:a.toString();return this.signalError(h,[]),re(h)}}addOnUxtCb(e){this.onUxtCb.push(e)}getUxtId(){var e;return(e=this.uxtManager)==null?void 0:e.getTestId()}async waitStart(){return new Promise(e=>{const s=()=>{this.canStart?e(!0):setTimeout(s,25)};s()})}async waitStarted(){return new Promise(e=>{const s=()=>{this.activityState===B.Active?e(!0):setTimeout(s,25)};s()})}async start(...e){return this.activityState===B.Active||this.activityState===B.Starting?Promise.resolve(re("OpenReplay: trying to call `start()` on the instance that has been started already.")):document.hidden?new Promise(s=>{const n=async()=>{document.hidden||(await this.waitStart(),document.removeEventListener("visibilitychange",n),s(this._start(...e)))};document.addEventListener("visibilitychange",n)}):(await this.waitStart(),this._start(...e))}forceFlushBatch(){var e;(e=this.worker)==null||e.postMessage("forceFlushBatch")}getTabId(){return this.session.getTabId()}clearBuffers(){this.bufferedMessages1.length=0,this.bufferedMessages2.length=0}trackWs(e){const s=e;return(n,i,r="down")=>{typeof n!="string"||typeof i!="string"||i.length>5*1024*1024||n.length>255||this.send(Mi("websocket",s,i,this.timestamp(),r,n))}}stop(e=!0){var s;if(this.activityState!==B.NotActive)try{this.attributeSender.clear(),this.sanitizer.clear(),this.observer.disconnect(),this.nodes.clear(),this.ticker.stop(),this.stopCallbacks.forEach(n=>n()),this.debug.log("OpenReplay tracking stopped."),this.tagWatcher.clear(),this.worker&&e&&this.worker.postMessage("stop"),(s=this.canvasRecorder)==null||s.clear()}finally{this.activityState=B.NotActive}}}function Cr(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const s=()=>t.send(Ei(Math.round(e.downlink*1e3),e.type||"unknown"));s(),e.addEventListener("change",s)}const Gs=G&&"InstallTrigger"in window?t=>t.message+`
289
- `+t.stack:t=>t.stack||t.message;function Ot(t){return t===void 0?"undefined":t===null?"null":t instanceof Error?Gs(t):Array.isArray(t)?`Array(${t.length})`:String(t)}function Nr(t){return typeof t!="number"?"NaN":t.toString()}function _r(t){return typeof t!="number"?"NaN":Math.floor(t).toString()}function Ks(t){if(t===void 0)return"undefined";if(t===null)return"null";if(t instanceof Error)return Gs(t);if(Array.isArray(t)){const e=t.length,s=t.slice(0,10).map(Ot).join(", ");return`Array(${e})[${s}]`}if(typeof t=="object"){const e=[];let s=0;for(const n in t){if(++s===10)break;const i=t[n];e.push(n+": "+Ot(i))}return"{"+e.join(", ")+"}"}return t.toString()}function Or(t){return typeof t[0]=="string"&&t.unshift(t.shift().replace(/%(o|s|f|d|i)/g,(e,s)=>{const n=t.shift();if(n===void 0)return e;switch(s){case"o":return Ks(n);case"s":return Ot(n);case"f":return Nr(n);case"d":case"i":return _r(n);default:return e}})),t.map(Ks).join(" ")}const Js=["log","info","warn","error","debug","assert"];function Rr(t,e){const s=Object.assign({consoleMethods:Js,consoleThrottling:30},e);if(!Array.isArray(s.consoleMethods)||s.consoleMethods.length===0)return;const n=t.safe((a,h)=>t.send(Si(a,Or(h))));let i=0;const r=()=>{i=0};t.attachStartCallback(r),t.ticker.attach(r,33,!1);const o=(a,h)=>{const c={apply:function(u,d,f){Reflect.apply(u,h,f),i=i+1,!(i>s.consoleThrottling)&&n(u.name,f)}};s.consoleMethods.forEach(u=>{if(Js.indexOf(u)===-1){t.debug.error(`OpenReplay: unsupported console method "${u}"`);return}const d=h.console[u];a[u]=new Proxy(d,c)})},l=t.safe(a=>o(a.console,a));l(window),t.observer.attachContextCallback(l)}var Ys=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qs={exports:{}},Rt={exports:{}},Zs;function Mr(){return Zs||(Zs=1,function(t,e){(function(s,n){t.exports=n()})(Ys,function(){function s(p){return!isNaN(parseFloat(p))&&isFinite(p)}function n(p){return p.charAt(0).toUpperCase()+p.substring(1)}function i(p){return function(){return this[p]}}var r=["isConstructor","isEval","isNative","isToplevel"],o=["columnNumber","lineNumber"],l=["fileName","functionName","source"],a=["args"],h=["evalOrigin"],c=r.concat(o,l,a,h);function u(p){if(p)for(var y=0;y<c.length;y++)p[c[y]]!==void 0&&this["set"+n(c[y])](p[c[y]])}u.prototype={getArgs:function(){return this.args},setArgs:function(p){if(Object.prototype.toString.call(p)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=p},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(p){if(p instanceof u)this.evalOrigin=p;else if(p instanceof Object)this.evalOrigin=new u(p);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var p=this.getFileName()||"",y=this.getLineNumber()||"",E=this.getColumnNumber()||"",N=this.getFunctionName()||"";return this.getIsEval()?p?"[eval] ("+p+":"+y+":"+E+")":"[eval]:"+y+":"+E:N?N+" ("+p+":"+y+":"+E+")":p+":"+y+":"+E}},u.fromString=function(y){var E=y.indexOf("("),N=y.lastIndexOf(")"),T=y.substring(0,E),m=y.substring(E+1,N).split(","),w=y.substring(N+1);if(w.indexOf("@")===0)var k=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(w,""),x=k[1],S=k[2],b=k[3];return new u({functionName:T,args:m||void 0,fileName:x,lineNumber:S||void 0,columnNumber:b||void 0})};for(var d=0;d<r.length;d++)u.prototype["get"+n(r[d])]=i(r[d]),u.prototype["set"+n(r[d])]=function(p){return function(y){this[p]=!!y}}(r[d]);for(var f=0;f<o.length;f++)u.prototype["get"+n(o[f])]=i(o[f]),u.prototype["set"+n(o[f])]=function(p){return function(y){if(!s(y))throw new TypeError(p+" must be a Number");this[p]=Number(y)}}(o[f]);for(var g=0;g<l.length;g++)u.prototype["get"+n(l[g])]=i(l[g]),u.prototype["set"+n(l[g])]=function(p){return function(y){this[p]=String(y)}}(l[g]);return u})}(Rt)),Rt.exports}(function(t,e){(function(s,n){t.exports=n(Mr())})(Ys,function(n){var i=/(^|@)\S+:\d+/,r=/^\s*at .*(\S+:\d+|\(native\))/m,o=/^(eval@)?(\[native code])?$/;return{parse:function(a){if(typeof a.stacktrace<"u"||typeof a["opera#sourceloc"]<"u")return this.parseOpera(a);if(a.stack&&a.stack.match(r))return this.parseV8OrIE(a);if(a.stack)return this.parseFFOrSafari(a);throw new Error("Cannot parse given Error object")},extractLocation:function(a){if(a.indexOf(":")===-1)return[a];var h=/(.+?)(?::(\d+))?(?::(\d+))?$/,c=h.exec(a.replace(/[()]/g,""));return[c[1],c[2]||void 0,c[3]||void 0]},parseV8OrIE:function(a){var h=a.stack.split(`
290
+ We appreciate your time and valuable input.`),r=C("div","end_button_or",Ls,"Submitting Feedback"),o=lr();r.appendChild(o),(h=this.test)!=null&&h.reqMic||(c=this.test)!=null&&c.reqCamera?this.userRecorder.sendToAPI().then(()=>{r.removeChild(o),r.textContent="End Session",e=!1}).catch(u=>{console.error(u),r.removeChild(o),r.textContent="End Session",e=!1}):(r.removeChild(o),r.textContent="End Session",e=!1),this.taskSection&&this.container.removeChild(this.taskSection),this.descriptionSection&&this.container.removeChild(this.descriptionSection),this.stopButton&&this.stopButtonContainer&&this.container.removeChild(this.stopButtonContainer),r.onclick=()=>{e||(window.close(),document.body.removeChild(this.bg))},s.append(n,i,r),this.endSection=s,this.container.append(s)}}function Ws(t){return!!t&&t.nodeType!=null}function Tt(t){return t.namespaceURI==="http://www.w3.org/2000/svg"}function ee(t){return t.nodeType===Node.ELEMENT_NODE}function fr(t){return t.nodeType===Node.COMMENT_NODE}function It(t){return t.nodeType===Node.TEXT_NODE}function ze(t){return t.nodeType===Node.DOCUMENT_NODE}function We(t){return t.nodeType===Node.DOCUMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function F(t,e){return t.localName===e}class pr{constructor(e,s){this.app=e,this.options=s,this.snapshots={},this.intervals=[],this.restartTracking=()=>{this.clear(),this.app.nodes.scanTree(this.captureCanvas)},this.captureCanvas=n=>{const i=this.app.nodes.getID(n);if(!i||!F(n,"canvas")||this.app.sanitizer.isObscured(i)||this.app.sanitizer.isHidden(i)||!F(n,"canvas")||this.snapshots[i])return;new IntersectionObserver(l=>{l.forEach(a=>{a.isIntersecting&&(a.target?this.snapshots[i]&&this.snapshots[i].createdAt?this.snapshots[i].paused=!1:this.recordCanvas(a.target,i):this.snapshots[i]&&(this.snapshots[i].paused=!0))})}).observe(n)},this.recordCanvas=(n,i)=>{const r=this.app.timestamp();this.snapshots[i]={images:[],createdAt:r,paused:!1,dummy:document.createElement("canvas")};const o=Hi(i.toString(),r);this.app.send(o);const l=h=>{gr(h,this.options.quality,this.snapshots[i].dummy,this.options.fixedScaling,this.fileExt,c=>{c&&(this.snapshots[i].images.push({id:this.app.timestamp(),data:c}),this.snapshots[i].images.length>9&&(this.sendSnaps(this.snapshots[i].images,i,this.snapshots[i].createdAt),this.snapshots[i].images=[]))})},a=setInterval(()=>{const h=this.app.nodes.getID(n),c=h?this.app.nodes.getNode(h):void 0;!c||!F(c,"canvas")||c!==n?(this.app.debug.log("Canvas element not in sync"),clearInterval(a)):this.snapshots[i].paused||(this.options.useAnimationFrame?requestAnimationFrame(()=>{l(c)}):l(c))},this.interval);this.intervals.push(a)},this.fileExt=s.fileExt??"webp",this.interval=1e3/s.fps}startTracking(){setTimeout(()=>{this.app.nodes.scanTree(this.captureCanvas),this.app.nodes.attachNodeCallback(e=>{this.captureCanvas(e)})},500)}sendSnaps(e,s,n){if(Object.keys(this.snapshots).length===0)return;const i=new FormData;e.forEach(r=>{const o=r.data;o&&(i.append("snapshot",o,`${n}_${s}_${r.id}.${this.fileExt}`),this.options.isDebug&&mr(o,`${n}_${s}_${r.id}.${this.fileExt}`))}),fetch(this.app.options.ingestPoint+"/v1/web/images",{method:"POST",headers:{Authorization:`Bearer ${this.app.session.getSessionToken()??""}`},body:i}).then(()=>!0).catch(r=>{this.app.debug.error("error saving canvas",r)})}clear(){this.intervals.forEach(e=>clearInterval(e)),this.snapshots={}}}const qs={low:.35,medium:.55,high:.8};function gr(t,e="medium",s,n=!1,i,r){const o=`image/${i}`;if(n){const l=window.devicePixelRatio||1;s.width=t.width/l,s.height=t.height/l;const a=s.getContext("2d");if(!a)return"";a.clearRect(0,0,s.width,s.height),a.drawImage(t,0,0,s.width,s.height),s.toBlob(r,o,qs[e])}else t.toBlob(r,o,qs[e])}function mr(t,e){const s=URL.createObjectURL(t),n=document.createElement("a");n.href=s,n.download=e,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)}const Te={Verbose:5,Log:4,Warnings:3,Errors:2,Silent:0};class br{constructor(e=Te.Silent){this.shouldLog=s=>this.level>=s,this.log=(...s)=>{this.shouldLog(Te.Log)&&console.log(...s)},this.warn=(...s)=>{this.shouldLog(Te.Warnings)&&console.warn(...s)},this.error=(...s)=>{this.shouldLog(Te.Errors)&&console.error(...s)},this.level=e}}class yr{constructor(e){this.node_id=e,this.nodes=[],this.totalNodeAmount=0,this.nodeCallbacks=[],this.elementListeners=new Map,this.nextNodeId=0,this.scanTree=s=>{this.nodes.forEach(n=>s(n))}}syntheticMode(e){const i=99999999*e;if(i>9007199254740900)throw new Error("Placeholder id overflow");this.nextNodeId=i}attachNodeCallback(e){this.nodeCallbacks.push(e)}attachNodeListener(e,s,n,i=!0){const r=this.getID(e);if(r===void 0)return;vs(e,s,n,i);let o=this.elementListeners.get(r);o===void 0&&(o=[],this.elementListeners.set(r,o)),o.push([s,n,i])}registerNode(e){let s=e[this.node_id];const n=s===void 0;return n&&(s=this.nextNodeId,this.totalNodeAmount++,this.nextNodeId++,this.nodes[s]=e,e[this.node_id]=s),[s,n]}unregisterNode(e){const s=e[this.node_id];if(s!==void 0){e[this.node_id]=void 0,delete e[this.node_id],delete this.nodes[s];const n=this.elementListeners.get(s);n!==void 0&&(this.elementListeners.delete(s),n.forEach(i=>ks(e,i[0],i[1],i[2]))),this.totalNodeAmount--}return s}cleanTree(){for(let e=0;e<this.nodes.length;e++){const s=this.nodes[e];s&&!document.contains(s)&&this.unregisterNode(s)}}callNodeCallbacks(e,s){this.nodeCallbacks.forEach(n=>n(e,s))}getID(e){if(e)return e[this.node_id]}getNode(e){return this.nodes[e]}getNodeCount(){return this.totalNodeAmount}clear(){for(let e=0;e<this.nodes.length;e++){const s=this.nodes[e];s&&this.unregisterNode(s)}this.nextNodeId=0,this.nodes.length=0}}function xt(t){if(fr(t))return!0;if(It(t))return!1;if(!ee(t))return!0;const e=t.tagName.toUpperCase();if(e==="LINK"){const s=t.getAttribute("rel"),n=t.getAttribute("as");return!(s!=null&&s.includes("stylesheet")||n==="style"||n==="font")}return e==="SCRIPT"||e==="NOSCRIPT"||e==="META"||e==="TITLE"||e==="BASE"}function Et(t){return We(t)?!0:!xt(t)}var J;(function(t){t[t.New=0]="New",t[t.Removed=1]="Removed",t[t.Changed=2]="Changed"})(J||(J={}));class Ct{constructor(e,s=!1){this.app=e,this.isTopContext=s,this.commited=[],this.recents=new Map,this.indexes=[],this.attributesMap=new Map,this.textSet=new Set,this.observer=ws(this.app.safe(n=>{for(const i of n){const r=i.target,o=i.type;if(!Et(r))continue;if(o==="childList"){for(let a=0;a<i.removedNodes.length;a++)Et(i.removedNodes[a])&&this.bindNode(i.removedNodes[a]);for(let a=0;a<i.addedNodes.length;a++)this.bindTree(i.addedNodes[a]);continue}const l=this.app.nodes.getID(r);if(l!==void 0){if(this.recents.has(l)||this.recents.set(l,J.Changed),o==="attributes"){const a=i.attributeName;if(a===null)continue;let h=this.attributesMap.get(l);h===void 0&&this.attributesMap.set(l,h=new Set),h.add(a);continue}if(o==="characterData"){this.textSet.add(l);continue}}}this.commitNodes()}))}clear(){this.commited.length=0,this.recents.clear(),this.indexes.length=1,this.attributesMap.clear(),this.textSet.clear()}sendNodeAttribute(e,s,n,i){if(Tt(s)){n.substr(0,6)==="xlink:"&&(n=n.substr(6)),i===null?this.app.send(Is(e,n)):n==="href"?(i.length>1e5&&(i=""),this.app.send(pt(e,n,i,this.app.getBaseHref()))):this.app.attributeSender.sendSetAttribute(e,n,i);return}if(!(n==="src"||n==="srcset"||n==="integrity"||n==="crossorigin"||n==="autocomplete"||n.substr(0,2)==="on")&&!(n==="value"&&F(s,"input")&&s.type!=="button"&&s.type!=="reset"&&s.type!=="submit")){if(i===null){this.app.send(Is(e,n));return}if(n==="style"||n==="href"&&F(s,"link")){this.app.send(pt(e,n,i,this.app.getBaseHref()));return}(n==="href"||i.length>1e5)&&(i=""),this.app.attributeSender.sendSetAttribute(e,n,i)}}sendNodeData(e,s,n){if(F(s,"style")){this.app.send(Ri(e,n,this.app.getBaseHref()));return}n=this.app.sanitizer.sanitize(e,n),this.app.send(bi(e,n))}bindNode(e){const[s,n]=this.app.nodes.registerNode(e);n?this.recents.set(s,J.New):this.recents.get(s)!==J.New&&this.recents.set(s,J.Removed)}bindTree(e){if(!Et(e))return;this.bindNode(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:n=>(this.app.nodes.getID(n)!==void 0&&this.app.debug.error("! Node is already bound",n),xt(n)||this.app.nodes.getID(n)!==void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT)},!1);for(;s.nextNode();)this.bindNode(s.currentNode)}unbindTree(e){const s=this.app.nodes.unregisterNode(e);if(s!==void 0&&this.recents.get(s)===J.Removed){this.app.send(mi(s));const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT+NodeFilter.SHOW_TEXT,{acceptNode:l=>xt(l)||this.app.nodes.getID(l)===void 0?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},!1);let i=0;const r=this.app.nodes.getNodeCount();for(;n.nextNode();)i+=1,this.app.nodes.unregisterNode(n.currentNode);const o=Math.floor(i/r*100);o>30&&this.app.send(Ui(o))}}_commitNode(e,s){if(We(s))return!0;const n=s.parentNode;let i;if(!F(s,"html")||!this.isTopContext){if(n===null)return this.unbindTree(s),!1;if(i=this.app.nodes.getID(n),i===void 0)return this.unbindTree(s),!1;if(!this.commitNode(i))return this.unbindTree(s),!1;if(this.app.sanitizer.handleNode(e,i,s),this.app.sanitizer.isHidden(i))return!1}let r=s.previousSibling;for(;r!==null;){const c=this.app.nodes.getID(r);if(c!==void 0){this.commitNode(c),this.indexes[e]=this.indexes[c]+1;break}r=r.previousSibling}r===null&&(this.indexes[e]=0);const o=this.recents.get(e),l=o===J.New,a=this.indexes[e];if(a===void 0)throw"commitNode: missing node index";if(l){if(ee(s)){let c=s;if(i!==void 0){if(this.app.sanitizer.isHidden(e)){const u=c.clientWidth,d=c.clientHeight;c=s.cloneNode(),c.style.width=`${u}px`,c.style.height=`${d}px`}this.app.send(fi(e,i,a,c.tagName,Tt(s)))}for(let u=0;u<c.attributes.length;u++){const d=c.attributes[u];this.sendNodeAttribute(e,c,d.nodeName,d.value)}}else It(s)&&(this.app.send(pi(e,i,a)),this.sendNodeData(e,n,s.data));return!0}o===J.Removed&&i!==void 0&&this.app.send(gi(e,i,a));const h=this.attributesMap.get(e);if(h!==void 0){if(!ee(s))throw"commitNode: node is not an element";for(const c of h)this.sendNodeAttribute(e,s,c,s.getAttribute(c))}if(this.textSet.has(e)){if(!It(s))throw"commitNode: node is not a text";this.sendNodeData(e,n,s.data)}return!0}commitNode(e){const s=this.app.nodes.getNode(e);if(s===void 0)return!1;const n=this.commited[e];return n!==void 0?n:this.commited[e]=this._commitNode(e,s)}commitNodes(e=!1){let s;this.recents.forEach((n,i)=>{this.commitNode(i),n===J.New&&(s=this.app.nodes.getNode(i))&&this.app.nodes.callNodeCallbacks(s,e)}),this.clear()}observeRoot(e,s,n=e){this.observer.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1}),this.bindTree(n),s(this.app.nodes.getID(e)),this.commitNodes(!0)}disconnect(){this.observer.disconnect(),this.clear()}}class $s extends Ct{observe(e){const s=e.contentDocument,n=this.app.nodes.getID(e);!s||n===void 0||this.observeRoot(s,i=>{if(i===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(gt(n,i))})}syntheticObserve(e,s){this.observeRoot(s,n=>{if(n===void 0){this.app.debug.log("OpenReplay: Iframe document not bound");return}this.app.send(gt(e,n))})}}class Sr extends Ct{observe(e){const s=e.shadowRoot,n=this.app.nodes.getID(e);!s||n===void 0||this.observeRoot(s,i=>{if(i===void 0){this.app.debug.error("OpenReplay: Shadow Root was not bound");return}this.app.send(gt(n,i))})}}class wr{constructor(){this.states=new Map}calcOffset(e){let s=0,n=0;if(e.parent&&([s,n]=this.calcOffset(e.parent)),!e.offset){const{left:o,top:l}=e.iFrame.getBoundingClientRect();e.offset=[o,l]}const[i,r]=e.offset;return[s+i,n+r]}getDocumentOffset(e){const s=this.states.get(e);return s?this.calcOffset(s):[0,0]}observe(e){var l;const s=e.contentDocument;if(!s)return;const n=e.ownerDocument,i=this.states.get(n),r={offset:null,iFrame:e,parent:i||null,clear:()=>{var a;n.removeEventListener("scroll",o),(a=n.defaultView)==null||a.removeEventListener("resize",o)}},o=()=>{r.offset=null};n.addEventListener("scroll",o),(l=n.defaultView)==null||l.addEventListener("resize",o),this.states.set(s,r)}clear(){this.states.forEach(e=>e.clear()),this.states.clear()}}const Nt=K?Element.prototype.attachShadow:()=>new ShadowRoot;class vr extends Ct{constructor(e,s){super(e,!0),this.iframeOffsets=new wr,this.contextCallbacks=[],this.contextsSet=new Set,this.iframeObservers=[],this.shadowRootObservers=[],this.options=Object.assign({captureIFrames:!0},s),this.app.nodes.attachNodeCallback(n=>{F(n,"iframe")&&(this.options.captureIFrames&&!oe(n,"obscured")||oe(n,"capture"))&&this.handleIframe(n)}),this.app.nodes.attachNodeCallback(n=>{ee(n)&&n.shadowRoot!==null&&this.handleShadowRoot(n.shadowRoot)})}attachContextCallback(e){this.contextCallbacks.push(e)}getDocumentOffset(e){return this.iframeOffsets.getDocumentOffset(e)}handleIframe(e){let s=null;const n=this.app.safe(()=>setTimeout(()=>{if(this.app.nodes.getID(e)===void 0||!ii(e))return;const r=e.contentWindow,o=e.contentDocument;if(o&&o!==s){const l=new $s(this.app);this.iframeObservers.push(l),l.observe(e),s=o,this.iframeOffsets.observe(e)}r&&r===r.window&&!this.contextsSet.has(r)&&(this.contextsSet.add(r),this.contextCallbacks.forEach(l=>l(r)))},100));e.addEventListener("load",n),n()}handleShadowRoot(e){const s=new Sr(this.app);this.shadowRootObservers.push(s),s.observe(e.host)}observe(){const e=this;Element.prototype.attachShadow=function(){const s=Nt.apply(this,arguments);return e.handleShadowRoot(s),s},this.app.nodes.clear(),this.observeRoot(window.document,()=>{this.app.send(di()),this.app.nodes.callNodeCallbacks(document,!0)},window.document.documentElement)}crossdomainObserve(e,s){const n=this;Element.prototype.attachShadow=function(){const r=Nt.apply(this,arguments);return n.handleShadowRoot(r),r},this.app.nodes.clear(),this.app.nodes.syntheticMode(s);const i=new $s(this.app);this.iframeObservers.push(i),i.syntheticObserve(e,window.document)}disconnect(){this.iframeOffsets.clear(),Element.prototype.attachShadow=Nt,this.iframeObservers.forEach(e=>e.disconnect()),this.iframeObservers=[],this.shadowRootObservers.forEach(e=>e.disconnect()),this.shadowRootObservers=[],super.disconnect()}}var qe;(function(t){t[t.Plain=0]="Plain",t[t.Obscured=1]="Obscured",t[t.Hidden=2]="Hidden"})(qe||(qe={}));const kr=t=>t.trim().replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"█");class Tr{constructor(e,s){this.app=e,this.obscured=new Set,this.hidden=new Set,this.options=Object.assign({obscureTextEmails:!0,obscureTextNumbers:!1},s)}handleNode(e,s,n){if((this.obscured.has(s)||ee(n)&&(oe(n,"masked")||oe(n,"obscured")))&&this.obscured.add(e),(this.hidden.has(s)||ee(n)&&(oe(n,"htmlmasked")||oe(n,"hidden")))&&this.hidden.add(e),this.options.domSanitizer!==void 0&&ee(n)){const i=this.options.domSanitizer(n);i===qe.Obscured&&this.obscured.add(e),i===qe.Hidden&&this.hidden.add(e)}}sanitize(e,s){return this.obscured.has(e)?kr(s):(this.options.obscureTextNumbers&&(s=s.replace(/\d/g,"0")),this.options.obscureTextEmails&&(s=s.replace(/^\w+([+.-]\w+)*@\w+([.-]\w+)*\.\w{2,3}$/g,n=>{const[i,r]=n.split("@"),[o,l]=r.split(".");return`${ut(i)}@${ut(o)}.${ut(l)}`})),s)}isObscured(e){return this.obscured.has(e)}isHidden(e){return this.hidden.has(e)}getInnerTextSecure(e){const s=this.app.nodes.getID(e);return s?this.sanitize(s,e.innerText):""}clear(){this.obscured.clear(),this.hidden.clear()}}class Ir{constructor(e,s){this.app=e,this.options=s,this.metadata={},this.userID=null,this.callbacks=[],this.timestamp=0,this.createTabId()}attachUpdateCallback(e){this.callbacks.push(e)}handleUpdate(e){e.userID==null&&delete e.userID,e.sessionID==null&&delete e.sessionID,this.callbacks.forEach(s=>s(e))}assign(e){e.userID!==void 0&&(this.userID=e.userID),e.metadata!==void 0&&Object.entries(e.metadata).forEach(([s,n])=>this.metadata[s]=n),e.sessionID!==void 0&&(this.sessionID=e.sessionID),e.timestamp!==void 0&&(this.timestamp=e.timestamp),e.projectID!==void 0&&(this.projectID=e.projectID),this.handleUpdate(e)}setMetadata(e,s){this.metadata[e]=s,this.handleUpdate({metadata:{[e]:s}})}setUserID(e){this.userID=e,this.handleUpdate({userID:e})}setUserInfo(e){this.userInfo=e}getPageNumber(){const e=this.app.sessionStorage.getItem(this.options.session_pageno_key);if(e!=null)return parseInt(e)}incPageNo(){let e=this.getPageNumber();return e===void 0?e=0:e++,this.app.sessionStorage.setItem(this.options.session_pageno_key,e.toString()),e}getSessionToken(){return this.app.sessionStorage.getItem(this.options.session_token_key)||void 0}setSessionToken(e){this.app.sessionStorage.setItem(this.options.session_token_key,e)}applySessionHash(e){const s=decodeURI(e).split("&");let n=e,i="100500";s.length==2&&([i,n]=s),!(!i||!n)&&(this.app.sessionStorage.setItem(this.options.session_token_key,n),this.app.sessionStorage.setItem(this.options.session_pageno_key,i))}getSessionHash(){const e=this.getPageNumber(),s=this.getSessionToken();if(!(e===void 0||s===void 0))return encodeURI(String(e)+"&"+s)}getTabId(){return this.tabId||this.createTabId(),this.tabId}regenerateTabId(){const e=ri(12);this.app.sessionStorage.setItem(this.options.session_tabid_key,e),this.tabId=e}createTabId(){const e=this.app.sessionStorage.getItem(this.options.session_tabid_key);e?this.tabId=e:this.regenerateTabId()}getInfo(){return{sessionID:this.sessionID,metadata:this.metadata,userID:this.userID,timestamp:this.timestamp,projectID:this.projectID}}reset(){this.app.sessionStorage.removeItem(this.options.session_token_key),this.metadata={},this.userID=null,this.sessionID=void 0,this.timestamp=0}}function xr(t,e){let s=0;return()=>{s++>=e&&(s=0,t())}}class Er{constructor(e){this.app=e,this.timer=null,this.callbacks=[]}attach(e,s=0,n=!0,i){i&&(e=e.bind(i)),n&&(e=this.app.safe(e)),this.callbacks.unshift(s?xr(e,s):e)-1}start(){this.timer===null&&(this.timer=setInterval(()=>this.callbacks.forEach(e=>{e&&e()}),30))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}}const Ie="canceled",Vs="or_uxt_active",_t="or_buffer_1",re=t=>({reason:t,success:!1}),Cr=t=>({...t,success:!0});var B;(function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Active=2]="Active",t[t.ColdStart=3]="ColdStart"})(B||(B={}));const Xs="https://api.openreplay.com/ingest";function Ot(){const t=new Date().getTimezoneOffset()*-1,e=t>=0?"+":"-",s=Math.floor(Math.abs(t)/60),n=Math.abs(t)%60;return`UTC${e}${String(s).padStart(2,"0")}:${String(n).padStart(2,"0")}`}const Nr=t=>new Promise(e=>setTimeout(e,t)),q={ask:"never-gonna-give-you-up",resp:"never-gonna-let-you-down",reg:"never-gonna-run-around-and-desert-you",iframeSignal:"never-gonna-make-you-cry",iframeId:"never-gonna-say-goodbye",iframeBatch:"never-gonna-tell-a-lie-and-hurt-you"};class _r{constructor(e,s,n,i,r){this.signalError=i,this.insideIframe=r,this.messages=[],this.bufferedMessages1=[],this.bufferedMessages2=[],this.startCallbacks=[],this.stopCallbacks=[],this.commitCallbacks=[],this.activityState=B.NotActive,this.version="14.0.4",this.socketMode=!1,this.compressionThreshold=24*1e3,this.bc=null,this.canvasRecorder=null,this.conditionsManager=null,this.canStart=!1,this.rootId=null,this.pageFrames=[],this.frameOderNumber=0,this.initialHostName=location.hostname,this.startTimeout=null,this.coldStartCommitN=0,this.delay=0,this.coldInterval=null,this.orderNumber=0,this.coldStartTs=0,this.singleBuffer=!1,this.onSessionSent=()=>{},this.restartCanvasTracking=()=>{var a;(a=this.canvasRecorder)==null||a.restartTracking()},this.flushBuffer=async a=>new Promise(h=>{let c=!1;const u=[a.shift()];for(;!c;){const d=a[0];!d||d[0]===0?c=!0:u.push(a.shift())}this.postToWorker(u),h(null)}),this.onUxtCb=[],this.contextId=Math.random().toString(36).slice(2),this.projectKey=e,Object.keys(n).findIndex(a=>["fixedCanvasScaling","disableCanvas"].includes(a))!==-1&&(console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.'),n={...n,canvas:{__save_canvas_locally:n.__save_canvas_locally,fixedCanvasScaling:n.fixedCanvasScaling,disableCanvas:n.disableCanvas}}),this.networkOptions=n.network;const o={revID:"",node_id:"__openreplay_id",session_token_key:"__openreplay_token",session_pageno_key:"__openreplay_pageno",session_reset_key:"__openreplay_reset",session_tabid_key:"__openreplay_tabid",local_uuid_key:"__openreplay_uuid",ingestPoint:Xs,resourceBaseHref:null,__is_snippet:!1,__debug_report_edp:null,__debug__:Te.Silent,__save_canvas_locally:!1,localStorage:null,sessionStorage:null,disableStringDict:!1,forceSingleTab:!1,assistSocketHost:"",fixedCanvasScaling:!1,disableCanvas:!1,captureIFrames:!0,obscureTextEmails:!0,obscureTextNumbers:!1,crossdomain:{parentDomain:"*"},canvas:{disableCanvas:!1,fixedCanvasScaling:!1,__save_canvas_locally:!1,useAnimationFrame:!1}};if(this.options=Ts(o,n),!this.insideIframe&&!this.options.forceSingleTab&&globalThis&&"BroadcastChannel"in globalThis){const a=location.hostname.split(".").slice(-2).join("_");this.bc=new BroadcastChannel(`rick_${a}`)}this.revID=this.options.revID,this.localStorage=this.options.localStorage??window.localStorage,this.sessionStorage=this.options.sessionStorage??window.sessionStorage,this.sanitizer=new Tr(this,n),this.nodes=new yr(this.options.node_id),this.observer=new vr(this,n),this.ticker=new Er(this),this.ticker.attach(()=>this.commit()),this.debug=new br(this.options.__debug__),this.session=new Ir(this,this.options),this.attributeSender=new Qn(this,!!this.options.disableStringDict),this.featureFlags=new ti(this),this.tagWatcher=new qi(this.sessionStorage,this.debug.error,a=>{this.send(ji(a))}),this.session.attachUpdateCallback(({userID:a,metadata:h})=>{a!=null&&this.send(Ei(a)),h!=null&&Object.entries(h).forEach(([c,u])=>this.send(xs(c,u)))}),s!=null&&this.session.applySessionHash(s),this.initWorker();const l=this.session.getTabId();if(this.insideIframe){const a=c=>{const{data:u}=c;u.line===q.iframeId&&(this.rootId=u.id,this.session.setSessionToken(u.token),this.frameOderNumber=u.frameOrderNumber,this.debug.log("starting iframe tracking",u),this.allowAppStart())};window.addEventListener("message",a),this.attachStopCallback(()=>{window.removeEventListener("message",a)});const h=this.initialHostName;window.parent.postMessage({line:q.iframeSignal,source:l,context:this.contextId,domain:h},"*")}else{let a=0;const h=c=>{const{data:u}=c;if(u.line===q.iframeSignal){const d=u.domain,f=Array.from(document.querySelectorAll("iframe"));this.pageFrames=f,(async()=>{let p=0;for(;p<10;){const y=this.checkNodeId(f,d);if(y){this.waitStarted().then(()=>{var T;a++;const E=this.session.getSessionToken(),N={line:q.iframeId,context:this.contextId,domain:d,id:y,token:E,frameOrderNumber:a};this.debug.log("iframe_data",N),(T=c.source)==null||T.postMessage(N,"*")}).catch(console.error),p=10;break}p++,await Nr(100)}})()}if(u.line===q.iframeBatch){const f=u.messages.map(g=>{if(g[0]===20){let p=g;return this.pageFrames.forEach(y=>{if(y.dataset.domain===c.data.domain){const[E,N,T]=g,{left:m,top:w}=y.getBoundingClientRect();p=[E,N+m,T+w]}}),p}if(g[0]===68){let p=g;return this.pageFrames.forEach(y=>{if(y.dataset.domain===c.data.domain){const[E,N,T,m,w,k,x]=g,{left:S,top:b,width:_,height:M}=y.getBoundingClientRect(),O=document.documentElement.scrollWidth,D=document.documentElement.scrollHeight,v=k/100*_+S,I=x/100*M+b,A=v/O,L=I/D;p=[E,N,T,m,w,Math.round(A*1e3)/10,Math.round(L*1e3)/10]}}),p}return g});this.messages.push(...f)}};window.addEventListener("message",h),this.attachStopCallback(()=>{window.removeEventListener("message",h)})}this.bc!==null&&(this.bc.postMessage({line:q.ask,source:l,context:this.contextId}),this.startTimeout=setTimeout(()=>{this.allowAppStart()},500),this.bc.onmessage=a=>{if(a.data.context!==this.contextId){if(a.data.line===q.resp){const h=a.data.token;this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===q.reg){const h=a.data.token;this.session.regenerateTabId(),this.session.setSessionToken(h),this.allowAppStart()}if(a.data.line===q.ask){const h=this.session.getSessionToken();h&&this.bc&&this.bc.postMessage({line:a.data.source===l?q.reg:q.resp,token:h,source:l,context:this.contextId})}}})}allowAppStart(){this.canStart=!0,this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}checkNodeId(e,s){for(const n of e)if(n.dataset.domain===s)return n[this.options.node_id];return null}initWorker(){try{this.worker=new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=250,h,r){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.pageNo=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.lastBatchNum=0,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){if(this.busy||!this.token)this.queue.push(t);else if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}}sendNext(){const t=this.queue.shift();if(t)if(this.busy=!0,this.isCompressing&&this.onCompress)this.onCompress(t);else{const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}else this.busy=!1}retry(t,s,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s,i)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s,i){const e=i?.toString().replace(/^([^_]+)_([^_]+).*/,"$1_$2_$3");this.busy=!0;const n={Authorization:`Bearer ${this.token}`};s&&(n["Content-Encoding"]="gzip"),null!==this.token?fetch(`${this.ingestURL}?batch=${this.pageNo??"noPageNum"}_${e??"noBatchNum"}`,{body:t,method:"POST",headers:n,keepalive:t.length<65536}).then((e=>{if(401===e.status)return this.busy=!1,void this.onUnauthorised();e.status>=400?this.retry(t,s,`${i??"noBatchNum"}_network:${e.status}`):(this.attemptsCount=0,this.sendNext())})).catch((e=>{console.warn("OpenReplay:",e),this.retry(t,s,`${i??"noBatchNum"}_reject:${e.message}`)})):setTimeout((()=>{this.sendBatch(t,s,`${i??"noBatchNum"}_newToken`)}),500)}sendCompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!0,s)}sendUncompressed(t){const s=++this.lastBatchNum;this.sendBatch(t,!1,s)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.int(t[5]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 68:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2]);case 121:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 122:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 123:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])}}}class n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if("q_end"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),122===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){return new Promise((t=>{u=h.Stopping,null!==l&&(clearInterval(l),l=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive,t(null)}),100)}))}function g(){u!==h.Stopped&&(postMessage("a_stop"),c().then((()=>{postMessage("a_start")})))}let p,l=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),void c().then((()=>{u=h.Stopped}));if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Compressed batch."),void g();s.batch&&r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Uncompressed batch."),void g();s.batch&&r.sendUncompressed(s.batch)}return"start"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{g()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])}),s.pageNo),a=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:"queue_empty"}))),null===l&&(l=setInterval(o,1e4)),u=h.Active):"auth"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("OR WebWorker: writer not initialised. Received auth."),void g()):(console.debug("OR WebWorker: sender not initialised. Received auth."),void g()):void 0}if(a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?p=setTimeout((()=>g()),18e5):clearTimeout(p)),t.writeMessage(s)}))}else postMessage("not_init"),g()}else o()}else o()};'],{type:"text/javascript"}))),this.worker.onerror=s=>{this._debug("webworker_error",s)},this.worker.onmessage=({data:s})=>{this.handleWorkerMsg(s)};const e=()=>{this.worker&&this.worker.postMessage(null)};this.attachEventListener(window,"beforeunload",e,!1),this.attachEventListener(document.body,"mouseleave",e,!1,!1),this.attachEventListener(document,"visibilitychange",e,!1)}catch(e){this._debug("worker_start",e)}}handleWorkerMsg(e){var s;if(e==="a_stop")this.stop(!1);else if(e==="a_start")this.start({},!0);else if(e==="not_init")this.debug.warn("OR WebWorker: writer not initialised. Restarting tracker");else if(e.type==="failure")this.stop(!1),this.debug.error("worker_failed",e.reason),this._debug("worker_failed",e.reason);else if(e.type==="compress"){const n=e.batch;n.byteLength>this.compressionThreshold?Kn(e.batch,{mtime:0},(r,o)=>{var l,a;r?(this.debug.error("Openreplay compression error:",r),(l=this.worker)==null||l.postMessage({type:"uncompressed",batch:n})):(a=this.worker)==null||a.postMessage({type:"compressed",batch:o})}):(s=this.worker)==null||s.postMessage({type:"uncompressed",batch:n})}else e.type==="queue_empty"&&this.onSessionSent()}_debug(e,s){this.options.__debug_report_edp!==null&&fetch(this.options.__debug_report_edp,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({context:e,error:`${s}`})}),this.debug.error("OpenReplay error: ",e,s)}send(e,s=!1){var n;this.activityState!==B.NotActive&&(this.activityState===B.ColdStart?(this.bufferedMessages1.push(e),this.singleBuffer||this.bufferedMessages2.push(e),(n=this.conditionsManager)==null||n.processMessage(e)):this.messages.push(e),this.activityState===B.Active&&s&&this.commit())}_nCommit(){if(this.socketMode){this.messages.unshift(ce(this.session.getTabId())),this.messages.unshift(ae(this.timestamp())),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}if(!(this.worker===void 0||!this.messages.length)){if(this.insideIframe){window.parent.postMessage({line:q.iframeBatch,messages:this.messages,domain:this.initialHostName},"*"),this.commitCallbacks.forEach(e=>e(this.messages)),this.messages.length=0;return}try{li(()=>{var e;this.messages.unshift(ce(this.session.getTabId())),this.messages.unshift(ae(this.timestamp())),(e=this.worker)==null||e.postMessage(this.messages),this.commitCallbacks.forEach(s=>s(this.messages)),this.messages.length=0})}catch(e){this._debug("worker_commit",e),this.stop(!0),setTimeout(()=>{this.start()},500)}}}_cStartCommit(){this.coldStartCommitN+=1,this.coldStartCommitN===2&&(this.bufferedMessages1.push(ae(this.timestamp())),this.bufferedMessages1.push(ce(this.session.getTabId())),this.bufferedMessages2.push(ae(this.timestamp())),this.bufferedMessages2.push(ce(this.session.getTabId())),this.coldStartCommitN=0)}commit(){this.activityState===B.ColdStart?this._cStartCommit():this._nCommit()}postToWorker(e){var s;(s=this.worker)==null||s.postMessage(e),this.commitCallbacks.forEach(n=>n(e)),e.length=0}timestamp(){return X()+this.delay}safe(e){const s=this;return function(...n){try{e.apply(this,n)}catch(i){s._debug("safe_fn_call",i)}}}attachCommitCallback(e){this.commitCallbacks.push(e)}attachStartCallback(e,s=!1){s&&(e=this.safe(e)),this.startCallbacks.push(e)}attachStopCallback(e,s=!1){s&&(e=this.safe(e)),this.stopCallbacks.push(e)}attachEventListener(e,s,n,i=!0,r=!0){i&&(n=this.safe(n));const o=()=>e?vs(e,s,n,r):null,l=()=>e?ks(e,s,n,r):null;this.attachStartCallback(o,i),this.attachStopCallback(l,i)}checkRequiredVersion(e){const s=e.split(/[.-]/),n=this.version.split(/[.-]/);for(let i=0;i<3;i++){if(isNaN(Number(n[i]))||isNaN(Number(s[i])))return!1;if(Number(n[i])>Number(s[i]))return!0;if(Number(n[i])<Number(s[i]))return!1}return!0}getTrackerInfo(){return{userUUID:this.localStorage.getItem(this.options.local_uuid_key),projectKey:this.projectKey,revID:this.revID,trackerVersion:this.version,isSnippet:this.options.__is_snippet}}getSessionInfo(){return{...this.session.getInfo(),...this.getTrackerInfo()}}getSessionToken(){return this.session.getSessionToken()}getSessionID(){return this.session.getInfo().sessionID||void 0}getSessionURL(e){const{projectID:s,sessionID:n,timestamp:i}=this.session.getInfo();if(!s||!n){this.debug.error("OpenReplay error: Unable to build session URL");return}const r=this.options.ingestPoint,a=(/api\.openreplay\.com/.test(r)?"https://app.openreplay.com/ingest":r).replace(/ingest$/,`${s}/session/${n}`);if(e!=null&&e.withCurrentTime){const h=X()-i;return`${a}?jumpto=${h}`}return a}getHost(){return new URL(this.options.ingestPoint).host}getProjectKey(){return this.projectKey}getBaseHref(){var e,s;return typeof this.options.resourceBaseHref=="string"?this.options.resourceBaseHref:(this.options.resourceBaseHref,document.baseURI?document.baseURI:((s=(e=document.head)==null?void 0:e.getElementsByTagName("base")[0])==null?void 0:s.getAttribute("href"))||location.origin+location.pathname)}resolveResourceURL(e){const s=new URL(this.getBaseHref());return s.pathname+="/"+new URL(e).pathname,s.pathname.replace(/\/+/g,"/"),s.toString()}isServiceURL(e){return e.startsWith(this.options.ingestPoint)}active(){return this.activityState===B.Active}resetNextPageSession(e){e?this.sessionStorage.setItem(this.options.session_reset_key,"t"):this.sessionStorage.removeItem(this.options.session_reset_key)}checkSessionToken(e){const s=this.sessionStorage.getItem(this.options.session_reset_key)!==null,n=e||s,i=this.session.getSessionToken();return n||!i}async coldStart(e={},s){this.singleBuffer=!1;const n=1e3,i=this.checkSessionToken(e.forceNew);s&&await this.setupConditionalStart(e);const r=()=>{this.orderNumber+=1,ht(),this.coldStartTs=X(),this.orderNumber%2===0?(this.bufferedMessages1.length=0,this.bufferedMessages1.push(ae(this.timestamp())),this.bufferedMessages1.push(ce(this.session.getTabId()))):(this.bufferedMessages2.length=0,this.bufferedMessages2.push(ae(this.timestamp())),this.bufferedMessages2.push(ce(this.session.getTabId()))),this.stop(!1),this.activityState=B.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata}),i||(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(Ue(this.session.getTabId()))),this.observer.observe(),this.ticker.start()};this.coldInterval=setInterval(()=>{r()},30*n),r()}async setupConditionalStart(e){var d,f;this.conditionsManager=new Zn(this,e);const s=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:X(),doNotRecord:!0,bufferDiff:0,userID:this.session.getInfo().userID,token:void 0,deviceMemory:St,jsHeapSizeLimit:wt,timezone:Ot(),width:window.screen.width,height:window.screen.height})}),{token:n,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,projectID:c}=await s.json();this.session.assign({projectID:c}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});const u={sessionToken:n,userUUID:"",sessionID:""};this.startCallbacks.forEach(g=>g(u)),await((d=this.conditionsManager)==null?void 0:d.fetchConditions(c,n)),await this.featureFlags.reloadFlags(n),await this.tagWatcher.fetchTags(this.options.ingestPoint,n),(f=this.conditionsManager)==null||f.processFlags(this.featureFlags.flags)}offlineRecording(e={},s){this.onSessionSent=s,this.singleBuffer=!0;const n=this.checkSessionToken(e.forceNew);ht(),this.coldStartTs=X();const i=this.localStorage.getItem(_t);if(i){const o=JSON.parse(i);this.bufferedMessages1=Array.isArray(o)?o:this.bufferedMessages1,this.localStorage.removeItem(_t)}this.bufferedMessages1.push(ae(this.timestamp())),this.bufferedMessages1.push(ce(this.session.getTabId())),this.activityState=B.ColdStart,e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r={sessionToken:"",userUUID:"",sessionID:""};return this.startCallbacks.forEach(o=>o(r)),n||this.send(Ue(this.session.getTabId())),this.observer.observe(),this.ticker.start(),{saveBuffer:this.saveBuffer,getBuffer:this.getBuffer,setBuffer:this.setBuffer}}saveBuffer(){this.localStorage.setItem(_t,JSON.stringify(this.bufferedMessages1))}getBuffer(){return this.bufferedMessages1}setBuffer(e){this.bufferedMessages1=e}async uploadOfflineRecording(){var d,f;this.stop(!1);const e=X();(d=this.worker)==null||d.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:this.coldStartTs,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const s=await fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:e,doNotRecord:!1,bufferDiff:e-this.coldStartTs,userID:this.session.getInfo().userID,token:void 0,deviceMemory:St,jsHeapSizeLimit:wt,timezone:Ot()})}),{token:n,userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h,beaconSizeLimit:c,projectID:u}=await s.json();for((f=this.worker)==null||f.postMessage({type:"auth",token:n,beaconSizeLimit:c}),this.session.assign({projectID:u}),this.session.setUserInfo({userBrowser:i,userCity:r,userCountry:o,userDevice:l,userOS:a,userState:h});this.bufferedMessages1.length>0;)await this.flushBuffer(this.bufferedMessages1);this.postToWorker([["q_end"]]),this.clearBuffers()}async _start(e={},s=!1,n){const i=this.activityState===B.ColdStart;if(i&&this.coldInterval&&clearInterval(this.coldInterval),!this.worker){const a="No worker found: perhaps, CSP is not set.";return this.signalError(a,[]),Promise.resolve(re(a))}if(this.activityState===B.Active||this.activityState===B.Starting)return Promise.resolve(re("OpenReplay: trying to call `start()` on the instance that has been started already."));this.activityState=B.Starting,i||ht(),e.sessionHash&&this.session.applySessionHash(e.sessionHash),e.forceNew&&this.session.reset(),this.session.assign({userID:e.userID,metadata:e.metadata});const r=X();this.worker.postMessage({type:"start",pageNo:this.session.incPageNo(),ingestPoint:this.options.ingestPoint,timestamp:i?this.coldStartTs:r,url:document.URL,connAttemptCount:this.options.connAttemptCount,connAttemptGap:this.options.connAttemptGap,tabId:this.session.getTabId()});const o=this.session.getSessionToken(),l=this.checkSessionToken(e.forceNew);this.sessionStorage.removeItem(this.options.session_reset_key),this.debug.log("OpenReplay: starting session; need new session id?",l,"session token: ",o);try{const a=await window.fetch(this.options.ingestPoint+"/v1/web/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...this.getTrackerInfo(),timestamp:r,doNotRecord:!1,bufferDiff:r-this.coldStartTs,userID:this.session.getInfo().userID,token:l?void 0:o,deviceMemory:St,jsHeapSizeLimit:wt,timezone:Ot(),condition:n,assistOnly:e.assistOnly??this.socketMode,width:window.screen.width,height:window.screen.height})});if(a.status!==200){const v=await a.text(),I=v===Ie?Ie:`Server error: ${a.status}. ${v}`;return re(I)}if(!this.worker){const v="no worker found after start request (this should not happen in real world)";return this.signalError(v,[]),re(v)}const{token:h,userUUID:c,projectID:u,beaconSizeLimit:d,compressionThreshold:f,delay:g,sessionID:p,startTimestamp:y,userBrowser:E,userCity:N,userCountry:T,userDevice:m,userOS:w,userState:k,canvasEnabled:x,canvasQuality:S,canvasFPS:b,assistOnly:_}=await a.json();if(typeof h!="string"||typeof c!="string"||typeof y!="number"&&typeof y<"u"||typeof p!="string"||typeof g!="number"||typeof d!="number"&&typeof d<"u"){const v=`Incorrect server response: ${JSON.stringify(a)}`;return this.signalError(v,[]),re(v)}this.delay=g,this.session.setSessionToken(h),this.session.setUserInfo({userBrowser:E,userCity:N,userCountry:T,userDevice:m,userOS:w,userState:k}),this.session.assign({sessionID:p,timestamp:y||r,projectID:u}),_?(this.socketMode=!0,this.worker.postMessage("stop")):this.worker.postMessage({type:"auth",token:h,beaconSizeLimit:d}),!l&&h===o&&(this.debug.log("continuing session on new tab",this.session.getTabId()),this.send(Ue(this.session.getTabId()))),Object.entries(this.session.getInfo().metadata).forEach(([v,I])=>this.send(xs(v,I))),this.localStorage.setItem(this.options.local_uuid_key,c),this.compressionThreshold=f;const M={sessionToken:h,userUUID:c,sessionID:p};if(this.startCallbacks.forEach(v=>v(M)),this.featureFlags.reloadFlags(),await this.tagWatcher.fetchTags(this.options.ingestPoint,h),this.activityState=B.Active,x&&!this.options.canvas.disableCanvas&&(this.canvasRecorder=this.canvasRecorder??new pr(this,{fps:b,quality:S,isDebug:this.options.canvas.__save_canvas_locally,fixedScaling:this.options.canvas.fixedCanvasScaling,useAnimationFrame:this.options.canvas.useAnimationFrame}),this.canvasRecorder.startTracking()),i){const v=this.bufferedMessages1.length>this.bufferedMessages2.length?this.bufferedMessages1:this.bufferedMessages2;for(;v.length>0;)await this.flushBuffer(v);this.clearBuffers(),this.commit()}else this.insideIframe&&this.rootId?this.observer.crossdomainObserve(this.rootId,this.frameOderNumber):this.observer.observe(),this.ticker.start();this.uxtManager=this.uxtManager?this.uxtManager:new dr(this,Vs);let O;const D=this.localStorage.getItem(Vs);if(D&&(O=parseInt(D,10)),location!=null&&location.search){const v=new URLSearchParams(location.search);if(v.has("oruxt")){const I=v.get("oruxt");O=I?parseInt(I,10):void 0}}return O&&(this.uxtManager.isActive?this.onUxtCb.forEach(v=>v(O)):this.uxtManager.getTest(O,h,!!D).then(v=>{v&&this.onUxtCb.forEach(I=>I(v))})),Cr(M)}catch(a){if(this.stop(),this.session.reset(),a===Ie)return this.signalError(Ie,[]),re(Ie);this._debug("session_start",a);const h=a instanceof Error?a.message:a.toString();return this.signalError(h,[]),re(h)}}addOnUxtCb(e){this.onUxtCb.push(e)}getUxtId(){var e;return(e=this.uxtManager)==null?void 0:e.getTestId()}async waitStart(){return new Promise(e=>{const s=()=>{this.canStart?e(!0):setTimeout(s,25)};s()})}async waitStarted(){return new Promise(e=>{const s=()=>{this.activityState===B.Active?e(!0):setTimeout(s,25)};s()})}async start(...e){return this.activityState===B.Active||this.activityState===B.Starting?Promise.resolve(re("OpenReplay: trying to call `start()` on the instance that has been started already.")):document.hidden?new Promise(s=>{const n=async()=>{document.hidden||(await this.waitStart(),document.removeEventListener("visibilitychange",n),s(this._start(...e)))};document.addEventListener("visibilitychange",n)}):(await this.waitStart(),this._start(...e))}forceFlushBatch(){var e;(e=this.worker)==null||e.postMessage("forceFlushBatch")}getTabId(){return this.session.getTabId()}clearBuffers(){this.bufferedMessages1.length=0,this.bufferedMessages2.length=0}trackWs(e){const s=e;return(n,i,r="down")=>{typeof n!="string"||typeof i!="string"||i.length>5*1024*1024||n.length>255||this.send(Li("websocket",s,i,this.timestamp(),r,n))}}stop(e=!0){var s;if(this.activityState!==B.NotActive)try{this.attributeSender.clear(),this.sanitizer.clear(),this.observer.disconnect(),this.nodes.clear(),this.ticker.stop(),this.stopCallbacks.forEach(n=>n()),this.debug.log("OpenReplay tracking stopped."),this.tagWatcher.clear(),this.worker&&e&&this.worker.postMessage("stop"),(s=this.canvasRecorder)==null||s.clear()}finally{this.activityState=B.NotActive}}}function Or(t){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(e===void 0)return;const s=()=>t.send(_i(Math.round(e.downlink*1e3),e.type||"unknown"));s(),e.addEventListener("change",s)}const Gs=K&&"InstallTrigger"in window?t=>t.message+`
291
+ `+t.stack:t=>t.stack||t.message;function Rt(t){return t===void 0?"undefined":t===null?"null":t instanceof Error?Gs(t):Array.isArray(t)?`Array(${t.length})`:String(t)}function Rr(t){return typeof t!="number"?"NaN":t.toString()}function Dr(t){return typeof t!="number"?"NaN":Math.floor(t).toString()}function Ks(t){if(t===void 0)return"undefined";if(t===null)return"null";if(t instanceof Error)return Gs(t);if(Array.isArray(t)){const e=t.length,s=t.slice(0,10).map(Rt).join(", ");return`Array(${e})[${s}]`}if(typeof t=="object"){const e=[];let s=0;for(const n in t){if(++s===10)break;const i=t[n];e.push(n+": "+Rt(i))}return"{"+e.join(", ")+"}"}return t.toString()}function Mr(t){return typeof t[0]=="string"&&t.unshift(t.shift().replace(/%(o|s|f|d|i)/g,(e,s)=>{const n=t.shift();if(n===void 0)return e;switch(s){case"o":return Ks(n);case"s":return Rt(n);case"f":return Rr(n);case"d":case"i":return Dr(n);default:return e}})),t.map(Ks).join(" ")}const Js=["log","info","warn","error","debug","assert"];function Ar(t,e){const s=Object.assign({consoleMethods:Js,consoleThrottling:30},e);if(!Array.isArray(s.consoleMethods)||s.consoleMethods.length===0)return;const n=t.safe((a,h)=>t.send(ki(a,Mr(h))));let i=0;const r=()=>{i=0};t.attachStartCallback(r),t.ticker.attach(r,33,!1);const o=(a,h)=>{const c={apply:function(u,d,f){Reflect.apply(u,h,f),i=i+1,!(i>s.consoleThrottling)&&n(u.name,f)}};s.consoleMethods.forEach(u=>{if(Js.indexOf(u)===-1){t.debug.error(`OpenReplay: unsupported console method "${u}"`);return}const d=h.console[u];a[u]=new Proxy(d,c)})},l=t.safe(a=>o(a.console,a));l(window),t.observer.attachContextCallback(l)}var Ys=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Qs={exports:{}},Dt={exports:{}},Zs;function Lr(){return Zs||(Zs=1,function(t,e){(function(s,n){t.exports=n()})(Ys,function(){function s(p){return!isNaN(parseFloat(p))&&isFinite(p)}function n(p){return p.charAt(0).toUpperCase()+p.substring(1)}function i(p){return function(){return this[p]}}var r=["isConstructor","isEval","isNative","isToplevel"],o=["columnNumber","lineNumber"],l=["fileName","functionName","source"],a=["args"],h=["evalOrigin"],c=r.concat(o,l,a,h);function u(p){if(p)for(var y=0;y<c.length;y++)p[c[y]]!==void 0&&this["set"+n(c[y])](p[c[y]])}u.prototype={getArgs:function(){return this.args},setArgs:function(p){if(Object.prototype.toString.call(p)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=p},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(p){if(p instanceof u)this.evalOrigin=p;else if(p instanceof Object)this.evalOrigin=new u(p);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var p=this.getFileName()||"",y=this.getLineNumber()||"",E=this.getColumnNumber()||"",N=this.getFunctionName()||"";return this.getIsEval()?p?"[eval] ("+p+":"+y+":"+E+")":"[eval]:"+y+":"+E:N?N+" ("+p+":"+y+":"+E+")":p+":"+y+":"+E}},u.fromString=function(y){var E=y.indexOf("("),N=y.lastIndexOf(")"),T=y.substring(0,E),m=y.substring(E+1,N).split(","),w=y.substring(N+1);if(w.indexOf("@")===0)var k=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(w,""),x=k[1],S=k[2],b=k[3];return new u({functionName:T,args:m||void 0,fileName:x,lineNumber:S||void 0,columnNumber:b||void 0})};for(var d=0;d<r.length;d++)u.prototype["get"+n(r[d])]=i(r[d]),u.prototype["set"+n(r[d])]=function(p){return function(y){this[p]=!!y}}(r[d]);for(var f=0;f<o.length;f++)u.prototype["get"+n(o[f])]=i(o[f]),u.prototype["set"+n(o[f])]=function(p){return function(y){if(!s(y))throw new TypeError(p+" must be a Number");this[p]=Number(y)}}(o[f]);for(var g=0;g<l.length;g++)u.prototype["get"+n(l[g])]=i(l[g]),u.prototype["set"+n(l[g])]=function(p){return function(y){this[p]=String(y)}}(l[g]);return u})}(Dt)),Dt.exports}(function(t,e){(function(s,n){t.exports=n(Lr())})(Ys,function(n){var i=/(^|@)\S+:\d+/,r=/^\s*at .*(\S+:\d+|\(native\))/m,o=/^(eval@)?(\[native code])?$/;return{parse:function(a){if(typeof a.stacktrace<"u"||typeof a["opera#sourceloc"]<"u")return this.parseOpera(a);if(a.stack&&a.stack.match(r))return this.parseV8OrIE(a);if(a.stack)return this.parseFFOrSafari(a);throw new Error("Cannot parse given Error object")},extractLocation:function(a){if(a.indexOf(":")===-1)return[a];var h=/(.+?)(?::(\d+))?(?::(\d+))?$/,c=h.exec(a.replace(/[()]/g,""));return[c[1],c[2]||void 0,c[3]||void 0]},parseV8OrIE:function(a){var h=a.stack.split(`
290
292
  `).filter(function(c){return!!c.match(r)},this);return h.map(function(c){c.indexOf("(eval ")>-1&&(c=c.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var u=c.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),d=u.match(/ (\(.+\)$)/);u=d?u.replace(d[0],""):u;var f=this.extractLocation(d?d[1]:u),g=d&&u||void 0,p=["eval","<anonymous>"].indexOf(f[0])>-1?void 0:f[0];return new n({functionName:g,fileName:p,lineNumber:f[1],columnNumber:f[2],source:c})},this)},parseFFOrSafari:function(a){var h=a.stack.split(`
291
293
  `).filter(function(c){return!c.match(o)},this);return h.map(function(c){if(c.indexOf(" > eval")>-1&&(c=c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),c.indexOf("@")===-1&&c.indexOf(":")===-1)return new n({functionName:c});var u=/((.*".+"[^@]*)?[^@]*)(?:@)/,d=c.match(u),f=d&&d[1]?d[1]:void 0,g=this.extractLocation(c.replace(u,""));return new n({functionName:f,fileName:g[0],lineNumber:g[1],columnNumber:g[2],source:c})},this)},parseOpera:function(a){return!a.stacktrace||a.message.indexOf(`
292
294
  `)>-1&&a.message.split(`
@@ -294,19 +296,19 @@ We appreciate your time and valuable input.`),r=C("div","end_button_or",Ps,"Subm
294
296
  `).length?this.parseOpera9(a):a.stack?this.parseOpera11(a):this.parseOpera10(a)},parseOpera9:function(a){for(var h=/Line (\d+).*script (?:in )?(\S+)/i,c=a.message.split(`
295
297
  `),u=[],d=2,f=c.length;d<f;d+=2){var g=h.exec(c[d]);g&&u.push(new n({fileName:g[2],lineNumber:g[1],source:c[d]}))}return u},parseOpera10:function(a){for(var h=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,c=a.stacktrace.split(`
296
298
  `),u=[],d=0,f=c.length;d<f;d+=2){var g=h.exec(c[d]);g&&u.push(new n({functionName:g[3]||void 0,fileName:g[2],lineNumber:g[1],source:c[d]}))}return u},parseOpera11:function(a){var h=a.stack.split(`
297
- `).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return h.map(function(c){var u=c.split("@"),d=this.extractLocation(u.pop()),f=u.shift()||"",g=f.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,p;f.match(/\(([^)]*)\)/)&&(p=f.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var y=p===void 0||p==="[arguments not available]"?void 0:p.split(",");return new n({functionName:g,args:y,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:c})},this)}}})})(Qs);var Ar=Qs.exports;const Lr=Dr(Ar);function en(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function $e(t,e,s={}){let n=e;try{n=Lr.parse(t)}catch{}return mt(t.name,t.message,JSON.stringify(n),JSON.stringify(s))}function tn(t,e=window,s={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return $e(t.error,en(t),s);{let[n,i]=t.message.split(":");return i||(n="Error",i=t.message),mt(n,i,JSON.stringify(en(t)),JSON.stringify(s))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return $e(t.reason,[],s);{let n;try{n=JSON.stringify(t.reason)}catch{n=String(t.reason)}return mt("Unhandled Promise Rejection",n,"[]",JSON.stringify(s))}}return null}function Pr(t,e){const s=Object.assign({captureExceptions:!0},e);function n(i){function r(o){const l=tn(o,i);l!=null&&t.send(l)}t.attachEventListener(i,"unhandledrejection",r),t.attachEventListener(i,"error",r)}s.captureExceptions&&(t.observer.attachContextCallback(n),n(window))}function sn(t,e=document.location){return t=t.trim(),t.startsWith("//")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")?t:t.startsWith("/")?e.origin+t:e.origin+e.pathname+t}function Fr(t){return Zn&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const Br="https://static.openreplay.com/tracker/placeholder.jpeg";function Ur(t){function e(l,a){t.attributeSender.sendSetAttribute(l,"src",Br);const{width:h,height:c}=a.getBoundingClientRect();a.hasAttribute("width")||t.attributeSender.sendSetAttribute(l,"width",String(h)),a.hasAttribute("height")||t.attributeSender.sendSetAttribute(l,"height",String(c))}const s=function(l,a){const{srcset:h}=a;if(!h)return;const c=h.split(h.match(/,\s+/)?/,\s+/:",").map(u=>sn(u)).join(", ");t.attributeSender.sendSetAttribute(l,"srcset",c)},n=function(l,a){a.src.length>ei&&e(l,a),t.send(ft(l,"src",a.src,t.getBaseHref()))},i=t.safe(function(l){const a=sn(l.src||"");bs(a)&&t.send(Ds(t.timestamp(),0,0,0,0,0,a,"img",0,!1))}),r=t.safe(function(l){const a=t.nodes.getID(l);a!==void 0&&l.complete&&(l.naturalHeight===0&&l.naturalWidth===0&&!Fr(l.src)?i(l):t.sanitizer.isHidden(a)||t.sanitizer.isObscured(a)?e(a,l):(n(a,l),s(a,l)))}),o=ws(t.safe(l=>{for(const a of l)if(a.type==="attributes"){const h=a.target,c=t.nodes.getID(h);if(c===void 0)return;a.attributeName==="src"&&n(c,h),a.attributeName==="srcset"&&s(c,h)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(l=>{F(l,"img")&&(t.nodes.attachNodeListener(l,"error",()=>i(l)),t.nodes.attachNodeListener(l,"load",()=>r(l)),r(l),o.observe(l,{attributes:!0,attributeFilter:["src","srcset"]}))})}const Hr=["text","password","email","search","number","range","date","tel","time"];function jr(t){return F(t,"textarea")?!0:F(t,"input")?Hr.includes(t.type):!1}function zr(t){if(!F(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const Wr=G&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(F(e,"label"))return e;const s=t.labels;if(s!==null&&s.length===1)return s[0]}:t=>{let e=t;for(;(e=e.parentNode)!==null;)if(F(e,"label"))return e;const s=t.id;if(s){const n=t.ownerDocument.querySelectorAll('label[for="'+s+'"]');if(n!==null&&n.length===1)return n[0]}};function nn(t){let e=ut(t);if(e===null){const s=Wr(t);e=s&&s.innerText||t.placeholder||t.name||t.id||t.className||t.type}return ms(e).slice(0,100)}const be={Plain:0,Obscured:1,Hidden:2};function qr(t,e){const s=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:be.Obscured,obscureInputDates:!1},e);function n(c,u){let d=u.value,f=s.defaultInputMode;u.type==="password"||t.sanitizer.isHidden(c)?f=be.Hidden:(t.sanitizer.isObscured(c)||f===be.Plain&&(s.obscureInputNumbers&&u.type!=="date"&&/\d\d\d\d/.test(d)||s.obscureInputDates&&u.type==="date"||s.obscureInputEmails&&(u.type==="email"||~d.indexOf("@"))))&&(f=be.Obscured);let g=0;switch(f){case be.Hidden:g=-1,d="";break;case be.Obscured:g=d.length,d="";break}return{value:d,mask:g}}function i(c,u){const{value:d,mask:f}=n(c,u);t.send(mi(c,d,f))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function l(c,u){r.get(c)!==u.value&&(r.set(c,u.value),i(c,u))}function a(c,u){o.get(c)!==u&&(o.set(c,u),t.send(bi(c,u)))}t.ticker.attach(()=>{r.forEach((c,u)=>{const d=t.nodes.getNode(u);if(!d)return r.delete(u);l(u,d)}),o.forEach((c,u)=>{const d=t.nodes.getNode(u);if(!d)return o.delete(u);a(u,d.checked)})},3);function h(c,u,d,f){const{value:g,mask:p}=n(c,u),y=nn(u);t.send(Ai(c,g,p!==0,y,d,f))}t.nodes.attachNodeCallback(t.safe(c=>{const u=t.nodes.getID(c);if(u!==void 0){if(F(c,"select")&&(i(u,c),t.nodes.attachNodeListener(c,"change",()=>i(u,c))),jr(c)){l(u,c);let d=0,f=0,g=0;const p=()=>{d=V()},y=()=>{f===0&&d!==0&&(f=V()-d)},E=()=>{d!==0&&(g=V()-d),h(u,c,f,g),f=0,g=0,d=0};t.nodes.attachNodeListener(c,"focus",p),t.nodes.attachNodeListener(c,"input",y),t.nodes.attachNodeListener(c,"change",E);return}if(zr(c)){a(u,c.checked),t.nodes.attachNodeListener(c,"change",()=>a(u,c.checked));return}}}))}let $,Dt,rn;function $r(t,e){if(rn=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";const s={root:document.body,idName:i=>!0,className:i=>!0,tagName:i=>!0,attr:(i,r)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};$={...s,...e},Dt=Vr($.root,s);let n=Ve(t,"all",()=>Ve(t,"two",()=>Ve(t,"one",()=>Ve(t,"none"))));if(n){const i=un(dn(n,t));return i.length>0&&(n=i[0]),Xe(n)}else throw new Error("Selector was not found.")}function Vr(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Ve(t,e,s){let n=null,i=[],r=t,o=0;for(;r;){const l=new Date().getTime()-rn.getTime();if($.timeoutMs!==void 0&&l>$.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${l}ms`);let a=Ke(Xr(r))||Ke(...Gr(r))||Ke(...Kr(r))||Ke(Jr(r))||[ln()];const h=Yr(r);if(e=="all")h&&(a=a.concat(a.filter(Mt).map(c=>Ge(c,h))));else if(e=="two")a=a.slice(0,1),h&&(a=a.concat(a.filter(Mt).map(c=>Ge(c,h))));else if(e=="one"){const[c]=a=a.slice(0,1);h&&Mt(c)&&(a=[Ge(c,h)])}else e=="none"&&(a=[ln()],h&&(a=[Ge(a[0],h)]));for(let c of a)c.level=o;if(i.push(a),i.length>=$.seedMinLength&&(n=on(i,s),n))break;r=r.parentElement,o++}return n||(n=on(i,s)),!n&&s?s():n}function on(t,e){const s=un(hn(t));if(s.length>$.threshold)return e?e():null;for(let n of s)if(cn(n))return n;return null}function Xe(t){let e=t[0],s=e.name;for(let n=1;n<t.length;n++){const i=t[n].level||0;e.level===i-1?s=`${t[n].name} > ${s}`:s=`${t[n].name} ${s}`,e=t[n]}return s}function an(t){return t.map(e=>e.penalty).reduce((e,s)=>e+s,0)}function cn(t){const e=Xe(t);switch(Dt.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return!0;default:return!1}}function Xr(t){const e=t.getAttribute("id");return e&&$.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Gr(t){return Array.from(t.attributes).filter(s=>$.attr(s.name,s.value)).map(s=>({name:`[${CSS.escape(s.name)}="${CSS.escape(s.value)}"]`,penalty:.5}))}function Kr(t){return Array.from(t.classList).filter($.className).map(s=>({name:"."+CSS.escape(s),penalty:1}))}function Jr(t){const e=t.tagName.toLowerCase();return $.tagName(e)?{name:e,penalty:2}:null}function ln(){return{name:"*",penalty:3}}function Yr(t){const e=t.parentNode;if(!e)return null;let s=e.firstChild;if(!s)return null;let n=0;for(;s&&(s.nodeType===Node.ELEMENT_NODE&&n++,s!==t);)s=s.nextSibling;return n}function Ge(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function Mt(t){return t.name!=="html"&&!t.name.startsWith("#")}function Ke(...t){const e=t.filter(Qr);return e.length>0?e:null}function Qr(t){return t!=null}function*hn(t,e=[]){if(t.length>0)for(let s of t[0])yield*hn(t.slice(1,t.length),e.concat(s));else yield e}function un(t){return[...t].sort((e,s)=>an(e)-an(s))}function*dn(t,e,s={counter:0,visited:new Map}){if(t.length>2&&t.length>$.optimizedMinLength)for(let n=1;n<t.length-1;n++){if(s.counter>$.maxNumberOfTries)return;s.counter+=1;const i=[...t];i.splice(n,1);const r=Xe(i);if(s.visited.has(r))return;cn(i)&&Zr(i,e)&&(yield i,s.visited.set(r,!0),yield*dn(i,e,s))}}function Zr(t,e){return Dt.querySelector(Xe(t))===e}function eo(t,e,s){return $r(t,{root:e.body,seedMinLength:3,optimizedMinLength:(s==null?void 0:s.minSelectorDepth)||2,threshold:(s==null?void 0:s.nthThreshold)||1e3,maxNumberOfTries:(s==null?void 0:s.maxOptimiseTries)||1e4})}function At(t){const e=t.tagName.toUpperCase();return e==="BUTTON"||e==="A"||e==="LI"||e==="SELECT"||e==="TR"||e==="TH"||t.onclick!=null||t.getAttribute("role")==="button"}function fn(t,e){return t instanceof Element?to(t,e):null}function to(t,e){let s=t;for(;s!==null&&s!==e.documentElement;){if(oe(s,"masked"))return null;s=s.parentElement}if(kt(t)){let n=t.ownerSVGElement;for(;n!==null;)t=n,n=n.ownerSVGElement}for(s=t;s!==null&&s!==e.documentElement;){const n=s.tagName.toUpperCase();if(n==="LABEL")return null;if(n==="INPUT"||At(s)||ut(s)!==null)return s;s=s.parentElement}return t===e.documentElement?null:t}function so(t,e){const{disableClickmaps:s=!1}=e||{};function n(m){const w=ut(m);if(w!==null)return w;if(F(m,"input"))return nn(m);if(At(m)){let k="";return m instanceof HTMLElement&&(k=t.sanitizer.getInnerTextSecure(m)),k=k||m.id||m.className,ms(k).slice(0,100)}return""}let i=-1,r=-1,o=!1,l=null,a=0,h={},c=0,u=0,d=0,f=0,g;const p=.008,y=225;function E(){const m=f/y;if(!c){c=m;return}const w=(m-c)/y;d>4&&w>p&&t.send(Li(V())),f=0,d=0,c=m}t.attachStartCallback(()=>{g=setInterval(()=>E(),y)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,l=null,h={},g&&clearInterval(g)});const N=()=>{o&&(t.send(yi(i,r)),o=!1)},T=(m,w=!1)=>{function k(S,b,_){return h[S]=h[S]||eo(b,m,_)}const x=w?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);x(m.documentElement,"mouseover",S=>{const b=fn(S.target,m);b!==l&&(l=b,a=performance.now())}),x(m,"mousemove",S=>{const[b,_]=t.observer.getDocumentOffset(m);i=S.clientX+b,r=S.clientY+_,o=!0;const M=Math.sign(S.movementX);f+=Math.abs(S.movementX)+Math.abs(S.movementY),M!==u&&(u=M,d++)},!1),x(m,"click",S=>{const b=fn(S.target,m);if(!S.clientX&&!S.clientY||b===null)return;const _=t.nodes.getID(b);if(_!==void 0){const M=S.pageX,O=S.pageY,D=m.documentElement.scrollWidth,v=m.documentElement.scrollHeight,I=pn(M/D),A=pn(O/v);N(),t.send(Ri(_,l===b?Math.round(performance.now()-a):0,n(b),At(b)&&!s?k(_,b,e):"",I,A),!0)}l=null})};t.nodes.attachNodeCallback(m=>{ze(m)&&T(m)}),T(document,!0),t.ticker.attach(N,(e==null?void 0:e.trackingOffset)||7)}function pn(t){return Math.round(t*1e4)}function no(t){const e=[],s=document.getElementsByTagName("*"),n=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<s.length;i++){const r=s[i];let o="";if(F(r,"img")&&(o=r.currentSrc||r.src),!o){const g=getComputedStyle(r).getPropertyValue("background-image");if(g){const p=n.exec(g);p!==null&&(o=p[1],(o.startsWith('"')||o.startsWith("'"))&&(o=o.substr(1,o.length-2)))}}if(!o)continue;const l=o.substr(0,10)==="data:image"?0:t[o];if(l===void 0)continue;const a=r.getBoundingClientRect(),h=Math.max(a.top,0),c=Math.max(a.left,0),u=Math.min(a.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),d=Math.min(a.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(u<=h||d<=c)continue;const f=(u-h)*(d-c);e.push({time:l,area:f})}return e}function io(t,e){let s=Math.max(document.documentElement&&document.documentElement.clientWidth||0,window.innerWidth||0)*Math.max(document.documentElement&&document.documentElement.clientHeight||0,window.innerHeight||0)/10,n=s*t;for(let i=0;i<e.length;i++){const{time:r,area:o}=e[i];s+=o,n+=o*(r>t?r:t)}return s===0?0:n/s}function ro(t,e){const s=Object.assign({captureResourceTimings:!0,capturePageLoadTimings:!0,capturePageRenderTimings:!0,excludedResourceUrls:[]},e);if("PerformanceObserver"in window||(s.captureResourceTimings=!1),!s.captureResourceTimings)return;let n={};function i(h){var u;if(h.duration<0||!bs(h.name)||t.isServiceURL(h.name))return;n!==null&&(n[h.name]=h.startTime+h.duration);let c=!1;(u=s.excludedResourceUrls)==null||u.forEach(d=>{if(h.name.startsWith(d)){c=!0;return}}),!c&&t.send(Ds(h.startTime+pe(),h.duration,h.responseStart&&h.startTime?h.responseStart-h.startTime:0,h.transferSize>h.encodedBodySize?h.transferSize-h.encodedBodySize:0,h.encodedBodySize||0,h.decodedBodySize||0,h.name,h.initiatorType,h.transferSize,h.responseStatus&&h.responseStatus===304||h.transferSize===0))}const r=new PerformanceObserver(h=>h.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:h}){h!==o&&(performance.getEntriesByType("resource").forEach(i),o=h),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let l=0,a=0;if(s.capturePageLoadTimings){let h=!1;t.ticker.attach(()=>{if(!h&&((l===0||a===0)&&performance.getEntriesByType("paint").forEach(c=>{const{name:u,startTime:d}=c;switch(u){case"first-paint":l=d;break;case"first-contentful-paint":a=d;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){h=!0;const{navigationStart:c,requestStart:u,responseStart:d,responseEnd:f,domContentLoadedEventStart:g,domContentLoadedEventEnd:p,loadEventStart:y,loadEventEnd:E}=performance.timing;t.send(wi(u-c||0,d-c||0,f-c||0,g-c||0,p-c||0,y-c||0,E-c||0,l,a))}},30)}if(s.capturePageRenderTimings){let h=0,c=0,u=0,d=null,f=!1;t.ticker.attach(()=>{if(f)return;const g=performance.now();if(n!==null&&(h=Math.max.apply(null,Object.keys(n).map(p=>n[p])),g-h>1e3&&(d=no(n),n=null)),u!==null&&(g-u>50&&(c=g),u=g-c>5e3?null:g),d!==null&&u===null||g>3e4){f=!0,n=null;const p=d===null?0:io(a||l,d),{domContentLoadedEventEnd:y,navigationStart:E}=performance.timing,N=u===null?Math.max(c,a,y-E||0):0;t.send(vi(p,a>h?a:h,N))}})}}function Lt(t){const e=t.defaultView;return[e&&e.scrollX||t.documentElement&&t.documentElement.scrollLeft||t.body&&t.body.scrollLeft||0,e&&e.scrollY||t.documentElement&&t.documentElement.scrollTop||t.body&&t.body.scrollTop||0]}function oo(t,e){let s=!1;const n=new Map;function i(l){Ws(l)&&(ee(l)&&n.set(l,[l.scrollLeft,l.scrollTop]),ze(l)&&n.set(l,Lt(l)))}const r=t.safe(()=>{e||t.send(ci(...Lt(document)))}),o=t.safe((l,a)=>{const h=t.nodes.getID(a);h!==void 0&&t.send(gi(h,l[0],l[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{s=!1,n.clear()}),t.nodes.attachNodeCallback((l,a)=>{a&&(ee(l)&&l.scrollLeft+l.scrollTop>0?n.set(l,[l.scrollLeft,l.scrollTop]):ze(l)&&n.set(l,Lt(l))),We(l)&&t.nodes.attachNodeListener(l,"scroll",h=>{i(h.target)})}),t.attachEventListener(document,"scroll",l=>{const a=l.target;if(a===document){s=!0;return}i(a)}),t.ticker.attach(()=>{s&&(r(),s=!1),n.forEach(o),n.clear()},5,!1)}function ao(t){let e,s,n,i,r=document.referrer;const o=t.safe(()=>{const{URL:h}=document;h!==e&&(e=h,t.send(Ui(e,r,i,document.title)),i=0,r=e)}),l=t.safe(()=>{const{innerWidth:h,innerHeight:c}=window;(h!==s||c!==n)&&(s=h,n=c,t.send(ai(s,n)))}),a=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(Ci(document.hidden)));t.attachStartCallback(()=>{e=null,i=pe(),s=n=-1,o(),l(),a()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",a,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(l,5,!1)}function gn(t){return We(t)&&!!t.adoptedStyleSheets}let co=15;function mn(){return co++}const Je=new Map;function lo(t){if(t===null||!gn(document))return;const e=new Map,s=new Map,n=o=>setTimeout(()=>{let l=t.nodes.getID(o);if(o===document&&(l=0),l===void 0)return;let a=s.get(l);a||(a=[]);const h=[],c=o.adoptedStyleSheets;if(c&&Symbol.iterator in c)for(const u of c){let d=e.get(u);const f=!d;if(d||(d=mn(),e.set(u,d)),a.includes(d)||t.send(Os(d,l)),f){const g=u.cssRules;for(let p=0;p<g.length;p++)t.send(gt(d,g[p].cssText,p,t.getBaseHref()))}h.push(d)}if(Symbol.iterator in a)for(const u of a)h.includes(u)||t.send(Di(u,l));s.set(l,h)},20);function i(o){const l=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");l&&Object.defineProperty(o,"adoptedStyleSheets",{...l,set:function(a){const h=l.set.call(this,a);return n(this),h}})}const r=o=>{if(o.__openreplay_adpss_patched__)return;o.__openreplay_adpss_patched__=!0,i(o.Document.prototype),i(o.ShadowRoot.prototype);const{replace:l,replaceSync:a}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(h){return l.call(this,h).then(c=>{const u=e.get(this);return u&&t.send(Ns(u,h,t.getBaseHref())),c})},o.CSSStyleSheet.prototype.replaceSync=function(h){const c=e.get(this);return c&&t.send(Ns(c,h,t.getBaseHref())),a.call(this,h)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),s.clear()}),t.attachStartCallback(()=>{n(document)}),t.nodes.attachNodeCallback(o=>{gn(o)&&n(o)})}function ho(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(_i("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const l=Je.get(i);l&&(typeof o=="string"?t.send(gt(l,o,r,t.getBaseHref())):t.send(_s(l,r)))}),s=t.safe(i=>{let r=i;for(;r.parentRule;)r=r.parentRule;const o=r.parentStyleSheet;if(!o){t.debug.warn("No parent StyleSheet found for",r,i);return}const l=Je.get(o);if(!l){t.debug.warn("No sheedID found for",o,Je);return}const a=r.cssText,h=o.cssRules,c=Array.from(h).indexOf(r);c>=0?(t.send(gt(l,a,c,t.getBaseHref())),t.send(_s(l,c+1))):t.debug.warn("Rule index not found in",o,r)}),n=t.safe(i=>{const{insertRule:r,deleteRule:o}=i.CSSStyleSheet.prototype,{insertRule:l,deleteRule:a}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(h,c=0){return e(this,c,h),r.call(this,h,c)},i.CSSStyleSheet.prototype.deleteRule=function(h){return e(this,h),o.call(this,h)},i.CSSGroupingRule.prototype.insertRule=function(h,c=0){const u=l.call(this,h,c);return s(this),u},i.CSSGroupingRule.prototype.deleteRule=function(h=0){const c=a.call(this,h);return s(this),c}});n(window),t.observer.attachContextCallback(n),t.nodes.attachNodeCallback(i=>{if(!F(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const o=i.sheet,l=mn();Je.set(o,l),t.send(Os(l,r));const a=o.cssRules;for(let h=0;h<a.length;h++)e(o,h,a[h].cssText)})}function uo(t){function e(n){const i=t.nodes.getID(n);i!==void 0&&t.send(Cs(i))}let s=!1;t.nodes.attachNodeCallback(n=>{F(n,"body")&&(t.nodes.attachNodeListener(n,"focus",i=>{Ws(i.target)&&(e(i.target),s=!1)}),t.nodes.attachNodeListener(n,"blur",i=>{i.relatedTarget===null&&(s=!0,setTimeout(()=>{s&&t.send(Cs(-1))},0))}))}),t.attachStartCallback(()=>{let n=document.activeElement;for(;n&&F(n,"iframe")&&n.contentDocument;)n=n.contentDocument.activeElement;n&&n!==n.ownerDocument.body&&e(n)},!0)}function fo(t){if(!window.FontFace)return;const e=new Map,s=n=>{class i extends n.FontFace{constructor(...o){if(typeof o[1]=="string"){let l="";o[2]&&t.safe(()=>{l=JSON.stringify(o[2])});const a=[o[0],o[1],l],h=e.get(n.document)||[];h.push(a),e.set(n.document,h);const c=n===window?0:t.nodes.getID(n.document);if(c===void 0)return;t.active()&&t.send(Es(c,...a))}super(...o)}}n.FontFace=i};t.observer.attachContextCallback(s),s(window),t.nodes.attachNodeCallback(t.safe(n=>{if(!ze(n))return;const i=e.get(n);if(!i)return;const r=n.defaultView===window?0:t.nodes.getID(n);r!==void 0&&i.forEach(o=>{t.send(Es(r,...o))})}))}function po(t,e,s,n,i){t.debug.log("Openreplay: attaching axios spy to instance",e);function r(d){t.debug.log("Openreplay: capturing axios response data",d);const{headers:f,data:g,method:p,url:y,baseURL:E}=d.config,{data:N,headers:T,status:m,response:w}=d,{data:k,headers:x,status:S}=w||{},b=s.ignoreHeaders,_=Array.isArray(b)?R=>b.includes(R):()=>b;function M(R,U){_(U[0])||(R[U[0]]=U[1])}let O={},D={};f.toJSON?O=f.toJSON():f instanceof Headers?f.forEach((R,U)=>M(O,[U,R])):Array.isArray(f)?f.forEach(R=>M(O,R)):typeof f=="object"&&Object.entries(f).forEach(R=>M(O,R));const v=x||T;v.toJSON?D=v.toJSON():v instanceof Headers?v.forEach((R,U)=>M(D,[U,R])):Array.isArray(v)?v.forEach(R=>M(D,R)):typeof v=="object"&&Object.entries(v).forEach(([R,U])=>{_(R)||(D[R]=U)});const I=n({url:y,method:p||"",status:m||S||0,request:{headers:O,body:g},response:{headers:D,body:k||N}});if(!I){t.debug.log("Openreplay: empty request/response info, skipping");return}const A=d.config.__openreplay_timing,P=performance.now()-A;t.debug.log("Openreplay: final req object",I),t.send(Be("xhr",String(p),String(I.url),i(I.request),i(I.response),I.status,A+pe(),P,0))}function o(d){if(t.debug.log("Openreplay: capturing API request",d),d.__openreplay_timing=performance.now(),s.sessionTokenHeader){const f=typeof s.sessionTokenHeader=="string"?s.sessionTokenHeader:"X-OpenReplay-Session-Token",g=t.getSessionToken();g&&d.headers.set(f,g)}return d}function l(d){return s.failuresOnly||r(d),d}function a(d){return t.debug.log("Openreplay: capturing API request error",d),go(d)&&d.response?r(d.response):d instanceof Error&&t.send($e(d,[])),Promise.reject(d)}function h(d){t.debug.log("Openreplay: failed API request, skipping",d)}const c=e.interceptors.request.use(o,h,{synchronous:!0}),u=e.interceptors.response.use(l,a,{synchronous:!0});t.attachStopCallback(()=>{var d,f,g,p;(f=(d=e.interceptors.request).eject)==null||f.call(d,c),(p=(g=e.interceptors.response).eject)==null||p.call(g,u)})}function go(t){return mo(t)&&t.isAxiosError===!0}function mo(t){return t!==null&&typeof t=="object"}var J;(function(t){t[t.UNSENT=0]="UNSENT",t[t.OPENED=1]="OPENED",t[t.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",t[t.LOADING=3]="LOADING",t[t.DONE=4]="DONE"})(J||(J={}));class Pt{constructor(e=[],s,n){this.ignoredHeaders=e,this.setSessionTokenHeader=s,this.sanitize=n,this.id="",this.name="",this.method="",this.url="",this.status=0,this.statusText="",this.cancelState=0,this.readyState=0,this.header={},this.responseType="",this.requestHeader={},this.responseSize=0,this.responseSizeText="",this.startTime=0,this.endTime=0,this.duration=0,this.getData={},this.requestData=null}getMessage(){const{reqHs:e,resHs:s}=this.writeHeaders(),n={headers:e,body:this.method==="GET"?JSON.stringify(this.getData):this.requestData},i={headers:s,body:this.response},r=this.sanitize({url:this.url,method:this.method,status:this.status,request:n,response:i});if(r)return Be(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+pe(),this.duration,this.responseSize)}writeHeaders(){const e={};Object.entries(this.requestHeader).forEach(([n,i])=>{this.isHeaderIgnored(n)||(e[n]=i)}),this.setSessionTokenHeader((n,i)=>{e[n]=i});const s={};return Object.entries(this.header).forEach(([n,i])=>{this.isHeaderIgnored(n)||(s[n]=i)}),{reqHs:e,resHs:s}}isHeaderIgnored(e){return Array.isArray(this.ignoredHeaders)?this.ignoredHeaders.map(s=>s.toLowerCase()).includes(e.toLowerCase()):this.ignoredHeaders}}const xe=(t,e)=>{let s="";switch(t){case"":case"text":case"json":typeof e=="string"?s=e:Bt(e)||Array.isArray(e)?s=JSON.stringify(e):typeof e<"u"&&(s=Object.prototype.toString.call(e));break;case"blob":case"document":case"arraybuffer":default:typeof e<"u"&&(s=Object.prototype.toString.call(e));break}return s},Ft=t=>{if(!t)return null;let e;if(typeof t=="string"){(t[0]==="{"||t[0]==="[")&&(e=t);const s=t.split("&");s.length===1?e=t:e=s.join(",")}else if(yo(t)){const s=[];for(const[n,i]of t)s.push(`${n}=${typeof i=="string"?i:"[object Object]"}`);e=s.join(",")}else t instanceof Blob||t instanceof ReadableStream||t instanceof ArrayBuffer?e="byte data":Bt(t)?e=t:e=`can't parse body ${typeof t}`;return e},bo=(t,e={})=>{Bt(e)||(e={});let s=t?t.split("?"):[];if(s.shift(),s.length>0){s=s.join("?").split("&");for(const n of s){const i=n.split("=");try{e[i[0]]=decodeURIComponent(i[1])}catch{e[i[0]]=i[1]}}}return e};function Bt(t){return t!==null&&typeof t=="object"}function yo(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function Ye(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const Ut=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class So{constructor(e,s){this.resp=e,this.item=s,this.mockReader()}set(e,s,n){return Reflect.set(e,s,n)}get(e,s){const n=Reflect.get(e,s);switch(s){case"arrayBuffer":case"blob":case"formData":case"json":case"text":return()=>(this.item.responseType=s.toLowerCase(),n.apply(e).then(i=>(this.item.response=xe(this.item.responseType,i),i)))}return typeof n=="function"?n.bind(e):n}mockReader(){let e;if(!this.resp.body||typeof this.resp.body.getReader!="function")return;const s=this.resp.body.getReader;this.resp.body.getReader=()=>{const n=s.apply(this.resp.body);if(this.item.readyState===J.DONE)return n;const i=n.read,r=n.cancel;return this.item.responseType="arraybuffer",n.read=()=>i.apply(n).then(o=>{if(!e)e=new Uint8Array(o.value);else{const l=new Uint8Array(e.length+o.value.length);l.set(e),l.set(o.value,e.length),e=l}return this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.readyState=o.done?4:3,this.item.statusText=o.done?String(this.item.status):"Loading",this.item.responseSize=e.length,this.item.responseSizeText=Ye(this.item.responseSize),o.done&&(this.item.response=xe(this.item.responseType,e)),o}),n.cancel=(...o)=>(this.item.cancelState=2,this.item.statusText="Cancel",this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=xe(this.item.responseType,e),r.apply(n,o)),n}}}class wo{constructor(e,s,n,i,r,o){this.ignoredHeaders=e,this.setSessionTokenHeader=s,this.sanitize=n,this.sendMessage=i,this.isServiceUrl=r,this.tokenUrlMatcher=o}apply(e,s,n){const i=n[0],r=n[1];if(!i||typeof i!="string"&&!(i!=null&&i.url)||(i instanceof URL||typeof i=="string"?this.isServiceUrl(String(i)):this.isServiceUrl(String(i.url))))return e.apply(window,n);const l=new Pt(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(l,i,r),this.setSessionTokenHeader((a,h)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(l.url))){if(n[1]===void 0&&n[0]instanceof Request)return n[0].headers.append(a,h);n[1]||(n[1]={}),n[1].headers===void 0&&(n[1]={...n[1],headers:{}}),n[1].headers instanceof Headers?n[1].headers.append(a,h):Array.isArray(n[1].headers)?n[1].headers.push([a,h]):n[1].headers[a]=h}}),e.apply(window,n).then(this.afterFetch(l)).catch(a=>{throw l.endTime=performance.now(),l.duration=l.endTime-(l.startTime||l.endTime),a})}beforeFetch(e,s,n){let i,r="GET",o={};if(typeof s=="string"?(r=(n==null?void 0:n.method)||"GET",i=Ut(s),o=(n==null?void 0:n.headers)||{}):(r=s.method||"GET",i=Ut(s.url),o=s.headers),e.method=r,e.requestType="fetch",e.requestHeader=o,e.url=i.toString(),e.name=(i.pathname.split("/").pop()||"")+i.search,e.status=0,e.statusText="Pending",e.readyState=1,e.startTime||(e.startTime=performance.now()),Object.prototype.toString.call(o)==="[object Headers]"){e.requestHeader={};for(const[l,a]of o)e.requestHeader[l]=a}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[l,a]of i.searchParams)e.getData[l]=a}n!=null&&n.body&&(e.requestData=Ft(n.body))}afterFetch(e){return s=>{e.endTime=performance.now(),e.duration=e.endTime-(e.startTime||e.endTime),e.status=s.status,e.statusText=String(s.status);let n=!1;e.header={};for(const[i,r]of s.headers)e.header[i]=r,n=r.toLowerCase().indexOf("chunked")>-1?!0:n;return n?e.readyState=3:(e.readyState=4,this.handleResponseBody(s.clone(),e).then(i=>{e.responseSize=typeof i=="string"?i.length:i.byteLength,e.responseSizeText=Ye(e.responseSize),e.response=xe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(s,new So(s,e))}}handleResponseBody(e,s){const n=e.headers.get("content-type");return n&&n.includes("application/json")?(s.responseType="json",e.text()):n&&(n.includes("text/html")||n.includes("text/plain"))?(s.responseType="text",e.text()):(s.responseType="arraybuffer",e.arrayBuffer())}}class vo{static create(e,s,n,i,r,o){return new Proxy(fetch,new wo(e,s,n,i,r,o))}}class ko{constructor(e,s,n,i,r,o,l){this.ignoredHeaders=s,this.setSessionTokenHeader=n,this.sanitize=i,this.sendMessage=r,this.isServiceUrl=o,this.tokenUrlMatcher=l,this.XMLReq=e,this.XMLReq.onreadystatechange=()=>{this.onReadyStateChange()},this.XMLReq.onabort=()=>{this.onAbort()},this.XMLReq.ontimeout=()=>{this.onTimeout()},this.item=new Pt(s,n,i),this.item.requestType="xhr"}get(e,s){switch(s){case"open":return this.getOpen(e);case"send":return this.setSessionTokenHeader((i,r)=>{this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(this.item.url)||e.setRequestHeader(i,r)}),this.getSend(e);case"setRequestHeader":return this.getSetRequestHeader(e);default:const n=Reflect.get(e,s);return typeof n=="function"?n.bind(e):n}}set(e,s,n){switch(s){case"onreadystatechange":return this.setOnReadyStateChange(e,s,n);case"onabort":return this.setOnAbort(e,s,n);case"ontimeout":return this.setOnTimeout(e,s,n)}return Reflect.set(e,s,n)}onReadyStateChange(){if(!(this.item.url&&this.isServiceUrl(this.item.url))&&(this.item.readyState=this.XMLReq.readyState,this.item.responseType=this.XMLReq.responseType,this.item.endTime=performance.now(),this.item.duration=this.item.endTime-this.item.startTime,this.updateItemByReadyState(),setTimeout(()=>{this.item.response=xe(this.item.responseType,this.item.response)},0),this.XMLReq.readyState===J.DONE)){const e=this.item.getMessage();e&&this.sendMessage(e)}}onAbort(){this.item.cancelState=1,this.item.statusText="Abort";const e=this.item.getMessage();e&&this.sendMessage(e)}onTimeout(){this.item.cancelState=3,this.item.statusText="Timeout";const e=this.item.getMessage();e&&this.sendMessage(e)}getOpen(e){const s=Reflect.get(e,"open");return(...n)=>{var o,l;const i=n[0],r=n[1];return this.item.method=i?i.toUpperCase():"GET",this.item.url=((o=r.toString)==null?void 0:o.call(r))||"",this.item.name=((l=this.item.url)==null?void 0:l.replace(new RegExp("/*$"),"").split("/").pop())??"",this.item.getData=bo(this.item.url,{}),s.apply(e,n)}}getSend(e){const s=Reflect.get(e,"send");return(...n)=>{const i=n[0];return this.item.requestData=Ft(i),s.apply(e,n)}}getSetRequestHeader(e){const s=Reflect.get(e,"setRequestHeader");return(...n)=>(this.item.requestHeader||(this.item.requestHeader={}),this.item.requestHeader[n[0]]=n[1],s.apply(e,n))}setOnReadyStateChange(e,s,n){return Reflect.set(e,s,(...i)=>{this.onReadyStateChange(),n==null||n.apply(e,i)})}setOnAbort(e,s,n){return Reflect.set(e,s,(...i)=>{this.onAbort(),n.apply(e,i)})}setOnTimeout(e,s,n){return Reflect.set(e,s,(...i)=>{this.onTimeout(),n.apply(e,i)})}updateItemByReadyState(){switch(this.XMLReq.readyState){case J.UNSENT:case J.OPENED:this.item.status=J.UNSENT,this.item.statusText="Pending",this.item.startTime||(this.item.startTime=performance.now());break;case J.HEADERS_RECEIVED:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.item.header={};const e=this.XMLReq.getAllResponseHeaders()||"",s=e.split(`
298
- `);for(let n=0;n<s.length;n++){const i=s[n];if(!i)continue;const r=i.split(": "),o=r[0];this.item.header[o]=r.slice(1).join(": ")}break;case J.LOADING:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ye(this.item.responseSize));break;case J.DONE:this.item.status=this.XMLReq.status||this.item.status||0,this.item.statusText=String(this.item.status),this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=this.XMLReq.response,this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ye(this.item.responseSize));break;default:this.item.status=this.XMLReq.status,this.item.statusText="Unknown";break}}}class To{static create(e,s,n,i,r,o){return new Proxy(XMLHttpRequest,{construct(l){const a=new l;return new Proxy(a,new ko(a,e,s,n,i,r,o))}})}}const Io=t=>t instanceof Blob?t.type:t instanceof FormData?"multipart/form-data":t instanceof URLSearchParams?"application/x-www-form-urlencoded;charset=UTF-8":"text/plain;charset=UTF-8";class xo{constructor(e,s,n,i,r){this.ignoredHeaders=e,this.setSessionTokenHeader=s,this.sanitize=n,this.sendMessage=i,this.isServiceUrl=r}apply(e,s,n){const i=n[0],r=n[1],o=new Pt(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);if(this.isServiceUrl(i))return e.apply(s,n);const l=Ut(i);if(o.method="POST",o.url=i,o.name=(l.pathname.split("/").pop()||"")+l.search,o.requestType="beacon",o.requestHeader={"Content-Type":Io(r)},o.status=0,o.statusText="Pending",l.search&&l.searchParams){o.getData={};for(const[c,u]of l.searchParams)o.getData[c]=u}o.requestData=Ft(r),o.startTime||(o.startTime=performance.now());const a=e.apply(s,n);a?(o.endTime=performance.now(),o.duration=o.endTime-(o.startTime||o.endTime),o.status=0,o.statusText="Sent",o.readyState=4):(o.status=500,o.statusText="Unknown");const h=o.getMessage();return h&&this.sendMessage(h),a}}class ye{static hasSendBeacon(){return!!ye.origSendBeacon}static create(e,s,n,i,r){if(ye.hasSendBeacon())return new Proxy(ye.origSendBeacon,new xo(e,s,n,i,r))}}ye.origSendBeacon=(wn=window==null?void 0:window.navigator)==null?void 0:wn.sendBeacon;const bn=t=>console.warn(`Openreplay: Can't find ${t} in global context.
299
- If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function Eo(t,e,s,n,i,r,o){var l;t.XMLHttpRequest?t.XMLHttpRequest=To.create(e,s,n,i,r,o):bn("XMLHttpRequest"),t.fetch?t.fetch=vo.create(e,s,n,i,r,o):bn("fetch"),(l=t==null?void 0:t.navigator)!=null&&l.sendBeacon&&(t.navigator.sendBeacon=ye.create(e,s,n,i,r))}function Ht(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function yn(t){return typeof t=="string"?t.toUpperCase():"GET"}function Co(t,e={}){const s=Object.assign({failuresOnly:!1,ignoreHeaders:["cookie","set-cookie","authorization"],capturePayload:!1,sessionTokenHeader:!1,captureInIframes:!0,axiosInstances:void 0,useProxy:!0},e);s.useProxy===!1&&t.debug.warn("Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true");const n=s.ignoreHeaders,i=Array.isArray(n)?c=>n.includes(c):()=>n,r=s.sessionTokenHeader===!0?"X-OpenReplay-SessionToken":s.sessionTokenHeader;function o(c){if(r){const u=t.getSessionToken();u&&t.safe(c)(r,u)}}function l(c){if(s.capturePayload||(delete c.request.body,delete c.response.body),s.sanitizer){const u=c.response.body;if(typeof u=="string")try{c.response.body=JSON.parse(u)}catch{}return s.sanitizer(c)}return c}function a(c){if(c&&typeof c.body!="string")try{c.body=JSON.stringify(c.body)}catch{c.body="<unable to stringify>",t.notify.warn("Openreplay fetch couldn't stringify body:",c.body)}return JSON.stringify(c)}const h=c=>{if(s.useProxy)return Eo(c,s.ignoreHeaders,o,l,T=>t.send(T),T=>t.isServiceURL(T),s.tokenUrlMatcher);const u=c.fetch.bind(c),d=(T,m={})=>{if(!(typeof T=="string"||T instanceof URL)||t.isServiceURL(String(T)))return u(T,m);o(function(k,x){m.headers===void 0&&(m.headers={}),m.headers instanceof Headers?m.headers.append(k,x):Array.isArray(m.headers)?m.headers.push([k,x]):m.headers[k]=x});const w=performance.now();return u(T,m).then(k=>{const x=performance.now()-w;if(s.failuresOnly&&k.status<400)return k;const S=k.clone();return S.text().then(b=>{const _={},M={};if(n!==!0){const v=([I,A])=>{i(I)||(_[I]=A)};m.headers instanceof Headers?m.headers.forEach((I,A)=>v([A,I])):Array.isArray(m.headers)?m.headers.forEach(v):typeof m.headers=="object"&&Object.entries(m.headers).forEach(v),S.headers.forEach((I,A)=>{i(A)||(M[A]=I)})}const O=yn(m.method),D=l({url:String(T),method:O,status:S.status,request:{headers:_,body:m.body||null},response:{headers:M,body:b}});D&&t.send(Be("fetch",O,String(D.url),a(D.request),a(D.response),S.status,w+pe(),x,0))}).catch(b=>t.debug.error("Could not process Fetch response:",b)),k})};c.fetch=d;const f=c.XMLHttpRequest.prototype.open,g=c.XMLHttpRequest.prototype.setRequestHeader,p=c.XMLHttpRequest.prototype.send;function y(T,m){const w=this;o((x,S)=>w.setRequestHeader(x,S));let k=0;return w.addEventListener("loadstart",x=>{k=x.timeStamp}),w.addEventListener("load",t.safe(x=>{const{headers:S,body:b}=Ht(w),_=k>0?x.timeStamp-k:0,O=(w.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),D={};O.forEach(function(A){const P=A.split(": "),R=P.shift();i(R)||(D[R]=P.join(": "))});const v=yn(T),I=l({url:String(m),method:v,status:w.status,request:{headers:S,body:b||null},response:{headers:D,body:w.response}});I&&t.send(Be("xhr",v,String(I.url),a(I.request),a(I.response),w.status,k+pe(),_,0))})),f.apply(this,arguments)}function E(T){const m=Ht(this);return m.body=T,p.apply(this,arguments)}function N(T,m){if(!i(T)){const w=Ht(this);w.headers[T]=m}return g.apply(this,arguments)}s.axiosInstances||(c.XMLHttpRequest.prototype.open=y,c.XMLHttpRequest.prototype.send=E,c.XMLHttpRequest.prototype.setRequestHeader=N)};h(window),s.axiosInstances&&s.axiosInstances.forEach(c=>{po(t,c,s,l,a)}),s.captureInIframes&&t.observer.attachContextCallback(t.safe(h))}function No(t){t.attachEventListener(document,"selectionchange",()=>{const e=document.getSelection();if(e!==null&&!e.isCollapsed){const s=t.nodes.getID(e.anchorNode),n=t.nodes.getID(e.focusNode),i=e.toString().replace(/\s+/g," ");s&&n&&t.send(Rs(s,n,i))}else t.send(Rs(-1,-1,""))})}function _o(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(Ue(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const Qe="/installation/javascript-sdk";function Oo(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${Fe}${Qe}`),!1;if(typeof t.projectKey!="string")if(typeof t.projectKey!="number"){if(typeof t.projectID!="number")return console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${Fe}${Qe} for more information.`),!1;t.projectKey=t.projectID.toString(),ie("`projectID` option","`projectKey` option",Qe)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&ie("`sessionToken` option","`sessionHash` start() option","/"),!0}class Ro{constructor(e){var l;if(this.options=e,this.app=null,this.crossdomainMode=!1,this.checkDoNotTrack=()=>this.options.respectDoNotTrack&&(navigator.doNotTrack=="1"||window.doNotTrack=="1"),this.signalStartIssue=(a,h)=>{const c=this.checkDoNotTrack(),u=new XMLHttpRequest,d=this.options.ingestPoint||Xs;u.open("POST",d+"/v1/web/not-started"),u.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:c,reason:h.length?`missing api: ${h.join(",")}`:a}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(a,h={})=>{if(this.app!==null){if(a instanceof Error){const c=$e(a,[],h);this.app.send(c)}else if(a instanceof ErrorEvent||"PromiseRejectionEvent"in window&&a instanceof PromiseRejectionEvent){const c=tn(a,void 0,h);c!=null&&this.app.send(c)}}},this.crossdomainMode=!!(ni()&&((l=e.crossdomain)!=null&&l.enabled)),!G||!Oo(e))return;if(window.__OPENREPLAY__){console.error("OpenReplay: one tracker instance has been initialised already");return}if(!e.__DISABLE_SECURE_MODE&&location.protocol!=="https:"){console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");return}const s=this.checkDoNotTrack(),n=[],i=["Map","Set","MutationObserver","performance","timing","startsWith","Blob","Worker"];if(s)n.push("doNotTrack");else for(const a of i)if(a==="timing"){if("performance"in window&&!(a in performance)){n.push(a);break}}else if(a==="startsWith"){if(!(a in String.prototype)){n.push(a);break}}else if(!(a in window)){n.push(a);break}if(n.length>0){const a=n.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${a}`),this.signalStartIssue("missing_api",n);return}const r=new Er(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(ao(r),Cr(r),Hi(r,e),_o(r)),so(r,e.mouse),oo(r,this.crossdomainMode),ho(r),lo(r),Rr(r,e),Pr(r,e),Ur(r),qr(r,e),ro(r,e),uo(r),fo(r),Co(r,e.network),No(r),window.__OPENREPLAY__=this,e.flags&&e.flags.onFlagsLoad&&this.onFlagsLoad(e.flags.onFlagsLoad);const o=window.open;(e.autoResetOnWindowOpen||e.resetTabOnWindowOpen)&&(r.attachStartCallback(()=>{const a=r.getTabId(),h=r.sessionStorage??window.sessionStorage;window.open=function(...c){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&h.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),h.setItem(e.session_tabid_key||"__openreplay_tabid",a),o.call(window,...c)}}),r.attachStopCallback(()=>{window.open=o}))}isFlagEnabled(e){return this.featureFlags.isFlagEnabled(e)}onFlagsLoad(e){var s;(s=this.app)==null||s.featureFlags.onFlagsLoad(e)}clearPersistFlags(){var e;(e=this.app)==null||e.featureFlags.clearPersistFlags()}reloadFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.reloadFlags()}getFeatureFlag(e){var s;return(s=this.app)==null?void 0:s.featureFlags.getFeatureFlag(e)}getAllFeatureFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.flags}use(e){return e(this.app,this.options)}isActive(){return this.app===null?!1:this.app.active()}trackWs(e){if(this.app!==null)return this.app.trackWs(e)}start(e){return this.browserEnvCheck()?this.app===null?Promise.reject("Browser doesn't support required api, or doNotTrack is active."):this.app.start(e):Promise.reject("Trying to start not in browser.")}browserEnvCheck(){return G?!0:(console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${Fe}${Qe}`),!1)}coldStart(e,s){if(this.browserEnvCheck()){if(this.app===null)return Promise.reject("Tracker not initialized");this.app.coldStart(e,s)}else return Promise.reject("Trying to start not in browser.")}startOfflineRecording(e,s){return this.browserEnvCheck()?this.app===null?Promise.reject("Tracker not initialized"):this.app.offlineRecording(e,s):Promise.reject("Trying to start not in browser.")}uploadOfflineRecording(){if(this.app!==null)return this.app.uploadOfflineRecording()}stop(){if(this.app!==null)return this.app.stop(),this.app.session.getSessionHash()}forceFlushBatch(){this.app!==null&&this.app.forceFlushBatch()}getSessionToken(){return this.app===null?null:this.app.getSessionToken()}getSessionInfo(){return this.app===null?null:this.app.session.getInfo()}getSessionID(){return this.app===null?null:this.app.getSessionID()}getTabId(){return this.app===null?null:this.app.getTabId()}getUxId(){return this.app===null?null:this.app.getUxtId()}sessionID(){return ie("'sessionID' method","'getSessionID' method","/"),this.getSessionID()}getSessionURL(e){if(this.app!==null)return this.app.getSessionURL(e)}setUserID(e){typeof e=="string"&&this.app!==null&&this.app.session.setUserID(e)}userID(e){ie("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(Ii(e))}userAnonymousID(e){ie("'userAnonymousID' method","'setUserAnonymousID' method","/"),this.setUserAnonymousID(e)}setMetadata(e,s){typeof e=="string"&&typeof s=="string"&&this.app!==null&&this.app.session.setMetadata(e,s)}metadata(e,s){ie("'metadata' method","'setMetadata' method","/"),this.setMetadata(e,s)}event(e,s=null,n=!1){if(typeof e=="string"&&this.app!==null){if(n)return this.issue(e,s);try{s=JSON.stringify(s)}catch{return}this.app.send(ki(e,s))}}issue(e,s=null){if(typeof e=="string"&&this.app!==null){try{s=JSON.stringify(s)}catch{return}this.app.send(Oi(e,s))}}}const Do=3;function jt(){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");t.classList.contains("visible")?(Yt(),zt(),e.style.display="flex"):(Jt(),t.classList.add("visible"),e.style.display="none")}function zt(){console.log("ghbdtn"),Yt(),document.getElementById("chat-window").classList.remove("visible");let e=parseInt(j("chatCloseCount"))||0;e+=1,e>=Do?(console.log(e),Ce("disableAutoOpen","true",1),_n("chatCloseCount")):(console.log(e),Ce("chatCloseCount",e,1))}function Wt(t=null){t?Rn(t):Jt(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const Mo=["climats","telckel","biobio","weinpoint","vinigrandi"],Ao="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class Sn{constructor(e){var s;this.baseURL="https://api.wineater.com/",this.store=Mo.find(n=>window.location.href.includes(n)),this.token=((s=window==null?void 0:window.wineaterData)==null?void 0:s.CLIENT_TOKEN)||Ao}async getStoreConfig(e){console.log(e);try{const s=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:e})});if(!s.ok)throw new Error(`HTTP error! Status: ${s.status}`);return await s.json()}catch(s){throw console.error("Error fetching store configuration:",s),s}}async getWineRecommendations(e){console.log(window.location.href);try{const s=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:e,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),n=await s.json();if(!s.ok)throw new Error(`API call failed with status ${s.status}: ${n.message||"No additional error information"}`);return n}catch(s){throw console.error("Fetching wine recommendations failed:",s.message),new Error(`Error in getWineRecommendations: ${s.message}`)}}}class Lo{constructor(){this.api=new Sn,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",reason:"Suggestion",moreInfo:"Plus d'infos"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridaje ideal",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",reason:"Sugerencia",moreInfo:"Más info"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",reason:"Suggestion",moreInfo:"More info"},de:{welcomeMessage:"Verbessern Sie Ihr kulinarisches Erlebnis. Geben Sie einfach die Details Ihres Gerichts an und erhalten Sie die ideale Weinempfehlung. Was möchten Sie essen?",noResultsFound:"Keine Ergebnisse gefunden.",somethingWentWrong:"Entschuldigung, etwas ist schief gelaufen.",chatButton:"Wein zum Abendessen",inputPlaceholder:"z.B., Thunfischsalat",sendButton:"Kombinieren",price:"Preis",region:"Region",type:"Typ",reason:"Anregung",moreInfo:"Mehr Info"}}}async fetchConfig(e="Demo"){try{const s=await this.api.getStoreConfig(e);this.language=s.lang}catch{this.language="en"}}translate(e){return this.translations[this.language][e]||e}}const Y=new Lo;class Po{constructor(){var s;this.api=new Sn;const e=((s=window==null?void 0:window.wineaterData)==null?void 0:s.FIRST_MESSAGE_TEXT)||Y.translate("welcomeMessage");this.displayFirstMessage(e)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",n=>{n.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(e,s="api"){const n=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${s}`,i.textContent=e,n.appendChild(i),n.scrollTop=n.scrollHeight}async handleUserInput(){const e=document.getElementById("user-input"),s=e.value.trim();if(s){this.displayMessage(s,"user"),e.value="",this.showTypingIndicator();try{Dn(s);const n=await this.api.getWineRecommendations(s);this.hideTypingIndicator(),n&&n.length?this.displayResults(n):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(Y.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(e,s){const n=document.getElementById("message-container"),i=document.createElement("div");i.textContent=e,i.className="message "+s,n.appendChild(i),n.scrollTop=n.scrollHeight}sendAnalytics(e){console.log(e),An(e)}displayResults(e){const s=document.getElementById("message-container");Mn(e.map(n=>n.Title)),e.forEach(n=>{const i=document.createElement("div");i.className="wine-item";const r=document.createElement("img");r.src=n.Image,i.appendChild(r);const o=document.createElement("div");o.innerHTML=`
299
+ `).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return h.map(function(c){var u=c.split("@"),d=this.extractLocation(u.pop()),f=u.shift()||"",g=f.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,p;f.match(/\(([^)]*)\)/)&&(p=f.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var y=p===void 0||p==="[arguments not available]"?void 0:p.split(",");return new n({functionName:g,args:y,fileName:d[0],lineNumber:d[1],columnNumber:d[2],source:c})},this)}}})})(Qs);var Fr=Qs.exports;const Br=Pr(Fr);function en(t){return[{columnNumber:t.colno,lineNumber:t.lineno,fileName:t.filename,functionName:"",source:""}]}function $e(t,e,s={}){let n=e;try{n=Br.parse(t)}catch{}return bt(t.name,t.message,JSON.stringify(n),JSON.stringify(s))}function tn(t,e=window,s={}){if(t instanceof ErrorEvent){if(t.error instanceof Error)return $e(t.error,en(t),s);{let[n,i]=t.message.split(":");return i||(n="Error",i=t.message),bt(n,i,JSON.stringify(en(t)),JSON.stringify(s))}}else if("PromiseRejectionEvent"in e&&t instanceof e.PromiseRejectionEvent){if(t.reason instanceof Error)return $e(t.reason,[],s);{let n;try{n=JSON.stringify(t.reason)}catch{n=String(t.reason)}return bt("Unhandled Promise Rejection",n,"[]",JSON.stringify(s))}}return null}function Ur(t,e){const s=Object.assign({captureExceptions:!0},e);function n(i){function r(o){const l=tn(o,i);l!=null&&t.send(l)}t.attachEventListener(i,"unhandledrejection",r),t.attachEventListener(i,"error",r)}s.captureExceptions&&(t.observer.attachContextCallback(n),n(window))}function sn(t,e=document.location){return t=t.trim(),t.startsWith("//")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")?t:t.startsWith("/")?e.origin+t:e.origin+e.pathname+t}function Hr(t){return si&&(t.startsWith("data:image/svg+xml")||t.match(/.svg$|/i))}const jr="https://static.openreplay.com/tracker/placeholder.jpeg";function zr(t){function e(l,a){t.attributeSender.sendSetAttribute(l,"src",jr);const{width:h,height:c}=a.getBoundingClientRect();a.hasAttribute("width")||t.attributeSender.sendSetAttribute(l,"width",String(h)),a.hasAttribute("height")||t.attributeSender.sendSetAttribute(l,"height",String(c))}const s=function(l,a){const{srcset:h}=a;if(!h)return;const c=h.split(h.match(/,\s+/)?/,\s+/:",").map(u=>sn(u)).join(", ");t.attributeSender.sendSetAttribute(l,"srcset",c)},n=function(l,a){a.src.length>ni&&e(l,a),t.send(pt(l,"src",a.src,t.getBaseHref()))},i=t.safe(function(l){const a=sn(l.src||"");bs(a)&&t.send(Ds(t.timestamp(),0,0,0,0,0,a,"img",0,!1))}),r=t.safe(function(l){const a=t.nodes.getID(l);a!==void 0&&l.complete&&(l.naturalHeight===0&&l.naturalWidth===0&&!Hr(l.src)?i(l):t.sanitizer.isHidden(a)||t.sanitizer.isObscured(a)?e(a,l):(n(a,l),s(a,l)))}),o=ws(t.safe(l=>{for(const a of l)if(a.type==="attributes"){const h=a.target,c=t.nodes.getID(h);if(c===void 0)return;a.attributeName==="src"&&n(c,h),a.attributeName==="srcset"&&s(c,h)}}));t.attachStopCallback(()=>{o.disconnect()}),t.nodes.attachNodeCallback(l=>{F(l,"img")&&(t.nodes.attachNodeListener(l,"error",()=>i(l)),t.nodes.attachNodeListener(l,"load",()=>r(l)),r(l),o.observe(l,{attributes:!0,attributeFilter:["src","srcset"]}))})}const Wr=["text","password","email","search","number","range","date","tel","time"];function qr(t){return F(t,"textarea")?!0:F(t,"input")?Wr.includes(t.type):!1}function $r(t){if(!F(t,"input"))return!1;const e=t.type;return e==="checkbox"||e==="radio"}const Vr=K&&"labels"in HTMLInputElement.prototype?t=>{let e=t;for(;(e=e.parentNode)!==null;)if(F(e,"label"))return e;const s=t.labels;if(s!==null&&s.length===1)return s[0]}:t=>{let e=t;for(;(e=e.parentNode)!==null;)if(F(e,"label"))return e;const s=t.id;if(s){const n=t.ownerDocument.querySelectorAll('label[for="'+s+'"]');if(n!==null&&n.length===1)return n[0]}};function nn(t){let e=dt(t);if(e===null){const s=Vr(t);e=s&&s.innerText||t.placeholder||t.name||t.id||t.className||t.type}return ms(e).slice(0,100)}const be={Plain:0,Obscured:1,Hidden:2};function Xr(t,e){const s=Object.assign({obscureInputNumbers:!0,obscureInputEmails:!0,defaultInputMode:be.Obscured,obscureInputDates:!1},e);function n(c,u){let d=u.value,f=s.defaultInputMode;u.type==="password"||t.sanitizer.isHidden(c)?f=be.Hidden:(t.sanitizer.isObscured(c)||f===be.Plain&&(s.obscureInputNumbers&&u.type!=="date"&&/\d\d\d\d/.test(d)||s.obscureInputDates&&u.type==="date"||s.obscureInputEmails&&(u.type==="email"||~d.indexOf("@"))))&&(f=be.Obscured);let g=0;switch(f){case be.Hidden:g=-1,d="";break;case be.Obscured:g=d.length,d="";break}return{value:d,mask:g}}function i(c,u){const{value:d,mask:f}=n(c,u);t.send(Si(c,d,f))}const r=new Map,o=new Map;t.attachStopCallback(()=>{r.clear(),o.clear()});function l(c,u){r.get(c)!==u.value&&(r.set(c,u.value),i(c,u))}function a(c,u){o.get(c)!==u&&(o.set(c,u),t.send(wi(c,u)))}t.ticker.attach(()=>{r.forEach((c,u)=>{const d=t.nodes.getNode(u);if(!d)return r.delete(u);l(u,d)}),o.forEach((c,u)=>{const d=t.nodes.getNode(u);if(!d)return o.delete(u);a(u,d.checked)})},3);function h(c,u,d,f){const{value:g,mask:p}=n(c,u),y=nn(u);t.send(Fi(c,g,p!==0,y,d,f))}t.nodes.attachNodeCallback(t.safe(c=>{const u=t.nodes.getID(c);if(u!==void 0){if(F(c,"select")&&(i(u,c),t.nodes.attachNodeListener(c,"change",()=>i(u,c))),qr(c)){l(u,c);let d=0,f=0,g=0;const p=()=>{d=X()},y=()=>{f===0&&d!==0&&(f=X()-d)},E=()=>{d!==0&&(g=X()-d),h(u,c,f,g),f=0,g=0,d=0};t.nodes.attachNodeListener(c,"focus",p),t.nodes.attachNodeListener(c,"input",y),t.nodes.attachNodeListener(c,"change",E);return}if($r(c)){a(u,c.checked),t.nodes.attachNodeListener(c,"change",()=>a(u,c.checked));return}}}))}let $,Mt,rn;function Gr(t,e){if(rn=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return"html";const s={root:document.body,idName:i=>!0,className:i=>!0,tagName:i=>!0,attr:(i,r)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};$={...s,...e},Mt=Kr($.root,s);let n=Ve(t,"all",()=>Ve(t,"two",()=>Ve(t,"one",()=>Ve(t,"none"))));if(n){const i=un(dn(n,t));return i.length>0&&(n=i[0]),Xe(n)}else throw new Error("Selector was not found.")}function Kr(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Ve(t,e,s){let n=null,i=[],r=t,o=0;for(;r;){const l=new Date().getTime()-rn.getTime();if($.timeoutMs!==void 0&&l>$.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${l}ms`);let a=Ke(Jr(r))||Ke(...Yr(r))||Ke(...Qr(r))||Ke(Zr(r))||[ln()];const h=eo(r);if(e=="all")h&&(a=a.concat(a.filter(At).map(c=>Ge(c,h))));else if(e=="two")a=a.slice(0,1),h&&(a=a.concat(a.filter(At).map(c=>Ge(c,h))));else if(e=="one"){const[c]=a=a.slice(0,1);h&&At(c)&&(a=[Ge(c,h)])}else e=="none"&&(a=[ln()],h&&(a=[Ge(a[0],h)]));for(let c of a)c.level=o;if(i.push(a),i.length>=$.seedMinLength&&(n=on(i,s),n))break;r=r.parentElement,o++}return n||(n=on(i,s)),!n&&s?s():n}function on(t,e){const s=un(hn(t));if(s.length>$.threshold)return e?e():null;for(let n of s)if(cn(n))return n;return null}function Xe(t){let e=t[0],s=e.name;for(let n=1;n<t.length;n++){const i=t[n].level||0;e.level===i-1?s=`${t[n].name} > ${s}`:s=`${t[n].name} ${s}`,e=t[n]}return s}function an(t){return t.map(e=>e.penalty).reduce((e,s)=>e+s,0)}function cn(t){const e=Xe(t);switch(Mt.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return!0;default:return!1}}function Jr(t){const e=t.getAttribute("id");return e&&$.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Yr(t){return Array.from(t.attributes).filter(s=>$.attr(s.name,s.value)).map(s=>({name:`[${CSS.escape(s.name)}="${CSS.escape(s.value)}"]`,penalty:.5}))}function Qr(t){return Array.from(t.classList).filter($.className).map(s=>({name:"."+CSS.escape(s),penalty:1}))}function Zr(t){const e=t.tagName.toLowerCase();return $.tagName(e)?{name:e,penalty:2}:null}function ln(){return{name:"*",penalty:3}}function eo(t){const e=t.parentNode;if(!e)return null;let s=e.firstChild;if(!s)return null;let n=0;for(;s&&(s.nodeType===Node.ELEMENT_NODE&&n++,s!==t);)s=s.nextSibling;return n}function Ge(t,e){return{name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function At(t){return t.name!=="html"&&!t.name.startsWith("#")}function Ke(...t){const e=t.filter(to);return e.length>0?e:null}function to(t){return t!=null}function*hn(t,e=[]){if(t.length>0)for(let s of t[0])yield*hn(t.slice(1,t.length),e.concat(s));else yield e}function un(t){return[...t].sort((e,s)=>an(e)-an(s))}function*dn(t,e,s={counter:0,visited:new Map}){if(t.length>2&&t.length>$.optimizedMinLength)for(let n=1;n<t.length-1;n++){if(s.counter>$.maxNumberOfTries)return;s.counter+=1;const i=[...t];i.splice(n,1);const r=Xe(i);if(s.visited.has(r))return;cn(i)&&so(i,e)&&(yield i,s.visited.set(r,!0),yield*dn(i,e,s))}}function so(t,e){return Mt.querySelector(Xe(t))===e}function no(t,e,s){return Gr(t,{root:e.body,seedMinLength:3,optimizedMinLength:(s==null?void 0:s.minSelectorDepth)||2,threshold:(s==null?void 0:s.nthThreshold)||1e3,maxNumberOfTries:(s==null?void 0:s.maxOptimiseTries)||1e4})}function Pt(t){const e=t.tagName.toUpperCase();return e==="BUTTON"||e==="A"||e==="LI"||e==="SELECT"||e==="TR"||e==="TH"||t.onclick!=null||t.getAttribute("role")==="button"}function fn(t,e){return t instanceof Element?io(t,e):null}function io(t,e){let s=t;for(;s!==null&&s!==e.documentElement;){if(oe(s,"masked"))return null;s=s.parentElement}if(Tt(t)){let n=t.ownerSVGElement;for(;n!==null;)t=n,n=n.ownerSVGElement}for(s=t;s!==null&&s!==e.documentElement;){const n=s.tagName.toUpperCase();if(n==="LABEL")return null;if(n==="INPUT"||Pt(s)||dt(s)!==null)return s;s=s.parentElement}return t===e.documentElement?null:t}function ro(t,e){const{disableClickmaps:s=!1}=e||{};function n(m){const w=dt(m);if(w!==null)return w;if(F(m,"input"))return nn(m);if(Pt(m)){let k="";return m instanceof HTMLElement&&(k=t.sanitizer.getInnerTextSecure(m)),k=k||m.id||m.className,ms(k).slice(0,100)}return""}let i=-1,r=-1,o=!1,l=null,a=0,h={},c=0,u=0,d=0,f=0,g;const p=.008,y=225;function E(){const m=f/y;if(!c){c=m;return}const w=(m-c)/y;d>4&&w>p&&t.send(Bi(X())),f=0,d=0,c=m}t.attachStartCallback(()=>{g=setInterval(()=>E(),y)}),t.attachStopCallback(()=>{i=-1,r=-1,o=!1,l=null,h={},g&&clearInterval(g)});const N=()=>{o&&(t.send(vi(i,r)),o=!1)},T=(m,w=!1)=>{function k(S,b,_){return h[S]=h[S]||no(b,m,_)}const x=w?t.attachEventListener.bind(t):t.nodes.attachNodeListener.bind(t.nodes);x(m.documentElement,"mouseover",S=>{const b=fn(S.target,m);b!==l&&(l=b,a=performance.now())}),x(m,"mousemove",S=>{const[b,_]=t.observer.getDocumentOffset(m);i=S.clientX+b,r=S.clientY+_,o=!0;const M=Math.sign(S.movementX);f+=Math.abs(S.movementX)+Math.abs(S.movementY),M!==u&&(u=M,d++)},!1),x(m,"click",S=>{const b=fn(S.target,m);if(!S.clientX&&!S.clientY||b===null)return;const _=t.nodes.getID(b);if(_!==void 0){const M=S.pageX,O=S.pageY,D=m.documentElement.scrollWidth,v=m.documentElement.scrollHeight,I=pn(M/D),A=pn(O/v);N(),t.send(Ai(_,l===b?Math.round(performance.now()-a):0,n(b),Pt(b)&&!s?k(_,b,e):"",I,A),!0)}l=null})};t.nodes.attachNodeCallback(m=>{ze(m)&&T(m)}),T(document,!0),t.ticker.attach(N,(e==null?void 0:e.trackingOffset)||7)}function pn(t){return Math.round(t*1e4)}function oo(t){const e=[],s=document.getElementsByTagName("*"),n=/url\(("[^"]*"|'[^']*'|[^)]*)\)/i;for(let i=0;i<s.length;i++){const r=s[i];let o="";if(F(r,"img")&&(o=r.currentSrc||r.src),!o){const g=getComputedStyle(r).getPropertyValue("background-image");if(g){const p=n.exec(g);p!==null&&(o=p[1],(o.startsWith('"')||o.startsWith("'"))&&(o=o.substr(1,o.length-2)))}}if(!o)continue;const l=o.substr(0,10)==="data:image"?0:t[o];if(l===void 0)continue;const a=r.getBoundingClientRect(),h=Math.max(a.top,0),c=Math.max(a.left,0),u=Math.min(a.bottom,window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0),d=Math.min(a.right,window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0);if(u<=h||d<=c)continue;const f=(u-h)*(d-c);e.push({time:l,area:f})}return e}function ao(t,e){let s=Math.max(document.documentElement&&document.documentElement.clientWidth||0,window.innerWidth||0)*Math.max(document.documentElement&&document.documentElement.clientHeight||0,window.innerHeight||0)/10,n=s*t;for(let i=0;i<e.length;i++){const{time:r,area:o}=e[i];s+=o,n+=o*(r>t?r:t)}return s===0?0:n/s}function co(t,e){const s=Object.assign({captureResourceTimings:!0,capturePageLoadTimings:!0,capturePageRenderTimings:!0,excludedResourceUrls:[]},e);if("PerformanceObserver"in window||(s.captureResourceTimings=!1),!s.captureResourceTimings)return;let n={};function i(h){var u;if(h.duration<0||!bs(h.name)||t.isServiceURL(h.name))return;n!==null&&(n[h.name]=h.startTime+h.duration);let c=!1;(u=s.excludedResourceUrls)==null||u.forEach(d=>{if(h.name.startsWith(d)){c=!0;return}}),!c&&t.send(Ds(h.startTime+pe(),h.duration,h.responseStart&&h.startTime?h.responseStart-h.startTime:0,h.transferSize>h.encodedBodySize?h.transferSize-h.encodedBodySize:0,h.encodedBodySize||0,h.decodedBodySize||0,h.name,h.initiatorType,h.transferSize,h.responseStatus&&h.responseStatus===304||h.transferSize===0))}const r=new PerformanceObserver(h=>h.getEntries().forEach(i));let o;t.attachStartCallback(function({sessionID:h}){h!==o&&(performance.getEntriesByType("resource").forEach(i),o=h),r.observe({entryTypes:["resource"]})}),t.attachStopCallback(function(){r.disconnect()});let l=0,a=0;if(s.capturePageLoadTimings){let h=!1;t.ticker.attach(()=>{if(!h&&((l===0||a===0)&&performance.getEntriesByType("paint").forEach(c=>{const{name:u,startTime:d}=c;switch(u){case"first-paint":l=d;break;case"first-contentful-paint":a=d;break}}),performance.timing.loadEventEnd||performance.now()>3e4)){h=!0;const{navigationStart:c,requestStart:u,responseStart:d,responseEnd:f,domContentLoadedEventStart:g,domContentLoadedEventEnd:p,loadEventStart:y,loadEventEnd:E}=performance.timing;t.send(Ti(u-c||0,d-c||0,f-c||0,g-c||0,p-c||0,y-c||0,E-c||0,l,a))}},30)}if(s.capturePageRenderTimings){let h=0,c=0,u=0,d=null,f=!1;t.ticker.attach(()=>{if(f)return;const g=performance.now();if(n!==null&&(h=Math.max.apply(null,Object.keys(n).map(p=>n[p])),g-h>1e3&&(d=oo(n),n=null)),u!==null&&(g-u>50&&(c=g),u=g-c>5e3?null:g),d!==null&&u===null||g>3e4){f=!0,n=null;const p=d===null?0:ao(a||l,d),{domContentLoadedEventEnd:y,navigationStart:E}=performance.timing,N=u===null?Math.max(c,a,y-E||0):0;t.send(Ii(p,a>h?a:h,N))}})}}function Lt(t){const e=t.defaultView;return[e&&e.scrollX||t.documentElement&&t.documentElement.scrollLeft||t.body&&t.body.scrollLeft||0,e&&e.scrollY||t.documentElement&&t.documentElement.scrollTop||t.body&&t.body.scrollTop||0]}function lo(t,e){let s=!1;const n=new Map;function i(l){Ws(l)&&(ee(l)&&n.set(l,[l.scrollLeft,l.scrollTop]),ze(l)&&n.set(l,Lt(l)))}const r=t.safe(()=>{e||t.send(ui(...Lt(document)))}),o=t.safe((l,a)=>{const h=t.nodes.getID(a);h!==void 0&&t.send(yi(h,l[0],l[1]))});t.attachStartCallback(r),t.attachStopCallback(()=>{s=!1,n.clear()}),t.nodes.attachNodeCallback((l,a)=>{a&&(ee(l)&&l.scrollLeft+l.scrollTop>0?n.set(l,[l.scrollLeft,l.scrollTop]):ze(l)&&n.set(l,Lt(l))),We(l)&&t.nodes.attachNodeListener(l,"scroll",h=>{i(h.target)})}),t.attachEventListener(document,"scroll",l=>{const a=l.target;if(a===document){s=!0;return}i(a)}),t.ticker.attach(()=>{s&&(r(),s=!1),n.forEach(o),n.clear()},5,!1)}function ho(t){let e,s,n,i,r=document.referrer;const o=t.safe(()=>{const{URL:h}=document;h!==e&&(e=h,t.send(zi(e,r,i,document.title)),i=0,r=e)}),l=t.safe(()=>{const{innerWidth:h,innerHeight:c}=window;(h!==s||c!==n)&&(s=h,n=c,t.send(hi(s,n)))}),a=document.hidden===void 0?Function.prototype:t.safe(()=>t.send(Oi(document.hidden)));t.attachStartCallback(()=>{e=null,i=pe(),s=n=-1,o(),l(),a()}),document.hidden!==void 0&&t.attachEventListener(document,"visibilitychange",a,!1,!1),t.ticker.attach(o,1,!1),t.ticker.attach(l,5,!1)}function gn(t){return We(t)&&!!t.adoptedStyleSheets}let uo=15;function mn(){return uo++}const Je=new Map;function fo(t){if(t===null||!gn(document))return;const e=new Map,s=new Map,n=o=>setTimeout(()=>{let l=t.nodes.getID(o);if(o===document&&(l=0),l===void 0)return;let a=s.get(l);a||(a=[]);const h=[],c=o.adoptedStyleSheets;if(c&&Symbol.iterator in c)for(const u of c){let d=e.get(u);const f=!d;if(d||(d=mn(),e.set(u,d)),a.includes(d)||t.send(Os(d,l)),f){const g=u.cssRules;for(let p=0;p<g.length;p++)t.send(mt(d,g[p].cssText,p,t.getBaseHref()))}h.push(d)}if(Symbol.iterator in a)for(const u of a)h.includes(u)||t.send(Pi(u,l));s.set(l,h)},20);function i(o){const l=Object.getOwnPropertyDescriptor(o,"adoptedStyleSheets");l&&Object.defineProperty(o,"adoptedStyleSheets",{...l,set:function(a){const h=l.set.call(this,a);return n(this),h}})}const r=o=>{if(o.__openreplay_adpss_patched__)return;o.__openreplay_adpss_patched__=!0,i(o.Document.prototype),i(o.ShadowRoot.prototype);const{replace:l,replaceSync:a}=o.CSSStyleSheet.prototype;o.CSSStyleSheet.prototype.replace=function(h){return l.call(this,h).then(c=>{const u=e.get(this);return u&&t.send(Ns(u,h,t.getBaseHref())),c})},o.CSSStyleSheet.prototype.replaceSync=function(h){const c=e.get(this);return c&&t.send(Ns(c,h,t.getBaseHref())),a.call(this,h)}};r(window),t.observer.attachContextCallback(t.safe(r)),t.attachStopCallback(()=>{e.clear(),s.clear()}),t.attachStartCallback(()=>{n(document)}),t.nodes.attachNodeCallback(o=>{gn(o)&&n(o)})}function po(t){if(t===null)return;if(!window.CSSStyleSheet){t.send(Di("no_stylesheet_prototype_in_window",""));return}const e=t.safe((i,r,o)=>{const l=Je.get(i);l&&(typeof o=="string"?t.send(mt(l,o,r,t.getBaseHref())):t.send(_s(l,r)))}),s=t.safe(i=>{let r=i;for(;r.parentRule;)r=r.parentRule;const o=r.parentStyleSheet;if(!o){t.debug.warn("No parent StyleSheet found for",r,i);return}const l=Je.get(o);if(!l){t.debug.warn("No sheedID found for",o,Je);return}const a=r.cssText,h=o.cssRules,c=Array.from(h).indexOf(r);c>=0?(t.send(mt(l,a,c,t.getBaseHref())),t.send(_s(l,c+1))):t.debug.warn("Rule index not found in",o,r)}),n=t.safe(i=>{const{insertRule:r,deleteRule:o}=i.CSSStyleSheet.prototype,{insertRule:l,deleteRule:a}=i.CSSGroupingRule.prototype;i.CSSStyleSheet.prototype.insertRule=function(h,c=0){return e(this,c,h),r.call(this,h,c)},i.CSSStyleSheet.prototype.deleteRule=function(h){return e(this,h),o.call(this,h)},i.CSSGroupingRule.prototype.insertRule=function(h,c=0){const u=l.call(this,h,c);return s(this),u},i.CSSGroupingRule.prototype.deleteRule=function(h=0){const c=a.call(this,h);return s(this),c}});n(window),t.observer.attachContextCallback(n),t.nodes.attachNodeCallback(i=>{if(!F(i,"style")||!i.sheet||i.textContent!==null&&i.textContent.trim().length>0)return;const r=t.nodes.getID(i);if(!r)return;const o=i.sheet,l=mn();Je.set(o,l),t.send(Os(l,r));const a=o.cssRules;for(let h=0;h<a.length;h++)e(o,h,a[h].cssText)})}function go(t){function e(n){const i=t.nodes.getID(n);i!==void 0&&t.send(Cs(i))}let s=!1;t.nodes.attachNodeCallback(n=>{F(n,"body")&&(t.nodes.attachNodeListener(n,"focus",i=>{Ws(i.target)&&(e(i.target),s=!1)}),t.nodes.attachNodeListener(n,"blur",i=>{i.relatedTarget===null&&(s=!0,setTimeout(()=>{s&&t.send(Cs(-1))},0))}))}),t.attachStartCallback(()=>{let n=document.activeElement;for(;n&&F(n,"iframe")&&n.contentDocument;)n=n.contentDocument.activeElement;n&&n!==n.ownerDocument.body&&e(n)},!0)}function mo(t){if(!window.FontFace)return;const e=new Map,s=n=>{class i extends n.FontFace{constructor(...o){if(typeof o[1]=="string"){let l="";o[2]&&t.safe(()=>{l=JSON.stringify(o[2])});const a=[o[0],o[1],l],h=e.get(n.document)||[];h.push(a),e.set(n.document,h);const c=n===window?0:t.nodes.getID(n.document);if(c===void 0)return;t.active()&&t.send(Es(c,...a))}super(...o)}}n.FontFace=i};t.observer.attachContextCallback(s),s(window),t.nodes.attachNodeCallback(t.safe(n=>{if(!ze(n))return;const i=e.get(n);if(!i)return;const r=n.defaultView===window?0:t.nodes.getID(n);r!==void 0&&i.forEach(o=>{t.send(Es(r,...o))})}))}function bo(t,e,s,n,i){t.debug.log("Openreplay: attaching axios spy to instance",e);function r(d){t.debug.log("Openreplay: capturing axios response data",d);const{headers:f,data:g,method:p,url:y,baseURL:E}=d.config,{data:N,headers:T,status:m,response:w}=d,{data:k,headers:x,status:S}=w||{},b=s.ignoreHeaders,_=Array.isArray(b)?R=>b.includes(R):()=>b;function M(R,U){_(U[0])||(R[U[0]]=U[1])}let O={},D={};f.toJSON?O=f.toJSON():f instanceof Headers?f.forEach((R,U)=>M(O,[U,R])):Array.isArray(f)?f.forEach(R=>M(O,R)):typeof f=="object"&&Object.entries(f).forEach(R=>M(O,R));const v=x||T;v.toJSON?D=v.toJSON():v instanceof Headers?v.forEach((R,U)=>M(D,[U,R])):Array.isArray(v)?v.forEach(R=>M(D,R)):typeof v=="object"&&Object.entries(v).forEach(([R,U])=>{_(R)||(D[R]=U)});const I=n({url:y,method:p||"",status:m||S||0,request:{headers:O,body:g},response:{headers:D,body:k||N}});if(!I){t.debug.log("Openreplay: empty request/response info, skipping");return}const A=d.config.__openreplay_timing,L=performance.now()-A;t.debug.log("Openreplay: final req object",I),t.send(Be("xhr",String(p),String(I.url),i(I.request),i(I.response),I.status,A+pe(),L,0))}function o(d){if(t.debug.log("Openreplay: capturing API request",d),d.__openreplay_timing=performance.now(),s.sessionTokenHeader){const f=typeof s.sessionTokenHeader=="string"?s.sessionTokenHeader:"X-OpenReplay-Session-Token",g=t.getSessionToken();g&&d.headers.set(f,g)}return d}function l(d){return s.failuresOnly||r(d),d}function a(d){return t.debug.log("Openreplay: capturing API request error",d),yo(d)&&d.response?r(d.response):d instanceof Error&&t.send($e(d,[])),Promise.reject(d)}function h(d){t.debug.log("Openreplay: failed API request, skipping",d)}const c=e.interceptors.request.use(o,h,{synchronous:!0}),u=e.interceptors.response.use(l,a,{synchronous:!0});t.attachStopCallback(()=>{var d,f,g,p;(f=(d=e.interceptors.request).eject)==null||f.call(d,c),(p=(g=e.interceptors.response).eject)==null||p.call(g,u)})}function yo(t){return So(t)&&t.isAxiosError===!0}function So(t){return t!==null&&typeof t=="object"}var Y;(function(t){t[t.UNSENT=0]="UNSENT",t[t.OPENED=1]="OPENED",t[t.HEADERS_RECEIVED=2]="HEADERS_RECEIVED",t[t.LOADING=3]="LOADING",t[t.DONE=4]="DONE"})(Y||(Y={}));class Ft{constructor(e=[],s,n){this.ignoredHeaders=e,this.setSessionTokenHeader=s,this.sanitize=n,this.id="",this.name="",this.method="",this.url="",this.status=0,this.statusText="",this.cancelState=0,this.readyState=0,this.header={},this.responseType="",this.requestHeader={},this.responseSize=0,this.responseSizeText="",this.startTime=0,this.endTime=0,this.duration=0,this.getData={},this.requestData=null}getMessage(){const{reqHs:e,resHs:s}=this.writeHeaders(),n={headers:e,body:this.method==="GET"?JSON.stringify(this.getData):this.requestData},i={headers:s,body:this.response},r=this.sanitize({url:this.url,method:this.method,status:this.status,request:n,response:i});if(r)return Be(this.requestType,r.method,r.url,JSON.stringify(r.request),JSON.stringify(r.response),r.status,this.startTime+pe(),this.duration,this.responseSize)}writeHeaders(){const e={};Object.entries(this.requestHeader).forEach(([n,i])=>{this.isHeaderIgnored(n)||(e[n]=i)}),this.setSessionTokenHeader((n,i)=>{e[n]=i});const s={};return Object.entries(this.header).forEach(([n,i])=>{this.isHeaderIgnored(n)||(s[n]=i)}),{reqHs:e,resHs:s}}isHeaderIgnored(e){return Array.isArray(this.ignoredHeaders)?this.ignoredHeaders.map(s=>s.toLowerCase()).includes(e.toLowerCase()):this.ignoredHeaders}}const xe=(t,e)=>{let s="";switch(t){case"":case"text":case"json":typeof e=="string"?s=e:Ut(e)||Array.isArray(e)?s=JSON.stringify(e):typeof e<"u"&&(s=Object.prototype.toString.call(e));break;case"blob":case"document":case"arraybuffer":default:typeof e<"u"&&(s=Object.prototype.toString.call(e));break}return s},Bt=t=>{if(!t)return null;let e;if(typeof t=="string"){(t[0]==="{"||t[0]==="[")&&(e=t);const s=t.split("&");s.length===1?e=t:e=s.join(",")}else if(vo(t)){const s=[];for(const[n,i]of t)s.push(`${n}=${typeof i=="string"?i:"[object Object]"}`);e=s.join(",")}else t instanceof Blob||t instanceof ReadableStream||t instanceof ArrayBuffer?e="byte data":Ut(t)?e=t:e=`can't parse body ${typeof t}`;return e},wo=(t,e={})=>{Ut(e)||(e={});let s=t?t.split("?"):[];if(s.shift(),s.length>0){s=s.join("?").split("&");for(const n of s){const i=n.split("=");try{e[i[0]]=decodeURIComponent(i[1])}catch{e[i[0]]=i[1]}}}return e};function Ut(t){return t!==null&&typeof t=="object"}function vo(t){return t==null||ArrayBuffer.isView(t)?!1:typeof Symbol<"u"&&typeof t[Symbol.iterator]=="function"}function Ye(t){return t<=0?"":t>=1e3*1e3?(t/1e3/1e3).toFixed(1)+" MB":t>=1e3?(t/1e3).toFixed(1)+" KB":`${t}B`}const Ht=t=>(t.startsWith("//")&&(t=`${new URL(window.location.href).protocol}${t}`),t.startsWith("http")?new URL(t):new URL(t,window.location.href));class ko{constructor(e,s){this.resp=e,this.item=s,this.mockReader()}set(e,s,n){return Reflect.set(e,s,n)}get(e,s){const n=Reflect.get(e,s);switch(s){case"arrayBuffer":case"blob":case"formData":case"json":case"text":return()=>(this.item.responseType=s.toLowerCase(),n.apply(e).then(i=>(this.item.response=xe(this.item.responseType,i),i)))}return typeof n=="function"?n.bind(e):n}mockReader(){let e;if(!this.resp.body||typeof this.resp.body.getReader!="function")return;const s=this.resp.body.getReader;this.resp.body.getReader=()=>{const n=s.apply(this.resp.body);if(this.item.readyState===Y.DONE)return n;const i=n.read,r=n.cancel;return this.item.responseType="arraybuffer",n.read=()=>i.apply(n).then(o=>{if(!e)e=new Uint8Array(o.value);else{const l=new Uint8Array(e.length+o.value.length);l.set(e),l.set(o.value,e.length),e=l}return this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.readyState=o.done?4:3,this.item.statusText=o.done?String(this.item.status):"Loading",this.item.responseSize=e.length,this.item.responseSizeText=Ye(this.item.responseSize),o.done&&(this.item.response=xe(this.item.responseType,e)),o}),n.cancel=(...o)=>(this.item.cancelState=2,this.item.statusText="Cancel",this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=xe(this.item.responseType,e),r.apply(n,o)),n}}}class To{constructor(e,s,n,i,r,o){this.ignoredHeaders=e,this.setSessionTokenHeader=s,this.sanitize=n,this.sendMessage=i,this.isServiceUrl=r,this.tokenUrlMatcher=o}apply(e,s,n){const i=n[0],r=n[1];if(!i||typeof i!="string"&&!(i!=null&&i.url)||(i instanceof URL||typeof i=="string"?this.isServiceUrl(String(i)):this.isServiceUrl(String(i.url))))return e.apply(window,n);const l=new Ft(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);return this.beforeFetch(l,i,r),this.setSessionTokenHeader((a,h)=>{if(!(this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(l.url))){if(n[1]===void 0&&n[0]instanceof Request)return n[0].headers.append(a,h);n[1]||(n[1]={}),n[1].headers===void 0&&(n[1]={...n[1],headers:{}}),n[1].headers instanceof Headers?n[1].headers.append(a,h):Array.isArray(n[1].headers)?n[1].headers.push([a,h]):n[1].headers[a]=h}}),e.apply(window,n).then(this.afterFetch(l)).catch(a=>{throw l.endTime=performance.now(),l.duration=l.endTime-(l.startTime||l.endTime),a})}beforeFetch(e,s,n){let i,r="GET",o={};if(typeof s=="string"?(r=(n==null?void 0:n.method)||"GET",i=Ht(s),o=(n==null?void 0:n.headers)||{}):(r=s.method||"GET",i=Ht(s.url),o=s.headers),e.method=r,e.requestType="fetch",e.requestHeader=o,e.url=i.toString(),e.name=(i.pathname.split("/").pop()||"")+i.search,e.status=0,e.statusText="Pending",e.readyState=1,e.startTime||(e.startTime=performance.now()),Object.prototype.toString.call(o)==="[object Headers]"){e.requestHeader={};for(const[l,a]of o)e.requestHeader[l]=a}else e.requestHeader=o;if(i.search&&i.searchParams){e.getData={};for(const[l,a]of i.searchParams)e.getData[l]=a}n!=null&&n.body&&(e.requestData=Bt(n.body))}afterFetch(e){return s=>{e.endTime=performance.now(),e.duration=e.endTime-(e.startTime||e.endTime),e.status=s.status,e.statusText=String(s.status);let n=!1;e.header={};for(const[i,r]of s.headers)e.header[i]=r,n=r.toLowerCase().indexOf("chunked")>-1?!0:n;return n?e.readyState=3:(e.readyState=4,this.handleResponseBody(s.clone(),e).then(i=>{e.responseSize=typeof i=="string"?i.length:i.byteLength,e.responseSizeText=Ye(e.responseSize),e.response=xe(e.responseType,i);const r=e.getMessage();r&&this.sendMessage(r)}).catch(i=>{if(i.name!=="AbortError")throw i})),new Proxy(s,new ko(s,e))}}handleResponseBody(e,s){const n=e.headers.get("content-type");return n&&n.includes("application/json")?(s.responseType="json",e.text()):n&&(n.includes("text/html")||n.includes("text/plain"))?(s.responseType="text",e.text()):(s.responseType="arraybuffer",e.arrayBuffer())}}class Io{static create(e,s,n,i,r,o){return new Proxy(fetch,new To(e,s,n,i,r,o))}}class xo{constructor(e,s,n,i,r,o,l){this.ignoredHeaders=s,this.setSessionTokenHeader=n,this.sanitize=i,this.sendMessage=r,this.isServiceUrl=o,this.tokenUrlMatcher=l,this.XMLReq=e,this.XMLReq.onreadystatechange=()=>{this.onReadyStateChange()},this.XMLReq.onabort=()=>{this.onAbort()},this.XMLReq.ontimeout=()=>{this.onTimeout()},this.item=new Ft(s,n,i),this.item.requestType="xhr"}get(e,s){switch(s){case"open":return this.getOpen(e);case"send":return this.setSessionTokenHeader((i,r)=>{this.tokenUrlMatcher!==void 0&&!this.tokenUrlMatcher(this.item.url)||e.setRequestHeader(i,r)}),this.getSend(e);case"setRequestHeader":return this.getSetRequestHeader(e);default:const n=Reflect.get(e,s);return typeof n=="function"?n.bind(e):n}}set(e,s,n){switch(s){case"onreadystatechange":return this.setOnReadyStateChange(e,s,n);case"onabort":return this.setOnAbort(e,s,n);case"ontimeout":return this.setOnTimeout(e,s,n)}return Reflect.set(e,s,n)}onReadyStateChange(){if(!(this.item.url&&this.isServiceUrl(this.item.url))&&(this.item.readyState=this.XMLReq.readyState,this.item.responseType=this.XMLReq.responseType,this.item.endTime=performance.now(),this.item.duration=this.item.endTime-this.item.startTime,this.updateItemByReadyState(),setTimeout(()=>{this.item.response=xe(this.item.responseType,this.item.response)},0),this.XMLReq.readyState===Y.DONE)){const e=this.item.getMessage();e&&this.sendMessage(e)}}onAbort(){this.item.cancelState=1,this.item.statusText="Abort";const e=this.item.getMessage();e&&this.sendMessage(e)}onTimeout(){this.item.cancelState=3,this.item.statusText="Timeout";const e=this.item.getMessage();e&&this.sendMessage(e)}getOpen(e){const s=Reflect.get(e,"open");return(...n)=>{var o,l;const i=n[0],r=n[1];return this.item.method=i?i.toUpperCase():"GET",this.item.url=((o=r.toString)==null?void 0:o.call(r))||"",this.item.name=((l=this.item.url)==null?void 0:l.replace(new RegExp("/*$"),"").split("/").pop())??"",this.item.getData=wo(this.item.url,{}),s.apply(e,n)}}getSend(e){const s=Reflect.get(e,"send");return(...n)=>{const i=n[0];return this.item.requestData=Bt(i),s.apply(e,n)}}getSetRequestHeader(e){const s=Reflect.get(e,"setRequestHeader");return(...n)=>(this.item.requestHeader||(this.item.requestHeader={}),this.item.requestHeader[n[0]]=n[1],s.apply(e,n))}setOnReadyStateChange(e,s,n){return Reflect.set(e,s,(...i)=>{this.onReadyStateChange(),n==null||n.apply(e,i)})}setOnAbort(e,s,n){return Reflect.set(e,s,(...i)=>{this.onAbort(),n.apply(e,i)})}setOnTimeout(e,s,n){return Reflect.set(e,s,(...i)=>{this.onTimeout(),n.apply(e,i)})}updateItemByReadyState(){switch(this.XMLReq.readyState){case Y.UNSENT:case Y.OPENED:this.item.status=Y.UNSENT,this.item.statusText="Pending",this.item.startTime||(this.item.startTime=performance.now());break;case Y.HEADERS_RECEIVED:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.item.header={};const e=this.XMLReq.getAllResponseHeaders()||"",s=e.split(`
300
+ `);for(let n=0;n<s.length;n++){const i=s[n];if(!i)continue;const r=i.split(": "),o=r[0];this.item.header[o]=r.slice(1).join(": ")}break;case Y.LOADING:this.item.status=this.XMLReq.status,this.item.statusText="Loading",this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ye(this.item.responseSize));break;case Y.DONE:this.item.status=this.XMLReq.status||this.item.status||0,this.item.statusText=String(this.item.status),this.item.endTime=performance.now(),this.item.duration=this.item.endTime-(this.item.startTime||this.item.endTime),this.item.response=this.XMLReq.response,this.XMLReq.response&&this.XMLReq.response.length&&(this.item.responseSize=this.XMLReq.response.length,this.item.responseSizeText=Ye(this.item.responseSize));break;default:this.item.status=this.XMLReq.status,this.item.statusText="Unknown";break}}}class Eo{static create(e,s,n,i,r,o){return new Proxy(XMLHttpRequest,{construct(l){const a=new l;return new Proxy(a,new xo(a,e,s,n,i,r,o))}})}}const Co=t=>t instanceof Blob?t.type:t instanceof FormData?"multipart/form-data":t instanceof URLSearchParams?"application/x-www-form-urlencoded;charset=UTF-8":"text/plain;charset=UTF-8";class No{constructor(e,s,n,i,r){this.ignoredHeaders=e,this.setSessionTokenHeader=s,this.sanitize=n,this.sendMessage=i,this.isServiceUrl=r}apply(e,s,n){const i=n[0],r=n[1],o=new Ft(this.ignoredHeaders,this.setSessionTokenHeader,this.sanitize);if(this.isServiceUrl(i))return e.apply(s,n);const l=Ht(i);if(o.method="POST",o.url=i,o.name=(l.pathname.split("/").pop()||"")+l.search,o.requestType="beacon",o.requestHeader={"Content-Type":Co(r)},o.status=0,o.statusText="Pending",l.search&&l.searchParams){o.getData={};for(const[c,u]of l.searchParams)o.getData[c]=u}o.requestData=Bt(r),o.startTime||(o.startTime=performance.now());const a=e.apply(s,n);a?(o.endTime=performance.now(),o.duration=o.endTime-(o.startTime||o.endTime),o.status=0,o.statusText="Sent",o.readyState=4):(o.status=500,o.statusText="Unknown");const h=o.getMessage();return h&&this.sendMessage(h),a}}class ye{static hasSendBeacon(){return!!ye.origSendBeacon}static create(e,s,n,i,r){if(ye.hasSendBeacon())return new Proxy(ye.origSendBeacon,new No(e,s,n,i,r))}}ye.origSendBeacon=(vn=window==null?void 0:window.navigator)==null?void 0:vn.sendBeacon;const bn=t=>console.warn(`Openreplay: Can't find ${t} in global context.
301
+ If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${t} won't be tracked.`);function _o(t,e,s,n,i,r,o){var l;t.XMLHttpRequest?t.XMLHttpRequest=Eo.create(e,s,n,i,r,o):bn("XMLHttpRequest"),t.fetch?t.fetch=Io.create(e,s,n,i,r,o):bn("fetch"),(l=t==null?void 0:t.navigator)!=null&&l.sendBeacon&&(t.navigator.sendBeacon=ye.create(e,s,n,i,r))}function jt(t){return t.__or_req_data__||(t.__or_req_data__={body:void 0,headers:{}}),t.__or_req_data__}function yn(t){return typeof t=="string"?t.toUpperCase():"GET"}function Oo(t,e={}){const s=Object.assign({failuresOnly:!1,ignoreHeaders:["cookie","set-cookie","authorization"],capturePayload:!1,sessionTokenHeader:!1,captureInIframes:!0,axiosInstances:void 0,useProxy:!0},e);s.useProxy===!1&&t.debug.warn("Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true");const n=s.ignoreHeaders,i=Array.isArray(n)?c=>n.includes(c):()=>n,r=s.sessionTokenHeader===!0?"X-OpenReplay-SessionToken":s.sessionTokenHeader;function o(c){if(r){const u=t.getSessionToken();u&&t.safe(c)(r,u)}}function l(c){if(s.capturePayload||(delete c.request.body,delete c.response.body),s.sanitizer){const u=c.response.body;if(typeof u=="string")try{c.response.body=JSON.parse(u)}catch{}return s.sanitizer(c)}return c}function a(c){if(c&&typeof c.body!="string")try{c.body=JSON.stringify(c.body)}catch{c.body="<unable to stringify>",t.notify.warn("Openreplay fetch couldn't stringify body:",c.body)}return JSON.stringify(c)}const h=c=>{if(s.useProxy)return _o(c,s.ignoreHeaders,o,l,T=>t.send(T),T=>t.isServiceURL(T),s.tokenUrlMatcher);const u=c.fetch.bind(c),d=(T,m={})=>{if(!(typeof T=="string"||T instanceof URL)||t.isServiceURL(String(T)))return u(T,m);o(function(k,x){m.headers===void 0&&(m.headers={}),m.headers instanceof Headers?m.headers.append(k,x):Array.isArray(m.headers)?m.headers.push([k,x]):m.headers[k]=x});const w=performance.now();return u(T,m).then(k=>{const x=performance.now()-w;if(s.failuresOnly&&k.status<400)return k;const S=k.clone();return S.text().then(b=>{const _={},M={};if(n!==!0){const v=([I,A])=>{i(I)||(_[I]=A)};m.headers instanceof Headers?m.headers.forEach((I,A)=>v([A,I])):Array.isArray(m.headers)?m.headers.forEach(v):typeof m.headers=="object"&&Object.entries(m.headers).forEach(v),S.headers.forEach((I,A)=>{i(A)||(M[A]=I)})}const O=yn(m.method),D=l({url:String(T),method:O,status:S.status,request:{headers:_,body:m.body||null},response:{headers:M,body:b}});D&&t.send(Be("fetch",O,String(D.url),a(D.request),a(D.response),S.status,w+pe(),x,0))}).catch(b=>t.debug.error("Could not process Fetch response:",b)),k})};c.fetch=d;const f=c.XMLHttpRequest.prototype.open,g=c.XMLHttpRequest.prototype.setRequestHeader,p=c.XMLHttpRequest.prototype.send;function y(T,m){const w=this;o((x,S)=>w.setRequestHeader(x,S));let k=0;return w.addEventListener("loadstart",x=>{k=x.timeStamp}),w.addEventListener("load",t.safe(x=>{const{headers:S,body:b}=jt(w),_=k>0?x.timeStamp-k:0,O=(w.getAllResponseHeaders()||"").trim().split(/[\r\n]+/),D={};O.forEach(function(A){const L=A.split(": "),R=L.shift();i(R)||(D[R]=L.join(": "))});const v=yn(T),I=l({url:String(m),method:v,status:w.status,request:{headers:S,body:b||null},response:{headers:D,body:w.response}});I&&t.send(Be("xhr",v,String(I.url),a(I.request),a(I.response),w.status,k+pe(),_,0))})),f.apply(this,arguments)}function E(T){const m=jt(this);return m.body=T,p.apply(this,arguments)}function N(T,m){if(!i(T)){const w=jt(this);w.headers[T]=m}return g.apply(this,arguments)}s.axiosInstances||(c.XMLHttpRequest.prototype.open=y,c.XMLHttpRequest.prototype.send=E,c.XMLHttpRequest.prototype.setRequestHeader=N)};h(window),s.axiosInstances&&s.axiosInstances.forEach(c=>{bo(t,c,s,l,a)}),s.captureInIframes&&t.observer.attachContextCallback(t.safe(h))}function Ro(t){t.attachEventListener(document,"selectionchange",()=>{const e=document.getSelection();if(e!==null&&!e.isCollapsed){const s=t.nodes.getID(e.anchorNode),n=t.nodes.getID(e.focusNode),i=e.toString().replace(/\s+/g," ");s&&n&&t.send(Rs(s,n,i))}else t.send(Rs(-1,-1,""))})}function Do(t){function e(){document.hidden||(t.debug.log("Openreplay: tab change to"+t.session.getTabId()),t.send(Ue(t.session.getTabId())))}t.attachEventListener(window,"focus",e,!1,!1)}const Qe="/installation/javascript-sdk";function Mo(t){if(t==null)return console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${Fe}${Qe}`),!1;if(typeof t.projectKey!="string")if(typeof t.projectKey!="number"){if(typeof t.projectID!="number")return console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${Fe}${Qe} for more information.`),!1;t.projectKey=t.projectID.toString(),ie("`projectID` option","`projectKey` option",Qe)}else console.warn("OpenReplay: projectKey is expected to have a string type."),t.projectKey=t.projectKey.toString();return t.sessionToken!=null&&ie("`sessionToken` option","`sessionHash` start() option","/"),!0}class Ao{constructor(e){var l;if(this.options=e,this.app=null,this.crossdomainMode=!1,this.checkDoNotTrack=()=>this.options.respectDoNotTrack&&(navigator.doNotTrack=="1"||window.doNotTrack=="1"),this.signalStartIssue=(a,h)=>{const c=this.checkDoNotTrack(),u=new XMLHttpRequest,d=this.options.ingestPoint||Xs;u.open("POST",d+"/v1/web/not-started"),u.send(JSON.stringify({trackerVersion:"14.0.4",projectKey:this.options.projectKey,doNotTrack:c,reason:h.length?`missing api: ${h.join(",")}`:a}))},this.restartCanvasTracking=()=>{this.app!==null&&this.app.restartCanvasTracking()},this.handleError=(a,h={})=>{if(this.app!==null){if(a instanceof Error){const c=$e(a,[],h);this.app.send(c)}else if(a instanceof ErrorEvent||"PromiseRejectionEvent"in window&&a instanceof PromiseRejectionEvent){const c=tn(a,void 0,h);c!=null&&this.app.send(c)}}},this.crossdomainMode=!!(oi()&&((l=e.crossdomain)!=null&&l.enabled)),!K||!Mo(e))return;if(window.__OPENREPLAY__){console.error("OpenReplay: one tracker instance has been initialised already");return}if(!e.__DISABLE_SECURE_MODE&&location.protocol!=="https:"){console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");return}const s=this.checkDoNotTrack(),n=[],i=["Map","Set","MutationObserver","performance","timing","startsWith","Blob","Worker"];if(s)n.push("doNotTrack");else for(const a of i)if(a==="timing"){if("performance"in window&&!(a in performance)){n.push(a);break}}else if(a==="startsWith"){if(!(a in String.prototype)){n.push(a);break}}else if(!(a in window)){n.push(a);break}if(n.length>0){const a=n.join(",");console.error(`OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1. Reason: ${a}`),this.signalStartIssue("missing_api",n);return}const r=new _r(e.projectKey,e.sessionToken,e,this.signalStartIssue,this.crossdomainMode);this.app=r,this.crossdomainMode||(ho(r),Or(r),Wi(r,e),Do(r)),ro(r,e.mouse),lo(r,this.crossdomainMode),po(r),fo(r),Ar(r,e),Ur(r,e),zr(r),Xr(r,e),co(r,e),go(r),mo(r),Oo(r,e.network),Ro(r),window.__OPENREPLAY__=this,e.flags&&e.flags.onFlagsLoad&&this.onFlagsLoad(e.flags.onFlagsLoad);const o=window.open;(e.autoResetOnWindowOpen||e.resetTabOnWindowOpen)&&(r.attachStartCallback(()=>{const a=r.getTabId(),h=r.sessionStorage??window.sessionStorage;window.open=function(...c){return e.autoResetOnWindowOpen&&r.resetNextPageSession(!0),e.resetTabOnWindowOpen&&h.removeItem(e.session_tabid_key||"__openreplay_tabid"),r.resetNextPageSession(!1),h.setItem(e.session_tabid_key||"__openreplay_tabid",a),o.call(window,...c)}}),r.attachStopCallback(()=>{window.open=o}))}isFlagEnabled(e){return this.featureFlags.isFlagEnabled(e)}onFlagsLoad(e){var s;(s=this.app)==null||s.featureFlags.onFlagsLoad(e)}clearPersistFlags(){var e;(e=this.app)==null||e.featureFlags.clearPersistFlags()}reloadFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.reloadFlags()}getFeatureFlag(e){var s;return(s=this.app)==null?void 0:s.featureFlags.getFeatureFlag(e)}getAllFeatureFlags(){var e;return(e=this.app)==null?void 0:e.featureFlags.flags}use(e){return e(this.app,this.options)}isActive(){return this.app===null?!1:this.app.active()}trackWs(e){if(this.app!==null)return this.app.trackWs(e)}start(e){return this.browserEnvCheck()?this.app===null?Promise.reject("Browser doesn't support required api, or doNotTrack is active."):this.app.start(e):Promise.reject("Trying to start not in browser.")}browserEnvCheck(){return K?!0:(console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${Fe}${Qe}`),!1)}coldStart(e,s){if(this.browserEnvCheck()){if(this.app===null)return Promise.reject("Tracker not initialized");this.app.coldStart(e,s)}else return Promise.reject("Trying to start not in browser.")}startOfflineRecording(e,s){return this.browserEnvCheck()?this.app===null?Promise.reject("Tracker not initialized"):this.app.offlineRecording(e,s):Promise.reject("Trying to start not in browser.")}uploadOfflineRecording(){if(this.app!==null)return this.app.uploadOfflineRecording()}stop(){if(this.app!==null)return this.app.stop(),this.app.session.getSessionHash()}forceFlushBatch(){this.app!==null&&this.app.forceFlushBatch()}getSessionToken(){return this.app===null?null:this.app.getSessionToken()}getSessionInfo(){return this.app===null?null:this.app.session.getInfo()}getSessionID(){return this.app===null?null:this.app.getSessionID()}getTabId(){return this.app===null?null:this.app.getTabId()}getUxId(){return this.app===null?null:this.app.getUxtId()}sessionID(){return ie("'sessionID' method","'getSessionID' method","/"),this.getSessionID()}getSessionURL(e){if(this.app!==null)return this.app.getSessionURL(e)}setUserID(e){typeof e=="string"&&this.app!==null&&this.app.session.setUserID(e)}userID(e){ie("'userID' method","'setUserID' method","/"),this.setUserID(e)}setUserAnonymousID(e){typeof e=="string"&&this.app!==null&&this.app.send(Ci(e))}userAnonymousID(e){ie("'userAnonymousID' method","'setUserAnonymousID' method","/"),this.setUserAnonymousID(e)}setMetadata(e,s){typeof e=="string"&&typeof s=="string"&&this.app!==null&&this.app.session.setMetadata(e,s)}metadata(e,s){ie("'metadata' method","'setMetadata' method","/"),this.setMetadata(e,s)}event(e,s=null,n=!1){if(typeof e=="string"&&this.app!==null){if(n)return this.issue(e,s);try{s=JSON.stringify(s)}catch{return}this.app.send(xi(e,s))}}issue(e,s=null){if(typeof e=="string"&&this.app!==null){try{s=JSON.stringify(s)}catch{return}this.app.send(Mi(e,s))}}}const Po=["climats","telckel","biobio","weinpoint","vinigrandi"],Lo="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class zt{constructor(e){var s;this.baseURL="https://api.wineater.com/",this.store=Po.find(n=>window.location.href.includes(n)),this.token=((s=window==null?void 0:window.wineaterData)==null?void 0:s.CLIENT_TOKEN)||Lo}async getStoreConfig(e){console.log(e);try{const s=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:e})});if(!s.ok)throw new Error(`HTTP error! Status: ${s.status}`);return await s.json()}catch(s){throw console.error("Error fetching store configuration:",s),s}}async getWineRecommendations(e){console.log(window.location.href);try{const s=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:e,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),n=await s.json();if(!s.ok)throw new Error(`API call failed with status ${s.status}: ${n.message||"No additional error information"}`);return n}catch(s){throw console.error("Fetching wine recommendations failed:",s.message),new Error(`Error in getWineRecommendations: ${s.message}`)}}async getPossibleDishesWithMeta(e,s){try{const n=await fetch(`${this.baseURL}dish/possible_dishes`,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({title:e,description:s})}),i=await n.json();if(console.log(i),!n.ok)throw new Error(`API call failed with status ${n.status}: ${i.message||"No additional error information"}`);return i}catch(n){throw console.error("Error fetching possible dishes:",n),n}}}class Fo{constructor(){this.api=new zt,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",reason:"Suggestion",moreInfo:"Plus d'infos",winePairingIntro:"Pour ce vin, voici quelques suggestions de plats :",askForDinner:"Que voulez-vous manger ce soir?",clearChatButton:"Effacer le chat"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridaje ideal",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",reason:"Sugerencia",moreInfo:"Más info",winePairingIntro:"Para este vino, aquí tienes algunas sugerencias de platos:",askForDinner:"¿Qué te gustaría cenar?",clearChatButton:"Limpiar el chat"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",reason:"Suggestion",moreInfo:"More info",winePairingIntro:"For this wine, here are some suggested dishes:",askForDinner:"What would you like to have for dinner?",clearChatButton:"Clear Chat"},de:{welcomeMessage:"Verbessern Sie Ihr kulinarisches Erlebnis. Geben Sie einfach die Details Ihres Gerichts an und erhalten Sie die ideale Weinempfehlung. Was möchten Sie essen?",noResultsFound:"Keine Ergebnisse gefunden.",somethingWentWrong:"Entschuldigung, etwas ist schief gelaufen.",chatButton:"Wein zum Abendessen",inputPlaceholder:"z.B., Thunfischsalat",sendButton:"Kombinieren",price:"Preis",region:"Region",type:"Typ",reason:"Anregung",moreInfo:"Mehr Info",winePairingIntro:"Für diesen Wein gibt es folgende Essensvorschläge:",askForDinner:"Was möchten Sie zum Abendessen essen?",clearChatButton:"Chat löschen"}}}async fetchConfig(e="Demo"){try{const s=await this.api.getStoreConfig(e);this.language=s.lang}catch{this.language="en"}}translate(e){return this.translations[this.language][e]||e}}const V=new Fo,Bo=3;let Ze=null;function Wt(){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");t.classList.contains("visible")?(Yt(),qt(),e.style.display="flex"):(Ze&&(clearTimeout(Ze),Ze=null),Jt(),t.classList.add("visible"),e.style.display="none")}function qt(){console.log("ghbdtn"),Yt(),document.getElementById("chat-window").classList.remove("visible");let e=parseInt(j("chatCloseCount"))||0;e+=1,e>=Bo?(console.log(e),Ce("disableAutoOpen","true",1),Dn("chatCloseCount")):(console.log(e),Ce("chatCloseCount",e,1))}function Uo(t){const e=document.getElementById("chat-window"),s=document.getElementById("message-container"),n=document.querySelector("#input-container input");s.innerHTML="",e.classList.add("visible");const i=document.createElement("div");i.className="message api",i.textContent=V.translate("winePairingIntro"),s.appendChild(i),t.slice(0,3).forEach(o=>{const l=document.createElement("div");l.className="message dish-message",l.textContent=o,l.addEventListener("click",()=>{n.value=o}),s.appendChild(l)});const r=document.createElement("div");r.className="message api",r.textContent=V.translate("askForDinner"),s.appendChild(r),s.scrollTop=s.scrollHeight}function Sn(t=null){t?An(t):Jt(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});function Ho(t){Ze=t}class jo{constructor(){var s;this.api=new zt;const e=((s=window==null?void 0:window.wineaterData)==null?void 0:s.FIRST_MESSAGE_TEXT)||V.translate("welcomeMessage");this.displayFirstMessage(e)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",n=>{n.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(e,s="api"){const n=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${s}`,i.textContent=e,n.appendChild(i),n.scrollTop=n.scrollHeight}async handleUserInput(){const e=document.getElementById("user-input"),s=e.value.trim();if(s){this.displayMessage(s,"user"),e.value="",this.showTypingIndicator();try{Pn(s);const n=await this.api.getWineRecommendations(s);this.hideTypingIndicator(),n&&n.length?this.displayResults(n):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(V.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(e,s){const n=document.getElementById("message-container"),i=document.createElement("div");i.textContent=e,i.className="message "+s,n.appendChild(i),n.scrollTop=n.scrollHeight}sendAnalytics(e){console.log(e),Fn(e)}displayResults(e){const s=document.getElementById("message-container");Ln(e.map(n=>n.Title)),e.forEach(n=>{const i=document.createElement("div");i.className="wine-item";const r=document.createElement("img");r.src=n.Image,i.appendChild(r);const o=document.createElement("div");o.innerHTML=`
300
302
  <strong>${n.Title}</strong><br>
301
- ${Y.translate("price")}: ${n.Price}<br>
302
- ${Y.translate("region")}: ${n.Region}<br>
303
- ${Y.translate("type")}: ${n.Type}<br>
304
- <a href="${n.Url}" target="_blank">${Y.translate("moreInfo")}</a>
305
- `,o.querySelector("a").addEventListener("click",a=>{a.preventDefault(),this.sendAnalytics(n.Title),window.open(n.Url,"_blank")}),i.appendChild(o),s.appendChild(i),this.displayFirstMessage(n.Reason)}),s.scrollTop=s.scrollHeight}}const Ze={PRODUCT_PAGES:/producto\/[^\/]+\/$/},qt={PRODUCT_PAGES:((vn=window.wineaterData)==null?void 0:vn.PRODUCT_PAGES)||Ze.PRODUCT_PAGES,CART_PAGE:((kn=window.wineaterData)==null?void 0:kn.CART_PAGE)||(Ze==null?void 0:Ze.CART_PAGE)};function Fo(){const t=window.location.href;return console.log(qt),!!(qt.PRODUCT_PAGES.test(t)||qt.CART_PAGE.test(t))}const Bo=new Ro({projectKey:"PA8j9fAi49i6g2QnvpNs"}),Uo="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=jt,window.closeChatWindow=zt,window.openChatWindow=Wt});function Ho(){var s;Bo.start();const e=`
303
+ ${V.translate("price")}: ${n.Price}<br>
304
+ ${V.translate("region")}: ${n.Region}<br>
305
+ ${V.translate("type")}: ${n.Type}<br>
306
+ <a href="${n.Url}" target="_blank">${V.translate("moreInfo")}</a>
307
+ `,o.querySelector("a").addEventListener("click",a=>{a.preventDefault(),this.sendAnalytics(n.Title),window.open(n.Url,"_blank")}),i.appendChild(o),s.appendChild(i),this.displayFirstMessage(n.Reason)}),s.scrollTop=s.scrollHeight}}const zo=new zt,et={PRODUCT_PAGES:/producto\/[^\/]+\/$/},wn={FESTIVAL_PAGES:/festival/,TASTING_PAGES:/tasting/},Wo={FESTIVAL_PAGES:((kn=window.wineaterData)==null?void 0:kn.FESTIVAL_PAGES)||wn.FESTIVAL_PAGES,TASTING_PAGES:((Tn=window.wineaterData)==null?void 0:Tn.TASTING_PAGES)||wn.TASTING_PAGES},qo={PRODUCT_PAGES:((In=window.wineaterData)==null?void 0:In.PRODUCT_PAGES)||et.PRODUCT_PAGES,CART_PAGE:((xn=window.wineaterData)==null?void 0:xn.CART_PAGE)||(et==null?void 0:et.CART_PAGE)};async function $o(){var e,s;const t=window.location.href;for(const[n,i]of Object.entries(Wo))if(i.test(t))return!1;for(const[n,i]of Object.entries(qo))if(i.test(t))try{const r=((e=document.querySelector('meta[name="title"]'))==null?void 0:e.getAttribute("content"))||document.title,o=((s=document.querySelector('meta[name="description"]'))==null?void 0:s.getAttribute("content"))||"",l=await zo.getPossibleDishesWithMeta(r,o);console.log(l);const a=setTimeout(()=>{Uo(l)},15e3);return Ho(a),!0}catch(r){return console.error("Error fetching dishes:",r),!1}return!1}const Vo=new Ao({projectKey:"PA8j9fAi49i6g2QnvpNs"}),Xo="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=Wt,window.closeChatWindow=qt,window.openChatWindow=Sn});function Go(){var s;Vo.start();const e=`
306
308
  <div id="chatbot-container">
307
309
  <div id="chat-icon" onclick="toggleChatWindow()">
308
310
  <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon"> <!-- Update the path to your logo image -->
309
- <span>${((s=window==null?void 0:window.wineaterData)==null?void 0:s.BUTTON_TEXT)||Y.translate("chatButton")}</span>
311
+ <span>${((s=window==null?void 0:window.wineaterData)==null?void 0:s.BUTTON_TEXT)||V.translate("chatButton")}</span>
310
312
  </div>
311
313
 
312
314
  <div id="chat-window" class="hidden">
@@ -325,9 +327,9 @@ If you're using serverside rendering in your app, make sure that tracker is load
325
327
  <span></span><span></span><span></span>
326
328
  </div>
327
329
  <div id="input-container">
328
- <input type="text" id="user-input" placeholder="${Y.translate("inputPlaceholder")}">
329
- <button id="send-button">${Y.translate("sendButton")}</button>
330
+ <input type="text" id="user-input" placeholder="${V.translate("inputPlaceholder")}">
331
+ <button id="send-button">${V.translate("sendButton")}</button>
330
332
  </div>
331
333
  </div>
332
334
  </div>
333
- `;document.body.insertAdjacentHTML("beforeend",e)}function jo(){document.getElementById("close-btn").addEventListener("click",jt)}function zo(){window.addEventListener("click",function(t){const e=document.getElementById("chat-window"),s=document.getElementById("chat-icon");!e.contains(t.target)&&!s.contains(t.target)&&(e.classList.remove("visible"),s.style.display="flex")})}function Wo(t){console.log(t);const e=document.getElementById("chat-icon"),s=document.getElementById("chat-window");e.className="",s.className="",t==="right-center"?(e.classList.add("chat-icon-right-center"),s.classList.add("right-center-aligned")):e.classList.add("chat-icon-bottom-right")}function qo(t=1e4){setTimeout(()=>{Wt(window.location.href)},t)}if(document.addEventListener("DOMContentLoaded",()=>{!j("disableAutoOpen")&&Fo()&&qo(1e4)}),typeof window<"u"){let t=((Tn=window==null?void 0:window.wineaterData)==null?void 0:Tn.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var r;const s=["climats","telckel","biobio","weinpoint","vinigrandi"].find(o=>window.location.href.includes(o))||null;let n;s&&(n=s.charAt(0).toUpperCase()+s.slice(1),n==="Biobio"&&(t="right-center")),await Y.fetchConfig(n||"Demo"),Ho(),jo(),zo(),Wo(t),Ce("chatbotToken",((r=window.wineaterData)==null?void 0:r.CLIENT_TOKEN)||Uo,365),On(),new Po().initialize()})}te.closeChatWindow=zt,te.openChatWindow=Wt,te.toggleChatWindow=jt,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
335
+ `;document.body.insertAdjacentHTML("beforeend",e)}function Ko(){document.getElementById("close-btn").addEventListener("click",Wt)}function Jo(){window.addEventListener("click",function(t){const e=document.getElementById("chat-window"),s=document.getElementById("chat-icon");!e.contains(t.target)&&!s.contains(t.target)&&(e.classList.remove("visible"),s.style.display="flex")})}function Yo(t){console.log(t);const e=document.getElementById("chat-icon"),s=document.getElementById("chat-window");e.className="",s.className="",t==="right-center"?(e.classList.add("chat-icon-right-center"),s.classList.add("right-center-aligned")):e.classList.add("chat-icon-bottom-right")}if(document.addEventListener("DOMContentLoaded",()=>{j("disableAutoOpen")||$o()}),typeof window<"u"){let t=((En=window==null?void 0:window.wineaterData)==null?void 0:En.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var r;const s=["climats","telckel","biobio","weinpoint","vinigrandi"].find(o=>window.location.href.includes(o))||null;let n;s&&(n=s.charAt(0).toUpperCase()+s.slice(1),n==="Biobio"&&(t="right-center")),await V.fetchConfig(n||"Demo"),Go(),Ko(),Jo(),Yo(t),Ce("chatbotToken",((r=window.wineaterData)==null?void 0:r.CLIENT_TOKEN)||Xo,365),Mn(),new jo().initialize()})}te.closeChatWindow=qt,te.openChatWindow=Sn,te.toggleChatWindow=Wt,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});