(function(){"use strict";const wn="rc_sn",xn="currency",Cn="rc_session_token",En=["shop-pay-wallet-button","shopify-amazon-pay-button>","shopify-apple-pay-button","shopify-google-pay-button","shopify-paypal-button","shopify-accelerated-checkout"];class kn extends Error{returnsError;constructor(e,n){super(e),this.returnsError={...n,error:e},window.postMessage({type:"returnsError",data:this.returnsError},window.location.origin)}}const Vt=t=>sessionStorage.getItem(t)||"",Wt=(t,e)=>{const r=new URLSearchParams(location.search).get(t)||Vt(t);if(r)return sessionStorage.setItem(t,r),e?.(()=>r),r},$n=()=>{let t="";try{const e=Vt("appProxy");t=e?JSON.parse(e).pathPrefix:""}catch{}return t};class Zt{interceptors;constructor(){this.interceptors=[]}addInterceptor(e){this.interceptors.push(e)}removeInterceptor(e){const n=this.interceptors.indexOf(e);n!==-1&&this.interceptors.splice(n,1)}}class In extends Zt{constructor(){super()}async intercept(e){const n=window.originalFetch(e);for(const r of this.interceptors)r(e,n);return n}}new In;class Dn extends Zt{constructor(){super()}intercept(e){this.interceptors.forEach(n=>{n(e)})}}new Dn;const Pn={SFCC:"sfcc",bigCommerce:"bigCommerce",shopify:"shopify"};function Tn(){return Pn["shopify"]}class Ht{get shopInfo(){const e=Wt(wn)||"",n=new URLSearchParams(window.atob(e)),r=new URL(n.get("referer")||"https://shopper.returnscenter.com/"),o=$n();return sessionStorage.setItem(Cn,n.get("sessionToken")||""),{rc_navigate_from_path:r.pathname.replace(o,""),rc_origin:r.origin+o,appKey:n.get("appKey")||"",orgId:n.get("orgId")||"",language:n.get("language")||"en-US",intentionId:n.get("intensionId")||"",sessionToken:n.get("sessionToken")||"",redirectUrl:n.get("redirectUrl")||"",currency:this.currency,platform:Tn()}}get providerShopInfo(){return{currency:this.shopInfo.currency,language:this.shopInfo.language,redirectUrl:this.shopInfo.redirectUrl,rc_origin:this.shopInfo.rc_origin,rc_navigate_from_path:this.shopInfo.rc_navigate_from_path}}get currency(){return Wt(xn)||""}}const An="modulepreload",Rn=function(t){return"/"+t},Kt={},Gt=function(e,n,r){return e()};var U=(t=>(t.pageEnter="page_enter",t.pageLeave="page_leave",t.UpdateProduct="click:update_product",t.ClickCheckout="click:checkout",t.ClickBuynow="click:buynow",t.APIcalculateAmount="api:calculate_amount",t.APIintention="api:intention",t))(U||{});const On=10;class Nn{reporter;breadcrumbCollector;initStatus="idle";retryCount=0;basicExtraData={trace_id:"",org_id:"",store:"",page_type:"shopper:efa_on_store"};pendingQueue=[];constructor(e){this.basicExtraData.trace_id=e}async init(){if(!(this.initStatus==="initialized"||this.initStatus=="preparing"))try{const{BreadcrumbCollector:e}=await Gt(()=>Promise.resolve().then(()=>ho),void 0),{Reporter:n}=await Gt(()=>Promise.resolve().then(()=>Xs),void 0);this.reporter=new n({pageData:{appName:"returns",pageId:"EFA_ON_STORE"}}),this.breadcrumbCollector=new e({reporter:this.reporter,networkSources:["automizely"],hooks:{onCollectBreadcrumb:r=>r.extraData&&r.extraData.eventName?r:!1,onCollectNetwork:()=>!1}}),this.initStatus="initialized",this.tryReportPendingQueue()}catch{this.initStatus="failed"}}prepareClickData(e,n){const r={...this.basicExtraData,...e};return{type:"click",reportTime:this.getISODateWithTimeZone(),data:this.formatClickData(n),extraData:r}}prepareEnterData(e){const n={...this.basicExtraData,eventName:U.pageEnter,payload:e};return{type:"pageEnter",reportTime:this.getISODateWithTimeZone(),data:{},extraData:n}}preparePageLeave(e){const n={...this.basicExtraData,eventName:U.pageLeave,payload:e};return{type:"pageLeave",reportTime:this.getISODateWithTimeZone(),data:{},extraData:n}}prepareAPIData(e,n){const r={...this.basicExtraData,eventName:e,payload:n};return{type:"api",reportTime:this.getISODateWithTimeZone(),data:{},extraData:r}}tryReportPendingQueue(){this.initStatus==="initialized"&&this.pendingQueue.length>0&&(this.pendingQueue.forEach(e=>this.breadcrumbCollector.collect({...e,extraData:{...this.basicExtraData,eventName:e.extraData.eventName,...e.extraData.payload&&{payload:e.extraData.payload}}})),this.pendingQueue=[])}async reportPageEnterEvent(e){this.collect(this.prepareEnterData(e))}async reportPageLeaveEvent(e){this.collect(this.preparePageLeave(e))}async reportAPIEvent(e,n){this.collect(this.prepareAPIData(e,n))}async reportClickEvent(e,n){this.collect(this.prepareClickData(e,n))}async collect(e){this.initStatus==="idle"?this.pendingQueue.push(e):this.initStatus==="failed"?this.retryCount<=On&&(this.retryCount+=1,this.pendingQueue.push(e),await this.init()):this.initStatus==="preparing"?this.pendingQueue.push(e):this.initStatus==="initialized"&&this.breadcrumbCollector.collect(e)}updateExtraDataByDeviceMode(e){this.basicExtraData={...this.basicExtraData,device:e}}updateExtraDataByShopInfo(e){this.basicExtraData={...this.basicExtraData,platform:e?.platform,store:e?.appKey,org_id:e.orgId,from:e.rc_navigate_from_path}}formatClickData(e){return{path:this.formatPath(e),text:this.formatText(e)}}formatText(e){return e?.target?.innerText??""}formatPath(e){return(e?.nativeEvent?.path??[]).map(r=>`${r.tagName}${r.id?`#${r.id}`:""}${r.className?`.${r.className.split(" ").join(".")}`:""}`).filter(r=>r!=="undefined")}getISODateWithTimeZone(){const e=new Date,n=e.toISOString(),r=e.getTimezoneOffset();if(r===0)return n;const o=Math.round(Math.abs(r/60)),s=Math.round(Math.abs(r%60)),i=o<10?"0"+o:String(o),a=s<10?"0"+s:String(s),c=`${r<0?"+":"-"}${i}:${a}`;return`${n.replace("Z","")}${c}`}}function jn(t){let n=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),r;return typeof window<"u"&&window.atob?r=decodeURIComponent(window.atob(n).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join("")):r=Buffer.from(n,"base64").toString(),JSON.parse(r)}let wt;const Xt=()=>{const{shopInfo:t}=new Ht;if(t?.sessionToken)return jn(t.sessionToken)?.trace_id};function B(){const t=Xt();return!wt&&t&&(wt=new Nn(Xt())),wt}const k={};function Bn(t){k.context=t}const it={equals:(t,e)=>t===e};let q=null,Yt=oe;const F=1,at=2,Jt={owned:null,cleanups:null,context:null,owner:null},xt={};var C=null;let H=null,E=null,A=null,z=null,Ct=0;function Qt(t,e){const n=E,r=C,o=t.length===0,s=o?Jt:{owned:null,cleanups:null,context:null,owner:e||r},i=o?t:()=>t(()=>V(()=>ft(s)));C=s,E=null;try{return K(i,!0)}finally{E=n,C=r}}function v(t,e){e=e?Object.assign({},it,e):it;const n={value:t,observers:null,observerSlots:null,comparator:e.equals||void 0},r=o=>(typeof o=="function"&&(o=o(n.value)),re(n,o));return[ne.bind(n),r]}function te(t,e,n){const r=ct(t,e,!0,F);J(r)}function Y(t,e,n){const r=ct(t,e,!1,F);J(r)}function R(t,e,n){Yt=Mn;const r=ct(t,e,!1,F);r.user=!0,z?z.push(r):J(r)}function L(t,e,n){n=n?Object.assign({},it,n):it;const r=ct(t,e,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,J(r),ne.bind(r)}function ot(t,e,n){let r,o,s;arguments.length===2&&typeof e=="object"||arguments.length===1?(r=!0,o=t,s=e||{}):(r=t,o=e,s=n||{});let i=null,a=xt,c=null,u=!1,l="initialValue"in s,d=typeof r=="function"&&L(r);const g=new Set,[S,w]=(s.storage||v)(s.initialValue),[D,j]=v(void 0),[_,x]=v(void 0,{equals:!1}),[f,h]=v(l?"ready":"unresolved");if(k.context){c=`${k.context.id}${k.context.count++}`;let y;s.ssrLoadFrom==="initial"?a=s.initialValue:k.load&&(y=k.load(c))&&(a=y[0])}function m(y,$,P,Z){return i===y&&(i=null,l=!0,(y===a||$===a)&&s.onHydrated&&queueMicrotask(()=>s.onHydrated(Z,{value:$})),a=xt,p($,P)),$}function p(y,$){K(()=>{$||w(()=>y),h($?"errored":"ready"),j($);for(const P of g.keys())P.decrement();g.clear()},!1)}function b(){const y=Un,$=S(),P=D();if(P&&!i)throw P;return E&&!E.user&&y&&te(()=>{_(),i&&(y.resolved||g.has(y)||(y.increment(),g.add(y)))}),$}function I(y=!0){if(y!==!1&&u)return;u=!1;const $=d?d():r;if($==null||$===!1){m(i,V(S));return}const P=a!==xt?a:V(()=>o($,{value:S(),refetching:y}));return typeof P!="object"||!(P&&"then"in P)?(m(i,P,void 0,$),P):(i=P,u=!0,queueMicrotask(()=>u=!1),K(()=>{h(l?"refreshing":"pending"),x()},!1),P.then(Z=>m(P,Z,void 0,$),Z=>m(P,void 0,ie(Z),$)))}return Object.defineProperties(b,{state:{get:()=>f()},error:{get:()=>D()},loading:{get(){const y=f();return y==="pending"||y==="refreshing"}},latest:{get(){if(!l)return b();const y=D();if(y&&!i)throw y;return S()}}}),d?te(()=>I(!1)):I(!1),[b,{refetch:I,mutate:w}]}function V(t){const e=E;E=null;try{return t()}finally{E=e}}function Et(t){R(()=>V(t))}function kt(t){return C===null||(C.cleanups===null?C.cleanups=[t]:C.cleanups.push(t)),t}function ee(t){q||(q=Symbol("error")),C===null||(C.context===null?C.context={[q]:[t]}:C.context[q]?C.context[q].push(t):C.context[q]=[t])}function Ln(){return C}let Un;function ne(){const t=H;if(this.sources&&(this.state||t))if(this.state===F||t)J(this);else{const e=A;A=null,K(()=>lt(this),!1),A=e}if(E){const e=this.observers?this.observers.length:0;E.sources?(E.sources.push(this),E.sourceSlots.push(e)):(E.sources=[this],E.sourceSlots=[e]),this.observers?(this.observers.push(E),this.observerSlots.push(E.sources.length-1)):(this.observers=[E],this.observerSlots=[E.sources.length-1])}return this.value}function re(t,e,n){let r=t.value;return(!t.comparator||!t.comparator(r,e))&&(t.value=e,t.observers&&t.observers.length&&K(()=>{for(let o=0;o1e6)throw A=[],new Error},!1)),e}function J(t){if(!t.fn)return;ft(t);const e=C,n=E,r=Ct;E=C=t,Fn(t,t.value,r),E=n,C=e}function Fn(t,e,n){let r;try{r=t.fn(e)}catch(o){t.pure&&(t.state=F,t.owned&&t.owned.forEach(ft),t.owned=null),ae(o)}(!t.updatedAt||t.updatedAt<=n)&&(t.updatedAt!=null&&"observers"in t?re(t,r):t.value=r,t.updatedAt=n)}function ct(t,e,n,r=F,o){const s={fn:t,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:C,context:null,pure:n};return C===null||C!==Jt&&(C.owned?C.owned.push(s):C.owned=[s]),s}function ut(t){const e=H;if(t.state===0||e)return;if(t.state===at||e)return lt(t);if(t.suspense&&V(t.suspense.inFallback))return t.suspense.effects.push(t);const n=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt=0;r--)if(t=n[r],t.state===F||e)J(t);else if(t.state===at||e){const o=A;A=null,K(()=>lt(t,n[0]),!1),A=o}}function K(t,e){if(A)return t();let n=!1;e||(A=[]),z?n=!0:z=[],Ct++;try{const r=t();return zn(n),r}catch(r){A||(z=null),ae(r)}}function zn(t){if(A&&(oe(A),A=null),t)return;const e=z;z=null,e.length&&K(()=>Yt(e),!1)}function oe(t){for(let e=0;e(R(()=>{const s=t();V(()=>n(s))}),o));return Ln()&&kt(r),{unsubscribe(){r()}}},[Symbol.observable||"@@observable"](){return this}}}function O(t,e){return V(()=>t(e||{}))}let dt;function Vn(t){let e,n;k.context&&k.load&&(n=k.load(k.context.id+k.context.count))&&(e=n[0]);const[r,o]=v(e,void 0);return dt||(dt=new Set),dt.add(o),kt(()=>dt.delete(o)),L(()=>{let s;if(s=r()){const i=t.fallback,a=typeof i=="function"&&i.length?V(()=>i(s,()=>o())):i;return ee(o),a}return ee(o),t.children},void 0,void 0)}function Wn(t,e,n){let r=n.length,o=e.length,s=r,i=0,a=0,c=e[o-1].nextSibling,u=null;for(;il-a){const w=e[i];for(;ao.call(t,n[1],s))}else t.addEventListener(e,n)}function M(t,e,n,r){if(n!==void 0&&!r&&(r=[]),typeof e!="function")return pt(t,e,r,n);Y(o=>pt(t,e(),o,n),r)}function Hn(t){const e=`$$${t.type}`;let n=t.composedPath&&t.composedPath()[0]||t.target;for(t.target!==n&&Object.defineProperty(t,"target",{configurable:!0,value:n}),Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}}),k.registry&&!k.done&&(k.done=!0,document.querySelectorAll("[id^=pl-]").forEach(r=>{for(;r&&r.nodeType!==8&&r.nodeValue!=="pl-"+t;){let o=r.nextSibling;r.remove(),r=o}r&&r.remove()}));n;){const r=n[e];if(r&&!n.disabled){const o=n[`${e}Data`];if(o!==void 0?r.call(n,o,t):r.call(n,t),t.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function pt(t,e,n,r,o){for(k.context&&!n&&(n=[...t.childNodes]);typeof n=="function";)n=n();if(e===n)return n;const s=typeof e,i=r!==void 0;if(t=i&&n[0]&&n[0].parentNode||t,s==="string"||s==="number"){if(k.context)return n;if(s==="number"&&(e=e.toString()),i){let a=n[0];a&&a.nodeType===3?a.data=e:a=document.createTextNode(e),n=Q(t,n,r,a)}else n!==""&&typeof n=="string"?n=t.firstChild.data=e:n=t.textContent=e}else if(e==null||s==="boolean"){if(k.context)return n;n=Q(t,n,r)}else{if(s==="function")return Y(()=>{let a=e();for(;typeof a=="function";)a=a();n=pt(t,a,n,r)}),()=>n;if(Array.isArray(e)){const a=[],c=n&&Array.isArray(n);if(Dt(a,e,n,o))return Y(()=>n=pt(t,a,n,r,!0)),()=>n;if(k.context){if(!a.length)return n;for(let u=0;u=0;i--){const a=e[i];if(o!==a){const c=a.parentNode===t;!s&&!i?c?t.replaceChild(o,a):t.insertBefore(o,n):c&&a.remove()}else s=!0}}else t.insertBefore(o,n);return[o]}function Kn(t){return Object.keys(t).reduce((n,r)=>{const o=t[r];return n[r]=Object.assign({},o),he(o.value)&&!Qn(o.value)&&!Array.isArray(o.value)&&(n[r].value=Object.assign({},o.value)),Array.isArray(o.value)&&(n[r].value=o.value.slice(0)),n},{})}function Gn(t){return t?Object.keys(t).reduce((n,r)=>{const o=t[r];return n[r]=he(o)&&"value"in o?o:{value:o},n[r].attribute||(n[r].attribute=Jn(r)),n[r].parse="parse"in n[r]?n[r].parse:typeof n[r].value!="string",n},{}):{}}function Xn(t){return Object.keys(t).reduce((n,r)=>(n[r]=t[r].value,n),{})}function Yn(t,e){const n=Kn(e);return Object.keys(e).forEach(o=>{const s=n[o],i=t.getAttribute(s.attribute),a=t[o];i&&(s.value=s.parse?de(i):i),a!=null&&(s.value=Array.isArray(a)?a.slice(0):a),s.reflect&&pe(t,s.attribute,s.value),Object.defineProperty(t,o,{get(){return s.value},set(c){const u=s.value;s.value=c,s.reflect&&pe(this,s.attribute,s.value);for(let l=0,d=this.__propertyChangedCallbacks.length;ldelete t.__updating[e])}function Jn(t){return t.replace(/\.?([A-Z]+)/g,(e,n)=>"-"+n.toLowerCase()).replace("_","-").replace(/^-/,"")}function he(t){return t!=null&&(typeof t=="object"||typeof t=="function")}function Qn(t){return Object.prototype.toString.call(t)==="[object Function]"}function tr(t){return typeof t=="function"&&t.toString().indexOf("class")===0}let Pt;function er(t,e){const n=Object.keys(e);return class extends t{static get observedAttributes(){return n.map(o=>e[o].attribute)}constructor(){super(),this.__initialized=!1,this.__released=!1,this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props={}}connectedCallback(){if(this.__initialized)return;this.__releaseCallbacks=[],this.__propertyChangedCallbacks=[],this.__updating={},this.props=Yn(this,e);const o=Xn(this.props),s=this.Component,i=Pt;try{Pt=this,this.__initialized=!0,tr(s)?new s(o,{element:this}):s(o,{element:this})}finally{Pt=i}}async disconnectedCallback(){if(await Promise.resolve(),this.isConnected)return;this.__propertyChangedCallbacks.length=0;let o=null;for(;o=this.__releaseCallbacks.pop();)o(this);delete this.__initialized,this.__released=!0}attributeChangedCallback(o,s,i){if(this.__initialized&&!this.__updating[o]&&(o=this.lookupProp(o),o in e)){if(i==null&&!this[o])return;this[o]=e[o].parse?de(i):i}}lookupProp(o){if(e)return n.find(s=>o===s||o===e[s].attribute)}get renderRoot(){return this.shadowRoot||this.attachShadow({mode:"open"})}addReleaseCallback(o){this.__releaseCallbacks.push(o)}addPropertyChangedCallback(o){this.__propertyChangedCallbacks.push(o)}}}function nr(t,e={},n={}){const{BaseElement:r=HTMLElement,extension:o}=n;return s=>{if(!t)throw new Error("tag is required to register a Component");let i=customElements.get(t);return i?(i.prototype.Component=s,i):(i=er(r,Gn(e)),i.prototype.Component=s,i.prototype.registeredTag=t,customElements.define(t,i,o),i)}}function rr(t){const e=Object.keys(t),n={};for(let r=0;ri)}})}return n}function or(t){if(t.assignedSlot&&t.assignedSlot._$owner)return t.assignedSlot._$owner;let e=t.parentNode;for(;e&&!e._$owner&&!(e.assignedSlot&&e.assignedSlot._$owner);)e=e.parentNode;return e&&e.assignedSlot?e.assignedSlot._$owner:t._$owner}function sr(t){return(e,n)=>{const{element:r}=n;return Qt(o=>{const s=rr(e);r.addPropertyChangedCallback((a,c)=>s[a]=c),r.addReleaseCallback(()=>{r.renderRoot.textContent="",o()});const i=t(s,n);return M(r.renderRoot,i)},or(r))}}function ir(t,e,n){return arguments.length===2&&(n=e,e={}),nr(t,e)(sr(n))}const ht="rc_sn",ar="hostname",ge="rc_session_token",me="rc_banner_fold",Tt=['button[name="checkout"]','input[name="checkout"]','a[href="/checkout"]',".rebuy-cart__checkout-button",'button[id="mu-checkout-button"]',".mu-checkout-btn",".button-checkout",".rebuy-button",'input[value="Checkout"]',".cart-checkout__button",".btn-checkout",".checkout-buttons",".cart-button",'button[class="publicHover"]',".Cart__Checkout",".cart__checkout","shopify-accelerated-checkout"],At=["button.shopify-payment-button__button","input.shopify-payment-button__button","div.shopify-payment-button__button","just-pay-button",".shopify-payment-button__more-options",".shopify-payment-button__button","button[id='mu-checkout-button']","div[data-testid='PayPalInContext-button']"],cr={"exchangeOnStore.banner.creditExchange":"You need to pay ${RemainingCredit} for the exchange.","exchangeOnStore.banner.creditUse":"You have ${RemainingCredit} credit to use.","exchangeOnStore.banner.goBack":"Go back"},Rt=["#upCart"],be=t=>sessionStorage.getItem(t)||"",Ot=(t,e)=>{const r=new URLSearchParams(location.search).get(t)||be(t);if(r)return sessionStorage.setItem(t,r),e?.(()=>r),r},gt=()=>{let t="";try{t=new URLSearchParams(window.atob(Ot(ht)||"")).get("pathPrefix")||""}catch{}return t},Nt=t=>`https://widgets.automizely.com/returns/${t}`,mt=t=>{const e=new URL(t),n=gt(),r=Ot(ar);return!n&&r&&e.searchParams.set("hostname",r),e.toString()},ur=(t,e)=>{const n=/\${(.*?)}/g;return t?.replace?.(n,(o,s)=>e.hasOwnProperty(s)?e[s]:o)},ye=()=>self!==top,jt="https://api.automizely.com/rc/v4/shopper",ve=40300,bt=(t,e)=>{const n=be(ge);return fetch(jt+t,{...e,headers:{"returns-authorization":`Bearer ${n}`,"Content-Type":"application/json"}}).then(r=>r.json()).then(r=>{if(r.meta.code===ve)throw new Error(`${r.meta.code}: ${r.meta.message}`);return r}).catch(r=>{const o=r instanceof Error?r.message:"Something went wrong";throw new kn(r,{baseUrl:jt,input:t,requertUrl:jt+t,method:"GET",message:o,returnsAPIException:!0})})},lr=async({intensionId:t})=>t?await bt(`/return-intentions/${t}`):null,fr=async({intensionId:t},e,n)=>{if(!(!t||!n))return await bt(`/return-intentions/${t}`,{method:"PUT",body:JSON.stringify(Object.assign(n,{exchange_items:e}))})},Se=async()=>await bt("/setting/checkout-button-class"),dr=async(t,e,n)=>await bt("/exchange-calculations",{method:"POST",body:JSON.stringify({app:{platform:"shopify",key:t.appKey},organization:{id:t.orgId},items:e?.map(r=>({quantity:r.return_quantity,external_item_id:r.item_id})),exchange:{items:n}})}),pr=async({orgId:t,language:e})=>fetch(`https://api.automizely.com/meerkat/v2/public/projects/returns-center-returns-page/production/business/${t}/translations/${e}/data.json`,{method:"GET"}).then(n=>n.json()),hr=async({orgId:t})=>fetch(`https://api.returnscenter.com/shopper/v1/shops?organization_id=${t}`,{method:"GET"}).then(e=>e.json()),gr=["6c6dcb3a55cc44078772dab27b3646e0"],mr=()=>{const[t,e]=v(""),n=()=>{Ot(ht,e)},r=L(()=>Boolean(t())),[o,s]=v({redirect_url:"",rc_navigate_from_url:"",rc_origin:"",appKey:"",orgId:"",intensionId:"",sessionToken:"",language:"en-US"});return R(()=>{if(r()){const i=new URLSearchParams(window.atob(t())),a=new URL(i.get("referer")||""),c=new URL(i.get("redirectUrl")||""),u=gt();s(()=>({rc_navigate_from_url:a.toString(),rc_origin:a.origin+u,redirect_url:c.toString(),appKey:i.get("appKey")||"",orgId:i.get("orgId")||"",language:i.get("language")||"en-US",intensionId:i.get("intensionId")||"",sessionToken:i.get("sessionToken")||""}))}}),{storageParams:n,isFromEFA:r,shopInfo:o,urlParams:t}},br=({openShopperUrl:t,shopInfo:e,validCurrency:n,setErrorMsg:r})=>{const[o]=ot(Se),{updateIntension:s}=_e({shopInfo:e}),i=new URL(e().redirect_url),a=gt();a&&a.length>0&&!i.pathname.includes(a)&&(i.pathname=a+i.pathname);const c=i.toString(),{checkoutBtnSelector:u,buyNowBtnSelector:l,shadowCheckoutBtnSelector:d}=vr(),g=()=>{const w=()=>{let _;try{_=document.querySelectorAll(d())}catch{_=document.querySelectorAll(Rt.join())}let x=[];_?.forEach(f=>{const h=f?.shadowRoot?.querySelectorAll(u());h&&(x=[...x,...h])}),x?.forEach(f=>{f?.addEventListener?.("click",h=>{h.target&&f&&f.contains(h.target)&&(h.stopPropagation(),h.preventDefault(),h.stopImmediatePropagation(),B?.()?.reportClickEvent({eventName:U.ClickCheckout}),n().then(()=>{t(c)}).catch(()=>{}))})})},D=()=>{let _;try{_=document.querySelectorAll(u())}catch{_=document.querySelectorAll(Tt.join())}document.addEventListener("click",function(x){_?.forEach(f=>{x.target&&f.contains(x.target)&&(x.stopPropagation(),x.preventDefault(),x.stopImmediatePropagation(),B?.()?.reportClickEvent({eventName:U.ClickCheckout}),n().then(()=>{t(c)}).catch(()=>{}))})},!0)},j=()=>{let _;try{_=document.querySelectorAll(l())}catch{_=document.querySelectorAll(At.join())}document.addEventListener("click",function(x){_?.forEach(f=>{x.target&&f.contains(x.target)&&(x.stopPropagation(),x.preventDefault(),x.stopImmediatePropagation(),n().then(()=>{const h=new URLSearchParams(location.search).get("variant"),m=document.querySelector('[name="quantity"]')?.value??1,p=location.pathname;B?.()?.reportClickEvent({eventName:U.ClickBuynow}),fetch(`${p}.js`).then(b=>b.json()).then(b=>{s([{external_product_id:String(b.id),external_variant_id:String(h||b.variants[0].id),quantity:Number(m)}]),t(c)}).catch(()=>{r(()=>"Please make an exchange on the product details page")})}).catch(()=>{}))})},!0)};w(),D(),j()},S=()=>{En?.forEach(w=>{try{document.querySelector(w)?.remove()}catch{}})};return R(()=>{g(),S();const w=document.body,D={attributes:!0,childList:!0,subtree:!0},j=()=>{g(),S()},_=new MutationObserver(j);w&&_.observe(w,D),kt(()=>{_.disconnect()})}),{buttonClasses:o}},_e=({shopInfo:t})=>{const[e,n]=v(!1),r=()=>{fetch("/cart?sections=cart-icon-bubble").then(f=>f.json()).then(f=>{const h=document.querySelector("#cart-icon-bubble");h&&(h.innerHTML=f["cart-icon-bubble"])})},o=()=>{l().then(f=>{D(f),x(f)})},s=f=>{const h=f?.exchange_items?.reduce((m,p)=>(m[p.external_variant_id]=String(p.quantity),m),{});fetch("/cart/update",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({updates:h,sections:"cart-icon-bubble"})}).then(()=>{r(),o()}).catch(()=>{})},[i]=ot(t,lr);R(()=>{const f=i()?.data;f&&s(f)});const a=()=>{const f=window,h=window.fetch;f.fetch=function(){const m=h.apply(this,arguments);return m.then(p=>{p.url.includes("cart/")&&(n(()=>!0),p.clone().json().then(()=>{o()}))}),m}},c=f=>{const h=["/cart/","/cart/add","/cart/change.js","/cart/add.js"];gr.includes(t().orgId)||h.push("/cart");const m=/\/cart\.js\?_=\d{13}/,p=f.split("?")[0];return!!h?.some(b=>(f===b||p.includes(b))&&!m.test(f))},u=()=>{window.XMLHttpRequest.prototype.originalOpen=window.XMLHttpRequest.prototype.open,window.XMLHttpRequest.prototype.open=function(f,h,m,p,b){this.addEventListener("readystatechange",function(){if(this.readyState===4&&this.status===200){if(!c(h))return;o()}}),this.originalOpen(f,h,m,p,b)}},l=()=>new Promise((f,h)=>{fetch(`/cart.js?rc=${Date.now()}`).then(m=>m.json()).then(m=>{const p=m.items.reduce((b,I)=>{const y=I.product_id.toString(),$=I.variant_id.toString(),P=b.some(Z=>Z.external_product_id===y&&Z.external_variant_id===$);return b.concat(P?[]:{external_product_id:y,external_variant_id:$,quantity:I.quantity})},[]);f(p)}).catch(m=>{console.log("error: "+m),h()})}),[d,g]=v(0),[S,w]=v(""),D=f=>{dr(t(),i()?.data?.items??[],f).then(h=>{B?.()?.reportAPIEvent(U.APIcalculateAmount,{status:"success"});const m=h.data.exchange.credit_remain;g(()=>Number(m.amount)),w(()=>m.currency),n(()=>!1)}).catch(()=>{B?.()?.reportAPIEvent(U.APIcalculateAmount,{status:"fail"})})},j=qn(S),_=()=>new Promise(f=>{j.subscribe(h=>{h&&f("")})}),x=f=>{fr(t(),f,i()?.data).then(()=>{B?.()?.reportAPIEvent(U.APIintention,{status:"success"})}).catch(h=>{B?.()?.reportAPIEvent(U.APIintention,{status:"fail",error:h})})};return{listenCartEvent:a,listenCartEvenForXMLHttpRequest:u,creditNum:d,creditCurrency:S,requestCartData:l,updateCartToRemainAndIntension:o,updateIntension:x,getCreditCurrency:_,isFetchingRemainCredit:e}},yr=t=>(window?.Shopify?.currency?.active??"")===t;function we(t){const[e]=ot(t,pr,{storage:v});return{data:e,t:(r,o)=>ur(e()?.translation?.[r]??cr[r],o??{})}}function xe(t){const[e,n]=v(),[r]=ot(t,hr);return R(()=>{n({background:r()?.data?.exchange_for_anything_in_store_banner_background,font:r()?.data?.exchange_for_anything_in_store_banner_font})}),{config:e}}function vr(){const[t,e]=v(Tt.join()),[n,r]=v(At.join()),[o,s]=v(Rt.join()),[i]=ot(Se);return R(()=>{const c=(i()?.data?.checkout_button_class_names??[]).reduce((g,S)=>{if(S.match("\\[buyNow\\]")){const[,w]=S.split("[buyNow]");g.buyNowBtn.push(w)}else if(S.match("\\[shadow\\]")){const[,w]=S.split("[shadow]");g.shadows.push(w)}else g.checkoutBtn.push(S);return g},{buyNowBtn:[],checkoutBtn:[],shadows:[]}),u=[...Tt,...c.checkoutBtn].join(),l=[...At,...c.buyNowBtn].join(),d=[...Rt,...c.shadows].join();r(l),e(u),s(d)}),{checkoutBtnSelector:t,buyNowBtnSelector:n,shadowCheckoutBtnSelector:o}}const Sr=`.toastWrapper{text-align:center}.toast{margin:16px auto;padding:16px;display:inline-flex;background:#D82C0D;border-radius:46px;color:#fff;font-size:14px;text-align:unset}.toast_info{background:#000}.icon{margin-right:16px} `,_r=W(""),wr=W('
warning
');let G;(function(t){t.error="error",t.info="info"})(G||(G={}));const Ce=({errorMsg:t,type:e})=>{if(!t())return null;const n=e?.()??G.error;return[(()=>{const r=_r.cloneNode(!0);return M(r,Sr),r})(),(()=>{const r=wr.cloneNode(!0),o=r.firstChild,s=o.firstChild,i=s.nextSibling;return M(i,t),Y(a=>{const c=`toast ${n===G.info?"toast_info":""}`,u=Nt("warning.svg");return c!==a._v$&&Zn(o,a._v$=c),u!==a._v$2&&$t(s,"src",a._v$2=u),a},{_v$:void 0,_v$2:void 0}),r})()]},Bt=({type:t,errorMsg:e,duration:n=2e3})=>{const[r,o]=v(""),[s,i]=v(O(Ce,{errorMsg:r,type:t}));return R(()=>{o(()=>e())}),R(()=>{r()&&(i(O(Ce,{errorMsg:r,type:t})),setTimeout(()=>{i(()=>null),o(()=>"")},n))}),s},xr=W('
thumbnail
');function Ee({onClick:t,config:e}){return(()=>{const n=xr.cloneNode(!0),r=n.firstChild;return It(n,"click",t,!0),Y(o=>{const s=e?.()?.background??"",i=Nt("thumbnail.svg");return s!==o._v$&&n.style.setProperty("background-color",o._v$=s),i!==o._v$2&&$t(r,"src",o._v$2=i),o},{_v$:void 0,_v$2:void 0}),n})()}le(["click"]);const Cr=W(''),Er="Lato",ke=[];function kr(t){if(t&&!ke.includes(t)){const e=``;document.head.insertAdjacentHTML("beforeend",e),ke.push(t)}}function Lt({credit:t,goback:e,config:n,backBtnClick:r,cancelClick:o,isPreview:s}){return R(()=>{kr(n?.()?.font||Er)}),(()=>{const i=Cr.cloneNode(!0),a=i.firstChild,c=a.firstChild,u=c.firstChild,l=c.nextSibling,d=a.nextSibling;return M(c,t,u),It(l,"click",s?void 0:r,!0),M(l,()=>typeof e=="string"?e:e()),It(d,"click",s?void 0:o,!0),Y(g=>{const S=n?.()?.background??"",w=n?.()?.font??"",D=Nt("cancel.svg");return S!==g._v$&&i.style.setProperty("background-color",g._v$=S),w!==g._v$2&&i.style.setProperty("font-family",g._v$2=w),D!==g._v$3&&$t(d,"src",g._v$3=D),g},{_v$:void 0,_v$2:void 0,_v$3:void 0}),i})()}le(["click"]);const $r=({shopInfo:t,urlParams:e})=>{const[n,r]=v("--"),[o,s]=v("Go back");Et(()=>{document.body.classList.add("aftership-returns-actived"),u(),l()});const{creditNum:i,creditCurrency:a,getCreditCurrency:c,listenCartEvent:u,listenCartEvenForXMLHttpRequest:l,requestCartData:d,isFetchingRemainCredit:g}=_e({shopInfo:t}),{t:S}=we(t),{config:w}=xe(t);R(()=>{i()<0?r(()=>S("exchangeOnStore.banner.creditExchange",{RemainingCredit:` ${a()} ${g()?"--":Math.abs(i()).toFixed(2)} `})):r(()=>S("exchangeOnStore.banner.creditUse",{RemainingCredit:` ${a()} ${g()?"--":i().toFixed(2)||"--"} `})),s(()=>S("exchangeOnStore.banner.goBack"))});const D=b=>{const I=new URL(b);I.searchParams.set(ht,e()),I.searchParams.set("lang",t().language);const y=mt(I.toString());d().then(()=>{location.href=y})},[j,_]=v(G.error),[x,f]=v("",{equals:!1});br({openShopperUrl:D,shopInfo:t,validCurrency:()=>new Promise(async(b,I)=>{if(a()||(_(G.info),f(()=>"We are processing your checkout···"),await c()),!yr(a())){_(G.error),f(()=>`Switch back to ${a()} before the checkout`),I("");return}b("")}),setErrorMsg:f});const[m,p]=v(sessionStorage.getItem(me)==="true");return R(()=>{sessionStorage.setItem(me,m().toString())}),[O(Bt,{errorMsg:x,type:j}),L((()=>{const b=L(()=>!!m());return()=>b()?O(Ee,{config:w,onClick:()=>{p(()=>!1)}}):O(Lt,{credit:n,config:w,goback:o,backBtnClick:()=>{D(t().rc_navigate_from_url)},cancelClick:()=>{p(()=>!0)}})})())]},Ir=({shopInfo:t,urlParams:e})=>{const n=mt(`${t().rc_origin}?${ht}=${e()}`),[r,o]=v("--"),[s,i]=v("Go back"),{t:a}=we(t),[c,u]=v(!1),{config:l}=xe(t);return R(()=>{o(()=>a("exchangeOnStore.banner.creditUse",{RemainingCredit:" -- "})),i(()=>a("exchangeOnStore.banner.goBack"))}),L((()=>{const d=L(()=>!!c());return()=>d()?O(Ee,{config:l,onClick:()=>{u(()=>!1)}}):O(Lt,{config:l,credit:r,goback:s,backBtnClick:()=>{location.href=n},cancelClick:()=>{u(()=>!0)}})})())},$e=`.wrapper{z-index:4;bottom:0;left:0;right:0;position:fixed}.thumbnail{position:fixed;left:32px;bottom:32px;width:72px;height:72px;border-radius:100%;background:rgba(0,0,0,.9);padding:20px 28px;box-sizing:border-box}.banner{display:flex;justify-content:space-between;align-items:center;padding:26px 40px;background:rgba(0,0,0,.9);color:#fff}.back_btn{color:#fff;text-decoration:underline;cursor:pointer}@media screen and (max-width: 500px){.banner{padding:12px 16px}.back_btn{padding:10px 5.5px;min-width:64px}}.text{font-size:20px;font-weight:500}.icon{cursor:pointer} `,Dr=W(""),Pr=W('
');function Ie(t){return typeof t=="string"?JSON.parse(t?.replace("undefined","")):void 0}function Tr(){const[t,e]=v(),[n,r]=v("");return Et(()=>{const o=sessionStorage.getItem("EFA_ON_STORE_BANNER_CONFIG");if(o){const s=Ie(o);s&&s?.is_efa_on_store_banner_preview===!0&&(r(()=>s?.text??""),e(()=>({background:s?.background??"",font:s?.font??""})))}window.addEventListener("message",s=>{const i=Ie(s.data);i&&i?.is_efa_on_store_banner_preview===!0&&(r(()=>i?.text??""),e(()=>({background:i?.background??"",font:i?.font??""})))})}),[(()=>{const o=Dr.cloneNode(!0);return M(o,$e),o})(),(()=>{const o=Pr.cloneNode(!0);return M(o,O(Lt,{isPreview:!0,credit:n,goback:"Go back",config:t})),o})()]}const Ar=W(""),Rr=W('
'),Or=()=>{const[t,e]=v("");if(ye()&&!{}.VITE_PREVIEW)return;const n=()=>{window.addEventListener("message",l=>{if(l.origin!==window.location.origin)return;const{type:d,data:g}=l.data;d==="returnsError"&&g?.returnsAPIException&&(e("Your session expired. Please refresh and try again"),setTimeout(()=>{location.href=mt(a().rc_origin)},2e3))})};Et(()=>{c(),n()});const[r,o]=v(""),s=mr(),{isFromEFA:i,shopInfo:a,storageParams:c}=s;R(()=>{sessionStorage.setItem(ge,a().sessionToken)});const u=L(()=>i()&&a().sessionToken);return R(()=>{u()&&window.asReturnsEvents?.()}),[(()=>{const l=Ar.cloneNode(!0);return M(l,$e),l})(),(()=>{const l=Rr.cloneNode(!0);return M(l,O(Vn,{fallback:(d,g)=>d.toString().includes(ve.toString())?(o("Your session expired. Please refresh and try again"),setTimeout(()=>{location.href=mt(a().rc_origin)},2e3),[O(Bt,{errorMsg:r}),O(Ir,s)]):null,get children(){return[L(()=>t&&O(Bt,{errorMsg:t})),L(()=>L(()=>!!u())()?O($r,s):null)]}})),l})()]};ir("credit-banner",{}.VITE_PREVIEW?Tr:Or);const Nr=()=>{const t=document.createElement("credit-banner");document.body.appendChild(t),t.setAttribute("style","z-index: 2147483647; position: fixed; display: unset;")};(async()=>{const t=gt();ye()&&!{}.VITE_PREVIEW||t&&location.href.includes(t)||!{}.VITE_PREVIEW&&window.self!==window.top||document.getElementsByTagName("credit-banner").length===0&&(B?.()?.updateExtraDataByShopInfo(new Ht().shopInfo),B?.()?.init(),B?.()?.reportPageEnterEvent({origin:location.origin}),Nr())})(),window.addEventListener("beforeunload",()=>{B?.()?.reportPageLeaveEvent({origin:location.origin})});var yt=(t=>(t.errors="errors",t.breadcrumbs="breadcrumbs",t.performances="performances",t))(yt||{});const De=()=>({reportURL:"https://www.automizely-analytics.com"}),Pe=3*1e3,Te=100*300,Ae=10*1e3,Re=30*1e3,Oe=`${De().reportURL}/perf-reports`,Ne=`${De().reportURL}/perf-report-settings`,Ut={reportBreadcrumbs:!1,reportErrors:!1,reportPerformances:!1,reportWebVitals:!1,samplingRatio:0,maxSamples:0},X=t=>{const e=t.toISOString(),n=t.getTimezoneOffset();if(n===0)return e;const r=Math.round(Math.abs(n/60)),o=Math.round(Math.abs(n%60)),s=r<10?"0"+r:String(r),i=o<10?"0"+o:String(o),a=`${n<0?"+":"-"}${s}:${i}`;return`${e.replace("Z","")}${a}`};var jr=typeof global=="object"&&global&&global.Object===Object&&global;const Br=jr;var Lr=typeof self=="object"&&self&&self.Object===Object&&self,Ur=Br||Lr||Function("return this")();const je=Ur;var Fr=je.Symbol;const tt=Fr;var Be=Object.prototype,zr=Be.hasOwnProperty,Mr=Be.toString,st=tt?tt.toStringTag:void 0;function qr(t){var e=zr.call(t,st),n=t[st];try{t[st]=void 0;var r=!0}catch{}var o=Mr.call(t);return r&&(e?t[st]=n:delete t[st]),o}var Vr=Object.prototype,Wr=Vr.toString;function Zr(t){return Wr.call(t)}var Hr="[object Null]",Kr="[object Undefined]",Le=tt?tt.toStringTag:void 0;function Gr(t){return t==null?t===void 0?Kr:Hr:Le&&Le in Object(t)?qr(t):Zr(t)}function Xr(t){return t!=null&&typeof t=="object"}var Yr="[object Symbol]";function Ue(t){return typeof t=="symbol"||Xr(t)&&Gr(t)==Yr}var Jr=Object.defineProperty,Qr=(t,e,n)=>e in t?Jr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,et=(t,e,n)=>(Qr(t,typeof e!="symbol"?e+"":e,n),n),nt=(t=>(t.Click="click",t.Scroll="scroll",t.Network="network",t.Input="input",t))(nt||{});const Fe=1e3,ze=1e3;var to=/\s/;function eo(t){for(var e=t.length;e--&&to.test(t.charAt(e)););return e}var no=/^\s+/;function ro(t){return t&&t.slice(0,eo(t)+1).replace(no,"")}function Ft(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Me=0/0,oo=/^[-+]0x[0-9a-f]+$/i,so=/^0b[01]+$/i,io=/^0o[0-7]+$/i,ao=parseInt;function qe(t){if(typeof t=="number")return t;if(Ue(t))return Me;if(Ft(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Ft(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=ro(t);var n=so.test(t);return n||io.test(t)?ao(t.slice(2),n?2:8):oo.test(t)?Me:+t}var co=function(){return je.Date.now()};const zt=co;var uo="Expected a function",lo=Math.max,fo=Math.min;function Ve(t,e,n){var r,o,s,i,a,c,u=0,l=!1,d=!1,g=!0;if(typeof t!="function")throw new TypeError(uo);e=qe(e)||0,Ft(n)&&(l=!!n.leading,d="maxWait"in n,s=d?lo(qe(n.maxWait)||0,e):s,g="trailing"in n?!!n.trailing:g);function S(p){var b=r,I=o;return r=o=void 0,u=p,i=t.apply(I,b),i}function w(p){return u=p,a=setTimeout(_,e),l?S(p):i}function D(p){var b=p-c,I=p-u,y=e-b;return d?fo(y,s-I):y}function j(p){var b=p-c,I=p-u;return c===void 0||b>=e||b<0||d&&I>=s}function _(){var p=zt();if(j(p))return x(p);a=setTimeout(_,D(p))}function x(p){return a=void 0,g&&r?S(p):(r=o=void 0,i)}function f(){a!==void 0&&clearTimeout(a),u=0,r=c=o=a=void 0}function h(){return a===void 0?i:x(zt())}function m(){var p=zt(),b=j(p);if(r=arguments,o=this,c=p,b){if(a===void 0)return w(c);if(d)return clearTimeout(a),a=setTimeout(_,e),S(c)}return a===void 0&&(a=setTimeout(_,e)),i}return m.cancel=f,m.flush=h,m}const vt={data:[],push(t){this.data.push(t)}};(()=>{const t=window.fetch,e=async(n,r)=>{var o,s;const i=new Date;let a;try{a=await t(n,r)}catch{a={status:0}}const c=new Date,u=X(c),{status:l}=a;return vt.push({type:nt.Network,data:{status:l,url:(o=n?.url)!=null?o:n.toString(),startTime:X(i),endTime:u,duration:c.getTime()-i.getTime(),method:(s=r?.method)!=null?s:"GET"},reportTime:u,extraData:{}}),a.status,a};window.fetch=e})();const We=t=>t.map(e=>`${e.tagName}${e.id?`#${e.id}`:""}${e.className?`.${e.className.split(" ").join(".")}`:""}`).filter(e=>e!=="undefined");class po{constructor({hooks:e,reporter:n,networkSources:r,excludeNetworkSources:o,scrollDebounce:s=Fe,inputDebounce:i=ze}){et(this,"reporter"),et(this,"hooks"),et(this,"scrollDebounce"),et(this,"inputDebounce"),et(this,"networkSources"),et(this,"excludeNetworkSources"),this.networkSources=r,this.excludeNetworkSources=[...o??[],"https://www.automizely-analytics.io"],this.scrollDebounce=s,this.inputDebounce=i,this.reporter=n,this.hooks=e,this.collectNetwork(),this.collectClick(),this.collectScroll(),this.collectInput()}collectNetwork(){const e=n=>{var r;if(!(this.excludeNetworkSources.some(o=>n.data.url.match(o))||!this.networkSources.some(o=>n.data.url.match(o)))){if((r=this.hooks)!=null&&r.onCollectNetwork){const o=this.hooks.onCollectNetwork(n);if(!o)return;n=o}this.collect(n)}};vt.push=e,vt.data.forEach(e),vt.data=[]}collectInput(){const e=Ve(n=>{this.collect({type:nt.Input,data:n,extraData:{},reportTime:X(new Date)})},this.inputDebounce);document.addEventListener("input",n=>{var r,o;e({path:n.path?We(n.path):[],value:(o=(r=n.target)==null?void 0:r.value)!=null?o:""})})}collectClick(){document.addEventListener("click",e=>{var n;this.collect({type:nt.Click,data:{path:e.path?We(e.path):[],text:(n=e.target)==null?void 0:n.innerText},extraData:{},reportTime:X(new Date)})})}collectScroll(){const e={deltaX:0,deltaY:0,deltaZ:0},n=Ve(r=>{this.collect({type:nt.Scroll,data:r,extraData:{},reportTime:X(new Date)}),e.deltaX=0,e.deltaY=0,e.deltaZ=0},this.scrollDebounce);document.addEventListener("touchstart",r=>{var o,s;const{pageX:i,pageY:a}=(s=(o=r.changedTouches)==null?void 0:o[0])!=null?s:{};i===void 0||a===void 0||(e.deltaX=i,e.deltaY=a)}),document.addEventListener("touchend",r=>{var o,s;const{pageX:i,pageY:a}=(s=(o=r.changedTouches)==null?void 0:o[0])!=null?s:{};if(i===void 0||a===void 0)return;const c=e.deltaX-i,u=e.deltaY-a;c===0&&u===0||n({deltaX:c,deltaY:u,deltaZ:0})}),document.addEventListener("wheel",r=>{n({deltaX:r.deltaX,deltaY:r.deltaY,deltaZ:r.deltaZ})})}collect(e){var n,r,o;if(e.reportTime||(e.reportTime=X(new Date)),(n=this.hooks)!=null&&n.onCollectBreadcrumb){const s=(o=(r=this.hooks)==null?void 0:r.onCollectBreadcrumb)==null?void 0:o.call(r,e);if(!s)return;e=s}this.reporter.push(yt.breadcrumbs,e)}}const ho=Object.freeze(Object.defineProperty({__proto__:null,BreadcrumbCollector:po,BreadcrumbType:nt,InputDebounceDefaultValue:ze,ScrollDebounceDefaultValue:Fe},Symbol.toStringTag,{value:"Module"}));var go=Object.defineProperty,mo=(t,e,n)=>e in t?go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,N=(t,e,n)=>(mo(t,typeof e!="symbol"?e+"":e,n),n);function bo(t,e){for(var n=-1,r=t==null?0:t.length,o=Array(r);++no?0:o+e),n=n>o?o:n,n<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(o);++r=r?t:_o(t,e,n)}var xo="\\ud800-\\udfff",Co="\\u0300-\\u036f",Eo="\\ufe20-\\ufe2f",ko="\\u20d0-\\u20ff",$o=Co+Eo+ko,Io="\\ufe0e\\ufe0f",Do="\\u200d",Po=RegExp("["+Do+xo+$o+Io+"]");function Ge(t){return Po.test(t)}function To(t){return t.split("")}var Xe="\\ud800-\\udfff",Ao="\\u0300-\\u036f",Ro="\\ufe20-\\ufe2f",Oo="\\u20d0-\\u20ff",No=Ao+Ro+Oo,jo="\\ufe0e\\ufe0f",Bo="["+Xe+"]",Mt="["+No+"]",qt="\\ud83c[\\udffb-\\udfff]",Lo="(?:"+Mt+"|"+qt+")",Ye="[^"+Xe+"]",Je="(?:\\ud83c[\\udde6-\\uddff]){2}",Qe="[\\ud800-\\udbff][\\udc00-\\udfff]",Uo="\\u200d",tn=Lo+"?",en="["+jo+"]?",Fo="(?:"+Uo+"(?:"+[Ye,Je,Qe].join("|")+")"+en+tn+")*",zo=en+tn+Fo,Mo="(?:"+[Ye+Mt+"?",Mt,Je,Qe,Bo].join("|")+")",qo=RegExp(qt+"(?="+qt+")|"+Mo+zo,"g");function Vo(t){return t.match(qo)||[]}function Wo(t){return Ge(t)?Vo(t):To(t)}function Zo(t){return function(e){e=St(e);var n=Ge(e)?Wo(e):void 0,r=n?n[0]:e.charAt(0),o=n?wo(n,1).join(""):e.slice(1);return r[t]()+o}}var Ho=Zo("toUpperCase");const Ko=Ho;function Go(t){return Ko(St(t).toLowerCase())}function Xo(t,e,n,r){var o=-1,s=t==null?0:t.length;for(r&&s&&(n=t[++o]);++o{try{const e=await fetch(`${Ne}?app-name=${t}`).then(n=>n.json());if(!(e!=null&&e.data))throw"Failed to get online setting";return{reportBreadcrumbs:e.data.report_breadcrumbs,reportErrors:e.data.report_errors,reportPerformances:e.data.report_performances,reportWebVitals:e.data.report_web_vitals,samplingRatio:e.data.sampling_ratio,maxSamples:e.data.max_samples}}catch(e){return console.error(e),Ut}};let _t;const qs=new Uint8Array(16);function Vs(){if(!_t&&(_t=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!_t))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _t(qs)}const T=[];for(let t=0;t<256;++t)T.push((t+256).toString(16).slice(1));function Ws(t,e=0){return(T[t[e+0]]+T[t[e+1]]+T[t[e+2]]+T[t[e+3]]+"-"+T[t[e+4]]+T[t[e+5]]+"-"+T[t[e+6]]+T[t[e+7]]+"-"+T[t[e+8]]+T[t[e+9]]+"-"+T[t[e+10]]+T[t[e+11]]+T[t[e+12]]+T[t[e+13]]+T[t[e+14]]+T[t[e+15]]).toLowerCase()}const Zs=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Sn={randomUUID:Zs};function Hs(t,e,n){if(Sn.randomUUID&&!e&&!t)return Sn.randomUUID();t=t||{};const r=t.random||(t.rng||Vs)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let o=0;o<16;++o)e[n+o]=r[o];return e}return Ws(r)}const Ks=t=>{var e,n;return{url:window.location.href,enterTime:X(new Date),shopifyStore:(n=(e=window.Shopify)==null?void 0:e.shop)!=null?n:null,sessionId:Hs(),...t}},_n=t=>Object.fromEntries(Object.entries(t).map(([e,n])=>[zs(e),n]));class Gs{constructor({reportInterval:e=Pe,reportSize:n=Te,checkReportInterval:r=Ae,reportURL:o=Oe,pageData:s,hooks:i}){N(this,"queue",[]),N(this,"queueSize",0),N(this,"reportInterval"),N(this,"reportURL"),N(this,"pageData"),N(this,"reportSize"),N(this,"checkReportInterval"),N(this,"onlineSetting",Ut),N(this,"hooks"),N(this,"isInSample",!1),N(this,"hasSetInSample",!1),N(this,"sentEventCount",0),this.checkReportInterval=Math.max(r,Re),this.reportInterval=e,this.reportSize=n,this.reportURL=o,this.pageData=Ks(s),this.reportInIntervals(),this.hooks=i??{},this.checkReport(),this.reportInIntervals()}checkReport(){Ms(this.pageData.appName).then(e=>{this.onlineSetting=e,!this.hasSetInSample&&(this.hasSetInSample=!0,this.isInSample=Math.random()<=this.onlineSetting.samplingRatio)}),setTimeout(()=>{!this.isInSample||this.checkReport()},this.checkReportInterval)}reportInIntervals(){setTimeout(()=>{this.report(),this.reportInIntervals()},this.reportInterval)}push(e,n){var r,o,s;const i=((s=(o=(r=this.hooks).onPush)==null?void 0:o.call(r,e,n))!=null?s:[{type:e,data:n}]).map(a=>{const c=JSON.stringify(_n(a.data));return this.queueSize+=c.length,{...a,data:c}});this.queue.push(...i),this.queueSize>this.reportSize&&this.report()}getDataToReport(){const e=Object.fromEntries(Object.keys(yt).map(n=>[n,[]]));return this.queue.forEach(({type:n,data:r})=>{!this.onlineSetting[`report${Go(n)}`]||e[n].push(r)}),e}checkAndClearQueueSize(){for(;this.queueSize>this.reportSize;){const e=this.queue.shift();if(!e)break;this.queueSize-=e.data.length}}sendReport(e){return e.breadcrumbs||(e.breadcrumbs=[]),e.errors||(e.errors=[]),e.performances||(e.performances=[]),navigator.sendBeacon(this.reportURL,`{"page":${JSON.stringify(_n(this.pageData))},${Object.entries(e).map(([n,r])=>`"${n}":[${r.join(",")}]`).join(",")}}`)}report(){var e,n;if(!this.isInSample||this.queue.length===0)return;const r=this.getDataToReport(),o=Object.values(r).flat();if(o.length===0)return this.checkAndClearQueueSize();this.sentEventCount+=o.length,!(this.sentEventCount>=this.onlineSetting.maxSamples)&&((n=(e=this.hooks).onReport)==null||n.call(e,r),this.queue=[],this.queueSize=0,this.sendReport(r))}}const Xs=Object.freeze(Object.defineProperty({__proto__:null,DefaultCheckReportInterval:Ae,DefaultOnlineSettings:Ut,DefaultReportInterval:Pe,DefaultReportSize:Te,DefaultReportURL:Oe,MaxCheckReportInterval:Re,ReportType:yt,Reporter:Gs,getSettingURL:Ne},Symbol.toStringTag,{value:"Module"}))})();