!function(e){"use strict";const n=e=>{let n=e;return'"'===n[0]&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},t=e=>{const t=document.cookie?document.cookie.split("; "):[],o={};for(let i=0;i{document.cookie=`${e}=${n}; SameSite=None; Secure; domain=.ru.laliexpress.com; path=/`};let i;const a=()=>i,r="a_t_info",d="a_r_t_info";var l;!function(e){e.NAVIGATE="navigate",e.RELOAD="reload"}(l||(l={}));const c=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const n=16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)}));function s(){let e=l.NAVIGATE;if("object"==typeof window&&"object"==typeof window.performance)if("object"==typeof window.performance.navigation)e=window.performance.navigation.type?l.RELOAD:l.NAVIGATE;else if("function"==typeof performance.getEntriesByType){const n=performance.getEntriesByType("navigation").map((e=>e.type));e=n[0]&&"reload"===n[0]?l.RELOAD:l.NAVIGATE}return e}const u=(e,n)=>{localStorage.setItem(e,JSON.stringify(n))},p=e=>{let n=null,o=null;const i=s();document.referrer&&(o=r),document.referrer&&i===l.RELOAD&&(o=d),o&&(n=(e=>{const n=t(e);if(n)try{return JSON.parse(n)}catch(e){return null}return null})(o));return{currentId:c(),currentName:null==e?void 0:e.alias,prevPageId:null==n?void 0:n.id,prevPageName:null==n?void 0:n.name}},m=e=>{const n=s(),t={name:e.currentName||"",id:e.currentId||""},i={name:e.prevPageName||"",id:e.prevPageId||""};document.referrer&&n===l.RELOAD&&(u(d,i),o(d,JSON.stringify(i))),u(r,t),o(r,JSON.stringify(t))},v={};let f=[];const w=()=>{setTimeout((()=>{x(),w()}),3e4)},g=(e,n)=>{const t=(new Date).toISOString(),o=c(),i=a();f.push(Object.assign(Object.assign(Object.assign({},e),i),{timestamp:t,uuid:o})),(n||f.length>=7)&&x(n)},x=e=>{if(!f.length)return;const n=JSON.stringify({events:f}),t=`${v.handler}/v1/collect/aer`;e&&"undefined"!=typeof navigator&&navigator.sendBeacon?navigator.sendBeacon(t,n):fetch(t,{method:"POST",body:n,credentials:"omit"}).catch((e=>{console.error("Couldn't send analytics to local tracker",e)})),f=[]};let y;const I=()=>{m(y),g({trackingInfo:{type:"page"},actionType:"page_close"},!0)};e.sendEvent=g,e.trackerInit=function(e){var n;n=(null==e?void 0:e.handler)||"",v.handler=n,y=p(e),m(y),((e,n)=>{var o,a,r,d,l;const[c,s]=window.location.pathname.split("/").filter((e=>e)),u="item"===c?s.split(".")[0]:"",p=!u||+u?u:u.split("_")[1],m=t("aer_fe_userid"),{referrer:v}=document,f=null===(a=null===(o=document.querySelector("body"))||void 0===o?void 0:o.attributes.getNamedItem("data-spm"))||void 0===a?void 0:a.value,w=(null===(r=document.querySelector("#__AER_DATA__"))||void 0===r?void 0:r.innerHTML)||null,g=w?JSON.parse(w).aerAbTest.split(".").map((e=>e.replace("_",":").replace("aerabtest",""))).join(","):"";i={user:{clientId:m||"",lang:t("aer_lang")||void 0,login:!!m,aerAbTest:g},page:{name:(null==e?void 0:e.alias)||"",chinaName:f||"",previousName:n.prevPageName||"",currentUrl:window.location.href,referralUrl:v,layoutId:(null===(d=null==e?void 0:e.layout)||void 0===d?void 0:d.id)||0,layoutName:(null===(l=null==e?void 0:e.layout)||void 0===l?void 0:l.name)||"",pageViewId:n.currentId||"",previousPageViewId:n.prevPageId||"",itemId:`${p}`||void 0},attributes:{domainName:window.location.hostname||"",chinaDeviceId:t("cna")||"",deviceId:t("aer_abid")||"",googleId:t("_ga")||"",namespace:(null==e?void 0:e.namespace)||"external",platform:window.matchMedia("(pointer:coarse)").matches||window.location.hostname.includes("m.aliexpress")?"mob-web":"web",screenResolutionX:window.screen.width,screenResolutionY:window.screen.height,appsflyerId:"",isIframe:(null===window||void 0===window?void 0:window.self)!==(null===window||void 0===window?void 0:window.top)||!1}}})(e,y),g({trackingInfo:{type:"page"},actionType:"page_view"}),window.addEventListener("DOMContentLoaded",w),window.addEventListener("focus",(()=>m(y))),window.addEventListener("blur",(()=>m(y))),window.addEventListener("beforeunload",I)},Object.defineProperty(e,"__esModule",{value:!0})}(this.iife=this.iife||{}); //# sourceMappingURL=index.js.map