@ordergroove/offers 2.34.4 → 2.34.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/offers.js CHANGED
@@ -107,7 +107,7 @@ var lib=(()=>{var ja=Object.create;var yt=Object.defineProperty;var Va=Object.ge
107
107
  `}
108
108
  <button ?disabled=${this.disabled} @click="${this.runTests.bind(this)}" class="primary">Run Test</button>
109
109
  </div>
110
- `}};n(Gt,"TestWizard");fl=Gt});var ku={};co(ku,{addOptinChangedCallback:()=>uu,addTemplate:()=>du,autoInit:()=>Nu,clear:()=>fu,config:()=>hu,default:()=>Iu,disableOptinChangedCallbacks:()=>mu,getOptins:()=>gu,getProductsForPurchasePost:()=>yu,initialize:()=>bu,isReady:()=>lu,offers:()=>w,platform:()=>L,previewMode:()=>_u,register:()=>Su,resolveSettings:()=>Eu,setAuthUrl:()=>xu,setEnvironment:()=>vu,setLocale:()=>Ou,setMerchantId:()=>Tu,setPublicPath:()=>Pu,setTemplates:()=>wu,setupCart:()=>Cu,setupProduct:()=>Ru,setupProducts:()=>Au,store:()=>Ma});function po(t){var e,r=t.Symbol;return typeof r=="function"?r.observable?e=r.observable:(e=r("observable"),r.observable=e):e="@@observable",e}n(po,"symbolObservablePonyfill");var He;typeof self<"u"?He=self:typeof window<"u"||typeof window<"u"?He=window:typeof module<"u"?He=module:He=Function("return this")();var za=po(He),lo=za;var uo=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),bt={INIT:"@@redux/INIT"+uo(),REPLACE:"@@redux/REPLACE"+uo(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+uo()},"PROBE_UNKNOWN_ACTION")};function Ya(t){if(typeof t!="object"||t===null)return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}n(Ya,"isPlainObject");function fo(t,e,r){var o;if(typeof e=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if(typeof e=="function"&&typeof r>"u"&&(r=e,e=void 0),typeof r<"u"){if(typeof r!="function")throw new Error("Expected the enhancer to be a function.");return r(fo)(t,e)}if(typeof t!="function")throw new Error("Expected the reducer to be a function.");var i=t,s=e,a=[],c=a,p=!1;function l(){c===a&&(c=a.slice())}n(l,"ensureCanMutateNextListeners");function f(){if(p)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return s}n(f,"getState");function d(h){if(typeof h!="function")throw new Error("Expected the listener to be a function.");if(p)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var v=!0;return l(),c.push(h),n(function(){if(!!v){if(p)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");v=!1,l();var S=c.indexOf(h);c.splice(S,1),a=null}},"unsubscribe")}n(d,"subscribe");function m(h){if(!Ya(h))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof h.type>"u")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(p)throw new Error("Reducers may not dispatch actions.");try{p=!0,s=i(s,h)}finally{p=!1}for(var v=a=c,C=0;C<v.length;C++){var S=v[C];S()}return h}n(m,"dispatch");function b(h){if(typeof h!="function")throw new Error("Expected the nextReducer to be a function.");i=h,m({type:bt.REPLACE})}n(b,"replaceReducer");function x(){var h,v=d;return h={subscribe:n(function(S){if(typeof S!="object"||S===null)throw new TypeError("Expected the observer to be an object.");function _(){S.next&&S.next(f())}n(_,"observeState"),_();var zt=v(_);return{unsubscribe:zt}},"subscribe")},h[lo]=function(){return this},h}return n(x,"observable"),m({type:bt.INIT}),o={dispatch:m,subscribe:d,getState:f,replaceReducer:b},o[lo]=x,o}n(fo,"createStore");function Wa(t,e){var r=e&&e.type,o=r&&'action "'+String(r)+'"'||"an action";return"Given "+o+', reducer "'+t+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}n(Wa,"getUndefinedStateErrorMessage");function Ja(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:bt.INIT});if(typeof o>"u")throw new Error('Reducer "'+e+`" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:bt.PROBE_UNKNOWN_ACTION()})>"u")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+bt.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.")})}n(Ja,"assertReducerShape");function Yt(t){for(var e=Object.keys(t),r={},o=0;o<e.length;o++){var i=e[o];typeof t[i]=="function"&&(r[i]=t[i])}var s=Object.keys(r),a,c;try{Ja(r)}catch(p){c=p}return n(function(l,f){if(l===void 0&&(l={}),c)throw c;if(!1)var d;for(var m=!1,b={},x=0;x<s.length;x++){var h=s[x],v=r[h],C=l[h],S=v(C,f);if(typeof S>"u"){var _=Wa(h,f);throw new Error(_)}b[h]=S,m=m||S!==C}return m=m||s.length!==Object.keys(l).length,m?b:l},"combination")}n(Yt,"combineReducers");function jn(t,e){return function(){return e(t.apply(this,arguments))}}n(jn,"bindActionCreator");function Hn(t,e){if(typeof t=="function")return jn(t,e);if(typeof t!="object"||t===null)throw new Error("bindActionCreators expected an object or a function, instead received "+(t===null?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');var r={};for(var o in t){var i=t[o];typeof i=="function"&&(r[o]=jn(i,e))}return r}n(Hn,"bindActionCreators");function Ka(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n(Ka,"_defineProperty");function Vn(t,e){var r=Object.keys(t);return Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(t)),e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r}n(Vn,"ownKeys");function Qa(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Vn(r,!0).forEach(function(o){Ka(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Vn(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n(Qa,"_objectSpread2");function ho(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.length===0?function(o){return o}:e.length===1?e[0]:e.reduce(function(o,i){return function(){return o(i.apply(void 0,arguments))}})}n(ho,"compose");function Gn(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(o){return function(){var i=o.apply(void 0,arguments),s=n(function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},"dispatch"),a={getState:i.getState,dispatch:n(function(){return s.apply(void 0,arguments)},"dispatch")},c=e.map(function(p){return p(a)});return s=ho.apply(void 0,c)(i.dispatch),Qa({},i,{dispatch:s})}}}n(Gn,"applyMiddleware");function Bn(t){var e=n(function(o){var i=o.dispatch,s=o.getState;return function(a){return function(c){return typeof c=="function"?c(i,s,t):a(c)}}},"middleware");return e}n(Bn,"createThunkMiddleware");var zn=Bn();zn.withExtraArgument=Bn;var Yn=zn;var Vi=fe(Jt());A();$();var qt="OG_STATE",Hi=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),No=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),Gi=n(()=>No()?{}:Hi(localStorage.getItem(qt)),"loadState"),lp=n(t=>!t||!t.sessionId?!1:JSON.stringify({sessionId:t.sessionId,optedin:t.optedin,optedout:t.optedout,productOffer:t.productOffer,firstOrderPlaceDate:t.firstOrderPlaceDate,productToSubscribe:t.productToSubscribe}),"serializeState"),Bi=n(t=>{if(No())return;let e=lp(t);e&&localStorage.getItem(qt)!==e&&localStorage.setItem(qt,e)},"saveState"),zi=n(t=>(0,Vi.throttle)(500,e=>{if(No())return;let{key:r,newValue:o}=e;r===qt&&o===null?(t.dispatch({type:he}),setTimeout(()=>t.dispatch(Ni()),0)):r===qt&&t.dispatch({type:Ce,newValue:Hi(o)})}),"listenLocalStorageChanges");var Wi=fe(Jt());$();N();var up=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),Yi=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>up("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),dp=[{expressions:[({type:t}={})=>t===k,({type:t}={})=>t===U],fn:Yi(!0)},{expressions:[({type:t}={})=>t===F],fn:Yi(!1)}],Ji=n(t=>e=>r=>{let o=t.getState();dp.forEach(i=>{i.expressions.some(s=>s(r,o))&&i.fn(r)}),e(r)},"dispatchMiddleware"),Ki=n(t=>e=>r=>{var i;let o;switch(r.type){case R:case F:case k:case U:o=new CustomEvent(`og-${r.type.toLowerCase().replace(/_/g,"-")}`,{bubbles:!0,cancelable:!0,detail:r.payload}),(((i=r.payload)==null?void 0:i.offer)||document).dispatchEvent(o);break;default:}o!=null&&o.defaultPrevented||e(r)},"offerEvents"),Qi=n(t=>e=>r=>{e(r);let o=(0,Wi.throttle)(500,()=>{Bi({...t.getState()})});r.type!==Ce&&o()},"localStorageMiddleware");A();$();var Io=n(()=>{let t,e;return[new Promise((r,o)=>{t=r,e=o}),t,e]},"waitFor");function Zi(t){let[e,r]=Io(),[o,i]=Io(),[s,a]=Io();o.then(p=>{let{sessionId:l}=t.getState();!l||p&&!l.startsWith(p)?t.dispatch(wo(p)):a(l)});let c=Promise.all([o,e,s]);return c.then(()=>{var p;window.addEventListener("storage",zi(t)),(p=t.getState().auth)!=null&&p.ts||t.dispatch(Ai())}),p=>async l=>{Ye===l.type||ze===l.type||We===l.type?r(l.payload):Ge===l.type?i(l.payload):Be===l.type?a(l.payload):await c,p(l)}}n(Zi,"waitUntilOffersReady");function Xi(t,...e){if(window.og&&window.og.store)return window.og.store;let r=window.og&&window.og.previewMode,o=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"Ordergroove Offers"}):ho,i=[Zi,Yn,Ji,Ki],s={};if(!r)try{s=Gi(),i.push(Qi)}catch{}let a=o(Gn(...i,...e.filter(p=>p))),c=fo(t,s,a);return window.og=window.og||{},window.og.store=c,c}n(Xi,"makeStore");var fp=Object.defineProperty,xr=n((t,e)=>fp(t,"name",{value:e,configurable:!0}),"i"),hp=xr(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),ts=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],es=xr(t=>(e,r)=>{ts.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function ko(t=window.opener,e=window.og){let r=xr(o=>{let i=hp(ts),s=es(o.source),a=o.data.options||{};if(i(o)&&o.data.ogType==="READY"){let c="//static.ordergroove.com/@ordergroove/offers-live-editor/0.6.1/dist/";c.startsWith("//")&&(c=window.location.protocol+c),c.endsWith("/")||(c+="/"),import(`${c}client.js`).then(({initializeClient:p})=>{p({isMessageAllowed:i,broadcastMessage:s,options:a,og:e}),window.removeEventListener("message",r)})}},"handleReady");t&&t!==window&&(window.addEventListener("message",r),es(t)("READY"))}n(ko,"f");xr(ko,"offersLiveEditor");var vr=null,mp=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),rs=n(t=>{if(!vr)throw new Error("Missing redux store.");return vr},"resolveStore"),gp=n((t,e)=>r=>{let{getState:o,dispatch:i}=rs(r),s=t?t(o(),r):{},a=e(i,r);Object.assign(r,s,a)},"createRecalcProps"),g=n((t,e=mp)=>r=>{let i=gp(t,typeof e=="function"?e:s=>Hn(e,s));return class extends r{get store(){return vr}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=rs(this).subscribe(()=>i(this)),i(this)}attributeChangedCallback(s,a,c){super.attributeChangedCallback&&super.attributeChangedCallback(s,a,c),this._storeUnsubscribe&&a!==c&&i(this)}disconnectedCallback(){this._storeUnsubscribe(),super.disconnectedCallback&&super.disconnectedCallback()}}},"connect"),os=n(t=>{vr=t},"setStore");ye();var qo=n((t={},e=[])=>(t.optedin||[]).map(r=>{let o={product:r.id,subscription_info:{components:r.components||[]},tracking_override:{offer:((t.productOffer||{})[r.id]||[])[0],...Ct(r.frequency)}};return t.firstOrderPlaceDate&&t.firstOrderPlaceDate[r.id]&&(o.subscription_info.first_order_place_date=t.firstOrderPlaceDate[r.id]),t.productToSubscribe&&t.productToSubscribe[r.id]&&(o.tracking_override.product=t.productToSubscribe[r.id]),o}).filter(r=>r.tracking_override.offer).filter(r=>e.length?e.includes(r.product):r),"getProductsForPurchasePost"),ot=n((t={})=>{let e={};return Object.entries(t).forEach(([r,o])=>{Object.entries(o).forEach(([i,s])=>{let a={};s&&!Array.isArray(s)?a=s:a={frequency:i,prepaidShipments:null,regularPrice:s[0],subscriptionPrice:s[2],discountRate:s[1]},e[r]?e[r].push(a):e[r]=[a]})}),e},"getObjectStructuredProductPlans");A();E();var Ls=fe(Ns());E();var Dp=n(t=>{let e=String(t||"").trim().match(/(\d+)\s*([dwm])/);return e?`${e[1]}_${{d:1,w:2,m:3}[e[2]]}`:t},"sanitizeFrequencyString"),Is=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var Mt=n(t=>{let e=Is(t);if(!e){let r=t.offer;r&&(e=Is(r))}return e},"resolveProduct"),Fp=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),on=n(t=>class extends t{get offer(){return Fp(this)}connectedCallback(){super.connectedCallback(),this.offersChangeTemplate=this.offersChangeTemplate.bind(this),this.offer&&this.offer.addEventListener("template-changed",this.offersChangeTemplate)}disconnectedCallback(){super.disconnectedCallback(),this.offer&&this.offer.removeEventListener("template-changed",this.offersChangeTemplate)}offersChangeTemplate(){this._enqueueUpdate()}},"withOfferTemplate"),I=n(t=>class extends on(t){get product(){return Mt(this)}},"withProduct"),Dr=n(t=>class extends t{get childOptions(){let e=[],r=null;return this.querySelectorAll("option").forEach(o=>{let i=Dp(o.value),s=o.innerText.trim();e.push({value:i,text:s}),!r&&o.selected&&(r=i)}),{options:e,isSelected:r}}},"withChildOptions");var Fr={};co(Fr,{autoshipByDefault:()=>Up,eligibilityGroups:()=>sn,eligible:()=>ks,hasPrepaidOptions:()=>Vp,hasUpcomingOrder:()=>Fs,hasUpsellGroup:()=>Ds,inStock:()=>nn,optedout:()=>$p,prepaidEligible:()=>Lp,prepaidSubscribed:()=>jp,regularEligible:()=>Gp,subscribed:()=>Mp,subscriptionEligible:()=>qs,upcomingOrderContainsProduct:()=>Hp,upsellEligible:()=>Us});N();q();var nn=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),ks=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),Up=n((t,e)=>(t.autoshipByDefault||{})[(e.product||{}).id]||!1,"autoshipByDefault"),qs=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&ks(t,e)&&nn(t,e),"subscriptionEligible"),sn=n((t,e)=>{let r=T((e.product||{}).id);return(t.eligibilityGroups||{})[r]||null},"eligibilityGroups"),Ds=n((t,e)=>{let r=sn(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),Lp=n((t,e)=>{let r=sn(t,e);return(r==null?void 0:r.some(o=>o==="prepaid"))||!1},"prepaidEligible"),Mp=n((t,e)=>mr(e.product)(t),"subscribed"),$p=n((t,e)=>gr(e.product)(t),"optedout"),jp=n((t,e)=>Si(e.product)(t),"prepaidSubscribed"),Vp=n((t,e)=>ne(e.product.id)(t).length>0,"hasPrepaidOptions"),Fs=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),Hp=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),Us=n((t,e)=>{var r;return!((r=e.offer)!=null&&r.isCart)&&t.offerId&&t.offerId!=="0"&&t.auth&&nn(t,e)&&Fs(t)&&Ds(t,e)},"upsellEligible"),Gp=n((t,e)=>qs(t,e)&&!Us(t,e),"regularEligible");var Bp=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),Ur=class extends I(P){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){if(!this.test)return u``;let e=Bp(this.test);return e=e.replace(/(![a-zA-Z]+)/g,"($1)"),Ls.default.parse(e,o=>Fr[o]&&Fr[o](this.state,this))?u`
110
+ `}};n(Gt,"TestWizard");fl=Gt});var ku={};co(ku,{addOptinChangedCallback:()=>uu,addTemplate:()=>du,autoInit:()=>Nu,clear:()=>fu,config:()=>hu,default:()=>Iu,disableOptinChangedCallbacks:()=>mu,getOptins:()=>gu,getProductsForPurchasePost:()=>yu,initialize:()=>bu,isReady:()=>lu,offers:()=>w,platform:()=>L,previewMode:()=>_u,register:()=>Su,resolveSettings:()=>Eu,setAuthUrl:()=>xu,setEnvironment:()=>vu,setLocale:()=>Ou,setMerchantId:()=>Tu,setPublicPath:()=>Pu,setTemplates:()=>wu,setupCart:()=>Cu,setupProduct:()=>Ru,setupProducts:()=>Au,store:()=>Ma});function po(t){var e,r=t.Symbol;return typeof r=="function"?r.observable?e=r.observable:(e=r("observable"),r.observable=e):e="@@observable",e}n(po,"symbolObservablePonyfill");var He;typeof self<"u"?He=self:typeof window<"u"||typeof window<"u"?He=window:typeof module<"u"?He=module:He=Function("return this")();var za=po(He),lo=za;var uo=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),bt={INIT:"@@redux/INIT"+uo(),REPLACE:"@@redux/REPLACE"+uo(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+uo()},"PROBE_UNKNOWN_ACTION")};function Ya(t){if(typeof t!="object"||t===null)return!1;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}n(Ya,"isPlainObject");function fo(t,e,r){var o;if(typeof e=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if(typeof e=="function"&&typeof r>"u"&&(r=e,e=void 0),typeof r<"u"){if(typeof r!="function")throw new Error("Expected the enhancer to be a function.");return r(fo)(t,e)}if(typeof t!="function")throw new Error("Expected the reducer to be a function.");var i=t,s=e,a=[],c=a,p=!1;function l(){c===a&&(c=a.slice())}n(l,"ensureCanMutateNextListeners");function f(){if(p)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return s}n(f,"getState");function d(h){if(typeof h!="function")throw new Error("Expected the listener to be a function.");if(p)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var v=!0;return l(),c.push(h),n(function(){if(!!v){if(p)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");v=!1,l();var S=c.indexOf(h);c.splice(S,1),a=null}},"unsubscribe")}n(d,"subscribe");function m(h){if(!Ya(h))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof h.type>"u")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(p)throw new Error("Reducers may not dispatch actions.");try{p=!0,s=i(s,h)}finally{p=!1}for(var v=a=c,C=0;C<v.length;C++){var S=v[C];S()}return h}n(m,"dispatch");function b(h){if(typeof h!="function")throw new Error("Expected the nextReducer to be a function.");i=h,m({type:bt.REPLACE})}n(b,"replaceReducer");function x(){var h,v=d;return h={subscribe:n(function(S){if(typeof S!="object"||S===null)throw new TypeError("Expected the observer to be an object.");function _(){S.next&&S.next(f())}n(_,"observeState"),_();var zt=v(_);return{unsubscribe:zt}},"subscribe")},h[lo]=function(){return this},h}return n(x,"observable"),m({type:bt.INIT}),o={dispatch:m,subscribe:d,getState:f,replaceReducer:b},o[lo]=x,o}n(fo,"createStore");function Wa(t,e){var r=e&&e.type,o=r&&'action "'+String(r)+'"'||"an action";return"Given "+o+', reducer "'+t+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}n(Wa,"getUndefinedStateErrorMessage");function Ja(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:bt.INIT});if(typeof o>"u")throw new Error('Reducer "'+e+`" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:bt.PROBE_UNKNOWN_ACTION()})>"u")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+bt.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.")})}n(Ja,"assertReducerShape");function Yt(t){for(var e=Object.keys(t),r={},o=0;o<e.length;o++){var i=e[o];typeof t[i]=="function"&&(r[i]=t[i])}var s=Object.keys(r),a,c;try{Ja(r)}catch(p){c=p}return n(function(l,f){if(l===void 0&&(l={}),c)throw c;if(!1)var d;for(var m=!1,b={},x=0;x<s.length;x++){var h=s[x],v=r[h],C=l[h],S=v(C,f);if(typeof S>"u"){var _=Wa(h,f);throw new Error(_)}b[h]=S,m=m||S!==C}return m=m||s.length!==Object.keys(l).length,m?b:l},"combination")}n(Yt,"combineReducers");function jn(t,e){return function(){return e(t.apply(this,arguments))}}n(jn,"bindActionCreator");function Hn(t,e){if(typeof t=="function")return jn(t,e);if(typeof t!="object"||t===null)throw new Error("bindActionCreators expected an object or a function, instead received "+(t===null?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');var r={};for(var o in t){var i=t[o];typeof i=="function"&&(r[o]=jn(i,e))}return r}n(Hn,"bindActionCreators");function Ka(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n(Ka,"_defineProperty");function Vn(t,e){var r=Object.keys(t);return Object.getOwnPropertySymbols&&r.push.apply(r,Object.getOwnPropertySymbols(t)),e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r}n(Vn,"ownKeys");function Qa(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Vn(r,!0).forEach(function(o){Ka(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Vn(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n(Qa,"_objectSpread2");function ho(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.length===0?function(o){return o}:e.length===1?e[0]:e.reduce(function(o,i){return function(){return o(i.apply(void 0,arguments))}})}n(ho,"compose");function Gn(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(o){return function(){var i=o.apply(void 0,arguments),s=n(function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},"dispatch"),a={getState:i.getState,dispatch:n(function(){return s.apply(void 0,arguments)},"dispatch")},c=e.map(function(p){return p(a)});return s=ho.apply(void 0,c)(i.dispatch),Qa({},i,{dispatch:s})}}}n(Gn,"applyMiddleware");function Bn(t){var e=n(function(o){var i=o.dispatch,s=o.getState;return function(a){return function(c){return typeof c=="function"?c(i,s,t):a(c)}}},"middleware");return e}n(Bn,"createThunkMiddleware");var zn=Bn();zn.withExtraArgument=Bn;var Yn=zn;var Vi=fe(Jt());A();$();var qt="OG_STATE",Hi=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),No=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),Gi=n(()=>No()?{}:Hi(localStorage.getItem(qt)),"loadState"),lp=n(t=>!t||!t.sessionId?!1:JSON.stringify({sessionId:t.sessionId,optedin:t.optedin,optedout:t.optedout,productOffer:t.productOffer,firstOrderPlaceDate:t.firstOrderPlaceDate,productToSubscribe:t.productToSubscribe}),"serializeState"),Bi=n(t=>{if(No())return;let e=lp(t);e&&localStorage.getItem(qt)!==e&&localStorage.setItem(qt,e)},"saveState"),zi=n(t=>(0,Vi.throttle)(500,e=>{if(No())return;let{key:r,newValue:o}=e;r===qt&&o===null?(t.dispatch({type:he}),setTimeout(()=>t.dispatch(Ni()),0)):r===qt&&t.dispatch({type:Ce,newValue:Hi(o)})}),"listenLocalStorageChanges");var Wi=fe(Jt());$();N();var up=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),Yi=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>up("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),dp=[{expressions:[({type:t}={})=>t===k,({type:t}={})=>t===U],fn:Yi(!0)},{expressions:[({type:t}={})=>t===F],fn:Yi(!1)}],Ji=n(t=>e=>r=>{let o=t.getState();dp.forEach(i=>{i.expressions.some(s=>s(r,o))&&i.fn(r)}),e(r)},"dispatchMiddleware"),Ki=n(t=>e=>r=>{var i;let o;switch(r.type){case R:case F:case k:case U:o=new CustomEvent(`og-${r.type.toLowerCase().replace(/_/g,"-")}`,{bubbles:!0,cancelable:!0,detail:r.payload}),(((i=r.payload)==null?void 0:i.offer)||document).dispatchEvent(o);break;default:}o!=null&&o.defaultPrevented||e(r)},"offerEvents"),Qi=n(t=>e=>r=>{e(r);let o=(0,Wi.throttle)(500,()=>{Bi({...t.getState()})});r.type!==Ce&&o()},"localStorageMiddleware");A();$();var Io=n(()=>{let t,e;return[new Promise((r,o)=>{t=r,e=o}),t,e]},"waitFor");function Zi(t){let[e,r]=Io(),[o,i]=Io(),[s,a]=Io();o.then(p=>{let{sessionId:l}=t.getState();!l||p&&!l.startsWith(p)?t.dispatch(wo(p)):a(l)});let c=Promise.all([o,e,s]);return c.then(()=>{var p;window.addEventListener("storage",zi(t)),(p=t.getState().auth)!=null&&p.ts||t.dispatch(Ai())}),p=>async l=>{Ye===l.type||ze===l.type||We===l.type?r(l.payload):Ge===l.type?i(l.payload):Be===l.type?a(l.payload):await c,p(l)}}n(Zi,"waitUntilOffersReady");function Xi(t,...e){if(window.og&&window.og.store)return window.og.store;let r=window.og&&window.og.previewMode,o=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"Ordergroove Offers"}):ho,i=[Zi,Yn,Ji,Ki],s={};if(!r)try{s=Gi(),i.push(Qi)}catch{}let a=o(Gn(...i,...e.filter(p=>p))),c=fo(t,s,a);return window.og=window.og||{},window.og.store=c,c}n(Xi,"makeStore");var fp=Object.defineProperty,xr=n((t,e)=>fp(t,"name",{value:e,configurable:!0}),"i"),hp=xr(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),ts=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","https://rc3-beta.stg.ordergroove.com","http://localhost:3000",window.location.origin],es=xr(t=>(e,r)=>{ts.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function ko(t=window.opener,e=window.og){let r=xr(o=>{let i=hp(ts),s=es(o.source),a=o.data.options||{};if(i(o)&&o.data.ogType==="READY"){let c="//static.ordergroove.com/@ordergroove/offers-live-editor/0.6.2/dist/";c.startsWith("//")&&(c=window.location.protocol+c),c.endsWith("/")||(c+="/"),import(`${c}client.js`).then(({initializeClient:p})=>{p({isMessageAllowed:i,broadcastMessage:s,options:a,og:e}),window.removeEventListener("message",r)})}},"handleReady");t&&t!==window&&(window.addEventListener("message",r),es(t)("READY"))}n(ko,"f");xr(ko,"offersLiveEditor");var vr=null,mp=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),rs=n(t=>{if(!vr)throw new Error("Missing redux store.");return vr},"resolveStore"),gp=n((t,e)=>r=>{let{getState:o,dispatch:i}=rs(r),s=t?t(o(),r):{},a=e(i,r);Object.assign(r,s,a)},"createRecalcProps"),g=n((t,e=mp)=>r=>{let i=gp(t,typeof e=="function"?e:s=>Hn(e,s));return class extends r{get store(){return vr}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=rs(this).subscribe(()=>i(this)),i(this)}attributeChangedCallback(s,a,c){super.attributeChangedCallback&&super.attributeChangedCallback(s,a,c),this._storeUnsubscribe&&a!==c&&i(this)}disconnectedCallback(){this._storeUnsubscribe(),super.disconnectedCallback&&super.disconnectedCallback()}}},"connect"),os=n(t=>{vr=t},"setStore");ye();var qo=n((t={},e=[])=>(t.optedin||[]).map(r=>{let o={product:r.id,subscription_info:{components:r.components||[]},tracking_override:{offer:((t.productOffer||{})[r.id]||[])[0],...Ct(r.frequency)}};return t.firstOrderPlaceDate&&t.firstOrderPlaceDate[r.id]&&(o.subscription_info.first_order_place_date=t.firstOrderPlaceDate[r.id]),t.productToSubscribe&&t.productToSubscribe[r.id]&&(o.tracking_override.product=t.productToSubscribe[r.id]),o}).filter(r=>r.tracking_override.offer).filter(r=>e.length?e.includes(r.product):r),"getProductsForPurchasePost"),ot=n((t={})=>{let e={};return Object.entries(t).forEach(([r,o])=>{Object.entries(o).forEach(([i,s])=>{let a={};s&&!Array.isArray(s)?a=s:a={frequency:i,prepaidShipments:null,regularPrice:s[0],subscriptionPrice:s[2],discountRate:s[1]},e[r]?e[r].push(a):e[r]=[a]})}),e},"getObjectStructuredProductPlans");A();E();var Ls=fe(Ns());E();var Dp=n(t=>{let e=String(t||"").trim().match(/(\d+)\s*([dwm])/);return e?`${e[1]}_${{d:1,w:2,m:3}[e[2]]}`:t},"sanitizeFrequencyString"),Is=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var Mt=n(t=>{let e=Is(t);if(!e){let r=t.offer;r&&(e=Is(r))}return e},"resolveProduct"),Fp=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),on=n(t=>class extends t{get offer(){return Fp(this)}connectedCallback(){super.connectedCallback(),this.offersChangeTemplate=this.offersChangeTemplate.bind(this),this.offer&&this.offer.addEventListener("template-changed",this.offersChangeTemplate)}disconnectedCallback(){super.disconnectedCallback(),this.offer&&this.offer.removeEventListener("template-changed",this.offersChangeTemplate)}offersChangeTemplate(){this._enqueueUpdate()}},"withOfferTemplate"),I=n(t=>class extends on(t){get product(){return Mt(this)}},"withProduct"),Dr=n(t=>class extends t{get childOptions(){let e=[],r=null;return this.querySelectorAll("option").forEach(o=>{let i=Dp(o.value),s=o.innerText.trim();e.push({value:i,text:s}),!r&&o.selected&&(r=i)}),{options:e,isSelected:r}}},"withChildOptions");var Fr={};co(Fr,{autoshipByDefault:()=>Up,eligibilityGroups:()=>sn,eligible:()=>ks,hasPrepaidOptions:()=>Vp,hasUpcomingOrder:()=>Fs,hasUpsellGroup:()=>Ds,inStock:()=>nn,optedout:()=>$p,prepaidEligible:()=>Lp,prepaidSubscribed:()=>jp,regularEligible:()=>Gp,subscribed:()=>Mp,subscriptionEligible:()=>qs,upcomingOrderContainsProduct:()=>Hp,upsellEligible:()=>Us});N();q();var nn=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),ks=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),Up=n((t,e)=>(t.autoshipByDefault||{})[(e.product||{}).id]||!1,"autoshipByDefault"),qs=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&ks(t,e)&&nn(t,e),"subscriptionEligible"),sn=n((t,e)=>{let r=T((e.product||{}).id);return(t.eligibilityGroups||{})[r]||null},"eligibilityGroups"),Ds=n((t,e)=>{let r=sn(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),Lp=n((t,e)=>{let r=sn(t,e);return(r==null?void 0:r.some(o=>o==="prepaid"))||!1},"prepaidEligible"),Mp=n((t,e)=>mr(e.product)(t),"subscribed"),$p=n((t,e)=>gr(e.product)(t),"optedout"),jp=n((t,e)=>Si(e.product)(t),"prepaidSubscribed"),Vp=n((t,e)=>ne(e.product.id)(t).length>0,"hasPrepaidOptions"),Fs=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),Hp=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),Us=n((t,e)=>{var r;return!((r=e.offer)!=null&&r.isCart)&&t.offerId&&t.offerId!=="0"&&t.auth&&nn(t,e)&&Fs(t)&&Ds(t,e)},"upsellEligible"),Gp=n((t,e)=>qs(t,e)&&!Us(t,e),"regularEligible");var Bp=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),Ur=class extends I(P){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){if(!this.test)return u``;let e=Bp(this.test);return e=e.replace(/(![a-zA-Z]+)/g,"($1)"),Ls.default.parse(e,o=>Fr[o]&&Fr[o](this.state,this))?u`
111
111
  <slot></slot>
