(()=>{"use strict";var t=function(t,e,s,n){return new(s||(s=Promise))(function(r,i){function o(t){try{a(n.next(t))}catch(t){i(t)}}function c(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(o,c)}a((n=n.apply(t,e||[])).next())})};class e{static isFetchSupported(){return"function"==typeof fetch&&"undefined"!=typeof AbortController}constructor(t){this.defaultTimeout=t,this.defaultMethod="POST",this.defaultCredentials="include"}send(t,e,s){const{body:n,method:r=this.defaultMethod,credentials:i=this.defaultCredentials,timeout:o=this.defaultTimeout,keepalive:c=!1}=e;if(!s)return new Promise((e,s)=>{const a=t=>e(t),h=t=>s(t);this.sendInternal(t,r,n,i,o,c,a,h)});{const{onLoad:e,onError:a}=s;this.sendInternal(t,r,n,i,o,c,e,a)}}sendInternal(t,s,n,r,i,o,c,a){e.isFetchSupported()?this.sendWithFetch(t,s,n,r,i,o,c,a):this.sendWithXHR(t,s,n,r,i,c,a)}sendWithFetch(e,s,n,r,i,o,c,a){const h=new AbortController;let l;const u={method:s,credentials:"include"===r?"include":"omit",signal:h.signal,keepalive:o};n&&(u.body=n),void 0!==i&&i>0&&(l=window.setTimeout(()=>h.abort(),i)),fetch(e,u).then(e=>t(this,void 0,void 0,function*(){if(void 0!==l&&window.clearTimeout(l),!e.ok){const t=new Error(`Request failed with status ${e.status}!`);return void(a&&a(t))}const t=yield e.text();c&&c(t)})).catch(t=>{if(void 0!==l&&window.clearTimeout(l),t instanceof TypeError&&t.message.includes("abort")){const t=new Error("Request timed out!");a&&a(t)}else a&&a(t)})}sendWithXHR(t,e,s,n,r,i,o){const c=new XMLHttpRequest;c.open(e,t,!0),void 0!==r&&r>0&&(c.timeout=r),c.withCredentials="include"===n,c.onload=()=>{if(c.status>=200&&c.status<=299)i&&i(c.responseText);else{const t=new Error(`Request failed with status ${c.status}!`);o&&o(t)}},c.ontimeout=()=>{const t=new Error("Request timed out!");o&&o(t)},c.onabort=()=>{const t=new Error("Request aborted!");o&&o(t)},c.onerror=()=>{const n=new Error(`Request failed with code "${c.status}". Calling "${t}" with method "${e}" and body "${s}"`);o&&o(n)},s?c.send(s):c.send()}get(t,e={},s){const{timeout:n,credentials:r}=e;return s?this.send(t,{method:"GET",timeout:n,credentials:r},s):this.send(t,{method:"GET",timeout:n,credentials:r})}post(t,e,s,n){const{timeout:r,credentials:i="include"}=s;return n?this.send(t,{method:"POST",body:e,timeout:r,credentials:i},n):this.send(t,{method:"POST",body:e,timeout:r,credentials:i})}}function s(t){switch(t){case 0:return"FATAL";case 1:return"ERROR";case 2:return"WARN";case 3:return"INFO";case 4:return"DEBUG";case 5:return"TRACE";case 6:return"SILLY"}}var n=function(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(s[n[r]]=t[n[r]])}return s};class r{static getCurrentStack(t){try{if(t>2)return;const e=new Error;return this.hasStack(e)?e.stack:void 0}catch(t){return}}static getMessage(t){switch(typeof t){case"string":return t;case"undefined":return;case"object":if(null===t)return;if(this.hasMessage(t))return t.message;try{return JSON.stringify(t)}catch(e){try{return String(t)}catch(t){return}}default:return String(t)}}static hasMessage(t){return null!==t&&"object"==typeof t&&"message"in t&&"string"==typeof t.message}static hasStack(t){return null!==t&&"object"==typeof t&&"stack"in t&&"string"==typeof t.stack}static hasName(t){return null!==t&&"object"==typeof t&&"name"in t&&"string"==typeof t.name}static hasAttachments(t){return null!==t&&"object"==typeof t&&"getAttachments"in t&&"function"==typeof t.getAttachments}constructor(t,e){this.environment=t,this.client=e,this.activationTimestamp=(new Date).toISOString(),this.attachments=[],this.maxLogLevel=t.isProduction()?3:5}attach(t){return this.attachments.push(t),this}integrate(t){let e=!0;for(let s=0;s<this.attachments.length;s++)this.attachments[s].type===t.type&&(this.attachments[s]=Object.assign(Object.assign({},this.attachments[s]),t),e=!1);return e&&this.attach(t),this}fork(){const t=new r(this.environment,this.client);return t.maxLogLevel=this.maxLogLevel,t.attachments=[...this.attachments],t}log(t,e){try{if(e<=this.maxLogLevel)if(this.environment.isProduction()&&!this.environment.isTest())this.client.post(r.tslogURL,JSON.stringify(this.serialize(t,e,!1)),{});else{const{message:s,name:n,levelName:r,stack:i,entries:o,timestamp:c}=this.serialize(t,e,!0),a=["color: #707070ff"];switch(e){case 0:a.push("color: #a11eddff");break;case 1:a.push("color: #FF0000");break;case 2:a.push("color: #FF7F00");break;case 3:a.push("color: #FFD700");break;case 4:a.push("color: #1E90FF");break;case 5:a.push("color: #32CD32");break;case 6:a.push("color: #87CEFA")}a.push("color: #1B6EA3")}}catch(t){}}error(t){this.log(t,1)}fatal(t){this.log(t,0)}debug(t){this.log(t,4)}warn(t){this.log(t,2)}info(t){this.log(t,3)}trace(t){this.log(t,5)}silly(t){this.log(t,6)}serialize(t,e,i){const o=r.getMessage(t),c=r.hasStack(t)?t.stack:r.getCurrentStack(e),a=r.hasName(t)?t.name:void 0;return{entries:this.attachments.concat(r.hasAttachments(t)?t.getAttachments():[]).reduce((t,e)=>{var{type:s}=e,r=n(e,["type"]);return t[s]=Object.assign({},r),t},{}),message:i?o:o?o.substring(0,500):void 0,timestamp:i?(new Date).toLocaleString():(new Date).toISOString(),activationTimestamp:i?new Date(this.activationTimestamp).toLocaleString():this.activationTimestamp,level:e,levelName:s(e),stack:i?c:c?c.substring(0,500):void 0,name:a}}}r.tslogURL="https://onetag-sys.com/tslog/";const i=r;function o(t){switch(t){case"production":return"production";case"development":return"development"}}class c{constructor(t,e){this.nodeEnv=null!=t?o(t)||"production":o("production")||"production",this.testType=null!=e?!1===e?null:function(t){switch(t){case"e2e":return"e2e";case"unit":return"unit"}}(e)||null:null}isProduction(){return"production"===this.nodeEnv}isDevelopment(){return"development"===this.nodeEnv}isE2ETest(){return"e2e"===this.testType}isUnitTest(){return"unit"===this.testType}isTest(){return this.isE2ETest()||this.isUnitTest()}}class a{constructor(t,e,s,n,r,i,o){this.config=t,this.sidStore=e,this.referrerResolver=s,this.apiClient=n,this.scheduler=r,this.locationWatcher=i,this.triggerRunner=o}init(){const t=this.sidStore.get()||this.config.serverSid,e=this.referrerResolver.resolve();this.sidStore.set(t);const s=this.resolveReferrer(e),n=t!==this.config.serverSid;(s.changed||n)&&this.apiClient.sendUpdate({txId:this.config.txId,sid:t,segmentGroupId:this.config.segmentGroupId,segmentIds:this.config.segmentIds,referrer:encodeURIComponent(s.value),callerType:this.config.callerType,userChanged:n,pageChanged:s.changed}),this.scheduler.start(t=>{this.apiClient.sendEvents({txId:this.config.txId,segmentIds:this.config.segmentIds,eventIds:t})}),this.triggerRunner.run(this.config.triggerCode),null!=this.config.segmentGroupId&&e&&this.locationWatcher.start(e,e=>{this.onLocationChange(t,e,this.config.segmentGroupId)})}destroy(){this.scheduler.stop(),this.locationWatcher.stop()}resolveReferrer(t){let e;try{e=new URL(this.config.serverReferrer).href}catch(t){e=this.config.serverReferrer}return t?{changed:t.href!==e,value:t.href}:{changed:!1,value:this.config.serverReferrer}}onLocationChange(t,e,s){this.destroy();const n=document.createElement("script"),r=new URL("https://onetag-sys.com/new-sync");r.searchParams.set("callerType","script"),r.searchParams.set("sid",t),r.searchParams.set("referrer",encodeURIComponent(e.href)),r.searchParams.set("segmentGroupId",s),n.src=r.toString(),n.referrerPolicy="no-referrer-when-downgrade",n.async=!0,document.head.appendChild(n)}}class h{constructor(t=document,e=localStorage,s=window.location.hostname){this.doc=t,this.storage=e,this.hostname=s}get(){return null}set(t){}readCookie(t){try{const e=this.doc.cookie.split(";");for(const s of e){const[e,n]=s.trim().split("=");if(e===t)return decodeURIComponent(n)}}catch(t){}return null}writeCookie(t,e,s){try{const n=new Date;n.setTime(n.getTime()+24*s*60*60*1e3);const r=`expires=${n.toUTCString()}`,i=this.resolveCookieDomain();this.doc.cookie=`${t}=${encodeURIComponent(e)};${r};path=/;${i}SameSite=Lax`}catch(t){}}resolveCookieDomain(){try{if(/^(\d+\.){3}\d+$/.test(this.hostname)||"localhost"===this.hostname)return"";const t=this.hostname.split(".");if(t.length>=2){return`domain=.${t.slice(-2).join(".")};`}}catch(t){}return""}readStorage(t){try{return this.storage.getItem(t)}catch(t){return null}}writeStorage(t,e){try{this.storage.setItem(t,e)}catch(t){}}}class l{constructor(t=window){this.win=t}resolve(){if(this.win===this.win.top)return new URL(this.win.location.href);const t=this.win.top;if(t&&this.isAccessible(t))return new URL(t.location.href);if(this.win.document.referrer)return new URL(this.win.document.referrer);const e=this.win.location.ancestorOrigins;return e&&e.length>0?new URL(e[e.length-1]):void 0}isAccessible(t){try{return t.location.href,!0}catch(t){return!1}}}class u{constructor(t,e,s){this.regionalUrl=t,this.httpClient=e,this.logger=s}sendUpdate(t){this.post("/new-sync/update",t)}sendEvents(t){this.post("/new-sync/events",t)}post(t,e){this.httpClient.post(new URL(t,this.regionalUrl).href,JSON.stringify(e),{},{onLoad:()=>{},onError:t=>this.logger.error(t)})}}const d={15:385,30:386,60:387,120:398,180:399,360:400};class g{constructor(t=window,e=d){this.win=t,this.timingMap=e,this.timers=[],this.collected=[]}start(t){for(const[e,s]of Object.entries(this.timingMap)){const n=1e3*parseInt(e,10),r=this.win.setTimeout(()=>{this.collected.push(s),t(this.collected.slice())},n);this.timers.push(r)}}stop(){for(const t of this.timers)this.win.clearTimeout(t);this.timers=[],this.collected=[]}}class m{constructor(t,e=window,s=m.DEFAULT_POLLING_INTERVAL_MS){this.resolver=t,this.win=e,this.pollingIntervalMs=s}start(t,e){this.last=t,this.intervalId=this.win.setInterval(()=>{const t=this.resolver.resolve();t&&t.href!==this.last.href&&(this.last=t,e(t))},this.pollingIntervalMs)}stop(){void 0!==this.intervalId&&(this.win.clearInterval(this.intervalId),this.intervalId=void 0)}}m.DEFAULT_POLLING_INTERVAL_MS=500;const f=m;class p{constructor(t){this.logger=t}run(t){for(const{segmentId:e,triggerCode:s}of t)try{s()}catch(t){const s=this.logger.fork();s.attach({type:"trigger_code",segmentId:e}),s.error(t)}}}!function(){const t=new c,s=new e,n=new i(t,s).attach({type:"context",artifactName:"PixelEnricher"}),r={txId:"202ceada-d8c3-473d-8783-1beca31df7ce",serverSid:"tK4XfVxWhN-MTiHULjItGI_YXW8f9zTI7aExApmX8Z4",segmentIds:"[114729,114993,117390,114660]",regionalUrl:"https://serv-us-1.onetag-sys.com",triggerCode:[{segmentId: 114660, triggerCode() { 
(function(){

//var a = [["/adesione",[114766,114995]],["/landing/imprese/",114765],["enel.it/it/imprese",114897],["login",114899]];
var a = [["/adesione",114995],["/landing/imprese/",114765],["enel.it/it/imprese",114897],["login",114899]];

a.forEach(function(a){ 
if(location.href.indexOf(a[0])>=0){
var i = a[1];
if(Array.isArray(i)){
  i = i[Math.floor(Math.random()*i.length)];
}
var s = document.createElement("script"); s.referrerPolicy="no-referrer-when-downgrade"; s.async=true; s.src="https://onetag-sys.com/audience-router/?tag=script&segment_id="+i; 
document.body.appendChild(s);
}
});

}());
 }}],segmentGroupId:446,serverReferrer:"https://www.enel.it/it/landing/casa/formidabile-clima-per-te?ecid=display-instal-formidabile_clima_ehome-pro_sud-clima",callerType:"script"};let o;try{o=Object.assign(Object.assign({},r),{segmentIds:JSON.parse(r.segmentIds)})}catch(t){return void n.attach({type:"pixel",config:r}).fatal(t)}try{const t=new l;new a(o,new h,t,new u(o.regionalUrl,s,n),new g,new f(t),new p(n)).init()}catch(t){n.fatal(t)}}()})();