"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[10],{68:(t,e,i)=>{i.d(e,{a:()=>p,b:()=>y,c:()=>I,d:()=>v,e:()=>f,f:()=>g,g:()=>M});var o=i(1),n=i(231),s=i(206),r=i(4),d=i(208),a=i(233),l=function(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{a(o.next(t))}catch(t){s(t)}}function d(t){try{a(o.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,d)}a((o=o.apply(t,e||[])).next())}))};function c(t,e){e?e("wishlist-error",{message:t}):window.alert(t)}const u=new n.a({concurrency:1}),h=new Map;function f(t,e,i){const o=`${t}-${e}`;if(h.has(o))return h.get(o);const n=u.add((()=>l(this,void 0,void 0,(function*(){try{yield i()}finally{h.delete(o)}}))));return h.set(o,n),n}let w=null,m=0;const v=()=>m,g=t=>{w=t},p="otsm_wishlistItems_cache",I="otsm_wishlistItems_pending",y="otsm_logged_out_pending_item",S={setWishlistItems:null,fetchWishlist:null,openLoginModal:null,getBentoStore:null};let b=0,O=!1;const C=()=>{if("undefined"==typeof window)return;let t=[];try{const e=localStorage.getItem(I);if(!e)throw new Error("No pending operations in localStorage");if(t=JSON.parse(e),!Array.isArray(t))throw new Error("Bad data shape: "+e)}catch(e){t=[],localStorage.setItem(I,JSON.stringify(t))}return t},_=t=>{if("undefined"==typeof window)return;const e=(C()||[]).filter((e=>e.variantId!==t));0===e.length?localStorage.removeItem(I):localStorage.setItem(I,JSON.stringify(e))},W=()=>{var t,e,i,o,n,s,r,d,l;if(!S.setWishlistItems||!S.fetchWishlist)return;if(!w)return;const c="a"in w?w:void 0,u="listcontents"in w?w:void 0;if(c){if(!S.setWishlistItems)return void(w=null);const r=[],d=[],l=[],u=[];for(const i of c.a)if("hasError"in i&&i.hasError){const o=null===(e=null===(t=i.error)||void 0===t?void 0:t.listitem)||void 0===e?void 0:e.epi;o&&l.push(o)}else i.epi&&i.empi&&(r.push({variantId:i.epi,productId:i.empi}),l.push(i.epi));for(const t of c.d)if("hasError"in t&&t.hasError){const e=null===(o=null===(i=t.error)||void 0===i?void 0:i.listitem)||void 0===o?void 0:o.epi;e&&u.push(e)}else t.epi&&(d.push(t.epi),u.push(t.epi));const h=null===(n=S.getBentoStore)||void 0===n?void 0:n.call(S),f=(null==h?void 0:h.wishlistItems)||[],m=null!==(s=null==h?void 0:h.wishlistMode)&&void 0!==s?s:"variant",v=f.filter((t=>!d.includes(t.variantId))),g=new Set(v.map((t=>(0,a.a)(t,m)))),y=v.concat(r.filter((t=>!g.has((0,a.a)(t,m)))));S.setWishlistItems(y),"undefined"!=typeof window&&localStorage.setItem(p,JSON.stringify(y));const b=[...l,...u],O=(C()||[]).filter((t=>!b.includes(t.variantId)));0===O.length?localStorage.removeItem(I):localStorage.setItem(I,JSON.stringify(O)),w=null}else if(u){const t=u.listcontents.map((t=>({variantId:t.epi,productId:t.empi})));"undefined"!=typeof window&&localStorage.setItem(p,JSON.stringify(t));const e=C()||[],i=null!==(l=null===(d=null===(r=S.getBentoStore)||void 0===r?void 0:r.call(S))||void 0===d?void 0:d.wishlistMode)&&void 0!==l?l:"variant",o=(0,a.b)(t,e,i);S.setWishlistItems(o),w=null}};function M(){const[t,e]=(0,o.useState)(!1),{loggedIn:i,loading:n}=(0,s.a)(),h=(0,r.e)(),{wishlistItems:v,wishlistLoading:g,setWishlistItems:p,fetchWishlist:C,wishlistMode:M,emitEvent:T}=(0,r.d)((t=>({wishlistItems:t.wishlistItems,wishlistLoading:t.wishlistLoading,setWishlistItems:t.setWishlistItems,fetchWishlist:t.fetchWishlist,wishlistMode:t.wishlistMode,emitEvent:t.emitEvent}))),L=(0,o.useCallback)((()=>{window.parent.postMessage({type:"wishlist",value:"open"}),setTimeout((()=>e(!0)),50)}),[e]),E=(0,o.useCallback)((()=>{e(!1),window.parent.postMessage({type:"wishlist",value:"closed"})}),[e]);(0,o.useEffect)((()=>(b++,1===b&&(O||(u.on("idle",W),O=!0)),S.setWishlistItems=p,S.fetchWishlist=C,S.openLoginModal=L,S.getBentoStore=()=>h.getState(),()=>{b--,0===b&&O&&(u.off("idle",W),O=!1,S.setWishlistItems=null,S.fetchWishlist=null,S.openLoginModal=null,S.getBentoStore=null)})),[p,C,L,h]);const P=(0,o.useCallback)((t=>{if(!t.epi||!t.empi||!t.du)return;0===u.pending&&0===u.size&&(w=null);const e={variantId:t.epi,productId:t.empi},o=!v.some((t=>(0,a.a)(t,M)===(0,a.a)(e,M)));if(!n&&!i){if(o){const e={variantId:t.epi,productId:t.empi};"undefined"!=typeof window&&localStorage.setItem(y,JSON.stringify(e))}return void L()}const s=(0,a.a)(e,M),r=o?void 0:v.find((t=>(0,a.a)(t,M)===s)),h=o?[{variantId:t.epi,productId:t.empi},...v.filter((t=>(0,a.a)(t,M)!==s))]:v.filter((t=>(0,a.a)(t,M)!==s));if(p(h),"undefined"!=typeof window){let e=[];try{const t=localStorage.getItem(I);t&&(e=JSON.parse(t))}catch(t){}const i=function(t,e){const i=t.findIndex((t=>t.variantId===e.variantId));if(-1===i)return[...t,e];if(t[i].action===e.action){const o=[...t];return o[i]=e,o}return t.filter(((t,e)=>e!==i))}(e,{action:o?"add":"remove",variantId:t.epi,productId:t.empi});i.length>0?localStorage.setItem(I,JSON.stringify(i)):localStorage.removeItem(I)}f(o?"a":"d",t.epi,(()=>l(this,void 0,void 0,(function*(){var e,i,n,s,a,l,u,h,f,v;const g=()=>{var e,i,n;_(t.epi);const s=(null===(i=null===(e=S.getBentoStore)||void 0===e?void 0:e.call(S))||void 0===i?void 0:i.wishlistItems)||[],d=function(t){const{newState:e,productData:i,currentItems:o,originalItem:n}=t;return e?o.filter((t=>t.variantId!==i.epi)):[...o,null!=n?n:{variantId:i.epi,productId:i.empi}]}({newState:o,productData:t,currentItems:s,originalItem:r});null===(n=S.setWishlistItems)||void 0===n||n.call(S,d)};try{const r=1e4,p=Date.now();let I=null===(i=null===(e=S.getBentoStore)||void 0===e?void 0:e.call(S))||void 0===i?void 0:i.accountStatus;for(;(null==I?void 0:I.loading)&&Date.now()-psetTimeout(t,100))),I=null===(s=null===(n=S.getBentoStore)||void 0===n?void 0:n.call(S))||void 0===s?void 0:s.accountStatus;if(!(null==I?void 0:I.loggedIn)||!(null===(a=null==I?void 0:I.data)||void 0===a?void 0:a.email))return;const y=I.data.email,b=null!==(h=null===(u=null===(l=S.getBentoStore)||void 0===l?void 0:l.call(S))||void 0===u?void 0:u.wishlistProvider)&&void 0!==h?h:null,O=(0,d.c)(b);if(!O)return void console.error("[useWishlist] No provider available");if(!O.isInitialized()){const t=(null===(f=null==I?void 0:I.data)||void 0===f?void 0:f.id)?String(I.data.id).replace(/\D/g,""):void 0;try{yield O.initialize(y,t)}catch(t){console.error("[useWishlist] Provider initialization failed:",t),yield null===(v=S.fetchWishlist)||void 0===v?void 0:v.call(S,y)}}m++,(o?yield O.addItem({productId:t.empi,variantId:t.epi,productUrl:t.du}):yield O.removeItem(t.epi)).success?w=o?{a:[{epi:t.epi,empi:t.empi}],d:[],u:[]}:{a:[],d:[{epi:t.epi,empi:t.empi}],u:[]}:(g(),c(o?"Failed to add item to wishlist. Please try again.":"Failed to remove item from wishlist. Please try again.",T))}catch(t){console.error("[useWishlist] Request failed:",t),g(),c("Something went wrong with your wishlist. Please try again.",T)}}))))}),[n,i,v,L,p,M,T]);return{loggedIn:i,accountLoading:n,wishlistLoading:g,wishlistItemCount:v.length,wishlistItems:v,wishlistMode:M,isModalOpen:t,toggleWishlistItem:P,openLoginModal:L,closeLoginModal:E}}},4:(t,e,i)=>{i.d(e,{a:()=>W,b:()=>C,c:()=>_,d:()=>M,e:()=>T});var o=i(331),n=i(332),s=i(333),r=i(2);i(9);var d=i(89);const a=(t,e)=>{if("undefined"!=typeof window){let i=0;const o=function(){let o;return function(...n){clearTimeout(o),o=setTimeout((()=>{clearTimeout(o),(()=>{window.parent.scrollY>i&&window.parent.scrollY>64?e().headerIsVisible&&t({headerIsVisible:!1}):(window.parent.scrollY{e().headerIsVisible||t({headerIsVisible:!0})}))}return{headerIsVisible:!0,setHeaderIsVisible(e){t((()=>({headerIsVisible:e})))},openCart(){const t=document.getElementById("cart-toggle");null==t||t.click()}}};var l=i(35),c=function(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{a(o.next(t))}catch(t){s(t)}}function d(t){try{a(o.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,d)}a((o=o.apply(t,e||[])).next())}))};let u=null;var h=i(68),f=i(208),w=i(233),m=function(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{a(o.next(t))}catch(t){s(t)}}function d(t){try{a(o.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,d)}a((o=o.apply(t,e||[])).next())}))};let v=!1,g=null;function p(t){return"undefined"==typeof window?[]:(0,f.b)(t)}function I(t){if("undefined"==typeof window)return;const e=(0,f.c)(t);e&&e.clearSession(),(0,f.a)()}function y(t,e){return m(this,void 0,void 0,(function*(){const i=(0,f.c)(e);if(i)try{const e="add"===t.action?yield i.addItem({productId:t.productId,variantId:t.variantId,productUrl:"undefined"!=typeof window?window.location.href:""}):yield i.removeItem(t.variantId);(0,h.f)(function(t,e){const i=e?{epi:t.variantId,empi:t.productId}:{hasError:!0,error:{listitem:{epi:t.variantId,empi:t.productId}}};return"add"===t.action?{a:[i],d:[],u:[]}:{a:[],d:[i],u:[]}}(t,e.success))}catch(t){console.error("[wishlistSubstate] Failed to sync pending operation:",t)}else console.error("[wishlistSubstate] No provider available for sync")}))}function S(){if("undefined"==typeof window)return[];let t=[];const e=localStorage.getItem(h.c);if(e)try{t=JSON.parse(e)}catch(t){console.error("[wishlistSubstate] Failed to parse pending operations:",t)}const i=localStorage.getItem(h.b);if(i)try{const e=JSON.parse(i),o={action:"add",variantId:e.variantId,productId:e.productId};t.some((t=>t.variantId===o.variantId))||t.push(o),localStorage.removeItem(h.b)}catch(t){console.error("[wishlistSubstate] Failed to parse logged out pending item:",t),localStorage.removeItem(h.b)}return t}function b(t,e){for(const i of t){const t="add"===i.action?"a":"d";(0,h.e)(t,i.variantId,(()=>y(i,e)))}}const O=t=>(e,i,o)=>{const n=o=>m(void 0,void 0,void 0,(function*(){return g||(v?void 0:(g=m(void 0,void 0,void 0,(function*(){var n;try{const s=i(),r=s.wishlistProvider;if(!r)return void console.warn("[wishlistSubstate] No wishlist provider configured");const d=s.fetchOperationVersion+1;e({fetchOperationVersion:d,wishlistLoading:!0});const a=(0,f.c)(r);if(!a)return console.error("[wishlistSubstate] Failed to get provider"),void e({wishlistLoading:!1});const l=null===(n=s.accountStatus)||void 0===n?void 0:n.data,c=(null==l?void 0:l.id)?String(l.id).replace(/\D/g,""):void 0;try{yield a.initialize(o,c)}catch(t){return console.error("[wishlistSubstate] Provider initialization failed:",t),void e({wishlistLoading:!1})}let u;try{u=yield a.fetchItems()}catch(t){return console.error("[wishlistSubstate] Failed to fetch items:",t),void e({wishlistLoading:!1})}"undefined"!=typeof window&&localStorage.setItem(h.a,JSON.stringify(u));const m=S(),g=i(),p=(0,h.d)();if(g.fetchOperationVersion>d||p>d)e({wishlistLoading:!1});else{const i=(0,w.b)(u,m,t.wishlistMode);e({wishlistItems:i,wishlistLoading:!1})}m.length>0&&b(m,r),v=!0}catch(t){console.error("[wishlistSubstate] Error fetching wishlist:",t),e({wishlistLoading:!1})}finally{g=null}})),g))})),s=t.wishlistProvider;let r=[];if("undefined"!=typeof window&&(r=p(s)),"undefined"!=typeof window){"comfrt"===s&&m(void 0,void 0,void 0,(function*(){const i=(0,f.c)(s);if(i)try{const o=yield i.fetchItems();localStorage.setItem(h.a,JSON.stringify(o));const n=function(){if("undefined"==typeof window)return[];let t=[];const e=localStorage.getItem(h.c);if(e)try{t=JSON.parse(e)}catch(t){}const i=localStorage.getItem(h.b);if(i)try{const e=JSON.parse(i),o={action:"add",variantId:e.variantId,productId:e.productId};t.some((t=>t.variantId===o.variantId))||t.push(o)}catch(t){}return t}(),s=(0,w.b)(o,n,t.wishlistMode);e({wishlistItems:s,wishlistLoading:!1}),v=!0}catch(t){console.error("[wishlistSubstate] Comfrt immediate fetch failed:",t),e({wishlistLoading:!1})}else e({wishlistLoading:!1})}));let r=!1,d=!1;o.subscribe((t=>{var o,s,a,l;const c=!0===(null===(o=t.accountStatus)||void 0===o?void 0:o.loggedIn),u=!0===(null===(s=t.accountStatus)||void 0===s?void 0:s.loading),w=null===(l=null===(a=t.accountStatus)||void 0===a?void 0:a.data)||void 0===l?void 0:l.email,y=t.wishlistProvider;if(u)return;if(!d&&(d=!0,!c)){I(y);const t=p(y);e({wishlistItems:t,wishlistLoading:!1})}if(r&&!c){I(y),v=!1,g=null,"undefined"!=typeof window&&(localStorage.removeItem(h.c),localStorage.removeItem(h.b));const t=p(y);e({wishlistItems:t,fetchOperationVersion:0,wishlistLoading:!1})}const O=c&&!r&&w;if(r=c,O)switch(y){case"swym":n(w);break;case"comfrt":!function(t,e,i){m(this,void 0,void 0,(function*(){var o;const n=null===(o=e().accountStatus)||void 0===o?void 0:o.data,s=(null==n?void 0:n.id)?String(n.id).replace(/\D/g,""):void 0;if(!s)return void console.warn("[wishlistSubstate] Comfrt login sync: no customerId");const r=(0,f.c)(i);if(r)try{yield r.initialize(t,s);const e=S();e.length>0&&b(e,i)}catch(t){console.error("[wishlistSubstate] Comfrt login sync failed:",t)}else console.warn("[wishlistSubstate] Comfrt login sync: no provider")}))}(w,i,y)}}))}return{wishlistItems:r,wishlistLoading:!0,wishlistProvider:s,wishlistMode:t.wishlistMode,fetchOperationVersion:0,setWishlistItems:t=>{e({wishlistItems:t})},setWishlistLoading:t=>{e({wishlistLoading:t})},fetchWishlist:n}};function C(t){return"enabled"===t||"enabledMobileLeft"===t||"enabledMobileMenu"===t?t:"default"}function _(t,e,i){if("default"===e)return!1;if(!i)return"navbar"===t;switch(e){case"enabled":return"navbar"===t;case"enabledMobileLeft":return"mobileLeft"===t;case"enabledMobileMenu":return"menu"===t}}i(31),i(5);const W=r.BentoUI.sharedState((t=>{const e=(0,o.a)(((e,i,...o)=>{var n;return(()=>{if("undefined"!=typeof window){const t=window.location.pathname;"/"===t?window.meta={page:Object.assign(Object.assign({},{}),{pageType:"home"})}:t.startsWith("/collections/")?window.meta={products:[],page:Object.assign(Object.assign({},{}),{pageType:"collection",resourceType:"collection"})}:t.startsWith("/cart")?window.meta={page:Object.assign(Object.assign({},{}),{pageType:"cart"})}:t.startsWith("/search")?window.meta={products:[],page:Object.assign(Object.assign({},{}),{pageType:"searchresults"})}:t.startsWith("/pages/")?window.meta={page:Object.assign(Object.assign({},{}),{pageType:"page",resourceType:"page",resourceId:0})}:t.startsWith("/blogs/")?window.meta={page:Object.assign(Object.assign({},{}),{pageType:"blog",resourceType:"blog",resourceId:0})}:window.meta={page:Object.assign({},{})}}})(),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({device:t.device,isMobile:t.isMobile,themeColor:t.themeColor,showVendor:t.showVendor,soldOutBadgeText:t.soldOutBadgeText,onSaleBadgeText:t.onSaleBadgeText,cardPriceDisplay:t.cardPriceDisplay,wishlistEnabled:t.wishlistEnabled,pdpWishlistLoc:t.pdpWishlistLoc,navWishlistLoc:t.navWishlistLoc,wishlistRemove:null!==(n=t.wishlistRemove)&&void 0!==n?n:"default",showStars:t.showStars,productCardOptionStyle:t.productCardOptionStyle,quickshopButton:t.quickshopButton,soldOutMode:t.soldOutMode,finalSaleContent:t.finalSaleContent,delayShipping:t.delayShipping,detectedCountry:t.detectedCountry,pathname:t.pathname,freeShippingThreshold:t.freeShippingThreshold,config:t.config},(t=>({setModalContent(e){t({modalContent:e})},closeModal(){t({modalContent:null})},modalContent:null}))(e,i,...o)),a(e,i,...o)),function({colorSwatches:t}){const e=function(t){return(e="")=>{var i,o,n,s,r,d;return null!==(o=null===(i=null==t?void 0:t.swatches)||void 0===i?void 0:i.find((t=>t.name.trim()===e.trim())))&&void 0!==o?o:null===(d=[...null!==(n=null==t?void 0:t.swatches_2)&&void 0!==n?n:[],...null!==(s=null==t?void 0:t.swatches_3)&&void 0!==s?s:[],...null!==(r=null==t?void 0:t.swatches_4)&&void 0!==r?r:[]])||void 0===d?void 0:d.find((t=>t.name.trim()===e.trim()))}}(t);return()=>({getOptionNameForColor(t,i){var o,n;if(t)return(null==i?void 0:i.includes(t))?"Clearance Colors":null===(n=null===(o=e(t))||void 0===o?void 0:o.color_option_name)||void 0===n?void 0:n.color_option_name},getHexForOptionColor(t,i){var o,n;const s=function(t,e){var i,o;const n=null===(i=null==e?void 0:e.swatches)||void 0===i?void 0:i[t];if((null==n?void 0:n.color)||(null==n?void 0:n.image))return{hexColor:null!==(o=n.color)&&void 0!==o?o:"#333",swatchStyle:(0,d.c)(n.image,80)}}(t,i);if(s)return s;const r=e(t);return r?"image"!==(null===(o=null==r?void 0:r.swatch_image)||void 0===o?void 0:o.type)?{hexColor:r.color}:{swatchStyle:(0,d.c)(null===(n=r.swatch_image)||void 0===n?void 0:n.url,80),hexColor:r.color}:{swatchStyle:{backgroundImage:"linear-gradient(45deg, #666 25%, #bbb 25%, #bbb 50%, #666 50%, #666 75%, #bbb 75%, #bbb)",backgroundSize:"4px 4px"},hexColor:t.toLowerCase().split(/\s/)[0]}}})}({colorSwatches:t.colorSwatches})(e,i,...o)),(()=>{let t=null;return"undefined"!=typeof window&&(t=new EventTarget,window.__orly_events__=t),{emitEvent(e,i){null==t||t.dispatchEvent(new CustomEvent(e,{detail:i}))}}})(e,i,...o)),((t,e)=>{let i=null;const o=()=>c(void 0,void 0,void 0,(function*(){if(u)return u;i&&i.abort(),i=new AbortController;const o=i.signal;return u=c(void 0,void 0,void 0,(function*(){var i,n,s,d,a;try{const h=null===(i=e())||void 0===i?void 0:i.accountStatus;t({accountStatus:{loggedIn:null!==(n=null==h?void 0:h.loggedIn)&&void 0!==n&&n,data:null==h?void 0:h.data,loading:!0,error:void 0}});const f=yield fetch("/api/account",{signal:o,cache:"no-store"});if(!f.ok)throw new Error("Bad response");const w=yield f.json();if(!("loggedIn"in w))throw new Error("Incorrect response shape:"+JSON.stringify(w));if(!w.loggedIn&&(0,l.a)("customer_token"))return yield c(void 0,void 0,void 0,(function*(){try{yield(0,r.getLazyState)("customerAccessTokenDelete",void 0)}catch(t){console.error("Failed to revoke customer access token:",t)}document.cookie="customer_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="secure_access_token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",document.cookie="auth_provider=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"})),void window.location.reload();t({accountStatus:{loggedIn:!0===w.loggedIn,loading:!1,data:w.loggedIn?w:void 0}});const m=w.currency,v=w.iso_code,g=e().country;if(m&&v&&v!==g)try{if("USD"!==m){if("enabled"!==(null!==(s=(0,r.getAssignment)("internationalPricing"))&&void 0!==s?s:"disabled"))return;t({internationalPricing:!0})}null===(a=(d=e()).updateCountry)||void 0===a||a.call(d,v),yield fetch("/localization",{headers:{"content-type":"application/x-www-form-urlencoded"},body:`_method=PUT&country_code=${v}`,method:"POST",mode:"cors",credentials:"include"})}catch(t){console.error("[Account] Failed to sync localization:",t)}u=null}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(u=null);console.error("Failed to fetch account status:",e),t({accountStatus:{loggedIn:!1,loading:!1,error:e instanceof Error?e.message:"Unknown error",data:void 0}}),u=null}})),u}));return"undefined"!=typeof window&&setTimeout((()=>{o()}),0),{accountStatus:{loggedIn:!1,loading:!0,data:void 0},fetchAccountStatus:o}})(e,i,...o)),O({wishlistProvider:t.wishlistProvider,wishlistMode:t.wishlistMode})(e,i,...o)),{country:t.country,internationalPricing:t.internationalPricing,dynamicCurrencyChange:!1,updateCountry(t){if(i().country!==t&&(e({country:t,dynamicCurrencyChange:"US"!==t}),"undefined"!=typeof window&&window.__ORLY_PRICING_STATE__)){const e=window.__ORLY_PRICING_STATE__;e.batchTimer&&(clearTimeout(e.batchTimer),e.batchTimer=null),e.cache={},e.pendingHandles.clear(),e.pendingCallbacks.clear(),e.config&&(e.config.country=t)}}})}));return function(){function t(t){const e=t.getAttribute("data-orly-type"),i=t.getAttribute("data-orly-handle"),o=t.getAttribute("data-orly-parent-handle");(0,r.logOutcome)(`click:${e}`),(0,r.logOutcome)(`click:${e}:${i}`),o&&(0,r.logOutcome)(`click:${e}:${o}`)}"undefined"!=typeof window&&document.addEventListener("DOMContentLoaded",(e=>{document.body.addEventListener("click",(function(e){let i=e.target;for(;i&&i!==document.body;){if(i.hasAttribute("data-orly-type")&&i.hasAttribute("data-orly-handle")){t(i);break}i=i.parentElement}}))}))}(),e})),M=t=>{const{useSharedStateStore:e}=(0,r.useBento)();return(0,s.a)(e,t,n.a)},T=()=>{const{useSharedStateStore:t}=(0,r.useBento)();return t}},208:(t,e,i)=>{i.d(e,{a:()=>S,b:()=>b,c:()=>y});var o=i(2),n=function(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{a(o.next(t))}catch(t){s(t)}}function d(t){try{a(o.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,d)}a((o=o.apply(t,e||[])).next())}))};const s="swym_regid",r="swym_sessionid",d="otsm_wishlistId",a="otsm_wishlistItems_cache";class l{constructor(){this.type="swym",this.regid=null,this.sessionid=null,this.wishlistId=null}initialize(t){return n(this,void 0,void 0,(function*(){if(this.restoreSession())return void(yield this.ensureWishlistId());const e=yield(0,o.getLazyState)("generateSwymRegid",{value:t});if(!e||"error"in e)throw new Error("Failed to generate Swym session");this.regid=e.regid,this.sessionid=e.sessionid,"undefined"!=typeof window&&(localStorage.setItem(s,this.regid),localStorage.setItem(r,this.sessionid)),yield this.ensureWishlistId()}))}isInitialized(){return!(!this.regid||!this.sessionid)}ensureWishlistId(){return n(this,void 0,void 0,(function*(){if(this.wishlistId)return;if(!this.regid||!this.sessionid)throw new Error("Swym session not initialized");const t=yield(0,o.getLazyState)("getSwymWishlist",{regid:this.regid,sessionid:this.sessionid});if(!t||"error"in t)throw new Error("Failed to fetch Swym wishlist");this.wishlistId=t.lid,"undefined"!=typeof window&&localStorage.setItem(d,this.wishlistId)}))}fetchItems(){return n(this,void 0,void 0,(function*(){if(!this.regid||!this.sessionid)throw new Error("Swym session not initialized");const t=yield(0,o.getLazyState)("getSwymWishlist",{regid:this.regid,sessionid:this.sessionid});if(!t||"error"in t)throw new Error("Failed to fetch Swym wishlist");this.wishlistId=t.lid,"undefined"!=typeof window&&localStorage.setItem(d,this.wishlistId);const e=t.listcontents.map((t=>({variantId:t.epi,productId:t.empi})));return"undefined"!=typeof window&&localStorage.setItem(a,JSON.stringify(e)),e}))}addItem(t){return n(this,void 0,void 0,(function*(){if(!this.regid||!this.sessionid||!this.wishlistId)return{success:!1,error:"Swym session not initialized"};try{const e=yield(0,o.getLazyState)("toggleSwymWishlistItem",{action:"a",listData:{regid:this.regid,sessionid:this.sessionid,lid:this.wishlistId},productData:{epi:t.variantId,empi:t.productId,du:t.productUrl}});return!e||"error"in e?{success:!1,error:"Failed to add item to wishlist"}:{success:!0,item:{variantId:t.variantId,productId:t.productId}}}catch(t){return console.error("[SwymWishlistProvider] addItem error:",t),{success:!1,error:"Failed to add item to wishlist"}}}))}removeItem(t){return n(this,void 0,void 0,(function*(){if(!this.regid||!this.sessionid||!this.wishlistId)return{success:!1,error:"Swym session not initialized"};try{const e=yield(0,o.getLazyState)("toggleSwymWishlistItem",{action:"d",listData:{regid:this.regid,sessionid:this.sessionid,lid:this.wishlistId},productData:{epi:t,empi:0,du:"undefined"!=typeof window?window.location.href:""}});return!e||"error"in e?{success:!1,error:"Failed to remove item from wishlist"}:{success:!0}}catch(t){return console.error("[SwymWishlistProvider] removeItem error:",t),{success:!1,error:"Failed to remove item from wishlist"}}}))}getWishlistId(){return this.wishlistId}clearSession(){this.regid=null,this.sessionid=null,this.wishlistId=null,"undefined"!=typeof window&&(localStorage.removeItem(s),localStorage.removeItem(r),localStorage.removeItem(d),localStorage.removeItem(a))}getStorageKeys(){return[s,r,d,a]}restoreSession(){if("undefined"==typeof window)return!1;const t=localStorage.getItem(s),e=localStorage.getItem(r),i=localStorage.getItem(d);return!(!t||!e||(this.regid=t,this.sessionid=e,this.wishlistId=i,0))}getSessionData(){return this.regid&&this.sessionid&&this.wishlistId?{regid:this.regid,sessionid:this.sessionid,wishlistId:this.wishlistId}:null}getCachedItems(){if("undefined"==typeof window)return[];try{const t=localStorage.getItem(a);if(t)return JSON.parse(t)}catch(t){}return[]}}function c(t,e,i){return o=this,n=void 0,r=function*(){const o=`${function(){if("undefined"==typeof window)throw new Error("comfrtClientFetch can only be called on the client");return`${window.location.origin}/apps/comfrt-wishlist`}()}${e}`,n={method:t,headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"include"};i&&"POST"===t&&(n.body=JSON.stringify(i));try{const t=yield fetch(o,n);if(!t.ok){const e=yield t.text();return console.error(`[comfrtClientFetch] HTTP ${t.status}: ${e}`),{success:!1,error:`API error (${t.status})`}}return yield t.json()}catch(t){return console.error("[comfrtClientFetch] Error:",t),{success:!1,error:t instanceof Error?t.message:"Unknown error"}}},new((s=void 0)||(s=Promise))((function(t,e){function i(t){try{a(r.next(t))}catch(t){e(t)}}function d(t){try{a(r.throw(t))}catch(t){e(t)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s((function(t){t(o)}))).then(i,d)}a((r=r.apply(o,n||[])).next())}));var o,n,s,r}var u=i(5),h=i(232),f=function(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{a(o.next(t))}catch(t){s(t)}}function d(t){try{a(o.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,d)}a((o=o.apply(t,e||[])).next())}))};const w="otsm_comfrt_wishlistId",m="otsm_comfrt_itemIdMap",v="otsm_comfrt_wishlistItems_cache";class g{constructor(){this.type="comfrt",this.customerId=null,this.wishlistId=null,this.itemIdMap={}}initialize(t,e){return f(this,void 0,void 0,(function*(){if(!e)throw new Error("Comfrt provider requires customerId");this.customerId=e,this.restoreSession()}))}isInitialized(){return!!this.customerId}fetchItems(){return f(this,void 0,void 0,(function*(){const t=yield c("GET","/wishlists?include=items");if(!t.success)throw new Error(t.error);const e=t.data||[],i=e[0];i&&(this.wishlistId=i.wishlistId,"undefined"!=typeof window&&this.wishlistId&&localStorage.setItem(w,this.wishlistId));const o=[];this.itemIdMap={};for(const t of e)if(t.items)for(const e of t.items){const t=e.variantId?(0,u.d)(e.variantId):(0,u.d)(e.productId),i=(0,u.d)(e.productId);void 0!==t&&void 0!==i?(o.push({variantId:t,productId:i,itemId:e.itemId,addedAt:e.addedAt}),this.itemIdMap[t]=e.itemId):console.warn("[ComfrtWishlistProvider] Skipping item with invalid GID:",e)}o.sort(((t,e)=>new Date(e.addedAt).getTime()-new Date(t.addedAt).getTime()));const n=o.map((t=>{var{addedAt:e}=t;return function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n`/wishlists/${t}/items/${e}`)(this.wishlistId,e));return i.success?(delete this.itemIdMap[t],"undefined"!=typeof window&&localStorage.setItem(m,JSON.stringify(this.itemIdMap)),{success:!0}):{success:!1,error:i.error}}catch(t){return console.error("[ComfrtWishlistProvider] removeItem error:",t),{success:!1,error:"Failed to remove item from wishlist"}}}))}getWishlistId(){return this.wishlistId}clearSession(){this.customerId=null,this.wishlistId=null,this.itemIdMap={},"undefined"!=typeof window&&(localStorage.removeItem(w),localStorage.removeItem(m),localStorage.removeItem(v))}getStorageKeys(){return[w,m,v]}restoreSession(){if("undefined"==typeof window)return!1;const t=localStorage.getItem(w),e=localStorage.getItem(m);if(t&&(this.wishlistId=t),e)try{this.itemIdMap=JSON.parse(e)}catch(t){this.itemIdMap={}}return!!t}getCachedItems(){if("undefined"==typeof window)return[];try{const t=localStorage.getItem(v);if(t)return JSON.parse(t)}catch(t){}return[]}}let p=null,I=null;function y(t){return t?(p&&I===t||(p=function(t){return"comfrt"===t?new g:new l}(t),I=t),p):null}function S(){p&&p.clearSession(),p=null,I=null}function b(t){var e;if(!t)return[];const i=y(t);return null!==(e=null==i?void 0:i.getCachedItems())&&void 0!==e?e:[]}},233:(t,e,i)=>{function o(t,e){return"product"===e?t.productId:t.variantId}function n(t,e,i="variant"){const n=e.filter((t=>"remove"===t.action)).map((t=>t.variantId)),s=t.filter((t=>!n.includes(t.variantId))),r=new Set(s.map((t=>o(t,i)))),d=e.filter((t=>{if("add"!==t.action)return!1;const e=o(t,i);return!r.has(e)})).map((t=>({variantId:t.variantId,productId:t.productId})));return s.concat(d)}i.d(e,{a:()=>o,b:()=>n})},206:(t,e,i)=>{i.d(e,{a:()=>n});var o=i(4);const n=()=>{const t=(0,o.d)((t=>t.accountStatus)),e=(0,o.d)((t=>t.fetchAccountStatus));return Object.assign(Object.assign({},t),{refetch:e})}},232:(t,e,i)=>{function o(t){return`gid://shopify/Product/${t}`}function n(t){return`gid://shopify/ProductVariant/${t}`}i.d(e,{a:()=>o,b:()=>n})}}]);