112
112
  `:u``}shouldUpdate(e){return e.size&&(this.product&&this.product.id in this.state.autoshipEligible&&this.product.id in this.state.inStock||!this.product.id)}};n(Ur,"When");var zp=n(t=>({state:t}),"mapStateToProps"),Ms=g(zp)(Ur);E();A();E();N();ye();var $s={type:Object,converter:{toAttribute(t){return t==null?t:JSON.stringify(t)},fromAttribute(t){return t&&t.match(/[{[]/)?JSON.parse(t):{id:t}}}},Te={type:String,attribute:"default-frequency",converter:{fromAttribute(t){return t&&So(t)?t:null}}},Lr={type:Boolean,attribute:!0,reflect:!0},ft={type:Object,attribute:!1};E();N();var Yp=n(t=>class extends t{getOption(e,r=e){let o=vo(e);if(this.hasAttribute(o)){let i=this.getAttribute(o);return i.toString().toLowerCase()==="true"?!0:i.toString().toLowerCase()==="false"?!1:i}if(this.template&&this.template.config&&typeof this.template.config[r]!="undefined")return this.template.config[r];if(this.config&&typeof this.config[r]!="undefined")return this.config[r]}applyTemplate(e){this.template=e;let r=typeof e.markup=="undefined"?this.constructor.initialTemplate:e.markup;r&&this._templateMarkup!==r&&(this._templateMarkup=r,this.innerHTML=r)}refreshTemplate(){if(this._templates&&this._templates.length){let e=this._templates.find(({selector:r})=>{try{return this.matches(r)}catch{return!1}});this.applyTemplate(e||{})}}set templates(e){this._templates=e,this.refreshTemplate()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.constructor.initialTemplate&&!this.innerHTML.trim()&&(this.innerHTML=this.constructor.initialTemplate)}},"withTemplate"),M=Yp(P);var Y=class extends I(M){static get properties(){return{subscribed:Lr,frequencyMatch:{type:Boolean,reflect:!0,attribute:"frequency-match"},productDefaultFrequency:{type:String},defaultFrequency:{type:String},frequencies:{type:Array}}}static get styles(){return y`
113
113
  :host {