@commversion/libs 0.18.9 → 0.18.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var o=class e{constructor(e={}){r(this,`dependencies`,void 0),this.dependencies=e}provide(t){return new e(a(a({},this.dependencies),t(this.dependencies)))}},s=class e{constructor(e,t,n,i,a,o,s){r(this,`bus`,void 0),r(this,`pageData`,void 0),r(this,`shortCodeStore`,void 0),r(this,`registry`,void 0),r(this,`channelClick`,void 0),r(this,`exitIntent`,void 0),r(this,`form`,void 0),this.bus=e,this.pageData=t,this.shortCodeStore=n,this.registry=i,this.channelClick=a,this.exitIntent=o,this.form=s}static build(t){let{bus:n,pageData:r,shortCodeStore:i,registry:a,channelClick:o,exitIntent:s,form:c}=t;return{app:new e(n,r,i,a,o,s,c)}}init(){this.pageData.init(),this.pageData.isNewSession()&&this.shortCodeStore.clear(),this.shortCodeStore.init(),this.registry.init(),this.channelClick.init(),this.exitIntent.init(),this.form.init(),this.bus.dispatch(`commversion:attribution-ready`,{})}destroy(){this.registry.destroy(),this.channelClick.destroy(),this.exitIntent.destroy(),this.form.destroy()}},c=class e{constructor(e){r(this,`target`,void 0),this.target=e}on(e,t){let n=e=>{e instanceof CustomEvent&&t(e.detail)};return this.target.addEventListener(e,n),()=>this.target.removeEventListener(e,n)}dispatch(e,t){this.target.dispatchEvent(new CustomEvent(e,{detail:t}))}static build(){return{bus:new e(window)}}},l=class e{constructor(e,t){r(this,`bus`,void 0),r(this,`registry`,void 0),r(this,`unsubscribe`,void 0),this.bus=e,this.registry=t}static build(t){let{bus:n,registry:r}=t;return{channelClick:new e(n,r)}}init(){this.unsubscribe=this.bus.on(`commversion:channel-clicked`,({channel:e})=>{let{sessionVariables:t}=window.LiveChatWidget.get(`customer_data`);this.registry.patchOne(e,{chat_start_url:window.location.href,chat_start_time:new Date().toISOString(),session_variables:t})})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}},u=class e{constructor(e,t,n){r(this,`registry`,void 0),r(this,`debounceMs`,void 0),r(this,`margin`,void 0),r(this,`isMouseInside`,!0),r(this,`leaveTimeout`,void 0),r(this,`onMouseEnter`,()=>{this.registry.patchAll({exit_intent:!1})}),r(this,`onMouseLeave`,()=>{this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})}),r(this,`onMouseMove`,e=>{this.checkBounds(e.clientX,e.clientY)?this.isMouseInside?(clearTimeout(this.leaveTimeout),this.leaveTimeout=void 0):(this.isMouseInside=!0,this.registry.patchAll({exit_intent:!1})):this.isMouseInside&&(this.isMouseInside=!1,this.leaveTimeout=setTimeout(()=>{this.leaveTimeout=void 0,this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})},this.debounceMs))}),this.registry=e,this.debounceMs=t,this.margin=n}init(){window.addEventListener(`mouseenter`,this.onMouseEnter),window.addEventListener(`mouseleave`,this.onMouseLeave),window.addEventListener(`mousemove`,this.onMouseMove)}static build(t){let{registry:n,config:r}=t,{exitIntentDebounceMs:i=1500,exitIntentMargin:a=10}=r;return{exitIntent:new e(n,i,a)}}destroy(){window.removeEventListener(`mouseenter`,this.onMouseEnter),window.removeEventListener(`mouseleave`,this.onMouseLeave),window.removeEventListener(`mousemove`,this.onMouseMove)}checkBounds(e,t){let n=window.innerWidth,r=window.innerHeight;return e>=this.margin&&e<=n-this.margin&&t>=this.margin&&t<=r-this.margin}isBrowsing(){try{return window.LiveChatWidget.get(`customer_data`).status===`browsing`}catch(e){return!1}}},d=class e{constructor(e,t,n,i){r(this,`registry`,void 0),r(this,`abandonmentSelector`,void 0),r(this,`abandonmentDelaySeconds`,void 0),r(this,`submissionSelector`,void 0),r(this,`formAbandonmentTimeout`,void 0),r(this,`abandonmentForms`,void 0),r(this,`submissionForms`,void 0),r(this,`inputs`,void 0),r(this,`onChange`,()=>{clearTimeout(this.formAbandonmentTimeout),this.formAbandonmentTimeout=setTimeout(()=>{this.registry.patchAll({form_abandoned:!0})},this.abandonmentDelaySeconds*1e3)}),r(this,`onAbandonmentFormSubmit`,()=>{clearTimeout(this.formAbandonmentTimeout)}),r(this,`onSubmit`,()=>{this.registry.patchAll({form_submission:!0})}),r(this,`onInvalid`,()=>{this.registry.patchAll({input_error:!0})}),this.registry=e,this.abandonmentSelector=t,this.abandonmentDelaySeconds=n,this.submissionSelector=i}static build(t){let{registry:n,config:r}=t,{formAbandonmentSelector:i=`form`,formAbandonmentDelay:a=10,formSubmissionSelector:o=`form`}=r;return{form:new e(n,i,a,o)}}init(){this.abandonmentForms=document.querySelectorAll(this.abandonmentSelector),this.submissionForms=document.querySelectorAll(this.submissionSelector),this.inputs=document.querySelectorAll(`input`);for(let e of this.abandonmentForms)e.addEventListener(`change`,this.onChange),e.addEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of this.submissionForms)e.addEventListener(`submit`,this.onSubmit);for(let e of this.inputs)e.addEventListener(`invalid`,this.onInvalid)}destroy(){var e,t,n;for(let t of(e=this.abandonmentForms)==null?[]:e)t.removeEventListener(`change`,this.onChange),t.removeEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of(t=this.submissionForms)==null?[]:t)e.removeEventListener(`submit`,this.onSubmit);for(let e of(n=this.inputs)==null?[]:n)e.removeEventListener(`invalid`,this.onInvalid)}};function f(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){f(a,r,i,o,s,`next`,e)}function s(e){f(a,r,i,o,s,`throw`,e)}o(void 0)})}}var m=class extends Error{constructor(e,t){super(`HTTP ${e}`),r(this,`status`,void 0),r(this,`body`,void 0),this.status=e,this.body=t,this.name=`HttpError`}},h=class e{constructor(e){r(this,`url`,void 0),this.url=e}static build(t){let{url:n}=t;return{http:new e(n)}}post(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw new m(n.status,yield g(n));return yield n.json()})()}patch(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0});if(!n.ok)throw new m(n.status,yield g(n))})()}},g=function(){var e=p(function*(e){try{return yield e.json()}catch(e){return null}});return function(t){return e.apply(this,arguments)}}(),_;function v(e,t,n){var r;function i(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=s.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let a=(r=n==null?void 0:n.Parent)==null?Object:r;class o extends a{}Object.defineProperty(o,"name",{value:e});function s(e){var t;let r=n!=null&&n.Parent?new o:this;i(r,e),(t=r._zod).deferred!=null||(t.deferred=[]);for(let e of r._zod.deferred)e();return r}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>{var r;return n!=null&&n.Parent&&t instanceof n.Parent?!0:t==null||(r=t._zod)==null||(r=r.traits)==null?void 0:r.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var y=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(_=globalThis).__zod_globalConfig!=null||(_.__zod_globalConfig={});var b=globalThis.__zod_globalConfig;function x(e){return e&&Object.assign(b,e),b}function ee(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function S(e,t){if(e==null)return{};var n,r,i=ee(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var te=[`inst`,`continue`,`input`];function ne(e,t){return typeof t==`bigint`?t.toString():t}function re(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}var C=Symbol(`evaluating`);function w(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==C)return r===void 0&&(r=C,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}var T=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ie(e){if(E(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(E(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ae(e,t,n){let r=new e._zod.constr(t==null?e._zod.def:t);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function D(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?a(a({},t),{},{error:()=>t.error}):t}function oe(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function O(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0}return!1}function se(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0}return!1}function k(e,t){return t.map(t=>{var n;return(n=t).path!=null||(n.path=[]),t.path.unshift(e),t})}function A(e){return typeof e==`string`?e:e==null?void 0:e.message}function j(e,t,n){var r,i,a,o,s,c,l,u,d;let f=e.message?e.message:(r=(i=(a=(o=A((s=e.inst)==null||(s=s._zod.def)==null||(c=s.error)==null?void 0:c.call(s,e)))==null?A(t==null||(l=t.error)==null?void 0:l.call(t,e)):o)==null?A((u=n.customError)==null?void 0:u.call(n,e)):a)==null?A((d=n.localeError)==null?void 0:d.call(n,e)):i)==null?`Invalid input`:r,{inst:p,continue:m,input:h}=e,g=S(e,te);return g.path!=null||(g.path=[]),g.message=f,t!=null&&t.reportInput&&(g.input=h),g}var M=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ne,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ce=v(`$ZodError`,M),N=v(`$ZodError`,M,{Parent:Error}),le=(e=>(t,n,r,i)=>{let o=r?a(a({},r),{},{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new y;if(s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>j(e,o,x())));throw T(t,i==null?void 0:i.callee),t}return s.value})(N),ue=(e=>function(){var t=p(function*(t,n,r,i){let o=r?a(a({},r),{},{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=yield s),s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>j(e,o,x())));throw T(t,i==null?void 0:i.callee),t}return s.value});return function(e,n,r,i){return t.apply(this,arguments)}}())(N),P=(e=>(t,n,r)=>{let i=r?a(a({},r),{},{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new y;return o.issues.length?{success:!1,error:new(e==null?ce:e)(o.issues.map(e=>j(e,i,x())))}:{success:!0,data:o.value}})(N),F=(e=>function(){var t=p(function*(t,n,r){let i=r?a(a({},r),{},{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=yield o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>j(e,i,x())))}:{success:!0,data:o.value}});return function(e,n,r){return t.apply(this,arguments)}}())(N),de=/^https?$/,I=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;`${I}`;function fe(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function pe(e){let t=fe({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${I}T(?:${r})$`)}var me=e=>{var t,n;let r=e?`[\\s\\S]{${(t=e==null?void 0:e.minimum)==null?0:t},${(n=e==null?void 0:e.maximum)==null?``:n}}`:`[\\s\\S]*`;return RegExp(`^${r}$`)},he=/^-?\d+(?:\.\d+)?$/,ge=v(`$ZodCheck`,(e,t)=>{var n;e._zod!=null||(e._zod={}),e._zod.def=t,(n=e._zod).onattach!=null||(n.onattach=[])}),L=v(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ge.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns!=null||(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check!=null||(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push(a(a({origin:`string`,code:`invalid_format`,format:t.format,input:n.value},t.pattern?{pattern:t.pattern.toString()}:{}),{},{inst:e,continue:!t.abort}))}):(r=e._zod).check!=null||(r.check=()=>{})}),_e={major:4,minor:4,patch:3},R=v(`$ZodType`,(e,t)=>{var n,r;e!=null||(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_e;let i=[...(n=e._zod.def.checks)==null?[]:n];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0){var o;(r=e._zod).deferred!=null||(r.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse})}else{let t=(e,t,n)=>{let r=O(e),i;for(let o of t){if(o._zod.def.when){if(se(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&(n==null?void 0:n.async)===!1)throw new y;if(i||s instanceof Promise){var a;i=((a=i)==null?Promise.resolve():a).then(p(function*(){yield s,e.issues.length!==t&&(r||(r=O(e,t)))}))}else{if(e.issues.length===t)continue;r||(r=O(e,t))}}return i?i.then(()=>e):e},n=(n,r,a)=>{if(O(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new y;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if(o.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},a(a({},o),{},{skipChecks:!0}));return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}let s=e._zod.parse(r,o);if(s instanceof Promise){if(o.async===!1)throw new y;return s.then(e=>t(e,i,o))}return t(s,i,o)}}w(e,`~standard`,()=>({validate:t=>{try{var n;let r=P(e,t);return r.success?{value:r.data}:{issues:(n=r.error)==null?void 0:n.issues}}catch(n){return F(e,t).then(e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}})}},vendor:`zod`,version:1}))}),z=v(`$ZodString`,(e,t)=>{var n,r,i;R.init(e,t),e._zod.pattern=(n=[...(r=e==null||(i=e._zod.bag)==null?void 0:i.patterns)==null?[]:r].pop())==null?me(e._zod.bag):n,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(e){}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),B=v(`$ZodStringFormat`,(e,t)=>{L.init(e,t),z.init(e,t)}),ve=v(`$ZodURL`,(e,t)=>{B.init(e,t),e._zod.check=n=>{try{var r;let i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===de.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let a=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(`:`)?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=i;return}catch(r){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ye=v(`$ZodISODateTime`,(e,t)=>{t.pattern!=null||(t.pattern=pe(t)),B.init(e,t)}),be=v(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function V(e,t,n){e.issues.length&&t.issues.push(...k(n,e.issues)),t.value[n]=e.value}var xe=v(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>V(t,n,e))):V(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function H(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...k(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Se(e){let t=Object.keys(e.shape);for(let r of t){var n;if(!(!((n=e.shape)==null||(n=n[r])==null||(n=n._zod)==null||(n=n.traits)==null)&&n.has(`$ZodType`)))throw Error(`Invalid element at key "${r}": expected a Zod schema`)}let r=oe(e.shape);return a(a({},e),{},{keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)})}function Ce(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>H(e,n,i,t,u,d))):H(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var we=v(`$ZodObject`,(e,t)=>{R.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`);if(!(n!=null&&n.get)){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n=a({},e);return Object.defineProperty(t,"shape",{value:n}),n}})}let r=re(()=>Se(t));w(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]!=null||(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let i=E,o=t.catchall,s;e._zod.parse=(t,n)=>{s!=null||(s=r.value);let a=t.value;if(!i(a))return t.issues.push({expected:`object`,code:`invalid_type`,input:a,inst:e}),t;t.value={};let c=[],l=s.shape;for(let e of s.keys){let r=l[e],i=r._zod.optin===`optional`,o=r._zod.optout===`optional`,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>H(n,t,e,a,i,o))):H(s,t,e,a,i,o)}return o?Ce(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),Te=v(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ie(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let c=new Set;for(let s of o)if(typeof s==`string`||typeof s==`number`||typeof s==`symbol`){c.add(typeof s==`number`?s.toString():s);let o=t.keyType._zod.run({value:s,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>j(e,r,x())),input:s,path:[s],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[s],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...k(s,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...k(s,u.issues)),n.value[l]=u.value)}let l;for(let e in i)if(!c.has(e)){var s;l=(s=l)==null?[]:s,l.push(e)}l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&he.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>j(e,r,x())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...k(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...k(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}});function Ee(e,t){return new e(a({type:`string`},D(t)))}function De(e,t){return new e(a({type:`string`,format:`url`,check:`string_format`,abort:!1},D(t)))}function Oe(e,t){return new e(a({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null},D(t)))}function ke(e,t){return new e(a({type:`never`},D(t)))}var U=v(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);R.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>le(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>P(e,t,n),e.parseAsync=function(){var t=p(function*(t,n){return ue(e,t,n,{callee:e.parseAsync})});return function(e,n){return t.apply(this,arguments)}}(),e.safeParseAsync=function(){var t=p(function*(t,n){return F(e,t,n)});return function(e,n){return t.apply(this,arguments)}}(),e.check=(...n)=>{var r;return e.clone(a(a({},t),{},{checks:[...(r=t.checks)==null?[]:r,...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},e.with=e.check,e.clone=(t,n)=>ae(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),W=v(`ZodMiniString`,(e,t)=>{z.init(e,t),U.init(e,t)});function G(e){return Ee(W,e)}var K=v(`ZodMiniStringFormat`,(e,t)=>{B.init(e,t),W.init(e,t)}),Ae=v(`ZodMiniURL`,(e,t)=>{ve.init(e,t),K.init(e,t)});function q(e){return De(Ae,e)}var je=v(`ZodMiniNever`,(e,t)=>{be.init(e,t),U.init(e,t)});function Me(e){return ke(je,e)}var Ne=v(`ZodMiniArray`,(e,t)=>{xe.init(e,t),U.init(e,t)});function Pe(e,t){return new Ne(a({type:`array`,element:e},D(t)))}var Fe=v(`ZodMiniObject`,(e,t)=>{we.init(e,t),U.init(e,t),w(e,`shape`,()=>t.shape)});function J(e,t){return new Fe(a({type:`object`,shape:e,catchall:Me()},D(t)))}var Y=v(`ZodMiniRecord`,(e,t)=>{Te.init(e,t),U.init(e,t)});function Ie(e,t,n){return!t||!t._zod?new Y(a({type:`record`,keyType:G(),valueType:e},D(t))):new Y(a({type:`record`,keyType:e,valueType:t},D(n)))}var Le=v(`ZodMiniISODateTime`,(e,t)=>{ye.init(e,t),K.init(e,t)});function Re(e){return Oe(Le,e)}var ze=e=>{let t={};for(let n of e.split(/;\s*/)){if(!n)continue;let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();if(!r)continue;let i=n.slice(e+1).trim();try{t[r]=decodeURIComponent(i)}catch(e){t[r]=i}}return t},Be=J({referrer:G(),landing_page:q(),browsing_history:Pe(J({opened_at:Re(),url:q(),title:G()}))}),X=`lc_browsing_history_data`,Ve=`screen and (max-width: 992px) and (pointer: coarse)`,He=class e{constructor(e){r(this,`sessionVariables`,void 0),r(this,`data`,void 0),this.sessionVariables=e}static build(t){let{sessionVariables:n}=t;return{pageData:new e(n)}}init(){this.data=Ue(this.sessionVariables)}get(){if(this.data===void 0)throw Error(`PageDataCollector.get called before init`);return this.data}isNewSession(){if(this.data===void 0)throw Error(`PageDataCollector.isNewSession called before init`);return this.data.wasReset}},Ue=e=>{let t=new URLSearchParams(window.location.search);return a(a(a({session_variables:e,device:window.matchMedia(Ve).matches?`mobile`:`desktop`},We(t,e)),Ge(t)),Ke())},We=(e,t)=>{var n,r,i;let a={};if(window.gaGlobal===void 0)return a;let o=ze(document.cookie),s=Object.entries(o),c=(n=window.analytics)==null?void 0:n.user(),l=window.gaGlobal.vid,u=s.filter(([e])=>e.startsWith(`_ga_`)).map(e=>{var t;return(t=e[1])==null?``:t}),d=e.get(`gclid`)||((r=s.find(([e])=>e.startsWith(`_gcl_aw`)))==null?void 0:r[1])||t.gclid,f=e.get(`dclid`)||o._gcl_dc||t.dclid,p=t.fbc||o._fbc,m=t.fbp||o._fbp,h=e.get(`ttclid`)||o._ttp,g=e.get(`li_fat_id`)||o.li_fat_id,_=(c==null?void 0:c.anonymousId())||window.localStorage.getItem(`ajs_anonymous_id`),v=(c==null?void 0:c.id())||window.localStorage.getItem(`ajs_user_id`),y=(i=s.find(([e])=>e.startsWith(`bid_`)))==null?void 0:i[1];return l&&(a.ga_session=l),u.length>0&&(a.ga_session_id=u),d&&(a.gclid=d),f&&(a.dclid=f),p&&(a.fbc=p),m&&(a.fbp=m),h&&(a.ttclid=h),g&&(a.li_fat_id=g),_&&(a.segment_anonymous_id=_),v&&(a.segment_user_id=v),y&&(a.sitecore_browser_id=y),a},Ge=e=>{let t={},n=e.get(`utm_id`),r=e.get(`utm_source`),i=e.get(`utm_medium`),a=e.get(`utm_campaign`),o=e.get(`utm_term`),s=e.get(`utm_content`);return n&&(t.utm_id=n),r&&(t.utm_source=r),i&&(t.utm_medium=i),a&&(t.utm_campaign=a),o&&(t.utm_term=o),s&&(t.utm_content=s),t},Ke=()=>{let e=Z(),t=new Date;t.setDate(t.getDate()-30);let n=e.browsing_history.filter(e=>new Date(e.opened_at)>t),r={opened_at:new Date().toISOString(),url:window.location.href,title:document.title},i=n.length===0,o=i?{referrer:document.referrer,landing_page:r.url,browsing_history:[r]}:a(a({},e),{},{browsing_history:[...n,r].slice(-50)});return window.localStorage.setItem(X,JSON.stringify(o)),a(a({},o),{},{wasReset:i})},Z=()=>{let e=window.localStorage.getItem(X);if(!e)return{referrer:``,landing_page:``,browsing_history:[]};try{return Be.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${X}:`,{content:e},t),{referrer:``,landing_page:``,browsing_history:[]}}},qe=[`wasReset`],Je=class e{constructor(e,t,n,i,a){r(this,`bus`,void 0),r(this,`http`,void 0),r(this,`pageData`,void 0),r(this,`shortCodeStore`,void 0),r(this,`clientId`,void 0),r(this,`shortCodes`,{whatsapp:void 0,sms:void 0,facebook:void 0}),r(this,`unsubscribe`,void 0),this.bus=e,this.http=t,this.pageData=n,this.shortCodeStore=i,this.clientId=a}static build(t){let{bus:n,http:r,pageData:i,shortCodeStore:a,config:o}=t;return{registry:new e(n,r,i,a,o.clientId)}}init(){this.unsubscribe=this.bus.on(`commversion:channels-registered`,({channels:e})=>{for(let t of e){if(this.shortCodes[t]!==void 0)continue;let e=this.shortCodeStore.get(t);e===void 0?this.shortCodes[t]=this.startChannel(t):this.shortCodes[t]=this.resumeChannel(t,e),this.shortCodes[t].catch(e=>console.error(e))}})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}patchAll(e){for(let t of Object.values(this.shortCodes))t==null||t.then(t=>this.http.patch(a({short_code:t},e)).catch(e=>console.error(e)),()=>{})}patchOne(e,t){var n;(n=this.shortCodes[e])==null||n.then(e=>this.http.patch(a({short_code:e},t)).catch(e=>console.error(e)),()=>{})}resumeChannel(e,t){var n=this;return p(function*(){n.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:t});try{return yield n.http.patch(a(a({},Q(n.pageData.get())),{},{short_code:t,exit_intent:!1})),t}catch(r){return Ye(r)||Xe(r)?n.startChannel(e):(console.error(r),t)}})()}startChannel(e){var t=this;return p(function*(){try{let{short_code:n}=yield t.http.post(a(a({},Q(t.pageData.get())),{},{client_id:t.clientId,channel:e,exit_intent:!1}));return t.shortCodeStore.set(e,n),t.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:n}),n}catch(n){let r=n instanceof Error?n.message:String(n);throw t.bus.dispatch(`commversion:shortcode-failed`,{channel:e,error:r}),n}})()}},Q=e=>{let{wasReset:t}=e;return S(e,qe)},Ye=e=>e instanceof m&&e.status===409&&typeof e.body==`object`&&e.body!==null&&`error`in e.body&&e.body.error===`CHAT_CLOSED`,Xe=e=>e instanceof m&&e.status===404,$=`lc_attribution_short_codes`,Ze=Ie(G(),G()),Qe=class e{constructor(){r(this,`codes`,{})}static build(){return{shortCodeStore:new e}}init(){this.codes=$e()}get(e){return this.codes[e]}set(e,t){this.codes=a(a({},this.codes),{},{[e]:t}),window.localStorage.setItem($,JSON.stringify(this.codes))}clear(){this.codes={},window.localStorage.removeItem($)}},$e=()=>{let e=window.localStorage.getItem($);if(!e)return{};try{return Ze.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${$}:`,{content:e},t),{}}},et=`https://api.cht-srvc.net/attribution`,tt=e=>{var t;let n,r=(t=e.attributionUrl)==null?et:t;return Object.assign(({customerData:t})=>{n=new o({config:e,url:r,sessionVariables:t.sessionVariables}).provide(c.build).provide(h.build).provide(He.build).provide(Qe.build).provide(Je.build).provide(l.build).provide(u.build).provide(d.build).provide(s.build).dependencies.app,n.init()},{destroy:()=>{n==null||n.destroy(),n=void 0}})};window.commversion=window.commversion||{};var nt=tt(window.commversion);window.LiveChatWidget.once(`ready`,nt)})();
1
+ (function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var o=class e{constructor(e={}){r(this,`dependencies`,void 0),this.dependencies=e}provide(t){return new e(a(a({},this.dependencies),t(this.dependencies)))}},s=class e{constructor(e,t,n,i,a,o,s){r(this,`bus`,void 0),r(this,`pageData`,void 0),r(this,`shortCodeStore`,void 0),r(this,`registry`,void 0),r(this,`channelClick`,void 0),r(this,`exitIntent`,void 0),r(this,`form`,void 0),this.bus=e,this.pageData=t,this.shortCodeStore=n,this.registry=i,this.channelClick=a,this.exitIntent=o,this.form=s}static build(t){let{bus:n,pageData:r,shortCodeStore:i,registry:a,channelClick:o,exitIntent:s,form:c}=t;return{app:new e(n,r,i,a,o,s,c)}}init(){this.pageData.init(),this.pageData.isNewSession()&&this.shortCodeStore.clear(),this.shortCodeStore.init(),this.registry.init(),this.channelClick.init(),this.exitIntent.init(),this.form.init(),this.bus.dispatch(`commversion:attribution-ready`,{})}destroy(){this.registry.destroy(),this.channelClick.destroy(),this.exitIntent.destroy(),this.form.destroy()}},c=class e{constructor(e){r(this,`target`,void 0),this.target=e}on(e,t){let n=e=>{e instanceof CustomEvent&&t(e.detail)};return this.target.addEventListener(e,n),()=>this.target.removeEventListener(e,n)}dispatch(e,t){this.target.dispatchEvent(new CustomEvent(e,{detail:t}))}static build(){return{bus:new e(window)}}},l=class e{constructor(e,t){r(this,`bus`,void 0),r(this,`registry`,void 0),r(this,`unsubscribe`,void 0),this.bus=e,this.registry=t}static build(t){let{bus:n,registry:r}=t;return{channelClick:new e(n,r)}}init(){this.unsubscribe=this.bus.on(`commversion:channel-clicked`,({channel:e})=>{let{sessionVariables:t}=window.LiveChatWidget.get(`customer_data`);this.registry.patchOne(e,{chat_start_url:window.location.href,chat_start_time:new Date().toISOString(),session_variables:t})})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}},u=class e{constructor(e,t,n){r(this,`registry`,void 0),r(this,`debounceMs`,void 0),r(this,`margin`,void 0),r(this,`isMouseInside`,!0),r(this,`leaveTimeout`,void 0),r(this,`onMouseEnter`,()=>{this.registry.patchAll({exit_intent:!1})}),r(this,`onMouseLeave`,()=>{this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})}),r(this,`onMouseMove`,e=>{this.checkBounds(e.clientX,e.clientY)?this.isMouseInside?(clearTimeout(this.leaveTimeout),this.leaveTimeout=void 0):(this.isMouseInside=!0,this.registry.patchAll({exit_intent:!1})):this.isMouseInside&&(this.isMouseInside=!1,this.leaveTimeout=setTimeout(()=>{this.leaveTimeout=void 0,this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})},this.debounceMs))}),this.registry=e,this.debounceMs=t,this.margin=n}init(){window.addEventListener(`mouseenter`,this.onMouseEnter),window.addEventListener(`mouseleave`,this.onMouseLeave),window.addEventListener(`mousemove`,this.onMouseMove)}static build(t){let{registry:n,config:r}=t,{exitIntentDebounceMs:i=1500,exitIntentMargin:a=10}=r;return{exitIntent:new e(n,i,a)}}destroy(){window.removeEventListener(`mouseenter`,this.onMouseEnter),window.removeEventListener(`mouseleave`,this.onMouseLeave),window.removeEventListener(`mousemove`,this.onMouseMove)}checkBounds(e,t){let n=window.innerWidth,r=window.innerHeight;return e>=this.margin&&e<=n-this.margin&&t>=this.margin&&t<=r-this.margin}isBrowsing(){try{return window.LiveChatWidget.get(`customer_data`).status===`browsing`}catch(e){return!1}}},d=class e{constructor(e,t,n,i){r(this,`registry`,void 0),r(this,`abandonmentSelector`,void 0),r(this,`abandonmentDelaySeconds`,void 0),r(this,`submissionSelector`,void 0),r(this,`formAbandonmentTimeout`,void 0),r(this,`abandonmentForms`,void 0),r(this,`submissionForms`,void 0),r(this,`inputs`,void 0),r(this,`onChange`,()=>{clearTimeout(this.formAbandonmentTimeout),this.formAbandonmentTimeout=setTimeout(()=>{this.registry.patchAll({form_abandoned:!0})},this.abandonmentDelaySeconds*1e3)}),r(this,`onAbandonmentFormSubmit`,()=>{clearTimeout(this.formAbandonmentTimeout)}),r(this,`onSubmit`,()=>{this.registry.patchAll({form_submission:!0})}),r(this,`onInvalid`,()=>{this.registry.patchAll({input_error:!0})}),this.registry=e,this.abandonmentSelector=t,this.abandonmentDelaySeconds=n,this.submissionSelector=i}static build(t){let{registry:n,config:r}=t,{formAbandonmentSelector:i=`form`,formAbandonmentDelay:a=10,formSubmissionSelector:o=`form`}=r;return{form:new e(n,i,a,o)}}init(){this.abandonmentForms=document.querySelectorAll(this.abandonmentSelector),this.submissionForms=document.querySelectorAll(this.submissionSelector),this.inputs=document.querySelectorAll(`input`);for(let e of this.abandonmentForms)e.addEventListener(`change`,this.onChange),e.addEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of this.submissionForms)e.addEventListener(`submit`,this.onSubmit);for(let e of this.inputs)e.addEventListener(`invalid`,this.onInvalid)}destroy(){var e,t,n;for(let t of(e=this.abandonmentForms)==null?[]:e)t.removeEventListener(`change`,this.onChange),t.removeEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of(t=this.submissionForms)==null?[]:t)e.removeEventListener(`submit`,this.onSubmit);for(let e of(n=this.inputs)==null?[]:n)e.removeEventListener(`invalid`,this.onInvalid)}};function f(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){f(a,r,i,o,s,`next`,e)}function s(e){f(a,r,i,o,s,`throw`,e)}o(void 0)})}}var m=class extends Error{constructor(e,t){super(`HTTP ${e}`),r(this,`status`,void 0),r(this,`body`,void 0),this.status=e,this.body=t,this.name=`HttpError`}},h=class e{constructor(e){r(this,`url`,void 0),this.url=e}static build(t){let{url:n}=t;return{http:new e(n)}}post(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw new m(n.status,yield g(n));return yield n.json()})()}patch(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0});if(!n.ok)throw new m(n.status,yield g(n))})()}},g=function(){var e=p(function*(e){try{return yield e.json()}catch(e){return null}});return function(t){return e.apply(this,arguments)}}(),_;function v(e,t,n){var r;function i(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=s.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let a=(r=n==null?void 0:n.Parent)==null?Object:r;class o extends a{}Object.defineProperty(o,"name",{value:e});function s(e){var t;let r=n!=null&&n.Parent?new o:this;i(r,e),(t=r._zod).deferred!=null||(t.deferred=[]);for(let e of r._zod.deferred)e();return r}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>{var r;return n!=null&&n.Parent&&t instanceof n.Parent?!0:t==null||(r=t._zod)==null||(r=r.traits)==null?void 0:r.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var y=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(_=globalThis).__zod_globalConfig!=null||(_.__zod_globalConfig={});var b=globalThis.__zod_globalConfig;function x(e){return e&&Object.assign(b,e),b}function ee(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function S(e,t){if(e==null)return{};var n,r,i=ee(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var te=[`inst`,`continue`,`input`];function ne(e,t){return typeof t==`bigint`?t.toString():t}function re(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}var C=Symbol(`evaluating`);function w(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==C)return r===void 0&&(r=C,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}var T=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ie(e){if(E(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(E(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ae(e,t,n){let r=new e._zod.constr(t==null?e._zod.def:t);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function D(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?a(a({},t),{},{error:()=>t.error}):t}function oe(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function O(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0}return!1}function se(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0}return!1}function k(e,t){return t.map(t=>{var n;return(n=t).path!=null||(n.path=[]),t.path.unshift(e),t})}function A(e){return typeof e==`string`?e:e==null?void 0:e.message}function j(e,t,n){var r,i,a,o,s,c,l,u,d;let f=e.message?e.message:(r=(i=(a=(o=A((s=e.inst)==null||(s=s._zod.def)==null||(c=s.error)==null?void 0:c.call(s,e)))==null?A(t==null||(l=t.error)==null?void 0:l.call(t,e)):o)==null?A((u=n.customError)==null?void 0:u.call(n,e)):a)==null?A((d=n.localeError)==null?void 0:d.call(n,e)):i)==null?`Invalid input`:r,{inst:p,continue:m,input:h}=e,g=S(e,te);return g.path!=null||(g.path=[]),g.message=f,t!=null&&t.reportInput&&(g.input=h),g}var M=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ne,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ce=v(`$ZodError`,M),N=v(`$ZodError`,M,{Parent:Error}),le=(e=>(t,n,r,i)=>{let o=r?a(a({},r),{},{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new y;if(s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>j(e,o,x())));throw T(t,i==null?void 0:i.callee),t}return s.value})(N),ue=(e=>function(){var t=p(function*(t,n,r,i){let o=r?a(a({},r),{},{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=yield s),s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>j(e,o,x())));throw T(t,i==null?void 0:i.callee),t}return s.value});return function(e,n,r,i){return t.apply(this,arguments)}}())(N),P=(e=>(t,n,r)=>{let i=r?a(a({},r),{},{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new y;return o.issues.length?{success:!1,error:new(e==null?ce:e)(o.issues.map(e=>j(e,i,x())))}:{success:!0,data:o.value}})(N),F=(e=>function(){var t=p(function*(t,n,r){let i=r?a(a({},r),{},{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=yield o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>j(e,i,x())))}:{success:!0,data:o.value}});return function(e,n,r){return t.apply(this,arguments)}}())(N),de=/^https?$/,I=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;`${I}`;function fe(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function pe(e){let t=fe({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${I}T(?:${r})$`)}var me=e=>{var t,n;let r=e?`[\\s\\S]{${(t=e==null?void 0:e.minimum)==null?0:t},${(n=e==null?void 0:e.maximum)==null?``:n}}`:`[\\s\\S]*`;return RegExp(`^${r}$`)},he=/^-?\d+(?:\.\d+)?$/,ge=v(`$ZodCheck`,(e,t)=>{var n;e._zod!=null||(e._zod={}),e._zod.def=t,(n=e._zod).onattach!=null||(n.onattach=[])}),L=v(`$ZodCheckStringFormat`,(e,t)=>{var n,r;ge.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns!=null||(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check!=null||(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push(a(a({origin:`string`,code:`invalid_format`,format:t.format,input:n.value},t.pattern?{pattern:t.pattern.toString()}:{}),{},{inst:e,continue:!t.abort}))}):(r=e._zod).check!=null||(r.check=()=>{})}),_e={major:4,minor:4,patch:3},R=v(`$ZodType`,(e,t)=>{var n,r;e!=null||(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_e;let i=[...(n=e._zod.def.checks)==null?[]:n];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0){var o;(r=e._zod).deferred!=null||(r.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse})}else{let t=(e,t,n)=>{let r=O(e),i;for(let o of t){if(o._zod.def.when){if(se(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&(n==null?void 0:n.async)===!1)throw new y;if(i||s instanceof Promise){var a;i=((a=i)==null?Promise.resolve():a).then(p(function*(){yield s,e.issues.length!==t&&(r||(r=O(e,t)))}))}else{if(e.issues.length===t)continue;r||(r=O(e,t))}}return i?i.then(()=>e):e},n=(n,r,a)=>{if(O(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new y;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if(o.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},a(a({},o),{},{skipChecks:!0}));return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}let s=e._zod.parse(r,o);if(s instanceof Promise){if(o.async===!1)throw new y;return s.then(e=>t(e,i,o))}return t(s,i,o)}}w(e,`~standard`,()=>({validate:t=>{try{var n;let r=P(e,t);return r.success?{value:r.data}:{issues:(n=r.error)==null?void 0:n.issues}}catch(n){return F(e,t).then(e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}})}},vendor:`zod`,version:1}))}),z=v(`$ZodString`,(e,t)=>{var n,r,i;R.init(e,t),e._zod.pattern=(n=[...(r=e==null||(i=e._zod.bag)==null?void 0:i.patterns)==null?[]:r].pop())==null?me(e._zod.bag):n,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(e){}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),B=v(`$ZodStringFormat`,(e,t)=>{L.init(e,t),z.init(e,t)}),ve=v(`$ZodURL`,(e,t)=>{B.init(e,t),e._zod.check=n=>{try{var r;let i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===de.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let a=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(`:`)?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=i;return}catch(r){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ye=v(`$ZodISODateTime`,(e,t)=>{t.pattern!=null||(t.pattern=pe(t)),B.init(e,t)}),be=v(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function V(e,t,n){e.issues.length&&t.issues.push(...k(n,e.issues)),t.value[n]=e.value}var xe=v(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>V(t,n,e))):V(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function H(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...k(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Se(e){let t=Object.keys(e.shape);for(let r of t){var n;if(!(!((n=e.shape)==null||(n=n[r])==null||(n=n._zod)==null||(n=n.traits)==null)&&n.has(`$ZodType`)))throw Error(`Invalid element at key "${r}": expected a Zod schema`)}let r=oe(e.shape);return a(a({},e),{},{keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)})}function Ce(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>H(e,n,i,t,u,d))):H(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var we=v(`$ZodObject`,(e,t)=>{R.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`);if(!(n!=null&&n.get)){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n=a({},e);return Object.defineProperty(t,"shape",{value:n}),n}})}let r=re(()=>Se(t));w(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]!=null||(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let i=E,o=t.catchall,s;e._zod.parse=(t,n)=>{s!=null||(s=r.value);let a=t.value;if(!i(a))return t.issues.push({expected:`object`,code:`invalid_type`,input:a,inst:e}),t;t.value={};let c=[],l=s.shape;for(let e of s.keys){let r=l[e],i=r._zod.optin===`optional`,o=r._zod.optout===`optional`,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>H(n,t,e,a,i,o))):H(s,t,e,a,i,o)}return o?Ce(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),Te=v(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ie(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let c=new Set;for(let s of o)if(typeof s==`string`||typeof s==`number`||typeof s==`symbol`){c.add(typeof s==`number`?s.toString():s);let o=t.keyType._zod.run({value:s,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>j(e,r,x())),input:s,path:[s],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[s],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...k(s,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...k(s,u.issues)),n.value[l]=u.value)}let l;for(let e in i)if(!c.has(e)){var s;l=(s=l)==null?[]:s,l.push(e)}l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&he.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>j(e,r,x())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...k(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...k(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}});function Ee(e,t){return new e(a({type:`string`},D(t)))}function De(e,t){return new e(a({type:`string`,format:`url`,check:`string_format`,abort:!1},D(t)))}function Oe(e,t){return new e(a({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null},D(t)))}function ke(e,t){return new e(a({type:`never`},D(t)))}var U=v(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);R.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>le(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>P(e,t,n),e.parseAsync=function(){var t=p(function*(t,n){return ue(e,t,n,{callee:e.parseAsync})});return function(e,n){return t.apply(this,arguments)}}(),e.safeParseAsync=function(){var t=p(function*(t,n){return F(e,t,n)});return function(e,n){return t.apply(this,arguments)}}(),e.check=(...n)=>{var r;return e.clone(a(a({},t),{},{checks:[...(r=t.checks)==null?[]:r,...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},e.with=e.check,e.clone=(t,n)=>ae(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),W=v(`ZodMiniString`,(e,t)=>{z.init(e,t),U.init(e,t)});function G(e){return Ee(W,e)}var K=v(`ZodMiniStringFormat`,(e,t)=>{B.init(e,t),W.init(e,t)}),Ae=v(`ZodMiniURL`,(e,t)=>{ve.init(e,t),K.init(e,t)});function q(e){return De(Ae,e)}var je=v(`ZodMiniNever`,(e,t)=>{be.init(e,t),U.init(e,t)});function Me(e){return ke(je,e)}var Ne=v(`ZodMiniArray`,(e,t)=>{xe.init(e,t),U.init(e,t)});function Pe(e,t){return new Ne(a({type:`array`,element:e},D(t)))}var Fe=v(`ZodMiniObject`,(e,t)=>{we.init(e,t),U.init(e,t),w(e,`shape`,()=>t.shape)});function J(e,t){return new Fe(a({type:`object`,shape:e,catchall:Me()},D(t)))}var Y=v(`ZodMiniRecord`,(e,t)=>{Te.init(e,t),U.init(e,t)});function Ie(e,t,n){return!t||!t._zod?new Y(a({type:`record`,keyType:G(),valueType:e},D(t))):new Y(a({type:`record`,keyType:e,valueType:t},D(n)))}var Le=v(`ZodMiniISODateTime`,(e,t)=>{ye.init(e,t),K.init(e,t)});function Re(e){return Oe(Le,e)}var ze=e=>{let t={};for(let n of e.split(/;\s*/)){if(!n)continue;let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();if(!r)continue;let i=n.slice(e+1).trim();try{t[r]=decodeURIComponent(i)}catch(e){t[r]=i}}return t},Be=J({referrer:G(),landing_page:q(),browsing_history:Pe(J({opened_at:Re(),url:q(),title:G()}))}),X=`lc_browsing_history_data`,Ve=`screen and (max-width: 992px) and (pointer: coarse)`,He=class e{constructor(e){r(this,`sessionVariables`,void 0),r(this,`data`,void 0),this.sessionVariables=e}static build(t){let{sessionVariables:n}=t;return{pageData:new e(n)}}init(){this.data=Ue(this.sessionVariables)}get(){if(this.data===void 0)throw Error(`PageDataCollector.get called before init`);return this.data}isNewSession(){if(this.data===void 0)throw Error(`PageDataCollector.isNewSession called before init`);return this.data.wasReset}},Ue=e=>{let t=new URLSearchParams(window.location.search);return a(a(a({session_variables:e,device:window.matchMedia(Ve).matches?`mobile`:`desktop`},We(t,e)),Ge(t)),Ke())},We=(e,t)=>{var n,r,i;let a={};if(window.gaGlobal===void 0)return a;let o=ze(document.cookie),s=Object.entries(o),c=(n=window.analytics)==null?void 0:n.user(),l=e=>e&&e!==`null`?e:void 0,u=(r=s.find(([e])=>e.startsWith(`_gcl_aw`)))==null?void 0:r[1],d=window.gaGlobal.vid,f=s.filter(([e])=>e.startsWith(`_ga_`)).map(([e,t])=>`${e}=${t}`),p=l(e.get(`gclid`))||t.gclid||(u?u.split(`.`).pop():``),m=l(e.get(`dclid`))||t.dclid||o._gcl_dc,h=t.fbc||o._fbc,g=t.fbp||o._fbp,_=e.get(`ttclid`)||o._ttp,v=e.get(`li_fat_id`)||o.li_fat_id,y=l(c==null?void 0:c.anonymousId())||l(window.localStorage.getItem(`ajs_anonymous_id`)),b=l(c==null?void 0:c.id())||l(window.localStorage.getItem(`ajs_user_id`)),x=(i=s.find(([e])=>e.startsWith(`bid_`)))==null?void 0:i[1];return d&&(a.ga_session=d),f.length>0&&(a.ga_session_id=f),p&&(a.gclid=p),m&&(a.dclid=m),h&&(a.fbc=h),g&&(a.fbp=g),_&&(a.ttclid=_),v&&(a.li_fat_id=v),y&&(a.segment_anonymous_id=y),b&&(a.segment_user_id=b),x&&(a.sitecore_browser_id=x),a},Ge=e=>{let t={},n=e.get(`utm_id`),r=e.get(`utm_source`),i=e.get(`utm_medium`),a=e.get(`utm_campaign`),o=e.get(`utm_term`),s=e.get(`utm_content`);return n&&(t.utm_id=n),r&&(t.utm_source=r),i&&(t.utm_medium=i),a&&(t.utm_campaign=a),o&&(t.utm_term=o),s&&(t.utm_content=s),t},Ke=()=>{let e=Z(),t=new Date;t.setDate(t.getDate()-30);let n=e.browsing_history.filter(e=>new Date(e.opened_at)>t),r={opened_at:new Date().toISOString(),url:window.location.href,title:document.title},i=n.length===0,o=i?{referrer:document.referrer,landing_page:r.url,browsing_history:[r]}:a(a({},e),{},{browsing_history:[...n,r].slice(-50)});return window.localStorage.setItem(X,JSON.stringify(o)),a(a({},o),{},{wasReset:i})},Z=()=>{let e=window.localStorage.getItem(X);if(!e)return{referrer:``,landing_page:``,browsing_history:[]};try{return Be.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${X}:`,{content:e},t),{referrer:``,landing_page:``,browsing_history:[]}}},qe=[`wasReset`],Je=class e{constructor(e,t,n,i,a){r(this,`bus`,void 0),r(this,`http`,void 0),r(this,`pageData`,void 0),r(this,`shortCodeStore`,void 0),r(this,`clientId`,void 0),r(this,`shortCodes`,{whatsapp:void 0,sms:void 0,facebook:void 0}),r(this,`unsubscribe`,void 0),this.bus=e,this.http=t,this.pageData=n,this.shortCodeStore=i,this.clientId=a}static build(t){let{bus:n,http:r,pageData:i,shortCodeStore:a,config:o}=t;return{registry:new e(n,r,i,a,o.clientId)}}init(){this.unsubscribe=this.bus.on(`commversion:channels-registered`,({channels:e})=>{for(let t of e){if(this.shortCodes[t]!==void 0)continue;let e=this.shortCodeStore.get(t);e===void 0?this.shortCodes[t]=this.startChannel(t):this.shortCodes[t]=this.resumeChannel(t,e),this.shortCodes[t].catch(e=>console.error(e))}})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}patchAll(e){for(let t of Object.values(this.shortCodes))t==null||t.then(t=>this.http.patch(a({short_code:t},e)).catch(e=>console.error(e)),()=>{})}patchOne(e,t){var n;(n=this.shortCodes[e])==null||n.then(e=>this.http.patch(a({short_code:e},t)).catch(e=>console.error(e)),()=>{})}resumeChannel(e,t){var n=this;return p(function*(){n.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:t});try{return yield n.http.patch(a(a({},Q(n.pageData.get())),{},{short_code:t,exit_intent:!1})),t}catch(r){return Ye(r)||Xe(r)?n.startChannel(e):(console.error(r),t)}})()}startChannel(e){var t=this;return p(function*(){try{let{short_code:n}=yield t.http.post(a(a({},Q(t.pageData.get())),{},{client_id:t.clientId,channel:e,exit_intent:!1}));return t.shortCodeStore.set(e,n),t.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:n}),n}catch(n){let r=n instanceof Error?n.message:String(n);throw t.bus.dispatch(`commversion:shortcode-failed`,{channel:e,error:r}),n}})()}},Q=e=>{let{wasReset:t}=e;return S(e,qe)},Ye=e=>e instanceof m&&e.status===409&&typeof e.body==`object`&&e.body!==null&&`error`in e.body&&e.body.error===`CHAT_CLOSED`,Xe=e=>e instanceof m&&e.status===404,$=`lc_attribution_short_codes`,Ze=Ie(G(),G()),Qe=class e{constructor(){r(this,`codes`,{})}static build(){return{shortCodeStore:new e}}init(){this.codes=$e()}get(e){return this.codes[e]}set(e,t){this.codes=a(a({},this.codes),{},{[e]:t}),window.localStorage.setItem($,JSON.stringify(this.codes))}clear(){this.codes={},window.localStorage.removeItem($)}},$e=()=>{let e=window.localStorage.getItem($);if(!e)return{};try{return Ze.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${$}:`,{content:e},t),{}}},et=`https://api.cht-srvc.net/attribution`,tt=e=>{var t;let n,r=(t=e.attributionUrl)==null?et:t;return Object.assign(({customerData:t})=>{n=new o({config:e,url:r,sessionVariables:t.sessionVariables}).provide(c.build).provide(h.build).provide(He.build).provide(Qe.build).provide(Je.build).provide(l.build).provide(u.build).provide(d.build).provide(s.build).dependencies.app,n.init()},{destroy:()=>{n==null||n.destroy(),n=void 0}})};window.commversion=window.commversion||{};var nt=tt(window.commversion);window.LiveChatWidget.once(`ready`,nt)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commversion/libs",
3
- "version": "0.18.9",
3
+ "version": "0.18.10",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Commversion",
6
6
  "type": "module",