Tolstoy widget will appear here.
Click on preview in top right to see widget.
`,gi=()=>g(void 0,null,function*(){const e=document.querySelectorAll("tolstoy-block");if(e.length!==0){if(Ao()){for(const t of Array.from(e))t.outerHTML=hi;return}for(const t of Array.from(e)){const{publishId:o,blockType:s,navType:n,height:i}=t.dataset||{},r={blockType:s,navType:n,height:i};let a="";switch(s){case Dt.PDP_CAROUSEL:a=ui(o);break;case Dt.VIDEO_PAGE:a=ci(o);break}a&&(t.outerHTML=a,pi(t,r))}}}),yi=function(){const t=typeof document!="undefined"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),fi=function(e){return"https://widget.gotolstoy.com/we/"+e},Ye={},P=function(t,o,s){if(!o||o.length===0)return t();const n=document.getElementsByTagName("link");return Promise.all(o.map(i=>{if(i=fi(i),i in Ye)return;Ye[i]=!0;const r=i.endsWith(".css"),a=r?'[rel="stylesheet"]':"";if(!!s)for(let u=n.length-1;u>=0;u--){const p=n[u];if(p.href===i&&(!r||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${a}`))return;const c=document.createElement("link");if(c.rel=r?"stylesheet":yi,r||(c.as="script",c.crossOrigin=""),c.href=i,document.head.appendChild(c),r)return new Promise((u,p)=>{c.addEventListener("load",u),c.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t()).catch(i=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=i,window.dispatchEvent(r),!r.defaultPrevented)throw i})},Vo=({tagName:e,src:t,container:o,attributes:s,style:n,styleString:i,classNames:r,eventListeners:a})=>{const d=document.createElement(e);if(a)for(const[c,u]of Object.entries(a))d.addEventListener(c,u);if(t&&(d.src=t),s)for(const[c,u]of Object.entries(s))d.setAttribute(c,u);if(i&&(d.style.cssText=i),n)for(const[c,u]of Object.entries(n))d.style[c]=u;return r&&d.classList.add(...r),o&&o.append(d),d},Ge=({src:e,container:t,attributes:o})=>Vo({tagName:"script",src:e,container:t,attributes:o}),md=({src:e,container:t,attributes:o,style:s})=>Vo({tagName:"iframe",src:e,container:t,attributes:o,style:s}),mi=({callback:e,classNames:t})=>{const o=c=>t.some(u=>c.getElementsByClassName(u).length>0),s=c=>t.includes(c),n=c=>[...c.classList].some(s),i=c=>c.classList?n(c)||o(c):!1,r=c=>c.type!=="childList"||c.addedNodes.length===0?!1:[...c.addedNodes].some(i),a=c=>{c.some(r)&&e()};new window.MutationObserver(a).observe(document.body,{subtree:!0,childList:!0})},wi=({callback:e})=>{window.addEventListener("DOMContentLoaded",e),window.addEventListener("load",e)},Fo=({callback:e,classNames:t})=>{wi({callback:e}),"MutationObserver"in window&&mi({callback:e,classNames:t})},wd=({video:e,onError:t})=>{var i;if(!e)return Promise.reject(new Error("No video element"));const o=/iPad|iPhone|iPod/.test(navigator.userAgent),s=Number.parseFloat(((i=navigator.userAgent.match(/OS (\d+)_/))==null?void 0:i[1])||"0");return o&&s>=18&&e.readyState<1&&e.load(),e.play().catch(r=>(console.warn("Video play failed:",r),t&&t(r),Promise.reject(r)))},Ei=e=>{const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild},Si=(e,t)=>`${e}-${t}`,Ti=(e,t)=>`[data-tolstoy-element="${Si(e,t)}"]`,Ed=(e,t)=>window.document.querySelector(Ti(e,t)),Sd=(e,t)=>`[${e}="${t}"]`,Td=(e,t)=>window.document.querySelector(`[${e}="${t}"]`),Id=`
`,bd=(e="#FFFFFF")=>``,_d=(e="#fff",t="")=>``,Cd='',Ad='',Od=``,vd=(e="#fff",t="")=>`
`,Rd=({color:e="#fff",className:t=""}={})=>``,Pd=({color:e="#fff",className:t=""}={})=>``,Ii=()=>`
`,bi=()=>`
`;class _i{constructor(t){y(this,"postMessage",t=>{var o;(o=this.broadcaster)==null||o.postMessage(t)});y(this,"addEventListener",(...t)=>{var o;(o=this.receiver)==null||o.addEventListener(...t)});this.name=t||mo();try{"BroadcastChannel"in self&&(this.broadcaster=new BroadcastChannel(this.name),this.receiver=new BroadcastChannel(this.name))}catch(o){console.error("self is not defined",o)}}}class Yo{constructor({shouldIncludeLogs:t=!1,shouldArchivePastEvents:o=!1}={}){y(this,"subscribeMultipleEvents",({eventNames:t,callback:o,shouldIncludePastEvents:s})=>{for(const n of t)this.subscribe({eventName:n,callback:o,shouldIncludePastEvents:s})});y(this,"unsubscribeMultipleEvents",({eventNames:t,callback:o})=>{for(const s of t)this.unsubscribe({eventName:s,callback:o})});this.broadcastHub=new _i,this.eventCallbacks={},this.pastEvents={},this.shouldIncludeLogs=t,this.shouldArchivePastEvents=o}logMessage(t){this.shouldIncludeLogs&&console.log(t)}throwError(t){if(this.shouldIncludeLogs)throw new Error(t)}archivePastEvent(t){if(!this.shouldArchivePastEvents)return;const{eventName:o}=t;this.pastEvents[o]||(this.pastEvents[o]=[]),this.pastEvents[o].push(t)}postMessage(t){this.archivePastEvent(t),this.broadcastHub.postMessage(t)}postPastEvents({eventName:t,callback:o}){if(this.pastEvents[t])for(const s of this.pastEvents[t])o({data:S(f({},s),{isPastEvent:!0})})}subscribe({eventName:t,callback:o,shouldIncludePastEvents:s}){if(this.eventCallbacks[t]||(this.eventCallbacks[t]=new Set),this.eventCallbacks[t].has(o)){this.throwError(`Already subscribed to event ${t} with this callback`);return}this.eventCallbacks[t].add(o),s&&this.postPastEvents({eventName:t,callback:o})}unsubscribe({eventName:t,callback:o}){if(!this.eventCallbacks[t]){this.throwError(`Not subscribed to event ${t}`);return}if(!this.eventCallbacks[t].has(o)){this.throwError("Callback is not subscribed");return}if(!this.eventCallbacks[t].delete(o)){this.logMessage(`Not subscribed to event ${t} with this callback`);return}this.logMessage(`Unsubscribed from event ${t}`)}initListener(t){this.broadcastHub.addEventListener("message",t)}}class at extends Yo{constructor(){if(at.instance)return at.instance;super({shouldArchivePastEvents:!0});y(this,"eventHandler",o=>{const{data:s={}}=o,{eventName:n}=s;if(this.eventCallbacks[n])for(const i of this.eventCallbacks[n])i(o)});y(this,"postMessage",o=>{const s=o.transmissionId||mo();return super.postMessage(S(f({},o),{transmissionId:s})),s});y(this,"init",()=>{this.initListener(this.eventHandler)});at.instance=this}}const h=new at;Object.freeze(h);const Ci={modalOpen:"tolstoyModalOpen",playerReady:"tolstoyPlayerReady",toggleFeedCloseButton:"toggleFeedCloseButton",showFeedProductModal:"showFeedProductModal",reportModalOpen:"tolstoyReportModalOpen",reportModalClose:"tolstoyReportModalClose",modalMessagingReady:"tolstoyModalMessagingReady",closePlayer:"tolstoyClosePlayer",userEmailUpdate:"tolstoyUserEmailUpdate"},Ai={isRebuyAppInstalled:"tolstoyIsRebuyAppInstalled",openRebuyCart:"tolstoyOpenRebuyCart",rebuyCartShown:"rebuyCartShown",rebuyCartHidden:"rebuyCartHidden"},Oi={openKendoModal:"tolstoyOpenKendoModal",changeZIndex:"tolstoyChangeZIndex"},vi={isTapcart:"tolstoyIsTapcart",openTapcartProduct:"tolstoyOpenTapcartProduct"},Ri={getProductsMetafields:"getProductsMetafields",returnProductsMetafields:"returnProductsMetafields"},Pi={isAfterpayAppInstalled:"tolstoyIsAfterpayAppInstalled"},Li={productCardClick:"tolstoyProductCardClick"},Ni={spotlightCarouselQuickShopClick:"tolstoySpotlightCarouselQuickShopClick"},Mi={externalEventSubscribed:"tolstoyExternalEventSubscribed",productCardClickSubscribed:"tolstoyProductCardClickSubscribed"},Ui={setAnonymousIdToCart:"tolstoySetAnonymousIdToCart",blockAnonymousIdToCart:"tolstoyBlockAnonymousIdToCart",addToCart:"tolstoyAddToCart",addToCartSuccess:"tolstoyAddToCartSuccess",addToCartError:"tolstoyAddToCartError",addToCartSoldOut:"tolstoyAddToCartSoldOut",addToCartDisableDefault:"tolstoyAddToCartDisableDefault",cartItemQuantityChange:"tolstoyCartItemQuantityChange",cartItemQuantityChangeSuccess:"tolstoyCartItemQuantityChangeSuccess",cartItemQuantityChangeError:"tolstoyCartItemQuantityChangeError",cartDataRequest:"tolstoyCartDataRequest",cartDataResponse:"tolstoyCartDataResponse"},Di={loginWithMultipassUrlRequest:"tolstoyLoginWithMultipassUrl",loginWithMultipassUrlResponse:"tolstoyLoginWithMultipassUrlResponseMessage"},ki={productRecommendationsRequest:"tolstoyProductRecommendationsRequest",productRecommendationsResponse:"tolstoyProductRecommendationsResponse"},$i={requestProductsUpdate:"tolstoyRequestProductsUpdate",productUpdateResponse:"tolstoyProductUpdateResponse",moveToUrl:"tolstoyMoveToUrl",isNonBaseCurrency:"tolstoyIsNonBaseCurrency"},Bi={urlChange:"urlChange",urlLocaleUpdate:"tolstoyUrlLocaleUpdate"},xi={openCommerceSettingsUpdate:"tolstoyOpenCommerceSettingsUpdate"},l=S(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f({},Ci),Ai),Oi),Pi),Ri),Li),Ni),Mi),vi),Ui),Di),ki),$i),Bi),xi),{rejectCookiePolicy:"rejectCookiePolicy"}),Go="widget-loading",Ld="widget-onyou",Nd="widget-onyou-enableAllPages",Hi="widget-video-fallback",Md="carousel-show-dots",Ud="carousel-videos",Dd="hide-spotlight-plus-button",kd="app-use-creator-profile",Wi="block-shopify-add-to-cart-attribute",$d="shopify-price-formatting",Vi="Nunito Sans, sans-serif",Bd="tolstoy-custom-font-family",xd="tolstoy-custom-heading-font-family",je=[];function Fi(e,t){const o="italic",s="normal",n={".ttf":"truetype",".otf":"opentype",".woff":"woff",".woff2":"woff2"},i=document.createElement("style");for(const r of Object.keys(e)){const a=e[r],d=r.includes(o),c=r.split("-")[1]||r.replace(o,"")||s,u=d?o:s,p=Object.keys(n).find(v=>a.includes(v)),w=n[p],I=a.replace("http://","https://");i.append(document.createTextNode(`@font-face { font-family: '${t}'; src: url("${I}") format("${[w]}"); font-weight: ${c}; font-style: ${u}; font-display: swap;}`))}document.head.append(i)}const jo=(e,t=1)=>{if(!(!e||t===3)){if(!document.querySelector("#tolstoyWidgetElement")){setTimeout(()=>{jo(e,t+1)},1e3);return}document.querySelector("#tolstoyWidgetElement").style.fontFamily=`${e}, ${Vi}`}},Yi=e=>{const t=document.head.querySelectorAll("style");return Array.from(t).some(o=>o.textContent.includes(`@font-face { font-family: '${e}';`))};function Ke(e,t="tolstoy-custom-font-family"){if(!e||je.includes(t)||Yi(t))return;const{sources:o}=e;Fi(o,t),jo(t),je.push(t)}let it,qe="";const Gi=e=>{var o;const t=document.querySelector("#smile-ui-container");e&&(qe=(t==null?void 0:t.style.display)||""),(o=t==null?void 0:t.style)==null||o.setProperty("display",e||qe)},ji=e=>{let t=0;return o=>{try{o()}catch(s){try{if(!N())return;fetch("https://api.gotolstoy.com/events/event",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({eventName:"widgetError",text:s.message,timestamp:new Date().toISOString(),parentUrl:window.location.href,appKey:e.data.appKey,publishId:e.data.publishId,sessionId:e.data.sessionId,source:e.data.name,answerKey:`${t}`,currentPageProductId:o.toString(),formData:`${(s&&s.stack||"").slice(0,1999)}`})})}catch(n){Eo(n)}}finally{t++}}},Ki=e=>{if(e.data.name===m.sessionStart||e.data.name===H.autoplayStart){const t=ji(e);t(()=>Cn(e.data.publishId)),t(()=>kn(e.data.appKey,e.data.appUrl)),t(()=>Ho(e.data.sessionId)),t(()=>Wn(e.data.publishId,e.data.sessionId)),t(()=>Gi("none")),t(()=>qi(e.data.anonymousId))}},qi=e=>{window.Shopify&&h.postMessage({eventName:l.setAnonymousIdToCart,anonymousId:e})},Hd=({data:{name:e,publishId:t,productIds:o}={}})=>{if(e===bs)for(const s of o)An({productId:s,publishId:t})},Wd=e=>{Ze[e.data.name]&&Ze[e.data.name](e.data)},Vd=e=>{Qe[e.data.name]&&setTimeout(()=>Qe[e.data.name](),500)},zi=()=>{var e,t;window.GorgiasChat&&((t=(e=window.GorgiasChat).open)==null||t.call(e),window.tolstoyWidget.hide(),document.head.insertAdjacentHTML("beforeend",""))},Zi=()=>{var e,t;window.GorgiasChat&&((t=(e=window.GorgiasChat).close)==null||t.call(e),document.head.insertAdjacentHTML("beforeend",""))},Qi=()=>{window.adaEmbed&&(window.adaEmbed.toggle(),window.tolstoyWidget.hide())},Xi=()=>{document.head.insertAdjacentHTML("beforeend","")},Ji=()=>{window.fcWidget&&(window.fcWidget.show(),window.fcWidget.open(),window.tolstoyWidget.hide())},tr=()=>{window.fcWidget&&(window.fcWidget.close(),window.fcWidget.hide(),window.tolstoyWidget.show())},er=()=>{var e,t;if(!it&&((e=window.Reamaze)!=null&&e.popup)){window.Reamaze.popup(),window.tolstoyWidget.hide();return}window._support&&it&&((t=window.Reamaze)!=null&&t.reload)&&(window._support.ui=it,window.Reamaze.reload(),it=null,window.tolstoyWidget.hide())},or=()=>{var e,t;(e=window._support)!=null&&e.ui&&((t=window.Reamaze)!=null&&t.reload)&&(it=window._support.ui,delete window._support.ui,window.Reamaze.reload(),window.tolstoyWidget.show())},sr=()=>{const e=setTimeout(()=>clearInterval(t),9e3),t=setInterval(()=>{window.Intercom&&(window.Intercom("show"),window.tolstoyWidget.hide(),clearInterval(t),clearTimeout(e),window.Intercom("onHide",()=>{window.tolstoyWidget.show()}))})},nr=()=>{const e=setTimeout(()=>clearInterval(t),9e3),t=setInterval(()=>{window.Intercom&&(window.Intercom("update",{hide_default_launcher:!0}),clearInterval(t),clearTimeout(e))},100)},ir=()=>{window.Tawk_API&&(window.Tawk_API.maximize(),window.tolstoyWidget.hide())};function rr(){window.Tawk_API&&window.Tawk_API.hideWidget()}const ar=()=>{window.LiveChatWidget&&(window.LiveChatWidget.call("maximize"),window.tolstoyWidget.hide())};function cr(){window.LiveChatWidget&&window.LiveChatWidget.call("hide")}const lr=()=>{window.HubSpotConversations&&window.HubSpotConversations.widget&&(window.HubSpotConversations.widget.open(),window.tolstoyWidget.hide())};function dr(){window.HubSpotConversations&&window.HubSpotConversations.widget&&window.HubSpotConversations.widget.close()}const ur=()=>{window.Beacon&&(window.Beacon("open"),window.tolstoyWidget.hide(),window.Beacon("config",{display:{zIndex:"99999"}}))},pr=()=>{window.Beacon&&window.Beacon("config",{display:{zIndex:"0"}})},hr=()=>{window.drift&&(window.drift.api.toggleChat(),window.tolstoyWidget.hide())},gr=()=>{window.drift&&window.drift.api.widget.hide()},yr=()=>{var e,t;window.zE&&(window.zE("messenger","open"),(t=(e=document.querySelector('[title="Button to launch messaging window"]'))==null?void 0:e.style)==null||t.setProperty("display","block"),window.tolstoyWidget.hide())},fr=()=>{const e=setTimeout(()=>clearInterval(t),5e3),t=setInterval(()=>{var n,i,r;const o=document.querySelector('[title="Button to launch messaging window"]'),s=document.querySelector('[title="Message from company"]');(n=o==null?void 0:o.style)==null||n.setProperty("display","none"),(r=(i=s==null?void 0:s.parentElement)==null?void 0:i.style)==null||r.setProperty("display","none"),o&&s&&(clearInterval(t),clearTimeout(e))},100);window.zE&&window.zE("messenger","close")},mr=()=>{window.tidioChatApi&&(window.tidioChatApi.show(),window.tidioChatApi.open(),window.tolstoyWidget.hide())},wr=()=>{window.tidioChatApi&&window.tidioChatApi.close()},Er=e=>{if(window.certainly)switch(window.certainly.widgetStatus({action:"open"}),window.tolstoyWidget.hide(),e.data.key){case"PmkMI":window.certainly.goTo({module:"670442"});break;case"_23Hl":window.certainly.goTo({module:"670178"});break;case"P9rfq":window.certainly.goTo({module:"670179"});break}},Sr=()=>{window.certainly&&window.certainly.widgetStatus({action:"hide"})},ze=e=>{document.head.insertAdjacentHTML("beforeend",``)},Tr=()=>{ze("#vfChat+div"),ze("#vfChat+div+div")},Ir="tolstoyHideFreshChat",br="tolstoyOpenFreshChat",_r="tolstoyHideReamaze",Cr="tolstoyOpenReamaze",Ar="tolstoyHideAda",Or="tolstoyOpenAda",vr="tolstoyHideTidio",Rr="tolstoyOpenTidio",Pr="tolstoyHideCertainly",Lr="tolstoyOpenCertainly",Nr="tolstoyHideVfChat",Ze={[m.openGorgias]:zi,[m.openIntercom]:sr,[m.openTawkTo]:ir,[m.openLiveChat]:ar,[m.openHubSpot]:lr,[m.openDrift]:hr,[m.openZendesk]:yr,[m.openHelpScout]:ur,[br]:Ji,[Cr]:er,[Or]:Qi,[Rr]:mr,[Lr]:Er},Qe={[m.hideGorgias]:Zi,[m.hideIntercom]:nr,[m.hideTawkTo]:rr,[m.hideLiveChat]:cr,[m.hideHubSpot]:dr,[m.hideDrift]:gr,[m.hideZendesk]:fr,[m.hideHelpScout]:pr,[Ir]:tr,[_r]:or,[Ar]:Xi,[Nr]:Tr,[vr]:wr,[Pr]:Sr};class Mr{constructor({config:t,playerType:o,collectionId:s}){this.config=t,this.publishId=t.publishId,this.playerType=o,this.sessionId=Ce()||Mt(),this.anonymousId=tt(),this.currentPageProductId=Ht(),this.collectionId=s,this.errors={}}getIsMobile(){return window.screen.width<=450||window.screen.height<=450}getAnalyticsParams(t={}){var c;const{id:o,appKey:s,name:n,googleAnalyticsID:i}=this.config,r=window.location.href.split("?")[0],a=(c=window.Shopify)==null?void 0:c.shop,d=this.errors;return f({appKey:s,publishId:this.publishId,sessionId:this.sessionId,anonymousId:this.anonymousId,currentPageProductId:this.currentPageProductId,isMobile:this.getIsMobile(),pageUrl:r,storeUrl:a,appUrl:a,googleAnalyticsID:i,projectId:o,playlist:n,timestamp:new Date().toISOString(),parentUrl:window.location.href,playerType:this.playerType,customParams:d?JSON.stringify(d):void 0,collectionId:this.collectionId},t)}sendEventToAllSources(t){pe(t),Kt({data:S(f({},t),{name:t.eventName})})}sendEventImmediately(t={},o=!1){const s=this.getAnalyticsParams(t);_o(s),!o&&Kt({data:S(f({},s),{name:s.eventName})})}sendEvent(t={},o=!1){if(!N())return;const s=this.getAnalyticsParams(t);s.eventName===T.onYouClick&&console.log("Analytics::sendEvent::params",s),pe(s),!o&&Kt({data:S(f({},s),{name:s.eventName})})}handlePageView(){qt(this.publishId,!1),this.sendEvent({eventName:T.pageView})}handleEmbedView(){qt(this.publishId,!0),this.sendEvent({eventName:T.embedView})}handleOnYouClick(){qt(this.publishId,!0),Ho(this.sessionId),this.sendEvent({eventName:T.onYouClick})}handleSessionStart(){const t=this.getAnalyticsParams({eventName:T.sessionStart});this.sendEventToAllSources(t),Ki({data:S(f({},t),{name:m.sessionStart})}),window.postMessage(S(f({},t),{name:m.sessionStart}),"*")}handleVideoLoaded(t={}){const o=this.getAnalyticsParams(S(f({},t),{eventName:T.videoLoaded}));this.sendEventToAllSources(o)}handleVideoWatched(t={}){const o=this.getAnalyticsParams(S(f({},t),{eventName:T.videoWatched}));this.sendEventToAllSources(o)}}const zt={A:"A",B:"B"};class Ur{constructor(t){this.widgetType=t}sendAbTestInitializedEvent({abTestId:t,group:o,excludeExternalAnalytics:s,probability:n}){const i={abTestId:t,eventName:T.abTestInitialized,sessionUniqueId:Ae(),testGroup:o,probability:n};this.analytics.sendEventImmediately(i,s)}initializeGroup({abTestId:t,probability:o,excludeExternalAnalytics:s}){const n=Gn(t);if(n){this.group=n;return}const r=Math.random()>o?zt.B:zt.A;this.group=r,this.sendAbTestInitializedEvent({abTestId:t,group:r,excludeExternalAnalytics:s,probability:o}),Yn(t,r)}init(t){if(!t)return;const{abTestSettings:o={}}=t,{isEnabled:s,abTestId:n,probability:i,groupASettings:r={},groupBSettings:a={},excludeExternalAnalytics:d}=o;if(s)return this.analytics=new Mr({config:t,playerType:this.widgetType}),this.initializeGroup({abTestId:n,probability:i,excludeExternalAnalytics:d}),this.group===zt.A?r:a}}const Re=({config:e,featureKey:t})=>{var o;return(o=e==null?void 0:e.featureSettings)==null?void 0:o[t]},Dr=({config:e,featureKey:t})=>{var o;return!!((o=e==null?void 0:e.featureSettings)!=null&&o[t])},Fd=(e={})=>{const t=Re({config:e,featureKey:Go});return t==null?void 0:t.playerLazy},Ko=(e={})=>{const t=Re({config:e,featureKey:Go});return t==null?void 0:t.playerOrigin},Yd=(e={})=>{const t=Re({config:e,featureKey:Hi});return t==null?void 0:t.dontUseFallback},Gd=".webp",jd={VIDEO:"video",IMAGE:"image",GALLERY:"gallery"},nt={XS:250,S:480,M:960,L:1280,XL:1920},Kd={[nt.XS]:"_250",[nt.S]:"_480",[nt.M]:"_960",[nt.L]:"_1280",[nt.XL]:"_1920"},qo={"250x140":"250x140","250x250":"250x250","480x480":"480x480","960x540":"960x540"},zo=({path:e=`${fo}/public`,ownerId:t="",assetId:o="",suffix:s="",extension:n=""})=>`${e}/${t}/${o}/${o}${s}${n}`,qd=({stockAsset:e={},posterSettings:t={}})=>{const{useShopifyPoster:o=!0}=t,{shopifyPosterUrl:s,posterUrl:n}=e||{};return s&&o?s:n},kr=({step:e,extension:t,posterSettings:o,size:s=qo["250x250"],custom:n={condition:"",callback:""},path:i=`${fo}/public`})=>{var B;const{videoOwner:r,videoId:a,stockAsset:d={},mediaAssets:c}=e;if(!a)return"";const{avatarUrl:u,posterUrl:p,hasOriginal:w,shopifyPosterUrl:I}=d||{},{shopifyAttributes:v={},shopifySpotlightAttributes:E={},useShopifyPoster:A=!1}=o||{},_=f(f({},v),E),U=!!((B=Object.keys(_))!=null&&B.length),D=I&&A&&U;if(p)return p;if(c&&(c!=null&&c.images)&&(c!=null&&c.images[s])&&!D)return c.images[s];const k=!w&&(u||p);if(I&&!1){let ot="width=300";return A&&(ot=new URLSearchParams(_).toString()),`${I}&${ot}`}return p!=null&&p.endsWith(t)||p&&!w?p:n!=null&&n.condition&&(n!=null&&n.callback)&&n.condition({posterUrl:p,avatarUrl:u,extension:t,isDuplicated:k})?n.callback(d):zo({path:i,ownerId:r,assetId:a,extension:t})},$r=".avatar.0000000.webp",Br=".401.0000000.webp",zd=".avatar.0000000.jpg",Zd=".0000000.jpg",xr=480,Hr=({isMobile:e,isStory:t,isPlayInTileFirst:o,isTile:s})=>o||s?"_640.mp4":e||t?"_preview.mp4":"_preview_embed.mp4",Xe=({step:e,isStory:t,isPlayInTileFirst:o,height:s=Os,isTile:n})=>{const{videoOwner:i,stockAsset:r,videoId:a}=e,d=window.innerWidth<=450,c=Hr({isMobile:d,isStory:t,isPlayInTileFirst:o,isTile:n}),u=r==null?void 0:r.videoUrl,p=!!(r!=null&&r.shopifyFileId),w=r==null?void 0:r.previewUrl,I=r==null?void 0:r.hasOriginal,v=r==null?void 0:r.gifUrl,E=p&&!I;return w&&!o&&s{const n=window.innerWidth<=450?$r:Br;return kr({step:e,extension:n,posterSettings:t,size:o})},Xd=(e,t)=>{const o=()=>{if(e.autoplay){e.src="";return}e.src=t};e.addEventListener("ended",o,{once:!0})},Wr=(e,t,o)=>o?`${e}-${t}-${o}`:`${e}-${t}`,Jd=e=>e.dataset.publishId?e.dataset.publishId.toLowerCase():e.id?e.id.split("_")[0].toLowerCase():"",tu=e=>{var t;return(t=e==null?void 0:e.dataset)==null?void 0:t.collectionId},eu=e=>{var s,n,i,r,a,d;const t=(i=(n=(s=e==null?void 0:e.design)==null?void 0:s.branding)==null?void 0:n.typography)==null?void 0:i.font,o=(d=(a=(r=e==null?void 0:e.design)==null?void 0:r.branding)==null?void 0:a.typography)==null?void 0:d.fontHeading;!(t!=null&&t.family)&&!(o!=null&&o.family)||(t!=null&&t.family&&Ke(t),o!=null&&o.family&&Ke(o,"tolstoy-custom-heading-font-family"))},ou=({step:e,embedMotion:t,isStory:o,loadAll:s=!1,isCarouselPlayInTileFirst:n})=>{if(t===rt.static||n)return null;const r=window.innerWidth<=450,a=t===rt.hoverOver,d=t===rt.dynamic;return d&&s?Xe({step:e,isStory:o}):a&&r||d?null:Xe({step:e,isStory:o})},Vr=e=>{const t=e.getBoundingClientRect();return t.top>=-t.height&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},Zo=(e,t)=>window.document.querySelectorAll(`[data-tolstoy-element="${Wr(e,t)}"]`),Fr=({videoClass:e,publishId:t,removeEventListenerFunction:o})=>{const s=Zo(e,t);for(const n of s)n.pause(),o==null||o(n)},Yr=({videoClass:e,publishId:t,setIsDynamicVideoRunning:o,onVideoEnd:s})=>{o(!1),Fr({videoClass:e,publishId:t,removeEventListenerFunction:n=>{n.removeEventListener("ended",s)}})},su=({videoClass:e,isDynamicVideoRunning:t,setIsDynamicVideoRunning:o,dynamicVideoHandler:s,publishId:n,onVideoEnd:i})=>{const r=Zo(e,n);if(r.length===0)return;const a=Vr(r[0]);!a&&t?(Yr({videoClass:e,publishId:n,setIsDynamicVideoRunning:o,onVideoEnd:i}),o(!1)):a&&!t&&(s(),o(!0))},nu=r=>g(void 0,[r],function*({publishId:e,productId:t,widgetType:o,tags:s,appUrl:n,variantId:i}){const a=t&&t!==Ws?cn:an,d=window.tolstoyAppKey||R()||"",c=new URLSearchParams(window.location.search),u=i||c.get("variant"),p=yield a({productId:t,defaultPublishId:e,widgetType:o,appKey:d,tags:s,appUrl:n,variantId:u});return(new Ur(o).init(p)||{}).hideElement?{disabled:!0}:(p!=null&&p.disabled||(Dr({config:p,featureKey:Wi})&&h.postMessage({eventName:l.blockAnonymousIdToCart,appKey:d}),p!=null&&p.openCommerceSettings&&h.postMessage({eventName:l.openCommerceSettingsUpdate,openCommerceSettings:p.openCommerceSettings})),p)});function iu(e,t){return!!(t==null?e:!t)}const ru=e=>{const t=a=>{const d=Ei(a);return d.style.verticalAlign="middle",d.style.margin="0 5px",d.style.marginBottom="3px",d},o=document.createElement("p"),s=t(Ii()),n=t(bi());return o.append(s),({"Invalid publishId":["Add the publish ID from the",n,"tab of your project in Tolstoy"],"Project is not live":["Your project is in draft. Publish project in the",n," tab of your project in Tolstoy"],"Project is deleted":["Project has been deleted"],"No videos found":["Select videos in the Videos tab of your project in Tolstoy"],"No filtered videos found":["Select videos in the Videos tab of your project in Tolstoy"],"No connections found":["Select videos in the Videos tab of your project in Tolstoy"],"No videos found for product":["Add tagged videos for this product in the Videos tab of your project in Tolstoy"]}[e]||["Couldn't find product page"]).forEach(a=>{typeof a=="string"?o.append(document.createTextNode(a)):o.append(a)}),o},Gr=({element:e})=>{const t=e.getBoundingClientRect();return t.width===0||t.height===0?!1:t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},au=()=>new URLSearchParams(window.location.search).get("variant");function jr(e){function t(){n&&(o.length>0&&/^[~+>]$/.test(o[o.length-1])&&o.push(" "),o.push(n))}var o=[],s,n,i,r=[0],a=0,d,c=/(?:[^\\]|(?:^|[^\\])(?:\\\\)+)$/,u=/^\s+$/,p=[/\s+|\/\*|["'>~+[(]/g,/\s+|\/\*|["'[\]()]/g,/\s+|\/\*|["'[\]()]/g,null,/\*\//g];for(e=e.trim();;)if(n="",i=p[r[r.length-1]],i.lastIndex=a,s=i.exec(e),s)if(d=a,a=i.lastIndex,d0)r.pop();else if(/^(?:\s+|[~+>])$/.test(s[0])&&(o.length>0&&!u.test(o[o.length-1])&&r[r.length-1]===0&&o.push(" "),r[r.length-1]===1&&o.length===5&&o[2].charAt(o[2].length-1)==="="&&(o[4]=" "+o[4]),u.test(s[0])))continue;o.push(s[0])}else o[o.length-1]+=n,c.test(o[o.length-1])&&(r[r.length-1]===4&&(o.length<2||u.test(o[o.length-2])?o.pop():o[o.length-1]=" ",s[0]=""),r.pop()),o[o.length-1]+=s[0];else{n=e.substr(a),t();break}return o.join("").trim()}function kt(e,t=document,o=null){return Kr(e,!0,t,o)}function Kr(e,t,o,s=null){e=jr(e);let n=o.querySelector(e);return document.head.createShadowRoot||document.head.attachShadow?!t&&n?n:Zt(e,",").reduce((r,a)=>{if(!t&&r)return r;const d=Zt(a.replace(/^\s+/g,"").replace(/\s*([>+~]+)\s*/g,"$1")," ").filter(I=>!!I).map(I=>Zt(I,">")),c=d.length-1,u=d[c][d[c].length-1],p=Zr(u,o,s),w=qr(d,c,o);return t?(r=r.concat(p.filter(w)),r):(r=p.find(w),r||null)},t?[]:null):t?o.querySelectorAll(e):n}function qr(e,t,o){return s=>{let n=t,i=s,r=!1;for(;i&&!zr(i);){let a=!0;if(e[n].length===1)a=i.matches(e[n]);else{const d=[].concat(e[n]).reverse();let c=i;for(const u of d){if(!c||!c.matches(u)){a=!1;break}c=Je(c,o)}}if(a&&n===0){r=!0;break}a&&n--,i=Je(i,o)}return r}}function Zt(e,t){return e.match(/\\?.|^$/g).reduce((o,s)=>(s==='"'&&!o.sQuote?(o.quote^=1,o.a[o.a.length-1]+=s):s==="'"&&!o.quote?(o.sQuote^=1,o.a[o.a.length-1]+=s):!o.quote&&!o.sQuote&&s===t?o.a.push(""):o.a[o.a.length-1]+=s,o),{a:[""]}).a}function zr(e){return e.nodeType===Node.DOCUMENT_FRAGMENT_NODE||e.nodeType===Node.DOCUMENT_NODE}function Je(e,t){const o=e.parentNode;return o&&o.host&&o.nodeType===11?o.host:o===t?null:o}function Zr(e=null,t,o=null){let s=[];if(o)s=o;else{const n=function(i){for(let r=0;rn.matches(e)):s}const $t=(e,t,o,s=null)=>{if(!e||e.length===0)return;e.forEach(i=>t.add(i));const n=Array.from(t);s&&s(n),o(n)},Qr=(e,t,o=null)=>setInterval(()=>{const n=Array.from(kt("img")).filter(i=>!e.has(i));n.length>0&&$t(n,e,t,o)},2e3),Xr=(e,t,o,s=null)=>{const n=new IntersectionObserver(i=>{let r=!1;i.forEach(a=>{if(a.isIntersecting){const c=a.target.querySelectorAll("img");if(c.length>0){const u=Array.from(c).filter(p=>!e.has(p));u.length>0&&($t(u,e,t,s),r=!0)}}}),r&&(o.current=Date.now())},{root:null,rootMargin:"100px",threshold:.1});return n.observe(document.body),n},Jr=(e,t,o,s,n=null)=>{const i=new MutationObserver(r=>{let a=!1;const d=[];if(r.forEach(c=>{c.type==="childList"?(Array.from(c.addedNodes).forEach(u=>{if(u.nodeName==="IMG")d.push(u),a=!0,s.observe(u);else if(u.querySelectorAll){const p=Array.from(u.querySelectorAll("img"));p.length>0&&(d.push(...p),a=!0,p.forEach(w=>s.observe(w)))}u.nodeType===1&&s.observe(u)}),Array.from(c.removedNodes).forEach(u=>{(u.nodeName==="IMG"||u.querySelectorAll&&u.querySelectorAll("img").length>0)&&(a=!0)})):c.type==="attributes"&&c.attributeName==="src"&&(a=!0)}),a)if(o.current=Date.now(),d.length>0)$t(d,e,t,n);else{const u=Array.from(kt("img")).filter(p=>!e.has(p));u.length>0&&$t(u,e,t,n)}});return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src"]}),i},ta=(e,t,o,s,n)=>{let i=null;const r={current:Date.now()};function a(){Date.now()-r.current>=e?(clearTimeout(t),clearTimeout(i),n(o)):i=setTimeout(a,100)}return i=setTimeout(a,100),{timeoutId:i,lastChangeTimeRef:r}};function ea(e=3e3,t=1e4,o=null){let s=Array.from(kt("img"));const n=new Set;let i=null,r=null,a=null;return new Promise(c=>{i=c,s.length>0&&(s.forEach(w=>n.add(w)),o&&o(s),c(s)),r=setTimeout(()=>{s=Array.from(kt("img")),s.forEach(w=>n.add(w)),o&&o(s),c(s)},t),a=ta(e,r,s,n,c).lastChangeTimeRef,Qr(n,i,o);const p=Xr(n,i,a,o);Jr(n,i,a,p,o)})}const oa=e=>{var o,s,n;let t=e;if(t){if(((o=t.parentElement)==null?void 0:o.tagName)==="PICTURE"&&(t=e.parentElement),!t.parentElement){const i=((s=t==null?void 0:t.shadowRoot)==null?void 0:s.host)||((n=t==null?void 0:t.parentNode)==null?void 0:n.host);if(i)t=i;else if(e.parentElement)t=e;else return}return t}},sa=e=>{const t=e.getBoundingClientRect();return t.width>200&&t.height>200};function na(e){const t=window.getComputedStyle(e),o=[":hover",":focus",":active",":visited",":focus-within",":focus-visible",":target",":checked",":disabled"],s=[];for(const i of document.styleSheets){let r=[];try{r=i.cssRules||i.rules}catch(d){}const a=(d,c=null)=>{for(const u of d){if(u instanceof CSSMediaRule&&a(u.cssRules,u.conditionText||u.media.mediaText),!(u instanceof CSSStyleRule))continue;const p=u.selectorText.replace(new RegExp(o.join("|"),"g"),"").trim();if(p)try{p&&e.matches(p)&&s.push({selector:u.selectorText,style:u.style,cssText:u.cssText,originalRule:u,media:c?{condition:c,matches:window.matchMedia(c).matches}:null})}catch(w){}}};a(r)}const n=e.style.cssText?{selector:"inline",cssText:e.style.cssText}:null;return{computed:Object.fromEntries(Array.from(t).map(i=>[i,t.getPropertyValue(i)])),rules:n?[...s,n]:s}}function to(e){let t;const o=document.styleSheets;for(const s of o)if(!s.href){t=s;break}if(!t){const s=document.createElement("style");document.head.append(s),t=s.sheet}t.insertRule(e,t.cssRules.length)}function ia(e){const{rules:t}=na(e);t.forEach(o=>{if(o.selector.includes("img")){const s=o.cssText.replace(/img\s*\+\s*img/,`img + .${X.collectionTileHoverWrapper}`);if(s===o.cssText){const n=o.cssText.replace("img",`.${X.collectionTileHoverWrapper}`);to(n)}else to(s)}})}const ra=e=>{const t=e.attributes,o=new Set;for(const s of t){const n=String(s.value||"").split(/[,\s]+/).filter(Boolean);for(const i of n){const r=Qo(i);r&&o.add(r)}}return Array.from(o)},aa=e=>{const t=e.attributes,o=new Set;for(const s of t){const n=String(s.value||"").split(/[,\s]+/).filter(Boolean);for(const i of n){const r=Xo(i);r&&o.add(r)}}return o};function Qo(e){try{return!e||!e.includes("//")?null:new URL(e!=null&&e.startsWith("//")?`https:${e}`:e).pathname.split("/").pop().split(".").slice(0,-1).join(".")}catch(t){return null}}function Xo(e){if(typeof e!="string")return null;const t=e.toLowerCase(),o=/[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}/,s=t.match(o);return s?s[0]:null}const ca=({config:e,project:t,collectionId:o},s)=>{var i;if(!e||!t||!o)return;const n=((i=e.settings||ks)==null?void 0:i.playMode)===me.HOVER;Object.entries((e==null?void 0:e.productsMap)||{}).forEach(([r,a])=>{var I,v;const d=((I=a==null?void 0:a.images)==null?void 0:I.map(E=>E.src))||((v=a==null?void 0:a.variants)==null?void 0:v.map(E=>E==null?void 0:E.imageUrl));if(!d)return;const c=d.map(E=>Qo(E)),u=d.map(E=>Xo(E)).filter(Boolean);let p=s.map(({fileNames:E,fileUuidsSet:A,element:_,isLarge:U,externalElement:D})=>{let k=-1;return u.length>0&&(k=u.findLastIndex($=>A.has($))),k===-1&&(k=c.findLastIndex($=>E.some(B=>B.includes($)&&B.length<1.3*$.length))),{imgElement:_,externalImgElement:D,imageIndex:k,isLarge:U,fileName:c[k]}}).filter(({imageIndex:E})=>E!==-1);xt("filtered by src img elements",{imgElements:s,filteredImgElements:p,productFileNames:c,productUuids:u});const w=p.filter(({isLarge:E})=>E);if(w.length>0&&(p=w),p.length>0){const{externalImgElement:E}=p.at(n?0:-1),A=[...E.classList].join(" ").split(" ").filter(Boolean),_=document.createElement("div");if(_.innerHTML=``,E.parentElement)if(n){ia(E);const{width:U,height:D}=E.getBoundingClientRect();_.style.width=`${U}px`,_.style.height=`${D}px`,_.classList.add(X.collectionTileHoverWrapper,...A),_.firstChild.style.zIndex="0",E.style.display="none",E.parentElement.insertBefore(_,E),_.append(E)}else A&&_.firstChild.classList.add(...A),_.firstChild.style.zIndex="1",E.parentElement.insertBefore(_.firstChild,E)}})},la=(e,t,o)=>{if(!e||e.length===0)return;e.forEach(n=>t.add(n));const s=da(e);pa(s,o)},da=e=>e.map(t=>({element:t,externalElement:oa(t),isLarge:sa(t),fileNames:ra(t),fileUuidsSet:aa(t)})).reverse(),ua=(e,t)=>{if(!t)return e;const o=t.split(",").flatMap(n=>[n,`${n} img`]).join(","),s=document.querySelectorAll(o);return e.filter(n=>[...s].some(i=>i.contains(n)))},pa=(e,t)=>{t.forEach(o=>ca(o,e))},ha=(e,t,o)=>{const{playerSettings:s,widgetSettings:n}=o[0].project,i=n.collectionTileSettings.playMode===me.HOVER,r=s.gallerySelector||"",a=s.galleryImageSelector||"",d=i&&s.galleryImageSecondarySelector,c=(i?d:a)||r,u=ua(e.filter(p=>!t.has(p)),c);return c&&xt("filter new images with selector",{playerSettings:s,widgetSettings:n,imgElements:e,filteredBySelectorImages:u,processedImageElements:t,filterSelector:c}),u},eo=(e,t,o)=>{if(!e||e.length===0)return;const s=ha(e,t,o);s.length!==0&&(xt("processImages",{imgElements:e,newImages:s}),la(s,t,o))},ga=e=>g(void 0,null,function*(){if(!(e!=null&&e.length)||document.querySelector(`.${X.collectionTile}`))return;const t=new Set,s=yield ea(3e3,1e4,n=>{eo(n,t,e)});eo(s,t,e)}),Qt="data-status",Xt=[ft],Ct={loading:"loading",loaded:"loaded",failed:"notFound"},ya=()=>{var t,o;const e=(o=(t=document.querySelector("script[data-collection-id]"))==null?void 0:t.dataset)==null?void 0:o.collectionId;return e!=null&&e.includes("{{ collection.id")||!e?null:e},fa=({element:e,callback:t,outOfViewCallback:o})=>{const s=new window.IntersectionObserver(n=>{n[0].isIntersecting===!0&&n[0].intersectionRatio>.9?(o||s.unobserve(e),t()):n[0].intersectionRatio<.1&&(o==null||o())},{threshold:[.1,.9]});s.observe(e)};class ma{constructor({name:t,component:o,elementClassname:s}){this.name=t,this.Component=o,this.widgets=[],this.initialized=!1,this.elementClassname=s,this.initTemplatesState=this.initAdditionalTemplates()}init(){return g(this,null,function*(){yield this.initTemplatesState;const t=this.getElements();if(t.length!==0){for(const o of t)if(this.getShouldInitializeElement(o)){if(Xt.includes(this.name)&&this.widgets.length>0)break;this.setElementStatus(o,Ct.loading);try{const s=new this.Component;if(yield s.init(o,this.preloadedConfigs.find(n=>n.projectId===o.dataset.projectId)),!s.getIsInitialized()){this.setElementStatus(o,Ct.failed);continue}if(this.widgets.push(s),this.initializeEvents({element:o,widget:s}),this.setElementStatus(o,Ct.loaded),Xt.includes(this.name))break}catch(s){this.setElementStatus(o,Ct.failed),console.log(`error starting tolstoy ${this.name}`,o.id,s)}}this.widgets.length>0&&(this.initialized=!0)}})}deleteElementStatus(t){delete t.removeAttribute(Qt)}getElementStatus(t){return t.getAttribute(Qt)}getIsTolstoyPreview(){return window.tolstoyPreview}getIsElementHidden(t){var o;return((o=window.getComputedStyle(t))==null?void 0:o.display)==="none"||!t.offsetParent}setElementStatus(t,o){return t.setAttribute(Qt,o)}getShouldInitializeElement(t){return t.classList.contains(co)&&!this.getElementStatus(t)?!0:!this.getElementStatus(t)&&!this.getIsElementHidden(t)||!this.getElementStatus(t)&&Tt()||this.getIsTolstoyPreview()}setComponent(t){this.Component=t}loadWidgetAdditionalConfigs(){return g(this,null,function*(){if(this.preloadedConfigs)return this.preloadedConfigs;try{const t=R(),o=ya(),s=et("collection-gallery-projects");if(!s)return[];const n=JSON.parse(s);if(o&&t&&(n!=null&&n.length))return ln(t,o)}catch(t){console.log(t)}return[]})}initAdditionalTemplates(){return g(this,null,function*(){if(this.name!==ft){this.preloadedConfigs=[];return}try{const t=yield this.loadWidgetAdditionalConfigs();this.preloadedConfigs=t,yield ga(this.preloadedConfigs)}catch(t){console.error("error initializing additional templates",t)}})}getElements(){return Xt.includes(this.name)?[...document.querySelectorAll(`.${this.elementClassname}`)].filter(Boolean):[...document.querySelectorAll(`.${this.elementClassname}`)]}shouldLoad(){return this.initTemplatesState.isResolved?this.getElements().length>0:!0}initializeEvents({element:t,widget:o}){var s;(s=o.handlePageView)==null||s.call(o),this.registerEmbedViewListener({element:t,callback:o.handleView,outOfViewCallback:o.handleOutOfView})}registerEmbedViewListener({element:t,callback:o,outOfViewCallback:s}){Gr({element:t})&&(o(),!s)||fa({element:t,callback:o,outOfViewCallback:s})}}let oo=!1;const Jo=()=>g(void 0,null,function*(){if(oo)return;(yield P(()=>import("./c616a8cb4e/widget.events.ea597858.js"),[])).initializeWidgetEvents(),oo=!0});class wa{constructor(){y(this,"loadEmbedWidgets",()=>g(this,null,function*(){const t=Object.entries(this.embedWidgetsMap).map(r=>g(this,[r],function*([o,{embedWidget:s,loaded:n,loading:i}]){if(s.shouldLoad()){if(i){setTimeout(()=>this.loadEmbedWidgets(),2e3);return}n||(yield this.loadEmbedWidget({embedWidgetName:o,embedWidget:s})),yield s.init()}}));yield Promise.all(t)}));y(this,"handleUrlChange",()=>{for(const t of Object.keys(this.embedWidgetsMap))this.embedWidgetsMap[t].loaded=!1;this.loadEmbedWidgets()});this.domUpdatesListenerInitialized=!1,this.widgets=[],this.embedWidgetsMap={}}init(){return g(this,null,function*(){const t=[],o=[re,ae,ce,le,ft];for(const s of o){const n=ho[s],i=new ma({name:s,elementClassname:n});this.embedWidgetsMap[s]={embedWidget:i,loaded:!1},t.push(n)}this.registerDomUpdatesListenerIfNeeded(t),this.subscribeToUrlChange(),yield this.loadEmbedWidgets()})}loadEmbedWidget(s){return g(this,arguments,function*({embedWidgetName:t,embedWidget:o}){this.embedWidgetsMap[t].loading=!0;let n;switch(t){case re:{n=yield P(()=>import("./c616a8cb4e/carousel-loader.85631ffe.js"),[]);break}case ae:{n=yield P(()=>import("./c616a8cb4e/story.34959867.js"),["c616a8cb4e/modal.eb93a2a4.css","c616a8cb4e/story.28102514.css"]);break}case ce:{n=yield P(()=>import("./c616a8cb4e/embed.fe6a4131.js"),["c616a8cb4e/modal.eb93a2a4.css","c616a8cb4e/embed.550ffe5d.css"]);break}case le:{n=yield P(()=>import("./c616a8cb4e/tile.7dc91c2e.js"),["c616a8cb4e/tile.4607c378.css"]);break}case ft:{n=yield P(()=>import("./c616a8cb4e/collection-tile-controller.960924e1.js"),["c616a8cb4e/collection-tile-controller.af177681.css"]);break}case po:{n=yield P(()=>import("./c616a8cb4e/collection-page-tile-controller.c1df9004.js"),["c616a8cb4e/collection-page-tile-controller.5d04a287.css"]);break}}o.setComponent(n.default),yield Jo(),this.embedWidgetsMap[t].loaded=!0,this.embedWidgetsMap[t].loading=!1})}registerDomUpdatesListenerIfNeeded(t){if(this.domUpdatesListenerInitialized)return;Fo({classNames:t,callback:()=>this.loadEmbedWidgets()}),this.domUpdatesListenerInitialized=!0}subscribeToUrlChange(){h.subscribe({eventName:l.urlChange,callback:this.handleUrlChange})}}const G=lo,Ea=new Set(["5bzilmwoe1fon","z7uu0kcyzumt0"]),ts=e=>Ea.has(e)?uo:G;class Sa{constructor(){this.initialized=!1,this.widgets=[],this.start=this.start.bind(this),this.startPart=this.startPart.bind(this),this.hide=this.hide.bind(this),this.show=this.show.bind(this),this.on=this.on.bind(this),this.recreate=this.recreate.bind(this),window.tolstoyWidget=S(f({},window.tolstoyWidget),{start:this.start,startPart:this.startPart,show:this.show,hide:this.hide,on:this.on,recreate:this.recreate})}init(n){return g(this,arguments,function*({bubbleSettings:t,widgetId:o,Component:s}){var a,d;this.bubbleSettings=t;const i=new s(t);if(yield i.init(),this.widgets.push(i),this.updateViewerIdentifyAttributes(),(a=window.tolstoySettings)!=null&&a.noReload||this.registerEvents(),(((d=window.tolstoySettings)==null?void 0:d.alwaysShow)||xo(o)!=="true")&&!t.exitIntentPublishId){const c=ts(o);this.show(c),this.recreate(o,c)}else this.hide()})}updateViewerIdentifyAttributes(){const t=Number($o()||0)+1;Un(t.toString()),Bo()||Dn(new Date().toISOString())}handleMouseDown(){this.userInteracted=!0,document.removeEventListener("mousedown",this.handleMouseDown)}registerEvents(){document.addEventListener("mousedown",()=>{this.handleMouseDown()}),document.body.addEventListener("mouseleave",()=>g(this,null,function*(){var s;const t=(s=this.bubbleSettings)==null?void 0:s.exitIntentPublishId;if(t&&this.userInteracted){const n=this.widgets.find(i=>{var r;return(r=i==null?void 0:i.bubbleSettings)==null?void 0:r.exitIntentPublishId});n&&(yield this.recreate(t,n.name,{startPlayerImmediately:!0}))}}))}start(t=G){const o=Z(this.widgets,t);o&&o.start()}startPart(t,o=G){const s=Z(this.widgets,o);s&&s.startPart(t)}hide(t=G){const o=Z(this.widgets,t);o&&o.hide()}show(t=G){const o=Z(this.widgets,t);o&&o.show()}on(t,o,s=G){const n=Z(this.widgets,s);n&&n.eventChange(t,o)}recreate(t,o=G,s={}){const n=Z(this.widgets,o);n&&n.recreate(t,s)}}const Z=(e,t)=>e.find(o=>o.name===t);class es{addHours(t,o=new Date){return o.setTime(o.getTime()+t*60*60*1e3),o}getTolstoyViewers(){const t=Gt();for(const[s,n]of Object.entries(t)){const i=n.restrictionLimits;!i||!(i!=null&&i.time&&new Date(i==null?void 0:i.time)<=new Date)||delete t[s].restrictionLimits}const o=JSON.stringify(t);return jt(t),o}updateRestrictions(t,o){var r;const s=Gt(),n=(r=s[o])==null?void 0:r.restrictionLimits;if(!n||(n==null?void 0:n.type)!==t)return;const i=n[t];n[t]=i?i+1:1,n.limit&&n.clickLimit===n[t]&&(n.time=this.addHours(n==null?void 0:n.limit)),s[o].restrictionLimits=n,jt(s)}updateRules(t){const o=(t==null?void 0:t.publishId)||void 0,s=t==null?void 0:t.limit,n=Gt();let i=n[o];const r=i==null?void 0:i.restrictionLimits;i?i.impressionCount+=1:i={impressionCount:1,playCount:0};let a=n.undefined;if(a?a.impressionCount+=1:a={impressionCount:1,playCount:0},s){let d={limit:Number(s.timeLimit),type:s.type,clickLimit:Number(s.clickLimit)};r&&(d=f(f({},r),d)),i.restrictionLimits=d}else r&&(i.restrictionLimits=null);n[o]=i,n.undefined=a,jt(n)}}class Bt{static isValidUrl(t){return t?t.startsWith("tel:")||t.startsWith("mailto:")?!0:t.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/g)!==null:!1}static isAndroid(){return navigator.userAgent.toLowerCase().indexOf("android")>-1}static isInIframe(){try{return window.self!==window.top}catch(t){return!0}}static isIos(){return/iPad|iPhone|iPod/.test(navigator.platform)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1}static getMobileOperatingSystem(){const t=navigator.userAgent||navigator.vendor||window.opera;return/windows phone/i.test(t)?"Windows Phone":/android/i.test(t)?"Android":/iPad|iPhone|iPod/.test(t)&&!window.MSStream?"iOS":navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2?"ipad":null}static isMobile(){return Bt.getMobileOperatingSystem()!=null}static isSafari(){return window.safari!==void 0}static enforceProtocol(t,o="https"){return t.startsWith("http")||t.startsWith("//")||t.startsWith("tel:")||t.startsWith("mailto:")?t:`${o}://${t}`}static removeProtocol(t){return t.replace(/(^\w+:|^)\/\//,"")}static stripUrl(t){return Bt.removeProtocol(t).replace(/^www./,"").replace(/\/$/,"")}static stringifyUrlParams(t){const o=new URLSearchParams;return Object.entries(t).forEach(([s,n])=>{o.set(s,n)}),o.toString()}}const Ta="player-version",Ia=(e,t,o)=>{if(o)return`${Fs}`;const s=Ko(e);if(s){const i=V("td"),r=os(e);return i&&r?s.replace("2.0.0","2.0.0-ls"):r?s.replace("2.0.0","2.0.0-l"):i?s.replace("2.0.0","2.0.0-s"):s}let n=`${Vs}`;return t&&(n+="/feed"),e.publishId&&(n+=`/${e.publishId}`),n},so=()=>{var e;return!!(window.Shopify&&((e=window.Shopify)!=null&&e.routes))},os=e=>e.playerLazy||V("pl"),ba=e=>{var t,o;return(o=(t=e==null?void 0:e.featureSettings)==null?void 0:t[Ta])==null?void 0:o.version},_a=e=>{var t;return(t=e==null?void 0:e.carouselEmbed)!=null&&t.carouselPlayInTileFirst?$s:""},Ca=()=>{var e,t,o,s;return((e=window._st)==null?void 0:e.cid)||((s=(o=(t=window.ShopifyAnalytics)==null?void 0:t.meta)==null?void 0:o.page)==null?void 0:s.customerId)||""},Aa=()=>new URLSearchParams(window.location.search).get("authToken"),Oa=()=>{var e;return((e=window.tolstoyUserInfo)==null?void 0:e.email)||window.tolstoyUser},va=()=>V(we.tolstoyAutoOpen)||window.tolstoyAutoOpen,cu=()=>V(we.tolstoyAutoOpenOnYou)||window.tolstoyAutoOpenOnYou,lu=()=>V(we.tolstoyStartVideo)||window.tolstoyStartVideo,Ra=()=>{const e=window.tolstoyMoneyFormat;return e?encodeURIComponent(e):""},Pa=({data:e,onYouMode:t})=>{var u,p;const o=((u=window.Shopify)==null?void 0:u.shop)||Et(),{productId:s}=e,n=`${window.location.origin}${window.location.pathname}`,i=window.location.href,r=localStorage.getItem("tolstoy-anonymousId"),a=Array.from(document.querySelectorAll("div")||{}).find(w=>w.textContent.trim()==="Size & Fit"),d=Array.from(((p=a==null?void 0:a.nextElementSibling)==null?void 0:p.childNodes)||{}).filter(w=>w.nodeType===Node.TEXT_NODE).map(w=>w.textContent.trim()).join(" "),c=new URLSearchParams;return c.append("appUrl",o),c.append("productId",s),c.append("url",n),c.append("urlWithQueryParams",i),c.append("isTolstoyStories","true"),r&&c.append("tolstoyAnonymousId",r),d&&c.append("productFitDetails",d),t&&c.append("mode",t),c.toString().split("&")},La=({data:e,isFeed:t,isOnYou:o,email:s,isDynamic:n,modalId:i,tolstoyStartVideo:r,onYouMode:a})=>{var B,ot,Ft,Pe,Le,Ne,Me,Ue,De;if(o)return Pa({data:e,onYouMode:a});const c=[`url=${`${window.location.origin}${window.location.pathname}`.slice(0,1999)}`,`modalId=${i}`];e.publishId&&c.push(`publishId=${e.publishId}`);const u=Aa();u&&c.push(`authToken=${u}`);const p=s||Oa();p&&c.push(`email=${encodeURIComponent(p)}`),e.productId&&c.push(`productId=${e.productId}`),e.currentProductDbId&&c.push(`currentPageDbProductId=${e.currentProductDbId}`);const w=((B=window.Shopify)==null?void 0:B.shop)||"",I=!!(so()&&w);if(c.push("host",`safari=${!!(window!=null&&window.safari)}`,`dontDownload=${!!e.dontDownload}`,`playerType=${e.playerType}`,`isShopifyStore=${I}`,`shopifyStoreUrl=${w}`,`ai=${tt()}`),so()){const It=(Ft=(ot=window.Shopify)==null?void 0:ot.routes)==null?void 0:Ft.root;It&&c.push(`shopifyRootRoute=${It}`)}if((Pe=window.tolstoyUserInfo)!=null&&Pe.name&&c.push(`name=${encodeURIComponent(window.tolstoyUserInfo.name)}`),(Le=window.tolstoyUserInfo)!=null&&Le.phone&&c.push(`phone=${encodeURIComponent(window.tolstoyUserInfo.phone)}`),window.tolstoyMoneyFormat){const It=Ra();c.push(`tolstoyMoneyFormat=${It}`)}r&&c.push(`tolstoyStartVideo=${r}`),e.testGroup&&c.push(`group=${e.testGroup}`),e.sneakpeek&&c.push("sneakpeek"),e.sneakpeek_hidden&&c.push("sneakpeek_hidden"),e.token&&c.push(`token=${e.token}`),e.gclid&&c.push(`gclid=${e.gclid}`),e.widgetDelay&&c.push("delay"),e.isShoppable===!1&&c.push(`isShoppable=${e.isShoppable}`),e.si&&c.push(`si=${e.si}`);const v=V("td");v&&c.push(`td=${v}`);const E=os(e);E&&c.push(`pl=${E}`);const A=ba(e);A&&c.push(`pv=${A}`);const _=_a(e);_&&c.push(`playerVariant=${_}`),n&&c.push("isDynamic=true");const U=Ca();U&&c.push(`customerId=${U}`);const D=en();D.size>0&&c.push(D.toString()),Tt()&&c.push("isTapcart=true");const $=Ko(e);return $&&e.publishId&&c.push(`publishId=${e.publishId}`),$&&t&&c.push("isFeed=true"),(Ne=window.tolstoySettings)!=null&&Ne.shouldUseCache&&c.push(`shouldUseCache=${(Me=window.tolstoySettings)==null?void 0:Me.shouldUseCache}`),(Ue=window.tolstoySettings)!=null&&Ue.cacheVersion&&c.push(`cacheVersion=${(De=window.tolstoySettings)==null?void 0:De.cacheVersion}`),N()||c.push("userConsent=false"),c},du=({data:e,isFeed:t,isOnYou:o,email:s,isDynamic:n,modalId:i,tolstoyStartVideo:r,onYouMode:a})=>{const d=Ia(e,t,o),c=La({data:e,isFeed:t,isOnYou:o,email:s,isDynamic:n,modalId:i,tolstoyStartVideo:r,onYouMode:a});return`${d}?${c.join("&")}`};class ct{constructor(){var t;if(ct.instance)return ct.instance;ct.instance=this,this.appKey=R(),this.shop=((t=window.Shopify)==null?void 0:t.shop)||Et(),this.accountSettings=null,this.rules=new es,this.shouldUseCache=null,this.cacheVersion=null,this.hasLiveBubble=null}init(){return g(this,null,function*(){var t,o,s,n;if(!(!this.appKey&&!this.shop)){if(this.accountSettings)return this.accountSettings;try{this.accountSettings=yield nn(),this.rules.updateRules(this.accountSettings),(((t=this.accountSettings)==null?void 0:t.shouldUseCache)||To())&&(window.tolstoySettings=window.tolstoySettings||{},window.tolstoySettings.shouldUseCache=!0);const r=((o=this.accountSettings)==null?void 0:o.cacheVersion)||K();return r&&(window.tolstoySettings=window.tolstoySettings||{},window.tolstoySettings.cacheVersion=r),window.tolstoySettings.hasLiveShopAssistant=(s=this.accountSettings)==null?void 0:s.hasLiveShopAssistant,this.hasLiveBubble=((n=this.accountSettings)==null?void 0:n.hasLiveBubble)||!!window.tolstoyWidgetId||va(),this.accountSettings}catch(i){return Eo("Error loading account settings"),null}}})}}const ss=new ct;class Na{constructor(){y(this,"getBubbleSettings",()=>g(this,null,function*(){var a;const t=window.location.href,o=((a=window.Shopify)==null?void 0:a.shop)||Et();if(!this.appKey&&!o)return;const s=Nn(),n=this.rules.getTolstoyViewers(),i=o||window.location.host,r={timestamp:Date.now(),url:t,sessionCount:Number($o()||0),lastSeenAt:new Date().toISOString(),firstSeenAt:Bo(),tolstoySeenCounter:n,isMobile:Bt.isMobile(),domain:i,appUrl:o,appKey:this.appKey};s&&(r.identifyInfoId=s);try{const d=yield dn(r);return d?(this.rules.updateRules(d),d):null}catch(d){return null}}));y(this,"init",()=>g(this,null,function*(){var r,a,d,c;if(!((r=this.account)!=null&&r.hasLiveBubble))return;const t=yield this.getBubbleSettings();this.subscribeToUrlChange();const o=window.tolstoyWidgetId||(t==null?void 0:t.publishId)||(t==null?void 0:t.exitIntentPublishId);if(!o){(d=(a=this.widget)==null?void 0:a.hide)==null||d.call(a);return}if(!((c=window.tolstoySettings)==null?void 0:c.alwaysShow)&&xo(o)==="true")return;const n=ts(o);let i;n===uo?i=yield P(()=>import("./c616a8cb4e/centered-modal.f4ad8b43.js"),["c616a8cb4e/modal.eb93a2a4.css"]):n===lo&&(i=yield P(()=>import("./c616a8cb4e/bubble.599ad443.js"),["c616a8cb4e/modal.eb93a2a4.css","c616a8cb4e/bubble.4d99fbce.css"])),yield Jo(),this.widget?(this.widget.recreate(o,n),this.widget.show()):(this.widget=new Sa,yield this.widget.init({bubbleSettings:t,widgetId:o,Component:i.default}))}));y(this,"handleUrlChange",()=>{this.unsubscribeFromUrlChange(),this.init()});this.account=ss,this.rules=new es,this.appKey=R()}subscribeToUrlChange(){h.subscribe({eventName:l.urlChange,callback:this.handleUrlChange})}unsubscribeFromUrlChange(){h.unsubscribe({eventName:l.urlChange,callback:this.handleUrlChange})}}const Ma={tvContainer:"tolstoy-video-page"},Ua="tolstoy-tv-container",uu="tolstoy-tv",pu={};class Da{constructor(){this.domUpdatesListenerInitialized=!1,this.loaded=!1}init(){return g(this,null,function*(){yield this.loadVideo(),!this.loaded&&this.registerDomUpdatesListenerIfNeeded()})}loadVideo(){return g(this,null,function*(){const t=document.querySelector(`#${Ua}`);if(!t)return;const o=(yield P(()=>import("./c616a8cb4e/tv.05a82209.js"),["c616a8cb4e/tv.176639ca.css"])).default;new o({tolstoyContainer:t}).init(),this.loaded=!0})}registerDomUpdatesListenerIfNeeded(){if(this.domUpdatesListenerInitialized)return;const t=[Ma.tvContainer];Fo({classNames:t,callback:()=>this.loadVideo()}),this.domUpdatesListenerInitialized=!0}}const ka=[l.urlChange],$a=e=>{switch(e.data.eventName){case l.urlChange:return Wo();default:return null}},Ba=["(+https://whatis.contentkingapp.com)","Shopify-Observe-Synthetic-Checks","+http://www.google.com/bot.html","https://naver.me/spd","HeadlessChrome","(+http://www.facebook.com/externalhit_uatext.php)","Bytespider","bot"],xa=()=>Ba.some(e=>window.navigator.userAgent.includes(e)),j={addToCart:"tolstoy_add_to_cart",spotlightCarouselQuickShopClick:"tolstoy_spotlight_carousel_quick_shop_click",productCardClick:"tolstoy_product_card_click"},C={addToCartSuccess:"tolstoy_add_to_cart_success",addToCartError:"tolstoy_add_to_cart_error",rejectCookiePolicy:"tolstoy_reject_cookie_policy",tolstoyZIndexChange:"tolstoy_z_index_change",urlLocaleUpdate:"tolstoy_url_locale_update",productUpdate:"tolstoy_product_update"},ns=Object.values(j),Ha=new Set([C.addToCartSuccess,C.addToCartError,C.rejectCookiePolicy,C.tolstoyZIndexChange,C.urlLocaleUpdate,C.productUpdate]),Wa=({eventName:e,callback:t})=>{if(!ns.includes(e)){console.error(`Event ${e} is not a valid event`);return}if(!t){console.error("Callback must be provided");return}if(typeof t!="function"){console.error("Callback must be a function");return}return!0};class lt extends Yo{constructor(){if(lt.instance)return lt.instance;super({shouldIncludeLogs:!0});y(this,"eventHandler",({data:o={}})=>{const{eventName:s}=o;if(this.eventCallbacks[s])for(const n of this.eventCallbacks[s])try{n(o)}catch(i){console.error(i)}});y(this,"subscribe",(o,s,n={})=>{if(Wa({eventName:o,callback:s}))try{super.subscribe({eventName:o,callback:s}),h.postMessage({eventName:l.externalEventSubscribed,subscribedEventName:o,payload:n});const i=new CustomEvent("TOLSTOY_WIDGET_V2_SUBSCRIBE",{detail:{eventName:o,payload:n,callback:s}});window.dispatchEvent(i),console.log("Subscribed to event",o)}catch(i){console.error(i)}});y(this,"unsubscribe",(o,s)=>super.unsubscribe({eventName:o,callback:s}));y(this,"initInternalMessagingSubscriptions",()=>{h.subscribeMultipleEvents({eventNames:ns,callback:this.eventHandler})});lt.instance=this}init(){this.initInternalMessagingSubscriptions(),this.initListener(this.eventHandler)}}const Lt=new lt;Object.freeze(Lt);const Va=e=>{const{eventName:t}=e;if(!t){console.error("eventName is required");return}if(!Ha.has(t)){console.error(`${t} is not a valid eventName`);return}return!0};class Fa{constructor(){y(this,"postMessage",(t={})=>{Va(t)&&h.postMessage(t)})}closePlayer(){h.postMessage({eventName:l.closePlayer})}changeEmail(t){window.tolstoyUser=t,h.postMessage({eventName:l.userEmailUpdate,email:t})}identify(){return g(this,arguments,function*(t={}){var n;const{email:o,userId:s}=t;if(!o&&!s){console.error("No email or userId");return}try{o&&this.changeEmail(o),s&&(t.userId=s.toString()),t.appKey=R();const i=yield rn(t);Ln(i==null?void 0:i.id)}catch(i){console.error("Error occurred while updating identify info:",i),(n=window.tolstoyCaptureError)==null||n.call(window,i,"Error occurred while updating identify info:"),Mn()}})}}const ye=new Fa;Object.freeze(ye);const Ya=[l.modalOpen];class Ga{constructor(){y(this,"internalMessagingHandler",t=>{switch(t.data.eventName){case l.modalOpen:this.sendIsAfterpayAppInstalledMessage();return;default:return null}})}sendIsAfterpayAppInstalledMessage(){h.postMessage({eventName:l.isAfterpayAppInstalled,value:!!(window!=null&&window.Afterpay)})}initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:Ya,callback:this.internalMessagingHandler})}init(){this.initInternalMessagingSubscriptions()}}const is=new Ga;Object.freeze(is);const ja=()=>{wn(),mn(Wt.rejected),h.postMessage({eventName:l.rejectCookiePolicy})},Ka=[C.rejectCookiePolicy];class dt{constructor(){y(this,"externalMessagingHandler",t=>{switch(t.data.eventName){case C.rejectCookiePolicy:return ja();default:return null}});y(this,"initExternalMessagingSubscriptions",()=>{h.subscribeMultipleEvents({eventNames:Ka,callback:this.externalMessagingHandler})});if(dt.instance)return dt.instance;dt.instance=this}init(){this.initExternalMessagingSubscriptions()}}const rs=new dt;Object.freeze(rs);const qa={itemSoldOut:"itemSoldOut"},as={tolstoyAnonymousId:"__tolstoyAnonymousId"},za=({description:e})=>{switch(e){case qa.itemSoldOut:return l.addToCartSoldOut;default:return l.addToCartError}},Za=({data:e})=>{const{description:t}=e,o=za({description:t});h.postMessage(S(f({},e),{eventName:o}))},Qa=({data:e})=>{const{variantId:t,productId:o,transmissionId:s,quantity:n,productHandle:i,templateSuffix:r}=e;h.postMessage({variantId:t,productId:o,transmissionId:s,quantity:n,productHandle:i,eventName:j.addToCart,templateSuffix:r})},Xa=({data:e})=>{const{product:t,transmissionId:o}=e;h.postMessage({product:t,transmissionId:o,eventName:j.spotlightCarouselQuickShopClick})},Ja=({data:e})=>{const{subscribedEventName:t,payload:o={}}=e,{disableDefault:s}=o;switch(t){case j.addToCart:case j.spotlightCarouselQuickShopClick:s&&h.postMessage({eventName:l.addToCartDisableDefault});break;default:return null}},tc=({data:e})=>{h.postMessage(S(f({},e),{eventName:l.addToCartSuccess}))},ec=[l.addToCart,l.spotlightCarouselQuickShopClick,l.externalEventSubscribed],oc=[C.addToCartSuccess,C.addToCartError];class ut{constructor(){y(this,"internalMessagingHandler",t=>{switch(t.data.eventName){case l.addToCart:return Qa(t);case l.spotlightCarouselQuickShopClick:return Xa(t);case l.externalEventSubscribed:return Ja(t);default:return null}});y(this,"externalMessagingHandler",t=>{switch(t.data.eventName){case C.addToCartSuccess:return tc(t);case C.addToCartError:return Za(t);default:return null}});y(this,"initInternalMessagingSubscriptions",()=>{h.subscribeMultipleEvents({eventNames:ec,callback:this.internalMessagingHandler})});y(this,"initExternalMessagingSubscriptions",()=>{h.subscribeMultipleEvents({eventNames:oc,callback:this.externalMessagingHandler})});if(ut.instance)return ut.instance;ut.instance=this}init(){this.initInternalMessagingSubscriptions(),this.initExternalMessagingSubscriptions()}}const cs=new ut;Object.freeze(cs);const sc=[l.openKendoModal];class nc{constructor(){y(this,"internalMessagingHandler",t=>{var o,s;switch(t.data.eventName){case l.openKendoModal:h.postMessage({eventName:l.changeZIndex,zIndex:1e3}),(s=(o=window.KENDO)==null?void 0:o.openQuickModalByHandle)==null||s.call(o,t.data.productHandle);const n=t.data.quantity;if(n<=1)return;for(let i=1;i{var a;const r=document.querySelector(".quantity-selector__action--increment");(a=r==null?void 0:r.click)==null||a.call(r)},1e3+i*150);return;default:return null}})}initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:sc,callback:this.internalMessagingHandler})}init(){this.initInternalMessagingSubscriptions()}}const ls=new nc;Object.freeze(ls);const ds={USD:"$",CAD:"CA$",EUR:"€",AED:"د.إ.",AFN:"؋",ALL:"Lek",AMD:"դր.",ARS:"$",AUD:"AU$",AZN:"ман.",BAM:"KM",BDT:"৳",BGN:"лв.",BHD:"د.ب.",BIF:"FBu",BND:"$",BOB:"Bs",BRL:"R$",BWP:"P",BYN:"руб.",BZD:"$",CDF:"FrCD",CHF:"CHF",CLP:"$",CNY:"CN¥",COP:"$",CRC:"₡",CVE:"CV$",CZK:"Kč",DJF:"Fdj",DKK:"kr",DOP:"RD$",DZD:"د.ج.",EEK:"kr",EGP:"ج.م.",ERN:"Nfk",ETB:"Br",GBP:"£",GEL:"GEL",GHS:"GH₵",GNF:"FG",GTQ:"Q",HKD:"$",HNL:"L",HRK:"kn",HUF:"Ft",IDR:"Rp",ILS:"₪",INR:"₹",IQD:"د.ع.",IRR:"﷼",ISK:"kr",JMD:"$",JOD:"د.أ.",JPY:"¥",KES:"Ksh",KHR:"៛",KMF:"FC",KRW:"₩",KWD:"د.ك.",KZT:"тңг.",LBP:"ل.ل.",LKR:"SL Re",LTL:"Lt",LVL:"Ls",LYD:"د.ل.",MAD:"د.م.",MDL:"MDL",MGA:"MGA",MKD:"MKD",MMK:"K",MOP:"MOP$",MUR:"MURs",MXN:"MX$",MYR:"RM",MZN:"MTn",NAD:"N$",NGN:"₦",NIO:"C$",NOK:"kr",NPR:"नेरू",NZD:"$",OMR:"ر.ع.",PAB:"B/.",PEN:"S/.",PHP:"₱",PKR:"₨",PLN:"zł",PYG:"₲",QAR:"ر.ق.",RON:"RON",RSD:"дин.",RUB:"₽.",RWF:"FR",SAR:"ر.س.",SDG:"SDG",SEK:"kr",SGD:"$",SOS:"Ssh",SYP:"ل.س.",THB:"฿",TND:"د.ت.",TOP:"T$",TRY:"TL",TTD:"$",TWD:"NT$",TZS:"TSh",UAH:"₴",UGX:"USh",UYU:"$",UZS:"UZS",VEF:"Bs.F.",VND:"₫",XAF:"FCFA",XOF:"CFA",YER:"ر.ي.",ZAR:"R",ZMK:"ZK",ZWL:"ZWL$"},ic=e=>({id:e.id,price:e.price,compareAtPrice:e.price,currencyCode:e.currency,currencySymbol:ds[e.currency],variants:[{price:e.price,compareAtPrice:e.price}]}),rc=(e="")=>e.replace("_","-"),ac=[l.openCommerceSettingsUpdate,l.requestProductsUpdate],Jt={},At={};class cc{constructor(){y(this,"fetchProduct",t=>g(this,null,function*(){const o=`${this.apiBaseUrl}/products/${t}`,s=new URL(o);s.searchParams.append("client_id",this.clientId),s.searchParams.append("locale",this.locale),s.searchParams.append("currency",this.currencyCode),s.searchParams.append("expand","prices");try{const i=yield(yield fetch(s)).json();return ic(i)}catch(n){console.error("Error fetching product price",n)}}));y(this,"getProduct",t=>g(this,null,function*(){if(Jt[t])return Jt[t];if(At[t])return At[t];const o=this.fetchProduct(t);At[t]=o;const s=yield o;return Jt[t]=s,delete At[t],s}));y(this,"onRequestProductsUpdateMessage",o=>g(this,[o],function*({productIds:t}){const n=[...new Set(t)].map(r=>this.getProduct(r)),i=(yield Promise.all(n)).filter(Boolean);for(const r of i)h.postMessage({eventName:l.productUpdateResponse,product:r,isProductUpdateResponse:!0})}));y(this,"internalMessagingHandler",t=>{switch(t.data.eventName){case l.openCommerceSettingsUpdate:return this.onOpenCommerceSettingsUpdate(t.data);case l.requestProductsUpdate:return this.onRequestProductsUpdateMessage(t.data);default:return null}});var t,o,s,n;this.isOpenCommerceStore=!!window.CQuotient,this.siteId=(t=window.CQuotient)==null?void 0:t.siteId,this.locale=rc((o=window.CQuotient)==null?void 0:o.locale),this.apiBaseUrl="",this.clientId="",this.currencyCode=(n=(s=window.pageContext)==null?void 0:s.ecommerce)==null?void 0:n.currencyCode}postUrlLocaleUpdateIfNeeded(t){this.locale!==t&&h.postMessage({eventName:l.urlLocaleUpdate,urlLocale:this.locale})}postIsNonBaseCurrencyIfNeeded(t){this.currencyCode!==t&&h.postMessage({eventName:l.isNonBaseCurrency,currencyCode:this.currencyCode})}onOpenCommerceSettingsUpdate({openCommerceSettings:t}){const{apiVersion:o,clientId:s,baseLocale:n,baseCurrency:i}=t;this.apiBaseUrl=`https://${window.location.host}/s/${this.siteId}/dw/shop/${o}`,this.clientId=s,this.postUrlLocaleUpdateIfNeeded(n),this.postIsNonBaseCurrencyIfNeeded(i)}initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:ac,callback:this.internalMessagingHandler})}init(){this.isOpenCommerceStore&&this.initInternalMessagingSubscriptions()}}const lc=new cc,dc=[l.externalEventSubscribed,l.productCardClick],uc=({subscribedEventName:e,payload:t})=>{switch(e){case j.productCardClick:{const{disableProductModal:o=!0}=t;h.postMessage({eventName:l.productCardClickSubscribed,isDisableProductModal:o});break}default:return null}},pc=({data:e})=>{const{eventName:t}=e;switch(t){case l.externalEventSubscribed:{const{subscribedEventName:o,payload:s}=e;uc({subscribedEventName:o,payload:s});break}case l.productCardClick:{const{variantId:o,productId:s,externalProductIds:n,productHandle:i}=e;h.postMessage({eventName:j.productCardClick,variantId:o,productId:s,taggedProductIds:n,productHandle:i});break}default:return null}};class hc{initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:dc,callback:pc})}init(){this.initInternalMessagingSubscriptions()}}const us=new hc;Object.freeze(us);const gc=[l.getProductsMetafields];class yc{constructor(){y(this,"internalMessagingHandler",({data:t})=>{var o;switch(t.eventName){case l.getProductsMetafields:if(!((o=t==null?void 0:t.productIds)!=null&&o.length))return;h.postMessage({productsExtraData:this.getProductsMetafields(t.productIds),modalId:t.modalId,eventName:l.returnProductsMetafields});return;default:return null}})}getProductsMetafields(t=[]){var s,n;const o={};for(const i of t)o[i]=(n=(s=window==null?void 0:window.metafields)==null?void 0:s.products)==null?void 0:n[i];return o}initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:gc,callback:this.internalMessagingHandler})}init(){this.initInternalMessagingSubscriptions()}}const ps=new yc;Object.freeze(ps);const fc=[C.productUpdate],mc=["id","descriptionHtml","description_html","variants","price","compare_at_price","title"],wc=["id","price","compare_at_price","title"],Ec=e=>mc.includes(e),Sc=e=>Array.isArray(e)?e.flatMap((t,o)=>{const n=Object.keys(t).filter(i=>!wc.includes(i));return n.length===0?[]:`variants[${o}]: { ${n.join(", ")} }`}):["variants (must be an array)"],Tc=({product:e})=>{const o=Object.keys(e).filter(s=>!Ec(s));if(e.variants&&o.push(...Sc(e.variants)),o.length>0){console.error(`Fields ${o.join(", ")} are not supported for product update.`);return}h.postMessage({product:e,eventName:l.productUpdateResponse})},Ic=({data:e})=>{switch(e.eventName){case C.productUpdate:return Tc(e);default:return null}};class bc{initExternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:fc,callback:Ic})}init(){this.initExternalMessagingSubscriptions()}}const hs=new bc;Object.freeze(hs);const _c=[l.openRebuyCart],te={show:"rebuy:smartcart.show",hide:"rebuy:smartcart.hide",init:"rebuy:smartcart.init"};class Cc{constructor(){y(this,"sendIsRebuyAppInstalledMessage",()=>{var t,o;if(!((t=window==null?void 0:window.Rebuy)!=null&&t.SmartCart)){document.addEventListener(te.init,this.sendIsRebuyAppInstalledMessage,{once:!0});return}h.postMessage({eventName:l.isRebuyAppInstalled,value:!!((o=window==null?void 0:window.Rebuy)!=null&&o.SmartCart)}),this.initRebuyEventListeners()});y(this,"internalMessagingHandler",t=>{var o,s;switch(t.data.eventName){case l.openRebuyCart:return(s=(o=window==null?void 0:window.Rebuy)==null?void 0:o.SmartCart)==null?void 0:s.show();default:return null}})}initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:_c,callback:this.internalMessagingHandler})}initRebuyEventListeners(){document.addEventListener(te.show,()=>{h.postMessage({eventName:l.rebuyCartShown})}),document.addEventListener(te.hide,()=>{h.postMessage({eventName:l.rebuyCartHidden})})}init(){this.initInternalMessagingSubscriptions(),this.sendIsRebuyAppInstalledMessage()}}const gs=new Cc;Object.freeze(gs);const Ac=()=>{var e,t;return Number((t=(e=window.Shopify)==null?void 0:e.currency)==null?void 0:t.rate)===1},hu=e=>typeof e=="string"&&e.includes("cdn.shopify.com"),no={soldOut:"already sold out",sellingPlanRequired:"Variant can only be purchased with a selling plan."},Oc=[l.addToCartDisableDefault,l.setAnonymousIdToCart,l.loginWithMultipassUrlRequest,l.cartItemQuantityChange,l.cartDataRequest,l.productRecommendationsRequest,l.requestProductsUpdate,l.blockAnonymousIdToCart],io=[l.addToCart,l.spotlightCarouselQuickShopClick],ee=e=>({headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(e)});let ro=!1,oe=!1;const se={},Ot={};class pt{constructor(){y(this,"getProduct",t=>g(this,null,function*(){if(se[t])return se[t];if(Ot[t])return Ot[t];const o=this.fetchRawProduct(t);Ot[t]=o;const s=yield o;return se[t]=s,delete Ot[t],s}));y(this,"onRequestProductsUpdateMessage",o=>g(this,[o],function*({handles:t}){const n=[...new Set(t)].map(r=>this.getProduct(r)),i=(yield Promise.all(n)).filter(Boolean);for(const r of i)h.postMessage({eventName:l.productUpdateResponse,product:r,isProductUpdateResponse:!0})}));y(this,"shopifyAddToCart",r=>g(this,[r],function*({variantId:t,productHandle:o,sellingPlanId:s,quantity:n=Hs,transmissionId:i}){const a={};oe||(a._isAddedFromTolstoy=!0,Ve(t));const d={id:t,quantity:n,properties:a};s&&(d.selling_plan=s);const u=ee({items:[d]});try{const p=yield fetch(`${this.storeRootUrl}cart/add.js`,u);if(!p.ok){const w=yield p.json();return this.handleAddToCartError({error:w,variantId:t,productHandle:o,transmissionId:i})}this.triggerExternalCartUpdate(),Ve(t),h.postMessage({eventName:l.addToCartSuccess,variantId:t,transmissionId:i,shouldEndTransmission:!1}),this.getCart({transmissionId:i})}catch(p){console.log(p),this.handleAddToCartError({error:p,variantId:t,productHandle:o,transmissionId:i})}}));y(this,"shopifyUpdateItemQuantity",n=>g(this,[n],function*({variantId:t,quantity:o,transmissionId:s}){const i={updates:{[t]:o}},r=ee(i);try{const a=yield fetch(`${this.storeRootUrl}cart/update.js`,r);if(!a.ok){const d=yield a.json();return this.handleUpdateItemQuantityError({error:d,variantId:t,transmissionId:s})}this.triggerExternalCartUpdate(),h.postMessage({eventName:l.cartItemQuantityChangeSuccess,variantId:t,transmissionId:s,shouldEndTransmission:!1}),this.getCart({transmissionId:s})}catch(a){this.handleUpdateItemQuantityError({error:a,variantId:t,transmissionId:s})}}));y(this,"internalMessagingHandler",t=>{switch(t.data.eventName){case l.addToCart:return this.shopifyAddToCart(t.data);case l.spotlightCarouselQuickShopClick:return this.shopifyQuickShopClick(t.data);case l.addToCartDisableDefault:return this.disableAddToCart(t.data);case l.blockAnonymousIdToCart:return this.blockAnonymousIdToCart(t.data);case l.setAnonymousIdToCart:return this.setAnonymousIdToCart(t.data);case l.loginWithMultipassUrlRequest:return this.loginWithMultipassUrl(t.data);case l.cartItemQuantityChange:return this.shopifyUpdateItemQuantity(t.data);case l.cartDataRequest:return this.getCart(t.data);case l.productRecommendationsRequest:return this.getProductRecommendations(t.data);case l.requestProductsUpdate:return this.onRequestProductsUpdateMessage(t.data);default:return null}});y(this,"initInternalMessagingSubscriptions",()=>{if(h.subscribeMultipleEvents({eventNames:Oc,callback:this.internalMessagingHandler}),ro){xt("Add to cart disabled");return}h.subscribeMultipleEvents({eventNames:io,callback:this.internalMessagingHandler})});var t,o,s,n;if(pt.instance)return pt.instance;pt.instance=this,this.isShopifyStore=!!((t=window.Shopify)!=null&&t.shop&&((o=window.Shopify)!=null&&o.routes)),this.storeRootUrl=(n=(s=window.Shopify)==null?void 0:s.routes)==null?void 0:n.root}getIsProductSoldOutError(t){return t.includes(no.soldOut)}getIsSellingPlanError(t){return t.includes(no.sellingPlanRequired)}formatProduct(t){var n,i,r;if(!t)return null;const o=((i=(n=window.Shopify)==null?void 0:n.currency)==null?void 0:i.active)||((r=window.Shopify)==null?void 0:r.currency),s=window.tolstoyCurrencySymbol||ds[o];return S(f({},t),{id:String(t.id),price:t.price/100,compare_at_price:t.compare_at_price?t.compare_at_price/100:t.compare_at_price,currencyCode:o,currencySymbol:s,variants:t.variants.map(a=>S(f({},a),{price:a.price/100,compare_at_price:a.compare_at_price?a.compare_at_price/100:a.compare_at_price}))})}fetchRawProduct(t){return g(this,null,function*(){const o=this.storeRootUrl+`products/${t}.js`;try{const n=yield(yield fetch(o)).json();return this.formatProduct(n)}catch(s){}})}handleSellingPlanError(t,o){return g(this,null,function*(){const s=yield this.getProduct(o);if(!s)return;const{id:n}=s.selling_plan_groups[0].selling_plans[0];return this.shopifyAddToCart({variantId:t,productHandle:o,sellingPlanId:n})})}handleAddToCartError({error:t,variantId:o,productHandle:s,transmissionId:n}){const{description:i}=t;if(this.getIsProductSoldOutError(i)){h.postMessage({eventName:l.addToCartSoldOut,variantId:o,transmissionId:n});return}if(this.getIsSellingPlanError(i))return this.handleSellingPlanError(o,s);h.postMessage({eventName:l.addToCartError,error:i,variantId:o,transmissionId:n})}handleUpdateItemQuantityError({error:t,variantId:o,transmissionId:s}){const{description:n}=t;h.postMessage({eventName:l.cartItemQuantityChangeError,error:n,variantId:o,transmissionId:s})}getCart(o){return g(this,arguments,function*({transmissionId:t}){try{const n=yield(yield fetch(`${this.storeRootUrl}cart.js`,{method:"GET"})).json();h.postMessage({eventName:l.cartDataResponse,cart:n,transmissionId:t})}catch(s){}})}triggerExternalCartUpdate(){var t,o,s,n,i,r,a,d,c,u,p;(i=(n=(s=(o=(t=window.VueMiniCart)==null?void 0:t.$store)==null?void 0:o._actions)==null?void 0:s.initCart)==null?void 0:n[0])==null||i.call(n),(d=(a=(r=window.slate)==null?void 0:r.cart)==null?void 0:a.reloadCart)==null||d.call(a),(c=window.tolstoyCartRefresh)==null||c.call(window),(u=window.monster_refresh)==null||u.call(window),(p=window.updateMiniCart)==null||p.call(window)}disableAddToCart(){ro=!0,h.unsubscribeMultipleEvents({eventNames:io,callback:this.internalMessagingHandler})}postUrlLocaleUpdateIfNeeded(){var t,o,s,n;((o=(t=window.Shopify)==null?void 0:t.routes)==null?void 0:o.root)!=="/"&&h.postMessage({eventName:l.urlLocaleUpdate,urlLocale:(n=(s=window.Shopify)==null?void 0:s.routes)==null?void 0:n.root})}postIsNonBaseCurrencyIfNeeded(){Ac()||h.postMessage({eventName:l.isNonBaseCurrency})}shopifyQuickShopClick({product:t}){const{variants:o,handle:s,quantity:n=1}=t,i=o[0].id;return this.shopifyAddToCart({variantId:i,productHandle:s,quantity:n})}getProductRecommendations(s){return g(this,arguments,function*({productId:t,transmissionId:o}){const n=`${this.storeRootUrl}recommendations/products.json?product_id=${t}`;try{const i=yield fetch(n,{method:"GET"}),{products:r}=yield i.json();h.postMessage({eventName:l.productRecommendationsResponse,productId:t,products:r,transmissionId:o})}catch(i){}})}loginWithMultipassUrl(s){return g(this,arguments,function*({multipassUrl:t,transmissionId:o}){try{const n=yield fetch(t);h.postMessage({eventName:l.loginWithMultipassUrlResponse,statusCode:n.status,transmissionId:o})}catch(n){}})}setAnonymousIdToCart(o){return g(this,arguments,function*({anonymousId:t}){if(Vn()==="true"||oe||!N())return;const s={attributes:{[as.tolstoyAnonymousId]:t}},n=ee(s);try{yield fetch(`${this.storeRootUrl}cart/update.js`,n),Fn(!0)}catch(i){console.error(i)}})}blockAnonymousIdToCart(o){return g(this,arguments,function*({appKey:t}){const s=Pn(t);qs(s)||(yield this.setAnonymousIdToCart({anonymousId:null})),oe=!0})}forceClearAnonymousIdFromCart(){var o;if(((o=window.Shopify)==null?void 0:o.shop)!=="mlt-boutique.myshopify.com")return;const t=R();t&&this.blockAnonymousIdToCart({appKey:t})}init(){this.isShopifyStore&&(this.initInternalMessagingSubscriptions(),this.postUrlLocaleUpdateIfNeeded(),this.postIsNonBaseCurrencyIfNeeded(),this.forceClearAnonymousIdFromCart())}}const ys=new pt;Object.freeze(ys);const vc=[l.addToCart,l.playerReady,l.productCardClick],Rc={cartUpdated:"cart/updated"},Pc=({productId:e,variantId:t})=>{const o={productId:String(e)};return t&&(o.variantId=String(t)),window.Tapcart.actions.openProduct(o)},Lc=e=>{const o=setTimeout(()=>{h.postMessage(S(f({},e),{eventName:l.addToCartError}))},4e3);window.Tapcart.registerEventHandler(Rc.cartUpdated,()=>{clearTimeout(o),h.postMessage(S(f({},e),{eventName:l.addToCartSuccess}))})},Nc=e=>g(void 0,null,function*(){const{variantId:t,productId:o}=e;try{Lc(e),window.Tapcart.actions.addToCart({lineItems:[{variantId:String(t||o),quantity:1}]})}catch(s){return h.postMessage(S(f({},e),{error:s,eventName:l.addToCartError}))}}),Mc=()=>{var e,t,o,s,n,i;try{const r=Co();if(!r)return;const d=[...((o=(t=(e=window==null?void 0:window.Tapcart)==null?void 0:e.variables)==null?void 0:t.cart)==null?void 0:o.attributes)||[],{key:as.tolstoyAnonymousId,value:r}];(i=(n=(s=window==null?void 0:window.Tapcart)==null?void 0:s.actions)==null?void 0:n.updateCartAttributes)==null||i.call(n,{attributes:d})}catch(r){pe({text:r==null?void 0:r.message,parentUrl:window.location.href,appKey:R(),source:"tapcart",eventName:"widgetError",timestamp:new Date().toISOString()})}};class Uc{constructor(){y(this,"internalMessagingHandler",t=>{switch(t.data.eventName){case l.playerReady:return this.disableCartDefault();case l.productCardClick:return Pc(t.data);case l.addToCart:return Nc(t.data);default:return null}})}disableCartDefault(){h.postMessage({eventName:l.addToCartDisableDefault})}initInternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:vc,callback:this.internalMessagingHandler})}init(){Tt()&&(this.initInternalMessagingSubscriptions(),Mc())}}const fs=new Uc;Object.freeze(fs);const Dc=[C.urlLocaleUpdate],kc=({data:e})=>{switch(e.eventName){case C.urlLocaleUpdate:const{payload:t}=e;h.postMessage({eventName:l.urlLocaleUpdate,urlLocale:t.urlLocale});break;default:return null}};class ht{constructor(){if(ht.instance)return ht.instance;ht.instance=this}initExternalMessagingSubscriptions(){h.subscribeMultipleEvents({eventNames:Dc,callback:kc})}init(){this.initExternalMessagingSubscriptions();const t=window.history.pushState,o=window.history.replaceState;let s=window.location.href;const n=()=>{window.location.href!==s&&(s=window.location.href,h.postMessage({eventName:l.urlChange}))};window.history.pushState=function(){t.apply(window.history,arguments),n()},window.history.replaceState=function(){o.apply(window.history,arguments),n()}}}const ms=new ht;Object.freeze(ms);const $c=[C.addToCartSuccess,C.addToCartError];class gt{constructor(){y(this,"postMessageToWidgetV2",t=>{const{data:o}=t||{},{eventName:s,subscribedEventName:n}=o||{};if(!s&&!n)return;const i=new CustomEvent("TOLSTOY_WIDGET_V2_MESSAGE",{detail:S(f({},o),{eventName:n||s})});window.dispatchEvent(i)});y(this,"initExternalMessagingSubscriptions",()=>{h.subscribeMultipleEvents({eventNames:$c,callback:this.postMessageToWidgetV2})});if(gt.instance)return gt.instance;gt.instance=this}init(){this.initExternalMessagingSubscriptions()}}const ws=new gt;Object.freeze(ws);class Bc{constructor(){this.domUpdatesListenerInitialized=!1,this.loaded=!1}init(){return g(this,null,function*(){})}loadVideo(){return g(this,null,function*(){})}registerDomUpdatesListenerIfNeeded(){}}const xc=[l.addToCartError,l.addToCartSuccess,l.addToCartSoldOut,l.isRebuyAppInstalled,l.isAfterpayAppInstalled,l.openRebuyCart,l.returnProductsMetafields,l.rejectCookiePolicy,l.productCardClickSubscribed,l.isTapcart,l.urlLocaleUpdate,l.loginWithMultipassUrlResponse,l.cartDataResponse,l.cartItemQuantityChangeSuccess,l.cartItemQuantityChangeError,l.productRecommendationsResponse,l.productUpdateResponse,l.isNonBaseCurrency,l.eventListenersInitialized],vt={},ne={},Rt={},ie=[];class yt{constructor(){y(this,"eventHandler",({data:t={}})=>{const{modalId:o,eventName:s}=t;if(o)switch(s){case l.addToCart:case l.openRebuyCart:case l.openKendoModal:case l.getProductsMetafields:case l.productCardClick:case l.loginWithMultipassUrlRequest:case l.cartItemQuantityChange:case l.cartDataRequest:case l.productRecommendationsRequest:case l.requestProductsUpdate:case l.moveToUrl:case l.showFeedProductModal:case l.reportModalOpen:case l.reportModalClose:case ao:return this.postInternalMessage({modalId:o,data:t});case l.modalMessagingReady:return this.postInternalMessage({modalId:o,data:t}),this.handleModalMessagingReady({modalId:o});case l.toggleFeedCloseButton:return this.postInternalMessage({modalId:o,data:t});default:return null}});y(this,"internalEventHandler",({data:t})=>{this.postMessageToModal(t)});y(this,"initInternalMessagingSubscriptions",()=>{h.subscribeMultipleEvents({eventNames:xc,callback:this.internalEventHandler})});if(yt.instance)return yt.instance;yt.instance=this}registerIframe({modalId:t,modalIframe:o}){vt[t]=o}postInternalMessage({modalId:t,data:o}){delete o.modalId;const s=h.postMessage(o);Rt[s]=t}handleModalMessagingReady({modalId:t}){ne[t]=!0;const o=vt[t];for(const s of ie){const{transmissionId:n}=s,i=Rt[n];(!i||i===t)&&this.postMessageToIframe({iframe:o,message:s})}}postMessageToIframe({iframe:t,message:o}){var s;(s=t.contentWindow)==null||s.postMessage(o,"*")}postMessageToAllIframes({message:t}){ie.push(t);for(const[o,s]of Object.entries(vt))ne[o]&&this.postMessageToIframe({iframe:s,message:t})}postMessageToModal(t){const d=t,{transmissionId:o,shouldEndTransmission:s=!0}=d,n=Be(d,["transmissionId","shouldEndTransmission"]),i=Rt[o];if(!i)return this.postMessageToAllIframes({message:n});if(!ne[i]){ie.push(t);return}const a=vt[i];this.postMessageToIframe({iframe:a,message:n}),s&&delete Rt[o]}init(){this.initInternalMessagingSubscriptions(),window.addEventListener("message",this.eventHandler)}}const fe=new yt;Object.freeze(fe);const Hc=50,Wc="8b32dacc-8f1d-4cce-b641-9f60e88f9414",Vc=()=>{var t,o;const e=((t=document.currentScript)==null?void 0:t.src)||((o=import.meta)==null?void 0:o.url);if(e!=null&&e.includes("/we/widget.js")){Ge({src:`https://${de}/wes/widget.js`,container:document.head,attributes:{type:"module"}});return}Ge({src:`https://${de}/ws/widget.js`,container:document.head})},Fc=()=>!!document.body,Yc=()=>{try{return window.self!==window.top}catch(e){return!0}},Gc=()=>Yc()&&window.location.host==="theordinary.com",Es=()=>g(void 0,null,function*(){var e,t,o,s,n,i;try{if(window.tolstoyWidget||Gc())return;if(xa()){console.debug("Bot user");return}if(!Fc()){setTimeout(Es,Hc);return}if(Tt()&&(yield gi()),Ao())return;if(V("td")==="true"&&!((o=(t=(e=document.currentScript)==null?void 0:e.src)==null?void 0:t.includes)!=null&&o.call(t,"/ws/widget.js"))&&!((i=(n=(s=import.meta)==null?void 0:s.url)==null?void 0:n.includes)!=null&&i.call(n,"/wes/widget.js"))){Vc();return}zn(),Qc(),Xc(),Jc(),tl(),el(),ol(),Wo(),yield jc(),yield Promise.all([Kc(),qc(),Zc(),zc()]),oi()}catch(r){console.log("error",r)}}),jc=()=>g(void 0,null,function*(){return ss.init()}),Kc=e=>new Na(e).init(),qc=()=>new Da().init(),zc=()=>new wa().init(),Zc=()=>new Bc().init(),Qc=()=>(h.init(),h),Xc=()=>(fe.init(),fe),Jc=()=>{Lt.init();const{subscribe:e,unsubscribe:t}=Lt;return window.tolstoyWidget=S(f({},window.tolstoyWidget),{subscribe:e,unsubscribe:t}),Lt},tl=()=>{const{postMessage:e,closePlayer:t,identify:o,changeEmail:s}=ye;return window.tolstoyWidget=S(f({},window.tolstoyWidget),{postMessage:e,closePlayer:t,identify:o,changeEmail:s}),ye},el=()=>{ys.init(),ms.init(),cs.init(),gs.init(),ls.init(),fs.init(),is.init(),rs.init(),us.init(),lc.init(),hs.init(),ws.init(),R()===Wc&&ps.init()},ol=()=>{h.subscribeMultipleEvents({eventNames:ka,callback:$a})};Es();export{Q as $,Nd as A,V as B,re as C,Ml as D,Rl as E,Vi as F,Fd as G,eu as H,l as I,zd as J,qt as K,rl as L,Zo as M,Re as N,Go as O,Rs as P,Xe as Q,Ks as R,Ns as S,wd as T,h as U,Ll as V,$r as W,Nl as X,Ul as Y,Pl as Z,P as _,Js as a,Vd as a$,Wl as a0,vs as a1,ce as a2,Ms as a3,zo as a4,qs as a5,jd as a6,ql as a7,jl as a8,Gr as a9,uo as aA,td as aB,lo as aC,es as aD,Ke as aE,ud as aF,hd as aG,ao as aH,Gt as aI,jt as aJ,Hl as aK,pd as aL,dd as aM,Id as aN,fd as aO,ad as aP,cd as aQ,Yd as aR,fo as aS,xo as aT,Bt as aU,Ur as aV,mo as aW,fe as aX,Ql as aY,Ho as aZ,Wn as a_,ld as aa,au as ab,le as ac,Mr as ad,iu as ae,Zl as af,qd as ag,Bl as ah,me as ai,X as aj,$l as ak,Us as al,vd as am,Rd as an,Pd as ao,ft as ap,T as aq,m as ar,Ki as as,Ds as at,Gl as au,ks as av,Fl as aw,po as ax,tu as ay,ed as az,Et as b,Si as b$,bd as b0,xt as b1,md as b2,ko as b3,Ua as b4,uu as b5,Ca as b6,Tt as b7,Co as b8,lu as b9,C as bA,va as bB,cu as bC,xl as bD,Oa as bE,du as bF,ul as bG,dl as bH,il as bI,al as bJ,nl as bK,ll as bL,cl as bM,Jl as bN,Ce as bO,yd as bP,od as bQ,gd as bR,hl as bS,pl as bT,yl as bU,gl as bV,fl as bW,Tl as bX,Ud as bY,Ed as bZ,Ei as b_,pu as ba,Yl as bb,Vs as bc,Ra as bd,Wd as be,Kt as bf,Hd as bg,rd as bh,kn as bi,id as bj,Cn as bk,Os as bl,Il as bm,Ol as bn,As as bo,Xd as bp,wl as bq,ml as br,rt as bs,Fr as bt,$s as bu,Al as bv,Sl as bw,Dr as bx,Md as by,El as bz,ru as c,Kl as c0,Ti as c1,Sd as c2,Qd as c3,zl as c4,xd as c5,Bd as c6,Cl as c7,Ad as c8,hu as c9,Td as ca,Od as cb,_l as cc,oi as cd,$d as ce,Dd as cf,kd as cg,Xl as ch,so as ci,Ut as cj,H as ck,Vl as cl,Kd as cm,Gd as cn,nu as d,bl as e,Wr as f,Jd as g,R as h,Cd as i,Vo as j,Zd as k,Eo as l,_d as m,ou as n,kr as o,nt as p,kl as q,Br as r,qo as s,Ps as t,vl as u,su as v,Yr as w,Dl as x,ae as y,Ld as z};