/*! For license information please see globocom-horizon.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.horizon=t():e.horizon=t()}(self,(()=>(()=>{var e={501:function(e,t,n){var r;e=n.nmd(e),function(o){var i=(e&&e.exports,"object"==typeof n.g&&n.g);i.global!==i&&i.window;var a=function(e){this.message=e};(a.prototype=new Error).name="InvalidCharacterError";var s=function(e){throw new a(e)},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,l={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var t,n,r,o,i=e.length%3,a="",c=-1,l=e.length-i;++c>18&63)+u.charAt(o>>12&63)+u.charAt(o>>6&63)+u.charAt(63&o);return 2==i?(t=e.charCodeAt(c)<<8,n=e.charCodeAt(++c),a+=u.charAt((o=t+n)>>10)+u.charAt(o>>4&63)+u.charAt(o<<2&63)+"="):1==i&&(o=e.charCodeAt(c),a+=u.charAt(o>>2)+u.charAt(o<<4&63)+"=="),a},decode:function(e){var t=(e=String(e).replace(c,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&s("Invalid character: the string to be decoded is not correctly encoded.");for(var n,r,o=0,i="",a=-1;++a>(-2*o&6)));return i},version:"1.0.0"};void 0===(r=function(){return l}.call(t,n,t,e))||(e.exports=r)}()},97:(e,t,n)=>{"use strict";n(91).polyfill()},91:e=>{"use strict";function t(e,t){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),r=1;r{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){var n=this.event&&this.event.type,r="unload"===n||"beforeunload"===n,o="XMLHttpRequest"in this?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");o.open("POST",e,!r),o.withCredentials=!0,o.setRequestHeader("Accept","*/*"),"string"==typeof t?(o.setRequestHeader("Content-Type","text/plain;charset=UTF-8"),o.responseType="text"):t instanceof Blob&&t.type&&o.setRequestHeader("Content-Type",t.type);try{o.send(t)}catch(e){return!1}return!0}(function(){"navigator"in this||(this.navigator={}),"function"!=typeof this.navigator.sendBeacon&&(this.navigator.sendBeacon=t.bind(this))}).call("object"===("undefined"==typeof window?"undefined":e(window))?window:{})},458:(e,t)=>{!function(e){var t,n,r,o=String.fromCharCode;function i(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function s(e,t){return o(e>>t&63|128)}function u(e){if(0==(4294967168&e))return o(e);var t="";return 0==(4294965248&e)?t=o(e>>6&31|192):0==(4294901760&e)?(a(e),t=o(e>>12&15|224),t+=s(e,6)):0==(4292870144&e)&&(t=o(e>>18&7|240),t+=s(e,12),t+=s(e,6)),t+o(63&e|128)}function c(){if(r>=n)throw Error("Invalid byte index");var e=255&t[r];if(r++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function l(){var e,o;if(r>n)throw Error("Invalid byte index");if(r==n)return!1;if(e=255&t[r],r++,0==(128&e))return e;if(192==(224&e)){if((o=(31&e)<<6|c())>=128)return o;throw Error("Invalid continuation byte")}if(224==(240&e)){if((o=(15&e)<<12|c()<<6|c())>=2048)return a(o),o;throw Error("Invalid continuation byte")}if(240==(248&e)&&(o=(7&e)<<18|c()<<12|c()<<6|c())>=65536&&o<=1114111)return o;throw Error("Invalid UTF-8 detected")}e.version="3.0.0",e.encode=function(e){for(var t=i(e),n=t.length,r=-1,o="";++r65535&&(i+=o((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=o(t);return i}(s)}}(t)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};return(()=>{"use strict";n.r(r),n.d(r,{HorizonClient:()=>_e,IDManager:()=>Re,Settings:()=>d}),n(97);var e,t=new Uint8Array(16);function o(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(t)}const i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,a=function(e){return"string"==typeof e&&i.test(e)};for(var s=[],u=0;u<256;++u)s.push((u+256).toString(16).substr(1));const c=function(e,t){var n=(window.horizonResources=window.horizonResources||{},window.horizonResources);return n[e]=n[e]||t,n[e]};var l={AVOID_COOKIE_USAGE:!1,EVENTS_BUFFER_SIZE:100,EVENTS_SENDER_INTERVAL:1e4,EVENTS_SENDER_MIN_INTERVAL:5e3,EVENTS_SENDER_MAX_INTERVAL:2e4,EVENTS_DISCARD_AFTER_MSECS:36e5,EVENTS_BULK_SIZE:10,HORIZON_CALLBACK_STACK_LIMIT:1e3,HORIZON_TRACK_IDENTIFICATION_RESOURCE:"id",HORIZON_TRACK_HOST:"horizon-track.globo.com",HORIZON_CLIENT_UUID:c("clientInstanceUUID",function(e,t,n){var r=(e=e||{}).random||(e.rng||o)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n}(r)}()),HORIZON_REQUEST_ENCODING:"base64",HORIZON_SCHEMAS_HOST:"horizon-schemas.globo.com",IDENTIFICATION_LOAD_RETRY_AFTER_MSECS:5e3,PACKAGE_VERSION:"1.10.0",SCHEMA_VALIDATOR_SCRIPT_URL:"s3.glbimg.com/cdn/libs/tv4/1.3.0/tv4.min.js",SCHEMA_VALIDATOR_SCRIPT_MAX_RETRIES:2,SCHEMA_LOAD_COLLECTION_RETRY_AFTER_MSECS:1e4,USE_HTTPS:!0},f={avoidCookieUsage:function(){l.AVOID_COOKIE_USAGE=!0},useHTTPOnly:function(){l.USE_HTTPS=!1},useQAConfiguration:function(){l.HORIZON_TRACK_HOST="horizon-track.qa.globoi.com",l.HORIZON_SCHEMAS_HOST="horizon-schemas.qa.globoi.com",l.HORIZON_REQUEST_ENCODING="json"}};const d=Object.assign(l,f);var h=n(671),v=n.n(h),y={COMPONENT_NOT_READY:"[Horizon] Component is not ready.",COMPONENT_UNAVAILABLE:"[Horizon] Class or function is required.",DUPLICATED_SCHEMA:"[Horizon] Duplicated schema.",ERROR_LOADING_RESOURCE:"[Horizon] Failed to load resource.",INVALID_AUTH_TOKEN:"[Horizon] Invalid authorization token.",INVALID_DATA:"[Horizon] Invalid data.",INVALID_DATE:"[Horizon] Invalid date-time RFC 3339 format.",INVALID_STRING_NUMERIC_STRING:"[Horizon] numericString should be string.",INVALID_EMPTY_NUMERIC_STRING:"[Horizon] numericString should be empty.",INVALID_NUMERIC_STRING:"[Horizon] Invalid number. Field with NumericString must to be number.",INVALID_ENVIRONMENT:"[Horizon] Invalid environment value.",INVALID_FORMAT:"[Horizon] Invalid event format.",INVALID_REQUEST:"[Horizon] Invalid request.",INVALID_TIMESTAMP:"[Horizon] Invalid timestamp.",INVALID_VERSION_FORMAT:"[Horizon] Invalid version format.",INVALID_RELATION_ID:"[Horizon] Invalid relation identification.",LIMIT_EXCEEDED:"[Horizon] Resource limit exceeded.",MUST_BE_DEFINED:"[Horizon] Parameter or argument must be defined",SCHEMA_VALIDATOR_ERROR_LOADING:"[Horizon] Could not load SchemaValidator.",UNSUPPORTED_TYPE:"[Horizon] Unsupported type.",UNSUPPORTED_TENANT:"[Horizon] Unsupported tenant.",UNSUPPORTED_ENCODER:"[Horizon] Unsupported encoder.",USE_MANAGER_ONLY_WHEN_AVOIDING_COOKIE:"[Horizon] Can not set or remove a logged user when AVOID_COOKIE_USAGE is not enabled."},p={mustBeDefined:function(e){throw new Error("".concat(y.MUST_BE_DEFINED,": ").concat(e,"."))}};const E=Object.assign(y,p);function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}var g={ready:[]},_=["url"],R=function(){return!!window.tv4},b=function(e){return null===e||isNaN(e)&&!isNaN(Date.parse(e))?null:E.INVALID_DATE},m=function(e){return"string"!=typeof e?E.INVALID_STRING_NUMERIC_STRING:""===e.trim()?E.INVALID_EMPTY_NUMERIC_STRING:Number.isFinite(Number(e))?null:E.INVALID_NUMERIC_STRING};const A={validateFor:function(e,t){if(!R())throw new Error("".concat(E.ERROR_LOADING_RESOURCE," Validator is not ready."));if(!t)throw new Error("".concat(E.INVALID_DATA," Argument: schema."));if(!/\d+\.\d+/.test(e.version))throw new Error(E.INVALID_VERSION_FORMAT);if(!tv4.validate(e.properties,t))throw new Error("".concat(E.INVALID_DATA," ").concat(e.id," ").concat(e.version,". ").concat(tv4.error))},validateArgs:function(e){var t=Object.prototype.hasOwnProperty;if(!(e&&t.call(e,"id")&&t.call(e,"version")&&t.call(e,"properties")))throw new Error("".concat(E.INVALID_FORMAT," Missing properties: ").concat(JSON.stringify(e)));if("string"!=typeof e.id||"string"!=typeof e.version||"object"!==I(e.properties))throw new Error("".concat(E.INVALID_FORMAT," Wrong object type: ").concat(JSON.stringify(e)));if(_.filter((function(t){return e[t]&&"string"!=typeof e[t]})).length>0)throw new Error("".concat(E.INVALID_FORMAT," Wrong object type: ").concat(JSON.stringify(e)));if(e.id.length<2||e.version.length<3)throw new Error("".concat(E.INVALID_FORMAT," Invalid property size: ").concat(JSON.stringify(e)));var n=Object.assign({},e);delete n.id,delete n.version,delete n.properties,delete n.contentType;var r=Object.keys(n);if(r.length>0&&!r.every((function(e){return-1!==_.indexOf(e)})))throw new Error("".concat(E.INVALID_FORMAT," Extra keys aren't allowed: ").concat(JSON.stringify(n)))},tv4IsValidData:b,tv4IsNumericString:m,isReady:R,onReady:function(e){if(R())return e();if(g.ready.length>d.HORIZON_CALLBACK_STACK_LIMIT)throw new Error("".concat(E.LIMIT_EXCEEDED," Validator callback stack."));return g.ready.unshift(e)},load:function(){if(!v().isDefined("tv4")){var e=d.USE_HTTPS?"https://":"http://",t="".concat(e).concat(d.SCHEMA_VALIDATOR_SCRIPT_URL);v()([t],"tv4",{async:!0,numRetries:d.SCHEMA_VALIDATOR_SCRIPT_MAX_RETRIES,success:function(){tv4.addFormat("date-time",b),tv4.addFormat("numericString",m),g.ready.forEach((function(e){return e()}))},error:function(e){throw new Error("".concat(E.SCHEMA_VALIDATOR_ERROR_LOADING," ").concat(e))}})}}};n(237);var O=n(501),T=n.n(O),S=n(458),N=n.n(S),D={base64:function(e){var t=new FormData;return t.append("data",T().encode(N().encode(JSON.stringify(e)))),t.append("encoding","base64"),t},json:function(e){return JSON.stringify(e)}};const C=function(e){if(!(e in D))throw new Error("".concat(E.UNSUPPORTED_ENCODER," Invalid ").concat(e," encoder."));return D[e]};function w(e){for(var t=1;t=t&&e.interval!==r&&e.reschedule(r)},V=function(){return k.get("_hzt.host")||d.HORIZON_TRACK_HOST};function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:100;H(this,e),this._queue=[],this.maxSize=t}var t,n,r;return t=e,r=[{key:"fromArray",value:function(t,n){var r=new e(n);return t.forEach((function(e){return r.push(e)})),r}}],(n=[{key:"length",get:function(){return this._queue.length}},{key:"items",get:function(){return JSON.parse(JSON.stringify(this._queue))}},{key:"push",value:function(e){var t;this._queue=[e].concat(function(e){if(Array.isArray(e))return M(e)}(t=this.slice(0,this.maxSize-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}},{key:"forEach",value:function(e){return this._queue.forEach(e)}},{key:"slice",value:function(e,t){return this._queue.slice(e,t)}},{key:"splice",value:function(e,t){return this._queue.splice(e,t)}},{key:"clear",value:function(){this._queue=[]}},{key:"filter",value:function(t){return e.fromArray(this._queue.filter(t),this.maxSize)}}])&&P(t.prototype,n),r&&P(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();const z=j;function G(e,t){for(var n=0;ne}))}},{key:"prepareRequest",value:function(){var e=this.queue.splice(0,d.EVENTS_BULK_SIZE);return this.actionCounter+=e.length,{horizonClientUUID:this.instanceID,horizonClientTenant:this.currentTenant,horizonClientTs:Date.now(),horizonClientType:"js",horizonClientDeviceGroup:this.deviceGroup,horizonDispatchNumber:this.dispatchNumber,horizonActionCounter:this.actionCounter,horizonEnvironment:this.environment,actions:e}}},{key:"isValidRequest",value:function(e){if(!e||e&&!e.actions)throw new Error(E.INVALID_REQUEST);return e.actions.length>0}},{key:"dispatch",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"json",n=d.USE_HTTPS?"https://":"http://",r=this.idManager.getAsKeyValue(),o=r?"?".concat(r):"",i="".concat(n).concat(V(),"/event/").concat(this.currentTenant).concat(o),a=C(t);if(!this.isValidRequest(e))return!1;this.dispatchNumber+=1;var s=a(e);return navigator.sendBeacon(i,s)}},{key:"enqueue",value:function(e){if(!e.actionTs)throw new Error(E.INVALID_TIMESTAMP);this.queue.push(e)}},{key:"flush",value:function(){for(;this.queue.length>0;){this.queue=this.filterQueue();var e=this.prepareRequest();this.dispatch(e,d.HORIZON_REQUEST_ENCODING)}}}],n&&q(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();const x=function(e,t,n,r){var o=c("bus",{}),i="".concat(e,"-").concat(t);return o[i]||(o[i]=new B(e,d.HORIZON_CLIENT_UUID,t,n,r)),o[i]},K=function(e,t){setTimeout((function(){return e(t)}),1)},Z=function(e,t,n,r){var o=new XMLHttpRequest;o.open(e,t,!0),o.onload=function(){return o.status<400?n(JSON.parse(o.response)):r(o.response)},o.onerror=r,o.send()};function Y(e,t){for(var n=0;nd.HORIZON_CALLBACK_STACK_LIMIT)throw new Error("".concat(E.LIMIT_EXCEEDED," Schemas callback stack."));return this.callbacks.onReady.push(e)}},{key:"onError",value:function(e){this.state===Q?e():this.callbacks.onError.push(e)}},{key:"load",value:function(){var e=this,t=W();if(this.state===J){this.state="statusLoading",this.callbacks.onLoad.forEach((function(e){return e()}));var n=d.USE_HTTPS?"https://":"http://";Z("GET","".concat(n).concat(this.url),(function(n){t.data=Object.assign(t.data||{},n),e.state=X,e.callbacks.onReady.forEach((function(e){return K(e,t.data)}))}),(function(t){e.state=Q,e.callbacks.onError.forEach((function(e){return K(e,t)})),e.retry()}))}}}])&&Y(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();const ee=function(e){var t=W();return t.provider||(t.provider=new $(e||"".concat(d.HORIZON_SCHEMAS_HOST,"/schemas"))),t.provider};var te=function(e){return window.cdaaas&&window.cdaaas.SETTINGS?window.cdaaas.SETTINGS[e]:null},ne=function(e){return window.utag_data?window.utag_data[e]:null};const re=function(){return te("SITE_ID")||ne("ut.profile")||"unknown"},oe=function(){return te("MOBILE_GROUP")||ne("platform")||"unknown"};function ie(e,t){for(var n=0;nd.HORIZON_CALLBACK_STACK_LIMIT)throw new Error("".concat(E.LIMIT_EXCEEDED," IDManager callback stack."));return this.callbacks.onReady.push(e)}},{key:"onError",value:function(e){this.state===le?e():this.callbacks.onError.push(e)}},{key:"getAsKeyValue",value:function(){if(!this.isReady())throw new Error("".concat(E.COMPONENT_NOT_READY));if(this.bypass)return"";var e=this.getClientIDs();return Object.keys(e).map((function(t){return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e[t]))})).join("&")}},{key:"getClientIDs",value:function(){var e=ae();return Object.assign(e.loggedIDs||{},e.anonymousIDs||{},e.sessionIDs||{})}},{key:"isReady",value:function(){return this.state===ue}},{key:"retry",value:function(){var e=this;this.state="statusScheduled",this.callbacks.onRetry.forEach((function(e){return e()})),setTimeout((function(){e.state=ce,e.load()}),d.IDENTIFICATION_LOAD_RETRY_AFTER_MSECS)}},{key:"setLoggedUser",value:function(e,t){if(-1===se.indexOf(e))throw Error(E.INVALID_AUTH_TOKEN);var n,r,o,i=ae();i.loggedIDs=Object.assign(i.loggedIDs||{},(o=t,(r=e)in(n={})?Object.defineProperty(n,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[r]=o,n))}},{key:"setAnonymousUser",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=ae();if(null==n.anonymousIDs||t){if(!("glb_uid"in e)||!("glb_uid_public"in e))throw E.mustBeDefined("glb_uid and glb_uid_public");var r={glb_uid:e.glb_uid,glb_uid_public:e.glb_uid_public};n.anonymousIDs=Object.assign(n.anonymousIDs||{},r)}}},{key:"getAnonymousUser",value:function(){return ae().anonymousIDs}},{key:"setSessionID",value:function(e){e.hsid&&(ae().sessionIDs=Object.assign({},{hsid:e.hsid}))}},{key:"removeLoggedUser",value:function(){var e=ae();se.forEach((function(t){e.loggedIDs[t]&&delete e.loggedIDs[t]}))}},{key:"load",value:function(){var e=this;if(this.state===ce){this.state="statusLoading",this.callbacks.onLoad.forEach((function(e){return e()}));var t=d.USE_HTTPS?"https://":"http://";Z("GET","".concat(t).concat(this.url),(function(t){e.setSessionID(t),e.setAnonymousUser(t,!1),e.state=ue,e.callbacks.onReady.forEach((function(t){return K(t,e.getClientIDs())}))}),(function(t){e.state=le,e.callbacks.onError.forEach((function(e){return K(e,t)})),e.retry()}))}}}],n&&ie(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),de=function(e){var t=ae();if(!t.instance){var n=e||"".concat(d.HORIZON_TRACK_HOST,"/").concat(d.HORIZON_TRACK_IDENTIFICATION_RESOURCE),r=!1===d.AVOID_COOKIE_USAGE;t.instance=new fe(n,r)}return t.instance};const he={getInstance:de,getContextManager:ae,setLoggedUser:function(e,t){if(!d.AVOID_COOKIE_USAGE)throw Error(E.USE_MANAGER_ONLY_WHEN_AVOIDING_COOKIE);e&&0!==e.length||E.mustBeDefined("tokenName"),t&&0!==t.length||E.mustBeDefined("tokenValue"),de().setLoggedUser(e,t)},removeLoggedUser:function(){if(!d.AVOID_COOKIE_USAGE)throw Error(E.USE_MANAGER_ONLY_WHEN_AVOIDING_COOKIE);de().removeLoggedUser()},setAnonymousUser:function(e){de().setAnonymousUser(e)},getAnonymousUser:function(){return de().getAnonymousUser()}};function ve(e){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ve(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pe(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"web";if(ye(this,e),this.tenant=n||re()||E.mustBeDefined("tenant"),this.deviceGroup=r||oe()||E.mustBeDefined("deviceGroup"),this.defaultContentType=o,-1===ge.indexOf(i))throw Error(E.INVALID_ENVIRONMENT);this.environment=i,this.validator=A,this.clientVersion=d.PACKAGE_VERSION,this.state=Ee,this.referer=document.referrer;var a=null,s=null,u=null;this.setSchemasProvider=function(e){a=e},this.getSchemasProvider=function(){if(!a){var e=ee();t.setSchemasProvider(e)}return a},this.setEventBus=function(e){s=e},this.getEventBus=function(){if(!s){var e=x(t.tenant,t.deviceGroup,t.environment,t.getIdManager());t.setEventBus(e)}return s},this.setIdManager=function(e){u=e},this.getIdManager=function(){if(!u){var e=he.getInstance();t.setIdManager(e)}return u},this.isReady=function(){return!!a&&!!u&&t.validator.isReady()&&a.isReady()&&u.isReady()},window.addEventListener("beforeunload",(function(){t.unload()}))}var t,n;return t=e,n=[{key:"useDefaultContentType",value:function(e){this.defaultContentType=e}},{key:"setValidator",value:function(e){this.validator=e}},{key:"setReferer",value:function(e){this.referer=e||document.referrer}},{key:"unload",value:function(){this.flush()}},{key:"getScopeInfo",value:function(e){return{url:document.location.href,actionTs:+Date.now(),horizonClientVersion:this.clientVersion,horizonClientReferer:this.referer,horizonRelationId:e}}},{key:"validateBeforeEnqueue",value:function(e){var t=this.getSchemasProvider().get(e.id,e.version);this.validator.validateFor(e,t)}},{key:"onReady",value:function(e){this.validator.isReady()?this.getSchemasProvider().isReady()?this.getIdManager().isReady()?(this.state="stateReady",e()):(this.state=Ie,this.getIdManager().onReady(e),this.getIdManager().load()):(this.state=Ie,this.getSchemasProvider().onReady(e),this.getSchemasProvider().load()):(this.state=Ie,this.validator.onReady(e),this.validator.load())}},{key:"flush",value:function(){var e=this;this.isReady()?this.getEventBus().flush():this.onReady((function(){return e.flush()}))}},{key:"send",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null!=n&&"string"!=typeof n)throw new Error("".concat(E.INVALID_RELATION_ID," Wrong relationId type. It should be a String: actual type is ").concat(ve(n)));var r=[];r.concat(e).forEach((function(e){t.validator.validateArgs(e),t.sendWithInfo(e,t.getScopeInfo(n))}))}},{key:"sendWithInfo",value:function(e,t){var n=this;if(!this.isReady())return this.state===Ee&&this.flush(),void this.onReady((function(){return n.sendWithInfo(e,t)}));this.validateBeforeEnqueue(e);var r=Object.assign({},t,e);r.contentType||(this.defaultContentType||E.mustBeDefined("contentType"),r.contentType=this.defaultContentType),this.getEventBus().enqueue(r)}}],n&&pe(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();var Re={setLoggedUser:he.setLoggedUser,removeLoggedUser:he.removeLoggedUser,setAnonymousUser:he.setAnonymousUser,getAnonymousUser:he.getAnonymousUser}})(),r})())); //# sourceMappingURL=globocom-horizon.min.js.map