@ordergroove/offers 2.33.1 → 2.33.2
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/CHANGELOG.md +11 -0
- package/dist/bundle-report.html +4 -4
- package/dist/offers.js +1 -1
- package/dist/offers.js.map +2 -2
- package/package.json +2 -2
- package/src/components/When.js +10 -3
- package/src/components/__tests__/When.spec.js +52 -28
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.33.2](https://github.com/ordergroove/plush-toys/compare/@ordergroove/offers@2.33.1...@ordergroove/offers@2.33.2) (2023-04-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* properly parse og-when expression with !& (canary) ([989c398](https://github.com/ordergroove/plush-toys/commit/989c398b6d82f95e874acb4888d10d1a2475bf78))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [2.33.1](https://github.com/ordergroove/plush-toys/compare/@ordergroove/offers@2.33.0...@ordergroove/offers@2.33.1) (2023-04-10)
|
|
7
18
|
|
|
8
19
|
|
package/dist/bundle-report.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
│ └ examples/index.js
|
|
5
5
|
└ examples/index.js ───────────────────────────────────────── 9.1kb ─── 3.4%
|
|
6
6
|
|
|
7
|
-
dist/offers.js ───────────────────────────────────────────── 139.
|
|
7
|
+
dist/offers.js ───────────────────────────────────────────── 139.7kb ─ 100.0%
|
|
8
8
|
├ src/components/Offer.js ─────────────────────────────────── 8.2kb ─── 5.9%
|
|
9
9
|
│ └ src/make-api.js
|
|
10
10
|
│ └ src/index.js
|
|
@@ -193,14 +193,14 @@
|
|
|
193
193
|
│ └ src/components/Price.js
|
|
194
194
|
│ └ src/make-api.js
|
|
195
195
|
│ └ src/index.js
|
|
196
|
+
├ src/components/When.js ──────────────────────────────────── 622b ──── 0.4%
|
|
197
|
+
│ └ src/make-api.js
|
|
198
|
+
│ └ src/index.js
|
|
196
199
|
├ node_modules/logical-expression-parser/polish.js ────────── 594b ──── 0.4%
|
|
197
200
|
│ └ node_modules/logical-expression-parser/index.js
|
|
198
201
|
│ └ src/components/When.js
|
|
199
202
|
│ └ src/make-api.js
|
|
200
203
|
│ └ src/index.js
|
|
201
|
-
├ src/components/When.js ──────────────────────────────────── 564b ──── 0.4%
|
|
202
|
-
│ └ src/make-api.js
|
|
203
|
-
│ └ src/index.js
|
|
204
204
|
├ src/components/OptoutButton.js ──────────────────────────── 546b ──── 0.4%
|
|
205
205
|
│ └ src/make-api.js
|
|
206
206
|
│ └ src/index.js
|
package/dist/offers.js
CHANGED
|
@@ -107,7 +107,7 @@ var lib=(()=>{var Aa=Object.create;var ot=Object.defineProperty;var Na=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(Nr,"TestWizard");Xl=Nr});var bu={};Ur(bu,{addOptinChangedCallback:()=>Qp,addTemplate:()=>Kp,autoInit:()=>gu,clear:()=>Zp,config:()=>Xp,default:()=>yu,disableOptinChangedCallbacks:()=>eu,getOptins:()=>tu,getProductsForPurchasePost:()=>ru,initialize:()=>ou,isReady:()=>Jp,offers:()=>T,platform:()=>L,previewMode:()=>nu,register:()=>su,resolveSettings:()=>iu,setAuthUrl:()=>au,setEnvironment:()=>cu,setLocale:()=>lu,setMerchantId:()=>pu,setPublicPath:()=>uu,setTemplates:()=>du,setupCart:()=>fu,setupProduct:()=>hu,setupProducts:()=>mu,store:()=>Pa});function Lr(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(Lr,"symbolObservablePonyfill");var Fe;typeof self!="undefined"?Fe=self:typeof window!="undefined"||typeof window!="undefined"?Fe=window:typeof module!="undefined"?Fe=module:Fe=Function("return this")();var Fa=Lr(Fe),Mr=Fa;var jr=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),nt={INIT:"@@redux/INIT"+jr(),REPLACE:"@@redux/REPLACE"+jr(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+jr()},"PROBE_UNKNOWN_ACTION")};function Ua(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(Ua,"isPlainObject");function $r(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=="undefined"&&(r=e,e=void 0),typeof r!="undefined"){if(typeof r!="function")throw new Error("Expected the enhancer to be a function.");return r($r)(t,e)}if(typeof t!="function")throw new Error("Expected the reducer to be a function.");var s=t,i=e,a=[],c=a,l=!1;function p(){c===a&&(c=a.slice())}n(p,"ensureCanMutateNextListeners");function f(){if(l)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 i}n(f,"getState");function u(m){if(typeof m!="function")throw new Error("Expected the listener to be a function.");if(l)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 x=!0;return p(),c.push(m),n(function(){if(!!x){if(l)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.");x=!1,p();var b=c.indexOf(m);c.splice(b,1),a=null}},"unsubscribe")}n(u,"subscribe");function h(m){if(!Ua(m))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof m.type=="undefined")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=s(i,m)}finally{l=!1}for(var x=a=c,C=0;C<x.length;C++){var b=x[C];b()}return m}n(h,"dispatch");function P(m){if(typeof m!="function")throw new Error("Expected the nextReducer to be a function.");s=m,h({type:nt.REPLACE})}n(P,"replaceReducer");function _(){var m,x=u;return m={subscribe:n(function(b){if(typeof b!="object"||b===null)throw new TypeError("Expected the observer to be an object.");function y(){b.next&&b.next(f())}n(y,"observeState"),y();var Nt=x(y);return{unsubscribe:Nt}},"subscribe")},m[Mr]=function(){return this},m}return n(_,"observable"),h({type:nt.INIT}),o={dispatch:h,subscribe:u,getState:f,replaceReducer:P},o[Mr]=_,o}n($r,"createStore");function La(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(La,"getUndefinedStateErrorMessage");function Ma(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:nt.INIT});if(typeof o=="undefined")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:nt.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+nt.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(Ma,"assertReducerShape");function It(t){for(var e=Object.keys(t),r={},o=0;o<e.length;o++){var s=e[o];typeof t[s]=="function"&&(r[s]=t[s])}var i=Object.keys(r),a,c;try{Ma(r)}catch(l){c=l}return n(function(p,f){if(p===void 0&&(p={}),c)throw c;if(!1)var u;for(var h=!1,P={},_=0;_<i.length;_++){var m=i[_],x=r[m],C=p[m],b=x(C,f);if(typeof b=="undefined"){var y=La(m,f);throw new Error(y)}P[m]=b,h=h||b!==C}return h=h||i.length!==Object.keys(p).length,h?P:p},"combination")}n(It,"combineReducers");function kn(t,e){return function(){return e(t.apply(this,arguments))}}n(kn,"bindActionCreator");function qn(t,e){if(typeof t=="function")return kn(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 s=t[o];typeof s=="function"&&(r[o]=kn(s,e))}return r}n(qn,"bindActionCreators");function ja(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n(ja,"_defineProperty");function Dn(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(Dn,"ownKeys");function $a(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Dn(r,!0).forEach(function(o){ja(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dn(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n($a,"_objectSpread2");function Vr(){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,s){return function(){return o(s.apply(void 0,arguments))}})}n(Vr,"compose");function Fn(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(o){return function(){var s=o.apply(void 0,arguments),i=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:s.getState,dispatch:n(function(){return i.apply(void 0,arguments)},"dispatch")},c=e.map(function(l){return l(a)});return i=Vr.apply(void 0,c)(s.dispatch),$a({},s,{dispatch:i})}}}n(Fn,"applyMiddleware");function Un(t){var e=n(function(o){var s=o.dispatch,i=o.getState;return function(a){return function(c){return typeof c=="function"?c(s,i,t):a(c)}}},"middleware");return e}n(Un,"createThunkMiddleware");var Ln=Un();Ln.withExtraArgument=Un;var Mn=Ln;var qs=ce(qt());k();j();var bt="OG_STATE",Ds=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),so=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),Fs=n(()=>so()?{}:Ds(localStorage.getItem(bt)),"loadState"),el=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"),Us=n(t=>{if(so())return;let e=el(t);e&&localStorage.getItem(bt)!==e&&localStorage.setItem(bt,e)},"saveState"),Ls=n(t=>(0,qs.throttle)(500,e=>{if(so())return;let{key:r,newValue:o}=e;r===bt&&o===null?(t.dispatch({type:le}),setTimeout(()=>t.dispatch(Ts()),0)):r===bt&&t.dispatch({type:Ee,newValue:Ds(o)})}),"listenLocalStorageChanges");var Ms=ce(qt());j();U();var tl=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),js=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>tl("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),rl=[{expressions:[({type:t}={})=>t===N,({type:t}={})=>t===D],fn:js(!0)},{expressions:[({type:t}={})=>t===q],fn:js(!1)}],$s=n(t=>e=>r=>{let o=t.getState();rl.forEach(s=>{s.expressions.some(i=>i(r,o))&&s.fn(r)}),e(r)},"dispatchMiddleware"),Vs=n(t=>e=>r=>{var s;let o;switch(r.type){case R:case q:case N:case D:o=new CustomEvent(`og-${r.type.toLowerCase().replace(/_/g,"-")}`,{bubbles:!0,cancelable:!0,detail:r.payload}),(((s=r.payload)==null?void 0:s.offer)||document).dispatchEvent(o);break;default:}(o==null?void 0:o.defaultPrevented)||e(r)},"offerEvents"),Hs=n(t=>e=>r=>{e(r);let o=(0,Ms.throttle)(500,()=>{Us({...t.getState()})});r.type!==Ee&&o()},"localStorageMiddleware");k();j();var io=n(()=>{let t,e;return[new Promise((r,o)=>{t=r,e=o}),t,e]},"waitFor");function Gs(t){let[e,r]=io(),[o,s]=io(),[i,a]=io();o.then(l=>{let{sessionId:p}=t.getState();!p||l&&!p.startsWith(l)?t.dispatch(eo(l)):a(p)});let c=Promise.all([o,e,i]);return c.then(()=>{var l;window.addEventListener("storage",Ls(t)),((l=t.getState().auth)==null?void 0:l.ts)||t.dispatch(vs())}),l=>async p=>{je===p.type||Me===p.type||$e===p.type?r(p.payload):Ue===p.type?s(p.payload):Le===p.type?a(p.payload):await c,l(p)}}n(Gs,"waitUntilOffersReady");function Bs(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"}):Vr,s=[Gs,Mn,$s,Vs],i={};if(!r)try{i=Fs(),s.push(Hs)}catch{}let a=o(Fn(...s,...e.filter(l=>l))),c=$r(t,i,a);return window.og=window.og||{},window.og.store=c,c}n(Bs,"makeStore");var ol=Object.defineProperty,pr=n((t,e)=>ol(t,"name",{value:e,configurable:!0}),"i"),nl=pr(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),zs=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],Ws=pr(t=>(e,r)=>{zs.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function ao(t=window.opener,e=window.og){let r=pr(o=>{let s=nl(zs),i=Ws(o.source),a=o.data.options||{};if(s(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:l})=>{l({isMessageAllowed:s,broadcastMessage:i,options:a,og:e}),window.removeEventListener("message",r)})}},"handleReady");t&&t!==window&&(window.addEventListener("message",r),Ws(t)("READY"))}n(ao,"f");pr(ao,"offersLiveEditor");var ur=null,sl=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),Ys=n(t=>{if(!ur)throw new Error("Missing redux store.");return ur},"resolveStore"),il=n((t,e)=>r=>{let{getState:o,dispatch:s}=Ys(r),i=t?t(o(),r):{},a=e(s,r);Object.assign(r,i,a)},"createRecalcProps"),g=n((t,e=sl)=>r=>{let s=il(t,typeof e=="function"?e:i=>qn(e,i));return class extends r{get store(){return ur}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=Ys(this).subscribe(()=>s(this)),s(this)}attributeChangedCallback(i,a,c){super.attributeChangedCallback&&super.attributeChangedCallback(i,a,c),this._storeUnsubscribe&&a!==c&&s(this)}disconnectedCallback(){this._storeUnsubscribe(),super.disconnectedCallback&&super.disconnectedCallback()}}},"connect"),Js=n(t=>{ur=t},"setStore");de();var co=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],...dt(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"),Qe=n((t={})=>{let e={};return Object.entries(t).forEach(([r,o])=>{Object.entries(o).forEach(([s,i])=>{let a={};i&&!Array.isArray(i)?a=i:a={frequency:s,prepaidShipments:null,regularPrice:i[0],subscriptionPrice:i[2],discountRate:i[1]},e[r]?e[r].push(a):e[r]=[a]})}),e},"getObjectStructuredProductPlans");k();O();var Ai=ce(vi());O();var Tl=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"),Ti=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var Io=n(t=>{let e=Ti(t);if(!e){let r=t.offer;r&&(e=Ti(r))}return e},"resolveProduct"),Ol=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),ko=n(t=>class extends t{get offer(){return Ol(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"),A=n(t=>class extends ko(t){get product(){return Io(this)}},"withProduct"),Or=n(t=>class extends t{get childOptions(){let e=[],r=null;return this.querySelectorAll("option").forEach(o=>{let s=Tl(o.value),i=o.innerText.trim();e.push({value:s,text:i}),!r&&o.selected&&(r=s)}),{options:e,isSelected:r}}},"withChildOptions");var Pr={};Ur(Pr,{autoshipByDefault:()=>Pl,eligibilityGroups:()=>Do,eligible:()=>Oi,hasPrepaidOptions:()=>Nl,hasUpcomingOrder:()=>Ci,hasUpsellGroup:()=>wi,inStock:()=>qo,optedout:()=>Rl,prepaidEligible:()=>wl,prepaidSubscribed:()=>Al,regularEligible:()=>kl,subscribed:()=>Cl,subscriptionEligible:()=>Pi,upcomingOrderContainsProduct:()=>Il,upsellEligible:()=>Ri});U();var qo=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),Oi=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),Pl=n((t,e)=>(t.autoshipByDefault||{})[(e.product||{}).id]||!1,"autoshipByDefault"),Pi=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&Oi(t,e)&&qo(t,e),"subscriptionEligible"),Do=n((t,e)=>(t.eligibilityGroups||{})[(e.product||{}).id]||null,"eligibilityGroups"),wi=n((t,e)=>{let r=Do(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),wl=n((t,e)=>{let r=Do(t,e);return(r==null?void 0:r.some(o=>o==="prepaid"))||!1},"prepaidEligible"),Cl=n((t,e)=>er(e.product)(t),"subscribed"),Rl=n((t,e)=>rr(e.product)(t),"optedout"),Al=n((t,e)=>ds(e.product)(t),"prepaidSubscribed"),Nl=n((t,e)=>nr(e.product.id)(t).length>0,"hasPrepaidOptions"),Ci=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),Il=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),Ri=n((t,e)=>{var r;return!((r=e.offer)==null?void 0:r.isCart)&&t.offerId&&t.offerId!=="0"&&t.auth&&qo(t,e)&&Ci(t)&&wi(t,e)},"upsellEligible"),kl=n((t,e)=>Pi(t,e)&&!Ri(t,e),"regularEligible");var ql=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),Fo=class extends A(v){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){return this.test&&Ai.default.parse(ql(this.test),r=>Pr[r]&&Pr[r](this.state,this))?d`
|
|
110
|
+
`}};n(Nr,"TestWizard");Xl=Nr});var bu={};Ur(bu,{addOptinChangedCallback:()=>Qp,addTemplate:()=>Kp,autoInit:()=>gu,clear:()=>Zp,config:()=>Xp,default:()=>yu,disableOptinChangedCallbacks:()=>eu,getOptins:()=>tu,getProductsForPurchasePost:()=>ru,initialize:()=>ou,isReady:()=>Jp,offers:()=>T,platform:()=>L,previewMode:()=>nu,register:()=>su,resolveSettings:()=>iu,setAuthUrl:()=>au,setEnvironment:()=>cu,setLocale:()=>lu,setMerchantId:()=>pu,setPublicPath:()=>uu,setTemplates:()=>du,setupCart:()=>fu,setupProduct:()=>hu,setupProducts:()=>mu,store:()=>Pa});function Lr(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(Lr,"symbolObservablePonyfill");var Fe;typeof self!="undefined"?Fe=self:typeof window!="undefined"||typeof window!="undefined"?Fe=window:typeof module!="undefined"?Fe=module:Fe=Function("return this")();var Fa=Lr(Fe),Mr=Fa;var jr=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),nt={INIT:"@@redux/INIT"+jr(),REPLACE:"@@redux/REPLACE"+jr(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+jr()},"PROBE_UNKNOWN_ACTION")};function Ua(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(Ua,"isPlainObject");function $r(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=="undefined"&&(r=e,e=void 0),typeof r!="undefined"){if(typeof r!="function")throw new Error("Expected the enhancer to be a function.");return r($r)(t,e)}if(typeof t!="function")throw new Error("Expected the reducer to be a function.");var s=t,i=e,a=[],c=a,l=!1;function p(){c===a&&(c=a.slice())}n(p,"ensureCanMutateNextListeners");function f(){if(l)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 i}n(f,"getState");function u(m){if(typeof m!="function")throw new Error("Expected the listener to be a function.");if(l)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 x=!0;return p(),c.push(m),n(function(){if(!!x){if(l)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.");x=!1,p();var b=c.indexOf(m);c.splice(b,1),a=null}},"unsubscribe")}n(u,"subscribe");function h(m){if(!Ua(m))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof m.type=="undefined")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=s(i,m)}finally{l=!1}for(var x=a=c,C=0;C<x.length;C++){var b=x[C];b()}return m}n(h,"dispatch");function P(m){if(typeof m!="function")throw new Error("Expected the nextReducer to be a function.");s=m,h({type:nt.REPLACE})}n(P,"replaceReducer");function _(){var m,x=u;return m={subscribe:n(function(b){if(typeof b!="object"||b===null)throw new TypeError("Expected the observer to be an object.");function y(){b.next&&b.next(f())}n(y,"observeState"),y();var Nt=x(y);return{unsubscribe:Nt}},"subscribe")},m[Mr]=function(){return this},m}return n(_,"observable"),h({type:nt.INIT}),o={dispatch:h,subscribe:u,getState:f,replaceReducer:P},o[Mr]=_,o}n($r,"createStore");function La(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(La,"getUndefinedStateErrorMessage");function Ma(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:nt.INIT});if(typeof o=="undefined")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:nt.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+nt.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(Ma,"assertReducerShape");function It(t){for(var e=Object.keys(t),r={},o=0;o<e.length;o++){var s=e[o];typeof t[s]=="function"&&(r[s]=t[s])}var i=Object.keys(r),a,c;try{Ma(r)}catch(l){c=l}return n(function(p,f){if(p===void 0&&(p={}),c)throw c;if(!1)var u;for(var h=!1,P={},_=0;_<i.length;_++){var m=i[_],x=r[m],C=p[m],b=x(C,f);if(typeof b=="undefined"){var y=La(m,f);throw new Error(y)}P[m]=b,h=h||b!==C}return h=h||i.length!==Object.keys(p).length,h?P:p},"combination")}n(It,"combineReducers");function kn(t,e){return function(){return e(t.apply(this,arguments))}}n(kn,"bindActionCreator");function qn(t,e){if(typeof t=="function")return kn(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 s=t[o];typeof s=="function"&&(r[o]=kn(s,e))}return r}n(qn,"bindActionCreators");function ja(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n(ja,"_defineProperty");function Dn(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(Dn,"ownKeys");function $a(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Dn(r,!0).forEach(function(o){ja(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dn(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n($a,"_objectSpread2");function Vr(){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,s){return function(){return o(s.apply(void 0,arguments))}})}n(Vr,"compose");function Fn(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(o){return function(){var s=o.apply(void 0,arguments),i=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:s.getState,dispatch:n(function(){return i.apply(void 0,arguments)},"dispatch")},c=e.map(function(l){return l(a)});return i=Vr.apply(void 0,c)(s.dispatch),$a({},s,{dispatch:i})}}}n(Fn,"applyMiddleware");function Un(t){var e=n(function(o){var s=o.dispatch,i=o.getState;return function(a){return function(c){return typeof c=="function"?c(s,i,t):a(c)}}},"middleware");return e}n(Un,"createThunkMiddleware");var Ln=Un();Ln.withExtraArgument=Un;var Mn=Ln;var qs=ce(qt());k();j();var bt="OG_STATE",Ds=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),so=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),Fs=n(()=>so()?{}:Ds(localStorage.getItem(bt)),"loadState"),el=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"),Us=n(t=>{if(so())return;let e=el(t);e&&localStorage.getItem(bt)!==e&&localStorage.setItem(bt,e)},"saveState"),Ls=n(t=>(0,qs.throttle)(500,e=>{if(so())return;let{key:r,newValue:o}=e;r===bt&&o===null?(t.dispatch({type:le}),setTimeout(()=>t.dispatch(Ts()),0)):r===bt&&t.dispatch({type:Ee,newValue:Ds(o)})}),"listenLocalStorageChanges");var Ms=ce(qt());j();U();var tl=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),js=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>tl("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),rl=[{expressions:[({type:t}={})=>t===N,({type:t}={})=>t===D],fn:js(!0)},{expressions:[({type:t}={})=>t===q],fn:js(!1)}],$s=n(t=>e=>r=>{let o=t.getState();rl.forEach(s=>{s.expressions.some(i=>i(r,o))&&s.fn(r)}),e(r)},"dispatchMiddleware"),Vs=n(t=>e=>r=>{var s;let o;switch(r.type){case R:case q:case N:case D:o=new CustomEvent(`og-${r.type.toLowerCase().replace(/_/g,"-")}`,{bubbles:!0,cancelable:!0,detail:r.payload}),(((s=r.payload)==null?void 0:s.offer)||document).dispatchEvent(o);break;default:}(o==null?void 0:o.defaultPrevented)||e(r)},"offerEvents"),Hs=n(t=>e=>r=>{e(r);let o=(0,Ms.throttle)(500,()=>{Us({...t.getState()})});r.type!==Ee&&o()},"localStorageMiddleware");k();j();var io=n(()=>{let t,e;return[new Promise((r,o)=>{t=r,e=o}),t,e]},"waitFor");function Gs(t){let[e,r]=io(),[o,s]=io(),[i,a]=io();o.then(l=>{let{sessionId:p}=t.getState();!p||l&&!p.startsWith(l)?t.dispatch(eo(l)):a(p)});let c=Promise.all([o,e,i]);return c.then(()=>{var l;window.addEventListener("storage",Ls(t)),((l=t.getState().auth)==null?void 0:l.ts)||t.dispatch(vs())}),l=>async p=>{je===p.type||Me===p.type||$e===p.type?r(p.payload):Ue===p.type?s(p.payload):Le===p.type?a(p.payload):await c,l(p)}}n(Gs,"waitUntilOffersReady");function Bs(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"}):Vr,s=[Gs,Mn,$s,Vs],i={};if(!r)try{i=Fs(),s.push(Hs)}catch{}let a=o(Fn(...s,...e.filter(l=>l))),c=$r(t,i,a);return window.og=window.og||{},window.og.store=c,c}n(Bs,"makeStore");var ol=Object.defineProperty,pr=n((t,e)=>ol(t,"name",{value:e,configurable:!0}),"i"),nl=pr(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),zs=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],Ws=pr(t=>(e,r)=>{zs.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function ao(t=window.opener,e=window.og){let r=pr(o=>{let s=nl(zs),i=Ws(o.source),a=o.data.options||{};if(s(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:l})=>{l({isMessageAllowed:s,broadcastMessage:i,options:a,og:e}),window.removeEventListener("message",r)})}},"handleReady");t&&t!==window&&(window.addEventListener("message",r),Ws(t)("READY"))}n(ao,"f");pr(ao,"offersLiveEditor");var ur=null,sl=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),Ys=n(t=>{if(!ur)throw new Error("Missing redux store.");return ur},"resolveStore"),il=n((t,e)=>r=>{let{getState:o,dispatch:s}=Ys(r),i=t?t(o(),r):{},a=e(s,r);Object.assign(r,i,a)},"createRecalcProps"),g=n((t,e=sl)=>r=>{let s=il(t,typeof e=="function"?e:i=>qn(e,i));return class extends r{get store(){return ur}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=Ys(this).subscribe(()=>s(this)),s(this)}attributeChangedCallback(i,a,c){super.attributeChangedCallback&&super.attributeChangedCallback(i,a,c),this._storeUnsubscribe&&a!==c&&s(this)}disconnectedCallback(){this._storeUnsubscribe(),super.disconnectedCallback&&super.disconnectedCallback()}}},"connect"),Js=n(t=>{ur=t},"setStore");de();var co=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],...dt(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"),Qe=n((t={})=>{let e={};return Object.entries(t).forEach(([r,o])=>{Object.entries(o).forEach(([s,i])=>{let a={};i&&!Array.isArray(i)?a=i:a={frequency:s,prepaidShipments:null,regularPrice:i[0],subscriptionPrice:i[2],discountRate:i[1]},e[r]?e[r].push(a):e[r]=[a]})}),e},"getObjectStructuredProductPlans");k();O();var Ai=ce(vi());O();var Tl=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"),Ti=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var Io=n(t=>{let e=Ti(t);if(!e){let r=t.offer;r&&(e=Ti(r))}return e},"resolveProduct"),Ol=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),ko=n(t=>class extends t{get offer(){return Ol(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"),A=n(t=>class extends ko(t){get product(){return Io(this)}},"withProduct"),Or=n(t=>class extends t{get childOptions(){let e=[],r=null;return this.querySelectorAll("option").forEach(o=>{let s=Tl(o.value),i=o.innerText.trim();e.push({value:s,text:i}),!r&&o.selected&&(r=s)}),{options:e,isSelected:r}}},"withChildOptions");var Pr={};Ur(Pr,{autoshipByDefault:()=>Pl,eligibilityGroups:()=>Do,eligible:()=>Oi,hasPrepaidOptions:()=>Nl,hasUpcomingOrder:()=>Ci,hasUpsellGroup:()=>wi,inStock:()=>qo,optedout:()=>Rl,prepaidEligible:()=>wl,prepaidSubscribed:()=>Al,regularEligible:()=>kl,subscribed:()=>Cl,subscriptionEligible:()=>Pi,upcomingOrderContainsProduct:()=>Il,upsellEligible:()=>Ri});U();var qo=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),Oi=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),Pl=n((t,e)=>(t.autoshipByDefault||{})[(e.product||{}).id]||!1,"autoshipByDefault"),Pi=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&Oi(t,e)&&qo(t,e),"subscriptionEligible"),Do=n((t,e)=>(t.eligibilityGroups||{})[(e.product||{}).id]||null,"eligibilityGroups"),wi=n((t,e)=>{let r=Do(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),wl=n((t,e)=>{let r=Do(t,e);return(r==null?void 0:r.some(o=>o==="prepaid"))||!1},"prepaidEligible"),Cl=n((t,e)=>er(e.product)(t),"subscribed"),Rl=n((t,e)=>rr(e.product)(t),"optedout"),Al=n((t,e)=>ds(e.product)(t),"prepaidSubscribed"),Nl=n((t,e)=>nr(e.product.id)(t).length>0,"hasPrepaidOptions"),Ci=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),Il=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),Ri=n((t,e)=>{var r;return!((r=e.offer)==null?void 0:r.isCart)&&t.offerId&&t.offerId!=="0"&&t.auth&&qo(t,e)&&Ci(t)&&wi(t,e)},"upsellEligible"),kl=n((t,e)=>Pi(t,e)&&!Ri(t,e),"regularEligible");var ql=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),Fo=class extends A(v){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){if(!this.test)return d``;let e=ql(this.test);return e=e.replace(/(![a-zA-Z]+)/g,"($1)"),Ai.default.parse(e,o=>Pr[o]&&Pr[o](this.state,this))?d`
|
|
111
111
|
<slot></slot>
|
|
112
112
|
`:d``}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(Fo,"When");var Dl=n(t=>({state:t}),"mapStateToProps"),Ni=g(Dl)(Fo);O();k();O();U();de();var Ii={type:Object,converter:{toAttribute(t){return t==null?t:JSON.stringify(t)},fromAttribute(t){return t&&t.match(/[{[]/)?JSON.parse(t):{id:t}}}},be={type:String,attribute:"default-frequency",converter:{fromAttribute(t){return t&&Yr(t)?t:null}}},wr={type:Boolean,attribute:!0,reflect:!0},tt={type:Object,attribute:!1};O();U();var Fl=n(t=>class extends t{getOption(e,r=e){let o=Kr(e);if(this.hasAttribute(o)){let s=this.getAttribute(o);return s.toString().toLowerCase()==="true"?!0:s.toString().toLowerCase()==="false"?!1:s}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=Fl(v);var Y=class extends A(M){static get properties(){return{subscribed:wr,frequencyMatch:{type:Boolean,reflect:!0,attribute:"frequency-match"},productDefaultFrequency:{type:String},defaultFrequency:{type:String},frequencies:{type:Array}}}static get styles(){return E`
|
|
113
113
|
:host {
|