(function(){"use strict";const f="mobile",w="notmobile",A={MOBILE_DEVICE:f,NOT_MOBILE_DEVICE:w};function S(){return(window.navigator.userAgentData?window.navigator.userAgentData.mobile:navigator.maxTouchPoints>0&&/Mobile|Android|webOS|iPhone|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&!/Tablet|iPad/i.test(navigator.userAgent))?f:w}const g={};class O{constructor(e){this.key=`eko.${e}`}setDataStorage(e,a){var o,r;try{let n=(o=window.localStorage)==null?void 0:o.getItem(this.key);n=JSON.parse(n)||{},n[e]=a,(r=window.localStorage)==null||r.setItem(this.key,JSON.stringify(n))}catch(n){console.error(`[setDataStorage]: ${n}`)}}getDataStorage(e){var a;try{let o=(a=window.localStorage)==null?void 0:a.getItem(this.key);return o=JSON.parse(o)||{},o[e]}catch(o){console.error(`[getDataStorage]: ${o}`)}}removeDataStorage(e){var a,o;try{let r=(a=window.localStorage)==null?void 0:a.getItem(this.key);r&&(r=JSON.parse(r),delete r[e],Object.keys(r).length>0?(o=window.localStorage)==null||o.setItem(this.key,JSON.stringify(r)):this.removeAll())}catch(r){console.error(`[removeDataStorage]: ${r}`)}}removeAll(){var e;try{(e=window.localStorage)==null||e.removeItem(this.key)}catch(a){console.error(`[removeAll]: ${a}`)}}}function d(t){return g[t]||(g[t]=new O(t)),g[t]}const i=d("ta");function u(t,e,a,o){i.removeAll(),i.setDataStorage("decision",t),i.setDataStorage("traffic_split",a),i.setDataStorage("provider",o),e&&i.setDataStorage("config",e)}const c=d("ta");function m(t){let e=S()===A.MOBILE_DEVICE?A.MOBILE_DEVICE:"desktop";return t[e]}function v(){var a,o;const t=c.getDataStorage("config")||{},e=((o=(a=window.eko)==null?void 0:a.trafficAllocation)==null?void 0:o.trafficAllocationConfig)||{};return t.version=t.version||0,e.reallocate&&e.version>t.version}function D(){const t=new URL(window.location.href);return t.searchParams.get("taclear")!==null&&t.searchParams.get("tavar")===null}window.eko=window.eko||{},window.eko.trafficAllocation=window.eko.trafficAllocation||{},window.eko.trafficAllocation.allocateTraffic=function(){var t,e;try{const a=new URL(window.location.href),o="eko";(D()||v())&&c.removeAll();const r=a.searchParams.get("forcetavariant"),n=((e=(t=window.eko)==null?void 0:t.trafficAllocation)==null?void 0:e.trafficAllocationConfig)||{},l=m(n);if(r!==null)return u(r,n,l,o),r;let s=c.getDataStorage("decision");if(s&&c.getDataStorage("provider")===o)return;if(n.active&&l>=0)return s=crypto.getRandomValues(new Uint32Array(1))[0]%100<l?"eko":"no_eko",u(s,n,l,o),s}catch(a){console.error("eko gallery split test decision snippet error:",a)}}})();
