<!-- 2026-05-07T21:50:32.2630264Z -->
<style>.shoplift-hide { opacity: 0 !important; }</style>
<style id="sl-preview-bar-hide">#preview-bar-iframe, #PBarNextFrameWrapper { display: none !important; }</style>
<script type="text/javascript">(function(rootPath, template, themeRole, themeId, isThemePreview){ /* Generated on 2026-12-03T14:45:04.2511927Z */(function(){"use strict";var fe=document.createElement("style");fe.textContent=`#shoplift-preview-control{position:fixed;max-width:332px;height:56px;background-color:#141414;z-index:9999;bottom:20px;display:flex;border-radius:8px;box-shadow:13px 22px 7px #0000,9px 14px 7px #00000003,5px 8px 6px #0000000d,2px 4px 4px #00000017,1px 1px 2px #0000001a,0 0 #0000001a;align-items:center;margin:0 auto;left:16px;right:16px;opacity:0;transform:translateY(20px);visibility:hidden;transition:opacity .4s ease-in-out,transform .4s ease-in-out,visibility 0s .4s}#shoplift-preview-control.visible{opacity:1;transform:translateY(0);visibility:visible;transition:opacity .4s ease-in-out,transform .4s ease-in-out,visibility 0s 0s}#shoplift-preview-control *{font-family:Inter,sans-serif;color:#fff;box-sizing:border-box;font-size:16px}#shoplift-preview-variant-title{font-weight:400;line-height:140%;font-size:16px;text-align:start;letter-spacing:-.16px;flex-grow:1;text-wrap:nowrap;overflow:hidden;text-overflow:ellipsis}#shoplift-preview-variant-selector{position:relative;display:block;padding:6px 0;height:100%;min-width:0;flex:1 1 auto}#shoplift-preview-variant-menu-trigger{border:none;cursor:pointer;width:100%;background-color:transparent;padding:0 16px;border-left:1px solid #333;border-right:1px solid #333;height:100%;display:flex;align-items:center;justify-content:start;gap:8px}#shoplift-preview-variant-selector .menu-variant-label{width:24px;height:24px;border-radius:50%;padding:6px;display:flex;justify-content:center;align-items:center;font-size:12px;font-style:normal;font-weight:600;line-height:100%;letter-spacing:-.12px;flex-shrink:0}#shoplift-preview-variant-selector .preview-variant-menu{position:absolute;bottom:110%;transform:translate3d(0,20px,0);visibility:hidden;pointer-events:none;opacity:0;cursor:pointer;background-color:#141414;border:1px solid #141414;border-radius:6px;width:100%;max-height:156px;overflow-y:auto;box-shadow:0 8px 16px #0003;z-index:1;transition:opacity .3s ease-in-out,transform .3s ease-in-out,visibility 0s .3s}#shoplift-preview-variant-selector .preview-variant-menu.preview-variant-menu__visible{visibility:visible;pointer-events:auto;opacity:100;transform:translateZ(0);transition:opacity .3s ease-in-out,transform .3s ease-in-out,visibility 0s 0s}@media screen and (max-width:400px){#shoplift-preview-variant-selector .preview-variant-menu{position:fixed;left:0;right:0;width:auto;bottom:110%}}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item{padding:12px 16px;display:flex;overflow:hidden}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item .menu-variant-label{margin-right:6px}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item span{overflow:hidden;text-overflow:ellipsis;text-wrap:nowrap;white-space:nowrap;color:#f6f6f6;font-size:14px;font-style:normal;font-weight:500}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item:hover{background-color:#545454}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item:last-of-type{border-bottom-left-radius:6px;border-bottom-right-radius:6px}#shoplift-preview-variant-selector .preview-variant-menu .preview-variant-menu--item:first-of-type{border-top-left-radius:6px;border-top-right-radius:6px}#shoplift-preview-control div:has(#shoplift-exit-preview-button){padding:0 16px}#shoplift-exit-preview-button{padding:6px 8px;font-weight:500;line-height:75%;border-radius:4px;background-color:transparent;border:none;text-decoration:none}#shoplift-exit-preview-button:hover{cursor:pointer;background-color:#333}#shoplift-preview-subscription-warning{position:relative;display:flex;align-items:center;gap:6px;padding:6px 10px;margin:0 4px;border-left:1px solid #333;cursor:help;outline:none}#shoplift-preview-subscription-warning__icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;background-color:#f59e0b;color:#141414!important;font-weight:700;font-size:12px!important;line-height:1;flex-shrink:0}#shoplift-preview-subscription-warning__label{font-size:13px!important;font-weight:500;color:#fbbf24!important;text-wrap:nowrap;white-space:nowrap}#shoplift-preview-subscription-warning__tooltip{position:absolute;bottom:calc(100% + 8px);right:0;max-width:320px;width:max-content;padding:10px 12px;border-radius:6px;background-color:#1f1f1f;color:#fff!important;font-size:12px!important;line-height:1.4!important;box-shadow:0 8px 16px #0000004d;z-index:10000;opacity:0;visibility:hidden;transform:translateY(4px);transition:opacity .2s ease-in-out,transform .2s ease-in-out,visibility 0s .2s;pointer-events:none}#shoplift-preview-subscription-warning__tooltip.shoplift-preview-subscription-warning__tooltip--visible{opacity:1;visibility:visible;transform:translateY(0);transition:opacity .2s ease-in-out,transform .2s ease-in-out,visibility 0s 0s}#shoplift-preview-subscription-warning:focus-visible{box-shadow:inset 0 0 0 2px #f59e0b;border-radius:4px}#shoplift-preview-control:has(#shoplift-preview-subscription-warning){max-width:480px}/*$vite$:1*/`,document.head.appendChild(fe);var Me=" daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! channel/|google/)google(?!(?:wv|app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!cam)scan|(?<!lib)http|-user/|24x7|;\\s\\w+;$|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\b\\w+/1\\.0;|\\bbw/|\\bdlc\\b|\\bort/|\\bperl\\b|\\btime/|\\||^[<\\(;]|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[\\w\\-]+/[\\w]+$|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^\\w+/\\d\\.\\d\\s\\([\\w@]+\\)$|^active|^ad muncher|^amaya|^apache/|^avsdevicesdk/|^azure|^biglotron|^blackbox exporter|^bot|^clamav[ /]|^claude-code/|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^exodusmovement|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\((?:compatible;)?(?:\\s?[\\w\\d-.]+[\\s/]\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^ps_daily/|^python|^rank|^read|^reed|^remove\\.bg/|^rest|^rss|^snapchat|^sora |^space bison|^stape/|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|abuse|advisor|agent\\b|analyzer|archive|ask jeeves/teoma|attracta|audit|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|collapsify\\b|convertify|cookiehubverify/|crawl|cursor/|cypress/|dareboost|datanyze|dejaclick|detect|discovery|dmbrowser|download|exaleadcloudview|feed|firephp|foregenix|functionize|grab|hardenize\\b|headless|hotjar|httrack|hubspot marketing grader|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|linktiger|mail\\.ru/|marketgoo/|measure|monitor\\b|neustar wpm|node\\b|nutch|offbyone|openvas|optimize|pageburst|pagespeed|parser|phantomjs|pingdom|playwright|powermarks|preview|productfinder|prospectingstudio|proxy|ptst[ /]\\d|radar|readable/|retriever|rexx;|rigor|rss\\b|scrape|securityheaders|selenium|server|silktide|sindup/|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|testlocally|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|watchtowr|webglance|webkit2png|whatcms/|xtate/",qe=/bot|crawl|http|lighthouse|scan|search|spider/i,W;function Ue(){if(W instanceof RegExp)return W;try{W=new RegExp(Me,"i")}catch{W=qe}return W}var He=a=>typeof a=="string"&&a!=="";function Ne(a){return He(a)&&Ue().test(a)}var Fe=Ne;class Y{timestamp;constructor(){this.timestamp=new Date}}class Be extends Y{type;testId;hypothesisId;constructor(e,t,i){super(),this.type=3,this.testId=e,this.hypothesisId=t,this.timestamp=i}}class Ke extends Y{type;path;constructor(e){super(),this.type=4,this.path=e}}class ze extends Y{type;eventVersionId;path;query;templateType;templateSuffix;constructor(e,t,i,s,n){super(),this.type=6,this.eventVersionId=e,this.path=t,this.query=i,this.templateType=s,this.templateSuffix=n}}class We extends Y{type;cart;constructor(e){super(),this.type=5,this.cart=e}}class Z extends Error{isBot;constructor(){super(),this.isBot=!0}}function Ge(a,e,t){for(const i of e.selectors){const s=a.querySelectorAll(i.cssSelector);for(let n=0;n<s.length;n++)t(e.testId,e.hypothesisId)}me(a,e,(i,s,n,r,o)=>o(s,n),t)}function F(a,e,t){for(const i of e.selectors)ye(a,e.testId,e.hypothesisId,i,t??(()=>{}));me(a,e,ye,t??(()=>{}))}function ge(a){return a.urlPatterns.reduce((e,t)=>{switch(t.operator){case"contains":return e+`.*${t}.*`;case"endsWith":return e+`.*${t}`;case"startsWith":return e+`${t}.*`}},"")}function me(a,e,t,i){new MutationObserver(()=>{for(const n of e.selectors)t(a,e.testId,e.hypothesisId,n,i)}).observe(a.documentElement,{childList:!0,subtree:!0})}function ye(a,e,t,i,s){const n=a.querySelectorAll(i.cssSelector);for(let r=0;r<n.length;r++){let o=n.item(r);if(o instanceof HTMLElement&&o.dataset.shoplift!==""){o.dataset.shoplift="";for(const c of i.actions.sort(tt))o=je(a,i.cssSelector,o,c)}}return n.length>0&&s?(s(e,t),!0):!1}function je(a,e,t,i){switch(i.type){case"innerHtml":t.innerHTML=i.value;break;case"attribute":Je(t,i.scope,i.value);break;case"css":Ye(a,e,i.value);break;case"js":Ze(a,t,i);break;case"copy":return Xe(t);case"remove":Qe(t);break;case"move":et(t,parseInt(i.value));break}return t}function Je(a,e,t){a.setAttribute(e,t)}function Ye(a,e,t){const i=a.createElement("style");i.textContent=`${e} { ${t} }`,a.getElementsByTagName("head")[0]?.appendChild(i)}function Ze(a,e,t){Function("document","element",`"use strict"; ${t.value}`)(a,e)}function Xe(a){const e=a.cloneNode(!0);if(!a.parentNode)throw"Can't copy node outside of DOM";return a.parentNode.insertBefore(e,a.nextSibling),e}function Qe(a){a.remove()}function et(a,e){if(e===0)return;const t=Array.prototype.slice.call(a.parentElement.children).indexOf(a),i=Math.min(Math.max(t+e,0),a.parentElement.children.length-1);a.parentElement.children.item(i).insertAdjacentElement(e>0?"afterend":"beforebegin",a)}function tt(a,e){return ve(a)-ve(e)}function ve(a){return a.type==="copy"||a.type==="remove"?0:1}const $={Template:0,UrlRedirect:2,Script:3,Price:5,Checkout:6},it="data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9.96001%207.90004C9.86501%207.90004%209.77001%207.86504%209.69501%207.79004L6.43501%204.53004C6.19501%204.29004%205.80501%204.29004%205.56501%204.53004L2.30501%207.79004C2.16001%207.93504%201.92001%207.93504%201.77501%207.79004C1.63001%207.64504%201.63001%207.40504%201.77501%207.26004L5.03501%204.00004C5.56501%203.47004%206.43001%203.47004%206.96501%204.00004L10.225%207.26004C10.37%207.40504%2010.37%207.64504%2010.225%207.79004C10.15%207.86004%2010.055%207.90004%209.96001%207.90004Z'%20fill='white'/%3e%3c/svg%3e",st="data:image/svg+xml,%3csvg%20width='14'%20height='24'%20viewBox='0%200%2014%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.3976%2014.5255C12.2833%2013.8788%2012.0498%2013.3024%2011.6952%2012.7961C11.3416%2012.2898%2010.9209%2011.8353%2010.4353%2011.4317C9.94868%2011.0291%209.43546%2010.6488%208.89565%2010.292C8.48487%2010.049%208.09577%209.78565%207.72637%209.50402C7.35697%209.2224%207.08016%208.89503%206.89694%208.51987C6.71273%208.14471%206.67826%207.69533%206.79055%207.1697C6.86345%206.83216%206.97476%206.54647%207.12351%206.31162C7.27324%206.07778%207.47124%205.89986%207.7175%205.77684C7.96377%205.65483%208.21989%205.59383%208.48389%205.59383C8.88087%205.59383%209.17639%205.7016%209.3734%205.91714C9.56943%206.13268%209.68271%206.42345%209.71424%206.78946C9.74576%207.15547%209.72015%207.55401%209.63839%207.98509C9.55663%208.41617%209.43645%208.84724%209.27687%209.27934L13.5127%208.80149C13.9638%207.52656%2014.1017%206.42447%2013.9264%205.49725C13.751%204.56901%2013.2664%203.85122%2012.4724%203.34491C12.239%203.19648%2011.9779%203.07041%2011.6893%202.96569L12.0026%201.50979L9.86397%200L7.3875%201.50979L7.11169%202.78878C6.65166%202.8874%206.21724%203.01957%205.8114%203.19038C4.85292%203.594%204.06684%204.15115%203.45117%204.86385C2.83452%205.57655%202.42571%206.40108%202.22378%207.33847C2.06616%208.06947%202.04942%208.70796%202.17551%209.25087C2.30061%209.7948%202.52028%2010.2828%202.8355%2010.7139C3.14974%2011.145%203.51816%2011.5344%203.93977%2011.881C4.36039%2012.2288%204.782%2012.5521%205.20164%2012.851C5.68334%2013.1702%206.13844%2013.5169%206.56497%2013.8921C6.99052%2014.2672%207.31954%2014.7125%207.55004%2015.228C7.78055%2015.7445%207.81502%2016.3769%207.65347%2017.1262C7.56482%2017.5389%207.43676%2017.8765%207.27028%2018.1388C7.10381%2018.4011%206.89596%2018.5983%206.64772%2018.7295C6.3985%2018.8606%206.12071%2018.9267%205.8114%2018.9267C5.21641%2018.9267%204.79776%2018.6034%204.62833%2018.1632C4.4589%2017.7229%204.47367%2017.2583%204.60075%2016.5639C4.72782%2015.8705%205.05092%2015.1395%205.37107%2014.3699H1.17665C1.17665%2014.3699%200.207341%2016.1115%200.0310135%2017.6762C-0.0655232%2018.5302%200.0635208%2019.2653%200.41519%2019.8844C0.76686%2020.5036%201.33032%2020.9814%202.10655%2021.319C2.39222%2021.443%202.7104%2021.5447%203.05813%2021.623L2.54589%2024H7.17473L7.7047%2021.5386C8.08493%2021.442%208.43857%2021.3231%208.76562%2021.1787C9.73985%2020.7476%2010.52%2020.1427%2011.1071%2019.3649C11.6932%2018.5871%2012.0873%2017.7291%2012.2892%2016.7917C12.4744%2015.9295%2012.5099%2015.1741%2012.3966%2014.5275L12.3976%2014.5255Z'%20fill='white'/%3e%3c/svg%3e";async function nt(a){let e=a.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";const t=atob(e),i=Uint8Array.from(t,r=>r.charCodeAt(0)),s=new Blob([i]).stream().pipeThrough(new DecompressionStream("gzip")),n=await new Response(s).text();return JSON.parse(n)}function B(a,e){return typeof e=="string"&&/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+(?:Z|[+-]\d+)/.test(e)?new Date(e):e}function rt(a,e){return e}function q(a,e=!1,t=!1,i=","){const s=a/100;if(t){const r=Math.round(s).toLocaleString("en-US");return i!==","?r.replace(/,/g,i):r}else{const n=e?",":".",r=s.toFixed(2).split("."),o=parseInt(r[0],10),c=r[1]??"00",l=o.toLocaleString("en-US");return i!==","?`${l.replace(/,/g,i)}${n}${c}`:e?`${l.replace(/,/g,".")}${n}${c}`:`${l}${n}${c}`}}function H(a,e,t,i){const s=e.replace("{{amount}}",q(a,!1,!1)).replace("{{amount_no_decimals}}",q(a,!1,!0)).replace("{{amount_with_comma_separator}}",q(a,!0,!1)).replace("{{amount_no_decimals_with_comma_separator}}",q(a,!0,!0)).replace("{{amount_with_space_separator}}",q(a,!1,!1," ")).replace("{{amount_no_decimals_with_space_separator}}",q(a,!1,!0," ")).replace("{{amount_with_apostrophe_separator}}",q(a,!1,!1,"'")).replace("{{amount_no_decimals_with_apostrophe_separator}}",q(a,!1,!0,"'")).replace("{{amount_with_period_and_space_separator}}",q(a,!1,!1,". ")).replace("{{amount_no_decimals_with_period_and_space_separator}}",q(a,!1,!0,". "));return i?`${s} ${t}`:s}function we(a){return a.replace(/[^\d.,\s-]/g,"").trim()}function X(a){const e=new Map;for(const[t,i,s]of a.variants)e.set(t,{priceInCents:i,compareAtPriceInCents:s});return e}function ot(a,e,t,i){const{priceInCents:s,compareAtPriceInCents:n}=t,{moneyFormat:r,currency:o,currencyCodeEnabled:c}=i;if(a.getAttribute("data-sl-attribute-p")===e)a.innerHTML=H(s,r,o,c);else if(a.getAttribute("data-sl-attribute-cap")===e)n<=0||n<=s?a.remove():a.innerHTML=H(n,r,o,c);else if(a.getAttribute("data-sl-attribute-discount")===e&&!(n<=0||n<=s)){const d=Math.round((n-s)/n*100),h=we(H(n-s,r,o,!1)),u=a.getAttribute("data-sl-format")||"percent";u==="percent"?a.textContent=`-${d}%`:u==="amount"?a.textContent=`-${h}`:u==="both"&&(a.textContent=`-${d}% (-${h})`)}}function at(a){const e=[],t={id:"url-pattern",operator:"contains",value:"/"};for(const[i,s,n]of a.variants){e.push({id:`p-${i}`,cssSelector:`[data-sl-attribute-p="${i}"]`,urlPatterns:[t],actions:[{id:`p-action-${i}`,type:"innerHtml",scope:"price",value:H(s,a.moneyFormat,a.currency,a.currencyCodeEnabled)}]});const r=n<=0||n<=s;if(e.push({id:`cap-${i}`,cssSelector:`[data-sl-attribute-cap="${i}"]`,urlPatterns:[t],actions:[{id:`cap-action-${i}`,type:r?"remove":"innerHtml",scope:"compare-at-price",value:r?"":H(n,a.moneyFormat,a.currency,a.currencyCodeEnabled)}]}),!r&&n>s){const o=Math.round((n-s)/n*100),c=we(H(n-s,a.moneyFormat,a.currency,!1));e.push({id:`d-${i}`,cssSelector:`[data-sl-attribute-discount="${i}"]`,urlPatterns:[t],actions:[{id:`d-action-${i}`,type:"js",scope:null,value:`var format = element.getAttribute('data-sl-format') || 'percent'; if (format === 'percent') { element.textContent = '-${o}%'; } else if (format === 'amount') { element.textContent = '-${c}'; } else if (format === 'both') { element.textContent = '-${o}% (-${c})'; }`}]})}}return e}const ct=a=>{let e=5381;for(let t=0;t<a.length;t++)e=(e*33^a.charCodeAt(t))>>>0;return e.toString(36)},be=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4),lt=a=>btoa(JSON.stringify(a)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),K=a=>a.replace(/#slr-[a-z0-9]+$/,""),dt=/^[A-Za-z0-9._=~+/-]{1,256}$/,ae=a=>typeof a=="string"&&dt.test(a)?a:null,ht=a=>{if(!a)return null;try{const t=JSON.parse(atob(decodeURIComponent(a)))?.$exchange_id;return typeof t=="string"&&t.length>0?t:null}catch{return null}},pt=a=>{let e=2166136261;for(let t=0;t<a.length;t++)e^=a.charCodeAt(t),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,(e>>>0)/2**32},qt="modulepreload",Ut=function(a){return"/"+a},Ht={},ut=function(e,t,i){let s=Promise.resolve();function n(r){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=r,window.dispatchEvent(o),!o.defaultPrevented)throw r}return s.then(r=>{for(const o of r||[])o.status==="rejected"&&n(o.reason);return e().catch(n)})};function Se(a,e,t){const i=t?a.plans.filter(l=>!l.variantId||l.variantId===t):a.plans,s=[],n=[];for(const l of i)l.direction==="decrease"?(s.push(l.existingShopifyPlanId),n.push(l.createdShopifyPlanId)):(s.push(l.createdShopifyPlanId),n.push(l.existingShopifyPlanId));const r=e?s:n,o=e?n:s;if(t)for(const l of a.plans)for(const d of[l.existingShopifyPlanId,l.createdShopifyPlanId])d&&!r.includes(d)&&!o.includes(d)&&o.push(d);const c={};for(let l=0;l<o.length;l++){const d=o[l],h=r[l];d&&h&&(c[d]=h)}return{showPlanIds:r,hidePlanIds:o,swapMap:c}}function Ce(a,e,t){const i=e?a.plans.find(n=>n.variantId===e):void 0;if(i)return i.direction;if(t){const n=a.plans.find(r=>r.productId===t);if(n)return n.direction}return a.plans.find(n=>!n.variantId)?.direction??null}function Q(a,e){const t=e?a.plans.filter(n=>!n.productId||n.productId===e):a.plans,i={};for(const n of t)i[n.existingShopifyPlanId]=n.existingDiscountAmount,i[n.createdShopifyPlanId]=n.existingDiscountAmount;const s=Math.max(...Object.values(i),0);return{discountMap:i,maxDiscount:s}}function G(a){const e=document.querySelector('form[action*="/cart/add"] input[name="product-id"]')?.value;if(e)return e;if(a){for(const n of Array.from(document.querySelectorAll("[data-sl-attribute-p]"))){const r=n.getAttribute("data-sl-attribute-p");if(!r)continue;const o=a.variants.find(c=>c[0]===r);if(o?.[3])return o[3]}const s=document.querySelector('form[action*="/cart/add"] input[name="id"]')?.value;if(s){const n=a.variants.find(r=>r[0]===s);if(n?.[3])return n[3]}}const t=window,i=t.ShopifyAnalytics?.meta?.product?.id??t.meta?.product?.id;return i!=null?String(i):null}function L(a,e){return a.widget.selectors[e]??[]}function N(a,e){return a.replace(/[\d.]+%/,`${e}%`)}function M(a,e){const t=document.createTreeWalker(a,NodeFilter.SHOW_TEXT);let i=t.nextNode();for(;i;){if(i.nodeValue!==null){const s=e(i.nodeValue);if(s!==i.nodeValue){i.nodeValue=s;return}}i=t.nextNode()}}function Te(a,e){return a===null?!1:a==="decrease"?!e:e}async function ft(a){if(a.subscriptionSwapDone)return;const e=a.getActiveAssignment();if(!e)return;const t=a.getHypothesis(e.hypothesisId);if(!t?.subscriptionData)return;a.subscriptionSwapDone=!0;const i=t.subscriptionData,s=t.isControl,n=[...new Set(i.plans.map(d=>d.direction))].join(",");a.log(`[SUB-SWAP] ${s?"A":"B"} side, directions=${n}`);const r=i.plans.some(d=>d.variantId);let o=!1,c=!1;function l(){if(!c){c=!0;try{const d=r?document.querySelector("select[name='id'], input[name='id']")?.value:void 0,{showPlanIds:h,hidePlanIds:u,swapMap:p}=Se(i,s,d);a.swapMap=p;const f=L(i,"widgetParent"),P=L(i,"subscriptionPlans"),S=L(i,"subscriptionInput");if(!f.length||!P.length||!S.length)return;const A=document.querySelector(f[0].selector);if(!A?.shadowRoot)return;const _=A.shadowRoot.querySelector(P[0].selector);if(!_?.shadowRoot)return;const C=S[0].selector;let g=null;if(i.widget.widgetType==="buttons"||i.widget.widgetType==="radio"){const v=Array.from(_.shadowRoot.querySelectorAll(C));if(!v.length)return;for(const w of v){const y=w.closest("label");y&&(h.includes(w.value)?y.style.display="":u.includes(w.value)&&(y.style.display="none"))}const b=v.some(w=>h.includes(w.value)&&w.checked),T=v.some(w=>u.includes(w.value)&&w.checked);if((b||T)&&(o=!1),!b&&!o){o=!0;for(const w of v)if(h.includes(w.value)){w.closest("label")?.click(),w.dispatchEvent(new Event("change",{bubbles:!0}));break}}const m=v.find(w=>w.checked);g=m&&h.includes(m.value)?m.value:h[0]??null}else if(i.widget.widgetType==="dropdown"){const v=_.shadowRoot.querySelector("select");if(!v)return;for(const b of Array.from(v.options))u.includes(b.value)&&(b.style.display="none",b.disabled=!0);if(u.includes(v.value)){const b=Array.from(v.options).find(T=>h.includes(T.value));b&&(v.value=b.value,v.dispatchEvent(new Event("change",{bubbles:!0})))}g=h.includes(v.value)?v.value:h[0]??null}if(g){const v=Array.from(document.querySelectorAll('input[name="selling_plan"]'));for(const b of v)b.value!==g&&(b.value=g)}}finally{c=!1}}}if(a.subscriptionHideWrongPlans=l,a.swapMap=Se(i,s).swapMap,l(),r){const d=document.querySelector("select[name='id'], input[name='id']");d&&d.addEventListener("change",l)}}function z(a){const e=L(a,"widgetParent");return e.length?document.querySelector(e[0].selector)?.shadowRoot??null:null}function ee(a,e){const t=L(a,"subscriptionPlans");return t.length?e.querySelector(t[0].selector)?.shadowRoot??null:null}function te(a,e){const t=new URLSearchParams(window.location.search).get("variant");if(t)return t;{const i=document.querySelector('form[action*="/cart/add"] input[name="id"]')?.value;if(i)return i}return a.size>0?[...a.keys()][0]:void 0}function j(a,e){return H(a,e.moneyFormat,e.currency,e.currencyCodeEnabled)}function gt({originalFetch:a,swapMap:e,slptValue:t,getSelectedPlanId:i,log:s}){if(window.fetch.__shoplift_intercepted)return s("[SUB-INTERCEPT] already installed — skipping"),()=>{};function n(o){if(i){const c=i();if(c)return e[c]??c}return e[o]??o}const r=function(o,c){if((typeof o=="string"?o:o instanceof URL?o.href:o.url).includes("/cart/add")&&c?.body)try{if(c.body instanceof FormData){const d=c.body.get("selling_plan");d?c.body.set("selling_plan",n(String(d))):(!d||d==="")&&t&&c.body.set("properties[_slpt]",t)}else if(typeof c.body=="string"){const d=JSON.parse(c.body);if(d.items)for(const h of d.items){const u=String(h.selling_plan??"");u?h.selling_plan=n(u):!h.selling_plan&&t&&(h.properties||(h.properties={}),h.properties._slpt=t)}else if(d.id){const h=String(d.selling_plan??"");h?d.selling_plan=n(h):!d.selling_plan&&t&&(d.properties||(d.properties={}),d.properties._slpt=t)}c.body=JSON.stringify(d)}}catch(d){s("[SUB-INTERCEPT] body parse failed; cart-add proceeds with un-swapped plan",d)}return a.call(window,o,c)};return r.__shoplift_intercepted=!0,window.fetch=r,function(){window.fetch===r&&(window.fetch=a)}}function mt({log:a}){if(window.fetch.__shoplift_intercepted)return a("[SUB-PREVIEW-BLOCK] already installed — skipping"),()=>{};const e=window.fetch,t=function(i,s){const n=typeof i=="string"?i:i instanceof URL?i.href:i.url;return n.includes("/cart/add")?(a("[SUB-PREVIEW-BLOCK] cart-add blocked in preview mode",{url:n}),Promise.resolve(new Response(JSON.stringify({id:0,properties:{},quantity:0,variant_id:0,key:"preview",title:"Preview — cart-add blocked",price:0,original_price:0,line_price:0,original_line_price:0,total_discount:0,discounts:[],preview:!0}),{status:200,headers:{"Content-Type":"application/json"}}))):e.call(window,i,s)};return t.__shoplift_intercepted=!0,window.fetch=t,function(){window.fetch===t&&(window.fetch=e)}}function Ie({data:a,runUpdates:e,debounceMs:t=150}){let i=null;function s(){i&&clearTimeout(i),e(),i=setTimeout(e,t)}let n=null;const r=[],o={childList:!0,subtree:!0,characterData:!0,attributes:!0};function c(u){for(const p of r)p.disconnect();r.length=0;for(const p of Array.from(u.querySelectorAll("*")))if(p.shadowRoot){const f=new MutationObserver(s);f.observe(p.shadowRoot,o),r.push(f)}}function l(){const u=z(a);return u?(n&&n.disconnect(),c(u),n=new MutationObserver(p=>{p.some(f=>f.type==="childList"&&f.addedNodes.length>0)&&c(u),s()}),n.observe(u,o),!0):!1}const d=document.body||document.documentElement,h=new MutationObserver(()=>{l()&&s()});return h.observe(d,{childList:!0,subtree:!0}),l()&&s(),e(),function(){i&&(clearTimeout(i),i=null),h.disconnect(),n&&(n.disconnect(),n=null);for(const p of r)p.disconnect();r.length=0}}async function yt(a){if(a.subscriptionPriceDone)return;const e=a.getActiveAssignment(),t=e?a.getHypothesis(e.hypothesisId):void 0,i=t?.subscriptionData?null:a.findActiveSubscriptionTestControl(),s=t?.subscriptionData?t:i?.hypothesis;if(!s?.subscriptionData)return;const n=t?.subscriptionData?e.testId:i.testId;a.subscriptionPriceDone=!0;const r=s.subscriptionData,o=s.isControl,c=s.priceData,l=r.widget.widgetType;let d=G(c),h=Q(r,d),u=h.discountMap,p=h.maxDiscount;function f(){const y=G(c);y!==d&&(d=y,h=Q(r,d),u=h.discountMap,p=h.maxDiscount,a.log(`[SUB-PRICE] scope refreshed side=${o?"A":"B"}, currentProductId=${d??"n/a"}, maxDiscount=${p}`))}a.log(`[SUB-PRICE] side=${o?"A":"B"}, currentProductId=${d??"n/a"}, maxDiscount=${p}`),a.updatePriceTestHiddenInputs(n,o?"control":"variant",!1);function P(){if(!c)return null;const y=X(c),I=te(y),k=Ce(r,I,d);if(!Te(k,o))return null;const E=I?y.get(I):void 0;return E?{formattedVariantPrice:j(E.priceInCents,c),formattedDiscounted:j(E.priceInCents*(1-p/100),c)}:null}gt({originalFetch:a.cartAddFetch?.()??a.fetch,swapMap:a.swapMap??{},slptValue:a.slptValue??void 0,log:a.log,getSelectedPlanId:()=>{const y=z(r);if(!y)return null;const I=ee(r,y);if(!I)return null;const k=L(r,"subscriptionInput"),E=k.length?k[0].selector:'input[name="rc_plan"]';return I.querySelector(`${E}:checked`)?.value??null}});function S(y){const I=L(r,"subscriptionDiscount");for(const k of I)if(k.selector.includes("badge")||k.selector.includes("__badge")){const E=y.querySelector(k.selector);E?.textContent&&!E.textContent.includes(`${p}%`)&&M(E,R=>N(R,p))}}function A(y){const I=P();if(!I)return;const k=L(r,"subscriptionCompareAt");for(const E of k){const R=y.querySelector(E.selector)||y.querySelector(`[part~="${E.selector}"]`);R?.textContent&&!R.textContent.includes(I.formattedVariantPrice)&&M(R,x=>/\d/.test(x)?I.formattedVariantPrice:x)}}function _(y,I){const k=L(r,"subscriptionCompareAt"),E=I===0?"none":"";for(const R of k){const x=y.querySelector(R.selector)||y.querySelector(`[part~="${R.selector}"]`);x&&(E==="none"?x.style.display!=="none"&&(x.style.display="none"):x.style.display==="none"&&(x.style.display=""))}}function C(y){const I=L(r,"subscriptionInput"),k=I.length?I[0].selector:'input[name="rc_plan"]',E=L(r,"subscriptionPlanDiscount"),R=E.length?E[0].selector:".rc-plans-button__discount";for(const x of Array.from(y.querySelectorAll("label"))){const O=x.querySelector(k),D=x.querySelector(R);if(O&&D){const V=u[O.value];if(V!==void 0){if(V===0)D.style.display!=="none"&&(D.style.display="none");else if(D.style.display==="none"&&(D.style.display=""),D.textContent){const oe=D.textContent.match(/[\d.]+%/)?.[0];oe&&oe!==`${V}%`&&M(D,Mt=>N(Mt,V))}}}}}function g(y){const I=y.querySelector("select");if(I)for(const k of Array.from(I.options)){const E=u[k.value];if(E!==void 0&&k.textContent){const R=k.textContent.match(/[\d.]+%/)?.[0];R&&R!==`${E}%`&&(k.textContent=N(k.textContent,E))}}}function v(y,I){const E=L(r,"subscriptionDiscount").filter(R=>R.selector.includes("benefit")||R.selector==="rc-benefits");for(const R of E){const x=y.querySelector(R.selector);if(x?.shadowRoot){for(const O of Array.from(x.shadowRoot.querySelectorAll("li")))if(O.textContent?.includes("Save")){const D=O;if(I===0)D.style.display!=="none"&&(D.style.display="none");else{D.style.display==="none"&&(D.style.display="");const V=O.textContent.match(/[\d.]+%/)?.[0];V&&V!==`${I}%`&&M(O,oe=>N(oe,I))}}}}}let b=!1;function T(){if(!b){b=!0;try{if(f(),d!==null&&Object.keys(u).length===0)return;const y=z(r);if(!y)return;S(y),c&&A(y);const I=ee(r,y);let k=p;if(I){const E=L(r,"subscriptionInput"),R=E.length?E[0].selector:'input[name="rc_plan"]',x=I.querySelector(`${R}:checked`);if(x){const O=u[x.value];O!==void 0&&(k=O)}l==="buttons"||l==="radio"?C(I):g(I)}_(y,k),v(y,k)}finally{b=!1}}}function m(){const y=P();if(!y)return;const I=z(r);if(!I)return;const k=L(r,"onetimeToggle"),E=k.length?k[0].selector:'input[value="onetime"]';if(!I.querySelector(E)?.checked)return;const x=L(r,"subscriptionPrice");for(const O of x){const D=I.querySelector(O.selector)||I.querySelector(`[part~="${O.selector}"]`);D?.textContent&&!D.textContent.includes(y.formattedDiscounted)&&M(D,V=>/\d/.test(V)?y.formattedDiscounted:V)}}function w(){a.subscriptionHideWrongPlans&&a.subscriptionHideWrongPlans(),T(),a.subscriptionUpdateOneTime&&a.subscriptionUpdateOneTime(),m()}Ie({data:r,runUpdates:w})}async function vt(a){if(a.subscriptionOneTimeDone)return;const e=a.getActiveAssignment(),t=e?a.getHypothesis(e.hypothesisId):void 0,i=!!(t?.subscriptionData&&t.priceData),s=i?null:a.findActiveSubscriptionTestControl(),n=i?t:s?.hypothesis;if(!n?.subscriptionData||!n.priceData)return;const r=i?e.testId:s.testId;a.subscriptionOneTimeDone=!0;const o=n.subscriptionData,c=n.priceData,l=X(c),d=n.isControl,h=d?"control":"variant";a.slptValue=`${r}:${h}:f`,a.updatePriceTestHiddenInputs(r,h,!1);function u(){const p=z(o);if(!p)return;const f=te(l);if(!f)return;const P=G(c),S=Ce(o,f,P);if(!Te(S,d))return;const A=l.get(f);if(!A)return;const _=H(A.priceInCents,c.moneyFormat,c.currency,c.currencyCodeEnabled),C=L(o,"onetimePrice");if(!C.length)return;const g=L(o,"onetimeContainer"),v=g.length?g[0].selector:'[part~="rc-purchase-option__onetime"]',T=p.querySelector(v)??p;for(const m of C){let w=null;try{w=T.querySelector(m.selector)}catch{w=null}w??=T.querySelector(`[part~="${m.selector}"]`),w&&w.textContent&&!w.textContent.includes(_)&&M(w,y=>/\d/.test(y)?_:y)}}a.subscriptionUpdateOneTime=u,u()}async function wt(a,e){const{subscriptionPreviewRender:t}=await ut(async()=>{const{subscriptionPreviewRender:i}=await Promise.resolve().then(()=>$t);return{subscriptionPreviewRender:i}},void 0);return t(a.subscriptionData,a.priceData,a.isControl,e)}function bt(a,e){const t=a.widget.selectors.widgetParent??[],i=a.widget.selectors.subscriptionPlans??[],s=a.widget.selectors.subscriptionInput??[];if(!t.length||!i.length||!s.length){e("[SUB-GLOBAL-HIDE] Missing required selectors — skipping");return}const n=t[0].selector,r=i[0].selector,o=s[0].selector;let c=!1,l=null,d=!1;function h(){if(!d){d=!0;try{u()}finally{d=!1}}}function u(){const A=document.querySelector(n);if(!A?.shadowRoot)return;const _=A.shadowRoot.querySelector(r);if(!_?.shadowRoot)return;_.shadowRoot!==l&&(l=_.shadowRoot,c=!1);let C=0;if(a.widget.widgetType==="buttons"||a.widget.widgetType==="radio"){const g=Array.from(_.shadowRoot.querySelectorAll(o));for(const m of g)if(a.planIds.includes(m.value)){m.disabled||(m.disabled=!0);const w=m.closest("label");w&&w.style.display!=="none"&&(w.style.display="none",C++)}const v=g.filter(m=>!a.planIds.includes(m.value));if(!v.some(m=>m.checked)&&!c&&v.length>0){c=!0;const m=v[0];m.closest("label")?.click(),m.dispatchEvent(new Event("change",{bubbles:!0})),e(`[SUB-GLOBAL-HIDE] Preselected first visible plan input=${m.value}`)}const T=v.find(m=>m.checked)??v[0];if(T){const m=Array.from(document.querySelectorAll('input[name="selling_plan"]'));for(const w of m)w.value!==T.value&&(w.value=T.value,e(`[SUB-GLOBAL-HIDE] Mirrored plan id ${T.value} to form selling_plan input`))}}else if(a.widget.widgetType==="dropdown"){const g=_.shadowRoot.querySelector("select");if(!g)return;for(const T of Array.from(g.options))a.planIds.includes(T.value)&&(T.style.display!=="none"&&(T.style.display="none"),T.disabled||(T.disabled=!0),C++);const v=Array.from(g.options).filter(T=>!a.planIds.includes(T.value)),b=v.some(T=>T.value===g.value);v.length>0&&!b&&!c&&(c=!0,g.value=v[0].value,g.dispatchEvent(new Event("change",{bubbles:!0})),e(`[SUB-GLOBAL-HIDE] Preselected first visible option=${v[0].value}`))}C>0&&e(`[SUB-GLOBAL-HIDE] Hidden ${C} B-side plan buttons`)}const p={childList:!0,subtree:!0,characterData:!0};let f=null;function P(A){f?.disconnect(),f=new MutationObserver(()=>h()),f.observe(A,p)}function S(){const A=document.querySelector(n);if(!A?.shadowRoot)return!1;h(),new MutationObserver(()=>{h();const g=A.shadowRoot.querySelector(r);g?.shadowRoot&&P(g.shadowRoot)}).observe(A.shadowRoot,p);const C=A.shadowRoot.querySelector(r);return C?.shadowRoot&&P(C.shadowRoot),!0}if(!S()){e("[SUB-GLOBAL-HIDE] Widget not in DOM yet — waiting via MutationObserver");const A=new MutationObserver(()=>{S()&&A.disconnect()});A.observe(document.body??document.documentElement,{childList:!0,subtree:!0})}}const Pe="Limited preview",St="Add-to-cart and checkout prices won't reflect this test until it launches — test selling plans are not created in your subscription app until after a test is launched.",Ct=5e3;function Tt(){const a=document.createElement("div");a.id="shoplift-preview-subscription-warning";const e=document.createElement("span");e.id="shoplift-preview-subscription-warning__icon",e.setAttribute("aria-hidden","true"),e.textContent="!";const t=document.createElement("span");t.id="shoplift-preview-subscription-warning__label",t.textContent=Pe;const i=document.createElement("div");i.id="shoplift-preview-subscription-warning__tooltip",i.setAttribute("role","tooltip"),i.textContent=St,a.appendChild(e),a.appendChild(t),a.appendChild(i),a.setAttribute("tabindex","0"),a.setAttribute("aria-describedby",i.id),a.setAttribute("aria-label",Pe);let s=null;function n(){s!==null&&(clearTimeout(s),s=null)}function r(){i.classList.add("shoplift-preview-subscription-warning__tooltip--visible")}function o(){i.classList.remove("shoplift-preview-subscription-warning__tooltip--visible")}function c(){r(),n(),s=setTimeout(()=>{o(),s=null},Ct)}function l(){n(),r()}function d(){s===null&&o()}a.addEventListener("mouseenter",l),a.addEventListener("mouseleave",d),a.addEventListener("focus",l),a.addEventListener("blur",d);function h(p){try{const f=p.target;if(!(f instanceof Element))return;(f.closest('form[action*="/cart/add"] button[type="submit"], form[action*="/cart/add"] input[type="submit"]')!==null||f.closest('[name="add"], button[name="add"], [data-add-to-cart], button[data-add-to-cart]')!==null)&&c()}catch{}}document.addEventListener("click",h,!0);function u(){n(),document.removeEventListener("click",h,!0),a.removeEventListener("mouseenter",l),a.removeEventListener("mouseleave",d),a.removeEventListener("focus",l),a.removeEventListener("blur",d),a.remove()}return{root:a,tooltip:i,cleanup:u}}const U=a=>a==="checkout",ie="_slct",se="_slct_preview",ce=`properties[${ie}]`,le=`properties[${se}]`,Ae="data-sl-ct",de="data-sl-ct-preview",It=a=>{const e=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t=new RegExp(`^(?:${e})?/cart/add(?:\\.js|\\.json)?/?$`,"i");return i=>t.test(new URL(i,window.location.href).pathname)},Pt=(a,e,t)=>{const i=JSON.parse(a),s={[ie]:e,...t?{[se]:"true"}:{}};if(i.items)for(const n of i.items)n.properties={...n.properties,...s};else i.properties={...i.properties,...s};return JSON.stringify(i)},ke=(a,e,t=!1)=>{if(a instanceof FormData||a instanceof URLSearchParams)return a.set(ce,e),t&&a.set(le,"true"),a;if(typeof a=="string"){if(a.trimStart().startsWith("{"))return Pt(a,e,t);if(/\s/.test(a))return a;const i=new URLSearchParams(a);return i.set(ce,e),t&&i.set(le,"true"),i.toString()}return a},Ee=(a,e,t,i)=>{let s=a.querySelector(`input[${e}]`);s||(s=document.createElement("input"),s.type="hidden",s.name=t,s.setAttribute(e,""),a.appendChild(s)),s.value=i},At=(a,e,t)=>{Ee(a,Ae,ce,e),t?Ee(a,de,le,"true"):a.querySelector(`input[${de}]`)?.remove()},_e=()=>{document.querySelectorAll(`input[${Ae}], input[${de}]`).forEach(a=>a.remove())},Re=(a,e)=>{const t=a.getAttribute("action");if(!t)return!1;try{return e(t)}catch{return!1}},xe=(a,e,t)=>{a instanceof HTMLFormElement&&Re(a,e)&&t(a),a.querySelectorAll('form[action*="/cart/add"]').forEach(i=>{Re(i,e)&&t(i)})},kt=async(a,e)=>{try{const t=await(await fetch("/cart.js")).json();for(const i of t.items??[]){const s=i.properties??{};if(s[ie]===a&&s[se]==="true")continue;const n=await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:i.key,quantity:i.quantity,properties:{...s,[ie]:a,[se]:"true"}})});n.ok||e("[CHECKOUT-LABEL] relabel of a cart line failed, cart change returned %s",n.status)}}catch(t){e("[CHECKOUT-LABEL] relabel of the cart lines failed",t)}},Et=(a,e="")=>{let t=null,i=!1;const s=It(e),n=f=>{t&&At(f,t,i)},r=new MutationObserver(f=>{for(const P of f)P.addedNodes.forEach(S=>{S instanceof Element&&xe(S,s,n)})});r.observe(document.documentElement,{childList:!0,subtree:!0});const o=window.fetch,c=function(f,P){if(t&&P?.body)try{const S=typeof f=="string"?f:f instanceof URL?f.href:String(f.url);s(S)&&(P.body=ke(P.body,t,i))}catch(S){a("[CHECKOUT-LABEL] could not label the request; cart add proceeds without the label",S)}return o.call(window,f,P)};window.fetch=c;const l=XMLHttpRequest.prototype,d=l.open,h=l.send,u=function(f,P,...S){this.__slctUrl=String(P),d.call(this,f,P,...S)},p=function(f){let P=f;if(t&&this.__slctUrl&&f)try{s(this.__slctUrl)&&(P=ke(f,t,i))}catch(S){a("[CHECKOUT-LABEL] could not label the request; cart add proceeds without the label",S)}h.call(this,P)};return l.open=u,l.send=p,{set:(f,P=!1)=>{t=f,i=f?P:!1,f?xe(document,s,n):_e()},teardown:()=>{t=null,i=!1,r.disconnect(),_e(),window.fetch===c&&(window.fetch=o),l.open===u&&(l.open=d),l.send===p&&(l.send=h)}}},_t=(a,e)=>{const t=new Set,i=(r,o)=>{if(t.has(o))return!1;try{return r.matches(o)}catch{return t.add(o),e.log("[CLICK] ignoring a selector the browser rejects: %s",o),!1}};let s;const n=r=>{if(r.isTrusted)try{const o=r.composedPath().filter(u=>u instanceof Element),c=a.filter(u=>u.selectors.some(p=>o.some(f=>i(f,p)))).map(u=>u.id),l=s&&s.control===o[0]?s.ids:[];s=void 0;const d=o.find(u=>u instanceof HTMLLabelElement)?.control;d&&!o.includes(d)&&(s={control:d,ids:c},setTimeout(()=>s=void 0));const h=c.filter(u=>!l.includes(u));h.length>0&&e.record(h)}catch(o){e.log("[CLICK] could not record a click",o)}};return window.addEventListener("click",n,!0),{teardown:()=>window.removeEventListener("click",n,!0)}};let Le=!1;const he=new Set(["index","collection","product","landing","cart","search","collectionList","blog","article","theme","urlRedirect"]),pe=a=>[...a].sort((e,t)=>e.isControl!==t.isControl?e.isControl?-1:1:e.id<t.id?-1:e.id>t.id?1:0),De=3e4,Rt=30*6e4,xt=3,Oe=()=>`exit:${themeId}`,ne=()=>rootPath.replace(/\/+$/,""),Lt=/^\/[a-z]{2}(?:-[a-z0-9]+)?(?=\/|$)/i,Ve=(a,e)=>a.endsWith(e)||e==="/"&&ne()!==""&&a===ne(),re="cache=0",ue=a=>{const e=a.search.replace(/&$/,"");e.slice(1).split("&").includes(re)||(a.search=e?`${e}&${re}`:`?${re}`)},Dt=()=>{const a=window.location.search.slice(1).split("&"),e=a.filter(i=>i!==re);if(e.length===a.length)return;const t=new URL(window.location.href);t.search=e.length?`?${e.join("&")}`:"";try{history.replaceState(history.state,"",t.href)}catch{}},J=a=>a.hypotheses.some(e=>U(e.type)),$e=a=>U(a);class Ot{DATA_SL_ATTRIBUTE_P="data-sl-attribute-p";DATA_SL_TEST_ID="data-sl-test-id";VIEWPORT_TRACK_THRESHOLD=.5;temporarySessionKey="Shoplift_Session";essentialSessionKey="Shoplift_Essential";analyticsSessionKey="Shoplift_Analytics";priceSelectorsSessionKey="Shoplift_PriceSelectors_v2";shop;host;eventHost;disableReferrerOverride;legacySessionKey;cssHideClass;testConfigs;inactiveTestConfigs;hiddenSubscriptionPlans;testsFilteredByAudience;sendPageView;shopliftDebug;gaConfig;telemetryEnabled;redirectCountersEnabled;anonymousVisitorIdEnabled;aSideHopEnabled;redirectLoopGuardEnabled;deterministicAssignmentEnabled;klaviyoGateTimeout=1e3;resolvedRegion=null;klaviyoMembership=null;state;subscriptionPreviewWarningCleanup=null;shopifyAnalyticsId;cookie=document.cookie;isSyncing=!1;inFlight=[];clickEventDefinitions;clickCollection;startUpDone=!1;isSyncingGA=!1;fetch;localStorageSet;localStorageGet;sessionStorageSet=window.sessionStorage.setItem.bind(window.sessionStorage);sessionStorageGet=window.sessionStorage.getItem.bind(window.sessionStorage);urlParams=new URLSearchParams(window.location.search);device;logHistory;activeViewportObservers=new Map;clientIdRetryCount=0;consentDeclined=!1;consentAnswered=!1;constructor(e,t,i,s,n,r,o,c,l,d,h,u,p=!1,f=!1,P=!1,S=!1,A=!1,_=[]){this.shop=e,this.host=t,this.eventHost=i,this.disableReferrerOverride=c,Dt(),this.logHistory=[],this.legacySessionKey=`SHOPLIFT_SESSION_${this.shop}`,this.cssHideClass=s?"shoplift-hide":"",this.testConfigs=d.map(g=>({...g,startAt:new Date(g.startAt),statusHistory:g.statusHistory.map(v=>({...v,createdAt:new Date(v.createdAt)}))})),this.inactiveTestConfigs=h,this.hiddenSubscriptionPlans=u,this.sendPageView=!!n,this.shopliftDebug=r===!0,this.telemetryEnabled=l===!0,this.redirectCountersEnabled=p===!0,this.anonymousVisitorIdEnabled=f===!0,this.aSideHopEnabled=P===!0,this.redirectLoopGuardEnabled=S===!0||this.aSideHopEnabled,this.deterministicAssignmentEnabled=A===!0,this.clickEventDefinitions=Array.isArray(_)?_:[],this.gaConfig=o!=={"sendEvents":false,"mode":"gtag"}?o:{sendEvents:!1},this.fetch=window.fetch.bind(window),this.localStorageSet=window.localStorage.setItem.bind(window.localStorage),this.localStorageGet=window.localStorage.getItem.bind(window.localStorage);const C=this.getDeviceType();this.device=C!=="tablet"?C:"mobile",this.state=this.loadState(),this.shopifyAnalyticsId=this.getShopifyAnalyticsId(),this.testsFilteredByAudience=d.filter(g=>g.status=="active"),window.__slReadCookie=g=>{const v=this.getCookie(g);if(v===null)return null;try{return decodeURIComponent(v)}catch{return v}},this.log("State Loaded",JSON.stringify(this.state))}deriveCategoryFromExistingTests(){if(!this.state.temporary.testCategory&&this.state.essential.visitorTests.length>0){const e=this.state.essential.visitorTests.some(t=>{if(!t.hypothesisId)return!1;const i=this.getHypothesis(t.hypothesisId);return i&&["theme","basicScript","price"].includes(i.type)});this.state.temporary.testCategory=e?"global":"conditional",this.persistTemporaryState(),this.log("Derived test category from existing visitorTests: %s",this.state.temporary.testCategory)}}async init(){try{if(this.log("Shoplift script initializing"),window.Shopify&&window.Shopify.designMode){this.log("Skipping script for design mode");return}if(window.location.href.includes("slScreenshot=true")){this.log("Skipping script for screenshot");return}if(window.location.hostname.endsWith(".edgemesh.com")){this.log("Skipping script for preview");return}if(window.location.href.includes("isShopliftMerchant")){const r=this.urlParams.get("isShopliftMerchant")==="true";this.log("Setting merchant session to %s",r),this.state.temporary.isMerchant=r,this.persistTemporaryState()}if(this.state.temporary.isMerchant){this.log("Setting up preview for merchant"),typeof window.shoplift!="object"&&this.setShopliftStub(),this.state.temporary.previewConfig||this.hidePage(),await this.initPreview(),document.querySelector("#sl-preview-bar-hide")?.remove();return}if(this.state.temporary.previewConfig=void 0,Fe(navigator.userAgent))return;const e=Date.now(),t=!this.state.temporary.lastSeen||e-this.state.temporary.lastSeen>1800*1e3;(!this.state.temporary.entryPage||t)&&(this.state.temporary.entryPage=K(window.location.href)),this.state.temporary.lastSeen=e,this.persistTemporaryState(),window.__slEntryPage=this.state.temporary.entryPage??"";const i=this.state.essential.visitorTests.filter(r=>r.hypothesisId&&!r.enrollmentDeferred&&+r.createdAt>Date.now()-6e4);if(i.length===0)this.sendDiagnosticTelemetry("page-landed",null);else for(const r of i)this.sendDiagnosticTelemetry("page-landed",r.testId,{hypothesisId:r.hypothesisId,isControl:r.assignedTo==="control",testType:r.testType??"unknown"});if(this.shopifyAnalyticsId=this.getShopifyAnalyticsId(),this.monitorConsentChange(),this.checkForThemePreview())return;if(this.clickEventDefinitions.length>0&&(this.clickCollection=_t(this.clickEventDefinitions,{log:(r,...o)=>this.log(r,...o),record:r=>this.recordClicks(r)})),!this.disableReferrerOverride&&this.state.temporary.originalReferrer!=null){this.log(`Overriding referrer from '${document.referrer}' to '${this.state.temporary.originalReferrer}'`);const r=this.state.temporary.originalReferrer;delete this.state.temporary.originalReferrer,this.persistTemporaryState(),Object.defineProperty(document,"referrer",{get:()=>r,enumerable:!0,configurable:!0})}if(this.needsKlaviyo(this.testConfigs,this.state.essential.visitorTests,this.state.analytics.visitor??this.buildBaseVisitor())&&this.ensureKlaviyoMembership(),await this.refreshVisitor(this.shopifyAnalyticsId),await this.handleVisitorTest()){this.log("Redirecting for visitor test");return}this.countRedirectLandings(),this.setShoplift(),this.showPage(),this.ensureCartAttributesForExistingPriceTests(!1);const n=this.state.essential.visitorTests.some(r=>(r.hypothesisId?this.getHypothesis(r.hypothesisId):void 0)?.subscriptionData!=null)||Object.values(this.state.temporary.testReservations??{}).some(r=>this.getHypothesis(r.hypothesisId)?.subscriptionData!=null);this.hiddenSubscriptionPlans&&!n&&(this.log(`[SUB-GLOBAL] Visitor not in subscription test — hiding ${this.hiddenSubscriptionPlans.planIds.length} B-side plans`),bt(this.hiddenSubscriptionPlans,r=>this.log(r))),await this.subscriptionSwap(),await this.subscriptionOneTimePrice(),await this.subscriptionPriceChange(),await this.finalize(),console.log("SHOPLIFT SCRIPT INITIALIZED!")}catch(e){if(e instanceof Z)return;throw e}finally{typeof window.shoplift!="object"&&this.setShopliftStub()}}getVariantColor(e){switch(e){case"a":return{text:"#141414",bg:"#E2E2E2"};case"b":return{text:"rgba(255, 255, 255, 1)",bg:"rgba(37, 99, 235, 1)"}}}getDefaultVariantTitle(e){return e.title?e.title:e.type==="price"?e.isControl?"Original prices":"Variant prices":e.isControl?"Original":"Untitled variant "+e.label.toUpperCase()}async initPreview(){const e=this.urlParams.get("previewConfig");if(e){this.state.temporary.previewConfig=void 0,this.log("Setting up the preview"),this.log("Found preview config, writing to temporary state");const t=await nt(e);if(this.state.temporary.previewConfig=t,this.state.temporary.previewConfig.testTypeCategory===$.Price){this.hidePage(!0);const s=this.state.temporary.previewConfig;let n=`${this.host}/api/dom-selectors/${s.storeId}/${s.testId}/${s.isDraft||!1}`;s.shopifyProductId&&(n+=`?productId=${s.shopifyProductId}`);const r=await this.makeJsonRequest({method:"get",url:n}).catch(o=>(this.log("Error getting domSelectors",o),null));if(s.variants.forEach(o=>o.domSelectors=r[o.id]?.domSelectors),s.isDraft){const o=`${this.host}/api/dom-selectors/${s.storeId}/${s.testId}/subscription-preview`,c=await this.makeJsonRequest({method:"get",url:o}).catch(l=>(this.log("No subscription preview data for draft (test may not have a subscription widget)",l),null));c?.subscriptionData&&s.variants.forEach(l=>{l.subscriptionData=c.subscriptionData,l.priceData=c.priceData})}}this.persistTemporaryState();const i=new URL(window.location.toString());i.searchParams.delete("previewConfig"),this.queueRedirect(i)}else if(this.state.temporary.previewConfig){this.showPage();const t=this.state.temporary.previewConfig;if(t.testTypeCategory===$.Template&&this.handleTemplatePreview(t)&&this.initPreviewControls(t),t.testTypeCategory===$.UrlRedirect&&this.handleUrlPreview(t)&&this.initPreviewControls(t),t.testTypeCategory===$.Script&&this.handleScriptPreview(t)&&this.initPreviewControls(t),t.testTypeCategory===$.Checkout&&this.handleCheckoutPreview(t)&&this.initPreviewControls(t),t.testTypeCategory===$.Price){const i=await this.handlePricePreview(t);t.isDraft?await this.handleSubscriptionPricePreview(t):await this.handleSubscriptionLivePreview(t),i&&this.initPreviewControls(t)}}}initPreviewControls(e){document.addEventListener("DOMContentLoaded",()=>{const t=e.variants.find(f=>f.id===e.currentVariant),i=t?.label||"a",s=e.variants,n=document.createElement("div");n.id="shoplift-preview-control";const r=document.createElement("div"),o=document.createElement("img");o.src=st,o.height=24,o.width=14,r.style.padding="0 16px",r.style.lineHeight="100%",r.appendChild(o),n.appendChild(r);const c=document.createElement("div");c.id="shoplift-preview-variant-selector";const l=document.createElement("button");l.id="shoplift-preview-variant-menu-trigger";const d=document.createElement("div");d.className="menu-variant-label",d.style.backgroundColor=this.getVariantColor(i).bg,d.style.color=this.getVariantColor(i).text,d.innerText=i.toUpperCase(),l.appendChild(d);const h=document.createElement("span");if(h.id="shoplift-preview-variant-title",h.innerText=t?this.getDefaultVariantTitle(t):"Untitled variant "+i.toUpperCase(),l.appendChild(h),s.length>1){const f=document.createElement("img");f.src=it,f.width=12,f.height=12,f.style.height="12px",f.style.width="12px",l.appendChild(f);const P=document.createElement("div");P.className="preview-variant-menu";for(const S of e.variants.filter(A=>A.id!==e.currentVariant)){const A=document.createElement("div");A.className="preview-variant-menu--item";const _=document.createElement("div");_.className="menu-variant-label",_.style.backgroundColor=this.getVariantColor(S.label).bg,_.style.color=this.getVariantColor(S.label).text,_.style.flexShrink="0",_.innerText=S.label.toUpperCase(),A.appendChild(_);const C=document.createElement("span");C.innerText=this.getDefaultVariantTitle(S),A.appendChild(C),A.addEventListener("click",()=>{this.pickVariant(S.id)}),P.appendChild(A)}c.appendChild(P),l.addEventListener("click",()=>{P.className!=="preview-variant-menu preview-variant-menu__visible"?P.classList.add("preview-variant-menu__visible"):P.classList.remove("preview-variant-menu__visible")}),document.addEventListener("click",S=>{S.target instanceof Element&&!l.contains(S.target)&&P.className==="preview-variant-menu preview-variant-menu__visible"&&P.classList.remove("preview-variant-menu__visible")})}else l.style.pointerEvents="none",d.style.margin="0";if(c.appendChild(l),n.appendChild(c),e.hasSubscription){this.subscriptionPreviewWarningCleanup?.();const f=Tt();n.appendChild(f.root),this.subscriptionPreviewWarningCleanup=f.cleanup}const u=document.createElement("div"),p=document.createElement("button");p.id="shoplift-exit-preview-button",p.innerText="Exit",u.appendChild(p),p.addEventListener("click",()=>{this.exitPreview()}),n.appendChild(u),document.body.appendChild(n),requestAnimationFrame(()=>{n.classList.add("visible")})}),this.ensureCartAttributesForExistingPriceTests(!0)}pickVariant(e){if(this.state.temporary.previewConfig){const t=this.state.temporary.previewConfig,i=new URL(window.location.toString());if(t.testTypeCategory===$.UrlRedirect){const s=t.variants.find(n=>n.id===t.currentVariant)?.redirectUrl;if(i.pathname===s){const n=t.variants.find(r=>r.id===e)?.redirectUrl;n&&(i.pathname=n)}}if(t.testTypeCategory===$.Template){const s=t.variants.find(n=>n.id===t.currentVariant)?.pathName;if(s&&i.pathname===s){const n=t.variants.find(r=>r.id===e)?.pathName;n&&n!==s&&(i.pathname=n)}}t.testTypeCategory===$.Checkout&&i.searchParams.set("slVariant",e),t.currentVariant=e,this.persistTemporaryState(),this.queueRedirect(i)}}handleCheckoutPreview(e){const t=this.urlParams.get("slVariant"),s=e.variants.find(n=>n.id===t)??e.variants.find(n=>n.id===e.currentVariant);return s?(e.currentVariant!==s.id&&(e.currentVariant=s.id,this.persistTemporaryState()),this.log("Setting up checkout preview"),this.setCheckoutLabel(s.id,!0),kt(s.id,(n,...r)=>this.log(n,...r)),!0):!1}exitPreview(){const e=new URL(window.location.toString());if(this.state.temporary.previewConfig?.testTypeCategory===$.Template&&e.searchParams.delete("view"),(this.state.temporary.previewConfig?.testTypeCategory===$.Script||this.state.temporary.previewConfig?.testTypeCategory===$.Checkout)&&e.searchParams.delete("slVariant"),this.state.temporary.previewConfig?.testTypeCategory===$.UrlRedirect){const i=this.state.temporary.previewConfig.variants.filter(n=>!n.isControl&&n.redirectUrl!==null).map(n=>n.redirectUrl),s=this.state.temporary.previewConfig.variants.find(n=>n.label==="a")?.redirectUrl;i.includes(e.pathname)&&s&&(e.pathname=s)}this.state.temporary.previewConfig?.testTypeCategory===$.Checkout&&this.setCheckoutLabel(null),this.state.temporary.isMerchant=!1,e.searchParams.delete("isShopliftMerchant"),this.state.temporary.previewConfig=void 0,this.persistTemporaryState(),this.subscriptionPreviewWarningCleanup?.(),this.subscriptionPreviewWarningCleanup=null,this.hidePage(),this.queueRedirect(e)}handleTemplatePreview(e){const t=e.currentVariant,i=e.variants.find(c=>c.id===t);if(!i)return!1;const s=e.variants.find(c=>c.isControl);if(!s)return!1;this.log("Setting up template preview for type",s.type);const n=new URL(window.location.toString()),r=n.searchParams.get("view"),o=i.type===s.type;return!o&&!i.isControl&&template.suffix===s.affix&&this.typeFromTemplate()===s.type&&i.pathName!==null?(this.log("Hit control template type, redirecting to the variant url"),this.hidePage(),n.pathname=i.pathName,this.queueRedirect(n),!0):(!i.isControl&&this.typeFromTemplate()==i.type&&template.suffix===s.affix&&o&&r!==(i.affix||"__DEFAULT__")&&(this.log("Template type and affix match control, updating the view param"),n.searchParams.delete("view"),this.log("Setting the new viewParam to",i.affix||"__DEFAULT__"),this.hidePage(),n.searchParams.set("view",i.affix||"__DEFAULT__"),this.queueRedirect(n)),r!==null&&r!==(i.affix||"__DEFAULT__")&&(n.searchParams.delete("view"),this.hidePage(),this.queueRedirect(n)),!0)}handleUrlPreview(e){const t=e.currentVariant,i=e.variants.find(r=>r.id===t),s=e.variants.find(r=>r.isControl)?.redirectUrl;if(!i)return!1;this.log("Setting up URL redirect preview");const n=new URL(window.location.toString());return n.pathname===s&&!i.isControl&&i.redirectUrl!==null&&(this.log("Url matches control, redirecting"),this.hidePage(),n.pathname=i.redirectUrl,this.queueRedirect(n)),!0}handleScriptPreview(e){const t=e.currentVariant,i=e.variants.find(r=>r.id===t);if(!i)return!1;this.log("Setting up script preview");const s=new URL(window.location.toString());return s.searchParams.get("slVariant")!==i.id&&(this.log("current id doesn't match the variant, redirecting"),s.searchParams.delete("slVariant"),this.log("Setting the new slVariantParam"),this.hidePage(),s.searchParams.set("slVariant",i.id),this.queueRedirect(s)),!0}async handlePricePreview(e){const t=e.currentVariant,i=e.variants.find(s=>s.id===t);return i?(this.log("Setting up price preview"),i.domSelectors&&i.domSelectors.length>0&&(F(document,{testId:e.testId,hypothesisId:i.id,selectors:i.domSelectors}),this.ensureCartAttributesForExistingPriceTests(!0)),!0):!1}async handleSubscriptionPricePreview(e){const t=e.variants.find(i=>i.id===e.currentVariant);t?.subscriptionData&&(this.log("Setting up subscription price preview"),await wt({id:t.id,isControl:t.isControl,subscriptionData:t.subscriptionData,priceData:t.priceData},(i,...s)=>this.log(i,...s)))}async handleSubscriptionLivePreview(e){this.testConfigs.find(s=>s.id===e.testId)?.hypotheses.find(s=>s.id===e.currentVariant)?.subscriptionData&&(this.log("Setting up subscription live preview"),this.subscriptionSwapDone=!1,this.subscriptionOneTimeDone=!1,this.subscriptionPriceDone=!1,await this.subscriptionSwap(),await this.subscriptionOneTimePrice(),await this.subscriptionPriceChange())}async finalize(){const e=await this.getCartState();e!==null&&this.queueCartUpdate(e),this.pruneStateAndSave(),this.startUpDone=!0,await this.syncAllEvents()}setShoplift(){this.log("Setting up public API");const t=this.urlParams.get("slVariant")==="true",i=t?null:this.urlParams.get("slVariant");window.shoplift={isHypothesisActive:async s=>{if(this.log("Script checking variant for hypothesis '%s'",s),t)return this.log("Forcing variant for hypothesis '%s'",s),!0;if(i!==null)return this.log("Forcing hypothesis '%s'",i),s===i;const n=this.testConfigs.find(o=>o.hypotheses.some(c=>c.id===s));if(!n)return this.log("No test found for hypothesis '%s'",s),!1;const r=this.state.essential.visitorTests.find(o=>o.testId===n.id);return r?(this.log("Active visitor test found",s),r.hypothesisId===s):(await this.manuallySplitVisitor(n),this.testConfigs.some(o=>o.hypotheses.some(c=>c.id===s&&this.state.essential.visitorTests.some(l=>l.hypothesisId===c.id))))},setAnalyticsConsent:async s=>{await this.onConsentChange(s,!0)},getVisitorData:()=>({visitor:this.state.analytics.visitor,visitorTests:this.state.essential.visitorTests.filter(s=>!s.isInvalid&&!s.enrollmentDeferred).map(s=>{const{shouldSendToGa:n,savedAt:r,redirectCount:o,anonAssigned:c,hop:l,hopNonce:d,hopThemeId:h,enrollmentDeferred:u,...p}=s;return p})})}}setShopliftStub(){this.log("Setting up stubbed public API");const t=this.urlParams.get("slVariant")==="true",i=t?null:this.urlParams.get("slVariant");window.shoplift={isHypothesisActive:s=>Promise.resolve(t||s===i),setAnalyticsConsent:()=>Promise.resolve(),getVisitorData:()=>({visitor:null,visitorTests:[]})}}async manuallySplitVisitor(e){this.log("Starting manual split for test '%s'",e.id),await this.handleVisitorTest([e])||this.showPage();const i=this.getReservationForTest(e.id);i&&!i.isRealized&&i.entryCriteriaKey&&(this.log("Realizing manual API reservation for test '%s'",e.id),this.realizeReservationForCriteria(i.entryCriteriaKey)),this.saveState(),this.syncAllEvents()}async handleVisitorTest(e){await this.filterTestsByAudience(this.testConfigs,this.state.analytics.visitor??this.buildBaseVisitor(),this.state.essential.visitorTests),this.pruneStaleVisitorTests(),this.deriveCategoryFromExistingTests(),this.clearStaleReservations();let t=e?e.filter(i=>this.testsFilteredByAudience.some(s=>s.id===i.id)):[...this.testsForUrl(this.testsFilteredByAudience),...this.domTestsForUrl(this.testsFilteredByAudience)];try{if(t.length===0)return this.log("No tests found"),!1;this.log("Checking for existing visitor test on page");const i=this.getCurrentVisitorHypothesis(t);if(i){this.log("Found current visitor test");const l=this.considerRedirect(i);return l&&(this.log("Redirecting for current visitor test"),this.redirect(i)),l}const s=this.getReservationForCurrentPage();if(s){this.log("Found matching reservation for current page: %s",s.testId);const l=this.getHypothesis(s.hypothesisId);if(l){l.type!=="price"&&this.realizeReservationForCriteria(s.entryCriteriaKey);const d=this.considerRedirect(l);return d&&this.redirect(l),d}}this.log("No active test relation for test page");const n=this.inactiveTestConfigs.filter(l=>this.testIsPaused(l)&&l.hypotheses.some(d=>this.state.essential.visitorTests.some(h=>h.hypothesisId===d.id))),r=this.testsForUrl(n.filter(l=>!J(l))).map(l=>l.id);if(r.length>0)return this.log("Visitor has paused tests for test page, skipping test assignment: %o",r),!1;if(n.some(J)&&(this.log("Visitor has a paused checkout test, skipping the checkout draw"),t=t.filter(l=>!J(l))),!this.state.temporary.testCategory){const l=this.testsFilteredByAudience.filter(h=>this.isGlobalEntryCriteria(this.getEntryCriteriaKey(h))),d=this.testsFilteredByAudience.filter(h=>!this.isGlobalEntryCriteria(this.getEntryCriteriaKey(h)));if(this.log("Category dice roll - global tests: %o, conditional tests: %o",l.map(h=>({id:h.id,title:h.title,criteria:this.getEntryCriteriaKey(h)})),d.map(h=>({id:h.id,title:h.title,criteria:this.getEntryCriteriaKey(h)}))),l.length>0&&d.length>0){const h=l.length,u=d.length,p=h+u,f=Math.random()*p;this.state.temporary.testCategory=f<h?"global":"conditional",this.log("Category dice roll: rolled %.2f of %d (global weight: %d, conditional weight: %d), selected '%s'",f,p,h,u,this.state.temporary.testCategory)}else l.length>0?(this.state.temporary.testCategory="global",this.log("Only global tests available, setting category to global")):(this.state.temporary.testCategory="conditional",this.log("Only conditional tests available, setting category to conditional"));this.persistTemporaryState()}const o=this.state.temporary.testCategory;if(this.log("Visitor test category: %s",o),o==="global"){const l=this.testsFilteredByAudience.filter(d=>!this.isGlobalEntryCriteria(this.getEntryCriteriaKey(d)));for(const d of l)this.markTestAsBlocked(d,"category:global");t=t.filter(d=>this.isGlobalEntryCriteria(this.getEntryCriteriaKey(d)))}else{const l=this.testsFilteredByAudience.filter(d=>this.isGlobalEntryCriteria(this.getEntryCriteriaKey(d)));for(const d of l)this.markTestAsBlocked(d,"category:conditional");t=t.filter(d=>!this.isGlobalEntryCriteria(this.getEntryCriteriaKey(d)))}if(t.length===0)return this.log("No tests remaining after category filter"),!1;this.createReservations(t);const c=this.getReservationForCurrentPage();if(c&&!c.isRealized){const l=this.getHypothesis(c.hypothesisId);if(l){l.type!=="price"&&this.realizeReservationForCriteria(c.entryCriteriaKey);const d=this.considerRedirect(l);return d&&(this.log("Redirecting for new test"),this.redirect(l)),d}}return!1}finally{this.includeInDomTests(),this.drawCheckoutPool(),this.applyCheckoutLabel(),this.saveState()}}isHeldByPausedCheckout(){return this.inactiveTestConfigs.filter(t=>this.testIsPaused(t)&&t.hypotheses.some(i=>this.state.essential.visitorTests.some(s=>s.hypothesisId===i.id))).some(J)}drawCheckoutPool(){if(this.state.temporary.testCategory!=="conditional"||this.isHeldByPausedCheckout())return;const e=this.testsFilteredByAudience.filter(J);e.length>0&&(this.createReservations(e),this.recordCheckoutReservation())}recordCheckoutReservation(){for(const e of Object.values(this.getActiveReservations())){if(e.isRealized||!U(e.testType))continue;const t=this.getHypothesis(e.hypothesisId);t&&this.queueAddVisitorToTest(e.testId,t)}}getCheckoutAssignment(){for(const e of this.state.essential.visitorTests){if(e.isInvalid||!e.hypothesisId)continue;const i=this.testsFilteredByAudience.find(s=>s.id===e.testId)?.hypotheses.find(s=>s.id===e.hypothesisId);if(i&&U(i.type))return i.id}for(const e of Object.values(this.getActiveReservations()))if(this.testConfigs.find(i=>i.id===e.testId)?.status==="active"&&U(e.testType))return e.hypothesisId;return null}checkoutLabelValue=null;checkoutLabelPreview=!1;checkoutLabel=null;cartAddFetch(){return this.checkoutLabel?window.fetch:this.fetch}applyCheckoutLabel(){this.setCheckoutLabel(this.getCheckoutAssignment())}setCheckoutLabel(e,t=!1){e===this.checkoutLabelValue&&t===this.checkoutLabelPreview||(e&&!this.checkoutLabel&&(this.checkoutLabel=Et((i,...s)=>this.log(i,...s),ne())),this.checkoutLabel?.set(e,t),this.checkoutLabelValue=e,this.checkoutLabelPreview=e?t:!1,this.log("Checkout label set to %s (preview: %s)",e,t))}includeInDomTests(){this.applyControlForAudienceFilteredPriceTests();const e=this.getDomTestsForCurrentUrl(),t=this.getVisitorDomHypothesis(e);for(const i of e){this.log("Evaluating dom test '%s'",i.id);const s=i.hypotheses.some(p=>p.type==="price");if(this.state.essential.visitorTests.find(p=>p.testId===i.id&&p.isInvalid&&!p.hypothesisId)){if(this.log("Visitor is blocked from test '%s', applying control prices if price test",i.id),s){const p=i.hypotheses.find(f=>f.isControl);p?.priceData&&(this.applyPriceTestWithMapLookup(i.id,p,[p],()=>{this.log("Control prices applied for blocked visitor, no metrics tracked")}),this.updatePriceTestHiddenInputs(i.id,"control",!1))}continue}const r=this.getReservationForTest(i.id);let o=null,c=!1;const l=t.find(p=>i.hypotheses.some(f=>p.id===f.id));if(r)o=this.getHypothesis(r.hypothesisId)??null,this.log("Using reserved hypothesis '%s' for test '%s'",r.hypothesisId,i.id);else if(l)o=l,this.log("Using existing hypothesis assignment for test '%s'",i.id);else if(s){const p=this.visitorActiveTestTypeWithReservations();p?(c=!0,this.log("Visitor already in test type '%s', treating as non-test for price test '%s'",p,i.id)):o=this.pickHypothesis(i)}else o=this.pickHypothesis(i);if(c&&s){const p=i.hypotheses.find(f=>f.isControl);p?.priceData&&(this.log("Applying control prices for non-test visitor on price test '%s' (Map-based)",i.id),this.applyPriceTestWithMapLookup(i.id,p,[p],()=>{this.log("Control prices applied for non-test visitor, no metrics tracked")}),this.updatePriceTestHiddenInputs(i.id,"control",!1));continue}if(!o){this.log("Failed to pick hypothesis for test");continue}this.sendDiagnosticTelemetry("assignment",i.id,{hypothesisId:o.id,isControl:o.isControl,testType:o.type});const d=i.bayesianRevision??4,h=o.type==="price",u=d>=5;if(h&&u){if(this.log(`Price test with Map-based lookup (v${d}): ${i.id}`),!o.priceData){this.log("No price data for hypothesis '%s', skipping",o.id);continue}const p=o.isControl?"control":"variant";this.log(`Setting up Map-based price test for ${p} (test: ${i.id})`),this.applyPriceTestWithMapLookup(i.id,o,i.hypotheses,f=>{const P=this.getReservationForTest(f);P&&!P.isRealized&&P.entryCriteriaKey?this.realizeReservationForCriteria(P.entryCriteriaKey):this.queueAddVisitorToTest(f,o),this.saveState(),this.queuePageView(window.location.pathname),this.syncAllEvents()});continue}if(h&&!u){this.log(`Price test without viewport tracking (v${d}): ${i.id}`);const p=this.getDomSelectorsForHypothesis(o);if(p.length===0)continue;F(document,{testId:i.id,hypothesisId:o.id,selectors:p},f=>{this.queueAddVisitorToTest(f,o),this.saveState(),this.queuePageView(window.location.pathname),this.syncAllEvents()});continue}if(!o.domSelectors||o.domSelectors.length===0){this.log("No selectors found, skipping hypothesis");continue}F(document,{testId:i.id,hypothesisId:o.id,selectors:o.domSelectors},p=>{this.queueAddVisitorToTest(p,o),this.saveState(),this.queuePageView(window.location.pathname),this.syncAllEvents()})}}considerRedirect(e){if(this.log("Considering redirect for hypothesis '%s'",e.id),e.isControl)return this.considerControlHop(e);if(e.type==="basicScript"||e.type==="manualScript")return this.log("Skipping redirect for script test"),!1;if(U(e.type))return this.log("Skipping redirect for checkout test"),!1;const t=this.state.essential.visitorTests.find(r=>r.hypothesisId===e.id),i=new URL(window.location.toString()),n=new URLSearchParams(window.location.search).get("view");if(e.type==="theme"){if(!(e.themeId===themeId)){if(this.log("Theme id '%s' is not hypothesis theme ID '%s'",e.themeId,themeId),this.isAppProxyPath())return this.log("On App Proxy path, skipping theme redirect to avoid infinite loop"),!1;const o=t&&t.themeId!==e.themeId&&(t.themeId===themeId||!this.isThemePreview());return!o&&this.isThemePreview()?(this.log("On non-test theme, skipping redirect"),!1):this.allowRedirect(e.id)?(o&&(this.log("On old theme, redirecting and updating local visitor"),t.themeId=e.themeId),this.log("Hiding page to redirect for theme test"),this.hidePage(),!0):!1}return!1}else if(e.type!=="dom"&&e.type!=="price"&&e.affix!==template.suffix&&e.affix!==n||e.redirectPath&&!Ve(i.pathname,e.redirectPath))return this.allowRedirect(e.id)?(this.log("Hiding page to redirect for template test"),this.hidePage(),!0):!1;return this.log("Not redirecting"),!1}allowRedirect(e){if(!this.redirectLoopGuardEnabled)return!0;const t=Date.now(),i=this.liveRedirectRecords(t),s=i.find(c=>c.key===e),n=this.arrivedVia(i,t),r=s?.stoppedUntil!==void 0?"stopped":this.redirectLoop(e,n);if(!r)return!0;const o=s??{key:e,nonce:"",at:t};return o.stoppedUntil??=t+Rt,r==="chain"&&n&&(n.stoppedUntil??=o.stoppedUntil),this.state.essential.redirectGuard=s?i:[...i,o],this.log("Redirect for '%s' loops (%s), not redirecting until %s",e,r,new Date(o.stoppedUntil)),r!=="stopped"&&this.sendRedirectStop(e,r),this.persistEssentialState(),!1}redirectLoop(e,t){if(t?.key===e)return"bounce";if(t&&(t.hops??0)+1>=xt)return"chain"}sendRedirectStop(e,t){const i=e.startsWith("exit:")?"preview-exit":this.state.essential.visitorTests.find(s=>s.hypothesisId===e)?.testId;i&&this.sendRedirectCount("stopped",i,e,t)}arrivedVia(e,t){return e.find(i=>i.nonce&&t-i.at<De&&window.location.hash===`#slr-${i.nonce}`)}recordRedirect(e,t){if(!this.redirectLoopGuardEnabled)return;const i=Date.now(),s=this.liveRedirectRecords(i),n=this.arrivedVia(s,i),r=n?(n.hops??0)+1:0;this.state.essential.redirectGuard=[...s.filter(o=>o.key!==e),{key:e,nonce:t,at:i,...r?{hops:r}:{}}]}liveRedirectRecords(e){return(this.state.essential.redirectGuard??[]).filter(t=>(t.stoppedUntil??t.at+De)>e)}redirect(e){if(this.log("Redirecting to hypothesis '%s'",e.id),e.isControl){this.hopControl(e);return}const t=new URL(window.location.toString());if(t.searchParams.delete("view"),e.redirectPath){const o=Lt.test(e.redirectPath)?"":ne();t.pathname=`${o}${e.redirectPath}`}else e.type==="theme"?this.previewTheme(t,e.themeId):e.type!=="urlRedirect"&&t.searchParams.set("view",e.affix);const i=this.state.essential.visitorTests.find(o=>o.hypothesisId===e.id)?.testId,s=t.pathname+t.search,n=window.location.pathname+window.location.search,r=K(t.hash);if(i&&s!==n&&!r){const o=this.markRedirectLanding(t,i);this.recordRedirect(e.id,o)}s!==n&&ue(t),s===n&&this.showPage(),this.queueRedirect(t)}considerControlHop(e){if(!this.aSideHopEnabled)return!1;const t=this.state.essential.visitorTests.find(i=>i.hypothesisId===e.id);return!t?.hop||(this.settleControlHop(t),t.hop!=="pending"&&t.hop!=="hopping")||K(window.location.hash)||e.type==="theme"&&(e.themeId!==themeId||this.isThemePreview()||this.isAppProxyPath())||(this.saveState(),!this.assignmentPersists(e.id))||!this.allowRedirect(e.id)?!1:(this.hidePage(),!0)}hopControl(e){const t=this.state.essential.visitorTests.find(n=>n.hypothesisId===e.id);if(t?.hop!=="pending"&&t?.hop!=="hopping")return;const i=new URL(window.location.toString());e.type==="theme"&&(this.previewTheme(i,e.themeId),t.hopThemeId=e.themeId);const s=i.pathname+i.search===window.location.pathname+window.location.search;if(s){const n=i.href.split("#")[0];i.href=/[?&]$/.test(n)?n.slice(0,-1):n+(n.includes("?")?"&":"?")}t.hopNonce=this.markRedirectLanding(i,t.testId,s),this.recordRedirect(e.id,t.hopNonce),ue(i),t.hop=t.hop==="pending"?"hopping":"retried",this.queueRedirect(i,s)}assignmentPersists(e){return[this.localStorageGet(this.essentialSessionKey),this.getCookie(this.essentialSessionKey,document.cookie)].some(t=>t?.includes(e)===!0)}settleControlHop(e){(e.hop==="hopping"||e.hop==="retried")&&e.hopNonce&&window.location.hash.endsWith(`slr-${e.hopNonce}`)&&(e.hop="hopped")}previewTheme(e,t){e.searchParams.set("_ab","0"),e.searchParams.set("_fd","0"),e.searchParams.set("_sc","1"),e.searchParams.set("preview_theme_id",t.toString())}markRedirectLanding(e,t,i=!1){const s=be(),n=lt({v:2,t,n:s,fh:ct(window.location.pathname+window.location.search),...i?{s:1}:{}});e.hash=`slr-${s}`;const r=new Date(Date.now()+3e4).toUTCString();return document.cookie=`shoplift_redirect=${n};domain=.${window.location.hostname};path=/;SameSite=Strict;expires=${r}`,s}async refreshVisitor(e){if(!this.state.essential.isFirstLoad||!this.testConfigs.some(n=>n.visitorOption!=="all"))return;const t=this.getCookie("_shopify_y")?"cookie":this.shopifyAnalyticsId?"pixel":"none";if(e===null){this.sendDiagnosticTelemetry("visitor-lookup",null,{outcome:"no-id",idSource:t});return}this.log("Refreshing visitor"),this.hidePage();const i=await this.getVisitor(e),s=i&&i.id?"found":"not-found";this.sendDiagnosticTelemetry("visitor-lookup",null,{outcome:s,idSource:t}),i&&i.id&&this.updateLocalVisitor(i)}buildBaseVisitor(){return{shopifyAnalyticsId:this.shopifyAnalyticsId,device:this.device,country:null,...this.state.essential.initialState}}getInitialState(){const e=this.getUTMValue("utm_source")??"",t=this.getUTMValue("utm_medium")??"",i=this.getUTMValue("utm_campaign")??"",s=this.getUTMValue("utm_content")??"",n=window.document.referrer,r=this.device;return{createdAt:new Date,utmSource:e,utmMedium:t,utmCampaign:i,utmContent:s,referrer:n,device:r}}checkForThemePreview(){return this.log("Checking for theme preview"),window.location.hostname.endsWith(".shopifypreview.com")?(this.log("on shopify preview domain"),document.querySelector("#sl-preview-bar-hide")?.remove(),!1):this.isThemePreview()?this.state.essential.visitorTests.some(e=>e.hopThemeId===themeId&&e.hypothesisId!=null&&this.getHypothesis(e.hypothesisId)?.themeId!==themeId)&&!this.state.essential.visitorTests.some(e=>e.hypothesisId!=null&&this.getHypothesis(e.hypothesisId)?.themeId===themeId)?(this.log("In control's hop preview of a theme the test has moved off, redirecting to main theme"),this.leavePreview()):this.state.essential.visitorTests.some(e=>e.isThemeTest&&e.hypothesisId!=null&&this.getHypothesis(e.hypothesisId)&&e.themeId===themeId)?(this.log("On active theme test, removing theme bar"),this.clearThemeBar(),!1):this.state.essential.visitorTests.some(e=>e.isThemeTest&&e.hypothesisId!=null&&!this.getHypothesis(e.hypothesisId)&&e.themeId===themeId)?(this.log("Visitor is on an inactive theme test, redirecting to main theme"),this.leavePreview()):this.state.essential.isFirstLoad?(this.log("No visitor found on theme preview, redirecting to main theme"),this.leavePreview()):this.inactiveTestConfigs.some(e=>e.hypotheses.some(t=>t.themeId===themeId))?(this.log("Current theme is an inactive theme test, redirecting to main theme"),this.leavePreview()):this.testConfigs.some(e=>e.hypotheses.some(t=>t.themeId===themeId))?(this.log("Falling back to clearing theme bar"),this.clearThemeBar(),!1):(this.log("No tests on current theme, skipping script"),document.querySelector("#sl-preview-bar-hide")?.remove(),!0):(this.log("Not on theme preview"),!1)}leavePreview(){return this.allowRedirect(Oe())?this.redirectToMainTheme():this.clearThemeBar(),!0}redirectToMainTheme(){this.hidePage();const e=new URL(window.location.toString());e.searchParams.set("preview_theme_id","");const t=e.pathname+e.search!==window.location.pathname+window.location.search;if(this.redirectLoopGuardEnabled&&t&&!K(e.hash)){const i=be();e.hash=`slr-${i}`,this.recordRedirect(Oe(),i)}t&&ue(e),this.queueRedirect(e)}testsForUrl(e){const t=new URL(window.location.href),i=this.typeFromTemplate();return e.filter(s=>s.hypotheses.some(n=>n.type!=="dom"&&n.type!=="price"&&(n.isControl&&n.type===i&&n.affix===template.suffix||n.type==="theme"||n.isControl&&n.type==="urlRedirect"&&n.redirectPath&&t.pathname.endsWith(n.redirectPath)||n.type==="basicScript"||U(n.type)))&&(s.ignoreTestViewParameterEnforcement||!t.searchParams.has("view")||s.hypotheses.map(n=>n.affix).includes(t.searchParams.get("view")??"")))}domTestsForUrl(e){const t=new URL(window.location.href);return e.filter(i=>i.hypotheses.some(s=>s.type!=="dom"&&s.type!=="price"?!1:s.type==="price"&&s.priceData&&s.priceData.variants.length>0?!0:s.domSelectors&&s.domSelectors.some(n=>new RegExp(ge(n)).test(K(t.toString())))))}needsKlaviyo(e,t,i){return e.some(s=>s.requiresKlaviyo&&!t.some(n=>n.testId===s.id)&&this.matchesTestSettings(s,i,this.visitorCreatedDuringTestActive(s.statusHistory)))}getKlaviyoIdentity(){const e=ae(ht(this.getCookie("__kla_id",document.cookie)));return{kx:ae(this.urlParams.get("_kx"))??(e?null:ae(new URL(this.state.temporary.entryPage??"",window.location.href).searchParams.get("_kx"))),exchangeId:e}}ensureKlaviyoMembership(){return this.klaviyoMembership??=this.resolveKlaviyoMembership().catch(e=>(this.log("Error resolving Klaviyo membership",e),{groups:[],known:!1})),this.klaviyoMembership}async resolveKlaviyoMembership(){const{kx:e,exchangeId:t}=this.getKlaviyoIdentity();if(!(e??t))return{groups:[],known:!1};this.log("Hiding page to resolve Klaviyo membership"),this.hidePage();const s=new URLSearchParams;e&&s.append("kx",e),t&&s.append("exchangeId",t);let n={groups:[],known:!1};try{const r=await this.makeJsonRequest({method:"get",url:`${this.host}/api/v1/storefront/klaviyo-groups/${encodeURIComponent(this.shop)}?${s}`,signal:AbortSignal.timeout(this.klaviyoGateTimeout)});n={groups:r?.groups??[],known:r?.known===!0}}catch(r){if(r instanceof Z)return r;this.log("Error getting Klaviyo groups",r)}return n}async filterTestsByAudience(e,t,i){const s=[],n=e.some(c=>(c.requiresRegion||c.requiresCountry)&&!i.some(l=>l.testId===c.id));this.resolvedRegion===null&&n&&(this.log("Hiding page to wait for Shopify region resolution"),this.hidePage(),await this.waitForResolvedRegion()),window.__slRegion=this.resolvedRegion??"";const r=this.resolvedRegion?this.resolvedRegion.slice(0,2):null;let o={groups:[],known:!1};if(this.needsKlaviyo(e,i,t)){const c=await this.ensureKlaviyoMembership();if(c instanceof Z)throw c;o=c}window.__slKlaviyoGroups=o.groups,window.__slKlaviyoKnown=o.known;for(const c of e){if(this.log("Checking audience for test '%s'",c.id),this.state.essential.visitorTests.some(h=>h.testId===c.id&&h.hypothesisId==null)){console.log(`Skipping blocked test '${c.id}'`);continue}const l=this.visitorCreatedDuringTestActive(c.statusHistory);(i.some(h=>h.testId===c.id&&(c.device==="all"||c.device===t.device&&c.device===this.device))||this.isTargetAudience(c,t,l,r))&&(this.log("Visitor is in audience for test '%s'",c.id),s.push(c))}this.testsFilteredByAudience=s}async waitForResolvedRegion(e=1500,t=50){const i=Date.now();for(;this.resolvedRegion===null&&Date.now()-i<e;)await new Promise(s=>window.setTimeout(s,t))}isTargetAudience(e,t,i,s){const n=this.getChannel(t);return this.matchesTestSettings(e,t,i)&&(e.targetAudiences.length===0||e.targetAudiences.reduce((r,o)=>r||o.reduce((c,l)=>c&&l(t,i,n,s),!0),!1))}matchesTestSettings(e,t,i){return(e.device==="all"||e.device===t.device&&e.device===this.device)&&(e.visitorOption==="all"||e.visitorOption==="new"&&i||e.visitorOption==="returning"&&!i)}visitorCreatedDuringTestActive(e){let t="";for(const i of e){if(this.state.analytics.visitor!==null&&this.state.analytics.visitor.createdAt<i.createdAt||this.state.essential.initialState.createdAt<i.createdAt)break;t=i.status}return t==="active"}getDomTestsForCurrentUrl(){return this.domTestsForUrl(this.testsFilteredByAudience)}getCurrentVisitorHypothesis(e){return e.flatMap(t=>t.hypotheses).find(t=>t.type!=="dom"&&t.type!=="price"&&!U(t.type)&&this.state.essential.visitorTests.some(i=>i.hypothesisId===t.id))}getVisitorDomHypothesis(e){return e.flatMap(t=>t.hypotheses).filter(t=>(t.type==="dom"||t.type==="price")&&this.state.essential.visitorTests.some(i=>i.hypothesisId===t.id))}getHypothesis(e){return this.testConfigs.filter(t=>t.hypotheses.some(i=>i.id===e)).map(t=>t.hypotheses.find(i=>i.id===e))[0]}getActiveAssignment(){if(this.state.temporary.isMerchant&&this.state.temporary.previewConfig){const t=this.state.temporary.previewConfig;return t.currentVariant&&t.testId?{testId:t.testId,hypothesisId:t.currentVariant}:null}const e=this.state.essential.visitorTests.find(t=>t.hypothesisId);return e?.hypothesisId?{testId:e.testId,hypothesisId:e.hypothesisId}:null}findActiveSubscriptionTestControl(){for(const e of this.testConfigs){const t=e.hypotheses.find(i=>i.isControl);if(t?.subscriptionData)return{testId:e.id,hypothesis:t}}return null}getDomSelectorsForHypothesis(e){if(!e)return[];if(e.domSelectors&&e.domSelectors.length>0)return e.domSelectors;if(e.priceData){const t=`${this.priceSelectorsSessionKey}_${e.id}`;try{const s=sessionStorage.getItem(t);if(s){const n=JSON.parse(s);return e.domSelectors=n,this.log("Loaded %d price selectors from cache for hypothesis '%s'",n.length,e.id),n}}catch{}const i=at(e.priceData);e.domSelectors=i;try{sessionStorage.setItem(t,JSON.stringify(i)),this.log("Generated and cached %d price selectors for hypothesis '%s'",i.length,e.id)}catch{this.log("Generated %d price selectors for hypothesis '%s' (cache unavailable)",i.length,e.id)}return i}return[]}hasThemeTest(e){return e.some(t=>t.hypotheses.some(i=>i.type==="theme"))}hasTestThatIsNotThemeTest(e){return e.some(t=>t.hypotheses.some(i=>i.type!=="theme"&&i.type!=="dom"&&i.type!=="price"))}hasThemeAndOtherTestTypes(e){return this.hasThemeTest(e)&&this.hasTestThatIsNotThemeTest(e)}testIsPaused(e){return e.status==="paused"||e.status==="incompatible"||e.status==="suspended"}visitorActiveTestType(){const e=this.state.essential.visitorTests.filter(t=>this.testConfigs.some(i=>i.hypotheses.some(s=>s.id==t.hypothesisId)));return e.length===0?null:e.some(t=>t.isThemeTest)?"theme":"templateOrUrlRedirect"}getReservationType(e){return e==="price"||this.isTemplateTestType(e)||U(e)?"deferred":"immediate"}isTemplateTestType(e){return["product","collection","landing","index","cart","search","blog","article","collectionList"].includes(e)}getEntryCriteriaKey(e){const t=e.hypotheses.find(i=>i.isControl);if(!t)return`unknown:${e.id}`;switch(t.type){case"theme":return"global:theme";case"basicScript":return"global:autoApi";case"price":return"global:price";case"checkout":return"conditional:checkout";case"manualScript":return`conditional:manualApi:${e.id}`;case"urlRedirect":return`conditional:url:${t.redirectPath||"unknown"}`;default:return`conditional:template:${t.type}`}}isGlobalEntryCriteria(e){return e.startsWith("global:")}groupTestsByEntryCriteria(e){const t=new Map;for(const i of e){const s=this.getEntryCriteriaKey(i),n=t.get(s)||[];n.push(i),t.set(s,n)}return t}doesCurrentPageMatchEntryCriteria(e){if(this.isGlobalEntryCriteria(e))return!0;if(e==="conditional:manualApi")return!1;if(e.startsWith("conditional:url:")){const t=e.replace("conditional:url:","");return window.location.pathname.endsWith(t)}if(e.startsWith("conditional:template:")){const t=e.replace("conditional:template:","");return this.typeFromTemplate()===t}return!1}hasActiveReservation(){const e=this.getActiveReservations();return Object.values(e).some(t=>!t.isRealized)}getActiveReservation(){const e=this.getActiveReservations();return Object.values(e).find(t=>!t.isRealized)??null}clearStaleReservations(){const e=this.state.temporary.testReservations;if(!e)return;let t=!1;for(const[i,s]of Object.entries(e)){const n=this.testConfigs.find(o=>o.id===s.testId);if(!n){this.log("Test '%s' no longer in config, clearing reservation for criteria '%s'",s.testId,i),delete e[i],t=!0;continue}if(n.status!=="active"){this.log("Test '%s' status is '%s', clearing reservation for criteria '%s'",s.testId,n.status,i),delete e[i],t=!0;continue}this.testsFilteredByAudience.some(o=>o.id===s.testId)||(this.log("Visitor no longer passes audience for test '%s', clearing reservation for criteria '%s'",s.testId,i),delete e[i],t=!0)}t&&this.persistTemporaryState()}createReservations(e){if(this.state.temporary.testReservations||(this.state.temporary.testReservations={}),this.state.temporary.rolledEntryCriteria||(this.state.temporary.rolledEntryCriteria=[]),this.state.temporary.testCategory==="global"){this.createSingleReservation(e,"global");return}const i=e.filter(o=>this.doesCurrentPageMatchEntryCriteria(this.getEntryCriteriaKey(o))),s=e.filter(o=>!this.doesCurrentPageMatchEntryCriteria(this.getEntryCriteriaKey(o)));this.log("Conditional tests split - matching current page: %d, not matching: %d",i.length,s.length),i.length>0&&this.log("Tests matching current page (same pool): %o",i.map(o=>({id:o.id,title:o.title,criteria:this.getEntryCriteriaKey(o)})));const n=`conditional:current-page:${this.typeFromTemplate()}`;if(i.length>0&&!this.state.temporary.rolledEntryCriteria.includes(n)){this.createSingleReservation(i,n);for(const o of i){const c=this.getEntryCriteriaKey(o);this.state.temporary.rolledEntryCriteria.includes(c)||this.state.temporary.rolledEntryCriteria.push(c)}}const r=this.groupTestsByEntryCriteria(s);for(const[o,c]of r){if(this.state.temporary.rolledEntryCriteria.includes(o)){this.log("Already rolled for criteria '%s', skipping",o);continue}if(c.some(S=>this.state.essential.visitorTests.some(A=>A.testId===S.id))){this.log("Visitor already has VT for criteria '%s', skipping",o),this.state.temporary.rolledEntryCriteria.push(o);continue}const d=[...c].sort((S,A)=>S.id.localeCompare(A.id));this.log("Test dice roll for criteria '%s' - available tests: %o",o,d.map(S=>({id:S.id,title:S.title})));const h=Math.floor(Math.random()*d.length),u=d[h];this.log("Test dice roll: picked index %d of %d, selected test '%s' (%s)",h+1,c.length,u.id,u.title);const p=this.pickHypothesis(u);if(!p){this.log("No hypothesis picked for test '%s'",u.id);continue}this.sendAssignmentTelemetry(u.id,p);const f=this.getReservationType(p.type),P={testId:u.id,hypothesisId:p.id,testType:p.type,reservationType:f,isThemeTest:p.type==="theme",themeId:p.themeId,createdAt:new Date,isRealized:!1,entryCriteriaKey:o,splits:this.hashRollSplits(u)};this.state.temporary.testReservations[o]=P,this.state.temporary.rolledEntryCriteria.push(o),this.log("Created %s reservation for test '%s' (criteria: %s)",f,u.id,o);for(const S of c)S.id!==u.id&&this.markTestAsBlocked(S,o)}this.persistTemporaryState()}createSingleReservation(e,t){if(this.state.temporary.rolledEntryCriteria.includes(t)){this.log("Already rolled for pool '%s', skipping",t);return}if(e.some(h=>this.state.essential.visitorTests.some(u=>u.testId===h.id&&!u.isInvalid))){this.log("Visitor already has VT for pool '%s', skipping",t),this.state.temporary.rolledEntryCriteria.push(t);return}if(e.length===0){this.log("No tests in pool '%s'",t);return}const s=[...e].sort((h,u)=>h.id.localeCompare(u.id));this.log("Test dice roll for pool '%s' - available tests: %o",t,s.map(h=>({id:h.id,title:h.title,criteria:this.getEntryCriteriaKey(h)})));const n=Math.floor(Math.random()*s.length),r=s[n];this.log("Test dice roll: picked index %d of %d, selected test '%s' (%s)",n,e.length,r.id,r.title);const o=this.pickHypothesis(r);if(!o){this.log("No hypothesis picked for test '%s'",r.id);return}this.sendAssignmentTelemetry(r.id,o);const c=this.getReservationType(o.type),l=this.getEntryCriteriaKey(r),d={testId:r.id,hypothesisId:o.id,testType:o.type,reservationType:c,isThemeTest:o.type==="theme",themeId:o.themeId,createdAt:new Date,isRealized:!1,entryCriteriaKey:l,splits:this.hashRollSplits(r)};this.state.temporary.testReservations[l]=d,this.state.temporary.rolledEntryCriteria.push(t),this.log("Created %s reservation for test '%s' from pool '%s' (criteria: %s)",c,r.id,t,l);for(const h of e)h.id!==r.id&&this.markTestAsBlocked(h,`pool:${t}`);this.persistTemporaryState()}markTestAsBlocked(e,t){this.state.essential.visitorTests.some(i=>i.testId===e.id)||(this.log("Blocking visitor from test '%s' (reason: %s)",e.id,t),this.state.essential.visitorTests.push({createdAt:new Date,testId:e.id,hypothesisId:null,isThemeTest:e.hypotheses.some(i=>i.type==="theme"),shouldSendToGa:!1,isSaved:!0,isInvalid:!0,themeId:void 0}))}realizeReservationForCriteria(e){const t=this.state.temporary.testReservations?.[e];if(!t)return this.log("No reservation found for criteria '%s'",e),!1;if(t.isRealized)return this.log("Reservation already realized for criteria '%s'",e),!1;if(this.state.essential.visitorTests.some(s=>s.testId===t.testId&&!s.isInvalid))return this.log("Visitor already assigned to test '%s'",t.testId),!1;const i=this.getHypothesis(t.hypothesisId);return i?(t.isRealized=!0,this.persistTemporaryState(),this.queueAddVisitorToTest(t.testId,i,t.splits),this.saveState(),this.log("Realized reservation for test '%s' (criteria: %s)",t.testId,e),!0):(this.log("Hypothesis '%s' not found",t.hypothesisId),!1)}getActiveReservations(){return this.state.temporary.testReservations??{}}getReservationForCurrentPage(){const e=this.getActiveReservations();for(const[t,i]of Object.entries(e)){if(i.isRealized)continue;const s=this.testConfigs.find(n=>n.id===i.testId);if(!(!s||s.status!=="active")&&this.doesCurrentPageMatchEntryCriteria(t))return i}return null}getReservationForTest(e){const t=this.getActiveReservations();return Object.values(t).find(i=>i.testId===e)??null}getReservationTestType(){const e=this.getActiveReservations(),t=Object.values(e);if(t.length===0)return null;for(const i of t)if(i.isThemeTest)return"theme";for(const i of t)if(i.testType==="price")return"price";return t.some(i=>!i.isRealized)?"templateOrUrlRedirect":null}hasPriceTests(e){return e.some(t=>t.hypotheses.some(i=>i.type==="price"))}_priceTestProductIds=null;getPriceTestProductIds(){if(this._priceTestProductIds)return this._priceTestProductIds;const e=new Set;for(const t of this.testConfigs)for(const i of t.hypotheses)if(i.type==="price"){for(const s of i.domSelectors||[]){const n=s.cssSelector.match(/data-sl-attribute-(?:p|cap)="(\d+)"/);n?.[1]&&e.add(n[1])}if(i.priceData?.variants)for(const[s]of i.priceData.variants)e.add(s)}return this._priceTestProductIds=e,this.log("Built price test product ID cache with %d products",e.size),e}isProductInAnyPriceTest(e){return this.getPriceTestProductIds().has(e)}visitorActiveTestTypeWithReservations(){const e=this.getActiveReservations();for(const n of Object.values(e)){if(n.isThemeTest)return"theme";if(n.testType==="price")return"price"}if(Object.values(e).some(n=>!n.isRealized)){if(this.state.temporary.testCategory==="global")for(const r of Object.values(e)){if(r.testType==="theme")return"theme";if(r.testType==="price")return"price";if(r.testType==="basicScript")return"theme"}return"templateOrUrlRedirect"}const i=this.state.essential.visitorTests.filter(n=>!n.isInvalid&&this.testConfigs.some(r=>r.hypotheses.some(o=>o.id===n.hypothesisId)));return i.length===0?null:i.some(n=>this.getHypothesis(n.hypothesisId)?.type==="price")?"price":i.some(n=>n.isThemeTest)?"theme":"templateOrUrlRedirect"}applyControlForAudienceFilteredPriceTests(){const e=this.testConfigs.filter(s=>s.status==="active"&&s.hypotheses.some(n=>n.type==="price"));if(e.length===0)return;const t=this.testsFilteredByAudience.filter(s=>s.hypotheses.some(n=>n.type==="price")),i=e.filter(s=>!t.some(n=>n.id===s.id));if(i.length!==0){this.log("Found %d price tests filtered by audience, applying control selectors",i.length);for(const s of i){const n=s.hypotheses.find(l=>l.isControl),r=this.getDomSelectorsForHypothesis(n);if(r.length===0){this.log("No control selectors for audience-filtered price test '%s'",s.id);continue}const o=new URL(window.location.href);r.some(l=>{try{return new RegExp(ge(l)).test(K(o.toString()))}catch{return!1}})&&(this.log("Applying control selectors for audience-filtered price test '%s'",s.id),F(document,{testId:s.id,hypothesisId:n.id,selectors:r},()=>{}),this.updatePriceTestHiddenInputs(s.id,"control",!1))}}}pickHypothesis(e){if(this.deterministicAssignmentEnabled){const n=pe(e.hypotheses),r=n.reduce((l,d)=>l+d.trafficPercentage,0);if(!(r>0))return n.find(l=>l.isControl)??n[0]??null;const{anonId:o}=this.state.essential;let c=(o?pt(`${e.id}:${o}`):Math.random())*r;for(const l of n){if(c<l.trafficPercentage)return l;c-=l.trafficPercentage}return n[n.length-1]}let t=Math.random();const i=e.hypotheses.reduce((n,r)=>n+r.visitorCount,0);return e.hypotheses.sort((n,r)=>n.isControl?r.isControl?0:-1:r.isControl?1:0).reduce((n,r)=>{if(n!==null)return n;const c=e.hypotheses.reduce((l,d)=>l&&d.visitorCount>20,!0)?r.visitorCount/i-r.trafficPercentage:0;return t<=r.trafficPercentage-c?r:(t-=r.trafficPercentage-c,null)},null)}hashRollSplits(e){if(!this.deterministicAssignmentEnabled||!this.state.essential.anonId)return;const t=pe(e.hypotheses).map(i=>i.trafficPercentage);return t.reduce((i,s)=>i+s,0)>0?t:void 0}typeFromTemplate(){switch(template.type){case"list-collections":return"collectionList";case"page":return"landing";case"article":case"blog":case"cart":case"collection":case"index":case"product":case"search":return template.type;default:return null}}queueRedirect(e,t=!1){this.saveState(),this.disableReferrerOverride||(this.log(`Saving temporary referrer override '${document.referrer}'`),this.state.temporary.originalReferrer=document.referrer,this.persistTemporaryState()),window.setTimeout(()=>{t?window.location.replace(e):window.location.assign(e)},0),window.setTimeout(()=>{this.syncAllEvents()},2e3)}scheduleRetrySync(){this.clientIdRetryCount>=5||(this.clientIdRetryCount++,window.setTimeout(()=>{this.syncAllEvents()},500))}async syncAllEvents(){const e=async()=>{if(this.isSyncing){window.setTimeout(()=>{(async()=>await e())()},500);return}try{if(this.isSyncing=!0,this.syncGAEvents(),this.shopifyAnalyticsId||(this.shopifyAnalyticsId=this.getShopifyAnalyticsId()),!this.shopifyAnalyticsId){this.scheduleRetrySync();return}this.syncAnonConsent(),await this.syncEvents()}finally{this.isSyncing=!1}};await e()}async syncEvents(){if(!this.state.essential.consentApproved||!this.shopifyAnalyticsId||this.state.analytics.queue.length===0)return;const e=this.state.analytics.queue.length,t=this.state.analytics.queue.splice(0,e);this.inFlight=t,this.log("Syncing %s events",e);try{const i={shopifyAnalyticsId:this.shopifyAnalyticsId,device:this.state.analytics.visitor?.device??this.device,...this.state.essential.initialState},s={shop:this.shop,visitorDetails:{...i,visitorId:this.savedVisitorIdFor(i.shopifyAnalyticsId)},events:this.state.essential.visitorTests.filter(r=>!r.isInvalid&&!r.isSaved&&!r.enrollmentDeferred&&r.hypothesisId!=null).map(r=>new Be(r.testId,r.hypothesisId,r.createdAt)).concat(t),shopifyRegion:this.resolvedRegion};await this.sendEvents(s),this.inFlight=[];for(const r of this.state.essential.visitorTests.filter(o=>!o.isInvalid&&!o.isSaved&&!o.enrollmentDeferred&&o.hypothesisId!=null))this.sendDiagnosticTelemetry("event-delivered",r.testId,{hypothesisId:r.hypothesisId,isControl:r.assignedTo==="control",testType:r.testType??"unknown"});const n=await this.getVisitor(this.shopifyAnalyticsId);n!==null&&this.updateLocalVisitor(n);for(const r of this.state.essential.visitorTests.filter(o=>!o.isInvalid&&!o.isSaved&&!o.enrollmentDeferred))r.isSaved=!0,r.savedAt=Date.now()}catch{this.state.analytics.queue.splice(0,0,...t)}finally{this.inFlight=[],this.saveState()}}syncGAEvents(){if(!this.gaConfig.sendEvents){if(Le)return;Le=!0,this.log("UseGtag is false — skipping GA Events");return}if(this.isSyncingGA){this.log("Already syncing GA - skipping GA events");return}const e=this.state.essential.visitorTests.filter(t=>t.shouldSendToGa);e.length!==0&&(this.isSyncingGA=!0,this.log("Syncing %s GA Events",e.length),Promise.allSettled(e.map(t=>this.sendGAEvent(t))).then(()=>this.log("All gtag events sent")).finally(()=>this.isSyncingGA=!1))}sendGAEvent(e){return new Promise(t=>{this.log("Sending GA Event for test %s, hypothesis %s",e.testId,e.hypothesisId);const i=()=>{this.log("GA acknowledged event for hypothesis %s",e.hypothesisId),e.shouldSendToGa=!1,this.persistEssentialState(),t()},s={exp_variant_string:`SL-${e.testId}-${e.hypothesisId}`};this.shopliftDebug&&Object.assign(s,{debug_mode:!0});function n(r,o,c){window.dataLayer=window.dataLayer||[],window.dataLayer.push(arguments)}this.gaConfig.mode==="gtag"?n("event","experience_impression",{...s,event_callback:i}):(window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"experience_impression",...s,eventCallback:i}))})}updateLocalVisitor(e){let t;({visitorTests:t,...this.state.analytics.visitor}=e),this.log("updateLocalVisitor - server returned %d tests: %o",t.length,t.map(s=>({testId:s.testId,hypothesisId:s.hypothesisId,isInvalid:s.isInvalid}))),this.log("updateLocalVisitor - local has %d tests: %o",this.state.essential.visitorTests.length,this.state.essential.visitorTests.map(s=>({testId:s.testId,hypothesisId:s.hypothesisId,isSaved:s.isSaved,isInvalid:s.isInvalid})));const i=300*1e3;for(const s of this.state.essential.visitorTests.filter(n=>n.isSaved&&(!n.savedAt||Date.now()-n.savedAt>i)&&!t.some(r=>r.testId===n.testId)))this.log("updateLocalVisitor - marking LOCAL test as INVALID (isSaved && not in server): testId=%s, hypothesisId=%s",s.testId,s.hypothesisId),s.isInvalid=!0;for(const s of t){const n=this.state.essential.visitorTests.findIndex(o=>o.testId===s.testId);if(!(n!==-1))this.log("updateLocalVisitor - ADDING server test (not found locally): testId=%s, hypothesisId=%s",s.testId,s.hypothesisId),this.state.essential.visitorTests.push(s);else{const o=this.state.essential.visitorTests.at(n);this.log("updateLocalVisitor - REPLACING local test with server test: testId=%s, local hypothesisId=%s -> server hypothesisId=%s, local isInvalid=%s -> false",s.testId,o?.hypothesisId,s.hypothesisId,o?.isInvalid),s.isInvalid=!1,s.shouldSendToGa=o?.shouldSendToGa??!1,s.testType=o?.testType,s.assignedTo=o?.assignedTo,s.testTitle=o?.testTitle,s.redirectCount=o?.hypothesisId===s.hypothesisId?o.redirectCount:void 0,s.anonAssigned=o?.anonAssigned,s.hop=o?.hypothesisId===s.hypothesisId?o.hop:void 0,s.hopNonce=o?.hypothesisId===s.hypothesisId?o.hopNonce:void 0,s.hopThemeId=o?.hopThemeId,this.state.essential.visitorTests.splice(n,1,s)}}this.log("updateLocalVisitor - FINAL local tests: %o",this.state.essential.visitorTests.map(s=>({testId:s.testId,hypothesisId:s.hypothesisId,isSaved:s.isSaved,isInvalid:s.isInvalid}))),this.state.analytics.visitor.storedAt=new Date}savedVisitorIdFor(e){const t=this.state.analytics.visitor;return t?.id&&t.shopifyAnalyticsId===this.shopifyAnalyticsId&&e===this.shopifyAnalyticsId?t.id:null}async getVisitor(e){try{return await this.makeJsonRequest({method:"get",url:`${this.eventHost}/api/v0/visitors/by-key/${this.shop}/${e}`})}catch{return null}}async sendEvents(e){await this.makeRequest({method:"post",url:`${this.eventHost}/api/v0/events`,data:JSON.stringify(e)})}sendAssignmentTelemetry(e,t){$e(t.type)||this.sendDiagnosticTelemetry("assignment",e,{hypothesisId:t.id,isControl:t.isControl,testType:t.type})}sendDiagnosticTelemetry(e,t,i){if(!this.telemetryEnabled||!navigator.sendBeacon)return;const s=this.state.essential.consentApproved,n=JSON.stringify({shop:this.shop,testId:t,checkpoint:e,device:this.device,...s?{visitorId:this.shopifyAnalyticsId??"unknown"}:{},clientTimestamp:Date.now(),consentApproved:s,hasConsentInteraction:this.state.essential.hasConsentInteraction,...i});navigator.sendBeacon(`${this.eventHost}/api/v0/telemetry`,new Blob([n],{type:"text/plain"}))}countRedirectLandings(){if(!this.redirectCountersEnabled)return;let e=!1;for(const t of this.state.essential.visitorTests){if(t.redirectCount!=="assigned"||!t.hypothesisId)continue;const i=this.getHypothesis(t.hypothesisId);!i||(t.assignedTo!=="variant"&&this.settleControlHop(t),!(t.assignedTo==="variant"?this.isOnRedirectTarget(i):t.hop==="hopped"))||this.sendRedirectCount("landed",t.testId,i.id)&&(t.redirectCount="landed",e=!0)}e&&this.persistEssentialState()}isOnRedirectTarget(e){if(e.type==="theme")return e.themeId===themeId;const t=new URL(window.location.toString());return e.redirectPath?Ve(t.pathname,e.redirectPath):this.typeFromTemplate()===e.type&&e.affix===template.suffix&&e.affix===t.searchParams.get("view")}sendRedirectCount(e,t,i,s){if(!navigator.sendBeacon)return!1;const n=JSON.stringify({shop:this.shop,testId:t,hypothesisId:i,stage:e,reason:s,consent:this.consentStatus()});return navigator.sendBeacon(`${this.eventHost}/api/v0/telemetry/redirect`,new Blob([n],{type:"text/plain"}))}sendAnonAssignment(e,t,i){const{anonId:s}=this.state.essential;if(!s||!navigator.sendBeacon)return!1;const n=pe(this.testConfigs.find(o=>o.id===e)?.hypotheses??[]),r=JSON.stringify({shop:this.shop,anonId:s,testId:e,hypothesisId:t.id,consent:this.consentStatus(),splits:i?.length===n.length?n.map((o,c)=>({hypothesisId:o.id,share:i[c]})):void 0});return navigator.sendBeacon(`${this.eventHost}/api/v0/events/anon/assigned`,new Blob([r],{type:"text/plain"}))}syncAnonConsent(){if(!this.anonymousVisitorIdEnabled||!navigator.sendBeacon)return;const{anonId:e,consentApproved:t,anonConsent:i,visitorTests:s}=this.state.essential;if(!e||!s.some(l=>l.anonAssigned))return;const n=t&&this.consentAnswered?"approved":this.consentDeclined?"declined":null,r=this.shopifyAnalyticsId??void 0;if(n===null||n==="approved"&&!r)return;const o=n==="approved"?{consent:n,analyticsId:r}:{consent:n};if(i?.consent===o.consent&&i.analyticsId===o.analyticsId)return;const c=JSON.stringify({shop:this.shop,anonId:e,consent:n,analyticsId:r});navigator.sendBeacon(`${this.eventHost}/api/v0/events/anon/consent`,new Blob([c],{type:"text/plain"}))&&(this.state.essential.anonConsent=o,this.persistEssentialState())}consentStatus(){const{consentApproved:e,hasConsentInteraction:t}=this.state.essential;return e?"approved":t?"declined":"unknown"}getUTMValue(e){return new URLSearchParams(window.location.search).get(e)||null}hidePage(e){this.log("Hiding page"),this.cssHideClass&&!window.document.documentElement.classList.contains(this.cssHideClass)&&(window.document.documentElement.classList.add(this.cssHideClass),e||setTimeout(this.removeAsyncHide(this.cssHideClass),2e3))}showPage(){this.cssHideClass&&this.removeAsyncHide(this.cssHideClass)()}getDeviceType(){function e(){let i=!1;return(function(s){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(s)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(s.substr(0,4)))&&(i=!0)})(navigator.userAgent||navigator.vendor),i}function t(){let i=!1;return(function(s){(/android|ipad|playbook|silk/i.test(s)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(s.substr(0,4)))&&(i=!0)})(navigator.userAgent||navigator.vendor),i}return e()?"mobile":t()?"tablet":"desktop"}removeAsyncHide(e){return()=>{e&&window.document.documentElement.classList.remove(e)}}async getCartState(){try{let e=await this.makeJsonRequest({method:"get",url:`${window.location.origin}/cart.js`});return e===null||(e.note===null&&(e=await this.makeJsonRequest({method:"post",url:`${window.location.origin}/cart/update.js`,data:JSON.stringify({note:""})})),e==null)?null:{token:e.token,total_price:e.total_price,total_discount:e.total_discount,currency:e.currency,items_subtotal_price:e.items_subtotal_price,items:e.items.map(t=>({quantity:t.quantity,variant_id:t.variant_id,key:t.key,price:t.price,final_line_price:t.final_line_price,sku:t.sku,product_id:t.product_id}))}}catch(e){return this.log("Error sending cart info",e),null}}ensureCartAttributesForExistingPriceTests(e){try{if(this.log("Checking visitor assignments for active price tests"),e&&this.state.temporary.previewConfig){const t=this.state.temporary.previewConfig;this.log("Using preview config for merchant:",t.testId);let i="variant";if(t.variants&&t.variants.length>0){const s=t.variants.find(n=>n.id===t.currentVariant);s&&s.isControl&&(i="control")}this.log("Merchant preview - updating hidden inputs:",t.testId,i),this.updatePriceTestHiddenInputs(t.testId,i,!0);return}for(const t of this.state.essential.visitorTests){const i=this.testConfigs.find(r=>r.id===t.testId);if(!i){this.log("Test config not found:",t.testId);continue}const s=i.hypotheses.find(r=>r.id===t.hypothesisId);if(!s||s.type!=="price")continue;const n=s.isControl?"control":"variant";this.log("Updating hidden inputs for price test:",t.testId,n),this.updatePriceTestHiddenInputs(t.testId,n,e)}}catch(t){this.log("Error ensuring cart attributes for existing price tests:",t)}}subscriptionSwapDone=!1;subscriptionHideWrongPlans=null;subscriptionPriceDone=!1;subscriptionUpdateOneTime=null;subscriptionOneTimeDone=!1;swapMap=null;slptValue=null;async subscriptionSwap(){await ft(this)}async subscriptionPriceChange(){await yt(this)}async subscriptionOneTimePrice(){await vt(this)}updatePriceTestHiddenInputs(e,t,i){try{this.cleanupPriceTestObservers();const s=`${e}:${t}:${i?"t":"f"}`,n=C=>{const g=C.getAttribute("data-sl-pid");if(!g)return!0;if(i&&this.state.temporary.previewConfig){const b=this.state.temporary.previewConfig,T=t==="control"?"a":"b",m=b.variants.find(w=>w.label===T);if(!m)return!1;for(const w of m.domSelectors||[]){const y=w.cssSelector.match(/data-sl-attribute-(?:p|cap)="(\d+)"/);if(y){const I=y[1];if(this.log(`Extracted ID from selector: ${I}, comparing to: ${g}`),I===g)return this.log("Product ID match found in preview config:",g,"variant:",m.label),!0}else this.log(`Could not extract ID from selector: ${w.cssSelector}`)}return this.log("No product ID match in preview config for:",g,"variant:",T),!1}const v=this.testConfigs.find(b=>b.id===e);if(!v)return this.log("Test config not found for testId:",e),!1;for(const b of v.hypotheses||[]){for(const T of b.domSelectors||[]){const m=T.cssSelector.match(/data-sl-attribute-(?:p|cap)="(\d+)"/);if(m&&m[1]===g)return this.log("Product ID match found in domSelectors:",g,"for test:",e),!0}if(b.priceData?.variants){for(const T of b.priceData.variants)if(T[0]===g)return this.log("Product ID match found in priceData:",g,"for test:",e),!0}}return this.log("No product ID match for:",g,"in test:",e),!1},r=new Set;let o=!1,c=null;const l=(C,g)=>{if(document.querySelectorAll("[data-sl-attribute-p]").forEach(b=>{if(b instanceof Element&&b.nodeType===Node.ELEMENT_NODE&&b.isConnected&&document.contains(b))try{C.observe(b,{childList:!0,subtree:!0,characterData:!0,characterDataOldValue:!0,attributes:!1})}catch(T){this.log(`Failed to observe element (${g}):`,T)}}),document.body&&document.body.isConnected)try{C.observe(document.body,{childList:!0,subtree:!0,characterData:!0,characterDataOldValue:!0,attributes:!1})}catch(b){this.log(`Failed to observe document.body (${g}):`,b)}},d=(C,g,v,b)=>{const T=C.filter(m=>{const w=m.cssSelector.match(/data-sl-attribute-(?:p|cap)="(\d+)"/);return w&&w[1]===b});this.log(`Applying ${v} DOM selectors, total: ${C.length}, filtered: ${T.length}`),T.length>0&&F(document,{testId:e,hypothesisId:g,selectors:T})},h=(C,g)=>{this.log(`Applying DOM selector changes for product ID: ${C}`),g.disconnect(),o=!0;try{if(i&&this.state.temporary.previewConfig){const v=t==="control"?"a":"b",b=this.state.temporary.previewConfig.variants.find(T=>T.label===v);if(!b?.domSelectors){this.log(`No DOM selectors found for preview variant: ${v}`);return}d(b.domSelectors,b.id,"preview config",C)}else{const v=this.testConfigs.find(T=>T.id===e);if(!v){this.log(`No test config found for testId: ${e}`);return}const b=v.hypotheses.find(T=>t==="control"?T.isControl:!T.isControl);if(!b?.domSelectors){this.log(`No DOM selectors found for assignment: ${t}`);return}d(b.domSelectors,b.id,"live config",C)}}finally{c!==null&&clearTimeout(c),c=window.setTimeout(()=>{o=!1,c=null,l(g,"reconnection"),this.log("Re-established innerHTML observer after DOM changes")},50)}},u=new MutationObserver(C=>{if(!o)for(const g of C){if(g.type!=="childList"&&g.type!=="characterData")continue;let v=g.target;g.type==="characterData"&&(v=g.target.parentElement||g.target.parentNode);let b=v,T=b.getAttribute("data-sl-attribute-p");for(;!T&&b.parentElement;)b=b.parentElement,T=b.getAttribute("data-sl-attribute-p");if(!T)continue;const m=b.innerHTML||b.textContent||"";let w="";g.type==="characterData"&&g.oldValue!==null&&(w=g.oldValue),this.log(`innerHTML changed on element with data-sl-attribute-p="${T}"`),w&&this.log(`Previous content: "${w}"`),this.log(`Current content: "${m}"`),h(T,u)}});l(u,"initial setup"),r.add(u);const p=new MutationObserver(C=>{C.forEach(g=>{g.addedNodes.forEach(v=>{if(v.nodeType===Node.ELEMENT_NODE){const b=v;P(b);const T=b.matches('input[name="properties[_slpt]"]')?[b]:b.querySelectorAll('input[name="properties[_slpt]"]');T.length>0&&this.log(`MutationObserver found ${T.length} new hidden input(s)`),T.forEach(m=>{const w=m.getAttribute("data-sl-pid");if(this.log(`MutationObserver checking new input with data-sl-pid="${w}"`),n(m))m.value!==s&&(m.value=s,this.log("Updated newly added hidden input:",s)),S(m);else{const y=m.getAttribute("data-sl-pid");y&&this.isProductInAnyPriceTest(y)?this.log("Preserving hidden input for product ID '%s' - belongs to a different price test",y):(m.remove(),this.log("Removed newly added non-matching hidden input for product ID:",y))}})}})})});r.add(p);const f=new MutationObserver(C=>{C.forEach(g=>{if(g.type==="attributes"&&g.attributeName==="data-sl-pid"){const v=g.target;if(this.log("AttributeObserver detected data-sl-pid attribute change on:",v.tagName),v.matches('input[name="properties[_slpt]"]')){const b=v,T=g.oldValue,m=b.getAttribute("data-sl-pid");this.log(`data-sl-pid changed from "${T}" to "${m}" - triggering payment placement updates`),n(b)?(b.value!==s&&(b.value=s,this.log("Updated hidden input after data-sl-pid change:",s)),m&&h(m,u),this.log("Re-running payment placement updates after variant change"),P(document.body)):m&&this.isProductInAnyPriceTest(m)?this.log("Preserving hidden input for product ID '%s' - belongs to a different price test",m):(b.remove(),this.log("Removed non-matching hidden input after data-sl-pid change:",m))}}})});r.add(f);const P=C=>{C.tagName==="SHOPIFY-PAYMENT-TERMS"&&(this.log("MutationObserver found new shopify-payment-terms element"),this.updateShopifyPaymentTerms(e,t));const g=C.querySelectorAll("shopify-payment-terms");g.length>0&&(this.log(`MutationObserver found ${g.length} shopify-payment-terms in added node`),this.updateShopifyPaymentTerms(e,t)),C.tagName==="AFTERPAY-PLACEMENT"&&(this.log("MutationObserver found new afterpay-placement element"),this.updateAfterpayPlacements(e,t,"afterpay"));const v=C.querySelectorAll("afterpay-placement");v.length>0&&(this.log(`MutationObserver found ${v.length} afterpay-placement in added node`),this.updateAfterpayPlacements(e,t,"afterpay")),C.tagName==="SQUARE-PLACEMENT"&&(this.log("MutationObserver found new square-placement element"),this.updateAfterpayPlacements(e,t,"square"));const b=C.querySelectorAll("square-placement");b.length>0&&(this.log(`MutationObserver found ${b.length} square-placement in added node`),this.updateAfterpayPlacements(e,t,"square")),C.tagName==="KLARNA-PLACEMENT"&&(this.log("MutationObserver found new klarna-placement element"),this.updateKlarnaPlacements(e,t));const T=C.querySelectorAll("klarna-placement");T.length>0&&(this.log(`MutationObserver found ${T.length} klarna-placement in added node`),this.updateKlarnaPlacements(e,t))},S=C=>{f.observe(C,{attributes:!0,attributeFilter:["data-sl-pid"],attributeOldValue:!0,subtree:!1});const g=C.getAttribute("data-sl-pid");this.log(`Started AttributeObserver on specific input with data-sl-pid="${g}"`)},A=()=>{const C=document.querySelectorAll('input[name="properties[_slpt]"]');this.log(`Found ${C.length} existing hidden inputs to check`),C.forEach(g=>{const v=g.getAttribute("data-sl-pid");this.log(`Checking existing input with data-sl-pid="${v}"`),n(g)?(g.value=s,this.log("Updated existing hidden input:",s),v&&(this.log("Applying initial DOM selector changes for existing product"),h(v,u)),S(g)):v&&this.isProductInAnyPriceTest(v)?this.log("Preserving hidden input for product ID '%s' - belongs to a different price test",v):(g.remove(),this.log("Removed non-matching hidden input for product ID:",v))})},_=()=>{document.body?(p.observe(document.body,{childList:!0,subtree:!0}),this.log("Started MutationObserver on document.body"),A(),P(document.body)):document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{document.body&&(p.observe(document.body,{childList:!0,subtree:!0}),this.log("Started MutationObserver after DOMContentLoaded"),A(),P(document.body))}):(this.log("Set timeout on observer"),setTimeout(_,10))};_(),window.__shopliftPriceTestObservers=r,window.__shopliftPriceTestValue=s,this.log("Set up DOM observer for price test hidden inputs")}catch(s){this.log("Error updating price test hidden inputs:",s)}}updateKlarnaPlacements(e,t){this.updatePlacementElements(e,t,"klarna-placement",(i,s)=>{i.setAttribute("data-purchase-amount",s.toString())})}cleanupPriceTestObservers(){const e=window.__shopliftPriceTestObservers;e&&(e.forEach(t=>{t.disconnect()}),e.clear(),this.log("Cleaned up existing price test observers")),delete window.__shopliftPriceTestObservers,delete window.__shopliftPriceTestValue}updateAfterpayPlacements(e,t,i="afterpay"){const s=i==="square"?"square-placement":"afterpay-placement";if(document.querySelectorAll(s).length===0){this.log(`No ${s} elements found on page - early return`);return}this.updatePlacementElements(e,t,s,(r,o)=>{if(i==="afterpay"){const c=(o/100).toFixed(2);r.setAttribute("data-amount",c)}else r.setAttribute("data-amount",o.toString())}),this.log("updateAfterpayPlacements completed")}updatePlacementElements(e,t,i,s){const n=document.querySelectorAll(i);if(n.length===0){this.log(`No ${i} elements found - early return`);return}let r;if(this.state.temporary.isMerchant&&this.state.temporary.previewConfig){const c=t==="control"?"a":"b",l=this.state.temporary.previewConfig.variants.find(d=>d.label===c);if(!l?.domSelectors){this.log(`No variant found for label ${c} in preview config for ${i}`);return}r=l.domSelectors,this.log(`Using preview config for ${i} in merchant mode, variant: ${c}`)}else{const c=this.testConfigs.find(d=>d.id===e);if(!c){this.log(`No testConfig found for id: ${e} - early return`);return}const l=c.hypotheses.find(d=>t==="control"?d.isControl:!d.isControl);if(!l?.domSelectors){this.log(`No hypothesis or domSelectors found for assignment: ${t} - early return`);return}r=l.domSelectors}const o=new RegExp(`${this.DATA_SL_ATTRIBUTE_P}=["'](\\d+)["']`);n.forEach(c=>{let l=null;const d=c.parentElement;if(d&&(l=d.querySelector('input[name="properties[_slpt]"]')),l||(l=c.querySelector('input[name="properties[_slpt]"]')),!l){this.log(`No hidden input found for ${i} element`);return}const h=l.getAttribute("data-sl-pid");if(!h){this.log("Hidden input has no data-sl-pid attribute - skipping");return}const u=r.find(S=>{const A=S.cssSelector.match(o);return A&&A[1]===h});if(!u){this.log(`No matching selector found for productId: ${h} - skipping element`);return}const p=u.actions.find(S=>S.scope==="price");if(!p?.value){this.log("No price action or value found - skipping element");return}const f=parseFloat(p.value.replace(/[^0-9.]/g,""));if(Number.isNaN(f)){this.log(`Invalid price "${p.value}" for product ${h} - skipping`);return}const P=Math.round(f*100);s(c,P)}),this.log(`updatePlacementElements completed for ${i}`)}updateShopifyPaymentTerms(e,t){const i=document.querySelectorAll("shopify-payment-terms");if(i.length===0)return;this.log("Store using shopify payments");let s;if(this.state.temporary.isMerchant&&this.state.temporary.previewConfig){const r=t==="control"?"a":"b",o=this.state.temporary.previewConfig.variants.find(c=>c.label===r);if(!o||!o.domSelectors){this.log(`No variant found for label ${r} in preview config`);return}s=o.domSelectors,this.log(`Using preview config for shopify-payment-terms in merchant mode, variant: ${r}`)}else{const r=this.testConfigs.find(c=>c.id===e);if(!r)return;const o=r.hypotheses.find(c=>t==="control"?c.isControl===!0:c.isControl===!1);if(!o||!o.domSelectors)return;s=o.domSelectors}const n=new RegExp(`${this.DATA_SL_ATTRIBUTE_P}=["'](\\d+)["']`);i.forEach(r=>{const o=r.getAttribute("variant-id");if(!o)return;const c=s.find(l=>{const d=l.cssSelector.match(n);return d&&d[1]===o});if(c){const l=c.actions.find(d=>d.scope==="price");if(l&&l.value){const d=r.getAttribute("shopify-meta");if(d)try{const h=JSON.parse(d);if(h.variants&&Array.isArray(h.variants)){const u=h.variants.find(p=>p.id?.toString()===o);if(u){u.full_price=l.value;const p=parseFloat(l.value.replace(/[^0-9.]/g,""));if(u.number_of_payment_terms&&u.number_of_payment_terms>1){const f=p/u.number_of_payment_terms;u.price_per_term=`$${f.toFixed(2)}`}r.setAttribute("shopify-meta",JSON.stringify(h))}}}catch(h){this.log("Error parsing/updating shoplift-meta:",h)}}}})}async makeJsonRequest(e){const t=await this.makeRequest(e);return t===null?null:JSON.parse(await t.text(),B)}async makeRequest(e){const{url:t,method:i,headers:s,data:n,signal:r}=e,o=new Headers;if(s)for(const l in s)o.append(l,s[l]);(!s||!s.Accept)&&o.append("Accept","application/json"),n!==void 0&&(!s||!s["Content-Type"])&&o.append("Content-Type","application/json"),(this.eventHost.includes("ngrok.io")||this.eventHost.includes("ngrok-free.app"))&&o.append("ngrok-skip-browser-warning","1234");const c=await this.fetch(t,{method:i,headers:o,body:n,signal:r});if(!c.ok){if(c.status===204)return null;if(c.status===422){const l=await c.json();if(typeof l<"u"&&l.isBot)throw new Z}throw new Error(`Error sending shoplift request ${c.status}`)}return c}queueAddVisitorToTest(e,t,i){if(this.state.essential.visitorTests.some(o=>o.testId===e))return;const s=this.testConfigs.find(o=>o.id===e),n=$e(t.type),r={createdAt:new Date,testId:e,hypothesisId:t.id,isThemeTest:t.type==="theme",themeId:t.themeId,isSaved:!1,isInvalid:!1,shouldSendToGa:!n,testType:t.type,assignedTo:t.isControl?"control":"variant",testTitle:s?.title,...n&&{enrollmentDeferred:n}};if(this.aSideHopEnabled&&t.isControl&&he.has(t.type)&&(r.hop="pending"),this.state.essential.visitorTests.push(r),this.redirectCountersEnabled&&he.has(t.type)&&this.sendRedirectCount("assigned",e,t.id)&&(r.redirectCount="assigned"),this.anonymousVisitorIdEnabled&&he.has(t.type)&&this.sendAnonAssignment(e,t,i)&&(r.anonAssigned=!0,this.syncAnonConsent()),t.type==="price"){const o=t.isControl?"control":"variant";this.log("Price test assignment detected, updating cart attributes:",e,o),this.updatePriceTestHiddenInputs(e,o,!1)}}queueCartUpdate(e){this.queueEvent(new We(e))}recordClicks(e){this.log("[CLICK] recorded %o",e);for(const t of e)this.queueEvent(new ze(t,window.location.pathname,window.location.search,template.type,template.suffix));this.saveState(),this.startUpDone&&this.syncAllEvents()}queuePageView(e){this.queueEvent(new Ke(e))}queueEvent(e){!this.state.essential.consentApproved&&this.state.essential.hasConsentInteraction||this.state.analytics.queue.length>10||this.state.analytics.queue.push(e)}legacyGetLocalStorageVisitor(){const e=this.localStorageGet(this.legacySessionKey);if(e)try{return JSON.parse(e,B)}catch{}return null}pruneStaleVisitorTests(){this.state.essential.visitorTests=this.state.essential.visitorTests.filter(e=>this.testConfigs.some(t=>t.id==e.testId)||this.inactiveTestConfigs.filter(t=>this.testIsPaused(t)).some(t=>t.id===e.testId))}pruneStateAndSave(){this.pruneStaleVisitorTests(),this.saveState()}saveState(){this.persistEssentialState(),this.persistAnalyticsState()}loadState(){const e=this.loadAnalyticsState(),t={analytics:e,essential:this.loadEssentialState(e),temporary:this.loadTemporaryState()},i=this.legacyGetLocalStorageVisitor(),s=this.legacyGetCookieVisitor(),n=[i,s].filter(r=>r!==null).sort((r,o)=>+o.storedAt-+r.storedAt)[0];return t.analytics.visitor===null&&n&&({visitorTests:t.essential.visitorTests,...t.analytics.visitor}=n,t.essential.isFirstLoad=!1,t.essential.initialState={createdAt:n.createdAt,referrer:n.referrer,utmCampaign:n.utmCampaign,utmContent:n.utmContent,utmMedium:n.utmMedium,utmSource:n.utmSource,device:n.device},this.deleteCookie("SHOPLIFT"),this.deleteLocalStorage(this.legacySessionKey)),!t.essential.consentApproved&&t.essential.hasConsentInteraction&&this.deleteLocalStorage(this.analyticsSessionKey),t}loadEssentialState(e){const t=this.loadLocalStorage(this.essentialSessionKey),i=this.loadCookie(this.essentialSessionKey),s=this.getInitialState();e.visitor?.device&&(s.device=e.visitor.device);const n={timestamp:new Date,consentApproved:!1,hasConsentInteraction:!1,debugMode:!1,initialState:s,visitorTests:[],isFirstLoad:!0},r=[t,i].filter(o=>o!==null).sort((o,c)=>+c.timestamp-+o.timestamp)[0]??n;if(r.initialState||(e.visitor!==null?r.initialState=e.visitor:(r.initialState=s,r.initialState.createdAt=r.timestamp)),this.anonymousVisitorIdEnabled)r.anonId||(r.anonId=this.mintAnonId());else{delete r.anonId,delete r.anonConsent;for(const o of r.visitorTests)delete o.anonAssigned}if(!this.aSideHopEnabled)for(const o of r.visitorTests)delete o.hop,delete o.hopNonce;return r}mintAnonId(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():void 0}loadAnalyticsState(){const e=this.loadLocalStorage(this.analyticsSessionKey),t=this.loadCookie(this.analyticsSessionKey),i={timestamp:new Date,visitor:null,queue:[]},s=[e,t].filter(n=>n!==null).sort((n,r)=>+r.timestamp-+n.timestamp)[0]??i;return s.queue.length===0&&e&&e.queue.length>1&&(s.queue=e.queue),s}loadTemporaryState(){const e=this.sessionStorageGet(this.temporarySessionKey),t=e?JSON.parse(e,B):null,i=this.loadCookie(this.temporarySessionKey);return t??i??{isMerchant:!1,timestamp:new Date}}persistEssentialState(){this.log("Persisting essential state"),this.state.essential.isFirstLoad=!1,this.state.essential.timestamp=new Date,this.persistLocalStorageState(this.essentialSessionKey,this.state.essential),this.persistCookieState(this.essentialSessionKey,this.state.essential)}persistAnalyticsState(){this.log("Persisting analytics state"),this.state.essential.consentApproved&&(this.state.analytics.timestamp=new Date,this.persistLocalStorageState(this.analyticsSessionKey,{...this.state.analytics,queue:[...this.inFlight,...this.state.analytics.queue]}),this.persistCookieState(this.analyticsSessionKey,{...this.state.analytics,queue:[]}))}persistTemporaryState(){this.log("Setting temporary session state"),this.state.temporary.timestamp=new Date,this.sessionStorageSet(this.temporarySessionKey,JSON.stringify(this.state.temporary)),this.persistCookieState(this.temporarySessionKey,this.state.temporary,!0)}loadLocalStorage(e){const t=this.localStorageGet(e);if(t===null)return null;try{return JSON.parse(t,B)}catch{return null}}loadCookie(e){const t=this.getCookie(e);if(t===null)return null;try{return JSON.parse(t,B)}catch{return null}}persistLocalStorageState(e,t){this.localStorageSet(e,JSON.stringify(t))}persistCookieState(e,t,i=!1){const s=JSON.stringify(t),n=i?"":`expires=${new Date(new Date().getTime()+864e5*365).toUTCString()};`;document.cookie=`${e}=${s};domain=.${window.location.hostname};path=/;SameSite=Strict;${n}`}deleteCookie(e){const t=new Date(0).toUTCString();document.cookie=`${e}=;domain=.${window.location.hostname};path=/;expires=${t};`}deleteLocalStorage(e){window.localStorage.removeItem(e)}getChannel(e){return[{"name":"cross-network","test":(v) => new RegExp(".*cross-network.*", "i").test(v.utmCampaign)},{"name":"direct","test":(v) => v.utmSource === "" && v.utmMedium === ""},{"name":"paid-shopping","test":(v) => (new RegExp("^(?:Google|IGShopping|aax-us-east\.amazon-adsystem\.com|aax\.amazon-adsystem\.com|alibaba|alibaba\.com|amazon|amazon\.co\.uk|amazon\.com|apps\.shopify\.com|checkout\.shopify\.com|checkout\.stripe\.com|cr\.shopping\.naver\.com|cr2\.shopping\.naver\.com|ebay|ebay\.co\.uk|ebay\.com|ebay\.com\.au|ebay\.de|etsy|etsy\.com|m\.alibaba\.com|m\.shopping\.naver\.com|mercadolibre|mercadolibre\.com|mercadolibre\.com\.ar|mercadolibre\.com\.mx|message\.alibaba\.com|msearch\.shopping\.naver\.com|nl\.shopping\.net|no\.shopping\.net|offer\.alibaba\.com|one\.walmart\.com|order\.shopping\.yahoo\.co\.jp|partners\.shopify\.com|s3\.amazonaws\.com|se\.shopping\.net|shop\.app|shopify|shopify\.com|shopping\.naver\.com|shopping\.yahoo\.co\.jp|shopping\.yahoo\.com|shopzilla|shopzilla\.com|simplycodes\.com|store\.shopping\.yahoo\.co\.jp|stripe|stripe\.com|uk\.shopping\.net|walmart|walmart\.com)$", "i").test(v.utmSource) || new RegExp("^(.*(([^a-df-z]|^)shop|shopping).*)$", "i").test(v.utmCampaign)) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"paid-search","test":(v) => new RegExp("^(?:360\.cn|alice|aol|ar\.search\.yahoo\.com|ask|at\.search\.yahoo\.com|au\.search\.yahoo\.com|auone|avg|babylon|baidu|biglobe|biglobe\.co\.jp|biglobe\.ne\.jp|bing|br\.search\.yahoo\.com|ca\.search\.yahoo\.com|centrum\.cz|ch\.search\.yahoo\.com|cl\.search\.yahoo\.com|cn\.bing\.com|cnn|co\.search\.yahoo\.com|comcast|conduit|daum|daum\.net|de\.search\.yahoo\.com|dk\.search\.yahoo\.com|dogpile|dogpile\.com|duckduckgo|ecosia\.org|email\.seznam\.cz|eniro|es\.search\.yahoo\.com|espanol\.search\.yahoo\.com|exalead\.com|excite\.com|fi\.search\.yahoo\.com|firmy\.cz|fr\.search\.yahoo\.com|globo|go\.mail\.ru|google|google-play|hk\.search\.yahoo\.com|id\.search\.yahoo\.com|in\.search\.yahoo\.com|incredimail|it\.search\.yahoo\.com|kvasir|lens\.google\.com|lite\.qwant\.com|lycos|m\.baidu\.com|m\.naver\.com|m\.search\.naver\.com|m\.sogou\.com|mail\.rambler\.ru|mail\.yandex\.ru|malaysia\.search\.yahoo\.com|msn|msn\.com|mx\.search\.yahoo\.com|najdi|naver|naver\.com|news\.google\.com|nl\.search\.yahoo\.com|no\.search\.yahoo\.com|ntp\.msn\.com|nz\.search\.yahoo\.com|onet|onet\.pl|pe\.search\.yahoo\.com|ph\.search\.yahoo\.com|pl\.search\.yahoo\.com|play\.google\.com|qwant|qwant\.com|rakuten|rakuten\.co\.jp|rambler|rambler\.ru|se\.search\.yahoo\.com|search-results|search\.aol\.co\.uk|search\.aol\.com|search\.google\.com|search\.smt\.docomo\.ne\.jp|search\.ukr\.net|secureurl\.ukr\.net|seznam|seznam\.cz|sg\.search\.yahoo\.com|so\.com|sogou|sogou\.com|sp-web\.search\.auone\.jp|startsiden|startsiden\.no|suche\.aol\.de|terra|th\.search\.yahoo\.com|tr\.search\.yahoo\.com|tut\.by|tw\.search\.yahoo\.com|uk\.search\.yahoo\.com|ukr|us\.search\.yahoo\.com|virgilio|vn\.search\.yahoo\.com|wap\.sogou\.com|webmaster\.yandex\.ru|websearch\.rakuten\.co\.jp|yahoo|yahoo\.co\.jp|yahoo\.com|yandex|yandex\.by|yandex\.com|yandex\.com\.tr|yandex\.fr|yandex\.kz|yandex\.ru|yandex\.ua|yandex\.uz|zen\.yandex\.ru)$", "i").test(v.utmSource) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"paid-social","test":(v) => new RegExp("^(?:43things|43things\.com|51\.com|5ch\.net|Hatena|ImageShack|academia\.edu|activerain|activerain\.com|activeworlds|activeworlds\.com|addthis|addthis\.com|airg\.ca|allnurses\.com|allrecipes\.com|alumniclass|alumniclass\.com|ameba\.jp|ameblo\.jp|americantowns|americantowns\.com|amp\.reddit\.com|ancestry\.com|anobii|anobii\.com|answerbag|answerbag\.com|answers\.yahoo\.com|aolanswers|aolanswers\.com|apps\.facebook\.com|ar\.pinterest\.com|artstation\.com|askubuntu|askubuntu\.com|asmallworld\.com|athlinks|athlinks\.com|away\.vk\.com|awe\.sm|b\.hatena\.ne\.jp|baby-gaga|baby-gaga\.com|babyblog\.ru|badoo|badoo\.com|bebo|bebo\.com|beforeitsnews|beforeitsnews\.com|bharatstudent|bharatstudent\.com|biip\.no|biswap\.org|bit\.ly|blackcareernetwork\.com|blackplanet|blackplanet\.com|blip\.fm|blog\.com|blog\.feedspot\.com|blog\.goo\.ne\.jp|blog\.naver\.com|blog\.yahoo\.co\.jp|blogg\.no|bloggang\.com|blogger|blogger\.com|blogher|blogher\.com|bloglines|bloglines\.com|blogs\.com|blogsome|blogsome\.com|blogspot|blogspot\.com|blogster|blogster\.com|blurtit|blurtit\.com|bookmarks\.yahoo\.co\.jp|bookmarks\.yahoo\.com|br\.pinterest\.com|brightkite|brightkite\.com|brizzly|brizzly\.com|business\.facebook\.com|buzzfeed|buzzfeed\.com|buzznet|buzznet\.com|cafe\.naver\.com|cafemom|cafemom\.com|camospace|camospace\.com|canalblog\.com|care\.com|care2|care2\.com|caringbridge\.org|catster|catster\.com|cbnt\.io|cellufun|cellufun\.com|centerblog\.net|chat\.zalo\.me|chegg\.com|chicagonow|chicagonow\.com|chiebukuro\.yahoo\.co\.jp|classmates|classmates\.com|classquest|classquest\.com|co\.pinterest\.com|cocolog-nifty|cocolog-nifty\.com|copainsdavant\.linternaute\.com|couchsurfing\.org|cozycot|cozycot\.com|cross\.tv|crunchyroll|crunchyroll\.com|cyworld|cyworld\.com|cz\.pinterest\.com|d\.hatena\.ne\.jp|dailystrength\.org|deluxe\.com|deviantart|deviantart\.com|dianping|dianping\.com|digg|digg\.com|diigo|diigo\.com|discover\.hubpages\.com|disqus|disqus\.com|dogster|dogster\.com|dol2day|dol2day\.com|doostang|doostang\.com|dopplr|dopplr\.com|douban|douban\.com|draft\.blogger\.com|draugiem\.lv|drugs-forum|drugs-forum\.com|dzone|dzone\.com|edublogs\.org|elftown|elftown\.com|epicurious\.com|everforo\.com|exblog\.jp|extole|extole\.com|facebook|facebook\.com|faceparty|faceparty\.com|fandom\.com|fanpop|fanpop\.com|fark|fark\.com|fb|fb\.me|fc2|fc2\.com|feedspot|feministing|feministing\.com|filmaffinity|filmaffinity\.com|flickr|flickr\.com|flipboard|flipboard\.com|folkdirect|folkdirect\.com|foodservice|foodservice\.com|forums\.androidcentral\.com|forums\.crackberry\.com|forums\.imore\.com|forums\.nexopia\.com|forums\.webosnation\.com|forums\.wpcentral\.com|fotki|fotki\.com|fotolog|fotolog\.com|foursquare|foursquare\.com|free\.facebook\.com|friendfeed|friendfeed\.com|fruehstueckstreff\.org|fubar|fubar\.com|gaiaonline|gaiaonline\.com|gamerdna|gamerdna\.com|gather\.com|geni\.com|getpocket\.com|glassboard|glassboard\.com|glassdoor|glassdoor\.com|godtube|godtube\.com|goldenline\.pl|goldstar|goldstar\.com|goo\.gl|gooblog|goodreads|goodreads\.com|google\+|googlegroups\.com|googleplus|govloop|govloop\.com|gowalla|gowalla\.com|gree\.jp|groups\.google\.com|gulli\.com|gutefrage\.net|habbo|habbo\.com|hi5|hi5\.com|hootsuite|hootsuite\.com|houzz|houzz\.com|hoverspot|hoverspot\.com|hr\.com|hu\.pinterest\.com|hubculture|hubculture\.com|hubpages\.com|hyves\.net|hyves\.nl|ibibo|ibibo\.com|id\.pinterest\.com|identi\.ca|ig|imageshack\.com|imageshack\.us|imvu|imvu\.com|in\.pinterest\.com|insanejournal|insanejournal\.com|instagram|instagram\.com|instapaper|instapaper\.com|internations\.org|interpals\.net|intherooms|intherooms\.com|irc-galleria\.net|is\.gd|italki|italki\.com|jammerdirect|jammerdirect\.com|jappy\.com|jappy\.de|kaboodle\.com|kakao|kakao\.com|kakaocorp\.com|kaneva|kaneva\.com|kin\.naver\.com|l\.facebook\.com|l\.instagram\.com|l\.messenger\.com|last\.fm|librarything|librarything\.com|lifestream\.aol\.com|line|line\.me|linkedin|linkedin\.com|listal|listal\.com|listography|listography\.com|livedoor\.com|livedoorblog|livejournal|livejournal\.com|lm\.facebook\.com|lnkd\.in|m\.blog\.naver\.com|m\.cafe\.naver\.com|m\.facebook\.com|m\.kin\.naver\.com|m\.vk\.com|m\.yelp\.com|mbga\.jp|medium\.com|meetin\.org|meetup|meetup\.com|meinvz\.net|meneame\.net|menuism\.com|messages\.google\.com|messages\.yahoo\.co\.jp|messenger|messenger\.com|mix\.com|mixi\.jp|mobile\.facebook\.com|mocospace|mocospace\.com|mouthshut|mouthshut\.com|movabletype|movabletype\.com|mubi|mubi\.com|my\.opera\.com|myanimelist\.net|myheritage|myheritage\.com|mylife|mylife\.com|mymodernmet|mymodernmet\.com|myspace|myspace\.com|netvibes|netvibes\.com|news\.ycombinator\.com|newsshowcase|nexopia|ngopost\.org|niconico|nicovideo\.jp|nightlifelink|nightlifelink\.com|ning|ning\.com|nl\.pinterest\.com|odnoklassniki\.ru|odnoklassniki\.ua|okwave\.jp|old\.reddit\.com|oneworldgroup\.org|onstartups|onstartups\.com|opendiary|opendiary\.com|oshiete\.goo\.ne\.jp|out\.reddit\.com|over-blog\.com|overblog\.com|paper\.li|partyflock\.nl|photobucket|photobucket\.com|pinboard|pinboard\.in|pingsta|pingsta\.com|pinterest|pinterest\.at|pinterest\.ca|pinterest\.ch|pinterest\.cl|pinterest\.co\.kr|pinterest\.co\.uk|pinterest\.com|pinterest\.com\.au|pinterest\.com\.mx|pinterest\.de|pinterest\.es|pinterest\.fr|pinterest\.it|pinterest\.jp|pinterest\.nz|pinterest\.ph|pinterest\.pt|pinterest\.ru|pinterest\.se|pixiv\.net|pl\.pinterest\.com|playahead\.se|plurk|plurk\.com|plus\.google\.com|plus\.url\.google\.com|pocket\.co|posterous|posterous\.com|pro\.homeadvisor\.com|pulse\.yahoo\.com|qapacity|qapacity\.com|quechup|quechup\.com|quora|quora\.com|qzone\.qq\.com|ravelry|ravelry\.com|reddit|reddit\.com|redux|redux\.com|renren|renren\.com|researchgate\.net|reunion|reunion\.com|reverbnation|reverbnation\.com|rtl\.de|ryze|ryze\.com|salespider|salespider\.com|scoop\.it|screenrant|screenrant\.com|scribd|scribd\.com|scvngr|scvngr\.com|secondlife|secondlife\.com|serverfault|serverfault\.com|shareit|sharethis|sharethis\.com|shvoong\.com|sites\.google\.com|skype|skyrock|skyrock\.com|slashdot\.org|slideshare\.net|smartnews\.com|snapchat|snapchat\.com|social|sociallife\.com\.br|socialvibe|socialvibe\.com|spaces\.live\.com|spoke|spoke\.com|spruz|spruz\.com|ssense\.com|stackapps|stackapps\.com|stackexchange|stackexchange\.com|stackoverflow|stackoverflow\.com|stardoll\.com|stickam|stickam\.com|studivz\.net|suomi24\.fi|superuser|superuser\.com|sweeva|sweeva\.com|t\.co|t\.me|tagged|tagged\.com|taggedmail|taggedmail\.com|talkbiznow|talkbiznow\.com|taringa\.net|techmeme|techmeme\.com|tencent|tencent\.com|tiktok|tiktok\.com|tinyurl|tinyurl\.com|toolbox|toolbox\.com|touch\.facebook\.com|tr\.pinterest\.com|travellerspoint|travellerspoint\.com|tripadvisor|tripadvisor\.com|trombi|trombi\.com|trustpilot|tudou|tudou\.com|tuenti|tuenti\.com|tumblr|tumblr\.com|tweetdeck|tweetdeck\.com|twitter|twitter\.com|twoo\.com|typepad|typepad\.com|unblog\.fr|urbanspoon\.com|ushareit\.com|ushi\.cn|vampirefreaks|vampirefreaks\.com|vampirerave|vampirerave\.com|vg\.no|video\.ibm\.com|vk\.com|vkontakte\.ru|wakoopa|wakoopa\.com|wattpad|wattpad\.com|web\.facebook\.com|web\.skype\.com|webshots|webshots\.com|wechat|wechat\.com|weebly|weebly\.com|weibo|weibo\.com|wer-weiss-was\.de|weread|weread\.com|whatsapp|whatsapp\.com|wiki\.answers\.com|wikihow\.com|wikitravel\.org|woot\.com|wordpress|wordpress\.com|wordpress\.org|xanga|xanga\.com|xing|xing\.com|yahoo-mbga\.jp|yammer|yammer\.com|yelp|yelp\.co\.uk|yelp\.com|youroom\.in|za\.pinterest\.com|zalo|zoo\.gr|zooppa|zooppa\.com)$", "i").test(v.utmSource) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"paid-video","test":(v) => new RegExp("^(?:blog\.twitch\.tv|crackle|crackle\.com|curiositystream|curiositystream\.com|d\.tube|dailymotion|dailymotion\.com|dashboard\.twitch\.tv|disneyplus|disneyplus\.com|fast\.wistia\.net|help\.hulu\.com|help\.netflix\.com|hulu|hulu\.com|id\.twitch\.tv|iq\.com|iqiyi|iqiyi\.com|jobs\.netflix\.com|justin\.tv|m\.twitch\.tv|m\.youtube\.com|music\.youtube\.com|netflix|netflix\.com|player\.twitch\.tv|player\.vimeo\.com|ted|ted\.com|twitch|twitch\.tv|utreon|utreon\.com|veoh|veoh\.com|viadeo\.journaldunet\.com|vimeo|vimeo\.com|wistia|wistia\.com|youku|youku\.com|youtube|youtube\.com)$", "i").test(v.utmSource) && new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"display","test":(v) => new RegExp("^(?:display|banner|expandable|interstitial|cpm)$", "i").test(v.utmMedium)},{"name":"paid-other","test":(v) => new RegExp("^(.*cp.*|ppc|retargeting|paid.*)$", "i").test(v.utmMedium)},{"name":"organic-shopping","test":(v) => new RegExp("^(?:360\.cn|alice|aol|ar\.search\.yahoo\.com|ask|at\.search\.yahoo\.com|au\.search\.yahoo\.com|auone|avg|babylon|baidu|biglobe|biglobe\.co\.jp|biglobe\.ne\.jp|bing|br\.search\.yahoo\.com|ca\.search\.yahoo\.com|centrum\.cz|ch\.search\.yahoo\.com|cl\.search\.yahoo\.com|cn\.bing\.com|cnn|co\.search\.yahoo\.com|comcast|conduit|daum|daum\.net|de\.search\.yahoo\.com|dk\.search\.yahoo\.com|dogpile|dogpile\.com|duckduckgo|ecosia\.org|email\.seznam\.cz|eniro|es\.search\.yahoo\.com|espanol\.search\.yahoo\.com|exalead\.com|excite\.com|fi\.search\.yahoo\.com|firmy\.cz|fr\.search\.yahoo\.com|globo|go\.mail\.ru|google|google-play|hk\.search\.yahoo\.com|id\.search\.yahoo\.com|in\.search\.yahoo\.com|incredimail|it\.search\.yahoo\.com|kvasir|lens\.google\.com|lite\.qwant\.com|lycos|m\.baidu\.com|m\.naver\.com|m\.search\.naver\.com|m\.sogou\.com|mail\.rambler\.ru|mail\.yandex\.ru|malaysia\.search\.yahoo\.com|msn|msn\.com|mx\.search\.yahoo\.com|najdi|naver|naver\.com|news\.google\.com|nl\.search\.yahoo\.com|no\.search\.yahoo\.com|ntp\.msn\.com|nz\.search\.yahoo\.com|onet|onet\.pl|pe\.search\.yahoo\.com|ph\.search\.yahoo\.com|pl\.search\.yahoo\.com|play\.google\.com|qwant|qwant\.com|rakuten|rakuten\.co\.jp|rambler|rambler\.ru|se\.search\.yahoo\.com|search-results|search\.aol\.co\.uk|search\.aol\.com|search\.google\.com|search\.smt\.docomo\.ne\.jp|search\.ukr\.net|secureurl\.ukr\.net|seznam|seznam\.cz|sg\.search\.yahoo\.com|so\.com|sogou|sogou\.com|sp-web\.search\.auone\.jp|startsiden|startsiden\.no|suche\.aol\.de|terra|th\.search\.yahoo\.com|tr\.search\.yahoo\.com|tut\.by|tw\.search\.yahoo\.com|uk\.search\.yahoo\.com|ukr|us\.search\.yahoo\.com|virgilio|vn\.search\.yahoo\.com|wap\.sogou\.com|webmaster\.yandex\.ru|websearch\.rakuten\.co\.jp|yahoo|yahoo\.co\.jp|yahoo\.com|yandex|yandex\.by|yandex\.com|yandex\.com\.tr|yandex\.fr|yandex\.kz|yandex\.ru|yandex\.ua|yandex\.uz|zen\.yandex\.ru)$", "i").test(v.utmSource) || new RegExp("^(.*(([^a-df-z]|^)shop|shopping).*)$", "i").test(v.utmCampaign)},{"name":"organic-social","test":(v) => new RegExp("^(?:43things|43things\.com|51\.com|5ch\.net|Hatena|ImageShack|academia\.edu|activerain|activerain\.com|activeworlds|activeworlds\.com|addthis|addthis\.com|airg\.ca|allnurses\.com|allrecipes\.com|alumniclass|alumniclass\.com|ameba\.jp|ameblo\.jp|americantowns|americantowns\.com|amp\.reddit\.com|ancestry\.com|anobii|anobii\.com|answerbag|answerbag\.com|answers\.yahoo\.com|aolanswers|aolanswers\.com|apps\.facebook\.com|ar\.pinterest\.com|artstation\.com|askubuntu|askubuntu\.com|asmallworld\.com|athlinks|athlinks\.com|away\.vk\.com|awe\.sm|b\.hatena\.ne\.jp|baby-gaga|baby-gaga\.com|babyblog\.ru|badoo|badoo\.com|bebo|bebo\.com|beforeitsnews|beforeitsnews\.com|bharatstudent|bharatstudent\.com|biip\.no|biswap\.org|bit\.ly|blackcareernetwork\.com|blackplanet|blackplanet\.com|blip\.fm|blog\.com|blog\.feedspot\.com|blog\.goo\.ne\.jp|blog\.naver\.com|blog\.yahoo\.co\.jp|blogg\.no|bloggang\.com|blogger|blogger\.com|blogher|blogher\.com|bloglines|bloglines\.com|blogs\.com|blogsome|blogsome\.com|blogspot|blogspot\.com|blogster|blogster\.com|blurtit|blurtit\.com|bookmarks\.yahoo\.co\.jp|bookmarks\.yahoo\.com|br\.pinterest\.com|brightkite|brightkite\.com|brizzly|brizzly\.com|business\.facebook\.com|buzzfeed|buzzfeed\.com|buzznet|buzznet\.com|cafe\.naver\.com|cafemom|cafemom\.com|camospace|camospace\.com|canalblog\.com|care\.com|care2|care2\.com|caringbridge\.org|catster|catster\.com|cbnt\.io|cellufun|cellufun\.com|centerblog\.net|chat\.zalo\.me|chegg\.com|chicagonow|chicagonow\.com|chiebukuro\.yahoo\.co\.jp|classmates|classmates\.com|classquest|classquest\.com|co\.pinterest\.com|cocolog-nifty|cocolog-nifty\.com|copainsdavant\.linternaute\.com|couchsurfing\.org|cozycot|cozycot\.com|cross\.tv|crunchyroll|crunchyroll\.com|cyworld|cyworld\.com|cz\.pinterest\.com|d\.hatena\.ne\.jp|dailystrength\.org|deluxe\.com|deviantart|deviantart\.com|dianping|dianping\.com|digg|digg\.com|diigo|diigo\.com|discover\.hubpages\.com|disqus|disqus\.com|dogster|dogster\.com|dol2day|dol2day\.com|doostang|doostang\.com|dopplr|dopplr\.com|douban|douban\.com|draft\.blogger\.com|draugiem\.lv|drugs-forum|drugs-forum\.com|dzone|dzone\.com|edublogs\.org|elftown|elftown\.com|epicurious\.com|everforo\.com|exblog\.jp|extole|extole\.com|facebook|facebook\.com|faceparty|faceparty\.com|fandom\.com|fanpop|fanpop\.com|fark|fark\.com|fb|fb\.me|fc2|fc2\.com|feedspot|feministing|feministing\.com|filmaffinity|filmaffinity\.com|flickr|flickr\.com|flipboard|flipboard\.com|folkdirect|folkdirect\.com|foodservice|foodservice\.com|forums\.androidcentral\.com|forums\.crackberry\.com|forums\.imore\.com|forums\.nexopia\.com|forums\.webosnation\.com|forums\.wpcentral\.com|fotki|fotki\.com|fotolog|fotolog\.com|foursquare|foursquare\.com|free\.facebook\.com|friendfeed|friendfeed\.com|fruehstueckstreff\.org|fubar|fubar\.com|gaiaonline|gaiaonline\.com|gamerdna|gamerdna\.com|gather\.com|geni\.com|getpocket\.com|glassboard|glassboard\.com|glassdoor|glassdoor\.com|godtube|godtube\.com|goldenline\.pl|goldstar|goldstar\.com|goo\.gl|gooblog|goodreads|goodreads\.com|google\+|googlegroups\.com|googleplus|govloop|govloop\.com|gowalla|gowalla\.com|gree\.jp|groups\.google\.com|gulli\.com|gutefrage\.net|habbo|habbo\.com|hi5|hi5\.com|hootsuite|hootsuite\.com|houzz|houzz\.com|hoverspot|hoverspot\.com|hr\.com|hu\.pinterest\.com|hubculture|hubculture\.com|hubpages\.com|hyves\.net|hyves\.nl|ibibo|ibibo\.com|id\.pinterest\.com|identi\.ca|ig|imageshack\.com|imageshack\.us|imvu|imvu\.com|in\.pinterest\.com|insanejournal|insanejournal\.com|instagram|instagram\.com|instapaper|instapaper\.com|internations\.org|interpals\.net|intherooms|intherooms\.com|irc-galleria\.net|is\.gd|italki|italki\.com|jammerdirect|jammerdirect\.com|jappy\.com|jappy\.de|kaboodle\.com|kakao|kakao\.com|kakaocorp\.com|kaneva|kaneva\.com|kin\.naver\.com|l\.facebook\.com|l\.instagram\.com|l\.messenger\.com|last\.fm|librarything|librarything\.com|lifestream\.aol\.com|line|line\.me|linkedin|linkedin\.com|listal|listal\.com|listography|listography\.com|livedoor\.com|livedoorblog|livejournal|livejournal\.com|lm\.facebook\.com|lnkd\.in|m\.blog\.naver\.com|m\.cafe\.naver\.com|m\.facebook\.com|m\.kin\.naver\.com|m\.vk\.com|m\.yelp\.com|mbga\.jp|medium\.com|meetin\.org|meetup|meetup\.com|meinvz\.net|meneame\.net|menuism\.com|messages\.google\.com|messages\.yahoo\.co\.jp|messenger|messenger\.com|mix\.com|mixi\.jp|mobile\.facebook\.com|mocospace|mocospace\.com|mouthshut|mouthshut\.com|movabletype|movabletype\.com|mubi|mubi\.com|my\.opera\.com|myanimelist\.net|myheritage|myheritage\.com|mylife|mylife\.com|mymodernmet|mymodernmet\.com|myspace|myspace\.com|netvibes|netvibes\.com|news\.ycombinator\.com|newsshowcase|nexopia|ngopost\.org|niconico|nicovideo\.jp|nightlifelink|nightlifelink\.com|ning|ning\.com|nl\.pinterest\.com|odnoklassniki\.ru|odnoklassniki\.ua|okwave\.jp|old\.reddit\.com|oneworldgroup\.org|onstartups|onstartups\.com|opendiary|opendiary\.com|oshiete\.goo\.ne\.jp|out\.reddit\.com|over-blog\.com|overblog\.com|paper\.li|partyflock\.nl|photobucket|photobucket\.com|pinboard|pinboard\.in|pingsta|pingsta\.com|pinterest|pinterest\.at|pinterest\.ca|pinterest\.ch|pinterest\.cl|pinterest\.co\.kr|pinterest\.co\.uk|pinterest\.com|pinterest\.com\.au|pinterest\.com\.mx|pinterest\.de|pinterest\.es|pinterest\.fr|pinterest\.it|pinterest\.jp|pinterest\.nz|pinterest\.ph|pinterest\.pt|pinterest\.ru|pinterest\.se|pixiv\.net|pl\.pinterest\.com|playahead\.se|plurk|plurk\.com|plus\.google\.com|plus\.url\.google\.com|pocket\.co|posterous|posterous\.com|pro\.homeadvisor\.com|pulse\.yahoo\.com|qapacity|qapacity\.com|quechup|quechup\.com|quora|quora\.com|qzone\.qq\.com|ravelry|ravelry\.com|reddit|reddit\.com|redux|redux\.com|renren|renren\.com|researchgate\.net|reunion|reunion\.com|reverbnation|reverbnation\.com|rtl\.de|ryze|ryze\.com|salespider|salespider\.com|scoop\.it|screenrant|screenrant\.com|scribd|scribd\.com|scvngr|scvngr\.com|secondlife|secondlife\.com|serverfault|serverfault\.com|shareit|sharethis|sharethis\.com|shvoong\.com|sites\.google\.com|skype|skyrock|skyrock\.com|slashdot\.org|slideshare\.net|smartnews\.com|snapchat|snapchat\.com|social|sociallife\.com\.br|socialvibe|socialvibe\.com|spaces\.live\.com|spoke|spoke\.com|spruz|spruz\.com|ssense\.com|stackapps|stackapps\.com|stackexchange|stackexchange\.com|stackoverflow|stackoverflow\.com|stardoll\.com|stickam|stickam\.com|studivz\.net|suomi24\.fi|superuser|superuser\.com|sweeva|sweeva\.com|t\.co|t\.me|tagged|tagged\.com|taggedmail|taggedmail\.com|talkbiznow|talkbiznow\.com|taringa\.net|techmeme|techmeme\.com|tencent|tencent\.com|tiktok|tiktok\.com|tinyurl|tinyurl\.com|toolbox|toolbox\.com|touch\.facebook\.com|tr\.pinterest\.com|travellerspoint|travellerspoint\.com|tripadvisor|tripadvisor\.com|trombi|trombi\.com|trustpilot|tudou|tudou\.com|tuenti|tuenti\.com|tumblr|tumblr\.com|tweetdeck|tweetdeck\.com|twitter|twitter\.com|twoo\.com|typepad|typepad\.com|unblog\.fr|urbanspoon\.com|ushareit\.com|ushi\.cn|vampirefreaks|vampirefreaks\.com|vampirerave|vampirerave\.com|vg\.no|video\.ibm\.com|vk\.com|vkontakte\.ru|wakoopa|wakoopa\.com|wattpad|wattpad\.com|web\.facebook\.com|web\.skype\.com|webshots|webshots\.com|wechat|wechat\.com|weebly|weebly\.com|weibo|weibo\.com|wer-weiss-was\.de|weread|weread\.com|whatsapp|whatsapp\.com|wiki\.answers\.com|wikihow\.com|wikitravel\.org|woot\.com|wordpress|wordpress\.com|wordpress\.org|xanga|xanga\.com|xing|xing\.com|yahoo-mbga\.jp|yammer|yammer\.com|yelp|yelp\.co\.uk|yelp\.com|youroom\.in|za\.pinterest\.com|zalo|zoo\.gr|zooppa|zooppa\.com)$", "i").test(v.utmSource) || new RegExp("^(?:social|social-network|social-media|sm|social network|social media)$", "i").test(v.utmMedium)},{"name":"organic-video","test":(v) => new RegExp("^(?:blog\.twitch\.tv|crackle|crackle\.com|curiositystream|curiositystream\.com|d\.tube|dailymotion|dailymotion\.com|dashboard\.twitch\.tv|disneyplus|disneyplus\.com|fast\.wistia\.net|help\.hulu\.com|help\.netflix\.com|hulu|hulu\.com|id\.twitch\.tv|iq\.com|iqiyi|iqiyi\.com|jobs\.netflix\.com|justin\.tv|m\.twitch\.tv|m\.youtube\.com|music\.youtube\.com|netflix|netflix\.com|player\.twitch\.tv|player\.vimeo\.com|ted|ted\.com|twitch|twitch\.tv|utreon|utreon\.com|veoh|veoh\.com|viadeo\.journaldunet\.com|vimeo|vimeo\.com|wistia|wistia\.com|youku|youku\.com|youtube|youtube\.com)$", "i").test(v.utmSource) || new RegExp("^(.*video.*)$", "i").test(v.utmMedium)},{"name":"organic-search","test":(v) => new RegExp("^(?:360\.cn|alice|aol|ar\.search\.yahoo\.com|ask|at\.search\.yahoo\.com|au\.search\.yahoo\.com|auone|avg|babylon|baidu|biglobe|biglobe\.co\.jp|biglobe\.ne\.jp|bing|br\.search\.yahoo\.com|ca\.search\.yahoo\.com|centrum\.cz|ch\.search\.yahoo\.com|cl\.search\.yahoo\.com|cn\.bing\.com|cnn|co\.search\.yahoo\.com|comcast|conduit|daum|daum\.net|de\.search\.yahoo\.com|dk\.search\.yahoo\.com|dogpile|dogpile\.com|duckduckgo|ecosia\.org|email\.seznam\.cz|eniro|es\.search\.yahoo\.com|espanol\.search\.yahoo\.com|exalead\.com|excite\.com|fi\.search\.yahoo\.com|firmy\.cz|fr\.search\.yahoo\.com|globo|go\.mail\.ru|google|google-play|hk\.search\.yahoo\.com|id\.search\.yahoo\.com|in\.search\.yahoo\.com|incredimail|it\.search\.yahoo\.com|kvasir|lens\.google\.com|lite\.qwant\.com|lycos|m\.baidu\.com|m\.naver\.com|m\.search\.naver\.com|m\.sogou\.com|mail\.rambler\.ru|mail\.yandex\.ru|malaysia\.search\.yahoo\.com|msn|msn\.com|mx\.search\.yahoo\.com|najdi|naver|naver\.com|news\.google\.com|nl\.search\.yahoo\.com|no\.search\.yahoo\.com|ntp\.msn\.com|nz\.search\.yahoo\.com|onet|onet\.pl|pe\.search\.yahoo\.com|ph\.search\.yahoo\.com|pl\.search\.yahoo\.com|play\.google\.com|qwant|qwant\.com|rakuten|rakuten\.co\.jp|rambler|rambler\.ru|se\.search\.yahoo\.com|search-results|search\.aol\.co\.uk|search\.aol\.com|search\.google\.com|search\.smt\.docomo\.ne\.jp|search\.ukr\.net|secureurl\.ukr\.net|seznam|seznam\.cz|sg\.search\.yahoo\.com|so\.com|sogou|sogou\.com|sp-web\.search\.auone\.jp|startsiden|startsiden\.no|suche\.aol\.de|terra|th\.search\.yahoo\.com|tr\.search\.yahoo\.com|tut\.by|tw\.search\.yahoo\.com|uk\.search\.yahoo\.com|ukr|us\.search\.yahoo\.com|virgilio|vn\.search\.yahoo\.com|wap\.sogou\.com|webmaster\.yandex\.ru|websearch\.rakuten\.co\.jp|yahoo|yahoo\.co\.jp|yahoo\.com|yandex|yandex\.by|yandex\.com|yandex\.com\.tr|yandex\.fr|yandex\.kz|yandex\.ru|yandex\.ua|yandex\.uz|zen\.yandex\.ru)$", "i").test(v.utmSource) || v.utmMedium.toLowerCase() === "organic"},{"name":"referral","test":(v) => new RegExp("^(?:referral|app|link)$", "i").test(v.utmMedium)},{"name":"email","test":(v) => new RegExp("^(?:email|e-mail|e_mail|e mail)$", "i").test(v.utmMedium) || new RegExp("^(?:email|e-mail|e_mail|e mail)$", "i").test(v.utmSource)},{"name":"affiliate","test":(v) => v.utmMedium.toLowerCase() === "affiliate"},{"name":"audio","test":(v) => v.utmMedium.toLowerCase() === "audio"},{"name":"sms","test":(v) => v.utmSource.toLowerCase() === "sms" || v.utmMedium.toLowerCase() === "sms"},{"name":"mobile-push-notification","test":(v) => v.utmSource.toLowerCase() === "firebase" || new RegExp("(?:.*mobile.*|.*notification.*|push$)", "i").test(v.utmMedium)}].find(i=>i.test(e))?.name??"other"}getShopifyAnalyticsId(){const e=this.getCookie("_shopify_y");if(e)return e;try{const t=this.localStorageGet("Shoplift_ClientId");if(t)return t}catch{}return null}legacyGetCookieVisitor(){const e=this.getCookie("SHOPLIFT");return e===null?null:JSON.parse(e,B)}getCookie(e,t=this.cookie){const i=t.split("; ").filter(s=>s.split("=").at(0)===e).at(0);return i===void 0?null:i.split("=").slice(1).join("=")}monitorConsentChange(){document.addEventListener("visitorConsentCollected",e=>{(async()=>await this.onConsentChange(e.detail.analyticsAllowed,!0))()}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.loadShopifyConsentApiWithRetry()):this.loadShopifyConsentApiWithRetry()}loadShopifyConsentApiWithRetry(){let e=0;const t=()=>{this.loadShopifyConsentApi()||e++<10&&window.setTimeout(t,100)};t()}loadShopifyConsentApi(){if(window.Shopify){this.log("Loading Shopify features");const e=async()=>{if(!window.Shopify){this.log("Shopify object missing... suddenly?");return}if(window.Shopify.customerPrivacy===void 0){this.log("Shopify CustomerPrivacy api still missing, trying again in 1000ms"),t=window.setTimeout(()=>{(async()=>await e())()},1e3);return}const i=window.Shopify.customerPrivacy.getRegion?.();this.resolvedRegion=typeof i=="string"?i.replace(/-/g,""):"";const s=window.Shopify.customerPrivacy.getTrackingConsent(),n=window.Shopify.customerPrivacy.analyticsProcessingAllowed();await this.onConsentChange(n,s==="yes",!n&&s!=="no_interaction")};let t=window.setTimeout(()=>{(async()=>await e())()},5e3);return window.Shopify.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],i=>{(async()=>{if(window.clearTimeout(t),i){this.log("Error loading consent tracking",i);return}await e()})()}),!0}return!1}async onConsentChange(e,t,i=!e&&t){try{if(this.log("Consent change detected",e,t),this.consentAnswered=!0,this.state.essential.consentApproved=e,this.state.essential.hasConsentInteraction=t,this.consentDeclined=!e&&i,!this.state.essential.consentApproved){this.state.essential.hasConsentInteraction&&(this.state.analytics.queue.length=0),this.syncAnonConsent(),this.state.essential.anonConsent?.consent==="approved"&&delete this.state.essential.anonConsent,this.saveState();return}this.cookie=document.cookie,this.shopifyAnalyticsId=this.getShopifyAnalyticsId(),this.anonymousVisitorIdEnabled&&!this.shopifyAnalyticsId&&(this.clientIdRetryCount=0),this.saveState(),await this.syncAllEvents()}catch(s){this.log("Error syncing on consent change",s)}}isThemePreview(){return isThemePreview||themeRole!=="main"}isAppProxyPath(){const e=["/apps/","/tools/","/a/"],t=window.location.pathname;return e.some(i=>t.startsWith(i))}clearThemeBar(){this.log("Looking for theme bar"),this.waitForElement(null,"body").then(e=>this.waitForElement(e,"#preview-bar-iframe, #PBarNextFrameWrapper").then(t=>{this.log("Removing theme bar"),t.remove()})).catch(e=>console.error(e))}waitForElement(e,t){return new Promise(i=>{const s=document.querySelector(t);if(s){i(s);return}const n=new MutationObserver(r=>{const o=document.querySelector(t);if(o){n.disconnect(),i(o);return}});n.observe(e??document.documentElement,{childList:!0})})}setDebug(e){this.state.essential.debugMode=e,this.saveState()}log(e,...t){let i=0;const s=e.replace(/%[sdoOfF]/g,n=>{if(i>=t.length)return n;const r=t[i++];return n==="%o"||n==="%O"?JSON.stringify(r):String(r)});this.logHistory.push(`[${new Date().toISOString()}][SL] ${s}`),!(!this.state.essential.debugMode&&!this.shopliftDebug)&&console.debug(`[SL] ${e}`,...t)}debugState(){return{state:this.state,storage:{essential:this.loadLocalStorage(this.essentialSessionKey),analytics:this.loadLocalStorage(this.analyticsSessionKey)},params:{shop:this.shop,host:this.host,eventHost:this.eventHost,cssHideClass:this.cssHideClass,testConfigs:this.testConfigs,inactiveTestConfigs:this.inactiveTestConfigs,sendPageView:this.sendPageView,isShopifyMerchantCookie:this.getCookie("is_shopify_merchant"),themeId,url:window.location.href,isThemePreview,themeRole,gaConfig:this.gaConfig},logHistory:this.logHistory}}createViewportObserver(e,t={}){const{threshold:i=this.VIEWPORT_TRACK_THRESHOLD,triggerOnce:s=!0}=t,n=new Set;return new IntersectionObserver(r=>{r.forEach(o=>{if(o.isIntersecting&&!n.has(o.target)){const c=o.target,l=c.getAttribute(this.DATA_SL_TEST_ID);l&&(e(l,c),s&&n.add(c))}})},{threshold:i})}applyChangesWithViewport(e,t,i,s){const n=t.selectorsForViewportTracking??t.selectors,r=o=>{if(this.state.essential.visitorTests.some(u=>u.testId===o)||this.activeViewportObservers.has(o))return;const c=[];if(n.forEach(u=>{e.querySelectorAll(u.cssSelector).forEach(f=>c.push(f))}),c.length===0)return;let l=!1;const d=()=>{l||(l=!0,i(o),h.disconnect(),this.activeViewportObservers.delete(o))},h=this.createViewportObserver(()=>{d()},{triggerOnce:!0,...s});this.activeViewportObservers.set(o,h),this.log(`Created viewport observer for test ${o}, observing ${c.length} elements`),c.forEach(u=>{u.setAttribute(this.DATA_SL_TEST_ID,String(o)),h.observe(u)}),setTimeout(()=>{l||c.forEach(u=>{const p=u.getBoundingClientRect(),f=s?.threshold??this.VIEWPORT_TRACK_THRESHOLD,P=Math.min(p.bottom,window.innerHeight)-Math.max(p.top,0),S=Math.min(p.right,window.innerWidth)-Math.max(p.left,0);p.top<window.innerHeight&&p.bottom>0&&p.left<window.innerWidth&&p.right>0&&P>0&&S>0&&P>=p.height*f&&(this.log(`Price element already visible in viewport for test ${o}:`,u),d())})},100)};t.selectors.length>0&&F(e,t,()=>{}),Ge(e,{testId:t.testId,hypothesisId:t.hypothesisId,selectors:n},o=>{r(o)})}applyPriceTestWithMapLookup(e,t,i,s){if(!t.priceData){this.log("No price data for hypothesis '%s'",t.id);return}this.log("Hypothesis '%s' isControl=%s, priceData has %d variants",t.id,t.isControl,t.priceData.variants.length);const n=t.priceData.variants.slice(0,3);for(const[S,A,_]of n)this.log(" Sample priceData: variant=%s, price=%d, compareAt=%d",S,A,_);const r=X(t.priceData),o=new Set;for(const S of i)if(S.priceData)for(const[A]of S.priceData.variants)o.add(A);this.log("Price test Map lookup: %d products in hypothesis, %d total products to track",r.size,o.size);const c=t.priceData,l=new WeakSet;let d=!1;const h="[data-sl-attribute-p], [data-sl-attribute-cap], [data-sl-attribute-discount]",u=S=>{if(l.has(S))return;const A=S.getAttribute("data-sl-attribute-p"),_=S.getAttribute("data-sl-attribute-cap"),C=S.getAttribute("data-sl-attribute-discount"),g=A||_||C;if(!g||!o.has(g))return;l.add(S);const v=r.get(g);v&&(this.log("Applying price for product %s: %d cents (compare at: %d cents)",g,v.priceInCents,v.compareAtPriceInCents),ot(S,g,v,c),this.log("Applied price to element for product %s",g)),!d&&!this.state.essential.visitorTests.some(b=>b.testId===e)&&(S.setAttribute(this.DATA_SL_TEST_ID,String(e)),this.setupElementViewportTracking(S,e,()=>{d||(d=!0,s(e))}))},p=()=>{const S=document.querySelectorAll(h);this.log("Scanning for price elements, found: %d",S.length),S.forEach(u)},f=new MutationObserver(S=>{for(const A of S)A.type==="childList"&&A.addedNodes.forEach(_=>{if(_.nodeType===Node.ELEMENT_NODE){const C=_;(C.hasAttribute("data-sl-attribute-p")||C.hasAttribute("data-sl-attribute-cap")||C.hasAttribute("data-sl-attribute-discount"))&&u(C),C.querySelectorAll(h).forEach(u)}}),A.type==="attributes"&&A.target instanceof Element&&u(A.target)}),P=document.body||document.documentElement;f.observe(P,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-sl-attribute-p","data-sl-attribute-cap","data-sl-attribute-discount"]}),this.log("MutationObserver started for price elements"),p(),document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",()=>{this.log("DOMContentLoaded - rescanning for price elements"),p()}),setTimeout(()=>{this.log("Delayed rescan for price elements"),p()},100),setTimeout(()=>{this.log("Final rescan for price elements"),p()},500)}setupElementViewportTracking(e,t,i){const s=this.VIEWPORT_TRACK_THRESHOLD,n=e.getBoundingClientRect(),r=Math.min(n.bottom,window.innerHeight)-Math.max(n.top,0),o=Math.min(n.right,window.innerWidth)-Math.max(n.left,0);if(n.top<window.innerHeight&&n.bottom>0&&n.left<window.innerWidth&&n.right>0&&r>0&&o>0&&r>=n.height*s){this.log("Price element already visible for test %s",t),i();return}const l=new IntersectionObserver(d=>{for(const h of d)if(h.isIntersecting&&h.intersectionRatio>=s){this.log("Price element entered viewport for test %s",t),l.disconnect(),i();break}},{threshold:s});l.observe(e)}debug(){const e=this.debugState();console.log(JSON.stringify(e,rt,2))}}(async function(){window.shopliftInstance||(window.shopliftInstance=new Ot("af3f30.myshopify.com","https://app.shoplift.ai","https://events.shoplift.ai",false,false,false,{"sendEvents":false,"mode":"gtag"},false,false,[],[],null,true,true,true,true,true,[]),await window.shopliftInstance.init())})();async function Vt(a,e,t,i){const s=mt({log:i});if(t)return i("[SUB-PREVIEW] A side — no overlay applied; widget renders naturally"),s;const n=a.widget.widgetType,r=e?X(e):null;let o=G(e),c=Q(a,o),l=c.discountMap,d=c.maxDiscount;function h(){const m=G(e);m!==o&&(o=m,c=Q(a,o),l=c.discountMap,d=c.maxDiscount,i(`[SUB-PREVIEW] scope refreshed currentProductId=${o??"n/a"}, maxDiscount=${d}`))}i(`[SUB-PREVIEW] side=B, currentProductId=${o??"n/a"}, maxDiscount=${d}`);function u(m){if(!e||!r)return null;const w=te(r),y=w?r.get(w):void 0;return y?{formattedVariantPrice:j(y.priceInCents,e),formattedDiscounted:j(y.priceInCents*(1-m/100),e)}:null}function p(m){const w=ee(a,m);if(!w)return d;const y=L(a,"subscriptionInput"),I=y.length?y[0].selector:'input[name="rc_plan"]',k=w.querySelector(`${I}:checked`);if(k){const E=l[k.value];if(E!==void 0)return E}return d}function f(m){const w=L(a,"subscriptionDiscount");for(const y of w)if(y.selector.includes("badge")||y.selector.includes("__badge")){const I=m.querySelector(y.selector);I?.textContent&&!I.textContent.includes(`${d}%`)&&M(I,k=>N(k,d))}}function P(m,w){const y=u(w);if(!y)return;const I=L(a,"subscriptionCompareAt");for(const k of I){const E=m.querySelector(k.selector)||m.querySelector(`[part~="${k.selector}"]`);E?.textContent&&!E.textContent.includes(y.formattedVariantPrice)&&M(E,R=>/\d/.test(R)?y.formattedVariantPrice:R)}}function S(m,w){const y=u(w);if(!y)return;const I=L(a,"subscriptionPrice");for(const k of I){const E=m.querySelector(k.selector)||m.querySelector(`[part~="${k.selector}"]`);E?.textContent&&!E.textContent.includes(y.formattedDiscounted)&&M(E,R=>/\d/.test(R)?y.formattedDiscounted:R)}}function A(m){const w=L(a,"subscriptionInput"),y=w.length?w[0].selector:'input[name="rc_plan"]',I=L(a,"subscriptionPlanDiscount"),k=I.length?I[0].selector:".rc-plans-button__discount";for(const E of Array.from(m.querySelectorAll("label"))){const R=E.querySelector(y),x=E.querySelector(k);if(R&&x?.textContent){const O=l[R.value];if(O!==void 0){const D=x.textContent.match(/[\d.]+%/)?.[0];D&&D!==`${O}%`&&M(x,V=>N(V,O))}}}}function _(m){const w=m.querySelector("select");if(w)for(const y of Array.from(w.options)){const I=l[y.value];if(I!==void 0&&y.textContent){const k=y.textContent.match(/[\d.]+%/)?.[0];k&&k!==`${I}%`&&(y.textContent=N(y.textContent,I))}}}function C(m){const w=L(a,"onetimePrice");if(!w.length||!e||!r)return;const y=te(r),I=y?r.get(y):void 0;if(!I)return;const k=j(I.priceInCents,e),E=L(a,"onetimeContainer"),R=E.length?E[0].selector:'[part~="rc-purchase-option__onetime"]',x=m.querySelector(R);if(x)for(const O of w){const D=x.querySelector(`[part~="${O.selector}"]`);D?.textContent&&!D.textContent.includes(k)&&M(D,V=>/\d/.test(V)?k:V)}}function g(m,w){const I=L(a,"subscriptionDiscount").filter(k=>k.selector.includes("benefit")||k.selector==="rc-benefits");for(const k of I){const E=m.querySelector(k.selector);if(E?.shadowRoot){for(const R of Array.from(E.shadowRoot.querySelectorAll("li")))if(R.textContent?.includes("Save")){const x=R.textContent.match(/[\d.]+%/)?.[0];x&&x!==`${w}%`&&M(R,O=>N(O,w))}}}}let v=!1;function b(){if(!v){v=!0;try{h();const m=z(a);if(!m)return;const w=p(m);f(m),P(m,w),S(m,w),C(m);const y=ee(a,m);y&&(n==="buttons"||n==="radio"?A(y):_(y)),g(m,w)}finally{v=!1}}}const T=Ie({data:a,runUpdates:b});return function(){T(),s()}}const $t=Object.freeze(Object.defineProperty({__proto__:null,subscriptionPreviewRender:Vt},Symbol.toStringTag,{value:"Module"}))})(); })("/", { suffix: "single-podcast", type: "article" }, "main", 149343731887, false)</script>
Take a deep dive into a variety of exam questions, gaining insight from seasoned Scorebuilders’ instructors as they help you understand and examine the why behind the correct answer. Ready to elevate your exam prep? Let’s go!
Innovate & Rehabilitate: The Entrepreneurial PT
Step into the entrepreneurial side of physical therapy as we explore innovative PT businesses and the inspiring journeys of their founders. Hear their stories, discover their strategies, and gain insights that could spark your own entrepreneurial path.
Episode 140 - Posture Interventions for Parkinson's
Scorebuilders' Team
Posted 12/01/2026
A physical therapist designs an intervention program to address axial rigidity and postural changes in a patient with mid-stage Parkinson's disease. Which of the following interventions is MOST appropriate to promote trunk extension and rotation?
Option 1- Performing resisted abdominal crunches Option 2- Practicing large-amplitude, reciprocal arm swings while walking Option 3- Exercising on a stationary bicycle with low resistance Option 4- Seated forward flexion stretching exercises for the lumbar spine
Transcript
Welcome back to the Scorebuilders' Question and Answer Podcast! This podcast provides members of the Scorebuilders' team with the opportunity to explore challenging multiple-choice examination questions with students actively preparing for the licensing examination.
Ready? Let's go!
Rigidity and bradykinesia in Parkinson's disease frequently lead to a stooped posture with a loss of reciprocal trunk movements. Physical therapy interventions should focus on high-amplitude movements that directly counteract these progressive musculoskeletal patterns.
Before we look at the options, let's establish the framework this question demands. Parkinson's disease produces two postural problems that this question is directly targeting: axial rigidity, which is the stiffness and loss of rotational mobility through the trunk, and a progressive flexion posture - the characteristic forward stoop that develops as the disease advances. An intervention that addresses both of these problems must do two things simultaneously: it must move the trunk into extension and rotation, and it must do so with sufficient amplitude to overcome the rigidity that Parkinson's disease imposes on movement. The question is testing whether you can identify which option actually accomplishes both of those goals. Keep that dual target - extension and rotation, high amplitude - in mind as we evaluate each option.
Let's explore each of the options:
Option 1- Performing resisted abdominal crunches
Performing resisted abdominal crunches reinforces a flexed trunk posture, which would exacerbate the patient's existing kyphotic structural alignment. Strengthening the abdominal muscles draws the rib cage closer to the pelvis, pulling the patient deeper into a bent-forward position.
This option moves in exactly the wrong direction. An abdominal crunch shortens the anterior chain and draws the thorax toward the pelvis. In a patient who already has a progressive flexion posture driven by Parkinson's disease, reinforcing that flexion pattern through resisted exercise will deepen the kyphosis and worsen the postural alignment the therapist is trying to correct. The question asks for an intervention that promotes trunk extension and rotation - and this option promotes neither. This choice actively makes the target problem worse.
Option 2- Practicing large-amplitude, reciprocal arm swings while walking
Practicing large-amplitude, reciprocal arm swings during ambulation directly addresses axial rigidity, promotes trunk rotation, and counteracts the loss of associated movements typical of Parkinson's disease. Parkinson's disease causes movements to become small, stiff, and restricted. Forcing the arms to swing in large, alternating arcs helps break up trunk rigidity and restores the natural rotation needed for an efficient walking pattern.
Reciprocal arm swing during walking is biomechanically coupled to trunk rotation. In Parkinson's disease, arm swing is one of the first associated movements to diminish, and its loss directly contributes to the axial rigidity and reduced trunk rotation that this question is targeting. The high-amplitude component is critical, as it directly counters the small, restricted movement pattern that Parkinson's disease imposes. The patient is simultaneously driving trunk rotation, challenging axial rigidity, and reinforcing the reciprocal movement pattern that the disease progressively erodes. This intervention targets both goals stated in the question through a functional, task-specific movement that integrates directly into the patient's daily mobility.
Option 3- Exercising on a stationary bicycle with low resistance
Stationary cycling is excellent for general aerobic conditioning, but it does not target or emphasize reciprocal trunk rotation and axial extension. The fixed, seated position on a standard bike holds the pelvis stable and keeps the spine in a slightly bent-forward posture.
Stationary cycling has legitimate benefits for patients with Parkinson's disease - research supports its role in improving cardiovascular fitness, lower extremity motor function, and even some aspects of bradykinesia. However, the question is asking specifically about an intervention to promote trunk extension and rotation, and stationary cycling does not deliver either. The seated, forward-leaning position on a standard bike actually places the spine in mild flexion, and the fixed pelvis eliminates the rotational component entirely. This is a case where a generally appropriate intervention for Parkinson's disease is the wrong answer because it does not match the specific therapeutic goal stated in the question.
Option 4- Seated forward flexion stretching exercises for the lumbar spine
Seated forward flexion stretching exercises for the lumbar spine will increase flexibility into flexion, which further reinforces the characteristic forward-stooped posture seen in these patients. Stretching the back further into a bent-forward position makes the patient's kyphotic posture worse and destabilizes their balance..
Like Option 1, this option moves in the wrong direction - but through a different mechanism. Where Option 1 strengthens the flexors, this option stretches the posterior chain into further flexion. Both outcomes reinforce the same problematic postural pattern. A patient with mid-stage Parkinson's disease already has a shortened anterior chain and a progressively kyphotic posture. Stretching the lumbar spine into forward flexion increases the range available in the direction the disease is already pulling the patient. The appropriate stretching targets for this patient are the anterior structures - hip flexors, pectorals, and anterior chest wall - to counteract the flexion bias, not to deepen it.
When we apply the dual-target framework - trunk extension and rotation, high amplitude - across all four options, two of them actively reinforce the flexion posture the therapist is trying to correct, one provides general conditioning without addressing the specific goal, and only one delivers high-amplitude trunk rotation through a functional, reciprocal movement pattern. Large-amplitude reciprocal arm swings during walking is the only option that directly and simultaneously addresses both targets stated in the question.
The correct answer is Option 2.
Let's explore the all student data:
90% of students selected Option 2 - Practicing large-amplitude, reciprocal arm swings while walking - the correct response 6% of students selected Option 4 - Seated forward flexion stretching exercises for the lumbar spine 2% of students selected Option 1 - Performing resisted abdominal crunches 2% of students selected Option 3 - Exercising on a stationary bicycle with low resistance
System Classification This question is a Neuromuscular and Nervous Systems question which represents approximately 24% of all exam items.
Content Outline Classification This question is an Interventions question which represents approximately 38% of all exam items.
Level Classification This question is a Level 2 question since the question requires students to integrate numerous pieces of information or to apply knowledge in a given clinical scenario. Remediation of Level 2 questions occurs by increasing flexibility with academic content and by carefully analyzing decision making processes when answering applied examination questions.