1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).abReader={})}(this,function(e){"use strict";const t=()=>"undefined"==typeof window;function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function r(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return s}}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||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.")}()}function a(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function s(e,t){if(e){if("string"==typeof e)return n(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}var c=function(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=s(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw i}}}}(document.cookie?document.cookie.split("; "):[]);try{for(n.s();!(t=n.n()).done;){var r=t.value.split("=");if(r[0]===e)return r.slice(1).join("=")}}catch(e){n.e(e)}finally{n.f()}return null};const u=[];for(let e=0;e<256;++e)u.push((e+256).toString(16).slice(1));let l;const f=new Uint8Array(16);var d={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function p(e,t,n){if(d.randomUUID&&!e)return d.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!l){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");l=crypto.getRandomValues.bind(crypto)}return l(f)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(u[e[t+0]]+u[e[t+1]]+u[e[t+2]]+u[e[t+3]]+"-"+u[e[t+4]]+u[e[t+5]]+"-"+u[e[t+6]]+u[e[t+7]]+"-"+u[e[t+8]]+u[e[t+9]]+"-"+u[e[t+10]]+u[e[t+11]]+u[e[t+12]]+u[e[t+13]]+u[e[t+14]]+u[e[t+15]]).toLowerCase()}(r)}var m,y="testUserId",g=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,[{key:"ensureUserTestId",value:function(){var e=this.getUserIdFromCookie(y);return e||(e=this.setNewUserIdCookie()),e}},{key:"getUserIdFromCookie",value:function(e){var t=c(e);if(t)return t}},{key:"setNewUserIdCookie",value:function(){var e=p();return function(e,t,n){var r=["".concat(e,"=").concat(t)].concat(i(Object.entries(n||{}).map(function(e){var t=o(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(r)})));document.cookie=r.join("; ")}(y,e,{"max-age":15552e3,path:"/"}),e}}]),e}()),h=function(){return g.ensureUserTestId()},w={};var v=function(){if(m)return w;m=1,Object.defineProperty(w,"__esModule",{value:!0}),w.isBot=void 0;var e=/bot|crawl|spider|AutoIt|requests|microsoft office|CFNetwork|Scrapy|k6\.io|vp-digital-image-processor|feed|facebookexternal|github\.com/i;return w.isBot=function(t){return!!t&&e.test(t)},w}();const b="expCtx",x="expIsQA",I="exp-ab-impression-v2",S=12e4,k={experiments:new Map([]),features:new Map([])},U=()=>
1{if(t())return!1;const e=window.location.search?.includes("exp_param_ignore");return e&&console.debug("(exp_param_ignore) Bypass experimentation"),e},A=(()=>{if(t())return null;const e="overrideInitTimeout",n=window.location.search?.includes(e);if(n){console.debug(`(${e}) Override init timeout`);const t=new URLSearchParams(window.location.search);return parseInt(t.get(e)||"")}return null})()||36e5,E=e=>localStorage.getItem(e)||"";function C(e){const t=document.cookie.split(";");for(const n of t){const[t,r]=n.trim().split("=");if(t===e)return r}return null}const N=(e,t)=>{console.warn(`AB reader failed in ${e}`,t)},T=()=>{try{if(U()||!z())return[];const e=E(b);if(e){const t=V(e,"|",R);return k.experiments.forEach((e,n)=>{let r=!1;t.forEach(t=>{t.experimentKey===n&&(r=!0,t.variationKey=e)}),r||t.push({experimentKey:n,variationKey:e})}),t}}catch(e){N("getAllExperiments",e)}return[]},j=()=>{try{if(M())return!0;if(k.experiments.size>0||k.features.size>0)return!0;return!!E(b)}catch(e){return N("isAvailable",e),!1}};const V=(e,t,n)=>{const r=[],o=new Set,i=e.split("~");if(null!==i&&2===i.length){i[1].split(t).forEach(t=>{const i=n(t);i?.key&&(o.has(i.key)?console.debug(`Exp: context has more than one instance of key ${i.key}`,e):(o.add(i.key),r.push(i.entry)))})}return r},R=e=>{const t=e.split(":");return 2!=t.length?(console.debug("Exp context is malformed: ",e),null):{key:t[0].trim(),entry:{experimentKey:t[0].trim(),variationKey:t[1].trim()}}},O=e=>{const t=e.split("^");return 3!=t.length?(console.debug("Features context is malformed: ",e),null):{key:t[0].trim(),entry:{featureName:t[0].trim(),ruleId:t[1].trim(),ruleName:t[1].trim(),enabled:t[2].trim()}}},$=["localhost","127.0.0.1"],D=/(^|\/)experimentation(\/|$)/,_=()=>{const e=(()=>{try{const e=document.getElementById("ubik-user-context");if(!e?.innerText)return{};const t=JSON.parse(e.innerText);return{tenant:t?.tenant??t?.Tenant,locale:t?.locale??t?.Locale}}catch{return{}}})();if(e.tenant)return e;const t=D.test(window.location.pathname)?{tenant:C("vp-experimentation-tenant")??void 0,locale:C("vp-experimentation-locale")??void 0}:{};return t.tenant?t:{}},F=e=>{const t=e?.locales?.supported;if(Array.isArray(t)&&1===t.length)return e.locales?.primary??t[0]},K=async()=>{try{const e=h(),t=Date.now(),{tenant:n,locale:r}=await(async()=>{const e=_();if(e.tenant)return e;const t=window.location.hostname;if($.includes(t))return{tenant:"vistaprint"};try{const e=window.location.pathname,n=await fetch(`https://api.experience.cimpress.io/tenants/v1/resolve?domain=${encodeURIComponent(t)}&path=${encodeURIComponent(e)}`);
1if(!n.ok)return{};const r=await n.json();return{tenant:r?.tenant,locale:r?.tenant?F(r):void 0}}catch{return{}}})(),o=n?`&tenant=${n}`:"",i=r?`&locale=${encodeURIComponent(r)}`:"",a=await fetch(`https://context-init-prod.cf-exp.vpsvc.com/?requestUrl=${encodeURIComponent(window.location.origin)}&testUserId=${e}&expIsClientSide=1${o}${i}`);(await a.json()).forEach(e=>{if("client"===e.destination&&"Set-Cookie"===e.name&&(document.cookie=e.value),"client"===e.destination&&"Add-Script"===e.name){const t=/localStorage\.setItem\(\s*"(?<key>\w+)"\s*,\s*"(?<value>[^\s]+)"\s*\)/g;let n=null,r=5;do{n=t.exec(e.value)?.groups,n?.key&&localStorage.setItem(n.key,n.value)}while(null!=n&&--r>0)}}),window.dispatchEvent(new Event("variationsResolved")),localStorage.setItem("expCtxInit",JSON.stringify({testUserId:e,timestamp:t,tenant:n,locale:r}))}catch{console.warn("Experiment conext initialization failed")}};function P(){const e={testUserId:h(),experimentsV2:{}};try{const e=JSON.parse(localStorage.getItem(I)||"{}");if(e&&e.testUserId===h()){const t=(new Date).getTime();return e.experimentsV2=Object.entries(e.experimentsV2||{}).reduce((e,[n,r])=>(r._ttl>t&&(e[n]=r),e),{}),e}}catch(e){N("fireImpression",e)}return e}function J(e,t){const n=P();return n.experimentsV2[e]?.variation===t}function L(e,t,n=12e4){const r=P();r.experimentsV2[e]={variation:t,_ttl:(new Date).getTime()+n},localStorage.setItem(I,JSON.stringify(r))}function B(e,t){if(window?.tracking?.track)n();else{const e=(new Date).getTime();window.addEventListener("trackingReady",function(){n((new Date).getTime()-e)})}function n(n){window?.tracking?.track?(t.trackingDelay=n??0,window.tracking.track(e,t)):console.debug("ab-reader: tracking still not available")}}function z(){try{if(M())return!0;const e=localStorage.getItem("expCtxInit");if(!e)return console.debug("ab-reader: unknown context init details"),!0;const t=JSON.parse(e);return h()!==t.testUserId?(console.debug("ab-reader: mismatched user id"),!1):Date.now()-t.timestamp>A?(console.debug("ab-reader: stale context"),!1):!function(e){const t=_(),n=(e,t)=>!!e&&!!t&&e.toLowerCase()!==t.toLowerCase();return n(t.tenant,e.tenant)||n(t.locale,e.locale)}(t)||(console.debug("ab-reader: mismatched site context"),!1)}catch(e){return N("isValidContext",e),!1}}const M=()=>!t()&&v.isBot(window.navigator?.userAgent);t()||window.location.hostname?.endsWith("proshopnext.com")||window.location.hostname?.endsWith("ourproshop.com")||((()=>{if(t()||!["localhost","127.0.0.1"].includes(window.location.hostname))return;const e=window.location.search,n="exp_e_",r="exp_f_";(e?.includes(n)||e?.includes(r))&&new URLSearchParams(e).forEach((e,t)=>{t.startsWith(n)&&k.experiments.set(t.replace(n,""),e),t.startsWith(r)&&k.features.set(t.replace(r,""),e)})})(),setTimeout(()=>{window.abReaderInitialized=!0,M()||setInterval(()=>{K()},A),j()&&z()||K()},200)),e.checkFeature=e=>{try{const t=k.features.get(e);if(t)return{enabled:t,featureName:e,ruleId:"override"};const n=(()=>{try{if(U()||!z())return[];const e=E("expFlagCtx");if(e)return V(e,"|",O)}catch(e){N("getAllFeatures",e)}return[]})();return n.find(t=>t.featureName===e)??null}catch(e){return N("getVariation",e),null}},e.fireFeatureImpression=function(e,t,n,r){if(!e||!t||!n)return N("fireImpression",`Invalid input parameters for the fireFeatureImpression ${JSON.stringify({featureName:e,ruleId:t,enabled:n})}`),!1;try{if(J(e,n))return!1;if("disabled"===t)return!1;const o={flagName:e,passes:"true"===n,ruleId:t,abReaderVersion:r||"3"},i="1"===C(x);return B("Experiment Flag Viewed",o),L(e,n,i?21e3:6e5),!0}catch(e){return N("fireFeatureImpression",e),!1}},e.fireImpression=function(e,t,n,r){if(!e||!t)return N("fireImpression",`Invalid input parameters for the fireImpression ${JSON.stringify({experimentKey:e,variationKey:t})}`),!1;let o={experimentName:e,variationName:t,impressionEventVersion:3,abReaderVersion:r||"3"};n&&(n.pageName&&n.pageSection&&n.pageStage?o={...o,pageName:n.pageName,pageSection:n.pageSection,pageStage:n.pageStage}:N("fireImpression","Page parameters format is wrong"));try{if(J(e,t))return!1;const n="1"===C(x);return B("Experiment Viewed",o),L(e,t,n?21e3:S),!0}catch(e){return N("fireImpression",e),!1}},e.getAllExperiments=T,e.getTestUserId=()=>h(),e.getVariation=e=>{try{const t=k.experiments.get(e);if(t)return t;const n=T().find(t=>t.experimentKey===e);return n?n.variationKey:null}catch(e){return N("getVariation",e),null}},e.isAvailable=j,e.whenAvailable=e=>{e(j())}}); 2//# sourceMappingURL=ab-reader.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.