(function(){"use strict";const i={};class l{constructor(a){this.key=`eko.${a}`}setDataStorage(a,e){var o,t;try{let n=(o=window.localStorage)==null?void 0:o.getItem(this.key);n=JSON.parse(n)||{},n[a]=e,(t=window.localStorage)==null||t.setItem(this.key,JSON.stringify(n))}catch(n){console.error(`[setDataStorage]: ${n}`)}}getDataStorage(a){var e;try{let o=(e=window.localStorage)==null?void 0:e.getItem(this.key);return o=JSON.parse(o)||{},o[a]}catch(o){console.error(`[getDataStorage]: ${o}`)}}removeDataStorage(a){var e,o;try{let t=(e=window.localStorage)==null?void 0:e.getItem(this.key);t&&(t=JSON.parse(t),delete t[a],Object.keys(t).length>0?(o=window.localStorage)==null||o.setItem(this.key,JSON.stringify(t)):this.removeAll())}catch(t){console.error(`[removeDataStorage]: ${t}`)}}removeAll(){var a;try{(a=window.localStorage)==null||a.removeItem(this.key)}catch(e){console.error(`[removeAll]: ${e}`)}}}function g(r){return i[r]||(i[r]=new l(r)),i[r]}const f="decision",w=g("ta");function h(r,a){const e=new URL(r.href);for(const[o,t]of Object.entries(a.searchParams))e.searchParams.set(o,t);return a.pathname&&(e.pathname=a.pathname),e.searchParams.set("ekooriginalurl",r.href),e}window.eko=window.eko||{},window.eko.trafficAllocation=window.eko.trafficAllocation||{},window.eko.trafficAllocation.applyVariant=function(){var r,a;try{const e=new URL(window.location.href);if(e.searchParams.get("tavar")!==null){const t=e.searchParams.get("ekooriginalurl");t&&history.replaceState({},"",t);return}if(e.searchParams.get("nota")===null){const t=w.getDataStorage(f);if(t){const c=(((a=(r=window.eko)==null?void 0:r.trafficAllocation)==null?void 0:a.variants)||{})[t];if(c!=null&&c.redirectUrl){const s=h(e,c.redirectUrl);return s.searchParams.set("tavar",t),window.location.replace(s.href),c}}}}catch(e){console.error("eko gallery split test snippet error:",e)}}})();
