import{r as R,j as F,u as De,w as Te,n as Dn,k as Re,l as He,b as Gn,p as qn,q as Hn,s as jn,_ as $n}from"./assets/1-d899965f.js";import{d as Ge,a as nt,c as zn,s as Wn}from"./assets/2-2655fe7f.js";import{u as Vn,a as Kn,J as i}from"./assets/3-7f672ca0.js";import"./app.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))l(u);new MutationObserver(u=>{for(const g of u)if(g.type==="childList")for(const h of g.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&l(h)}).observe(document,{childList:!0,subtree:!0});function o(u){const g={};return u.integrity&&(g.integrity=u.integrity),u.referrerPolicy&&(g.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?g.credentials="include":u.crossOrigin==="anonymous"?g.credentials="omit":g.credentials="same-origin",g}function l(u){if(u.ep)return;u.ep=!0;const g=o(u);fetch(u.href,g)}})();var aa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jn={},pt={};pt.byteLength=Qn;pt.toByteArray=er;pt.fromByteArray=rr;var Ee=[],we=[],Yn=typeof Uint8Array<"u"?Uint8Array:Array,At="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Ke=0,Zn=At.length;Ke0)throw new Error("Invalid string. Length must be a multiple of 4");var o=e.indexOf("=");o===-1&&(o=r);var l=o===r?0:4-o%4;return[o,l]}function Qn(e){var r=Tn(e),o=r[0],l=r[1];return(o+l)*3/4-l}function Xn(e,r,o){return(r+o)*3/4-o}function er(e){var r,o=Tn(e),l=o[0],u=o[1],g=new Yn(Xn(e,l,u)),h=0,c=u>0?l-4:l,f;for(f=0;f>16&255,g[h++]=r>>8&255,g[h++]=r&255;return u===2&&(r=we[e.charCodeAt(f)]<<2|we[e.charCodeAt(f+1)]>>4,g[h++]=r&255),u===1&&(r=we[e.charCodeAt(f)]<<10|we[e.charCodeAt(f+1)]<<4|we[e.charCodeAt(f+2)]>>2,g[h++]=r>>8&255,g[h++]=r&255),g}function tr(e){return Ee[e>>18&63]+Ee[e>>12&63]+Ee[e>>6&63]+Ee[e&63]}function nr(e,r,o){for(var l,u=[],g=r;gc?c:h+g));return l===1?(r=e[o-1],u.push(Ee[r>>2]+Ee[r<<4&63]+"==")):l===2&&(r=(e[o-2]<<8)+e[o-1],u.push(Ee[r>>10]+Ee[r>>4&63]+Ee[r<<2&63]+"=")),u.join("")}var Dt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */Dt.read=function(e,r,o,l,u){var g,h,c=u*8-l-1,f=(1<>1,m=-7,T=o?u-1:0,M=o?-1:1,w=e[r+T];for(T+=M,g=w&(1<<-m)-1,w>>=-m,m+=c;m>0;g=g*256+e[r+T],T+=M,m-=8);for(h=g&(1<<-m)-1,g>>=-m,m+=l;m>0;h=h*256+e[r+T],T+=M,m-=8);if(g===0)g=1-_;else{if(g===f)return h?NaN:(w?-1:1)*(1/0);h=h+Math.pow(2,l),g=g-_}return(w?-1:1)*h*Math.pow(2,g-l)};Dt.write=function(e,r,o,l,u,g){var h,c,f,_=g*8-u-1,m=(1<<_)-1,T=m>>1,M=u===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=l?0:g-1,N=l?1:-1,B=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,h=m):(h=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-h))<1&&(h--,f*=2),h+T>=1?r+=M/f:r+=M*Math.pow(2,1-T),r*f>=2&&(h++,f/=2),h+T>=m?(c=0,h=m):h+T>=1?(c=(r*f-1)*Math.pow(2,u),h=h+T):(c=r*Math.pow(2,T-1)*Math.pow(2,u),h=0));u>=8;e[o+w]=c&255,w+=N,c/=256,u-=8);for(h=h<0;e[o+w]=h&255,w+=N,h/=256,_-=8);e[o+w-N]|=B*128};/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */(function(e){var r=pt,o=Dt,l=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=q,e.INSPECT_MAX_BYTES=50;var u=2147483647;e.kMaxLength=u,c.TYPED_ARRAY_SUPPORT=g(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function g(){try{var a=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(a,t),a.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function h(a){if(a>u)throw new RangeError('The value "'+a+'" is invalid for option "size"');var t=new Uint8Array(a);return Object.setPrototypeOf(t,c.prototype),t}function c(a,t,n){if(typeof a=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return T(a)}return f(a,t,n)}c.poolSize=8192;function f(a,t,n){if(typeof a=="string")return M(a,t);if(ArrayBuffer.isView(a))return N(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(Ce(a,ArrayBuffer)||a&&Ce(a.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ce(a,SharedArrayBuffer)||a&&Ce(a.buffer,SharedArrayBuffer)))return B(a,t,n);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var s=a.valueOf&&a.valueOf();if(s!=null&&s!==a)return c.from(s,t,n);var d=G(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return c.from(a[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}c.from=function(a,t,n){return f(a,t,n)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function _(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function m(a,t,n){return _(a),a<=0?h(a):t!==void 0?typeof n=="string"?h(a).fill(t,n):h(a).fill(t):h(a)}c.alloc=function(a,t,n){return m(a,t,n)};function T(a){return _(a),h(a<0?0:O(a)|0)}c.allocUnsafe=function(a){return T(a)},c.allocUnsafeSlow=function(a){return T(a)};function M(a,t){if((typeof t!="string"||t==="")&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=D(a,t)|0,s=h(n),d=s.write(a,t);return d!==n&&(s=s.slice(0,d)),s}function w(a){for(var t=a.length<0?0:O(a.length)|0,n=h(t),s=0;s=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return a|0}function q(a){return+a!=a&&(a=0),c.alloc(+a)}c.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==c.prototype},c.compare=function(t,n){if(Ce(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),Ce(n,Uint8Array)&&(n=c.from(n,n.offset,n.byteLength)),!c.isBuffer(t)||!c.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;for(var s=t.length,d=n.length,v=0,y=Math.min(s,d);vd.length?c.from(y).copy(d,v):Uint8Array.prototype.set.call(d,y,v);else if(c.isBuffer(y))y.copy(d,v);else throw new TypeError('"list" argument must be an Array of Buffers');v+=y.length}return d};function D(a,t){if(c.isBuffer(a))return a.length;if(ArrayBuffer.isView(a)||Ce(a,ArrayBuffer))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);var n=a.length,s=arguments.length>2&&arguments[2]===!0;if(!s&&n===0)return 0;for(var d=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return re(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Xt(a).length;default:if(d)return s?-1:re(a).length;t=(""+t).toLowerCase(),d=!0}}c.byteLength=D;function V(a,t,n){var s=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(a||(a="utf8");;)switch(a){case"hex":return oe(this,t,n);case"utf8":case"utf-8":return ge(this,t,n);case"ascii":return I(this,t,n);case"latin1":case"binary":return H(this,t,n);case"base64":return Ie(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,t,n);default:if(s)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),s=!0}}c.prototype._isBuffer=!0;function b(a,t,n){var s=a[t];a[t]=a[n],a[n]=s}c.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;nn&&(t+=" ... "),""},l&&(c.prototype[l]=c.prototype.inspect),c.prototype.compare=function(t,n,s,d,v){if(Ce(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),s===void 0&&(s=t?t.length:0),d===void 0&&(d=0),v===void 0&&(v=this.length),n<0||s>t.length||d<0||v>this.length)throw new RangeError("out of range index");if(d>=v&&n>=s)return 0;if(d>=v)return-1;if(n>=s)return 1;if(n>>>=0,s>>>=0,d>>>=0,v>>>=0,this===t)return 0;for(var y=v-d,P=s-n,W=Math.min(y,P),J=this.slice(d,v),ie=t.slice(n,s),Z=0;Z2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,It(n)&&(n=d?0:a.length-1),n<0&&(n=a.length+n),n>=a.length){if(d)return-1;n=a.length-1}else if(n<0)if(d)n=0;else return-1;if(typeof t=="string"&&(t=c.from(t,s)),c.isBuffer(t))return t.length===0?-1:E(a,t,n,s,d);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(a,t,n):Uint8Array.prototype.lastIndexOf.call(a,t,n):E(a,[t],n,s,d);throw new TypeError("val must be string, number or Buffer")}function E(a,t,n,s,d){var v=1,y=a.length,P=t.length;if(s!==void 0&&(s=String(s).toLowerCase(),s==="ucs2"||s==="ucs-2"||s==="utf16le"||s==="utf-16le")){if(a.length<2||t.length<2)return-1;v=2,y/=2,P/=2,n/=2}function W(en,tn){return v===1?en[tn]:en.readUInt16BE(tn*v)}var J;if(d){var ie=-1;for(J=n;Jy&&(n=y-P),J=n;J>=0;J--){for(var Z=!0,it=0;itd&&(s=d)):s=d;var v=t.length;s>v/2&&(s=v/2);for(var y=0;y>>0,isFinite(s)?(s=s>>>0,d===void 0&&(d="utf8")):(d=s,s=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var v=this.length-n;if((s===void 0||s>v)&&(s=v),t.length>0&&(s<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");for(var y=!1;;)switch(d){case"hex":return Y(this,t,n,s);case"utf8":case"utf-8":return ne(this,t,n,s);case"ascii":case"latin1":case"binary":return j(this,t,n,s);case"base64":return fe(this,t,n,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ke(this,t,n,s);default:if(y)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),y=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ie(a,t,n){return t===0&&n===a.length?r.fromByteArray(a):r.fromByteArray(a.slice(t,n))}function ge(a,t,n){n=Math.min(a.length,n);for(var s=[],d=t;d239?4:v>223?3:v>191?2:1;if(d+P<=n){var W,J,ie,Z;switch(P){case 1:v<128&&(y=v);break;case 2:W=a[d+1],(W&192)===128&&(Z=(v&31)<<6|W&63,Z>127&&(y=Z));break;case 3:W=a[d+1],J=a[d+2],(W&192)===128&&(J&192)===128&&(Z=(v&15)<<12|(W&63)<<6|J&63,Z>2047&&(Z<55296||Z>57343)&&(y=Z));break;case 4:W=a[d+1],J=a[d+2],ie=a[d+3],(W&192)===128&&(J&192)===128&&(ie&192)===128&&(Z=(v&15)<<18|(W&63)<<12|(J&63)<<6|ie&63,Z>65535&&Z<1114112&&(y=Z))}}y===null?(y=65533,P=1):y>65535&&(y-=65536,s.push(y>>>10&1023|55296),y=56320|y&1023),s.push(y),d+=P}return Be(s)}var Ae=4096;function Be(a){var t=a.length;if(t<=Ae)return String.fromCharCode.apply(String,a);for(var n="",s=0;ss)&&(n=s);for(var d="",v=t;vs&&(t=s),n<0?(n+=s,n<0&&(n=0)):n>s&&(n=s),nn)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(t,n,s){t=t>>>0,n=n>>>0,s||k(t,n,this.length);for(var d=this[t],v=1,y=0;++y>>0,n=n>>>0,s||k(t,n,this.length);for(var d=this[t+--n],v=1;n>0&&(v*=256);)d+=this[t+--n]*v;return d},c.prototype.readUint8=c.prototype.readUInt8=function(t,n){return t=t>>>0,n||k(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||k(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||k(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||k(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,n,s){t=t>>>0,n=n>>>0,s||k(t,n,this.length);for(var d=this[t],v=1,y=0;++y=v&&(d-=Math.pow(2,8*n)),d},c.prototype.readIntBE=function(t,n,s){t=t>>>0,n=n>>>0,s||k(t,n,this.length);for(var d=n,v=1,y=this[t+--d];d>0&&(v*=256);)y+=this[t+--d]*v;return v*=128,y>=v&&(y-=Math.pow(2,8*n)),y},c.prototype.readInt8=function(t,n){return t=t>>>0,n||k(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},c.prototype.readInt16LE=function(t,n){t=t>>>0,n||k(t,2,this.length);var s=this[t]|this[t+1]<<8;return s&32768?s|4294901760:s},c.prototype.readInt16BE=function(t,n){t=t>>>0,n||k(t,2,this.length);var s=this[t+1]|this[t]<<8;return s&32768?s|4294901760:s},c.prototype.readInt32LE=function(t,n){return t=t>>>0,n||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,n){return t=t>>>0,n||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,n){return t=t>>>0,n||k(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,n){return t=t>>>0,n||k(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||k(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||k(t,8,this.length),o.read(this,t,!1,52,8)};function C(a,t,n,s,d,v){if(!c.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>d||ta.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,n,s,d){if(t=+t,n=n>>>0,s=s>>>0,!d){var v=Math.pow(2,8*s)-1;C(this,t,n,s,v,0)}var y=1,P=0;for(this[n]=t&255;++P>>0,s=s>>>0,!d){var v=Math.pow(2,8*s)-1;C(this,t,n,s,v,0)}var y=s-1,P=1;for(this[n+y]=t&255;--y>=0&&(P*=256);)this[n+y]=t/P&255;return n+s},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,1,255,0),this[n]=t&255,n+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4},c.prototype.writeIntLE=function(t,n,s,d){if(t=+t,n=n>>>0,!d){var v=Math.pow(2,8*s-1);C(this,t,n,s,v-1,-v)}var y=0,P=1,W=0;for(this[n]=t&255;++y>0)-W&255;return n+s},c.prototype.writeIntBE=function(t,n,s,d){if(t=+t,n=n>>>0,!d){var v=Math.pow(2,8*s-1);C(this,t,n,s,v-1,-v)}var y=s-1,P=1,W=0;for(this[n+y]=t&255;--y>=0&&(P*=256);)t<0&&W===0&&this[n+y+1]!==0&&(W=1),this[n+y]=(t/P>>0)-W&255;return n+s},c.prototype.writeInt8=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1},c.prototype.writeInt16LE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2},c.prototype.writeInt16BE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2},c.prototype.writeInt32LE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4},c.prototype.writeInt32BE=function(t,n,s){return t=+t,n=n>>>0,s||C(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function X(a,t,n,s,d,v){if(n+s>a.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function me(a,t,n,s,d){return t=+t,n=n>>>0,d||X(a,t,n,4),o.write(a,t,n,s,23,4),n+4}c.prototype.writeFloatLE=function(t,n,s){return me(this,t,n,!0,s)},c.prototype.writeFloatBE=function(t,n,s){return me(this,t,n,!1,s)};function xe(a,t,n,s,d){return t=+t,n=n>>>0,d||X(a,t,n,8),o.write(a,t,n,s,52,8),n+8}c.prototype.writeDoubleLE=function(t,n,s){return xe(this,t,n,!0,s)},c.prototype.writeDoubleBE=function(t,n,s){return xe(this,t,n,!1,s)},c.prototype.copy=function(t,n,s,d){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(s||(s=0),!d&&d!==0&&(d=this.length),n>=t.length&&(n=t.length),n||(n=0),d>0&&d=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),t.length-n>>0,s=s===void 0?this.length:s>>>0,t||(t=0);var y;if(typeof t=="number")for(y=n;y55295&&n<57344){if(!d){if(n>56319){(t-=3)>-1&&v.push(239,191,189);continue}else if(y+1===s){(t-=3)>-1&&v.push(239,191,189);continue}d=n;continue}if(n<56320){(t-=3)>-1&&v.push(239,191,189),d=n;continue}n=(d-55296<<10|n-56320)+65536}else d&&(t-=3)>-1&&v.push(239,191,189);if(d=null,n<128){if((t-=1)<0)break;v.push(n)}else if(n<2048){if((t-=2)<0)break;v.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;v.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;v.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return v}function kt(a){for(var t=[],n=0;n>8,d=n%256,v.push(d),v.push(s);return v}function Xt(a){return r.toByteArray($(a))}function ot(a,t,n,s){for(var d=0;d=t.length||d>=a.length);++d)t[d+n]=a[d];return d}function Ce(a,t){return a instanceof t||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===t.name}function It(a){return a!==a}var Nn=function(){for(var a="0123456789abcdef",t=new Array(256),n=0;n<16;++n)for(var s=n*16,d=0;d<16;++d)t[s+d]=a[n]+a[d];return t}()})(Jn);var Sn={exports:{}},te=Sn.exports={},Le,Me;function Mt(){throw new Error("setTimeout has not been defined")}function Et(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Le=setTimeout:Le=Mt}catch{Le=Mt}try{typeof clearTimeout=="function"?Me=clearTimeout:Me=Et}catch{Me=Et}})();function kn(e){if(Le===setTimeout)return setTimeout(e,0);if((Le===Mt||!Le)&&setTimeout)return Le=setTimeout,setTimeout(e,0);try{return Le(e,0)}catch{try{return Le.call(null,e,0)}catch{return Le.call(this,e,0)}}}function or(e){if(Me===clearTimeout)return clearTimeout(e);if((Me===Et||!Me)&&clearTimeout)return Me=clearTimeout,clearTimeout(e);try{return Me(e)}catch{try{return Me.call(null,e)}catch{return Me.call(this,e)}}}var Fe=[],Je=!1,We,lt=-1;function ir(){!Je||!We||(Je=!1,We.length?Fe=We.concat(Fe):lt=-1,Fe.length&&In())}function In(){if(!Je){var e=kn(ir);Je=!0;for(var r=Fe.length;r;){for(We=Fe,Fe=[];++lt1)for(var o=1;oVn(),ae={CONSENT:"et-001-c",CLICKED_BUTTONS:"et-001-cb",MESSAGES:"et-001-m",USER_ID:"et-001-aid",TRIGGER_TIMEOUT:"et-001-tt",SESSION_ID:"et-001-bid",SESSION_START_TIMESTAMP:"et-001-sst",POST_REVEAL_TRIGGER:"et-001-prt",REVEAL_BUTTON_JUST_CLICKED:"et-001-rbjc"},nn={LIVE_CHAT_SESSION_ID:"et-001-lid"},ca=4/3,Ve={CONFIG:"config",MESSAGES:"messages",EMAILS:"emails",MESSAGE_LOGGING:"api/msg/v2/send",EVENT_LOGGING:"api/cb/v2/send",CONVERSION_CLICK_LOGGING:"api/cc/v2/send",TRANSIENT_LOGGING:"api/tl/v2/send"},ua={LAUNCHER_ICON:"Open Virtual Shopping Assistant",CLOSE_ICON:"Close",SEND_ICON:"Send Message",MESSAGE_SENDING:"Message Sending"},lr="23pt",da=5,xn="Thank you for using our live chat service.",cr="I’m sorry that we were unable to resolve your query. Please click the button below to contact a member of our Customer Support Team.",rn=1e3,Gt=3.25,ur=Gt*4,Cn=Gt*.05,Ln=.75,dr=Ln*2+Cn,ga={HORIZONTAL_PADDING:`${dr}em`,VERTICAL_PADDING:`${Ln}em`,FONT_SIZE:"1em",WIDTH:`${ur}em`,HEIGHT:`${Gt}em`,BUTTON_SPACING:"0.6em",BORDER_WIDTH:`${Cn}em`},ha="0.8125em",_a="0.161em",fa="1.3em",_t="_ERR_CONFIG_NOT_AVAILABLE_",gr="_ERR_CHAT_SESSION_MISSING_",on=["mousemove","click","touchstart","touchend","touchmove","scroll","keydown"];var p=(e=>(e[e.chatbot_loaded=1]="chatbot_loaded",e[e.chat_window_shown=2]="chat_window_shown",e[e.chat_window_hidden=3]="chat_window_hidden",e[e.trigger_shown=4]="trigger_shown",e[e.trigger_disappear_launcher_click=5]="trigger_disappear_launcher_click",e[e.trigger_shown_delay=6]="trigger_shown_delay",e[e.trigger_shown_timeout=7]="trigger_shown_timeout",e[e.trigger_close=8]="trigger_close",e[e.trigger_button_click=9]="trigger_button_click",e[e.trigger_body_click=10]="trigger_body_click",e[e.trigger_button_redirect_click=11]="trigger_button_redirect_click",e[e.trigger_button_recommend_click=12]="trigger_button_recommend_click",e[e.chat_window_open_user_launcher_click=13]="chat_window_open_user_launcher_click",e[e.chat_window_open_automatic=14]="chat_window_open_automatic",e[e.chat_window_open_user_trigger_body=15]="chat_window_open_user_trigger_body",e[e.chat_window_open_user_trigger_button=16]="chat_window_open_user_trigger_button",e[e.chat_window_close_launcher_icon=17]="chat_window_close_launcher_icon",e[e.chat_window_close_header_close_icon=18]="chat_window_close_header_close_icon",e[e.consent_overlay_shown=19]="consent_overlay_shown",e[e.consent_overlay_agree_button_click=20]="consent_overlay_agree_button_click",e[e.consent_overlay_disagree_button_click=21]="consent_overlay_disagree_button_click",e[e.consent_overlay_nonagreement_follow_up_shown=22]="consent_overlay_nonagreement_follow_up_shown",e[e.consent_overlay_nonagreement_follow_up_button_click=23]="consent_overlay_nonagreement_follow_up_button_click",e[e.welcome_menu_redirect_button_click=24]="welcome_menu_redirect_button_click",e[e.welcome_menu_text_button_click=25]="welcome_menu_text_button_click",e[e.welcome_menu_reveal_text_button_click=26]="welcome_menu_reveal_text_button_click",e[e.welcome_menu_product_recommend_button_click=27]="welcome_menu_product_recommend_button_click",e[e.welcome_menu_handover_button_click=28]="welcome_menu_handover_button_click",e[e.chatbot_message_handover_preamble_shown=29]="chatbot_message_handover_preamble_shown",e[e.chatbot_message_email_button_shown=30]="chatbot_message_email_button_shown",e[e.chatbot_message_email_button_click=31]="chatbot_message_email_button_click",e[e.chatbot_message_email_form_shown=32]="chatbot_message_email_form_shown",e[e.chatbot_message_email_form_submit=33]="chatbot_message_email_form_submit",e[e.chatbot_message_redirect_handover_shown=34]="chatbot_message_redirect_handover_shown",e[e.chatbot_message_redirect_handover_button_click=35]="chatbot_message_redirect_handover_button_click",e[e.chatbot_message_live_chat_redirect_handover_shown=36]="chatbot_message_live_chat_redirect_handover_shown",e[e.chatbot_message_live_chat_redirect_handover_button_click=37]="chatbot_message_live_chat_redirect_handover_button_click",e[e.chatbot_message_text_shown=38]="chatbot_message_text_shown",e[e.chatbot_message_redirect_button_shown=39]="chatbot_message_redirect_button_shown",e[e.user_message_sent_user_input_send_icon_click=40]="user_message_sent_user_input_send_icon_click",e[e.user_message_sent_user_input_enter_press=41]="user_message_sent_user_input_enter_press",e[e.loading_message_appears=42]="loading_message_appears",e[e.loading_message_disappears=43]="loading_message_disappears",e[e.user_message_text_message_shown=44]="user_message_text_message_shown",e[e.chatbot_message_carousel_shown=45]="chatbot_message_carousel_shown",e[e.chatbot_message_carousel_left_button_click=46]="chatbot_message_carousel_left_button_click",e[e.chatbot_message_carousel_right_button_click=47]="chatbot_message_carousel_right_button_click",e[e.chatbot_message_carousel_swipe_left=48]="chatbot_message_carousel_swipe_left",e[e.chatbot_message_carousel_swipe_right=49]="chatbot_message_carousel_swipe_right",e[e.chatbot_message_carousel_pagination_button_click=50]="chatbot_message_carousel_pagination_button_click",e[e.chatbot_message_carousel_image_click=51]="chatbot_message_carousel_image_click",e[e.chatbot_message_carousel_redirect_button_click=52]="chatbot_message_carousel_redirect_button_click",e[e.chatbot_message_generic_error_text_shown=53]="chatbot_message_generic_error_text_shown",e[e.page_navigation_on_redirect=54]="page_navigation_on_redirect",e[e.page_close=55]="page_close",e[e.chatbot_message_redirect_button_click=56]="chatbot_message_redirect_button_click",e[e.trigger_hidden=57]="trigger_hidden",e[e.chatbot_config_retrieved=58]="chatbot_config_retrieved",e[e.chatbot_message_carousel_image_broken=59]="chatbot_message_carousel_image_broken",e[e.live_chat_handover_requested_salesforce=60]="live_chat_handover_requested_salesforce",e[e.live_chat_handover_requested_gorgias=61]="live_chat_handover_requested_gorgias",e[e.live_chat_handover_requested_zendesk=62]="live_chat_handover_requested_zendesk",e[e.live_chat_handover_requested_tawk_to=63]="live_chat_handover_requested_tawk_to",e[e.live_chat_handover_requested_tidio=64]="live_chat_handover_requested_tidio",e[e.live_chat_handover_requested_live_chat=65]="live_chat_handover_requested_live_chat",e[e.live_chat_handover_requested_edesk=66]="live_chat_handover_requested_edesk",e[e.live_chat_handover_requested_chatra=67]="live_chat_handover_requested_chatra",e[e.live_chat_handover_requested_intercom=68]="live_chat_handover_requested_intercom",e[e.live_chat_handover_chatbot_hidden=69]="live_chat_handover_chatbot_hidden",e[e.live_chat_handover_provider_shown=70]="live_chat_handover_provider_shown",e[e.live_chat_handover_provider_not_shown=71]="live_chat_handover_provider_not_shown",e[e.live_chat_handover_provider_no_agents=72]="live_chat_handover_provider_no_agents",e[e.live_chat_handover_provider_hidden=73]="live_chat_handover_provider_hidden",e[e.live_chat_handover_chatbot_shown=74]="live_chat_handover_chatbot_shown",e[e.live_chat_handover_requested_custom_api_integration=75]="live_chat_handover_requested_custom_api_integration",e[e.chatbot_api_end_live_chat=76]="chatbot_api_end_live_chat",e[e.chatbot_message_live_chat_handover_button_click=77]="chatbot_message_live_chat_handover_button_click",e[e.chatbot_message_live_chat_handover_button_shown=78]="chatbot_message_live_chat_handover_button_shown",e[e.chatbot_message_handover_post_prompt_shown=79]="chatbot_message_handover_post_prompt_shown",e[e.backup_handover_requested=80]="backup_handover_requested",e[e.chatbot_config_not_retrieved=81]="chatbot_config_not_retrieved",e[e.chatbot_api_show_called=82]="chatbot_api_show_called",e[e.chatbot_api_hide_called=83]="chatbot_api_hide_called",e[e.launcher_shown=84]="launcher_shown",e[e.launcher_hidden=85]="launcher_hidden",e[e.notifier_shown=86]="notifier_shown",e[e.notifier_hidden=87]="notifier_hidden",e[e.live_chat_handover_session_already_active=88]="live_chat_handover_session_already_active",e[e.live_chat_handover_no_session_available=89]="live_chat_handover_no_session_available",e[e.local_storage_write_error=90]="local_storage_write_error",e[e.session_storage_write_error=91]="session_storage_write_error",e[e.live_chat_handover_provider_outside_business_hours=92]="live_chat_handover_provider_outside_business_hours",e[e.chatbot_overlay_resume_live_chat_button_click=93]="chatbot_overlay_resume_live_chat_button_click",e[e.chatbot_overlay_end_live_chat_button_click=94]="chatbot_overlay_end_live_chat_button_click",e[e.live_chat_handover_missing_gorgias_widget=97]="live_chat_handover_missing_gorgias_widget",e[e.live_chat_handover_missing_zendesk_widget=98]="live_chat_handover_missing_zendesk_widget",e[e.chatbot_message_live_chat_out_of_hours_message_shown=99]="chatbot_message_live_chat_out_of_hours_message_shown",e[e.chatbot_message_carousel_preamble_shown=100]="chatbot_message_carousel_preamble_shown",e[e.chatbot_message_reveal_text_post_prompt_shown=101]="chatbot_message_reveal_text_post_prompt_shown",e[e.system_message_live_chat_cancelled_shown=102]="system_message_live_chat_cancelled_shown",e[e.system_message_live_chat_started_shown=103]="system_message_live_chat_started_shown",e[e.system_message_live_chat_ended_shown=104]="system_message_live_chat_ended_shown",e[e.system_message_live_chat_no_agents_available_shown=105]="system_message_live_chat_no_agents_available_shown",e[e.chatbot_message_live_chat_offline_message_shown=106]="chatbot_message_live_chat_offline_message_shown",e[e.chatbot_message_live_chat_session_already_active_shown=107]="chatbot_message_live_chat_session_already_active_shown",e[e.live_chat_handover_requested_zendesk_classic=108]="live_chat_handover_requested_zendesk_classic",e[e.welcome_message_shown=109]="welcome_message_shown",e[e.trigger_shown_inactivity_delay=110]="trigger_shown_inactivity_delay",e[e.live_chat_handover_missing_tawk_to_widget=111]="live_chat_handover_missing_tawk_to_widget",e[e.chatbot_api_open_called=112]="chatbot_api_open_called",e[e.chatbot_api_close_called=113]="chatbot_api_close_called",e[e.chat_window_height_grow_header_toggle_icon=114]="chat_window_height_grow_header_toggle_icon",e[e.chat_window_height_shrink_header_toggle_icon=115]="chat_window_height_shrink_header_toggle_icon",e[e.page_navigation_on_title_change=116]="page_navigation_on_title_change",e[e.chatbot_message_copy_text_button_click=117]="chatbot_message_copy_text_button_click",e[e.chatbot_message_copy_text_button_shown=118]="chatbot_message_copy_text_button_shown",e[e.post_reveal_trigger_shown=119]="post_reveal_trigger_shown",e[e.chatbot_messsage_guide_user_to_revealed_message=120]="chatbot_messsage_guide_user_to_revealed_message",e[e.trigger_button_clicked_reveal_click=121]="trigger_button_clicked_reveal_click",e[e.welcome_menu_clicked_reveal_button_click=122]="welcome_menu_clicked_reveal_button_click",e[e.trigger_button_reveal_click=123]="trigger_button_reveal_click",e[e.trigger_button_copy_text_click=124]="trigger_button_copy_text_click",e[e.trigger_copy_text_button_shown=125]="trigger_copy_text_button_shown",e[e.post_reveal_trigger_body_click=126]="post_reveal_trigger_body_click",e[e.chat_window_open_user_post_reveal_trigger_body=127]="chat_window_open_user_post_reveal_trigger_body",e[e.chatbot_hidden_blacklisted_path=128]="chatbot_hidden_blacklisted_path",e[e.chat_window_open_user_after_welcome_menu_reveal_text_redirect=129]="chat_window_open_user_after_welcome_menu_reveal_text_redirect",e[e.welcome_menu_shown=130]="welcome_menu_shown",e[e.session_created=131]="session_created",e[e.session_started=132]="session_started",e[e.session_inactivity_warning_limit_reached=133]="session_inactivity_warning_limit_reached",e[e.session_ended_via_timeout=134]="session_ended_via_timeout",e[e.session_destroyed=135]="session_destroyed",e[e.session_continued_after_load=136]="session_continued_after_load",e))(p||{});const an={Gorgias:61,Zendesk:62,"Zendesk (Classic)":108,"Tawk.to":63,"Custom API Integration":75},hr={email:{click:31,message:32}},Oe=(e,r,o="local")=>{o==="local"?S(p.local_storage_write_error):o==="session"&&S(p.session_storage_write_error),console.error(`An error occured while writing ${e} to ${o} storage. Current estimated size of used ${o} storage is ${_r(o)}`),console.error(r)},_r=e=>{const r=JSON.stringify(window[`${e}Storage`]).length;return r?r*2/1024+" KB":"Empty (0 KB)"};var vt={exports:{}};function fr(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}var mr=pr;function pr(e,r,o){var l=o&&o.stringify||fr,u=1;if(typeof e=="object"&&e!==null){var g=r.length+u;if(g===1)return e;var h=new Array(g);h[0]=l(e);for(var c=1;c-1?T:0,e.charCodeAt(w+1)){case 100:case 102:if(m>=f||r[m]==null)break;T=f||r[m]==null)break;T=f||r[m]===void 0)break;T",T=w+2,w++;break}_+=l(r[m]),T=w+2,w++;break;case 115:if(m>=f)break;T{l[u]=o[u]?o[u]:et[u]||et[wr[u]||"log"]||tt}),e[qt]=l}function br(e,r){return Array.isArray(e)?e.filter(function(l){return l!=="!stdSerializers.err"}):e===!0?Object.keys(r):!1}function Ue(e){e=e||{},e.browser=e.browser||{};const r=e.browser.transmit;if(r&&typeof r.send!="function")throw Error("pino: transmit option must have a send function");const o=e.browser.write||et;e.browser.write&&(e.browser.asObject=!0);const l=e.serializers||{},u=br(e.browser.serialize,l);let g=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(g=!1);const h=Object.keys(e.customLevels||{}),c=["error","fatal","warn","info","debug","trace"].concat(h);typeof o=="function"&&c.forEach(function(B){o[B]=o}),(e.enabled===!1||e.browser.disabled)&&(e.level="silent");const f=e.level||"info",_=Object.create(o);_.log||(_.log=tt),yr(_,c,o),ln({},_),Object.defineProperty(_,"levelVal",{get:T}),Object.defineProperty(_,"level",{get:M,set:w});const m={transmit:r,serialize:u,asObject:e.browser.asObject,formatters:e.browser.formatters,levels:c,timestamp:Lr(e)};_.levels=Tr(e),_.level=f,_.setMaxListeners=_.getMaxListeners=_.emit=_.addListener=_.on=_.prependListener=_.once=_.prependOnceListener=_.removeListener=_.removeAllListeners=_.listeners=_.listenerCount=_.eventNames=_.write=_.flush=tt,_.serializers=l,_._serialize=u,_._stdErrSerialize=g,_.child=N,r&&(_._logEvent=Rt());function T(){return ft(this.level,this)}function M(){return this._level}function w(B){if(B!=="silent"&&!this.levels.values[B])throw Error("unknown level "+B);this._level=B,je(this,m,_,"error"),je(this,m,_,"fatal"),je(this,m,_,"warn"),je(this,m,_,"info"),je(this,m,_,"debug"),je(this,m,_,"trace"),h.forEach(G=>{je(this,m,_,G)})}function N(B,G){if(!B)throw new Error("missing bindings for child Pino");G=G||{},u&&B.serializers&&(G.serializers=B.serializers);const O=G.serializers;if(u&&O){var q=Object.assign({},l,O),D=e.browser.serialize===!0?Object.keys(q):u;delete B.serializers,wt([B],D,q,this._stdErrSerialize)}function V(x){this._childLevel=(x._childLevel|0)+1,this.bindings=B,q&&(this.serializers=q,this._serialize=D),r&&(this._logEvent=Rt([].concat(x._logEvent.bindings,B)))}V.prototype=this;const b=new V(this);return ln(this,b),b.level=this.level,b}return _}function Tr(e){const r=e.customLevels||{},o=Object.assign({},Ue.levels.values,r),l=Object.assign({},Ue.levels.labels,Sr(r));return{values:o,labels:l}}function Sr(e){const r={};return Object.keys(e).forEach(function(o){r[e[o]]=o}),r}Ue.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Ue.stdSerializers=vr;Ue.stdTimeFunctions=Object.assign({},{nullTime:Mn,epochTime:En,unixTime:Mr,isoTime:Er});function kr(e){const r=[];e.bindings&&r.push(e.bindings);let o=e[Bt];for(;o.parent;)o=o.parent,o.logger.bindings&&r.push(o.logger.bindings);return r.reverse()}function je(e,r,o,l){if(e[l]=ft(e.level,o)>ft(l,o)?tt:o[qt][l],!r.transmit&&e[l]===tt)return;e[l]=Ar(e,r,o,l);const u=kr(e);u.length!==0&&(e[l]=Ir(u,e[l]))}function Ir(e,r){return function(){return r.apply(this,[...e,...arguments])}}function Ar(e,r,o,l){return function(u){return function(){const h=r.timestamp(),c=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===et?et:this;for(var _=0;_e.levels.values[r],log:h=M=>M}=u;e._serialize&&wt(o,e._serialize,e.serializers,e._stdErrSerialize);const c=o.slice();let f=c[0];const _={};l&&(_.time=l),_.level=g(r,e.levels.values[r]);let m=(e._childLevel|0)+1;if(m<1&&(m=1),f!==null&&typeof f=="object"){for(;m--&&typeof c[0]=="object";)Object.assign(_,c.shift());f=c.length?sn(c.shift(),c):void 0}else typeof f=="string"&&(f=sn(c.shift(),c));return f!==void 0&&(_.msg=f),h(_)}function wt(e,r,o,l){for(const u in e)if(l&&e[u]instanceof Error)e[u]=Ue.stdSerializers.err(e[u]);else if(typeof e[u]=="object"&&!Array.isArray(e[u]))for(const g in e[u])r&&r.indexOf(g)>-1&&g in o&&(e[u][g]=o[g](e[u][g]))}function Cr(e,r,o){const l=r.send,u=r.ts,g=r.methodLevel,h=r.methodValue,c=r.val,f=e._logEvent.bindings;wt(o,e._serialize||Object.keys(e.serializers),e.serializers,e._stdErrSerialize===void 0?!0:e._stdErrSerialize),e._logEvent.ts=u,e._logEvent.messages=o.filter(function(_){return f.indexOf(_)===-1}),e._logEvent.level.label=g,e._logEvent.level.value=h,l(g,e._logEvent,c),e._logEvent=Rt(f)}function Rt(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function cn(e){const r={type:e.constructor.name,msg:e.message,stack:e.stack};for(const o in e)r[o]===void 0&&(r[o]=e[o]);return r}function Lr(e){return typeof e.timestamp=="function"?e.timestamp:e.timestamp===!1?Mn:En}function at(){return{}}function xt(e){return e}function tt(){}function Mn(){return!1}function En(){return Date.now()}function Mr(){return Math.round(Date.now()/1e3)}function Er(){return new Date(Date.now()).toISOString()}function Br(){function e(r){return typeof r<"u"&&r}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return e(self)||e(window)||e(this)||{}}}vt.exports.default=Ue;vt.exports.pino=Ue;var Rr=vt.exports;const Fr=bn(Rr),Or=R(Fr({level:{VITE_WEB_COMPONENT:"true",VITE_RELEASE_TOGGLE_AFFILIATE_TRACKING_ENABLED:"true",VITE_RELEASE_TOGGLE_MULTIPLE_SESSIONS_ENABLED:"false",VITE_BOT_BACKEND:"https://envolve-chatbot-api-dot-envolvetech-001.nw.r.appspot.com",VITE_LOGGING_BACKEND:"https://envolve-logging-dot-envolvetech-001.nw.r.appspot.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}.VITE_CONSOLE_LOG_LEVEL||"silent"})),ue=()=>Or,Ft=R(!1),yt=()=>Ft,Ur=(e=[],r=window.location.pathname,o=window.location.href)=>e.some(l=>{if(typeof l!="string")return!1;const u=l.match(/^\/((?:\\.|[^\/])+)\/([gimsuy]*)$/);if(u){const h=u[1].replace(/\\\\/g,"\\"),c=u[2];try{const f=new RegExp(h,c);return f.test(r)||f.test(o)}catch{return!1}}const g=l.toLowerCase();return r.toLowerCase().includes(g)||o.toLowerCase()===g}),Pr=(e=!0,r=[])=>{if(e&&Ur(r)){Ft.value=!1,ue().value.debug("Could not load the application due to a match on a blacklisted path/URL"),S(p.chatbot_hidden_blacklisted_path);return}Ft.value=e},_e=Ge("application",()=>{const e=de(),r=ue(),o=()=>{{const L=l.value,$=document.createElement("style");$.textContent=` :host { all: initial !important; } `,L.appendChild($)}},l=R(null);customElements.whenDefined("envolve-vsa").then(async()=>{const L=document.querySelector("envolve-vsa");L&&L.shadowRoot&&(l.value=L.shadowRoot)});const u=navigator.userAgent,g=new Kn.UAParser(u),h=F(()=>g.getDevice().type==="mobile"),c=F(()=>g.getDevice().type??"unknown"),f=De(ae.CLICKED_BUTTONS,{},{onError:L=>{Oe(ae.CLICKED_BUTTONS,L)}}),_=R(!1),m=()=>{_.value=!_.value,D.value.consentGiven===!1&&(D.value={consentGiven:null,expiry:0})},T=(L,$,re)=>{const kt=window.btoa(L.postReveal);f.value[kt]={postPrompt:$,copyButton:re}},M=L=>window.btoa(L.postReveal)in f.value,w=L=>{const $=window.btoa(L.postReveal);return f.value[$]},N=R(null),B=R(),G=De(ae.USER_ID,he(),{onError:L=>{Oe(ae.USER_ID,L)}}),O=L=>{L&&(N.value=L)},q=L=>{L&&(B.value=L)},D=De(ae.CONSENT,{consentGiven:null,expiry:null},{onError:L=>{Oe(ae.CONSENT,L)}}),V=F(()=>D.value.expiry&&D.value.expiry>new Date().getTime()?D.value.consentGiven:null),b=(L,$)=>{D.value={consentGiven:L,expiry:new Date().getTime()+$}},x=F(()=>!V.value&&e.userConsentConfig.enabled),E=F(()=>h.value),Y=F(()=>!(_.value&&E.value)),ne=async L=>{let $=l.value?.querySelector(".message-list > div:nth-last-child(1)");if(!$){const re=document.querySelector("envolve-vsa");re?.shadowRoot&&($=re.shadowRoot.querySelector(".message-list > div:nth-last-child(1)"))}await Dn(),$&&$.scrollIntoView({behavior:L.smooth?"smooth":"instant"})},j=(L,$)=>{const re=fe(L);return re?.scrollIntoView({behavior:$.smooth?"smooth":"instant"}),re},fe=L=>{let $=l.value?.getElementById(L);if(!$){const re=document.querySelector("envolve-vsa");re?.shadowRoot&&($=re.shadowRoot.getElementById(L))}return $},ke=F(()=>!!(_.value&&x.value));Te(ke,()=>{ke.value&&S(p.consent_overlay_shown)});const Ie=R(!1),ge=De(ae.POST_REVEAL_TRIGGER,{contents:null,justClicked:null},{onError:L=>{Oe(ae.POST_REVEAL_TRIGGER,L)}}),Ae=F(()=>ge.value.contents),Be=R(!1),I=R(!1),H=R(),oe=R(),K=R(!0),k=()=>{K.value=!K.value};Te(()=>Be.value,L=>{S(L?p.launcher_shown:p.launcher_hidden)}),Te(()=>Ie.value,L=>{ge.value.contents&&L?(S(p.post_reveal_trigger_shown),S(p.trigger_copy_text_button_shown)):S(L?p.trigger_shown:p.trigger_hidden)}),Te(()=>_.value,L=>{S(L?p.chat_window_shown:p.chat_window_hidden)});let C;const X=()=>{const L=()=>{const re=window.location.href;S(p.page_navigation_on_title_change),r.value.debug(`Navigation or DOM change detected: ${re}`)};C=new MutationObserver(L);const $=document.querySelector("title");$?C.observe($,{childList:!0}):r.value.warn("Title element not found.")},me=()=>{C||(r.value.debug("Starting MutationObserver."),X())},xe=()=>{C&&(C.disconnect(),C=null,r.value.debug("MutationObserver disconnected."))};return Te(()=>yt().value,()=>{r.value.debug("Application Loaded - starting navigation observer."),me()}),{clickedButtons:f,chatWindowOpen:_,toggleWindowOpenState:m,addClickedButton:T,buttonExistsInList:M,backendUrl:N,updateBackendUrl:O,siteKey:B,updateSitekey:q,userId:G,consent:V,setConsentWithExpiry:b,userConsentOverlayShouldRender:x,showLauncher:Y,showFullscreenChatWindow:E,isMobileOnly:h,scrollToLastMessage:ne,deviceType:c,triggerMessageVisible:Ie,launcherVisible:Be,scrollToMessageWithId:j,resetStylesAtRoot:o,liveChatOverlayActive:I,launcherRef:H,startNavigationObserver:me,stopNavigationObserver:xe,notifierRef:oe,chatWindowShouldBeMaxHeight:K,toggleIfChatWindowShouldBeMaxHeight:k,postRevealData:ge,postRevealTriggerTimerCheck:Ae,getClickedButtonValue:w,findMessageElementWithId:fe}}),bt=e=>btoa(encodeURIComponent(JSON.stringify(e))).split("").reverse().join(""),Nr=e=>new Promise(r=>{if(e.value)r(e.value);else{const o=Te(()=>e.value,l=>{l&&(o(),r(l))},{immediate:!0})}}),Ht=Ge("session",()=>{const e=F(()=>!1),r=De(ae.SESSION_ID,e.value?null:he(),{onError:O=>{Oe(ae.SESSION_ID,O)}}),o=Nr(r);if(!e.value)return{sessionId:r,sessionReady:o};const l=ue(),u=_e(),g=De(ae.SESSION_START_TIMESTAMP,0,{onError:O=>{Oe(ae.SESSION_START_TIMESTAMP,O)}}),h=R(()=>{}),c=R(()=>{}),f=R(!1),_=60*60*1e3,m=24*60*60*1e3,T=()=>{S(p.session_ended_via_timeout),l.value.debug("Session Destroyed, creating new session..."),S(p.session_destroyed),r.value=null,g.value=0,w()},M=(O=_,q=m)=>{const D=Re(()=>{l.value.debug("Session Inactivity Warning Timer finished"),S(p.session_inactivity_warning_limit_reached)},O,{immediate:!1}),V=Re(()=>{l.value.debug("Session Expiry Timer finished"),T()},q,{immediate:!1});h.value=()=>{l.value.debug("Session timers started"),D.start(),V.start()},c.value=()=>{l.value.debug("Session timers stopped"),D.stop(),V.stop()},l.value.debug("Session timers created"),f.value=!0},w=()=>{l.value.debug("Session created"),M(),r.value=he().toString(),o.then(()=>{S(p.session_created)})},N=()=>{if(g.value===0){M();return}const q=Date.now()-g.value,D=Math.max(_-q,0),V=Math.max(m-q,0);V>0?(M(D,V),h.value(),l.value.debug("Resumed Session Timers after load"),S(p.session_continued_after_load)):(l.value.debug("Session Ended after load"),T())};(()=>{r.value?f.value||o.then(()=>{N()}):w()})();const G=()=>{l.value.debug("Session started"),S(p.session_started),g.value=Date.now(),h.value()};return Te(()=>u.chatWindowOpen,O=>{O&&g.value===0&&G()}),{sessionId:r,sessionReady:o,timersInitialised:f}}),le=()=>he(),S=(e,r=le())=>{const o=_e(),l=de(),u=ue(),g=Ht(),h=new Date,c={c:o.siteKey,co:l.state.config.id,c_v:l.state.config.currentVersion,e_t:e,c_t:h.toISOString(),w_t:document.title,w_u:document.URL,s_i:g.sessionId??gr,u_a:navigator.userAgent,u_i:o.userId,d_o:window.screen.orientation.type,d_t:o.deviceType,e_i:r,t_o:h.getTimezoneOffset()};u.value.debug(c);const f=bt(c);return nt.post(`https://envolve-logging-dot-envolvetech-001.nw.r.appspot.com/${Ve.EVENT_LOGGING}`,f,{headers:{"Content-Type":"text/plain"}}).catch(()=>{console.error("Error occurred attempting to send message")}),r},Dr=/^#[A-Fa-f0-9]{3}(?:[A-Fa-f0-9]?|(?:[A-Fa-f0-9]{3}(?:[A-Fa-f0-9]{2})?)?)$/;function A(e){if(!Dr.test(e))throw new Error("Invalid hexadecimal colour");return e}const Ot=["_blank","_self"],Gr=["redirect","recommend","handover","revealText","text"],qr=["Unknown","Tawk.to","Live Chat","Intercom"],Hr=["Unknown","Custom API Integration","Gorgias","Zendesk","Zendesk (Classic)","Tawk.to"],jr=["none","email","redirect"],$r=["message","tiltedMessage","lightbulb","speechBubble","notification","envelope","lightning","present"],zr=["bottomRight","bottomLeft","middleRight","middleLeft"],Wr=["circle","rectangle","square"],Vr=["rounded","sharp"],z={config:{components:{button:{hoverBackgroundColour:A("#A9A9A9"),hoverBorderColour:A("#A9A9A9"),hoverFontColour:A("#00357B"),contexts:{welcomeMenu:{backgroundColour:A("#00357B"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!0,textColour:A("#A9A9A9"),borderColour:A("#A9A9A9")},triggerMessage:{backgroundColour:A("#00357B"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!0,textColour:A("#A9A9A9"),borderColour:A("#A9A9A9")},message:{backgroundColour:A("#00357B"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!0,textColour:A("#A9A9A9"),borderColour:A("#A9A9A9")},carousel:{backgroundColour:A("#00357B"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!0,textColour:A("#A9A9A9"),borderColour:A("#A9A9A9")},handover:{backgroundColour:A("#00357B"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!0,textColour:A("#A9A9A9"),borderColour:A("#A9A9A9")},userConsent:{backgroundColour:A("#00357B"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!1,textColour:A("#A9A9A9"),borderColour:A("#A9A9A9")},systemOverlayPrimary:{backgroundColour:A("#E9E9E9"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!1,textColour:A("#000000"),borderColour:A("#000000")},systemOverlaySecondary:{backgroundColour:A("#E9E9E9"),buttonStyle:"rounded",hoverEnabled:!1,pulsingEnabled:!1,textColour:A("#000000"),borderColour:A("#000000")}}},carouselMessage:{backgroundColour:A("#00357B"),navigationArrowColourActive:A("#A9A9A9"),navigationArrowColourInactive:A("#00357B"),paginationItemColourFocused:A("#A9A9A9"),paginationItemColourUnfocused:A("#00357B"),preambleText:"Here are some recommendations...",preambleTextEnabled:!0,textColour:A("#A9A9A9"),buttonBehaviour:"_self",imageBehaviour:"_self",affiliateTrackingEnabledForComponent:!0},chatHeader:{backgroundColour:A("#00357B"),bodyCopy:`I am your friendly neighbourhood chatbot. I can help recommend products. Check out this link to Google!`,linkColour:A("#D3D3D3"),linkStyle:"underline",textColour:A("#A9A9A9"),titleCopy:"Hi there!"},chatIcon:{contexts:{chatHeader:{enabled:!0,payload:"šŸ‘‹",type:"unicode",style:"rounded"},messageFrame:{enabled:!0,payload:"šŸ‘‹",type:"unicode",style:"rounded"}}},handover:{activeType:"email",prePrompt:"Sorry we could not answer your question, please click the button below to contact our team.",promptButtonText:"Please complete the following form to contact our team.",handoverOptions:{email:{buttonTitle:"Send",postHandover:"Thank you, someone will be in contact soon.",recipient:"joe.bloggs@email.com",formTitle:"Email Form"},iframe:{buttonTitle:"Speak to an agent",url:new URL("https://www.google.com")},liveChatRedirect:{buttonTitle:"Speak to an agent",provider:"Tawk.to",url:new URL("https://www.google.com"),windowOpenTarget:"_blank"},liveChat:{buttonTitle:"Speak to an agent",provider:"Custom API Integration",postHandover:xn,backupHandoverEnabled:!1,backupHandoverType:"email",backupHandoverPrePrompt:"I’m sorry that we were unable to resolve your query. Please click the button below to contact a member of our Customer Support Team.",integrationType:"internal",showLiveChatProviderAndChatbot:!1},redirect:{buttonTitle:"Speak to the team",url:new URL("https://www.google.com"),windowOpenTarget:"_blank"},zendesk:{apiKey:"",buttonTitle:"Speak to an agent",postHandover:"Thank you, someone will be in contact soon."}}},messageList:{sliderColour:A("#00357B"),sliderShape:"rounded",trackColour:A("#A9A9A9"),avatarBackgroundColour:A("#00357B")},textMessage:{contexts:{user:{backgroundColour:A("#00357B"),textColour:A("#A9A9A9")},chatbot:{backgroundColour:A("#00357B"),textColour:A("#A9A9A9")}}},buttonMessage:{buttonBehaviour:"_self",affiliateTrackingEnabledForComponent:!0},userConsent:{agreementText:`Hi there. Welcome! We use your communications here to provide technical support services and improve customer support. This chat uses an automated bot to respond. By continuing, you consent to the collection, use and sharing of the communications in this chat, and with any live agent, for the purposes mentioned above and as provided in our Privacy Policy. If I am not able to assist, you can speak with a human. I agree to the terms above and want to proceed. `,nonAgreementText:"I do not sign away many rights",agreementButtonText:"I agree",nonAgreementButtonText:"I disagree",nonAgreementFollowUpEnabled:!0,postNonAgreementButtonText:"Consent Agreement",placeholderText:"Please consent",backgroundColour:"#F7F7F7",agreementFontColor:"#000000",fontFamily:"Arial",timeout:3e3,title:"Consent to electronic communication",enabled:!1,headerBodyVisible:!1},userInput:{placeholderText:"Type here...",textColour:A("#A9A9A9")},launcher:{icon:{displayed:!0,type:"speechBubble",colour:A("#A9A9A9")},text:{displayed:!0,title:"Talk to us!",colour:A("#A9A9A9")},position:"bottomRight",horizontalOffset:"20pt",verticalOffset:"20pt",backgroundColour:A("#00357B"),shape:"circle",style:"rounded",boxShadow:{offsetX:"0pt",offsetY:"2.5pt",blurRadius:"0.375em",color:A("#00000040"),enabled:!1},notifier:{enabled:!1,blinkingEnabled:!0,backgroundColour:A("#FF0000"),borderColour:A("#FFFFFF"),borderThickness:"0em"},altText:"Virtual Assistant"},triggerMessage:{enabled:!0,type:"textAndButtons",position:"above",style:"rounded",title:"Welcome to Example Business!",body:"Look at all the amazing stuff you can buy here",appearance:{fontColour:A("#00357B"),backgroundColour:A("#f7f7f7"),borderColour:A("#00357B")},timeout:{enabled:!1,value:86400},delay:{enabled:!1,value:5,hasInactivityDelay:!1},duration:{enabled:!1,value:5},boxShadow:{offsetX:"0em",offsetY:"0.25em",blurRadius:"0.375em",color:A("#00000040"),enabled:!1},hover:{backgroundColour:A("#A9A9A9"),borderColour:A("#A9A9A9"),fontColour:A("#00357B")},useWelcomeMenuButtons:!0,items:[]}},globalConfig:{fontFamily:"Arial",fontSize:14,boxShadow:{offsetX:"0em",offsetY:"0.25em",blurRadius:"0.375em",color:A("#00000040"),enabled:!0},badResponse:"Sorry we could not answer your message.",visible:!0,handoverEnabled:!0,relativeChatWindowHeight:100,relativeChatWindowHeightEnabled:!1,blacklistedPaths:["/blacklisted"]},network:null,id:_t,currentVersion:_t}},U=i.string().pattern(/^#[A-Fa-f0-9]{3}(?:[A-Fa-f0-9]?|(?:[A-Fa-f0-9]{3}(?:[A-Fa-f0-9]{2})?)?)$/);i.string().pattern(/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(0|1|0?\.\d+)\)$/i);const Q=z.config.components.button.contexts,Kr=e=>{switch(e){case"carousel":return Q.carousel;case"handover":return Q.handover;case"message":return Q.message;case"welcomeMenu":return Q.welcomeMenu;case"userConsent":return Q.userConsent;case"triggerMessage":return Q.triggerMessage;case"systemOverlayPrimary":return Q.systemOverlayPrimary?Q.systemOverlayPrimary:Q.userConsent;case"systemOverlaySecondary":return Q.systemOverlaySecondary?Q.systemOverlaySecondary:Q.userConsent}},Ne=e=>{const r=Kr(e);return i.object({backgroundColour:U.default(r.backgroundColour),buttonStyle:i.string().valid("rounded","square").default(r.buttonStyle),hoverEnabled:i.boolean().default(r.hoverEnabled),pulsingEnabled:i.boolean().default(r.pulsingEnabled),textColour:U.default(r.textColour),borderColour:U.default(r.borderColour)}).default(Q)},Jr=i.object({contexts:i.object({welcomeMenu:Ne("welcomeMenu").default(Q.welcomeMenu),triggerMessage:Ne("triggerMessage").default(Q.triggerMessage),message:Ne("message").default(Q.message),carousel:Ne("carousel").default(Q.carousel),handover:Ne("handover").default(Q.handover),userConsent:Ne("userConsent").default(Q.userConsent),systemOverlayPrimary:Ne("systemOverlayPrimary").default(Q.systemOverlayPrimary),systemOverlaySecondary:Ne("systemOverlaySecondary").default(Q.systemOverlaySecondary)}).default(Q),hoverBackgroundColour:U.default(z.config.components.button.hoverBackgroundColour),hoverBorderColour:U.default(z.config.components.button.hoverBorderColour),hoverFontColour:U.default(z.config.components.button.hoverFontColour)}).default(z.config.components.button),Yr=i.object({buttonBehaviour:i.string().valid(...Ot).default(z.config.components.buttonMessage.buttonBehaviour),affiliateTrackingEnabledForComponent:i.boolean().default(z.config.components.buttonMessage.affiliateTrackingEnabledForComponent)}).default(z.config.components.buttonMessage),ye=z.config.components.carouselMessage,Zr=i.object({backgroundColour:U.default(ye.backgroundColour),navigationArrowColourActive:U.default(ye.navigationArrowColourActive),navigationArrowColourInactive:U.default(ye.navigationArrowColourInactive),paginationItemColourFocused:U.default(ye.paginationItemColourFocused),paginationItemColourUnfocused:U.default(ye.paginationItemColourUnfocused),preambleText:i.string().default(ye.preambleText),preambleTextEnabled:i.boolean().default(ye.preambleTextEnabled),textColour:U.default(ye.textColour),buttonBehaviour:i.string().valid(...Ot).default(ye.buttonBehaviour),imageBehaviour:i.string().valid(...Ot).default(ye.imageBehaviour),affiliateTrackingEnabledForComponent:i.boolean().default(z.config.components.carouselMessage.affiliateTrackingEnabledForComponent)}).default(ye),$e=z.config.components.chatHeader,Qr=i.object({backgroundColour:U.default($e.backgroundColour),bodyCopy:i.string().default($e.bodyCopy).allow(""),linkColour:U.default($e.linkColour),linkStyle:i.string().valid("underline","none").default($e.linkStyle),textColour:U.default($e.textColour),titleCopy:i.string().default($e.titleCopy)}).default($e),Bn=z.config.components.chatIcon,Xe=Bn.contexts,st=e=>{switch(e){case"chatHeader":return Xe.chatHeader;case"messageFrame":return Xe.messageFrame}},un=e=>i.object({enabled:i.boolean().default(st(e).enabled),payload:i.string().default(st(e).payload),type:i.string().valid("unicode","svg","url").default(st(e).type),style:i.string().valid("rounded","square").default(st(e).style)}),Xr=i.object({contexts:i.object({chatHeader:un("chatHeader").default(Xe.chatHeader),messageFrame:un("messageFrame").default(Xe.messageFrame)}).default(Xe)}).default(Bn),eo=e=>({type:"urlObject",base:e.any(),messages:{"urlObject.base":'"{{#label}}" must be a valid URL object'},validate(r,o){return r instanceof URL?{value:r}:{errors:o.error("urlObject.base")}}}),jt=i.extend(eo),to=["none","email","iframe","liveChatRedirect","liveChat","redirect","zendesk"],no=i.object({buttonTitle:i.string(),postHandover:i.string(),recipient:i.string().email({tlds:{allow:!1}}),formTitle:i.string()}),ro=i.object({buttonTitle:i.string(),url:i.alternatives().try(i.string().uri(),jt.urlObject())}),oo=i.object({buttonTitle:i.string(),provider:i.string().valid(...qr),url:i.alternatives().try(i.string().uri(),jt.urlObject()),windowOpenTarget:i.string().valid("_self","_blank")}),io=i.object({buttonTitle:i.string(),provider:i.string().valid(...Hr),postHandover:i.string(),backupHandoverEnabled:i.boolean(),backupHandoverType:i.string().valid(...jr),backupHandoverPrePrompt:i.string(),integrationType:i.string().valid("internal","embedded"),showLiveChatProviderAndChatbot:i.boolean()}),ao=i.object({buttonTitle:i.string(),url:i.alternatives().try(i.string().uri(),jt.urlObject()),windowOpenTarget:i.string().valid("_self","_blank")}),so=i.object({apiKey:i.string(),buttonTitle:i.string(),postHandover:i.string()}),lo=i.object({activeType:i.string().valid(...to),handoverOptions:i.object({email:i.object().when("...activeType",{is:"email",then:no,otherwise:i.any()}),iframe:i.object().when("...activeType",{is:"iframe",then:ro}),liveChatRedirect:i.object().when("...activeType",{is:"liveChatRedirect",then:oo}),liveChat:i.object().when("...activeType",{is:"liveChat",then:io}),redirect:i.object().when("...activeType",{is:"redirect",then:ao}),zendesk:i.object().when("...activeType",{is:"zendesk",then:so})}),prePrompt:i.string(),promptButtonText:i.string()}),Ze=z.config.components.messageList,co=i.object({sliderColour:U.default(Ze.sliderColour),sliderShape:i.string().valid("rounded","square").default(Ze.sliderShape),trackColour:U.default(Ze.trackColour),avatarBackgroundColour:U.default(Ze.avatarBackgroundColour)}).default(Ze),Ut=z.config.components.textMessage.contexts,mt=e=>{switch(e){case"chatbot":return Ut.chatbot;case"user":return Ut.user}},dn=e=>i.object({backgroundColour:U.default(mt(e).backgroundColour),textColour:U.default(mt(e).textColour)}),uo=i.object({contexts:i.object({user:dn("user").default(mt("user")),chatbot:dn("chatbot").default(mt("chatbot"))}).default(Ut)}),se=z.config.components.userConsent,go=i.object({agreementText:i.string().default(se.agreementText),nonAgreementText:i.string().default(se.nonAgreementText),agreementButtonText:i.string().default(se.agreementButtonText),nonAgreementButtonText:i.string().default(se.nonAgreementButtonText),nonAgreementFollowUpEnabled:i.boolean().default(se.nonAgreementFollowUpEnabled),postNonAgreementButtonText:i.string().default(se.postNonAgreementButtonText),backgroundColour:U.default(se.backgroundColour),placeholderText:i.string().default(se.placeholderText),agreementFontColor:U.default(se.agreementFontColor),fontFamily:i.string().default(se.fontFamily),timeout:i.number().default(se.timeout),title:i.string().default(se.title),enabled:i.boolean().default(se.enabled),buttonType:i.string().valid("rounded","square"),headerBodyVisible:i.boolean().default(se.headerBodyVisible)}).default(se),Ct=z.config.components.userInput,ho=i.object({placeholderText:i.string().default(Ct.placeholderText),textColour:U.default(Ct.textColour)}).default(Ct),gn=["redirect","revealText"],_o=i.object({type:i.string().valid(...Gr).required(),title:i.string().required(),position:i.number().required(),url:i.string().uri().when("type",{is:i.string().valid(...gn),then:i.required(),otherwise:i.optional()}),behaviour:i.string().valid("_self","_blank").when("type",{is:"redirect",then:i.required(),otherwise:i.optional()}),postReveal:i.string().when("type",{is:"revealText",then:i.required(),otherwise:i.optional()}),postPrompt:i.any().when("type",{is:"text",then:i.string().required(),otherwise:i.when("type",{is:"revealText",then:i.string().required(),otherwise:i.any()})}),searchTerms:i.array().items(i.string()).when("type",{is:"recommend",then:i.required(),otherwise:i.optional()}),affiliateTrackingEnabledForComponent:i.boolean().when("type",{is:i.string().valid(...gn),then:i.required(),otherwise:i.optional()})}),fo=i.object({welcomeMessage:i.string().default("").allow("",null),items:i.array().items(_o)}),ct=i.string().pattern(/^[-]?[0-9]*\.?[0-9]+(em|px|pt)$/i),$t=i.object({offsetX:ct,offsetY:ct,blurRadius:ct,color:U,enabled:i.bool()}),mo=i.object({fontFamily:i.string().default(z.config.globalConfig.fontFamily),fontSize:i.number().min(1).default(z.config.globalConfig.fontSize),boxShadow:$t.default(z.config.globalConfig.boxShadow),badResponse:i.string().default(z.config.globalConfig.badResponse),visible:i.boolean().default(z.config.globalConfig.visible),handoverEnabled:i.boolean().default(z.config.globalConfig.handoverEnabled),relativeChatWindowHeightEnabled:i.boolean().default(!1),relativeChatWindowHeight:i.number().min(50).max(100).default(100),blacklistedPaths:i.array().items(i.string()).optional().default([])}),po=i.object({blinkingEnabled:i.boolean().required(),backgroundColour:U,borderColour:U,borderThickness:ct}),vo=po.append({enabled:i.bool()}),be=z.config.components.launcher,ut=be.icon,wo=i.object({displayed:i.boolean().default(ut.displayed),type:i.string().valid(...$r).default(ut.type),colour:U.default(ut.colour)}),dt=be.text,yo=i.object({displayed:i.boolean().default(dt.displayed),title:i.string().default(dt.title),colour:U.default(dt.colour)}),bo=i.object({icon:wo.default(ut),text:yo.default(dt),position:i.string().valid(...zr).default(be.position),horizontalOffset:i.string().default(be.horizontalOffset),verticalOffset:i.string().default(be.verticalOffset),backgroundColour:U.default(be.backgroundColour),shape:i.string().valid(...Wr).default(be.shape),style:i.string().valid(...Vr).default(be.style),boxShadow:$t.default(be.boxShadow),notifier:vo.default(be.notifier),altText:i.string().default(be.altText)}),ce=z.config.components.triggerMessage,To=["text","textAndButtons"],So=["above","inline"],ko=["rounded","square"],gt=ce.appearance,Io=i.object({fontColour:U.default(gt.fontColour),backgroundColour:U.default(gt.backgroundColour),borderColour:U.default(gt.borderColour)}),Ao=i.object({fontColour:U.default(ce.hover.fontColour),backgroundColour:U.default(ce.hover.backgroundColour),borderColour:U.default(ce.hover.borderColour)}),Pt=ce.timeout,xo=[3600,7200,14400,28800,86400,172800,259200],Co=i.object({enabled:i.boolean().default(Pt.enabled),value:i.number().valid(...xo).default(Pt.value)}),ht=ce.delay,Lo=i.object({enabled:i.boolean().default(ht.enabled),value:i.number().default(ht.value),hasInactivityDelay:i.boolean().default(ht.hasInactivityDelay)}),Nt=ce.duration,Mo=i.object({enabled:i.boolean().default(Nt.enabled),value:i.number().default(Nt.value)}),Eo=["redirect","recommend","revealText"],hn=["redirect","revealText"],Bo=i.object({type:i.string().valid(...Eo).required(),title:i.string().required(),position:i.number().required(),url:i.string().uri().when("type",{is:i.string().valid(...hn),then:i.required(),otherwise:i.optional()}),behaviour:i.string().valid("_self","_blank").when("type",{is:"redirect",then:i.required(),otherwise:i.optional()}),searchTerms:i.array().items(i.string()).when("type",{is:"recommend",then:i.required(),otherwise:i.optional()}),postPrompt:i.any().when("type",{is:"revealText",then:i.string().required(),otherwise:i.optional()}),postReveal:i.any().when("type",{is:"revealText",then:i.string().required(),otherwise:i.optional()}),affiliateTrackingEnabledForComponent:i.boolean().when("type",{is:i.string().valid(...hn),then:i.required(),otherwise:i.optional()})}),Ro=i.object({enabled:i.boolean().default(ce.enabled),type:i.string().valid(...To).default(ce.type),position:i.string().valid(...So).default(ce.position),style:i.string().valid(...ko).default(ce.style),title:i.string().default(ce.title),body:i.string().allow(null,""),appearance:Io.default(gt),timeout:Co.default(Pt),delay:Lo.default(ht),duration:Mo.default(Nt),boxShadow:$t.default(ce.boxShadow),hover:Ao.default(ce.hover),useWelcomeMenuButtons:i.boolean().default(ce.useWelcomeMenuButtons),items:i.array().items(Bo)}),Fo=!0,Oo={affiliateIndexKey:i.string().required(),name:i.string().required(),networkCustomDataIdentifier:i.string().allow(null,"").optional(),publisherId:i.string().allow(null,"").optional(),merchantId:i.string().allow(null,"").optional(),networkTrackingBaseDomains:i.array().optional(),affiliateTrackingEnabledForAccount:i.boolean().required(),automaticAffiliateTrackingEnabledForAccount:i.boolean().required(),affiliateTrackingEnabledForNetwork:i.boolean().required(),affiliateTrackingSupportedForNetwork:i.boolean().required(),fullTrackingLink:i.string().allow(null,"").optional()},Uo={...Oo},Po=i.object(Uo).unknown(!Fo),ve=z.config.components,No=i.object({config:i.object({components:i.object({button:Jr.default(ve.button),carouselMessage:Zr.default(ve.carouselMessage),chatHeader:Qr.default(ve.chatHeader),chatIcon:Xr.default(ve.chatIcon),handover:i.object().when("...globalConfig.handoverEnabled",{is:!0,then:lo,otherwise:i.any()}),messageList:co.default(ve.messageList),textMessage:uo.default(ve.textMessage),buttonMessage:Yr.default(ve.buttonMessage),userConsent:go.default(ve.userConsent),userInput:ho.default(ve.userInput),welcomeMenu:fo,launcher:bo.default(ve.launcher),triggerMessage:Ro.default(ve.triggerMessage)}).default(ve),globalConfig:mo.default(z.config.globalConfig),network:Po.optional().allow(null),id:i.string().pattern(new RegExp("[0-7][0-9A-HJKMNP-TV-Z]{25}")).allow(_t).required(),currentVersion:i.string().pattern(new RegExp("[0-7][0-9A-HJKMNP-TV-Z]{25}")).allow(_t).required()}).default(z.config)}),qe=i.object({id:i.string().required(),timestamp:i.date().required(),type:i.string().required(),sender:i.string().valid("envolve_chatbot_api","language_studio","convert","chatbot").required(),eventId:i.string().required()}),zt=qe.keys({type:i.string().valid("textMessage").required(),payload:i.string().required()}),Wt=qe.keys({type:i.string().valid("buttonMessage").required(),sender:i.string().valid("envolve_chatbot_api","language_studio","convert","chatbot").required(),payload:i.object({content:i.string().required(),url:i.alternatives().try(i.string(),i.object()).required()}).required()}),Do=i.object({type:i.string().valid("carouselMessageItem").required(),imageURL:i.string(),title:i.string().required(),buttonTitle:i.string().required(),buttonURL:i.string()}),Vt=qe.keys({type:i.string().valid("carouselMessage").required(),sender:i.string().valid("convert","envolve_chatbot_api").required(),payload:i.array().items(Do).required()}),Kt=qe.keys({type:i.string().valid("welcomeMenu").required(),payload:i.any().valid(null).required()}),Jt=qe.keys({type:i.string().valid("handoverMessage").required(),payload:i.any().valid(null).default(null)}),Yt=qe.keys({type:i.string().valid("formMessage").required(),sent:i.bool(),payload:i.object({fullName:i.string().allow(""),email:i.string().allow(""),query:i.string().allow("")}).required()}),Go=qe.keys({type:i.string().valid("revealButtonMessage").required(),sender:i.string().valid("chatbot").required(),payload:i.object({message:i.alternatives().try(zt,Wt,Vt,Kt,Jt,Yt).required(),event_type:i.object({click:i.number(),message:i.number()})}).required()}),qo=qe.keys({type:i.string().valid("copyTextButtonMessage").required(),sender:i.string().valid("chatbot").required(),payload:i.object({message:i.alternatives().try(zt,Wt,Vt,Kt,Jt,Yt).required(),event_type:i.object({click:i.number(),message:i.number()})}).required()}),Ho=i.alternatives().try(zt,Wt,Vt,Kt,Jt,Yt,Go,qo),jo=i.string().valid("SUCCESS","ERROR"),$o=i.string().valid("live"),zo=i.object({error:i.string()}),Wo=i.object({loc:i.array().ordered(i.string(),i.number()),msg:i.string(),type:i.string()}),Vo=i.object({error:i.array().items(Wo),body:i.string()}),Ko=No.append({status:$o,enabled:i.boolean()}),Jo=i.object({messages:i.array().items(Ho)}),Zt=i.alternatives().try(zo,Vo),Yo=i.alternatives().try(Ko,Zt),Zo=i.alternatives().try(Jo,Zt),Qt=i.object({status:jo,message:i.string()}),_n=Qt.append({data:Yo}),Qo=Qt.append({data:Zo}),Xo=Qt.append({data:Zt.optional()}),Rn=Ge("api",()=>{const e=()=>`${r.backendUrl}${Ve.CONFIG}/${r.siteKey}?origin_bot=true`,r=_e(),o=async(c,f)=>r.backendUrl?await nt.post(c,f).catch(_=>(console.error(`There was a problem connecting to ${c}`),console.error(_),null)):null,l=async(c,f,_)=>{if(!r.backendUrl||!r.siteKey)return null;const m=new URL(e());c&&m.searchParams.append("co",c),f&&m.searchParams.append("cov",f),_&&m.searchParams.append("covt",_),m.searchParams.append("device_type",r.deviceType);const T=await fetch(m.toString(),{method:"GET",headers:{"Content-Type":"application/json"}});return T.ok?await T.json():null},u=de();return{getConfig:l,getMessageResponse:async(c,f=!1)=>{const _=Ht(),m={payload:c,deviceMetadata:{},chatbotUlid:r.siteKey,chatbotConfigUlid:u.state.config.id,userId:r.userId,sessionId:_.sessionId},T=await o(`${r.backendUrl}${Ve.MESSAGES}${f?"?recommendations_only=true":""}`,m);if(!T)return T;const M=Qo.validate(T.data);return M.error||!M.value?(console.error("validation error on message response"),console.error(M),null):M.value},sendEmailHandover:async c=>{const f={payload:c,deviceMetadata:{},chatbotUlid:r.siteKey,chatbotConfigUlid:u.state.config.id},_=await o(`${r.backendUrl}${Ve.EMAILS}`,f);if(!_)return _;const m=Xo.validate(_.data);return m.error||!m.value?(console.error("validation error on email response"),console.error(m.error),null):m.value}}});var Fn=(e=>(e.success="SUCCESS",e.error="ERROR",e))(Fn||{});const ei=e=>e?.config!==void 0,ti=e=>e.data!==void 0,Qe=ue(),fn=e=>{const{error:r,value:o}=_n.validate(e,{stripUnknown:!0,abortEarly:!1});return r?(Qe.value.debug("Failed to obtain config"),Qe.value.debug(r),null):ei(o.data)?o.data:(Qe.value.debug("Data is not ConfigResponse"),Qe.value.debug("Note: ignore errors related to unexpected extra fields"),Qe.value.debug(_n.validate(e,{stripUnknown:!1,abortEarly:!1})),null)},ni=Ge("timer",()=>{const e=ue(),r=de(),o=_e(),l=De(ae.TRIGGER_TIMEOUT,0,{onError:I=>{Oe(ae.TRIGGER_TIMEOUT,I)}}),u=R(()=>{}),g=R(()=>{}),h=R(!1),c=R(()=>{}),f=R(()=>{}),_=R(!1),m=R(()=>{}),T=R(()=>{}),M=R(!1),w=R(()=>{}),N=R(()=>{}),B=R(!1),G=R(()=>{}),O=R(()=>{}),q=R(!1),D=R(()=>{}),V=R(()=>{}),b=R(!1),x=R(!1),E=R(!1),Y=(I=.1)=>{e.value.debug(`Creating initialLauncherDelayTimer with delay of ${I} seconds. This timer will be initialised in a stopped state.`);const H=Re(()=>{o.resetStylesAtRoot(),e.value.debug("initialLauncherDelayTimer finished"),o.launcherVisible=!0},I*1e3,{immediate:!1});u.value=()=>{e.value.debug("initialLauncherDelayTimer started."),H.start()},g.value=()=>{e.value.debug("initialLauncherDelayTimer stopped."),H.stop()},He(()=>{h.value=H.isPending.value})},ne=(I,H,oe,K,k=.1)=>{e.value.debug(`Creating delayTimer with delay of ${I} seconds. This timer will be initialised in a stopped state.`),e.value.debug(`Creating durationTimer with duration of ${H} seconds. This timer will be initialised in a stopped state.`),e.value.debug(`Creating timeoutTimer with timeout of ${oe} seconds. This timer will be initialised in a stopped state.`),e.value.debug(`Creating continuedTimeoutTimer with continuedTimeout of ${K} seconds. This timer will be initialised in a stopped state.`),e.value.debug(`Creating initialDelayTimer with initialDelay of ${k} seconds. This timer will be initialised in a stopped state.`);const C=Re(()=>{e.value.debug("initialDelayTimer finished"),o.triggerMessageVisible=!0,S(p.trigger_shown_delay)},k*1e3,{immediate:!1});c.value=()=>{e.value.debug("initialDelayTimer started."),C.start()},f.value=()=>{e.value.debug("initialDelayTimer stopped."),C.stop()},He(()=>{_.value=C.isPending.value});const X=Re(()=>{e.value.debug("delayTimer finished"),o.triggerMessageVisible=!0,r.triggerMessageConfig.delay.hasInactivityDelay?S(p.trigger_shown_inactivity_delay):S(p.trigger_shown_delay)},I*1e3,{immediate:!1});m.value=()=>{e.value.debug("delayTimer started."),X.start()},T.value=()=>{e.value.debug("delayTimer stopped."),X.stop()},He(()=>{M.value=X.isPending.value});const me=Re(()=>{o.triggerMessageVisible=!1,e.value.debug("durationTimer finished")},H*1e3,{immediate:!1});w.value=()=>{e.value.debug("durationTimer started."),me.start()},N.value=()=>{e.value.debug("durationTimer stopped."),me.stop()},He(()=>{B.value=me.isPending.value});const xe=Re(()=>{e.value.debug("timeoutTimer finished"),o.postRevealData.contents=null,o.chatWindowOpen?x.value=!0:o.triggerMessageVisible=!0,S(p.trigger_shown_timeout)},oe*1e3,{immediate:!1}),L=Re(()=>{e.value.debug("continuedTimeoutTimer finished"),o.chatWindowOpen?x.value=!0:o.triggerMessageVisible=!0,S(p.trigger_shown_timeout)},K*1e3,{immediate:!1});G.value=()=>{e.value.debug("timeoutTimer started."),xe.start(),l.value=Date.now()+oe*1e3},O.value=()=>{e.value.debug("timeoutTimer stopped"),xe.stop(),l.value=0},He(()=>{q.value=xe.isPending.value}),D.value=()=>{e.value.debug("continuedTimeoutTimer started"),L.start(),l.value=Date.now()+K*1e3},V.value=()=>{e.value.debug("continuedTimeoutTimer stopped."),L.stop(),l.value=0},He(()=>{b.value=L.isPending.value})},j=()=>{e.value.debug("Stopping delay and duration trigger timers"),f.value(),T.value(),N.value()},fe=()=>{e.value.debug("Stopping timeout trigger timers"),O.value(),V.value()};Te(()=>o.chatWindowOpen,I=>{I&&(e.value.debug("The chat window is open."),j()),!I&&x.value&&(o.triggerMessageVisible=!0,x.value=!1)}),Te(()=>o.triggerMessageVisible,I=>{I&&r.state.config.components.triggerMessage.duration.enabled&&(e.value.debug("starting duration timer"),w.value()),!I&&r.state.config.components.triggerMessage.enabled&&r.state.config.components.triggerMessage.timeout.enabled&&l.value===0&&(e.value.debug("Trigger message is hidden"),e.value.debug("starting timeout timer"),G.value()),Date.now()>=l.value&&fe()}),Te(()=>o.postRevealTriggerTimerCheck,I=>{I&&r.state.config.components.triggerMessage.duration.enabled&&(j(),e.value.debug("starting duration timer"),w.value())});const ke=R(!1),Ie=()=>{const I=Date.now(){if(E.value||o.triggerMessageVisible||o.chatWindowOpen)return;const I=Re(()=>{Ie()},500,{immediate:!0});He(()=>{E.value=I.isPending.value})};return{createTriggerTimers:ne,createInitialLauncherDelayTimer:Y,startInitialLauncherDelayTimer:u,stopInitialLauncherDelayTimer:g,startInitialDelayTimer:c,stopInitialDelayTimer:f,startDelayTimer:m,stopDelayTimer:T,startDurationTimer:w,stopDurationTimer:N,startTimeoutTimer:G,stopTimeoutTimer:O,startContinuedTimeoutTimer:D,stopContinuedTimeoutTimer:V,initialLauncherDelayTimerPending:h,initialDelayTimerPending:_,delayTimerPending:M,durationTimerPending:B,timeoutTimerPending:q,continuedTimeoutTimerPending:b,timeoutEndTime:l,liveChatOverlayActive:ke,stopDelayAndDurationTimers:j,stopTimeoutTimers:fe,openTriggerPending:x,addEventListeners:()=>{on.forEach(I=>{window.addEventListener(I,ge)})},removeEventListeners:()=>{on.forEach(I=>{window.removeEventListener(I,ge)})},resetDelayTimerDebounced:ge,resetDelayPending:E}}),de=Ge("config",()=>{const e=Gn(z),r=ue(),o=Rn(),l=ni(),u=_e(),g=async(I=null,H=null,oe=null)=>{let K;try{const C=await o.getConfig(I,H,oe);if(I!==null&&C.status!==Fn.success){console.error(`Unable to retrieve config with specified id ${I}`);return}K=fn(C)}catch(C){r.value.error(`Error in Validation: ${C}`)}if(!K){r.value.error("Failed Validation"),S(p.chatbot_config_not_retrieved);return}K?.config?.components?.welcomeMenu?.items.sort((C,X)=>C.position-X.position);const k={config:{components:K.config.components,globalConfig:K.config.globalConfig,network:K.config.network,currentVersion:K.config.currentVersion,id:K.config.id}};Object.assign(e,k),S(p.chatbot_config_retrieved),K.config.globalConfig.relativeChatWindowHeightEnabled&&(u.chatWindowShouldBeMaxHeight=!1),r.value.debug("Setting Application Ready"),Pr(!0,e.config.globalConfig.blacklistedPaths),yt()&&(r.value.debug("Application Ready"),l.createInitialLauncherDelayTimer(),l.startInitialLauncherDelayTimer(),e.config.components.triggerMessage.enabled&&c())},h=I=>{const H=fn(I);if(!H)return;const oe={config:{components:H.config.components,globalConfig:H.config.globalConfig}};Object.assign(e,oe)},c=()=>{let I=!1,H;const oe=Date.now();return oee.config.components.userInput),_=F(()=>e.config.components.chatHeader),m=F(()=>e.config.components.userConsent),T=F(()=>e.config.globalConfig),M=F(()=>e.config.components.welcomeMenu?.items),w=I=>F(()=>{const H=e.config.components.button.contexts[I];if(!H&&(I==="systemOverlayPrimary"||I==="systemOverlaySecondary"))return e.config.components.button.contexts.userConsent;if(!H)throw new Error(`Button config for context ${I} is missing`);return H}),N=I=>I==="rounded"?"1em":"0em",B=I=>F(()=>{const H=w(I);return N(H.value.buttonStyle)}),G=F(()=>({backgroundColour:e.config.components.button.hoverBackgroundColour,borderColour:e.config.components.button.hoverBorderColour,fontColour:e.config.components.button.hoverFontColour})),O=F(()=>e.config.components.textMessage),q=I=>I.enabled?`${I.offsetX} ${I.offsetY} ${I.blurRadius} ${I.color}`:"none",D=F(()=>q(e.config.globalConfig.boxShadow)),V=F(()=>e.config.components.launcher),b=F(()=>e.config.components.handover),x=F(()=>e.config.components.welcomeMenu),E=F(()=>e.config.components.carouselMessage),Y=F(()=>e.config.components.buttonMessage),ne=F(()=>e.config.components.messageList),j=F(()=>e.config.components.triggerMessage),fe=F(()=>e.config.components.chatIcon),ke=F(()=>e.config.network),Ie=F(()=>{const I=e.config.globalConfig.fontSize;return u.deviceType==="mobile"&&I<12?"12pt":`${I}pt`}),ge=F(()=>e.config.globalConfig.relativeChatWindowHeight),Ae=F(()=>e.config.globalConfig.relativeChatWindowHeightEnabled),Be=F(()=>e.config.globalConfig.relativeChatWindowHeight);return{state:e,chatHeaderConfig:_,userInputConfig:f,globalConfig:T,welcomeMenuItems:M,updateConfig:g,returnConfig:h,userConsentConfig:m,launcherConfig:V,getButtonConfig:w,getButtonRadius:B,messageConfig:O,boxShadow:D,handoverConfig:b,welcomeMenuConfig:x,messageListConfig:ne,triggerMessageConfig:j,chatIconConfig:fe,globalHoverConfig:G,network:ke,createTriggerTimers:c,fontSizeWithUnit:Ie,generateBoxShadowString:q,calculateButtonRadius:N,mobileChatWindowHeight:ge,relativeMobileHeightEnabled:Ae,relativeChatWindowHeight:Be,carouselMessageConfig:E,buttonMessageConfig:Y}}),ri="modulepreload",oi=function(e){return"/"+e},mn={},ma=function(r,o,l){if(!o||o.length===0)return r();const u=document.getElementsByTagName("link");return Promise.all(o.map(g=>{if(g=oi(g),g in mn)return;mn[g]=!0;const h=g.endsWith(".css"),c=h?'[rel="stylesheet"]':"";if(!!l)for(let m=u.length-1;m>=0;m--){const T=u[m];if(T.href===g&&(!h||T.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${g}"]${c}`))return;const _=document.createElement("link");if(_.rel=h?"stylesheet":ri,h||(_.as="script",_.crossOrigin=""),_.href=g,document.head.appendChild(_),h)return new Promise((m,T)=>{_.addEventListener("load",m),_.addEventListener("error",()=>T(new Error(`Unable to preload CSS for ${g}`)))})})).then(()=>r()).catch(g=>{const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=g,window.dispatchEvent(h),!h.defaultPrevented)throw g})},ii=e=>{const r=de(),l=_e().isMobileOnly,u=r.launcherConfig.notifier.enabled;let g;return l&&u?g="3pt":l?g="0pt":g=e,g},pa={launcher:{width:"auto",minWidth:"3.28125em",minHeight:"3.28125em",height:"3.28125em"},launcherIcon:{width:"2em",minWidth:"2em",minHeight:"2em",height:"2em"},launcherCloseIcon:{width:"1em",minWidth:"1em",minHeight:"1em",height:"1em"}},va={launcher:{width:"7.65625em",minWidth:"7.65625em",minHeight:"2.73437em",height:"2.5625em"},launcherIcon:{width:"2em",minWidth:"2em",minHeight:"2em",height:"2em"},launcherCloseIcon:{width:"1em",minWidth:"1em",minHeight:"1em",height:"1em"}},wa=(e,r,o,l)=>{const u=ii(e),g={left:"none",top:"none",bottom:`${r}`,right:`${u}`},h={left:`${u}`,top:"none",bottom:`${r}`,right:"none"},c=l==="rectangle"?{left:"none",top:"none",bottom:`calc(45% + ${r})`,right:`${u}`}:{left:"none",top:"none",bottom:`calc(50% + ${r})`,right:`${u}`},f=l==="rectangle"?{left:`${u}`,top:"none",bottom:`calc(60% + ${r})`,right:"none"}:{left:`${u}`,top:"none",bottom:`calc(50% + ${r})`,right:"none"},_={bottomRight:g,bottomLeft:h,middleRight:c,middleLeft:f};return _[o]||_.bottomRight};function ya(){const e=de();return F(()=>e.launcherConfig.position.toLocaleLowerCase().includes("left"))}function ba(){const e=de();return F(()=>e.launcherConfig.position.includes("middle"))}const Ta=(e,r,o)=>!(parseInt(e)<3&&(r==="middleLeft"&&o==="rectangle"||r==="middleRight"||r==="bottomRight")),ai=e=>{const r=e.split("@"),o=r[0],l=r[1].split(".");return pn(o)+"@"+l.map(g=>pn(g)).join(".")},pn=e=>{const r=(o,l)=>{const h="•";return l||(l=0),o.length==1?l>=4?o:h:l==0&&o.length>=8?r(o.slice(0,-1),l+1)+o.slice(-1):r(o.slice(0,-1),l+1)+h};return r(e)},Se=(e,r)=>{const o={...e,id:he(),timestamp:new Date,eventId:r};return e.type==="formMessage"&&(o.sent=!1,o.timeSent=new Date),o},si=Se({type:"welcomeMessage",sender:"chatbot",payload:null},"01J4RSCMBD8CYC4FTBQ57ND4M5"),li=Se({type:"textMessage",sender:"language_studio",payload:"I'm sorry I don't know the answer to that. Please click the button below to get some help with your issue."},"01J4RSCMBD8CYC4FTBQ57ND4M5"),ci=Se({type:"buttonMessage",sender:"language_studio",payload:{content:"Click here",url:new URL("https://www.google.com")}},"01J4RSCMBD8CYC4FTBQ57ND4M5"),ui=Se({type:"carouselMessage",sender:"convert",payload:[{type:"carouselMessageItem",imageURL:new URL("https://picsum.photos/id/237/200/300"),title:"Example Item 1",buttonTitle:"Learn more",buttonURL:new URL("https://www.google.com")},{type:"carouselMessageItem",imageURL:new URL("https://picsum.photos/id/9/200/300"),title:"Example Item 2",buttonTitle:"Learn more",buttonURL:new URL("https://www.google.com")},{type:"carouselMessageItem",imageURL:new URL("https://picsum.photos/id/135/200/300"),title:"Example Item 3",buttonTitle:"Learn more",buttonURL:new URL("https://www.google.com")}]},"01J4RSCMBD8CYC4FTBQ57ND4M5"),di=Se({type:"welcomeMenu",sender:"chatbot",payload:null},"01J4RSCMBD8CYC4FTBQ57ND4M5"),gi=Se({type:"formMessage",sender:"convert",payload:{fullName:"John Doe",email:"john.doe@example.com",query:"How can I get support?"}},"01J4RSCMBD8CYC4FTBQ57ND4M5");Se({type:"revealButtonMessage",sender:"chatbot",payload:{message:{type:"textMessage",id:"01J4RSCMBD8CYC4FTBQ57ND4M5",timestamp:new Date,payload:"Hello!",sender:"chatbot"},event_type:{click:p.welcome_menu_reveal_text_button_click,message:p.chatbot_message_reveal_text_post_prompt_shown}}},"01J4RSCMBD8CYC4FTBQ57ND4M5");Se({type:"copyTextButtonMessage",sender:"chatbot",payload:{content:"offer15"}},"01J4RSCMBD8CYC4FTBQ57ND4M5");const hi=[si,di,li,ci,gi,ui],_i=ue(),fi=(e,r,o)=>{e?S(e,r.eventId):console.error(`Message logging attempted with no event. Message: ${JSON.stringify(r)}`),mi(r,r.eventId,o)},mi=(e,r,o)=>{if(e.type==="loadingMessage")return;const l=new Date,u={e_i:r,m_i:e.id,m_p:JSON.stringify(e),m_s:e.sender,m_t:e.type,s_m_i:o??null,c_t:l.toISOString(),t_o:l.getTimezoneOffset()};_i.value.debug(u);const g=bt(u);nt.post(`https://envolve-logging-dot-envolvetech-001.nw.r.appspot.com/${Ve.MESSAGE_LOGGING}`,g,{headers:{"Content-Type":"text/plain"}}).catch(()=>{console.error(`Error occurred attempting to send message ${e.id}`)})},pi=Ge("messages",()=>{const e=Rn(),r=de(),o={}.VITE_DEMO_MODE==="true"?hi:[],l=De(ae.MESSAGES,o,{onError:b=>{Oe(ae.MESSAGES,b)}}),u=R(!1),g=b=>({type:"textMessage",id:he(),payload:r.globalConfig.badResponse,sender:"chatbot",timestamp:new Date,eventId:b}),h=(b,x=!1)=>{if(!r.state.config.components.handover||r.state.config.components.handover.activeType==="none"){w(p.chatbot_message_generic_error_text_shown,g(le()));return}switch(b||(b={id:"BBBBBBBBBBBBBBBBBBBBBBBBBB",type:"buttonMessage",sender:"chatbot",timestamp:new Date,payload:{content:"REPLACE THIS",url:new URL("http://www.needtoreplacethis.co.uk")},eventId:le()}),x?r.handoverConfig?.handoverOptions.liveChat.backupHandoverType:r.handoverConfig?.activeType){case"email":w(p.chatbot_message_email_button_shown,{type:"revealButtonMessage",id:b.id,sender:b.sender,timestamp:b.timestamp,eventId:b.eventId,payload:{message:{id:he(),sender:b.sender,type:"formMessage",sent:!1,timestamp:new Date,timeSent:new Date,payload:{email:"",fullName:"",query:""}},event_type:hr.email}});break;case"redirect":w(p.chatbot_message_redirect_handover_shown,{type:"buttonMessage",payload:{url:new URL(r.state.config.components.handover.handoverOptions.redirect.url),content:r.state.config.components.handover.handoverOptions.redirect.buttonTitle},sender:b.sender,id:b.id,timestamp:b.timestamp,eventId:b.eventId,isHandover:!0,handoverType:"redirect",behaviour:r.state.config.components.handover.handoverOptions.redirect.windowOpenTarget});break;case"liveChatRedirect":w(p.chatbot_message_live_chat_redirect_handover_shown,{type:"buttonMessage",payload:{url:new URL(r.state.config.components.handover.handoverOptions.liveChatRedirect.url),content:r.state.config.components.handover.handoverOptions.liveChatRedirect.buttonTitle},sender:b.sender,id:b.id,timestamp:b.timestamp,eventId:b.eventId,isHandover:!0,handoverType:"liveChatRedirect",behaviour:r.state.config.components.handover.handoverOptions.liveChatRedirect.windowOpenTarget});break;case"liveChat":w(p.chatbot_message_live_chat_handover_button_shown,{type:"liveChatButtonMessage",payload:{content:r.state.config.components.handover.handoverOptions.liveChat.buttonTitle,clicked:!1},sender:b.sender,id:b.id,timestamp:b.timestamp,eventId:b.eventId});break;case"iframe":case"zendesk":default:w(p.chatbot_message_generic_error_text_shown,g(b.eventId))}},c=(b,x,E=!1,Y=null)=>{if(!r.state.config.components.handover||!r.state.config.globalConfig.handoverEnabled||r.state.config.components.handover.activeType==="none"){w(p.chatbot_message_generic_error_text_shown,{type:"textMessage",id:b.id,payload:r.globalConfig.badResponse,sender:b.sender,timestamp:new Date,eventId:b.eventId});return}const ne=le();let j=cr;E?(j=r.handoverConfig?.handoverOptions?.liveChat?.backupHandoverPrePrompt??j,Y&&(j=`${Y} ${j}`)):j=r.state.config.components.handover.prePrompt;const fe={type:"textMessage",sender:b.sender,id:he(),timestamp:new Date,eventId:ne,payload:j};w(p.chatbot_message_handover_preamble_shown,fe,x),h(b,E)},f=b=>{if(b.type==="carouselMessage"&&r.state.config.components.carouselMessage.preambleTextEnabled){const x={type:"textMessage",payload:r.state.config.components.carouselMessage.preambleText,sender:b.sender};w(p.chatbot_message_carousel_preamble_shown,Se(x,le()))}},_=async(b,x)=>{const E=R(G(b));if(E.value?.type!=="formMessage"){console.log("not a form message!"),console.log(E.value?.type);return}const Y={...E.value};Y.payload={email:x.email,fullName:x.fullName,query:x.query},e.sendEmailHandover({...Y}),E.value.payload.email=ai(x.email),E.value.payload.fullName="***",E.value.payload.query=x.query,E.value.sent=!0,E.value.timeSent=new Date},m=(b,x,E)=>{const Y=Se(x,E);return w(b,Y),Y},T=async b=>{const x=le(),E=m(p.user_message_text_message_shown,b,x);E.type==="textMessage"&&await B(E)},M=async(b,x)=>{m(b,x,le())},w=async(b,x,E)=>{fi(b,x,E),l.value.push(x)},N=async(b,x)=>{const E=e.getMessageResponse(b,x),Y=new Promise(j=>setTimeout(j.bind(void 0,"messsage timeout"),rn));return(await Promise.all([E,Y]))[0]},B=async(b,x=!1)=>{u.value=!0;const E=await N(b,x);if(u.value=!1,E){if(!ti(E)){console.error("Malformed Message Response"),w(p.chatbot_message_generic_error_text_shown,g(le()),b.id);return}const Y=E.data.messages;for(const ne of Y){f(ne);let j;switch(ne.type){case"textMessage":j=p.chatbot_message_text_shown;break;case"buttonMessage":j=p.chatbot_message_redirect_button_shown;break;case"carouselMessage":j=p.chatbot_message_carousel_shown;break;case"formMessage":j=p.chatbot_message_email_form_shown;break;case"copyTextButtonMessage":j=p.chatbot_message_copy_text_button_shown;break;case"handoverMessage":c(ne,b.id);return}if(!j){console.error(`Unexpected message recieved from API, no associated event. Message: ${ne}`);return}w(j,ne,b.id)}}else console.error("Error retrieving message response"),w(p.chatbot_message_generic_error_text_shown,g(le()),b.id)},G=b=>l.value.find(x=>x.id===b),O=b=>{l.value.find(x=>x.id===b).payload.clicked=!0},q=async(b,x)=>{const E={payload:b.join(),id:he(),timestamp:new Date,eventId:x,sender:"chatbot",type:"recommendationRequest"};await B(E,!0)};return Te(u,(b,x)=>{u.value?S(p.loading_message_appears):x===!0&&S(p.loading_message_disappears)}),{awaitingMessage:u,messages:l,handleNewUserMessage:T,addMessage:w,sendMessage:B,getMessageById:G,createMessage:Se,handleHandoverResponse:c,getRecommendations:q,handleFormSubmission:_,MESSAGE_DELAY:rn,getHandoverMessage:h,addHandoverMessages:(b=!1,x=null)=>{const E={type:"handoverMessage",id:he(),sender:"chatbot",timestamp:new Date,payload:null};c(E,void 0,b,x)},handleNewSystemMessage:M,markLiveChatButtonAsClicked:O,initialiseWelcomeMessages:()=>{if(l.value.length==0){if(r.welcomeMenuConfig&&r.welcomeMenuConfig.welcomeMessage){const b={type:"welcomeMessage",sender:"chatbot",payload:null};m(p.welcome_message_shown,b,le())}if(r.welcomeMenuItems&&r.welcomeMenuItems.length>0){const b={type:"welcomeMenu",sender:"chatbot",payload:null};m(p.welcome_menu_shown,b,le())}}}}});var ee=(e=>(e.showCustomElement="envolve-show-custom-element",e.hideCustomElement="envolve-hide-custom-element",e.openCustomElement="envolve-open-custom-element",e.closeCustomElement="envolve-close-custom-element",e.startLiveChat="envolve-start-live-chat",e.endLiveChat="envolve-end-live-chat",e))(ee||{});const vi=(e,r)=>{const o=R(null);let l=0,u=null;const g=1e3,h=6e5,c=()=>{o.value||(o.value=setInterval(()=>{window.Tawk_API.isVisitorEngaged()?(u===!1&&(l=0),u=!0):(l+=g,l>=h?(f(),r()):u===!0&&(u=!1,f(),e()))},g))},f=()=>{o.value&&(clearInterval(o.value),o.value=null,l=0)};return qn(()=>{f()}),{startTawkToPolling:c,stopTawkToPolling:f}},rt=Ge("liveChat",()=>{const e=ue(),r=pi(),o=de(),l=_e(),u=F(()=>o.handoverConfig?.handoverOptions.liveChat.provider),g=Hn(nn.LIVE_CHAT_SESSION_ID,null,{onError:k=>{Oe(nn.LIVE_CHAT_SESSION_ID,k,"session")}}),h=F(()=>o.handoverConfig?.handoverOptions.liveChat.showLiveChatProviderAndChatbot),c=()=>{K(`Invalid live chat config. Provider: ${u.value}, Integration Type: ${o.handoverConfig?.handoverOptions.liveChat.integrationType}`,"Live Chat cancelled",p.system_message_live_chat_cancelled_shown),S(p.live_chat_handover_provider_not_shown)},f=()=>{let k=!1;if(w()){console.error("Live Chat session already in progress"),S(p.live_chat_handover_session_already_active);const C=r.createMessage({type:"textMessage",sender:"chatbot",payload:"A Live Chat session is already in progress. Please close the window and try again."},le());r.addMessage(p.chatbot_message_live_chat_session_already_active_shown,C)}else{g.value=he(),e.value.debug("Started live chat session");const C={payload:"Live Chat began",sender:"system",type:"systemMessage"};r.handleNewSystemMessage(p.system_message_live_chat_started_shown,C),u.value&&u.value in an?(S(an[u.value]),window.dispatchEvent(new Event(ee.hideCustomElement)),window.dispatchEvent(new Event(ee.startLiveChat)),S(p.live_chat_handover_chatbot_hidden),k=!0):c()}return k},_=(k=null)=>{S(p.backup_handover_requested),r.addHandoverMessages(!0,k)},m=()=>{S(p.live_chat_handover_provider_outside_business_hours),S(p.live_chat_handover_provider_not_shown);const k={payload:"Live Chat cancelled",sender:"system",type:"systemMessage"};r.handleNewSystemMessage(p.system_message_live_chat_cancelled_shown,k);const C="Our Live Chat Service is currently offline";if(o.handoverConfig?.handoverOptions.liveChat.backupHandoverEnabled)_(C);else{const X={type:"textMessage",sender:"chatbot",id:he(),timestamp:new Date,eventId:le(),payload:C};r.addMessage(p.chatbot_message_live_chat_out_of_hours_message_shown,X)}},T=()=>{S(p.live_chat_handover_provider_not_shown);const k={payload:"Live Chat cancelled",sender:"system",type:"systemMessage"};if(r.handleNewSystemMessage(p.system_message_live_chat_cancelled_shown,k),o.handoverConfig?.handoverOptions.liveChat.backupHandoverEnabled)_();else{const C=le(),X=r.createMessage({type:"textMessage",sender:"chatbot",payload:"Our Live Chat Service is currently offline, please try again later."},C);r.addMessage(p.chatbot_message_live_chat_offline_message_shown,X)}},M=()=>{const k=o.handoverConfig?.handoverOptions?.liveChat?.postHandover??xn,C={type:"textMessage",sender:"chatbot",id:he(),timestamp:new Date,eventId:le(),payload:k};r.addMessage(p.chatbot_message_handover_post_prompt_shown,C)},w=()=>g.value!==null,N=()=>{if(!w())throw S(p.live_chat_handover_no_session_available),new Error("No Live Chat session in progress")},B=()=>{e.value.debug("Ended live chat session");const k={payload:"Live Chat ended",sender:"system",type:"systemMessage"};r.handleNewSystemMessage(p.system_message_live_chat_ended_shown,k),window.dispatchEvent(new Event(ee.showCustomElement)),window.dispatchEvent(new Event(ee.endLiveChat)),S(p.live_chat_handover_chatbot_shown),M(),g.value=null},G=()=>{N(),B()},O=()=>{l.liveChatOverlayActive||(l.liveChatOverlayActive=!0,window.dispatchEvent(new Event(ee.showCustomElement)),l.chatWindowOpen=!0)},q=()=>{window.GorgiasChat?window.GorgiasChat.isBusinessHours()?f()&&(window.GorgiasChat.hideChat(!1),window.GorgiasChat.open(),S(p.live_chat_handover_provider_shown)):m():(S(p.live_chat_handover_missing_gorgias_widget),T())},D=k=>{window.zE?f()&&(window.zE(k,"show"),window.zE(k,"open"),S(p.live_chat_handover_provider_shown)):(S(p.live_chat_handover_missing_zendesk_widget),T())},V=()=>{window.Tawk_API.minimize(),window.Tawk_API.hideWidget(),S(p.live_chat_handover_provider_hidden)},b=()=>{N(),V(),B()},x=()=>{V(),O()},{startTawkToPolling:E,stopTawkToPolling:Y}=vi(b,x),ne=()=>{b(),Y()},j=()=>{!window.Tawk_API||!window.Tawk_API.isVisitorEngaged||!window.$_Tawk||!window.$_Tawk.connected?(S(p.live_chat_handover_missing_tawk_to_widget),T()):window.Tawk_API.getStatus()==="offline"?m():f()&&(window.Tawk_API.showWidget(),window.Tawk_API.maximize(),S(p.live_chat_handover_provider_shown),E())},fe=()=>{switch(u.value){case"Custom API Integration":f();break;case"Gorgias":q();break;case"Zendesk":D("messenger");break;case"Zendesk (Classic)":D("webWidget");break;case"Tawk.to":j();break;default:c();break}},ke=()=>{if(l.liveChatOverlayActive=!1,!w()){K("Invalid live chat session ID.","Live Chat cancelled",p.system_message_live_chat_cancelled_shown);return}const k=()=>{window.dispatchEvent(new Event(ee.hideCustomElement)),S(p.live_chat_handover_chatbot_hidden)},X={Gorgias:()=>{window.GorgiasChat.isBusinessHours()?(k(),window.GorgiasChat.hideChat(!1),window.GorgiasChat.open(),S(p.live_chat_handover_provider_shown)):m()},Zendesk:()=>{k(),window.zE("messenger","show"),window.zE("messenger","open"),S(p.live_chat_handover_provider_shown)},"Zendesk (Classic)":()=>{k(),window.zE("webWidget","show"),window.zE("webWidget","open"),S(p.live_chat_handover_provider_shown)},"Tawk.to":()=>{window.Tawk_API.getStatus()==="offline"?m():(k(),window.Tawk_API.showWidget(),window.Tawk_API.maximize(),S(p.live_chat_handover_provider_shown),E())}}[u.value??"Unknown"];X?X():K(`Unrecognised live chat provider. Provider: ${u.value}, Integration Type: ${o.handoverConfig?.handoverOptions.liveChat.integrationType}`,"Live Chat cancelled",p.system_message_live_chat_cancelled_shown)},Ie=()=>{(window.GorgiasChat?window.GorgiasChat.init():new Promise(function(C){window.addEventListener("gorgias-widget-loaded",function(){C()})})).then(function(){!h.value&&(!w()||l.liveChatOverlayActive)&&(window.GorgiasChat.hideChat(!0),S(p.live_chat_handover_provider_hidden)),window.GorgiasChat.on("disconnected",function(){I()}),window.GorgiasChat.on("widget:closed",function(){I()})})},ge=(k,C,X=1e4,me=100)=>new Promise((xe,L)=>{const $=setInterval(()=>{k()&&(clearInterval($),clearTimeout(re),xe())},me),re=setTimeout(()=>{clearInterval($),L(new Error(`${C} widget not found`))},X)}),Ae=async k=>{try{await ge(()=>window.zE,"Zendesk"),!h.value&&(!w()||l.liveChatOverlayActive)&&(window.zE(k,"hide"),S(p.live_chat_handover_provider_hidden)),window.zE(`${k}:on`,"close",function(){window.zE(k,"hide"),S(p.live_chat_handover_provider_hidden),setTimeout(function(){O()},k==="messenger"?1e3:500)})}catch{e.value.error("Missing Zendesk widget"),S(p.live_chat_handover_missing_zendesk_widget)}},Be=async()=>{try{window.Tawk_API=window.Tawk_API||{},!h.value&&(!w()||l.liveChatOverlayActive)?(window.Tawk_API.onBeforeLoad=function(){V()},V()):w()&&!l.liveChatOverlayActive&&(window.Tawk_API.getStatus()==="offline"?m():E())}catch{e.value.error("Missing Tawk.to widget"),S(p.live_chat_handover_missing_tawk_to_widget)}},I=()=>{w()&&(window.GorgiasChat.hideChat(!0),S(p.live_chat_handover_provider_hidden),O())},H=async()=>{o.handoverConfig?.handoverOptions.liveChat.integrationType==="internal"&&(u.value==="Gorgias"?Ie():u.value==="Zendesk"?await Ae("messenger"):u.value==="Zendesk (Classic)"?await Ae("webWidget"):u.value==="Tawk.to"&&await Be())},oe=()=>{if(o.handoverConfig?.activeType!=="liveChat"&&u.value!=="Custom API Integration")throw new Error(`Misconfigured live chat handover, speak to an admin: (Active: ${o.handoverConfig?.activeType}, Provider: ${u.value})`)},K=(k,C,X)=>{e.value.debug(k);const me={payload:C,sender:"system",type:"systemMessage"};r.handleNewSystemMessage(X,me),l.launcherVisible||(window.dispatchEvent(new Event(ee.showCustomElement)),S(p.live_chat_handover_chatbot_shown)),window.dispatchEvent(new Event(ee.endLiveChat)),o.handoverConfig?.handoverOptions.liveChat.backupHandoverEnabled?_():M(),g.value=null};return{startLiveChatSession:fe,endGenericLiveChatSession:B,indicateLiveChatFailure:K,verifyLiveChatInProgress:N,liveChatSessionId:g,registerLiveChatWidget:H,endLiveChatSession:G,resumeLiveChatSession:ke,verifyAPILiveChatIntegration:oe,indicateOutsideBusinessHours:m,showChatbotWithOverlay:O,endTawkToSessionFromOverlay:ne,isLiveChatInProgress:w}}),Sa=Ge("clientApi",()=>{const e=_e(),r=()=>{e.chatWindowOpen||(e.chatWindowOpen=!0,e.triggerMessageVisible=!1)},o=()=>{e.chatWindowOpen&&(e.chatWindowOpen=!1)},l=()=>{yt().value&&(e.launcherVisible=!0)};return{addEventListeners:()=>{window.addEventListener(ee.hideCustomElement,()=>e.launcherVisible=!1),window.addEventListener(ee.showCustomElement,l),window.addEventListener(ee.openCustomElement,r),window.addEventListener(ee.closeCustomElement,o)},removeEventListeners:()=>{window.removeEventListener(ee.hideCustomElement,()=>e.launcherVisible=!1),window.removeEventListener(ee.showCustomElement,l),window.removeEventListener(ee.openCustomElement,r),window.removeEventListener(ee.closeCustomElement,o)}}});function ka(e){return F(()=>e?.type==="textMessage"&&e?.sender==="user"?"message-user":(e?.type==="textMessage"||e?.type==="loadingMessage"||e?.type==="welcomeMessage")&&e?.sender!=="user"?"message-chatbot":e?.type==="buttonMessage"||e?.type==="revealButtonMessage"||e?.type==="copyTextButtonMessage"?"message-button":"")}const Ia=e=>_e().deviceType.toLowerCase()==="unknown"?e:lr,wi=(e,r,o,l,u,g)=>{const h=e.clientHeight,c=Math.floor(+getComputedStyle(e).lineHeight.replace("px","")||1),f=e?.parentElement?.parentElement?.parentElement;let _=f?.parentElement||f;_?.className.includes("swiper")&&(_=_.parentElement);let m=_?.querySelectorAll(r),T=Array.from(m).indexOf(e);if(_?.className==="message-list"){const G=e.parentElement?.parentElement?.parentElement?.className||"",O=e?.parentElement?.parentElement?.parentElement;m=[O];let q=O.previousElementSibling;for(;q&&q.className.includes(G);)m.unshift(q),q=q.previousElementSibling;let D=O.nextElementSibling;for(;D&&D.className.includes(G);)m.push(D),D=D.nextElementSibling;T=Array.from(m).indexOf(O)}const M=r.includes("img"),w=M?o:e.textContent||null,N=M?0:Math.floor(h/c);return{e_c:m.length,e_p:T,e_t:w,c_t:new Date().toISOString(),e_i:l,l_c:u,n_l:N,r_l:g}},yi=e=>{ue().value.debug(e);const o=bt(e);nt.post(`https://envolve-logging-dot-envolvetech-001.nw.r.appspot.com/${Ve.CONVERSION_CLICK_LOGGING}`,o,{headers:{"Content-Type":"text/plain"}}).catch(()=>{console.error("Error occurred attempting to send button click event")})},bi=()=>he(),Tt=({logLevel:e,logPayload:r,logType:o,logMetadata:l=null,logId:u=bi()})=>{const h={c_t:new Date().toISOString(),l_i:u,l_l:e,l_m:l?JSON.stringify(l):null,l_p:JSON.stringify(r),l_t:o};ue().value.debug(h);const f=bt(h);return nt.post(`https://envolve-logging-dot-envolvetech-001.nw.r.appspot.com/${Ve.TRANSIENT_LOGGING}`,f,{headers:{"Content-Type":"text/plain"}}).catch(()=>{console.error("Error occurred attempting to send message")}),u};var Ye=(e=>(e.AFFILIATE_TRACKING_STRIP_LINK="affiliate_tracking_strip_link",e.AFFILIATE_TRACKING_STRIP_LINK_UNSUPPORTED="affiliate_tracking_strip_link_unsupported",e.AFFILIATE_TRACKING_GENERATE_LINK="affiliate_tracking_generate_link",e.AFFILIATE_TRACKING_GENERATE_LINK_UNSUPPORTED="affiliate_tracking_generate_link_unsupported",e.AFFILIATE_TRACKING_VALID_LINK="affiliate_tracking_valid_link",e.AFFILIATE_TRACKING_INVALID_LINK="affiliate_tracking_invalid_link",e))(Ye||{});const Lt=(e,r)=>{const o=e.searchParams.get(r);return o?new URL(o):e},Ti=e=>{const r=e.toString(),o="destination:",l=r.indexOf(o);if(l!==-1){let u=r.substring(l+o.length);const g=u.indexOf("?");return g!==-1&&(u=u.substring(0,g)),new URL(decodeURIComponent(u))}return e},Si={adtraction:"url",affiliate_future:"url",avantlink:"url",awin:"ued",commission_factory:"Url",commission_factory_nz:"Url",conectia:"ckmrdr",impact:"u",linkconnector:"url",partnerize:"partnerize",pepperjam:"url",rakuten:"murl",rakuten_aus:"murl",rakuten_brz:"murl",rakuten_can:"murl",rakuten_fr:"murl",rakuten_ger:"murl",rakuten_us:"murl",shareasale:"urllink",trade_tracker:"u",webgains:"wgtarget"},vn=(e,r,o)=>{const l=o[e];if(!l)return r;if(Array.isArray(l))for(const g of l){const h=Lt(r,g);if(h!==r)return h}else if(l==="partnerize"){const g=Ti(r);if(g!==r)return g}else{const g=Lt(r,l);if(g!==r)return g}const u=Lt(r,"url");return u!==r?u:r},ki=(e,r,o)=>{let l=e,u=vn(r,l,o);for(;u.toString()!==l.toString();)l=u,u=vn(r,l,o);return l},On=(e,r,o)=>{const{affiliateIndexKey:l,name:u}=r,g=u.toLowerCase().trim(),h=e.toString(),c=l?ki(e,l,Si):e,f=c.toString(),m=de().state.config.id,M=_e().userId,w=h!==f,N=w?"info":"warn",B=w?Ye.AFFILIATE_TRACKING_STRIP_LINK:Ye.AFFILIATE_TRACKING_STRIP_LINK_UNSUPPORTED,G=w?`Stripped all tracking from url ${h}`:`Unable to strip tracking url: ${h}, affiliate: ${g}, key: ${l}`;return w||ue().value.warn(G),Tt({logLevel:N,logPayload:{networkConfigDetails:r,chatbotConfigId:m,message:G,originalUrl:h,processedUrl:f,eventId:o,userId:M},logType:B}),c},Ii=(e,r,o)=>{const l=de(),u=_e();Tt({logLevel:"error",logPayload:{networkConfigDetails:e,chatbotConfigId:l.state.config.id,message:"Misconfigured network configuration - missing networkCustomDataIdentifier",originalUrl:r.toString(),processedUrl:r.toString(),eventId:o,userId:u.userId},logType:Ye.AFFILIATE_TRACKING_GENERATE_LINK_UNSUPPORTED})},St=(e,r,o)=>{if(!o.networkCustomDataIdentifier)return Ii(o,e,r),e;e.searchParams.delete(o.networkCustomDataIdentifier);const l=Array.from(e.searchParams.entries());return l.forEach(u=>{e.searchParams.delete(u[0])}),l.unshift([o.networkCustomDataIdentifier,r.toString()]),l.forEach(u=>{e.searchParams.append(u[0],u[1])}),e},Ai=(e,r,o)=>{const l=e.toString(),u=l.indexOf("/destination");return u==-1?new URL(e+`/${o.networkCustomDataIdentifier}:${r.toString()}`):new URL(l.slice(0,u)+`/${o.networkCustomDataIdentifier}:${r.toString()}`+l.slice(u))},Un=(e,r,o)=>{const l=ue(),u=`Unable to autogenerate tracking link for ${o.name}, merchant ${o.merchantId}`;l.value.warn(u);const g=de(),h=_e();Tt({logLevel:"warn",logPayload:{networkConfigDetails:o,chatbotConfigId:g.state.config.id,message:u,originalUrl:e.toString(),processedUrl:e.toString(),eventId:r,userId:h.userId},logType:Ye.AFFILIATE_TRACKING_GENERATE_LINK_UNSUPPORTED})},xi=(e,r,o,l,u="url")=>(e.searchParams.set(l,o.toString()),e.searchParams.set(u,r.toString()),e),pe=(e,r,o,l="url")=>{const{fullTrackingLink:u,networkCustomDataIdentifier:g}=o;return u&&g?e.toString().startsWith(u)&&e.searchParams.has(l)?St(e,r,o):xi(new URL(u),e,r,g,l):(Un(e,r,o),e)},Ci=e=>e.pathname.toLowerCase().endsWith("/pclick.php")&&e.searchParams.has("p"),Li=(e,r,o)=>pe(e,r,o),Mi=(e,r,o)=>pe(e,r,o),Ei=(e,r,o)=>pe(e,r,o),Bi=(e,r,o)=>Ci(e)?St(e,r,o):pe(e,r,o,"ued"),wn=(e,r,o)=>pe(e,r,o,"Url"),Ri=(e,r,o)=>pe(e,r,o,"ckmrdr"),Fi=(e,r,o)=>pe(e,r,o,"u"),Oi=(e,r,o)=>pe(e,r,o),Ui=(e,r,o)=>{const{fullTrackingLink:l}=o;if(l){const u=new URL(l+`/destination:${encodeURIComponent(e.toString())}`);return Ai(u,r,o)}return Un(e,r,o),e},Pi=(e,r,o)=>pe(e,r,o),ze=(e,r,o)=>pe(e,r,o,"murl"),Ni=(e,r,o)=>pe(e,r,o,"urllink"),Di=(e,r,o)=>pe(e,r,o,"u"),Gi=(e,r,o)=>pe(e,r,o,"wgtarget"),qi={adtraction:Li,affiliate_future:Mi,avantlink:Ei,awin:Bi,commission_factory:wn,commission_factory_nz:wn,conectia:Ri,impact:Fi,linkconnector:Oi,partnerize:Ui,pepperjam:Pi,rakuten:ze,rakuten_aus:ze,rakuten_brz:ze,rakuten_can:ze,rakuten_fr:ze,rakuten_ger:ze,rakuten_us:ze,shareasale:Ni,trade_tracker:Di,webgains:Gi},Hi=e=>{const{affiliateIndexKey:r}=e;return r&&qi[r]||St},ji=(e,r,o)=>{const l=e.toString(),u=Hi(o),g=u(e,r,o),h=de(),c=g.toString(),f=_e();return Tt({logLevel:"info",logPayload:{networkConfigDetails:o,chatbotConfigId:h.state.config.id,message:`Generated tracking link ${c} from ${l}`,originalUrl:l,processedUrl:c,eventId:r,userId:f.userId,trackingLinkHandler:u.name},logType:Ye.AFFILIATE_TRACKING_GENERATE_LINK}),g},$i=(e,r,o)=>{const l=On(e,o,r);return ji(l,r,o)},Aa=(e,r,o,l,u="a.envolve-button",g=null,h=!0)=>{const f=de()?.network,_=zi(e,o,f,h);Object.assign(document.createElement("a"),{target:r,rel:"noopener noreferrer",href:_}).click();const m=wi(l,u,g,o,_,e);yi(m)},zi=(e,r,o,l)=>{if(!o)return e;let u=new URL(e);return!o.affiliateTrackingEnabledForNetwork||!o.affiliateTrackingEnabledForAccount?u=On(u,o,r):o.affiliateTrackingSupportedForNetwork&&o.automaticAffiliateTrackingEnabledForAccount&&l?u=$i(u,r,o):u=St(u,r,o),u.toString()};function xa(e,r){const{top:o,left:l,right:u}=e.getBoundingClientRect(),{top:g,left:h,height:c,width:f}=r.getBoundingClientRect();return o>=g&&o<=g+c&&(u>=h&&u<=h+f||l>=h&&l<=h+f)}const Ca=e=>{const r=e.clientHeight,o=Math.floor(parseInt(getComputedStyle(e).lineHeight)||1);return r>0?Math.floor(r/o):0},Wi=()=>{window.dispatchEvent(new Event(ee.showCustomElement)),S(p.chatbot_api_show_called)},Vi=()=>{window.dispatchEvent(new Event(ee.hideCustomElement)),S(p.chatbot_api_hide_called)},Ki=()=>{window.dispatchEvent(new Event(ee.openCustomElement)),S(p.chatbot_api_open_called)},Ji=()=>{window.dispatchEvent(new Event(ee.closeCustomElement)),S(p.chatbot_api_close_called)},Yi=()=>{const e=rt();e.verifyAPILiveChatIntegration(),S(p.chatbot_api_end_live_chat),e.endLiveChatSession()},Zi=e=>{const r=rt();r.verifyAPILiveChatIntegration(),r.verifyLiveChatInProgress(),S(p.chatbot_api_end_live_chat),S(p.live_chat_handover_provider_not_shown),r.indicateLiveChatFailure(e.message,"Live Chat cancelled",p.system_message_live_chat_cancelled_shown)},Qi=()=>{const e=rt();e.verifyAPILiveChatIntegration(),e.verifyLiveChatInProgress(),S(p.chatbot_api_end_live_chat),S(p.live_chat_handover_provider_no_agents),e.indicateLiveChatFailure("No live chat agents available","No Agents Available",p.system_message_live_chat_no_agents_available_shown)},Xi=()=>rt().isLiveChatInProgress(),ea=()=>{try{window.EnvolveChat={show:Wi,hide:Vi,open:Ki,close:Ji,endGenericLiveChatSession:Yi,indicateLiveChatException:Zi,indicateLiveChatNoAgentsAvailable:Qi,isLiveChatInProgress:Xi}}catch(e){throw ue().value.error("Error initializing EnvolveChatAPI: ",e),e}},yn=ue(),ta=async(e=null,r=zn())=>{{Wn(r);const T=jn($n);customElements.define("envolve-vsa",T);const M=document.createElement("envolve-vsa");M.classList.add("needsclick"),function w(){if(document.body)return document.body.appendChild(M);window.requestAnimationFrame(w)}()}ea();const o=_e(),l=de(),u=document.currentScript||document.querySelector('script#envolve-chat[data-envolve-chat-id]:not([data-envolve-chat-id=""])');u||yn.value.warn('Unable to retrieve script via `currentScript` or CSS selector. Review the script format and check for the existance of the `data-enolve-chat-id` attribute and id="envolve-chat". The rest of the app initialisation will rely on the existance of the `envolve_vsa_id` query parameter in the URL.');const g=new URL(window.location.href),h=u?.getAttribute("data-envolve-chat-id")||g.searchParams.get("envolve_vsa_id");h||console.error("Unable to retrieve `data-envolve-chat-id` identifier from the script. Unable to load the VSA configuration."),yn.value.debug(`Found script identifier: ${h}`),o.updateBackendUrl(new URL("https://envolve-chatbot-api-dot-envolvetech-001.nw.r.appspot.com")),o.updateSitekey(h),Ht().sessionReady.then(()=>{S(p.chatbot_loaded)});const f=u?.getAttribute("data-envolve-co"),_=u?.getAttribute("data-envolve-cov"),m=u?.getAttribute("data-envolve-covt");await l.updateConfig(f,_,m),yt()&&l.handoverConfig?.activeType==="liveChat"&&rt().registerLiveChatWidget()};await ta();export{Sa as A,sa as B,p as C,Jn as D,aa as E,bn as F,ua as I,da as M,ca as P,fa as U,la as _,de as a,ma as b,Ta as c,S as d,ue as e,yt as f,ni as g,wa as h,ya as i,ba as j,rt as k,pa as l,ka as m,ga as n,Gt as o,Ia as p,pi as q,va as r,le as s,he as t,_e as u,Aa as v,ha as w,_a as x,Ca as y,xa as z};