(()=>{"use strict";var t={app:{origin:"https://app.cux.io"},dc:{origin:"https://dc.cux.io"},debug:!1,protocol:4,connection:{endpoint:"wss://{slug}.track.cux.io",timeout:4500},sampling:{snapshot:{size:150,interval:2e3},move:15},patterns:{rageClick:{number:4,time:1500},rageKeyPress:{number:12,time:1500},refreshing:{number:3,time:5e3},chaoticMovement:{number:10,time:2e3,distance:.6},deadClick:{time:2e3,unloadTimout:500,number:3},chaoticScrolling:{time:1e4,number:4,distance:.25},bounceBack:{time:4e3}},ttl:{visit:600}},e=t.connection,n=t.ttl,o=t.protocol;const i=t;function r(){if(i.debug){var t=window._cux._ts||0;[(new Date).getTime()-t].concat(Array.prototype.slice.call(arguments))}}var c=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]?window.top._cux:window._cux};function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}const u=new(function(){function t(){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!window.__nativeWindow){var e=document.createElement("iframe");e.style.display="none",e.sandbox="allow-same-origin",document.body&&(document.body.appendChild(e),window.__nativeWindow=e.contentWindow,e.remove())}}var e,n;return e=t,(n=[{key:"get",value:function(){return window.__nativeWindow}}])&&function(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.url=e,this.options=n,this.generateNativeNamespace(),this.connect()}var e,n;return e=t,n=[{key:"generateNativeNamespace",value:function(){window.dispatchEventNative=u.get().dispatchEvent}},{key:"connect",value:function(){var t=this;this.socket=new WebSocket(this.url),this.reconnection=0,setTimeout((function(){t.socket.readyState!==t.socket.OPEN&&(t.timeout=!0)}),this.options.connectionTimeout),this.socket.onmessage=this.onMessage.bind(this),this.socket.onopen=this.onOpen.bind(this),this.socket.onclose=this.onClose.bind(this),this.socket.onerror=this.onError.bind(this)}},{key:"on",value:function(t,e){window.addEventListener(t,(function(t){e(t.detail)}))}},{key:"emit",value:function(t,e){1===this.socket.readyState&&this.socket.send(l.serialize([t,e]))}},{key:"onMessage",value:function(t){var e=l.unserialize(t.data),n=new CustomEvent(e[0],{detail:e[1]});this.dispatchEvent(n)}},{key:"onOpen",value:function(){var t=new CustomEvent("cux:transport:connect");this.dispatchEvent(t),this.reconnection=0}},{key:"onClose",value:function(){var t=this;this.options.reconnect&&this.reconnection<30&&setTimeout((function(){t.reconnection++,t.connect()}),1e3)}},{key:"onError",value:function(){}},{key:"disconnect",value:function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(this.options.reconnect=!1),this.socket.close()}},{key:"dispatchEvent",value:function(t){window.dispatchEventNative?window.dispatchEventNative(t):window.dispatchEvent(t)}}],n&&function(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,o=new Array(e);n2?".".concat(t.slice(-2).join(".")):".".concat(window.location.hostname)}}])&&function(t,e){for(var n=0;n-1}catch(t){return!0}}()?(t=c(),e=c(!0),t&&t.instance||e&&e.instance?r("cux.io is already initialized"):(r("cux.io initialized successfully with id",window._cuxSettings.id),this.connect())):S.load("picker")}},{key:"connect",value:function(){var t=this,e=(new b).connect();this.socket=e,window._cux_q=window._cux_q||[],this.send=function(t,e){window._cux_q.push([t,e])},e&&e.on("ready",(function(n){t.initialized||e.timeout||e.disabled||(t.initialized=!0,r("has ready connection"),window.addEventListener("cux:collector:ready",(function(o){var i=new(0,o.detail.Collector)({config:n,socket:e});t.send=i.send.bind(i)})),S.load("collector").then((function(){r("collector loaded")})),n.integrations&&n.integrations.length&&(window.addEventListener("cux:integrations:ready",(function(t){new(0,t.detail.Integrations)({config:n})})),S.load("integrations").then((function(){r("integrations loaded")}))))}))}},{key:"disconnect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.socket&&(this.socket.disconnect(t),t&&(window._cux=void 0,window._cuxSettings=void 0,new Storage("visit").invalidate(),new Storage("session").invalidate()))}},{key:"pause",value:function(){window.dispatchEvent(new CustomEvent("cux:recorder:pause"))}},{key:"resume",value:function(){window.dispatchEvent(new CustomEvent("cux:recorder:resume"))}}],n&&function(t,e){for(var n=0;n