@ordergroove/offers 2.23.1 → 2.24.1-alpha-PR-566-18.13
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 +15 -0
- package/build.js +5 -0
- package/dist/bundle-report.html +221 -63
- package/dist/examples.js +385 -1897
- package/dist/examples.js.map +7 -1
- package/dist/offers.js +266 -214
- package/dist/offers.js.map +7 -1
- package/examples/index.html +3 -0
- package/examples/index.js +19 -6
- package/karma-functional.conf.js +12 -10
- package/karma.conf.js +20 -10
- package/package.json +10 -15
- package/src/__tests__/offers.spec.js +111 -0
- package/src/__tests__/test-mode.spec.js +16 -0
- package/src/components/FrequencyStatus.js +2 -2
- package/src/components/IncentiveText.js +1 -1
- package/src/components/Offer.js +21 -15
- package/src/components/OptinButton.js +2 -5
- package/src/components/OptinSelect.js +2 -2
- package/src/components/OptinToggle.js +1 -4
- package/src/components/OptoutButton.js +1 -4
- package/src/components/Price.js +54 -0
- package/src/components/SelectFrequency.js +4 -8
- package/src/components/UpsellButton.js +2 -5
- package/src/components/UpsellModal.js +6 -10
- package/src/components/__tests__/FrequencyStatus.spec.js +33 -38
- package/src/components/__tests__/IncentiveText.spec.js +1 -1
- package/src/components/__tests__/Modal.spec.js +1 -1
- package/src/components/__tests__/NextUpcomingOrder.spec.js +1 -1
- package/src/components/__tests__/OG.fspec.js +2 -2
- package/src/components/__tests__/Offer.spec.js +5 -7
- package/src/components/__tests__/OptinButton.spec.js +1 -1
- package/src/components/__tests__/OptinSelect.spec.js +1 -1
- package/src/components/__tests__/OptinStatus.spec.js +1 -1
- package/src/components/__tests__/Price.fspec.js +43 -0
- package/src/components/__tests__/Select.spec.js +1 -1
- package/src/components/__tests__/SelectFrequency.spec.js +17 -6
- package/src/components/__tests__/Text.spec.js +1 -1
- package/src/components/__tests__/Tooltip.spec.js +1 -1
- package/src/components/__tests__/UpsellButton.spec.js +4 -6
- package/src/components/__tests__/When.spec.js +1 -1
- package/src/core/__tests__/api.spec.js +10 -3
- package/src/core/__tests__/base.spec.js +8 -2
- package/src/core/__tests__/reducer.spec.js +1 -1
- package/src/core/actions.js +16 -10
- package/src/core/adapters.js +3 -3
- package/src/core/api.js +4 -1
- package/src/core/constants.js +1 -0
- package/src/core/localStorage.js +1 -1
- package/src/core/middleware.js +9 -7
- package/src/core/reducer.js +10 -0
- package/src/core/selectors.js +19 -33
- package/src/index.js +187 -153
- package/src/init-func-tests.js +1 -2
- package/src/init-test.js +3 -0
- package/src/test-mode.js +5 -3
- package/dist/index.html +0 -125
- package/dist/offers-preview-mode.bundle.js +0 -2
- package/dist/offers-preview-mode.bundle.js.map +0 -1
- package/dist/offers-test-mode.bundle.js +0 -100
- package/dist/offers-test-mode.bundle.js.map +0 -1
- package/src/_tests_/offers.spec.js +0 -18
- package/src/_tests_/test-mode.spec.js +0 -15
- package/webpack.config.js +0 -43
package/dist/offers.js
CHANGED
|
@@ -1,150 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Code distributed by Google as part of the polymer project is also
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* This code may only be used under the BSD style license found at
|
|
114
|
-
* http://polymer.github.io/LICENSE.txt
|
|
115
|
-
* The complete set of authors may be found at
|
|
116
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
117
|
-
* The complete set of contributors may be found at
|
|
118
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
119
|
-
* Code distributed by Google as part of the polymer project is also
|
|
120
|
-
* subject to an additional IP rights grant found at
|
|
121
|
-
* http://polymer.github.io/PATENTS.txt
|
|
122
|
-
*/"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const D=(t,...e)=>new S(t,e,"html",U),M=(t,e)=>`${t}--${e}`;let $=!0;void 0===window.ShadyCSS?$=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),$=!1);const B=t=>e=>{const r=M(e.type,t);let n=F.get(r);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},F.set(r,n));let o=n.stringsArray.get(e.strings);if(void 0!==o)return o;const s=e.strings.join(i);if(o=n.keyString.get(s),void 0===o){const r=e.getTemplateElement();$&&window.ShadyCSS.prepareTemplateDom(r,t),o=new c(e,r),n.keyString.set(s,o)}return n.stringsArray.set(e.strings,o),o},V=["html","svg"],z=new Set,H=(t,e,r)=>{z.add(t);const n=r?r.element:document.createElement("template"),o=e.querySelectorAll("style"),{length:i}=o;if(0===i)return void window.ShadyCSS.prepareTemplateStyles(n,t);const s=document.createElement("style");for(let t=0;t<i;t++){const e=o[t];e.parentNode.removeChild(e),s.textContent+=e.textContent}(t=>{V.forEach(e=>{const r=F.get(M(e,t));void 0!==r&&r.keyString.forEach(t=>{const{element:{content:e}}=t,r=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{r.add(t)}),f(t,r)})})})(t);const a=n.content;r?function(t,e,r=null){const{element:{content:n},parts:o}=t;if(null==r)return void n.appendChild(e);const i=document.createTreeWalker(n,133,null,!1);let s=g(o),a=0,c=-1;for(;i.nextNode();){for(c++,i.currentNode===r&&(a=h(e),r.parentNode.insertBefore(e,r));-1!==s&&o[s].index===c;){if(a>0){for(;-1!==s;)o[s].index+=a,s=g(o,s);return}s=g(o,s)}}}(r,s,a.firstChild):a.insertBefore(s,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)e.insertBefore(c.cloneNode(!0),e.firstChild);else if(r){a.insertBefore(s,a.firstChild);const t=new Set;t.add(s),f(r,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const J={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},G=(t,e)=>e!==t&&(e==e||t==t),Y={attribute:!0,type:String,converter:J,reflect:!1,hasChanged:G};class W extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,r)=>{const n=this._attributeNameForProperty(r,e);void 0!==n&&(this._attributeToPropertyMap.set(n,r),t.push(n))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=Y){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const r="symbol"==typeof t?Symbol():`__${t}`,n=this.getPropertyDescriptor(t,r,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,r){return{get(){return this[e]},set(n){const o=this[t];this[e]=n,this.requestUpdateInternal(t,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||Y}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const r of e)this.createProperty(r,t[r])}}static _attributeNameForProperty(t,e){const r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,r=G){return r(t,e)}static _propertyValueFromAttribute(t,e){const r=e.type,n=e.converter||J,o="function"==typeof n?n:n.fromAttribute;return o?o(t,r):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const r=e.type,n=e.converter;return(n&&n.toAttribute||J.toAttribute)(t,r)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,r){e!==r&&this._attributeToProperty(t,r)}_propertyToAttribute(t,e,r=Y){const n=this.constructor,o=n._attributeNameForProperty(t,r);if(void 0!==o){const t=n._propertyValueToAttribute(e,r);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(o):this.setAttribute(o,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const r=this.constructor,n=r._attributeToPropertyMap.get(t);if(void 0!==n){const t=r.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=r._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,r){let n=!0;if(void 0!==t){const o=this.constructor;r=r||o.getPropertyOptions(t),o._valueHasChanged(this[t],e,r.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==r.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,r))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}W.finalized=!0;const Z=Element.prototype;Z.msMatchesSelector||Z.webkitMatchesSelector;
|
|
123
|
-
/**
|
|
124
|
-
@license
|
|
125
|
-
Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
|
|
126
|
-
This code may only be used under the BSD style license found at
|
|
127
|
-
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
|
|
128
|
-
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
|
|
129
|
-
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
|
|
130
|
-
part of the polymer project is also subject to an additional IP rights grant
|
|
131
|
-
found at http://polymer.github.io/PATENTS.txt
|
|
132
|
-
*/
|
|
133
|
-
const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,K=Symbol();class X{constructor(t,e){if(e!==K)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(Q?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const tt=(t,...e)=>{const r=e.reduce((e,r,n)=>e+(t=>{if(t instanceof X)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(r)+t[n+1],t[0]);return new X(r,K)};r.d(e,"a",(function(){return rt})),r.d(e,"c",(function(){return D})),r.d(e,"b",(function(){return tt})),
|
|
134
|
-
/**
|
|
135
|
-
* @license
|
|
136
|
-
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
|
137
|
-
* This code may only be used under the BSD style license found at
|
|
138
|
-
* http://polymer.github.io/LICENSE.txt
|
|
139
|
-
* The complete set of authors may be found at
|
|
140
|
-
* http://polymer.github.io/AUTHORS.txt
|
|
141
|
-
* The complete set of contributors may be found at
|
|
142
|
-
* http://polymer.github.io/CONTRIBUTORS.txt
|
|
143
|
-
* Code distributed by Google as part of the polymer project is also
|
|
144
|
-
* subject to an additional IP rights grant found at
|
|
145
|
-
* http://polymer.github.io/PATENTS.txt
|
|
146
|
-
*/
|
|
147
|
-
(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const et={};class rt extends W{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,r)=>t.reduceRight((t,r)=>Array.isArray(r)?e(r,t):(t.add(r),t),r),r=e(t,new Set),n=[];r.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!Q){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new X(String(e),K)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Q?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==et&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return et}}rt.finalized=!0,rt.render=(t,e,r)=>{if(!r||"object"!=typeof r||!r.scopeName)throw new Error("The `scopeName` option is required.");const n=r.scopeName,i=L.has(e),s=$&&11===e.nodeType&&!!e.host,a=s&&!z.has(n),c=a?document.createDocumentFragment():e;if(((t,e,r)=>{let n=L.get(e);void 0===n&&(o(e,e.firstChild),L.set(e,n=new P(Object.assign({templateFactory:R},r))),n.appendInto(e)),n.setValue(t),n.commit()})(t,c,Object.assign({templateFactory:B(n)},r)),a){const t=L.get(c);L.delete(c);const r=t.value instanceof _?t.value.template:void 0;H(n,c,r),o(e,e.firstChild),e.appendChild(c),L.set(e,t)}!i&&s&&window.ShadyCSS.styleElement(e.host)}},function(t,e,r){"use strict";function n(t,e){return t===e}function o(t,e,r){if(null===e||null===r||e.length!==r.length)return!1;for(var n=e.length,o=0;o<n;o++)if(!t(e[o],r[o]))return!1;return!0}function i(t){var e=Array.isArray(t[0])?t[0]:t;if(!e.every((function(t){return"function"==typeof t}))){var r=e.map((function(t){return typeof t})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return e}var s=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return function(){for(var e=arguments.length,n=Array(e),o=0;o<e;o++)n[o]=arguments[o];var s=0,a=n.pop(),c=i(n),u=t.apply(void 0,[function(){return s++,a.apply(null,arguments)}].concat(r)),l=t((function(){for(var t=[],e=c.length,r=0;r<e;r++)t.push(c[r].apply(null,arguments));return u.apply(null,t)}));return l.resultFunc=a,l.dependencies=c,l.recomputations=function(){return s},l.resetRecomputations=function(){return s=0},l}}((function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n,r=null,i=null;return function(){return o(e,r,arguments)||(i=t.apply(null,arguments)),r=arguments,i}}));var a=r(7),c=r.n(a),u=r(5);r.d(e,"c",(function(){return l})),r.d(e,"j",(function(){return d})),r.d(e,"a",(function(){return f})),r.d(e,"e",(function(){return g})),r.d(e,"i",(function(){return y})),r.d(e,"f",(function(){return m})),r.d(e,"h",(function(){return b})),r.d(e,"g",(function(){return v})),r.d(e,"d",(function(){return _})),r.d(e,"b",(function(){return w})),r.d(e,"k",(function(){return O})),c.a.Cache=Map;const l=(t,e)=>{if(t===e)return!0;if("object"==typeof t&&"object"==typeof e&&t&&e&&t.id===e.id){if(!Array.isArray(t.components)||!Array.isArray(e.components))return!0;if(function(t,e){if(t===e)return!0;if(null===t||null===e)return!1;if(t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}((t.components||[]).sort(),(e.components||[]).sort()))return!0}return!1},d=t=>t.optedin||[],p=t=>t.optedout||[],f=t=>t.autoshipByDefault||{},h=t=>t.defaultFrequencies||{},g=c()(t=>s(d,p,f,(e,r,n)=>{const o=e.find(e=>l(t,e));return o||!r.find(e=>l(t,e))&&(!(!t||!n[t.id])&&{id:t.id})}),t=>JSON.stringify(t)),y=c()(t=>s(d,e=>{const r=e.find(e=>l(t,e));return r||!1}),t=>JSON.stringify(t)),m=c()(t=>s(p,e=>e.find(e=>l(t,e)))),b=c()(t=>s(g(t),t=>t&&t.frequency||null)),v=c()(t=>s(h,e=>e[t]&&Object(u.stringifyFrequency)(e[t])||null)),_=t=>t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),w=(t,e,r,n)=>({[r]:e&&e.hasAttribute&&e.hasAttribute(_(r))&&e[r]||e.offer&&typeof("undefined"!==e.offer[r])&&e.offer[r]||t.config&&t.config[r]||n}),O=t=>({templates:t.templates||[]})},function(t,e,r){"use strict";r.r(e),r.d(e,"optinProduct",(function(){return s})),r.d(e,"optoutProduct",(function(){return a})),r.d(e,"productHasChangedComponents",(function(){return c})),r.d(e,"productChangeFrequency",(function(){return u})),r.d(e,"concludeUpsell",(function(){return l})),r.d(e,"setMerchantId",(function(){return d})),r.d(e,"createSessionId",(function(){return p})),r.d(e,"requestAuth",(function(){return f})),r.d(e,"authorize",(function(){return h})),r.d(e,"unauthorized",(function(){return g})),r.d(e,"setAuthUrl",(function(){return y})),r.d(e,"fetchDone",(function(){return m})),r.d(e,"fetchAuth",(function(){return b})),r.d(e,"requestOrders",(function(){return v})),r.d(e,"receiveOrders",(function(){return _})),r.d(e,"receiveItems",(function(){return w})),r.d(e,"fetchOrders",(function(){return O})),r.d(e,"setEnvironment",(function(){return S})),r.d(e,"requestSessionId",(function(){return x})),r.d(e,"receiveOffer",(function(){return E})),r.d(e,"fetchResponseError",(function(){return T})),r.d(e,"requestOffer",(function(){return C})),r.d(e,"fetchOffer",(function(){return P})),r.d(e,"checkout",(function(){return k})),r.d(e,"requestCreateOneTime",(function(){return j})),r.d(e,"receiveCreateOneTime",(function(){return q})),r.d(e,"requestConvertOneTimeToSubscription",(function(){return A})),r.d(e,"receiveConvertOneTime",(function(){return N})),r.d(e,"createIu",(function(){return I})),r.d(e,"setLocale",(function(){return R})),r.d(e,"setConfig",(function(){return F})),r.d(e,"addTemplate",(function(){return L})),r.d(e,"setTemplates",(function(){return U})),r.d(e,"setFirstOrderPlaceDate",(function(){return D})),r.d(e,"setProductToSubscribe",(function(){return M}));var n=r(15),o=r(0),i=r(5);const s=(t,e)=>({type:o.k,payload:{product:t,frequency:e}}),a=t=>({type:o.l,payload:{product:t}}),c=(t,e)=>({type:o.n,payload:{newProduct:t,product:e}}),u=(t,e)=>({type:o.m,payload:{product:t,frequency:e}}),l=t=>({type:o.d,payload:{product:t}}),d=t=>({type:o.E,payload:t}),p=t=>({type:o.f,payload:`${t}.${Math.floor(999999*Math.random())}.${Math.round((new Date).getTime()/1e3)}`}),f=t=>({type:o.s,payload:t}),h=(t,e,r,n)=>({type:o.b,payload:{public_id:t,sig_field:e,ts:r,sig:n}}),g=t=>({type:o.J,payload:t}),y=t=>({type:o.x,payload:t}),m=t=>({type:o.o,payload:t}),b=(t=n.resolveAuth)=>function(e,r){if(window.og&&window.og.previewMode)return e(g({message:"Offers are running in preview mode"}));const{merchantId:n,authUrl:o}=r(),i=f(o);return e(i),t(o).then(({sig_field:t,ts:r,sig:o})=>e(h(n,t,r,o)),t=>e(g(t))).finally(()=>e(m(i)))},v=(t,e)=>({type:o.w,payload:{status:t,ordering:e}}),_=t=>({type:o.q,payload:t}),w=t=>({type:o.r,payload:t}),O=(t=1,e="place")=>function(r,n){const{environment:{legoUrl:o},auth:s}=n();if(!s)return r(g("No auth set."));const a=v(t,e);return r(a),i.api.fetchOrders(o,s,t,e).then(t=>{r(_(t));const e=(t.results[0]||{}).public_id;return e?i.api.fetchItems(o,s,e).then(t=>r(w(t))):null},t=>r(g(t))).finally(()=>r(m(a)))},S=t=>{switch(t){case"dev":return{type:o.z,payload:t};case"staging":return{type:o.B,payload:t};case"prod":return{type:o.A,payload:t};default:throw new Error(`${t} is not a supported environment`)}},x=()=>(t,e)=>{const{merchantId:r,sessionId:n}=e();return(!n||r&&!n.startsWith(r))&&t(p(r)),n},E=t=>({type:o.p,payload:t}),T=t=>({type:o.h,payload:t}),C=(t,e="pdp")=>({type:o.v,payload:{product:t,module:e}}),P=(t,e="pdp")=>function(r,n){const{merchantId:o,sessionId:s,environment:{apiUrl:a}}=n(),c=C(t,e);return r(c),i.api.fetchOffer(a,o,s,t,e).then(t=>r(E(t)),t=>r(T(t))).finally(()=>r(m(c)))},k=()=>({type:o.c}),j=(t,e,r,n)=>({type:o.u,payload:{product:t,order:e,quantity:r,offerId:n}}),q=t=>({type:o.g,payload:t}),A=(t,e)=>({type:o.t,payload:{item:t,frequency:e}}),N=(t,e)=>({type:o.e,payload:{response:t,product:e}}),I=(t,e,r,n=!1,o=null)=>function(s,a){const{auth:c,environment:{legoUrl:u},previewUpsellOffer:l,offerId:d}=a();if(!c)return s(g("No auth set."));const p=j(t,e,r,d);return s(p),(l?Promise.resolve({legoUrl:u,product:t,order:e,quantity:r,offer:d}):i.api.createOneTime(u,c,t.id,e,r,d)).then(e=>(s(q(e)),n?(s(A(e,o)),(l?Promise.resolve({item:e,frequency:o}):i.api.convertOneTimeToSubscription(u,c,e,o,d)).then(e=>s(N(e,t)),t=>s(T(t)))):e),t=>s(T(t))).finally(()=>s(m(p)))},R=t=>({type:o.D,payload:t}),F=t=>({type:o.y,payload:t}),L=(t,e,r)=>({type:o.a,payload:{selector:t,markup:e,config:r}}),U=t=>({type:o.I,payload:t}),D=(t,e)=>({type:o.C,payload:{product:t,firstOrderPlaceDate:e}}),M=(t,e)=>({type:o.H,payload:{product:t,productToSubscribe:e}})},function(t,e,r){"use strict";r.r(e),r.d(e,"resolveStore",(function(){return s})),r.d(e,"createRecalcProps",(function(){return a})),r.d(e,"connect",(function(){return c})),r.d(e,"setStore",(function(){return u})),r.d(e,"unsetStore",(function(){return l}));var n=r(12);let o=null;const i=t=>({dispatch:t}),s=t=>{if(!o)throw new Error("Missing redux store.");return o},a=(t,e)=>r=>{const{getState:n,dispatch:o}=s(r),i=t?t(n(),r):{},a=e(o,r);Object.assign(r,i,a)},c=(t,e=i)=>r=>{const i=a(t,"function"==typeof e?e:t=>Object(n.b)(e,t));return class extends r{get store(){return o}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=s(this).subscribe(()=>i(this)),i(this)}attributeChangedCallback(t,e,r){super.attributeChangedCallback&&super.attributeChangedCallback(t,e,r),this._storeUnsubscribe&&e!==r&&i(this)}disconnectedCallback(){this._storeUnsubscribe(),super.disconnectedCallback&&super.disconnectedCallback()}}},u=t=>{o=t},l=()=>{o=void 0};e.default=c},function(t,e,r){"use strict";r.r(e),r.d(e,"withFetchJson",(function(){return s})),r.d(e,"withHost",(function(){return a})),r.d(e,"withAuth",(function(){return c})),r.d(e,"withJsonBody",(function(){return u})),r.d(e,"toQuery",(function(){return l})),r.d(e,"toProductId",(function(){return d})),r.d(e,"fetchOffer",(function(){return p})),r.d(e,"fetchOrders",(function(){return f})),r.d(e,"fetchItems",(function(){return h})),r.d(e,"createOneTime",(function(){return g})),r.d(e,"parseFrequency",(function(){return y})),r.d(e,"isFrequencyValid",(function(){return m})),r.d(e,"compareFrequencies",(function(){return b})),r.d(e,"parseFrequenciesList",(function(){return v})),r.d(e,"stringifyFrequencies",(function(){return _})),r.d(e,"stringifyFrequency",(function(){return w})),r.d(e,"convertOneTimeToSubscription",(function(){return O})),r.d(e,"api",(function(){return S}));var n=r(7),o=r.n(n);const i=(...t)=>JSON.stringify(t),s=t=>(...e)=>fetch(...t(...e)).then(t=>t.json()),a=t=>(e,...r)=>{if(!e)throw Error("host required");const[n,o={}]=t(...r);return[`${e.replace(/\/+$/,"")}${n}`,o]},c=t=>(e,...r)=>{if(!e)throw Error("auth required");const[n,o={}]=t(...r);return[n,{...o,headers:{Authorization:JSON.stringify(e),...o.headers}}]},u=t=>(...e)=>{const[r,n={}]=t(...e);return[r,{method:"POST",...n,body:JSON.stringify(n.body),headers:{"Content-type":"application/json",...n.headers}}]},l=(t=[])=>(Array.isArray(t)?t:Object.entries(t)).map(([t,e])=>[t,encodeURIComponent(e)].join("=")).join("&"),d=t=>JSON.stringify([].concat(t).map(t=>"object"==typeof t?t.id:t).filter(t=>t)),p=o()(s(a((t,e,r,n="pdp")=>{if(!t)throw Error("merchantId required");if(!e)throw Error("sessionId required");if(!r)throw Error("product required");return[`/offer/${t}/${n}?${l([["session_id",e],["page_type",1],["p",d(r)],["module_view",JSON.stringify(["regular"])]])}`]})),i),f=o()(s(a(c((t=1,e="place")=>[`/orders/?${l([["status",t],["ordering",e]])}`]))),i),h=o()(s(a(c(t=>{if(!t)throw Error("orderId required");return[`/items/?order=${t}`]}))),i),g=s(a(c(u((t,e,r,n)=>{if(!t)throw Error("product required");if(!e)throw Error("order required");if(!r)throw Error("quantity required");if(r<=0)throw Error("quantity must be greater or equal than one");if(!n)throw Error("offer required");return["/items/iu/",{body:{product:t,order:e,quantity:r,offer:n}}]})))),y=t=>{if("object"==typeof t)return{...t};const[e,r]=(t||"").split(/_/).map(t=>parseInt(t,10));return e&&r&&{every:e,every_period:r}},m=t=>t.match(/^\d+_\d$/),b=(t,e)=>String.prototype.localeCompare.call(t&&t.split("_").reverse().join("_"),e&&e.split("_").reverse().join("_")),v=t=>[...new Set(t&&t.split(/\s+/))].filter(m).sort(b),_=t=>null==t?t:t.join(" "),w=t=>{if("object"==typeof t){const{every:e,period:r,every_period:n}=t;return`${e}_${r||n}`}return"string"==typeof t?t:""},O=s(a(c(u((t,e,r)=>{if(!t)throw Error("item required");if(!e)throw Error("frequency required");const n=y(e);if(!n)throw Error("invalid frequency");return["/subscriptions/create_from_item/",{body:{item:t.public_id,offer:r,...n}}]})))),S={fetchOffer:p,fetchOrders:f,fetchItems:h,createOneTime:g,convertOneTimeToSubscription:O};e.default=S},function(t,e,r){"use strict";r.d(e,"a",(function(){return o})),r.d(e,"c",(function(){return i})),r.d(e,"d",(function(){return s})),r.d(e,"b",(function(){return a}));r(1);const n=t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},o=t=>{let e=n(t);if(!e){const r=t.offer;r&&(e=n(r))}return e},i=t=>class extends t{get offer(){return(t=>{let e=t;for(;e;){if("OG-OFFER"===e.tagName)return e;e=11===e.nodeType?e.host:e.parentNode}})(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()}},s=t=>class extends(i(t)){get product(){return o(this)}},a=t=>class extends t{get childOptions(){return this._childOptions||{options:[]}}connectedCallback(){const t=[];let e=null;this.querySelectorAll("option").forEach(r=>{const n=(t=>{const e=String(t||"").trim().match(/(\d+)\s*([dwm])/);return e?`${e[1]}_${{d:1,w:2,m:3}[e[2]]}`:t})(r.value),o=r.innerText.trim();t.push({value:n,text:o}),!e&&r.selected&&(e=n)}),this._childOptions={options:t,isSelected:e},super.connectedCallback&&super.connectedCallback()}}},function(t,e,r){(function(e){var r=/^\[object .+?Constructor\]$/,n="object"==typeof e&&e&&e.Object===Object&&e,o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();var s,a=Array.prototype,c=Function.prototype,u=Object.prototype,l=i["__core-js_shared__"],d=(s=/[^.]+$/.exec(l&&l.keys&&l.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"",p=c.toString,f=u.hasOwnProperty,h=u.toString,g=RegExp("^"+p.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),y=a.splice,m=E(i,"Map"),b=E(Object,"create");function v(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function w(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function O(t,e){for(var r,n,o=t.length;o--;)if((r=t[o][0])===(n=e)||r!=r&&n!=n)return o;return-1}function S(t){return!(!C(t)||(e=t,d&&d in e))&&(function(t){var e=C(t)?h.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?g:r).test(function(t){if(null!=t){try{return p.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function x(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function E(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return S(r)?r:void 0}function T(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s),s};return r.cache=new(T.Cache||w),r}function C(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}v.prototype.clear=function(){this.__data__=b?b(null):{}},v.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},v.prototype.get=function(t){var e=this.__data__;if(b){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return f.call(e,t)?e[t]:void 0},v.prototype.has=function(t){var e=this.__data__;return b?void 0!==e[t]:f.call(e,t)},v.prototype.set=function(t,e){return this.__data__[t]=b&&void 0===e?"__lodash_hash_undefined__":e,this},_.prototype.clear=function(){this.__data__=[]},_.prototype.delete=function(t){var e=this.__data__,r=O(e,t);return!(r<0)&&(r==e.length-1?e.pop():y.call(e,r,1),!0)},_.prototype.get=function(t){var e=this.__data__,r=O(e,t);return r<0?void 0:e[r][1]},_.prototype.has=function(t){return O(this.__data__,t)>-1},_.prototype.set=function(t,e){var r=this.__data__,n=O(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},w.prototype.clear=function(){this.__data__={hash:new v,map:new(m||_),string:new v}},w.prototype.delete=function(t){return x(this,t).delete(t)},w.prototype.get=function(t){return x(this,t).get(t)},w.prototype.has=function(t){return x(this,t).has(t)},w.prototype.set=function(t,e){return x(this,t).set(t,e),this},T.Cache=w,t.exports=T}).call(this,r(11))},function(t,e,r){"use strict";r.d(e,"c",(function(){return o})),r.d(e,"b",(function(){return i})),r.d(e,"d",(function(){return s})),r.d(e,"a",(function(){return a}));var n=r(5);const o={type:Object,converter:{toAttribute:t=>null==t?t:JSON.stringify(t),fromAttribute:t=>t&&t.match(/[{[]/)?JSON.parse(t):{id:t}}},i={type:String,attribute:"default-frequency",converter:{fromAttribute:t=>t&&Object(n.isFrequencyValid)(t)?t:null}},s={type:Boolean,attribute:!0,reflect:!0},a={type:Object,attribute:!1}},function(t,e,r){"use strict";r.r(e),r.d(e,"OptinStatus",(function(){return u})),r.d(e,"mapStateToProps",(function(){return l})),r.d(e,"ConnectedOptinStatus",(function(){return d}));var n=r(1),o=r(2),i=r(4),s=r(8),a=r(6),c=r(10);class u extends(Object(a.d)(c.a)){static get properties(){return{subscribed:s.d,frequencyMatch:{type:Boolean,reflect:!0,attribute:"frequency-match"}}}static get styles(){return n.b`
|
|
1
|
+
(factory => {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define([], factory);
|
|
6
|
+
else {
|
|
7
|
+
window.og = window.og || {};
|
|
8
|
+
window.og['offers'] = factory();
|
|
9
|
+
}
|
|
10
|
+
})(()=>{
|
|
11
|
+
var lib=(()=>{var Zs=Object.create;var ke=Object.defineProperty;var Xs=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ri=Object.prototype.hasOwnProperty;var mo=t=>ke(t,"__esModule",{value:!0}),n=(t,e)=>ke(t,"name",{value:e,configurable:!0}),oi=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xt=(t,e)=>{mo(t);for(var r in e)ke(t,r,{get:e[r],enumerable:!0})},ni=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ei(e))!ri.call(t,o)&&o!=="default"&&ke(t,o,{get:()=>e[o],enumerable:!(r=Xs(e,o))||r.enumerable});return t},oe=t=>ni(mo(ke(t!=null?Zs(ti(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ne,se,ie,ot,Po,q,qe,nt,st,Ro,it,_e,Ao,at,ct,No,lt,ut,pt,ko,Io,dt,qo,ft,xe,Uo,ht,mt,Ue,Fe,gt,yt,ae,G,bt,_t,xt,ce=S(()=>{ne="OPTIN_PRODUCT",se="OPTOUT_PRODUCT",ie="PRODUCT_CHANGE_FREQUENCY",ot="SET_MERCHANT_ID",Po="REQUEST_OFFER",q="RECEIVE_OFFER",qe="PRODUCT_HAS_CHANGED",nt="CREATED_SESSION_ID",st="SET_AUTH_URL",Ro="REQUEST_AUTH",it="AUTHORIZE",_e="UNAUTHORIZED",Ao="REQUEST_ORDERS",at="RECEIVE_ORDERS",ct="RECEIVE_ORDER_ITEMS",No="FETCH_RESPONSE_ERROR",lt="SET_ENVIRONMENT_STAGING",ut="SET_ENVIRONMENT_DEV",pt="SET_ENVIRONMENT_PROD",ko="CONCLUDE_UPSELL",Io="REQUEST_CREATE_IU_ORDER",dt="CREATE_ONE_TIME",qo="REQUEST_CONVERT_ONE_TIME",ft="CONVERT_ONE_TIME",xe="CHECKOUT",Uo="RECEIVE_FETCH",ht="SET_LOCALE",mt="SET_CONFIG",Ue="SET_PREVIEW_STANDARD_OFFER",Fe="SET_PREVIEW_UPSELL_OFFER",gt="ADD_TEMPLATE",yt="SET_TEMPLATES",ae="LOCAL_STORAGE_CHANGE",G="LOCAL_STORAGE_CLEAR",bt="SET_FIRST_ORDER_PLACE_DATE",_t="SET_PRODUCT_TO_SUBSCRIBE",xt="RECEIVE_PRODUCT_PLANS"});var vt=re((Jc,Bo)=>{var xi="Expected a function",Fo="__lodash_hash_undefined__",Ei="[object Function]",Si="[object GeneratorFunction]",vi=/[\\^$.*+?()[\]{}|]/g,wi=/^\[object .+?Constructor\]$/,Ti=typeof window=="object"&&window&&window.Object===Object&&window,Oi=typeof self=="object"&&self&&self.Object===Object&&self,Do=Ti||Oi||Function("return this")();function Ci(t,e){return t==null?void 0:t[e]}n(Ci,"getValue");function Pi(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}n(Pi,"isHostObject");var Ri=Array.prototype,Ai=Function.prototype,Lo=Object.prototype,ar=Do["__core-js_shared__"],jo=function(){var t=/[^.]+$/.exec(ar&&ar.keys&&ar.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Mo=Ai.toString,cr=Lo.hasOwnProperty,Ni=Lo.toString,ki=RegExp("^"+Mo.call(cr).replace(vi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ii=Ri.splice,qi=Vo(Do,"Map"),De=Vo(Object,"create");function le(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}n(le,"Hash");function Ui(){this.__data__=De?De(null):{}}n(Ui,"hashClear");function Fi(t){return this.has(t)&&delete this.__data__[t]}n(Fi,"hashDelete");function Di(t){var e=this.__data__;if(De){var r=e[t];return r===Fo?void 0:r}return cr.call(e,t)?e[t]:void 0}n(Di,"hashGet");function Li(t){var e=this.__data__;return De?e[t]!==void 0:cr.call(e,t)}n(Li,"hashHas");function ji(t,e){var r=this.__data__;return r[t]=De&&e===void 0?Fo:e,this}n(ji,"hashSet");le.prototype.clear=Ui;le.prototype.delete=Fi;le.prototype.get=Di;le.prototype.has=Li;le.prototype.set=ji;function Se(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}n(Se,"ListCache");function Mi(){this.__data__=[]}n(Mi,"listCacheClear");function Vi(t){var e=this.__data__,r=Et(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ii.call(e,r,1),!0}n(Vi,"listCacheDelete");function $i(t){var e=this.__data__,r=Et(e,t);return r<0?void 0:e[r][1]}n($i,"listCacheGet");function Bi(t){return Et(this.__data__,t)>-1}n(Bi,"listCacheHas");function Hi(t,e){var r=this.__data__,o=Et(r,t);return o<0?r.push([t,e]):r[o][1]=e,this}n(Hi,"listCacheSet");Se.prototype.clear=Mi;Se.prototype.delete=Vi;Se.prototype.get=$i;Se.prototype.has=Bi;Se.prototype.set=Hi;function ue(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}n(ue,"MapCache");function zi(){this.__data__={hash:new le,map:new(qi||Se),string:new le}}n(zi,"mapCacheClear");function Gi(t){return St(this,t).delete(t)}n(Gi,"mapCacheDelete");function Wi(t){return St(this,t).get(t)}n(Wi,"mapCacheGet");function Yi(t){return St(this,t).has(t)}n(Yi,"mapCacheHas");function Qi(t,e){return St(this,t).set(t,e),this}n(Qi,"mapCacheSet");ue.prototype.clear=zi;ue.prototype.delete=Gi;ue.prototype.get=Wi;ue.prototype.has=Yi;ue.prototype.set=Qi;function Et(t,e){for(var r=t.length;r--;)if(ea(t[r][0],e))return r;return-1}n(Et,"assocIndexOf");function Ji(t){if(!$o(t)||Zi(t))return!1;var e=ta(t)||Pi(t)?ki:wi;return e.test(Xi(t))}n(Ji,"baseIsNative");function St(t,e){var r=t.__data__;return Ki(e)?r[typeof e=="string"?"string":"hash"]:r.map}n(St,"getMapData");function Vo(t,e){var r=Ci(t,e);return Ji(r)?r:void 0}n(Vo,"getNative");function Ki(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}n(Ki,"isKeyable");function Zi(t){return!!jo&&jo in t}n(Zi,"isMasked");function Xi(t){if(t!=null){try{return Mo.call(t)}catch{}try{return t+""}catch{}}return""}n(Xi,"toSource");function lr(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(xi);var r=n(function(){var o=arguments,s=e?e.apply(this,o):o[0],i=r.cache;if(i.has(s))return i.get(s);var a=t.apply(this,o);return r.cache=i.set(s,a),a},"memoized");return r.cache=new(lr.Cache||ue),r}n(lr,"memoize");lr.Cache=ue;function ea(t,e){return t===e||t!==t&&e!==e}n(ea,"eq");function ta(t){var e=$o(t)?Ni.call(t):"";return e==Ei||e==Si}n(ta,"isFunction");function $o(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}n($o,"isObject");Bo.exports=lr});var wt,ur,Le,je,Tt,Ho,zo,ra,oa,na,sa,ia,Me,pr,aa,Go,Ve,ca,W,Y=S(()=>{wt=oe(vt()),ur=n((...t)=>JSON.stringify(t),"memoizeKey"),Le=n(t=>(...e)=>fetch(...t(...e)).then(r=>r.json()),"withFetchJson"),je=n(t=>(e,...r)=>{if(!e)throw Error("host required");let[o,s={}]=t(...r);return[`${e.replace(/\/+$/,"")}${o}`,s]},"withHost"),Tt=n(t=>(e,...r)=>{if(!e)throw Error("auth required");let[o,s={}]=t(...r);return[o,{...s,headers:{Authorization:JSON.stringify(e),...s.headers}}]},"withAuth"),Ho=n(t=>(...e)=>{let[r,o={}]=t(...e);return[r,{method:"POST",...o,body:JSON.stringify(o.body),headers:{"Content-type":"application/json",...o.headers}}]},"withJsonBody"),zo=n((t=[])=>(Array.isArray(t)?t:Object.entries(t)).map(([e,r])=>[e,encodeURIComponent(r)].join("=")).join("&"),"toQuery"),ra=n(t=>JSON.stringify([].concat(t).map(e=>typeof e=="object"?e.id:e).filter(e=>e)),"toProductId"),oa=(0,wt.default)(Le(je((t,e,r,o="pdp")=>{if(!t)throw Error("merchantId required");if(!e)throw Error("sessionId required");if(!r)throw Error("product required");let s=zo([["session_id",e],["page_type",1],["p",ra(r)],["module_view",JSON.stringify(["regular"])]]);return[`/offer/${t}/${o}?${s}`]})),ur),na=(0,wt.default)(Le(je(Tt((t=1,e="place")=>[`/orders/?${zo([["status",t],["ordering",e]])}`]))),ur),sa=(0,wt.default)(Le(je(Tt(t=>{if(!t)throw Error("orderId required");return[`/items/?order=${t}`]}))),ur),ia=Le(je(Tt(Ho((t,e,r,o)=>{if(!t)throw Error("product required");if(!e)throw Error("order required");if(!r)throw Error("quantity required");if(r<=0)throw Error("quantity must be greater or equal than one");if(!o)throw Error("offer required");return["/items/iu/",{body:{product:t,order:e,quantity:r,offer:o}}]})))),Me=n(t=>{if(typeof t=="object")return{...t};let[e,r]=(t||"").split(/_/).map(o=>parseInt(o,10));return e&&r&&{every:e,every_period:r}},"parseFrequency"),pr=n(t=>t.match(/^\d+_\d$/),"isFrequencyValid"),aa=n((t,e)=>String.prototype.localeCompare.call(t&&t.split("_").reverse().join("_"),e&&e.split("_").reverse().join("_")),"compareFrequencies"),Go=n(t=>[...new Set(t&&t.split(/\s+/))].filter(pr).sort(aa),"parseFrequenciesList"),Ve=n(t=>{if(typeof t=="object"){let{every:e,period:r,every_period:o}=t;return`${e}_${r||o}`}return typeof t=="string"?t:""},"stringifyFrequency"),ca=Le(je(Tt(Ho((t,e,r)=>{if(!t)throw Error("item required");if(!e)throw Error("frequency required");let o=Me(e);if(!o)throw Error("invalid frequency");return["/subscriptions/create_from_item/",{body:{item:t.public_id,offer:r,...o}}]})))),W={fetchOffer:oa,fetchOrders:na,fetchItems:sa,createOneTime:ia,convertOneTimeToSubscription:ca}});var mr=re((Pt,Zo)=>{(function(t,e){typeof Pt=="object"&&typeof Zo!="undefined"?e(Pt):typeof define=="function"&&define.amd?define(["exports"],e):(t=t||self,e(t.throttleDebounce={}))})(Pt,function(t){"use strict";function e(o,s,i,a){var c,l=!1,d=0;function g(){c&&clearTimeout(c)}n(g,"clearExistingTimeout");function p(){g(),l=!0}n(p,"cancel"),typeof s!="boolean"&&(a=i,i=s,s=void 0);function m(){for(var E=arguments.length,y=new Array(E),f=0;f<E;f++)y[f]=arguments[f];var T=this,O=Date.now()-d;if(l)return;function b(){d=Date.now(),i.apply(T,y)}n(b,"exec");function P(){c=void 0}n(P,"clear"),a&&!c&&b(),g(),a===void 0&&O>o?b():s!==!0&&(c=setTimeout(a?P:b,a===void 0?o-O:o))}return n(m,"wrapper"),m.cancel=p,m}n(e,"throttle");function r(o,s,i){return i===void 0?e(o,s,!1):e(o,i,s!==!1)}n(r,"debounce"),t.debounce=r,t.throttle=e,Object.defineProperty(t,"__esModule",{value:!0})})});var Xo,Ua,Fa,Da,La,en,tn=S(()=>{Xo=/^og_auth=/,Ua=n((t=Xo)=>(document.cookie.split(/;\s*/).find(e=>e.match(t))||"").replace(Xo,""),"s"),Fa=n(t=>{if(typeof t=="object")return t;let e=(t||"").split("|");return e.length===3?{sig_field:e[0],ts:parseInt(e[1],10),sig:e[2]}:null},"i"),Da=n(t=>new Promise((e,r)=>{let o=document.createElement("iframe");o.style.setProperty("display","none","important"),document.body.appendChild(o),o.onload=e,o.onerror=r,o.src=t}),"p"),La=n(t=>(t.headers.get("content-type")||"").indexOf("application/json")!==-1,"c"),en=n((t,e=Ua,r=Da)=>Promise.resolve(e()||t&&typeof t=="string"&&fetch(t).then(o=>o.status>=200&&o.status<300?e()||(La(o)?o.json():Promise.resolve(r(t)).then(e)):null)).then(Fa).then(o=>o===null?Promise.reject(new Error("Unauthorized")):o),"l")});var Q,we,rn,Rt,on,nn,ja,Ma,gr,J,sn,At,an,Va,yr,br,Nt,_r,kt,Te,xr,$a,cn,ln,Ba,Ha,za,Ga,un,pn,dn,fn,hn,mn,gn,N=S(()=>{tn();ce();Y();Q=n((t,e)=>({type:ne,payload:{product:t,frequency:e}}),"optinProduct"),we=n(t=>({type:se,payload:{product:t}}),"optoutProduct"),rn=n((t,e)=>({type:qe,payload:{newProduct:t,product:e}}),"productHasChangedComponents"),Rt=n((t,e)=>({type:ie,payload:{product:t,frequency:e}}),"productChangeFrequency"),on=n(t=>({type:ko,payload:{product:t}}),"concludeUpsell"),nn=n(t=>({type:ot,payload:t}),"setMerchantId"),ja=n(t=>({type:nt,payload:`${t}.${Math.floor(Math.random()*999999)}.${Math.round(new Date().getTime()/1e3)}`}),"createSessionId"),Ma=n(t=>({type:Ro,payload:t}),"requestAuth"),gr=n((t,e,r,o)=>({type:it,payload:{public_id:t,sig_field:e,ts:r,sig:o}}),"authorize"),J=n(t=>({type:_e,payload:t}),"unauthorized"),sn=n(t=>({type:st,payload:t}),"setAuthUrl"),At=n(t=>({type:Uo,payload:t}),"fetchDone"),an=n((t=en)=>n(function(r,o){if(window.og&&window.og.previewMode)return r(J({message:"Offers are running in preview mode"}));let{merchantId:s,authUrl:i}=o(),a=Ma(i);return r(a),t(i).then(({sig_field:c,ts:l,sig:d})=>r(gr(s,c,l,d)),c=>r(J(c))).finally(()=>r(At(a)))},"fetchAuthThunk"),"fetchAuth"),Va=n((t,e)=>({type:Ao,payload:{status:t,ordering:e}}),"requestOrders"),yr=n(t=>({type:at,payload:t}),"receiveOrders"),br=n(t=>({type:ct,payload:t}),"receiveItems"),Nt=n((t=1,e="place")=>n(function(o,s){let{environment:{legoUrl:i},auth:a}=s();if(!a)return o(J("No auth set."));let c=Va(t,e);return o(c),W.fetchOrders(i,a,t,e).then(l=>{if(l.results){o(yr(l));let d=(l.results[0]||{}).public_id;if(d)return W.fetchItems(i,a,d).then(g=>o(br(g)))}return o(J(l.detail)),null},l=>o(J(l))).finally(()=>o(At(c)))},"fetchOrdersThunk"),"fetchOrders"),_r=n(t=>{switch(t){case"dev":return{type:ut,payload:t};case"staging":return{type:lt,payload:t};case"prod":return{type:pt,payload:t};default:throw new Error(`${t} is not a supported environment`)}},"setEnvironment"),kt=n(()=>(t,e)=>{let{merchantId:r,sessionId:o}=e();return(!o||r&&!o.startsWith(r))&&t(ja(r)),o},"requestSessionId"),Te=n(t=>({type:q,payload:t}),"receiveOffer"),xr=n(t=>({type:No,payload:t}),"fetchResponseError"),$a=n((t,e="pdp")=>({type:Po,payload:{product:t,module:e}}),"requestOffer"),cn=n((t,e="pdp")=>n(function(o,s){let{merchantId:i,sessionId:a,environment:{apiUrl:c}}=s(),l=$a(t,e);return o(l),W.fetchOffer(c,i,a,t,e).then(d=>o(Te(d)),d=>o(xr(d))).finally(()=>o(At(l)))},"fetchOfferThunk"),"fetchOffer"),ln=n(()=>({type:xe}),"checkout"),Ba=n((t,e,r,o)=>({type:Io,payload:{product:t,order:e,quantity:r,offerId:o}}),"requestCreateOneTime"),Ha=n(t=>({type:dt,payload:t}),"receiveCreateOneTime"),za=n((t,e)=>({type:qo,payload:{item:t,frequency:e}}),"requestConvertOneTimeToSubscription"),Ga=n((t,e)=>({type:ft,payload:{response:t,product:e}}),"receiveConvertOneTime"),un=n((t,e,r,o=!1,s=null)=>n(function(a,c){let{auth:l,environment:{legoUrl:d},previewUpsellOffer:g,offerId:p}=c();if(!l)return a(J("No auth set."));let m=Ba(t,e,r,p);return a(m),(g?Promise.resolve({legoUrl:d,product:t,order:e,quantity:r,offer:p}):W.createOneTime(d,l,t.id,e,r,p)).then(E=>(a(Ha(E)),o?(a(za(E,s)),(g?Promise.resolve({item:E,frequency:s}):W.convertOneTimeToSubscription(d,l,E,s,p)).then(y=>a(Ga(y,t)),y=>a(xr(y)))):E),E=>a(xr(E))).finally(()=>a(At(m)))},"createIuThunk"),"createIu"),pn=n(t=>({type:ht,payload:t}),"setLocale"),dn=n(t=>({type:mt,payload:t}),"setConfig"),fn=n((t,e,r)=>({type:gt,payload:{selector:t,markup:e,config:r}}),"addTemplate"),hn=n(t=>({type:yt,payload:t}),"setTemplates"),mn=n((t,e)=>({type:bt,payload:{product:t,firstOrderPlaceDate:e}}),"setFirstOrderPlaceDate"),gn=n((t,e)=>({type:_t,payload:{product:t,productToSubscribe:e}}),"setProductToSubscribe")});var vr,de,fe=S(()=>{vr=typeof window!="undefined"&&window.customElements!=null&&window.customElements.polyfillWrapFlushCallback!==void 0,de=n((t,e,r=null)=>{for(;e!==r;){let o=e.nextSibling;t.removeChild(e),e=o}},"removeNodes")});var U,wr,Cn,Oe,he,Pn,Be,M,It,K=S(()=>{U=`{{lit-${String(Math.random()).slice(2)}}}`,wr=`<!--${U}-->`,Cn=new RegExp(`${U}|${wr}`),Oe="$lit$",he=class{constructor(e,r){this.parts=[],this.element=r;let o=[],s=[],i=document.createTreeWalker(r.content,133,null,!1),a=0,c=-1,l=0,{strings:d,values:{length:g}}=e;for(;l<g;){let p=i.nextNode();if(p===null){i.currentNode=s.pop();continue}if(c++,p.nodeType===1){if(p.hasAttributes()){let m=p.attributes,{length:E}=m,y=0;for(let f=0;f<E;f++)Pn(m[f].name,Oe)&&y++;for(;y-- >0;){let f=d[l],T=It.exec(f)[2],O=T.toLowerCase()+Oe,b=p.getAttribute(O);p.removeAttribute(O);let P=b.split(Cn);this.parts.push({type:"attribute",index:c,name:T,strings:P}),l+=P.length-1}}p.tagName==="TEMPLATE"&&(s.push(p),i.currentNode=p.content)}else if(p.nodeType===3){let m=p.data;if(m.indexOf(U)>=0){let E=p.parentNode,y=m.split(Cn),f=y.length-1;for(let T=0;T<f;T++){let O,b=y[T];if(b==="")O=M();else{let P=It.exec(b);P!==null&&Pn(P[2],Oe)&&(b=b.slice(0,P.index)+P[1]+P[2].slice(0,-Oe.length)+P[3]),O=document.createTextNode(b)}E.insertBefore(O,p),this.parts.push({type:"node",index:++c})}y[f]===""?(E.insertBefore(M(),p),o.push(p)):p.data=y[f],l+=f}}else if(p.nodeType===8)if(p.data===U){let m=p.parentNode;(p.previousSibling===null||c===a)&&(c++,m.insertBefore(M(),p)),a=c,this.parts.push({type:"node",index:c}),p.nextSibling===null?p.data="":(o.push(p),c--),l++}else{let m=-1;for(;(m=p.data.indexOf(U,m+1))!==-1;)this.parts.push({type:"node",index:-1}),l++}}for(let p of o)p.parentNode.removeChild(p)}};n(he,"Template");Pn=n((t,e)=>{let r=t.length-e.length;return r>=0&&t.slice(r)===e},"endsWith"),Be=n(t=>t.index!==-1,"isTemplatePartActive"),M=n(()=>document.createComment(""),"createMarker"),It=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/});function Or(t,e){let{element:{content:r},parts:o}=t,s=document.createTreeWalker(r,Tr,null,!1),i=He(o),a=o[i],c=-1,l=0,d=[],g=null;for(;s.nextNode();){c++;let p=s.currentNode;for(p.previousSibling===g&&(g=null),e.has(p)&&(d.push(p),g===null&&(g=p)),g!==null&&l++;a!==void 0&&a.index===c;)a.index=g!==null?-1:a.index-l,i=He(o,i),a=o[i]}d.forEach(p=>p.parentNode.removeChild(p))}function Rn(t,e,r=null){let{element:{content:o},parts:s}=t;if(r==null){o.appendChild(e);return}let i=document.createTreeWalker(o,Tr,null,!1),a=He(s),c=0,l=-1;for(;i.nextNode();)for(l++,i.currentNode===r&&(c=Ja(e),r.parentNode.insertBefore(e,r));a!==-1&&s[a].index===l;){if(c>0){for(;a!==-1;)s[a].index+=c,a=He(s,a);return}a=He(s,a)}}var Tr,Ja,He,An=S(()=>{K();Tr=133;n(Or,"removeNodesFromTemplate");Ja=n(t=>{let e=t.nodeType===11?0:1,r=document.createTreeWalker(t,Tr,null,!1);for(;r.nextNode();)e++;return e},"countNodes"),He=n((t,e=-1)=>{for(let r=e+1;r<t.length;r++){let o=t[r];if(Be(o))return r}return-1},"nextActiveIndexInTemplateParts");n(Rn,"insertNodeIntoTemplate")});var Ka,me,Cr=S(()=>{Ka=new WeakMap,me=n(t=>typeof t=="function"&&Ka.has(t),"isDirective")});var k,qt,Pr=S(()=>{k={},qt={}});var Z,Ut=S(()=>{fe();K();Z=class{constructor(e,r,o){this.__parts=[],this.template=e,this.processor=r,this.options=o}update(e){let r=0;for(let o of this.__parts)o!==void 0&&o.setValue(e[r]),r++;for(let o of this.__parts)o!==void 0&&o.commit()}_clone(){let e=vr?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),r=[],o=this.template.parts,s=document.createTreeWalker(e,133,null,!1),i=0,a=0,c,l=s.nextNode();for(;i<o.length;){if(c=o[i],!Be(c)){this.__parts.push(void 0),i++;continue}for(;a<c.index;)a++,l.nodeName==="TEMPLATE"&&(r.push(l),s.currentNode=l.content),(l=s.nextNode())===null&&(s.currentNode=r.pop(),l=s.nextNode());if(c.type==="node"){let d=this.processor.handleTextExpression(this.options);d.insertAfterNode(l.previousSibling),this.__parts.push(d)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,c.name,c.strings,this.options));i++}return vr&&(document.adoptNode(e),customElements.upgrade(e)),e}};n(Z,"TemplateInstance")});var Nn,Xa,B,Ft=S(()=>{fe();K();Nn=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),Xa=` ${U} `,B=class{constructor(e,r,o,s){this.strings=e,this.values=r,this.type=o,this.processor=s}getHTML(){let e=this.strings.length-1,r="",o=!1;for(let s=0;s<e;s++){let i=this.strings[s],a=i.lastIndexOf("<!--");o=(a>-1||o)&&i.indexOf("-->",a+1)===-1;let c=It.exec(i);c===null?r+=i+(o?Xa:wr):r+=i.substr(0,c.index)+c[1]+c[2]+Oe+c[3]+U}return r+=this.strings[e],r}getTemplateElement(){let e=document.createElement("template"),r=this.getHTML();return Nn!==void 0&&(r=Nn.createHTML(r)),e.innerHTML=r,e}};n(B,"TemplateResult")});var Dt,Lt,Ce,ze,H,Ge,We,jt,kn,Ye,ec,Mt=S(()=>{Cr();fe();Pr();Ut();Ft();K();Dt=n(t=>t===null||!(typeof t=="object"||typeof t=="function"),"isPrimitive"),Lt=n(t=>Array.isArray(t)||!!(t&&t[Symbol.iterator]),"isIterable"),Ce=class{constructor(e,r,o){this.dirty=!0,this.element=e,this.name=r,this.strings=o,this.parts=[];for(let s=0;s<o.length-1;s++)this.parts[s]=this._createPart()}_createPart(){return new ze(this)}_getValue(){let e=this.strings,r=e.length-1,o=this.parts;if(r===1&&e[0]===""&&e[1]===""){let i=o[0].value;if(typeof i=="symbol")return String(i);if(typeof i=="string"||!Lt(i))return i}let s="";for(let i=0;i<r;i++){s+=e[i];let a=o[i];if(a!==void 0){let c=a.value;if(Dt(c)||!Lt(c))s+=typeof c=="string"?c:String(c);else for(let l of c)s+=typeof l=="string"?l:String(l)}}return s+=e[r],s}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}};n(Ce,"AttributeCommitter");ze=class{constructor(e){this.value=void 0,this.committer=e}setValue(e){e!==k&&(!Dt(e)||e!==this.value)&&(this.value=e,me(e)||(this.committer.dirty=!0))}commit(){for(;me(this.value);){let e=this.value;this.value=k,e(this)}this.value!==k&&this.committer.commit()}};n(ze,"AttributePart");H=class{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(M()),this.endNode=e.appendChild(M())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=M()),e.__insert(this.endNode=M())}insertAfterPart(e){e.__insert(this.startNode=M()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(this.startNode.parentNode===null)return;for(;me(this.__pendingValue);){let r=this.__pendingValue;this.__pendingValue=k,r(this)}let e=this.__pendingValue;e!==k&&(Dt(e)?e!==this.value&&this.__commitText(e):e instanceof B?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):Lt(e)?this.__commitIterable(e):e===qt?(this.value=qt,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){let r=this.startNode.nextSibling;e=e??"";let o=typeof e=="string"?e:String(e);r===this.endNode.previousSibling&&r.nodeType===3?r.data=o:this.__commitNode(document.createTextNode(o)),this.value=e}__commitTemplateResult(e){let r=this.options.templateFactory(e);if(this.value instanceof Z&&this.value.template===r)this.value.update(e.values);else{let o=new Z(r,e.processor,this.options),s=o._clone();o.update(e.values),this.__commitNode(s),this.value=o}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());let r=this.value,o=0,s;for(let i of e)s=r[o],s===void 0&&(s=new H(this.options),r.push(s),o===0?s.appendIntoPart(this):s.insertAfterPart(r[o-1])),s.setValue(i),s.commit(),o++;o<r.length&&(r.length=o,this.clear(s&&s.endNode))}clear(e=this.startNode){de(this.startNode.parentNode,e.nextSibling,this.endNode)}};n(H,"NodePart");Ge=class{constructor(e,r,o){if(this.value=void 0,this.__pendingValue=void 0,o.length!==2||o[0]!==""||o[1]!=="")throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=r,this.strings=o}setValue(e){this.__pendingValue=e}commit(){for(;me(this.__pendingValue);){let r=this.__pendingValue;this.__pendingValue=k,r(this)}if(this.__pendingValue===k)return;let e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=k}};n(Ge,"BooleanAttributePart");We=class extends Ce{constructor(e,r,o){super(e,r,o);this.single=o.length===2&&o[0]===""&&o[1]===""}_createPart(){return new jt(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}};n(We,"PropertyCommitter");jt=class extends ze{};n(jt,"PropertyPart");kn=!1;(()=>{try{let t={get capture(){return kn=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch{}})();Ye=class{constructor(e,r,o){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=r,this.eventContext=o,this.__boundHandleEvent=s=>this.handleEvent(s)}setValue(e){this.__pendingValue=e}commit(){for(;me(this.__pendingValue);){let i=this.__pendingValue;this.__pendingValue=k,i(this)}if(this.__pendingValue===k)return;let e=this.__pendingValue,r=this.value,o=e==null||r!=null&&(e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive),s=e!=null&&(r==null||o);o&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=ec(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=k}handleEvent(e){typeof this.value=="function"?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}};n(Ye,"EventPart");ec=n(t=>t&&(kn?{capture:t.capture,passive:t.passive,once:t.once}:t.capture),"getOptions")});function Rr(t){let e=ge.get(t.type);e===void 0&&(e={stringsArray:new WeakMap,keyString:new Map},ge.set(t.type,e));let r=e.stringsArray.get(t.strings);if(r!==void 0)return r;let o=t.strings.join(U);return r=e.keyString.get(o),r===void 0&&(r=new he(t,t.getTemplateElement()),e.keyString.set(o,r)),e.stringsArray.set(t.strings,r),r}var ge,Vt=S(()=>{K();n(Rr,"templateFactory");ge=new Map});var X,Ar,Nr=S(()=>{fe();Mt();Vt();X=new WeakMap,Ar=n((t,e,r)=>{let o=X.get(e);o===void 0&&(de(e,e.firstChild),X.set(e,o=new H(Object.assign({templateFactory:Rr},r))),o.appendInto(e)),o.setValue(t),o.commit()},"render")});var $t,kr,Ir=S(()=>{Mt();$t=class{handleAttributeExpressions(e,r,o,s){let i=r[0];return i==="."?new We(e,r.slice(1),o).parts:i==="@"?[new Ye(e,r.slice(1),s.eventContext)]:i==="?"?[new Ge(e,r.slice(1),o)]:new Ce(e,r,o).parts}handleTextExpression(e){return new H(e)}};n($t,"DefaultTemplateProcessor");kr=new $t});var u,qr=S(()=>{Ir();Ft();Ir();Cr();fe();Pr();Mt();Nr();Vt();Ut();Ft();K();typeof window!="undefined"&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");u=n((t,...e)=>new B(t,e,"html",kr),"html")});var qn,Bt,rc,oc,nc,Un,sc,Fn,Dn=S(()=>{fe();An();Nr();Vt();Ut();K();qr();qn=n((t,e)=>`${t}--${e}`,"getTemplateCacheKey"),Bt=!0;typeof window.ShadyCSS=="undefined"?Bt=!1:typeof window.ShadyCSS.prepareTemplateDom=="undefined"&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),Bt=!1);rc=n(t=>e=>{let r=qn(e.type,t),o=ge.get(r);o===void 0&&(o={stringsArray:new WeakMap,keyString:new Map},ge.set(r,o));let s=o.stringsArray.get(e.strings);if(s!==void 0)return s;let i=e.strings.join(U);if(s=o.keyString.get(i),s===void 0){let a=e.getTemplateElement();Bt&&window.ShadyCSS.prepareTemplateDom(a,t),s=new he(e,a),o.keyString.set(i,s)}return o.stringsArray.set(e.strings,s),s},"shadyTemplateFactory"),oc=["html","svg"],nc=n(t=>{oc.forEach(e=>{let r=ge.get(qn(e,t));r!==void 0&&r.keyString.forEach(o=>{let{element:{content:s}}=o,i=new Set;Array.from(s.querySelectorAll("style")).forEach(a=>{i.add(a)}),Or(o,i)})})},"removeStylesFromLitTemplates"),Un=new Set,sc=n((t,e,r)=>{Un.add(t);let o=r?r.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:i}=s;if(i===0){window.ShadyCSS.prepareTemplateStyles(o,t);return}let a=document.createElement("style");for(let d=0;d<i;d++){let g=s[d];g.parentNode.removeChild(g),a.textContent+=g.textContent}nc(t);let c=o.content;r?Rn(r,a,c.firstChild):c.insertBefore(a,c.firstChild),window.ShadyCSS.prepareTemplateStyles(o,t);let l=c.querySelector("style");if(window.ShadyCSS.nativeShadow&&l!==null)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(r){c.insertBefore(a,c.firstChild);let d=new Set;d.add(a),Or(r,d)}},"prepareTemplateStyles"),Fn=n((t,e,r)=>{if(!r||typeof r!="object"||!r.scopeName)throw new Error("The `scopeName` option is required.");let o=r.scopeName,s=X.has(e),i=Bt&&e.nodeType===11&&!!e.host,a=i&&!Un.has(o),c=a?document.createDocumentFragment():e;if(Ar(t,c,Object.assign({templateFactory:rc(o)},r)),a){let l=X.get(c);X.delete(c);let d=l.value instanceof Z?l.value.template:void 0;sc(o,c,d),de(e,e.firstChild),e.appendChild(c),X.set(e,l)}!s&&i&&window.ShadyCSS.styleElement(e.host)},"render")});var Ln,Ur,jn,Fr,Dr,Lr,jr,Mr,Vr,Qe,$r=S(()=>{window.JSCompiler_renameProperty=(t,e)=>t;Ur={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return t!==null;case Number:return t===null?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},jn=n((t,e)=>e!==t&&(e===e||t===t),"notEqual"),Fr={attribute:!0,type:String,converter:Ur,reflect:!1,hasChanged:jn},Dr=1,Lr=1<<2,jr=1<<3,Mr=1<<4,Vr="finalized",Qe=class extends HTMLElement{constructor(){super();this.initialize()}static get observedAttributes(){this.finalize();let e=[];return this._classProperties.forEach((r,o)=>{let s=this._attributeNameForProperty(o,r);s!==void 0&&(this._attributeToPropertyMap.set(s,o),e.push(s))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;let e=Object.getPrototypeOf(this)._classProperties;e!==void 0&&e.forEach((r,o)=>this._classProperties.set(o,r))}}static createProperty(e,r=Fr){if(this._ensureClassProperties(),this._classProperties.set(e,r),r.noAccessor||this.prototype.hasOwnProperty(e))return;let o=typeof e=="symbol"?Symbol():`__${e}`,s=this.getPropertyDescriptor(e,o,r);s!==void 0&&Object.defineProperty(this.prototype,e,s)}static getPropertyDescriptor(e,r,o){return{get(){return this[r]},set(s){let i=this[e];this[r]=s,this.requestUpdateInternal(e,i,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||Fr}static finalize(){let e=Object.getPrototypeOf(this);if(e.hasOwnProperty(Vr)||e.finalize(),this[Vr]=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){let r=this.properties,o=[...Object.getOwnPropertyNames(r),...typeof Object.getOwnPropertySymbols=="function"?Object.getOwnPropertySymbols(r):[]];for(let s of o)this.createProperty(s,r[s])}}static _attributeNameForProperty(e,r){let o=r.attribute;return o===!1?void 0:typeof o=="string"?o:typeof e=="string"?e.toLowerCase():void 0}static _valueHasChanged(e,r,o=jn){return o(e,r)}static _propertyValueFromAttribute(e,r){let o=r.type,s=r.converter||Ur,i=typeof s=="function"?s:s.fromAttribute;return i?i(e,o):e}static _propertyValueToAttribute(e,r){if(r.reflect===void 0)return;let o=r.type,s=r.converter;return(s&&s.toAttribute||Ur.toAttribute)(e,o)}initialize(){this._updateState=0,this._updatePromise=new Promise(e=>this._enableUpdatingResolver=e),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,r)=>{if(this.hasOwnProperty(r)){let o=this[r];delete this[r],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(r,o)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,r)=>this[r]=e),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){this._enableUpdatingResolver!==void 0&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,r,o){r!==o&&this._attributeToProperty(e,o)}_propertyToAttribute(e,r,o=Fr){let s=this.constructor,i=s._attributeNameForProperty(e,o);if(i!==void 0){let a=s._propertyValueToAttribute(r,o);if(a===void 0)return;this._updateState=this._updateState|jr,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._updateState=this._updateState&~jr}}_attributeToProperty(e,r){if(this._updateState&jr)return;let o=this.constructor,s=o._attributeToPropertyMap.get(e);if(s!==void 0){let i=o.getPropertyOptions(s);this._updateState=this._updateState|Mr,this[s]=o._propertyValueFromAttribute(r,i),this._updateState=this._updateState&~Mr}}requestUpdateInternal(e,r,o){let s=!0;if(e!==void 0){let i=this.constructor;o=o||i.getPropertyOptions(e),i._valueHasChanged(this[e],r,o.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,r),o.reflect===!0&&!(this._updateState&Mr)&&(this._reflectingProperties===void 0&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,o))):s=!1}!this._hasRequestedUpdate&&s&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,r){return this.requestUpdateInternal(e,r),this.updateComplete}async _enqueueUpdate(){this._updateState=this._updateState|Lr;try{await this._updatePromise}catch{}let e=this.performUpdate();return e!=null&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return this._updateState&Lr}get hasUpdated(){return this._updateState&Dr}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let e=!1,r=this._changedProperties;try{e=this.shouldUpdate(r),e?this.update(r):this._markUpdated()}catch(o){throw e=!1,this._markUpdated(),o}e&&(this._updateState&Dr||(this._updateState=this._updateState|Dr,this.firstUpdated(r)),this.updated(r))}_markUpdated(){this._changedProperties=new Map,this._updateState=this._updateState&~Lr}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){this._reflectingProperties!==void 0&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((r,o)=>this._propertyToAttribute(o,this[o],r)),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}};n(Qe,"UpdatingElement");Ln=Vr;Qe[Ln]=!0});var Mn,wu,Vn=S(()=>{Mn=Element.prototype,wu=Mn.msMatchesSelector||Mn.webkitMatchesSelector});var Ht,Br,Je,$n,ic,w,Hr=S(()=>{Ht=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Br=Symbol(),Je=class{constructor(e,r){if(r!==Br)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return this._styleSheet===void 0&&(Ht?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}};n(Je,"CSSResult");$n=n(t=>new Je(String(t),Br),"unsafeCSS"),ic=n(t=>{if(t instanceof Je)return t.cssText;if(typeof t=="number")return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but
|
|
12
|
+
take care to ensure page security.`)},"textFromCSSResult"),w=n((t,...e)=>{let r=e.reduce((o,s,i)=>o+ic(s)+t[i+1],t[0]);return new Je(r,Br)},"css")});var Bn,x,v=S(()=>{Dn();$r();$r();Vn();qr();Hr();Hr();(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");Bn={},x=class extends Qe{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;let e=this.getStyles();if(Array.isArray(e)){let r=n((i,a)=>i.reduceRight((c,l)=>Array.isArray(l)?r(l,c):(c.add(l),c),a),"addStyles"),o=r(e,new Set),s=[];o.forEach(i=>s.unshift(i)),this._styles=s}else this._styles=e===void 0?[]:[e];this._styles=this._styles.map(r=>{if(r instanceof CSSStyleSheet&&!Ht){let o=Array.prototype.slice.call(r.cssRules).reduce((s,i)=>s+i.cssText,"");return $n(o)}return r})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){let e=this.constructor._styles;e.length!==0&&(window.ShadyCSS!==void 0&&!window.ShadyCSS.nativeShadow?window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(r=>r.cssText),this.localName):Ht?this.renderRoot.adoptedStyleSheets=e.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet):this._needsShimAdoptedStyleSheets=!0)}connectedCallback(){super.connectedCallback(),this.hasUpdated&&window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this)}update(e){let r=this.render();super.update(e),r!==Bn&&this.constructor.render(r,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(o=>{let s=document.createElement("style");s.textContent=o.cssText,this.renderRoot.appendChild(s)}))}render(){return Bn}};n(x,"LitElement");x.finalized=!0;x.render=Fn});var zt=re((Uu,Hn)=>{var ac={PAR_OPEN:"(".charCodeAt(0),PAR_CLOSE:")".charCodeAt(0),OP_NOT:"!".charCodeAt(0),BINARY_AND:"&".charCodeAt(0),BINARY_OR:"|".charCodeAt(0),LITERAL:"LITERAL",END:"END",LEAF:"LEAF",ATOMIC:"ATOMIC"};Hn.exports=ac});var Gn=re((Fu,zn)=>{var ye=zt(),cc=n(t=>{let e="",r=[];for(let o of t){let s=o.charCodeAt(0);switch(s){case ye.PAR_OPEN:case ye.PAR_CLOSE:case ye.OP_NOT:case ye.BINARY_AND:case ye.BINARY_OR:e&&(r.push({type:ye.LITERAL,value:e}),e=""),r.push({type:s,value:o});break;default:e+=o}}return e&&r.push({type:ye.LITERAL,value:e}),r},"Tokenizer");zn.exports=cc});var Yn=re((Du,Wn)=>{var ee=zt(),lc=n(t=>{let e=[],r=[];return t.forEach(s=>{switch(s.type){case ee.LITERAL:e.unshift(s);break;case ee.BINARY_AND:case ee.BINARY_OR:case ee.OP_NOT:case ee.PAR_OPEN:r.push(s);break;case ee.PAR_CLOSE:for(;r.length&&r[r.length-1].type!==ee.PAR_OPEN;)e.unshift(r.pop());r.pop(),r.length&&r[r.length-1].type===ee.OP_NOT&&e.unshift(r.pop());break;default:break}}),r.length&&[...r.reverse(),...e]||e},"PolishNotation"),uc=n(function*(t){for(let e=0;e<t.length-1;e++)yield t[e];return t[t.length-1]},"PolishGenerator");Wn.exports={PolishNotation:lc,PolishGenerator:uc}});var Jn=re((Lu,Qn)=>{var I=zt(),D=class{constructor(e,r,o,s){this.op=e,this.left=r,this.right=o,this.literal=s}isLeaf(){return this.op===I.LEAF}isAtomic(){return this.isLeaf()||this.op===I.OP_NOT&&this.left.isLeaf()}getLiteralValue(){return this.literal}static CreateAnd(e,r){return new D(I.BINARY_AND,e,r)}static CreateNot(e){return new D(I.OP_NOT,e)}static CreateOr(e,r){return new D(I.BINARY_OR,e,r)}static CreateLiteral(e){return new D(I.LEAF,null,null,e)}};n(D,"ExpNode");var Pe=n(t=>{let e=t.next().value;switch(e.type){case I.LITERAL:return D.CreateLiteral(e.value);case I.OP_NOT:return D.CreateNot(Pe(t));case I.BINARY_AND:{let r=Pe(t),o=Pe(t);return D.CreateAnd(r,o)}case I.BINARY_OR:{let r=Pe(t),o=Pe(t);return D.CreateOr(r,o)}}return null},"make"),Re=n((t,e)=>{if(t.isLeaf())return e(t.getLiteralValue());if(t.op===I.OP_NOT)return!Re(t.left,e);if(t.op===I.BINARY_OR)return Re(t.left,e)||Re(t.right,e);if(t.op===I.BINARY_AND)return Re(t.left,e)&&Re(t.right,e)},"nodeEvaluator");Qn.exports={make:Pe,nodeEvaluator:Re}});var es=re((ju,Xn)=>{var pc=Gn(),Kn=Yn(),Zn=Jn(),dc=n((t,e)=>{let r=pc(t),o=Kn.PolishNotation(r),s=Kn.PolishGenerator(o),i=Zn.make(s);return Zn.nodeEvaluator(i,e)},"parse");Xn.exports={parse:dc}});var Ns={};Xt(Ns,{TestWizard:()=>Zt,default:()=>Ic});var Zt,Ic,ks=S(()=>{v();N();Zt=class extends x{static get styles(){return w`
|
|
13
|
+
:host {
|
|
14
|
+
position: fixed;
|
|
15
|
+
top: 5em;
|
|
16
|
+
right: 5em;
|
|
17
|
+
background-color: rgba(255, 255, 255, 0.7);
|
|
18
|
+
width: 400px;
|
|
19
|
+
padding: 1em;
|
|
20
|
+
border-radius: 5px;
|
|
21
|
+
border: 1px solid #ccc;
|
|
22
|
+
box-shadow: 2px 2px 0 0 #000;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
button {
|
|
26
|
+
margin: 0 0.5em 0.5em;
|
|
27
|
+
background-color: gray;
|
|
28
|
+
color: white;
|
|
29
|
+
border: 0;
|
|
30
|
+
border-radius: 3px;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
padding: 0.5em;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
button.primary {
|
|
36
|
+
background-color: blue;
|
|
37
|
+
padding: 1em;
|
|
38
|
+
color: white;
|
|
39
|
+
border: 0;
|
|
40
|
+
border-radius: 3px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
button[disabled] {
|
|
44
|
+
background-color: #777;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
div {
|
|
48
|
+
margin-bottom: 0.5em;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.message {
|
|
52
|
+
margin-left: 0.5em;
|
|
53
|
+
margin: 1em;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.success {
|
|
57
|
+
color: green;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.error {
|
|
61
|
+
color: red;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.warning {
|
|
65
|
+
color: orange;
|
|
66
|
+
}
|
|
67
|
+
a {
|
|
68
|
+
color: white;
|
|
69
|
+
}
|
|
70
|
+
`}runTests(){this.results=[],this.disabled=!0,this.requestUpdate(),document.querySelectorAll("og-offer").forEach(r=>{let o=r.store.getState(),s=r.getAttribute("product"),i=r.getAttribute("location"),a={messages:this.getOfferAttributeMessages(s,i).concat(this.getOfferRequestMessages(s,o)),product:s};this.results.push(a)}),this.testsRan=!0,this.disabled=!1,this.requestUpdate()}getOfferAttributeMessages(e,r){let o=[];return e||o.push({name:"Offer element found but missing product attribute",type:"error"}),r||o.push({name:"Offer element found but missing location attribute",type:"warning"}),e&&r&&o.push({name:"Offer element found and properly tagged",type:"success"}),o}getOfferRequestMessages(e,r){let o=r.inStock[e],s=r.autoshipEligible[e],i=[];return e&&o===!1&&i.push({name:"This product is marked as out of stock in the OG database",type:"warning"}),e&&s===!1&&i.push({name:"This product is not eligible for autoship",type:"warning"}),e&&o===null&&s===null&&i.push({name:"This product does not exist in our database",type:"error"}),i}resultsCodeBlock(){return this.results.length===0?u`
|
|
71
|
+
<div class="message error">No offer element found on the page</div>
|
|
72
|
+
`:this.results.map((e,r)=>u`
|
|
73
|
+
<div>For offer tag with product = "${e.product}"</div>
|
|
74
|
+
${e.messages.map(o=>u`
|
|
75
|
+
<div class="message ${o.type}">
|
|
76
|
+
${o.name}
|
|
77
|
+
</div>
|
|
78
|
+
`)}
|
|
79
|
+
<button @click=${this.toggleProductFlags(r,{})}>
|
|
80
|
+
Set inStock and eligible
|
|
81
|
+
</button>
|
|
82
|
+
<br />
|
|
83
|
+
<button @click=${this.toggleProductFlags(r,{inStock:!1})}>
|
|
84
|
+
Set to not inStock
|
|
85
|
+
</button>
|
|
86
|
+
<br />
|
|
87
|
+
<button @click=${this.toggleProductFlags(r,{autoship:!1})}>
|
|
88
|
+
Set to not eligible
|
|
89
|
+
</button>
|
|
90
|
+
<br />
|
|
91
|
+
<button @click=${this.toggleProductFlags(r,{autoship:!1,inStock:!1})}>
|
|
92
|
+
Set to not eligible and not in stock
|
|
93
|
+
</button>
|
|
94
|
+
<br />
|
|
95
|
+
<button @click=${this.toggleUpsellPreview(r)}>
|
|
96
|
+
Toggle upsell/regular in this offer
|
|
97
|
+
</button>
|
|
98
|
+
<br />
|
|
99
|
+
<button @click=${this.toggleUpsellNextOrder(r)}>
|
|
100
|
+
upsell product is in next order
|
|
101
|
+
</button>
|
|
102
|
+
<br />
|
|
103
|
+
`)}toggleUpsellPreview(e){return r=>{r.preventDefault();let o=document.querySelectorAll("og-offer")[e];o.getAttribute("preview-upsell-offer")?o.removeAttribute("preview-upsell-offer"):o.setAttribute("preview-upsell-offer",!0),this.runTests()}}toggleProductFlags(e,{inStock:r=!0,autoship:o=!0,groups:s=["subscription","upsell"]}){return i=>{i.preventDefault();let a=document.querySelectorAll("og-offer")[e],c=a.product.id;a.store.dispatch(Te({in_stock:{[c]:r},eligibility_groups:{[c]:s},result:"success",autoship:{[c]:o},module_view:{regular:"58a01e9aacbe40389b5c7325d79091bb"},modifiers:{},incentives_display:{"47c01e9aacbe40389b5c7325d79091aa":{field:"sub_total",object:"order",type:"Discount Percent",value:5},e6534b9d877f41e586c37b7d8abc3a58:{field:"total_price",object:"item",type:"Discount Percent",value:5},f35e842710b24929922db4a529eecd40:{field:"total_price",object:"item",type:"Discount Percent",value:10},"5be321d7c17f4e18a757212b9a20bfcc":{field:"total_price",object:"item",type:"Discount Percent",value:1}},incentives:{[c]:{initial:["5be321d7c17f4e18a757212b9a20bfcc"],ongoing:["e6534b9d877f41e586c37b7d8abc3a58","47c01e9aacbe40389b5c7325d79091aa","f35e842710b24929922db4a529eecd40"]}}})),this.runTests()}}toggleUpsellNextOrder(e){return r=>{let o=document.querySelectorAll("og-offer")[e],s=o.product.id;r.preventDefault(),o.store.dispatch(br({count:1,next:null,previous:null,results:[{order:"24d50352579511ea806cbc764e100cfd",offer:null,subscription:"8a076b7a0ea011e7a5bcbc764e105eda",product:s,components:[],quantity:1,public_id:"24d6901e579511ea806cbc764e100cfd",product_attribute:null,price:"14.99",extra_cost:"0.00",total_price:"13.49",one_time:!1,frozen:!1,first_placed:null}]})),this.runTests()}}render(){return u`
|
|
104
|
+
<div>
|
|
105
|
+
${this.testsRan?this.resultsCodeBlock():u`
|
|
106
|
+
<div>Click the button to run tests</div>
|
|
107
|
+
`}
|
|
108
|
+
<button ?disabled=${this.disabled} @click="${this.runTests.bind(this)}" class="primary">Run Test</button>
|
|
109
|
+
</div>
|
|
110
|
+
`}};n(Zt,"TestWizard");Ic=Zt});var Dc={};Xt(Dc,{addOptinChangedCallback:()=>Vs,addTemplate:()=>Ws,clear:()=>Ms,config:()=>zs,default:()=>Fc,disableOptinChangedCallbacks:()=>$s,getOptins:()=>js,getProductsForPurchasePost:()=>Ls,initialize:()=>ho,offers:()=>_,previewMode:()=>Hs,register:()=>Bs,resolveSettings:()=>Js,setAuthUrl:()=>Ds,setEnvironment:()=>Us,setLocale:()=>Gs,setMerchantId:()=>Fs,setPublicPath:()=>Qs,setTemplates:()=>Ys});var si=Object.defineProperty,tt=n((t,e)=>si(t,"name",{value:e,configurable:!0}),"s"),ii=tt(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),go=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],yo=tt(t=>(e,r)=>{go.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function er(t){let e=ii(go),r=yo(t.source);e(t)&&t.data.ogType==="READY"&&import("//static.ordergroove.com/@ordergroove/offers-live-editor/0.4.0/dist/client.js").then(({initializeClient:o})=>{o(e,r),window.removeEventListener("message",er)})}n(er,"d");tt(er,"handleReady");function tr(t=window.opener){t&&t!==window&&(window.addEventListener("message",er),yo(t)("READY"))}n(tr,"l");tt(tr,"offersLiveEditor");function rr(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(rr,"symbolObservablePonyfill");var be;typeof self!="undefined"?be=self:typeof window!="undefined"||typeof window!="undefined"?be=window:typeof module!="undefined"?be=module:be=Function("return this")();var ai=rr(be),or=ai;var nr=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),Ie={INIT:"@@redux/INIT"+nr(),REPLACE:"@@redux/REPLACE"+nr(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+nr()},"PROBE_UNKNOWN_ACTION")};function ci(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(ci,"isPlainObject");function sr(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(sr)(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 d(){c===a&&(c=a.slice())}n(d,"ensureCanMutateNextListeners");function g(){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(g,"getState");function p(f){if(typeof f!="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 T=!0;return d(),c.push(f),n(function(){if(!!T){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.");T=!1,d();var b=c.indexOf(f);c.splice(b,1),a=null}},"unsubscribe")}n(p,"subscribe");function m(f){if(!ci(f))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof f.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,f)}finally{l=!1}for(var T=a=c,O=0;O<T.length;O++){var b=T[O];b()}return f}n(m,"dispatch");function E(f){if(typeof f!="function")throw new Error("Expected the nextReducer to be a function.");s=f,m({type:Ie.REPLACE})}n(E,"replaceReducer");function y(){var f,T=p;return f={subscribe:n(function(b){if(typeof b!="object"||b===null)throw new TypeError("Expected the observer to be an object.");function P(){b.next&&b.next(g())}n(P,"observeState"),P();var Ks=T(P);return{unsubscribe:Ks}},"subscribe")},f[or]=function(){return this},f}return n(y,"observable"),m({type:Ie.INIT}),o={dispatch:m,subscribe:p,getState:g,replaceReducer:E},o[or]=y,o}n(sr,"createStore");function li(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(li,"getUndefinedStateErrorMessage");function ui(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:Ie.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:Ie.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+Ie.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(ui,"assertReducerShape");function bo(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{ui(r)}catch(l){c=l}return n(function(d,g){if(d===void 0&&(d={}),c)throw c;if(!1)var p;for(var m=!1,E={},y=0;y<i.length;y++){var f=i[y],T=r[f],O=d[f],b=T(O,g);if(typeof b=="undefined"){var P=li(f,g);throw new Error(P)}E[f]=b,m=m||b!==O}return m=m||i.length!==Object.keys(d).length,m?E:d},"combination")}n(bo,"combineReducers");function _o(t,e){return function(){return e(t.apply(this,arguments))}}n(_o,"bindActionCreator");function xo(t,e){if(typeof t=="function")return _o(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]=_o(s,e))}return r}n(xo,"bindActionCreators");function pi(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n(pi,"_defineProperty");function Eo(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(Eo,"ownKeys");function di(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Eo(r,!0).forEach(function(o){pi(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Eo(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n(di,"_objectSpread2");function ir(){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(ir,"compose");function So(){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=ir.apply(void 0,c)(s.dispatch),di({},s,{dispatch:i})}}}n(So,"applyMiddleware");var rt=null,fi=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),vo=n(t=>{if(!rt)throw new Error("Missing redux store.");return rt},"resolveStore"),hi=n((t,e)=>r=>{let{getState:o,dispatch:s}=vo(r),i=t?t(o(),r):{},a=e(s,r);Object.assign(r,i,a)},"createRecalcProps"),h=n((t,e=fi)=>r=>{let s=hi(t,typeof e=="function"?e:i=>xo(e,i));return class extends r{get store(){return rt}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=vo(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"),wo=n(t=>{rt=t},"setStore");function To(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(To,"createThunkMiddleware");var Oo=To();Oo.withExtraArgument=To;var Co=Oo;ce();function mi(t,e){return t===e}n(mi,"defaultEqualityCheck");function gi(t,e,r){if(e===null||r===null||e.length!==r.length)return!1;for(var o=e.length,s=0;s<o;s++)if(!t(e[s],r[s]))return!1;return!0}n(gi,"areArgumentsShallowlyEqual");function yi(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mi,r=null,o=null;return function(){return gi(e,r,arguments)||(o=t.apply(null,arguments)),r=arguments,o}}n(yi,"defaultMemoize");function bi(t){var e=Array.isArray(t[0])?t[0]:t;if(!e.every(function(o){return typeof o=="function"})){var r=e.map(function(o){return typeof o}).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, "+("instead received the following types: ["+r+"]"))}return e}n(bi,"getDependencies");function _i(t){for(var e=arguments.length,r=Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];return function(){for(var s=arguments.length,i=Array(s),a=0;a<s;a++)i[a]=arguments[a];var c=0,l=i.pop(),d=bi(i),g=t.apply(void 0,[function(){return c++,l.apply(null,arguments)}].concat(r)),p=t(function(){for(var m=[],E=d.length,y=0;y<E;y++)m.push(d[y].apply(null,arguments));return g.apply(null,m)});return p.resultFunc=l,p.dependencies=d,p.recomputations=function(){return c},p.resetRecomputations=function(){return c=0},p}}n(_i,"createSelectorCreator");var Ee=_i(yi);var pe=oe(vt());Y();pe.default.Cache=Map;function la(t,e){if(t===e)return!0;if(t===null||e===null||t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}n(la,"arraysEqual");var R=n((t,e)=>!!(t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&t.id===e.id&&(!(Array.isArray(t.components)&&Array.isArray(e.components))||la((t.components||[]).sort(),(e.components||[]).sort()))),"isSameProduct"),Ot=n(t=>t.optedin||[],"optedinSelector"),Wo=n(t=>t.optedout||[],"optedoutSelector"),dr=n(t=>t.autoshipByDefault||{},"autoshipSelector"),ua=n(t=>t.defaultFrequencies||{},"defaultFrequenciesSelector"),V=(0,pe.default)(t=>Ee(Ot,Wo,dr,(e,r,o)=>{let s=e.find(i=>R(t,i));return s||(r.find(i=>R(t,i))?!1:t&&o[t.id]?{id:t.id}:!1)}),t=>JSON.stringify(t)),Yo=(0,pe.default)(t=>Ee(Ot,e=>{let r=e.find(o=>R(t,o));return r||!1}),t=>JSON.stringify(t)),Qo=(0,pe.default)(t=>Ee(Wo,e=>e.find(r=>R(t,r))));var j=(0,pe.default)(t=>Ee(V(t),e=>e&&e.frequency||null)),Ct=(0,pe.default)(t=>Ee(ua,e=>e[t]&&Ve(e[t])||null)),fr=n(t=>t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),"kebabCase"),$=n((t,e,r,o)=>({[r]:e&&e.hasAttribute&&e.hasAttribute(fr(r))&&e[r]||e.offer&&typeof(e.offer[r]!=="undefined")&&e.offer[r]||t.config&&t.config[r]||o}),"configSelector"),ve=n(t=>({templates:t.templates||[]}),"templatesSelector");Y();var pa=n((t=[],e)=>{switch(e.type){case G:return[];case ae:return e.newValue?e.newValue.optedin:t;case ne:case ie:let[[r],o]=t.reduce((s,i)=>s[R(e.payload.product,i)?0:1].push(i)&&s,[[],[]]);return(o||[]).concat({...r,...e.payload.product,frequency:e.payload.frequency});case se:return t.filter(s=>!R(e.payload.product,s));case qe:return t.map(s=>R(e.payload.product,s)?{...s,...e.payload.newProduct}:s);case ft:return t.filter(s=>!R(e.payload.product,s));case xe:return[];default:return t}},"optedin"),da=n((t=[],e)=>{switch(e.type){case G:return[];case ae:return e.newValue?e.newValue.optedout:t;case ne:case ie:return t.filter(s=>!R(e.payload.product,s));case se:let[[r],o]=t.reduce((s,i)=>s[R(e.payload.product,i)?0:1].push(i)&&s,[[],[]]);return(o||[]).concat({...r,...e.payload.product,frequency:e.payload.frequency});case qe:return t.map(s=>R(e.payload.product,s)?{...s,...e.payload.newProduct}:s);case xe:return[];default:return t}},"optedout"),fa=n((t={},{type:e,payload:r})=>{switch(e){case at:return r&&r.count>0?{...t,...r.results[0]&&{...r.results[0],place:new Date(Date.parse(r.results[0].place.replace(/-/gi,"/")))}}:t;case ct:return{...t,products:(r.results||[]).map(o=>o.product)};case dt:return{...t,...r,public_id:r.order,...r.product&&{products:(t.products||[]).concat(r.product)}};default:return t}},"nextUpcomingOrder"),ha=n((t={},e)=>{switch(e.type){case q:return{...t,...e.payload.autoship};default:return t}},"autoshipEligible"),ma=n((t={},e)=>{switch(e.type){case q:return{...t,...e.payload.in_stock};default:return t}},"inStock"),ga=n((t={},e)=>{switch(e.type){case q:return{...t,...e.payload.eligibility_groups};default:return t}},"eligibilityGroups"),Jo=n((t,e)=>t.map(r=>({...e[r],id:[r][0]})),"mapIncentive"),ya=n((t={},e)=>{switch(e.type){case q:return{...t,...[...new Set(Object.keys(e.payload.incentives||{}))].reduce((r,o)=>({...r,[o]:Object.entries(e.payload.incentives).filter(([s])=>s===o).reduce((s,[,{initial:i,ongoing:a}])=>({...s,initial:[...s.initial||[],...Jo(i,e.payload.incentives_display)],ongoing:[...s.ongoing||[],...Jo(a,e.payload.incentives_display)]}),{})}),{})};default:return t}},"incentives");var ba=n((t=!1,e)=>{switch(e.type){case it:return{...e.payload};case _e:return!1;default:return t}},"auth"),_a=n((t="",e)=>{switch(e.type){case ot:return e.payload;default:return t}},"merchantId"),xa=n((t=null,e)=>{switch(e.type){case st:return e.payload;default:return t}},"authUrl"),Ea=n((t={},e)=>{switch(e.type){case q:return{...t,offerId:(e.payload.module_view||{}).regular,...e.payload.modifiers};default:return t}},"offer"),Sa=n((t="",e)=>{switch(e.type){case q:return(e.payload.module_view||{}).regular||"";default:return t}},"offerId"),va=n((t=null,e)=>{switch(e.type){case G:return null;case nt:return e.payload;default:return t}},"sessionId"),wa=n((t={},e)=>{switch(e.type){case q:return{...t,...Object.entries(e.payload.autoship).map(([r])=>({[r]:Object.keys(e.payload.modifiers)})).reduce((r,o)=>({...r,...o}))};case xe:return{};default:return t}},"productOffer"),Ta=n((t={},e)=>{switch(e.type){case bt:return{...t,[e.payload.product]:e.payload.firstOrderPlaceDate};default:return t}},"firstOrderPlaceDate"),Oa=n((t={},e)=>{switch(e.type){case _t:return{...t,[e.payload.product]:e.payload.productToSubscribe};default:return t}},"productToSubscribe"),hr=n((t={},e)=>{switch(e.type){case lt:return{...t,name:"staging",apiUrl:"https://staging.om.ordergroove.com",legoUrl:"https://staging.restapi.ordergroove.com"};case ut:return{...t,name:"dev",apiUrl:"https://dev.om.ordergroove.com",legoUrl:"https://dev.restapi.ordergroove.com"};case pt:return{...t,name:"prod",apiUrl:"https://om.ordergroove.com",legoUrl:"https://restapi.ordergroove.com"};default:return t}},"environment"),Ca=n((t={offerOptInLabel:"Subscribe",offerOptOutLabel:"Purchase one time",offerEveryLabel:"Every",offerTooltipTrigger:"Hover for additional info",offerTooltipContent:"Seems this is a great subscription offering. Many fun details about this program exist.",optinButtonLabel:"\u2022",optoutButtonLabel:"\u2022",optinStatusOptedInLabel:"You're opted in!",optinStatusOptedOutLabel:"You're not opted in.",optinToggleLabel:"\u2022",upsellButtonLabel:"Add item to order on ",upsellButtonPrefix:"",upsellModalContent:"Some upsell modal content",upsellModalOptInLabel:"Subscribe",upsellModalOptOutLabel:"Purchase one time",upsellModalTitle:"Impulse Upsell",upsellModalConfirmLabel:"Ok",upsellModalCancelLabel:"Cancel",defaultFrequencyCopy:"(Recommended)",frequencyPeriods:{"1":"day","2":"week","3":"month"}},e)=>{switch(e.type){case ht:return{...t,...e.payload};default:return t}},"locale"),Pa=n((t={frequencies:["1_2","1_2","1_3"],offerType:"radio"},e)=>{switch(e.type){case mt:return{...t,...e.payload,defaultFrequency:e.payload.defaultFrequency?Ve(e.payload.defaultFrequency):t.defaultFrequency,frequencies:e.payload.frequencies?e.payload.frequencies.map(Ve):t.frequencies};default:return t}},"config"),Ra=n((t=!1,e)=>{switch(e.type){case Ue:return e.payload;default:return t}},"previewStandardOffer"),Aa=n((t=!1,e)=>{switch(e.type){case Fe:return e.payload;default:return t}},"previewUpsellOffer"),Na=n((t=[],e)=>{switch(e.type){case q:return{...t,...e.payload.autoship_by_default};default:return t}},"autoshipByDefault"),ka=n((t=[],e)=>{switch(e.type){case q:return{...t,...e.payload.default_frequencies};default:return t}},"defaultFrequencies"),Ia=n((t=[],e)=>{switch(e.type){case yt:return[...e.payload||[]];case gt:return[e.payload,...t];default:return t}},"templates"),qa=n((t={},e)=>{switch(e.type){case xt:return{...e.payload};default:return t}},"productPlans"),Ko=bo({productPlans:qa,environment:hr,optedin:pa,optedout:da,merchantId:_a,offer:Ea,offerId:Sa,productOffer:wa,sessionId:va,inStock:ma,eligibilityGroups:ga,autoshipByDefault:Na,autoshipEligible:ha,incentives:ya,nextUpcomingOrder:fa,auth:ba,authUrl:xa,locale:Ca,config:Pa,previewStandardOffer:Ra,previewUpsellOffer:Aa,templates:Ia,defaultFrequencies:ka,firstOrderPlaceDate:Ta,productToSubscribe:Oa});var yn=oe(mr());N();ce();var $e="OG_STATE",bn=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),Er=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),_n=n(()=>Er()?{}:bn(localStorage.getItem($e)),"loadState"),Wa=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"),xn=n(t=>{if(Er())return;let e=Wa(t);e&&localStorage.getItem($e)!==e&&localStorage.setItem($e,e)},"saveState"),En=n(t=>(0,yn.throttle)(500,e=>{if(Er())return;let{key:r,newValue:o}=e;r===$e&&o===null?(t.dispatch({type:G}),setTimeout(()=>t.dispatch(kt()),0)):r===$e&&t.dispatch({type:ae,newValue:bn(o)})}),"listenLocalStorageChanges");var Sn=oe(mr());ce();var Ya=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),vn=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>Ya("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),Qa=[{expressions:[({type:t}={})=>t===ne,({type:t}={})=>t===ie],fn:vn(!0)},{expressions:[({type:t}={})=>t===se],fn:vn(!1)}],wn=n(t=>e=>r=>{let o=t.getState();Qa.forEach(s=>{s.expressions.some(i=>i(r,o))&&s.fn(r)}),e(r)},"dispatchMiddleware"),Tn=n(t=>e=>r=>{e(r);let o=(0,Sn.throttle)(500,()=>{xn({...t.getState()})});r.type!==ae&&o()},"localStorageMiddleware");function On(){if(window.og&&window.og.store)return window.og.store;let t=window.og&&window.og.previewMode,e=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}):ir,r=[Co,wn];t||r.push(Tn);let o=e(So(...r)),s=sr(Ko,t?{}:_n(),o);return window.og=window.og||{},window.og.store=s,s}n(On,"getStore");Y();var Sr=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],...Me(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");N();v();var cs=oe(es());v();var fc=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"),ts=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var zr=n(t=>{let e=ts(t);if(!e){let r=t.offer;r&&(e=ts(r))}return e},"resolveProduct"),hc=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),Gr=n(t=>class extends t{get offer(){return hc(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 Gr(t){get product(){return zr(this)}},"withProduct"),Gt=n(t=>class extends t{get childOptions(){return this._childOptions||{options:[]}}connectedCallback(){let e=[],r=null;this.querySelectorAll("option").forEach(o=>{let s=fc(o.value),i=o.innerText.trim();e.push({value:s,text:i}),!r&&o.selected&&(r=s)}),this._childOptions={options:e,isSelected:r},super.connectedCallback&&super.connectedCallback()}},"withChildOptions");var Wt={};Xt(Wt,{eligibilityGroups:()=>ns,eligible:()=>rs,hasUpcomingOrder:()=>is,hasUpsellGroup:()=>ss,inStock:()=>Wr,regularEligible:()=>yc,subscribed:()=>mc,subscriptionEligible:()=>os,upcomingOrderContainsProduct:()=>gc,upsellEligible:()=>as});var Wr=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),rs=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),os=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&rs(t,e)&&Wr(t,e),"subscriptionEligible"),ns=n((t,e)=>(t.eligibilityGroups||{})[(e.product||{}).id]||null,"eligibilityGroups"),ss=n((t,e)=>{let r=ns(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),mc=n((t,e)=>Yo(e.product)(t),"subscribed"),is=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),gc=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),as=n((t,e)=>t.offerId&&t.offerId!=="0"&&t.auth&&Wr(t,e)&&is(t)&&ss(t,e),"upsellEligible"),yc=n((t,e)=>os(t,e)&&!as(t,e),"regularEligible");var bc=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),Yr=class extends A(x){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){return this.test&&cs.default.parse(bc(this.test),r=>Wt[r]&&Wt[r](this.state,this))?u`
|
|
111
|
+
<slot></slot>
|
|
112
|
+
`:u``}shouldUpdate(e){return e.size&&this.product&&this.product.id in this.state.autoshipEligible&&this.product.id in this.state.inStock}};n(Yr,"When");var _c=n(t=>({state:t}),"mapStateToProps"),ls=h(_c)(Yr);v();N();v();Y();var us={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&&pr(t)?t:null}}},Yt={type:Boolean,attribute:!0,reflect:!0},Ae={type:Object,attribute:!1};v();var xc=n(t=>class extends t{getOption(e,r=e){let o=fr(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"),F=xc(x);var L=class extends A(F){static get properties(){return{subscribed:Yt,frequencyMatch:{type:Boolean,reflect:!0,attribute:"frequency-match"}}}static get styles(){return w`
|
|
148
113
|
:host {
|
|
149
114
|
cursor: default;
|
|
150
115
|
display: inline-block;
|
|
@@ -197,61 +162,61 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
197
162
|
text-align: center;
|
|
198
163
|
overflow: visible;
|
|
199
164
|
}
|
|
200
|
-
`}constructor(){super()
|
|
165
|
+
`}constructor(){super();this.addEventListener("click",this.handleClick.bind(this))}updated(e){e.has("subscribed")&&(this.frequencyMatch=this.frequency===this.defaultFrequency)}handleClick(){}render(){return this.subscribed&&!this.defaultFrequency?u`
|
|
201
166
|
<slot name="subscribed"></slot>
|
|
202
167
|
<slot name="frequency-mismatch"></slot>
|
|
203
|
-
`:this.subscribed&&this.defaultFrequency===this.frequency?
|
|
168
|
+
`:this.subscribed&&this.defaultFrequency===this.frequency?u`
|
|
204
169
|
<slot name="subscribed"></slot>
|
|
205
170
|
<slot name="frequency-match"></slot>
|
|
206
|
-
`:this.subscribed&&this.defaultFrequency!==this.frequency?
|
|
171
|
+
`:this.subscribed&&this.defaultFrequency!==this.frequency?u`
|
|
207
172
|
<slot name="subscribed"></slot>
|
|
208
173
|
<slot name="frequency-mismatch"></slot>
|
|
209
|
-
`:
|
|
174
|
+
`:u`
|
|
210
175
|
<slot name="not-subscribed"></slot>
|
|
211
|
-
`}}
|
|
176
|
+
`}};n(L,"OptinStatus");var z=n((t,e={})=>({subscribed:V(e.product)(t),frequency:j(e.product)(t),...$(t,e,"defaultFrequency"),...ve(t,e)}),"mapStateToProps"),ps=h(z)(L);var Qr=class extends L{static get properties(){return{...super.properties,frequency:{type:String,reflect:!0},defaultFrequency:te,optinButtonLabel:{type:String}}}handleClick(e){this.optinProduct(zr(this),this.defaultFrequency),e.preventDefault()}render(){return u`
|
|
177
|
+
<slot name="default">
|
|
178
|
+
<button id="action-trigger" class="btn radio ${this.subscribed?"active":""}"></button>
|
|
179
|
+
<label for="action-trigger">
|
|
180
|
+
<slot>
|
|
181
|
+
<slot name="label"><og-text key="offerOptInLabel"></og-text></slot>
|
|
182
|
+
</slot>
|
|
183
|
+
</label>
|
|
184
|
+
</slot>
|
|
185
|
+
`}};n(Qr,"OptinButton");var ds=h(z,{optinProduct:Q})(Qr);v();N();var Jr=class extends L{static get properties(){return{...super.properties,label:{type:String}}}handleClick(e){this.optoutProduct(this.product),e.preventDefault()}render(){return u`
|
|
186
|
+
<slot name="default">
|
|
187
|
+
<button id="action-trigger" class="btn radio ${this.subscribed?"":"active"}"></button>
|
|
188
|
+
<label for="action-trigger">
|
|
189
|
+
<slot>
|
|
190
|
+
<og-text key="offerOptOutLabel"></og-text>
|
|
191
|
+
</slot>
|
|
192
|
+
</label>
|
|
193
|
+
</slot>
|
|
194
|
+
`}};n(Jr,"OptoutButton");var fs=h(z,{optoutProduct:we})(Jr);v();N();v();Y();var Ke=n((t,e)=>{let{every:r,every_period:o}=Me(t);return u`
|
|
212
195
|
${r}
|
|
213
196
|
<og-text key="frequencyPeriods" variant="${o}" pluralize="${r}"></og-text>
|
|
214
|
-
${e&&e===t?
|
|
197
|
+
${e&&e===t?u`
|
|
215
198
|
<og-text key="defaultFrequencyCopy"></og-text>
|
|
216
199
|
`:""}
|
|
217
|
-
`}
|
|
200
|
+
`},"frequencyText"),Ze=class extends A(F){static get properties(){return{...super.properties,disabled:{type:Boolean},subscribed:Yt,frequency:{type:String},defaultFrequency:te,productDefaultFrequency:{type:String},frequencies:{converter:{fromAttribute:Go}}}}static get styles(){return w`
|
|
218
201
|
:host[hidden] {
|
|
219
202
|
display: none;
|
|
220
203
|
}
|
|
221
204
|
:host {
|
|
222
205
|
display: inline-block;
|
|
223
206
|
}
|
|
224
|
-
`}constructor(){super()
|
|
207
|
+
`}constructor(){super();this.frequencies=[]}render(){let e=this.frequency||this.defaultFrequency;return u`
|
|
225
208
|
<span>
|
|
226
|
-
${this.subscribed&&
|
|
227
|
-
<slot name="subscribed">${
|
|
209
|
+
${this.subscribed&&u`
|
|
210
|
+
<slot name="subscribed">${Ke(e)} </slot>
|
|
228
211
|
`||""}
|
|
229
|
-
${!this.subscribed&&
|
|
212
|
+
${!this.subscribed&&u`
|
|
230
213
|
<slot name="not-subscribed"></slot>
|
|
231
214
|
`||""}
|
|
232
|
-
${this.subscribed&&this.defaultFrequency&&this.defaultFrequency!==this.frequency&&
|
|
215
|
+
${this.subscribed&&this.defaultFrequency&&this.defaultFrequency!==this.frequency&&u`
|
|
233
216
|
<slot name="frequency-mismatch"></slot>
|
|
234
217
|
`||""}
|
|
235
218
|
</span>
|
|
236
|
-
`}}const p=(t,e)=>({subscribed:Object(o.e)(e.product)(t),frequency:Object(o.h)(e.product)(t),productDefaultFrequency:Object(o.g)((e.product||{}).id)(t),...Object(o.b)(t,e,"frequencies",[]),...Object(o.b)(t,e,"defaultFrequency"),...Object(o.k)(t,e)}),f=Object(i.connect)(p)(d);e.default=f},function(t,e,r){"use strict";r.r(e),function(t){r.d(e,"STORE_ROOT",(function(){return s})),r.d(e,"safeParseState",(function(){return a})),r.d(e,"loadState",(function(){return u})),r.d(e,"serializeState",(function(){return l})),r.d(e,"saveState",(function(){return d})),r.d(e,"listenLocalStorageChanges",(function(){return p})),r.d(e,"clearState",(function(){return f}));var n=r(17),o=r(3),i=r(0);const s="OG_STATE",a=t=>{try{if(null===t)return;return JSON.parse(t)}catch(t){return}},c=()=>window.og&&window.og.previewMode,u=()=>c()?{}:a(localStorage.getItem(s)),l=t=>!(!t||!t.sessionId)&&JSON.stringify({sessionId:t.sessionId,optedin:t.optedin,optedout:t.optedout,productOffer:t.productOffer,firstOrderPlaceDate:t.firstOrderPlaceDate,productToSubscribe:t.productToSubscribe}),d=t=>{if(c())return;const e=l(t);e&&localStorage.getItem(s)!==e&&localStorage.setItem(s,e)},p=e=>Object(n.throttle)(500,r=>{if(c())return;const{key:n,newValue:u}=r;n===s&&null===u?(e.dispatch({type:i.j}),t(()=>e.dispatch(Object(o.requestSessionId)()))):n===s&&e.dispatch({type:i.i,newValue:a(u)})}),f=()=>localStorage.removeItem(s)}.call(this,r(16).setImmediate)},function(t,e,r){window,t.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e),r.d(e,"ogAuthRegExp",(function(){return n})),r.d(e,"readAuthCookie",(function(){return o})),r.d(e,"parseAuth",(function(){return i})),r.d(e,"iframeLoad",(function(){return s})),r.d(e,"isJsonResponse",(function(){return a})),r.d(e,"resolveAuth",(function(){return c}));const n=/^og_auth=/,o=(t=n)=>(document.cookie.split(/;\s*/).find(e=>e.match(t))||"").replace(n,""),i=t=>{if("object"==typeof t)return t;const e=(t||"").split("|");return 3===e.length?{sig_field:e[0],ts:parseInt(e[1],10),sig:e[2]}:null},s=t=>new Promise((e,r)=>{const n=document.createElement("iframe");n.style.setProperty("display","none","important"),document.body.appendChild(n),n.onload=e,n.onerror=r,n.src=t}),a=t=>-1!==(t.headers.get("content-type")||"").indexOf("application/json"),c=(t,e=o,r=s)=>Promise.resolve(e()||t&&"string"==typeof t&&fetch(t).then(n=>n.status>=200&&n.status<300?e()||(a(n)?n.json():Promise.resolve(r(t)).then(e)):null)).then(i).then(t=>null===t?Promise.reject(new Error("Unauthorized")):t);e.default=c}])},function(t,e,r){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function i(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new i(o.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new i(o.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r(19),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(11))},function(t,e,r){!function(t){"use strict";function e(t,e,r,n){var o,i=!1,s=0;function a(){o&&clearTimeout(o)}function c(){for(var c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];var d=this,p=Date.now()-s;function f(){s=Date.now(),r.apply(d,u)}function h(){o=void 0}i||(n&&!o&&f(),a(),void 0===n&&p>t?f():!0!==e&&(o=setTimeout(n?h:f,void 0===n?t-p:t)))}return"boolean"!=typeof e&&(n=r,r=e,e=void 0),c.cancel=function(){a(),i=!0},c}t.debounce=function(t,r,n){return void 0===n?e(t,r,!1):e(t,n,!1!==r)},t.throttle=e,Object.defineProperty(t,"__esModule",{value:!0})}(e)},,function(t,e,r){(function(t,e){!function(t,r){"use strict";if(!t.setImmediate){var n,o,i,s,a,c=1,u={},l=!1,d=t.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(t);p=p&&p.setTimeout?p:t,"[object process]"==={}.toString.call(t.process)?n=function(t){e.nextTick((function(){h(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,r=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=r,e}}()?t.MessageChannel?((i=new MessageChannel).port1.onmessage=function(t){h(t.data)},n=function(t){i.port2.postMessage(t)}):d&&"onreadystatechange"in d.createElement("script")?(o=d.documentElement,n=function(t){var e=d.createElement("script");e.onreadystatechange=function(){h(t),e.onreadystatechange=null,o.removeChild(e),e=null},o.appendChild(e)}):n=function(t){setTimeout(h,0,t)}:(s="setImmediate$"+Math.random()+"$",a=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(s)&&h(+e.data.slice(s.length))},t.addEventListener?t.addEventListener("message",a,!1):t.attachEvent("onmessage",a),n=function(e){t.postMessage(s+e,"*")}),p.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r<e.length;r++)e[r]=arguments[r+1];var o={callback:t,args:e};return u[c]=o,n(c),c++},p.clearImmediate=f}function f(t){delete u[t]}function h(t){if(l)setTimeout(h,0,t);else{var e=u[t];if(e){l=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(void 0,r)}}(e)}finally{f(t),l=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,r(11),r(20))},function(t,e){var r,n,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var c,u=[],l=!1,d=-1;function p(){l&&c&&(l=!1,c.length?u=c.concat(u):d=-1,u.length&&f())}function f(){if(!l){var t=a(p);l=!0;for(var e=u.length;e;){for(c=u,u=[];++d<e;)c&&c[d].run();d=-1,e=u.length}c=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function h(t,e){this.fun=t,this.array=e}function g(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new h(t,e)),1!==u.length||l||a(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,e){const r={PAR_OPEN:"(".charCodeAt(0),PAR_CLOSE:")".charCodeAt(0),OP_NOT:"!".charCodeAt(0),BINARY_AND:"&".charCodeAt(0),BINARY_OR:"|".charCodeAt(0),LITERAL:"LITERAL",END:"END",LEAF:"LEAF",ATOMIC:"ATOMIC"};t.exports=r},,function(t,e,r){"use strict";r.r(e),r.d(e,"optedin",(function(){return a})),r.d(e,"optedout",(function(){return c})),r.d(e,"nextUpcomingOrder",(function(){return u})),r.d(e,"autoshipEligible",(function(){return l})),r.d(e,"inStock",(function(){return d})),r.d(e,"eligibilityGroups",(function(){return p})),r.d(e,"incentives",(function(){return h})),r.d(e,"frequency",(function(){return g})),r.d(e,"auth",(function(){return y})),r.d(e,"merchantId",(function(){return m})),r.d(e,"authUrl",(function(){return b})),r.d(e,"offer",(function(){return v})),r.d(e,"offerId",(function(){return _})),r.d(e,"sessionId",(function(){return w})),r.d(e,"productOffer",(function(){return O})),r.d(e,"firstOrderPlaceDate",(function(){return S})),r.d(e,"productToSubscribe",(function(){return x})),r.d(e,"environment",(function(){return E})),r.d(e,"locale",(function(){return T})),r.d(e,"config",(function(){return C})),r.d(e,"previewStandardOffer",(function(){return P})),r.d(e,"previewUpsellOffer",(function(){return k})),r.d(e,"autoshipByDefault",(function(){return j})),r.d(e,"defaultFrequencies",(function(){return q})),r.d(e,"templates",(function(){return A}));var n=r(12),o=r(0),i=r(2),s=r(5);const a=(t=[],e)=>{switch(e.type){case o.j:return[];case o.i:return e.newValue?e.newValue.optedin:t;case o.k:case o.m:const[[r],n]=t.reduce((t,r)=>t[Object(i.c)(e.payload.product,r)?0:1].push(r)&&t,[[],[]]);return(n||[]).concat({...r,...e.payload.product,frequency:e.payload.frequency});case o.l:return t.filter(t=>!Object(i.c)(e.payload.product,t));case o.n:return t.map(t=>Object(i.c)(e.payload.product,t)?{...t,...e.payload.newProduct}:t);case o.e:return t.filter(t=>!Object(i.c)(e.payload.product,t));case o.c:return[];default:return t}},c=(t=[],e)=>{switch(e.type){case o.j:return[];case o.i:return e.newValue?e.newValue.optedout:t;case o.k:case o.m:return t.filter(t=>!Object(i.c)(e.payload.product,t));case o.l:const[[r],n]=t.reduce((t,r)=>t[Object(i.c)(e.payload.product,r)?0:1].push(r)&&t,[[],[]]);return(n||[]).concat({...r,...e.payload.product,frequency:e.payload.frequency});case o.n:return t.map(t=>Object(i.c)(e.payload.product,t)?{...t,...e.payload.newProduct}:t);case o.c:return[];default:return t}},u=(t={},{type:e,payload:r})=>{switch(e){case o.q:return r&&r.count>0?{...t,...r.results[0]&&{...r.results[0],place:new Date(Date.parse(r.results[0].place.replace(/-/gi,"/")))}}:t;case o.r:return{...t,products:(r.results||[]).map(t=>t.product)};case o.g:return{...t,...r,public_id:r.order,...r.product&&{products:(t.products||[]).concat(r.product)}};default:return t}},l=(t={},e)=>{switch(e.type){case o.p:return{...t,...e.payload.autoship};default:return t}},d=(t={},e)=>{switch(e.type){case o.p:return{...t,...e.payload.in_stock};default:return t}},p=(t={},e)=>{switch(e.type){case o.p:return{...t,...e.payload.eligibility_groups};default:return t}},f=(t,e)=>t.map(t=>({...e[t],id:[t][0]})),h=(t={},e)=>{switch(e.type){case o.p:return{...t,...[...new Set(Object.keys(e.payload.incentives||{}))].reduce((t,r)=>({...t,[r]:Object.entries(e.payload.incentives).filter(([t])=>t===r).reduce((t,[,{initial:r,ongoing:n}])=>({...t,initial:[...t.initial||[],...f(r,e.payload.incentives_display)],ongoing:[...t.ongoing||[],...f(n,e.payload.incentives_display)]}),{})}),{})};default:return t}},g=(t={},e)=>{switch(e.type){case o.k:case o.m:return{...t,[e.payload.product]:e.payload.frequency};case o.l:return{...t,[e.payload.product]:void 0};default:return t}},y=(t=!1,e)=>{switch(e.type){case o.b:return{...e.payload};case o.J:return!1;default:return t}},m=(t="",e)=>{switch(e.type){case o.E:return e.payload;default:return t}},b=(t=null,e)=>{switch(e.type){case o.x:return e.payload;default:return t}},v=(t={},e)=>{switch(e.type){case o.p:return{...t,offerId:(e.payload.module_view||{}).regular,...e.payload.modifiers};default:return t}},_=(t="",e)=>{switch(e.type){case o.p:return(e.payload.module_view||{}).regular||"";default:return t}},w=(t=null,e)=>{switch(e.type){case o.j:return null;case o.f:return e.payload;default:return t}},O=(t={},e)=>{switch(e.type){case o.p:return{...t,...Object.entries(e.payload.autoship).map(([t])=>({[t]:Object.keys(e.payload.modifiers)})).reduce((t,e)=>({...t,...e}))};case o.c:return{};default:return t}},S=(t={},e)=>{switch(e.type){case o.C:return{...t,[e.payload.product]:e.payload.firstOrderPlaceDate};default:return t}},x=(t={},e)=>{switch(e.type){case o.H:return{...t,[e.payload.product]:e.payload.productToSubscribe};default:return t}},E=(t={},e)=>{switch(e.type){case o.B:return{...t,name:"staging",apiUrl:"https://staging.om.ordergroove.com",legoUrl:"https://staging.restapi.ordergroove.com"};case o.z:return{...t,name:"dev",apiUrl:"https://dev.om.ordergroove.com",legoUrl:"https://dev.restapi.ordergroove.com"};case o.A:return{...t,name:"prod",apiUrl:"https://om.ordergroove.com",legoUrl:"https://restapi.ordergroove.com"};default:return t}},T=(t={offerOptInLabel:"Subscribe",offerOptOutLabel:"Purchase one time",offerEveryLabel:"Every",offerTooltipTrigger:"Hover for additional info",offerTooltipContent:"Seems this is a great subscription offering. Many fun details about this program exist.",optinButtonLabel:"•",optoutButtonLabel:"•",optinStatusOptedInLabel:"You're opted in!",optinStatusOptedOutLabel:"You're not opted in.",optinToggleLabel:"•",upsellButtonLabel:"Add item to order on ",upsellButtonPrefix:"",upsellModalContent:"Some upsell modal content",upsellModalOptInLabel:"Subscribe",upsellModalOptOutLabel:"Purchase one time",upsellModalTitle:"Impulse Upsell",upsellModalConfirmLabel:"Ok",upsellModalCancelLabel:"Cancel",defaultFrequencyCopy:"(Recommended)",frequencyPeriods:{1:"day",2:"week",3:"month"}},e)=>{switch(e.type){case o.D:return{...t,...e.payload};default:return t}},C=(t={frequencies:["1_2","1_2","1_3"],offerType:"radio"},e)=>{switch(e.type){case o.y:return{...t,...e.payload,defaultFrequency:e.payload.defaultFrequency?Object(s.stringifyFrequency)(e.payload.defaultFrequency):t.defaultFrequency,frequencies:e.payload.frequencies?e.payload.frequencies.map(s.stringifyFrequency):t.frequencies};default:return t}},P=(t=!1,e)=>{switch(e.type){case o.F:return e.payload;default:return t}},k=(t=!1,e)=>{switch(e.type){case o.G:return e.payload;default:return t}},j=(t=[],e)=>{switch(e.type){case o.p:return{...t,...e.payload.autoship_by_default};default:return t}},q=(t=[],e)=>{switch(e.type){case o.p:return{...t,...e.payload.default_frequencies};default:return t}},A=(t=[],e)=>{switch(e.type){case o.I:return[...e.payload||[]];case o.a:return[e.payload,...t];default:return t}};e.default=Object(n.c)({environment:E,optedin:a,optedout:c,merchantId:m,offer:v,offerId:_,productOffer:O,sessionId:w,inStock:d,eligibilityGroups:p,autoshipByDefault:j,autoshipEligible:l,incentives:h,nextUpcomingOrder:u,auth:y,authUrl:b,locale:T,config:C,previewStandardOffer:P,previewUpsellOffer:k,templates:A,defaultFrequencies:q,firstOrderPlaceDate:S,productToSubscribe:x})},function(t,e,r){"use strict";(function(t,n){var o,i=r(26);o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:n;var s=Object(i.a)(o);e.a=s}).call(this,r(11),r(31)(t))},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return c})),r.d(e,"b",(function(){return u}));var n=r(17),o=r(0),i=(r(2),r(14));const s=e=>({payload:{product:{id:r,components:n}={}}={}}={})=>t(()=>((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})))("optin-changed",{productId:r,components:n,optedIn:e})),a=[{expressions:[({type:t}={})=>t===o.k,({type:t}={})=>t===o.m],fn:s(!0)},{expressions:[({type:t}={})=>t===o.l],fn:s(!1)}],c=t=>e=>r=>{const n=t.getState();a.forEach(t=>{t.expressions.some(t=>t(r,n))&&t.fn(r)}),e(r)},u=t=>e=>r=>{e(r);const s=Object(n.throttle)(500,()=>{Object(i.saveState)({...t.getState()})});r.type!==o.i&&s()}}).call(this,r(16).setImmediate)},function(t,e,r){"use strict";function n(t){var e,r=t.Symbol;return"function"==typeof r?r.observable?e=r.observable:(e=r("observable"),r.observable=e):e="@@observable",e}r.d(e,"a",(function(){return n}))},function(t,e,r){const n=r(33),o=r(34),i=r(35);t.exports={parse:(t,e)=>{const r=n(t),s=o.PolishNotation(r),a=o.PolishGenerator(s),c=i.make(a);return i.nodeEvaluator(c,e)}}},,function(t,e,r){const{offersLiveEditor:n}=r(30),{setStore:o}=r(4),{getStore:i}=r(51),{listenLocalStorageChanges:s}=r(14),a=r(32),c=r(3),{ConnectedWhen:u}=r(52),{ConnectedOptinButton:l}=r(36),{ConnectedOptoutButton:d}=r(37),{ConnectedOptinSelect:p}=r(38),{ConnectedUpsellButton:f}=r(39),{ConnectedUpsellModal:h}=r(40),{ConnectedOptinToggle:g}=r(41),{ConnectedOptinStatus:y}=r(9),{ConnectedText:m}=r(42),{ConnectedIncentiveText:b}=r(43),{ConnectedSelectFrequency:v}=r(44),{ConnectedNextUpcomingOrder:_}=r(53),{ConnectedOffer:w}=r(45),{Modal:O}=r(46),{Select:S}=r(47),{Tooltip:x}=r(48),{ConnectedFrequencyStatus:E}=r(13),T=r(49),{default:C}=r(5),{environment:P}=r(23);let k;T.enable();const j={setEnvironment:t=>(k.dispatch(c.setEnvironment(t)),j),setMerchantId:t=>(k.dispatch(c.setMerchantId(t)),j),setAuthUrl:t=>(k.dispatch(c.setAuthUrl(t)),j),getProductsForPurchasePost:(t=[])=>a.getProductsForPurchasePost(k.getState(),t),getOptins:(t=[])=>a.getProductsForPurchasePost(k.getState(),t),clear(){k.dispatch(c.checkout())},addOptinChangedCallback(t){"function"==typeof t&&document.addEventListener("optin-changed",e=>t(e.detail))},disableOptinChangedCallbacks(){document.addEventListener("optin-changed",t=>t.stopPropagation(),!0)},register(){try{customElements.define("og-when",u),customElements.define("og-text",m),customElements.define("og-incentive-text",b),customElements.define("og-offer",w),customElements.define("og-select-frequency",v),customElements.define("og-optout-button",d),customElements.define("og-optin-toggle",g),customElements.define("og-optin-status",y),customElements.define("og-optin-button",l),customElements.define("og-optin-select",p),customElements.define("og-upsell-button",f),customElements.define("og-frequency-status",E),customElements.define("og-modal",O),customElements.define("og-select",S),customElements.define("og-tooltip",x),customElements.define("og-upsell-modal",h),customElements.define("og-next-upcoming-order",_)}catch(t){console.error(t)}j.register=()=>0},previewMode(t){return window.og=window.og||{},!1===t?delete window.og:window.og.previewMode=!0,this},initialize(t,e,r){if(j.isReady)return console.warn("og.offers has been initialized already. Skipping."),j;k=i();const n=window.og_settings;if(t&&e&&n){let r=[];n.product?r.push(n.product):n.cart&&Array.isArray(n.cart.products)&&(r=r.concat(n.cart.products));const{apiUrl:o}=P({},c.setEnvironment(e)),{sessionId:i}=k.getState();i&&r.forEach(e=>C.fetchOffer(o,t,i,`${e}`,"pdp"))}return o(k),t&&j.setMerchantId(t),e&&j.setEnvironment(e),r&&j.setAuthUrl(r),window.addEventListener("storage",s(k)),t&&e&&(k.dispatch(c.requestSessionId()),k.dispatch(c.fetchAuth()),j.register()),j.isReady=!0,j},config:t=>(k.dispatch(c.setConfig(t)),j),setLocale:t=>(k.dispatch(c.setLocale(t)),j),addTemplate:(t,e,r)=>(k.dispatch(c.addTemplate(t,e,r)),j),setTemplates:t=>(k.dispatch(c.setTemplates(t)),j),setPublicPath:t=>(r.p=t,j)};window.OG=window.OG||{},Object.assign(window.OG,j),Object.assign(j.initialize,j),n(),t.exports=j.initialize},function(t,e,r){window,t.exports=function(t){function e(e){for(var r,o,i=e[0],s=e[1],a=0,u=[];a<i.length;a++)o=i[a],Object.prototype.hasOwnProperty.call(n,o)&&n[o]&&u.push(n[o][0]),n[o]=0;for(r in s)Object.prototype.hasOwnProperty.call(s,r)&&(t[r]=s[r]);for(c&&c(e);u.length;)u.shift()()}var r={},n={0:0};function o(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.e=function(t){var e=[],r=n[t];if(0!==r)if(r)e.push(r[2]);else{var i=new Promise((function(e,o){r=n[t]=[e,o]}));e.push(r[2]=i);var s,a=document.createElement("script");a.charset="utf-8",a.timeout=120,o.nc&&a.setAttribute("nonce",o.nc),a.src=function(t){return o.p+""+t+".offers-live-editor.js"}(t);var c=new Error;s=function(e){a.onerror=a.onload=null,clearTimeout(u);var r=n[t];if(0!==r){if(r){var o=e&&("load"===e.type?"missing":e.type),i=e&&e.target&&e.target.src;c.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",c.name="ChunkLoadError",c.type=o,c.request=i,r[1](c)}n[t]=void 0}};var u=setTimeout((function(){s({type:"timeout",target:a})}),12e4);a.onerror=a.onload=s,document.head.appendChild(a)}return Promise.all(e)},o.m=t,o.c=r,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(r,n,function(e){return t[e]}.bind(null,n));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="//static.ordergroove.com/@ordergroove/offers-live-editor/0.3.0/dist/",o.oe=function(t){throw console.error(t),t};var i=window.webpackJsonp=window.webpackJsonp||[],s=i.push.bind(i);i.push=e,i=i.slice();for(var a=0;a<i.length;a++)e(i[a]);var c=s;return o(o.s=0)}([function(t,e,r){"use strict";r.r(e),r.d(e,"offersLiveEditor",(function(){return s}));const n=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],o=t=>(e,r)=>{n.forEach(n=>t.postMessage({ogType:e,...r},n))};function i(t){const e=(t=>e=>t.indexOf(e.origin)>=0)(n),s=o(t.source);e(t)&&"READY"===t.data.ogType&&r.e(1).then(r.bind(null,2)).then(({initializeClient:t})=>{t(e,s),window.removeEventListener("message",i)})}function s(t=window.opener){t&&t!==window&&(window.addEventListener("message",i),o(t)("READY"))}e.default=s}])},function(t,e){t.exports=function(t){if(!t.webpackPolyfill){var e=Object.create(t);e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(e,"exports",{enumerable:!0}),e.webpackPolyfill=1}return e}},function(t,e,r){"use strict";r.r(e),r.d(e,"getProductsForPurchasePost",(function(){return o}));var n=r(5);const o=(t={},e=[])=>(t.optedin||[]).map(e=>{const r={product:e.id,subscription_info:{components:e.components||[]},tracking_override:{offer:((t.productOffer||{})[e.id]||[])[0],...Object(n.parseFrequency)(e.frequency)}};return t.firstOrderPlaceDate&&t.firstOrderPlaceDate[e.id]&&(r.subscription_info.first_order_place_date=t.firstOrderPlaceDate[e.id]),t.productToSubscribe&&t.productToSubscribe[e.id]&&(r.tracking_override.product=t.productToSubscribe[e.id]),r}).filter(t=>t.tracking_override.offer).filter(t=>e.length?e.includes(t.product):t);e.default={getProductsForPurchasePost:o}},function(t,e,r){const n=r(21);t.exports=t=>{let e="";const r=[];for(const o of t){const t=o.charCodeAt(0);switch(t){case n.PAR_OPEN:case n.PAR_CLOSE:case n.OP_NOT:case n.BINARY_AND:case n.BINARY_OR:e&&(r.push({type:n.LITERAL,value:e}),e=""),r.push({type:t,value:o});break;default:e+=o}}return e&&r.push({type:n.LITERAL,value:e}),r}},function(t,e,r){const n=r(21);t.exports={PolishNotation:t=>{const e=[],r=[];return t.forEach(t=>{switch(t.type){case n.LITERAL:e.unshift(t);break;case n.BINARY_AND:case n.BINARY_OR:case n.OP_NOT:case n.PAR_OPEN:r.push(t);break;case n.PAR_CLOSE:for(;r.length&&r[r.length-1].type!==n.PAR_OPEN;)e.unshift(r.pop());r.pop(),r.length&&r[r.length-1].type===n.OP_NOT&&e.unshift(r.pop())}}),r.length&&[...r.reverse(),...e]||e},PolishGenerator:function*(t){for(let e=0;e<t.length-1;e++)yield t[e];return t[t.length-1]}}},function(t,e,r){const n=r(21);class o{constructor(t,e,r,n){this.op=t,this.left=e,this.right=r,this.literal=n}isLeaf(){return this.op===n.LEAF}isAtomic(){return this.isLeaf()||this.op===n.OP_NOT&&this.left.isLeaf()}getLiteralValue(){return this.literal}static CreateAnd(t,e){return new o(n.BINARY_AND,t,e)}static CreateNot(t){return new o(n.OP_NOT,t)}static CreateOr(t,e){return new o(n.BINARY_OR,t,e)}static CreateLiteral(t){return new o(n.LEAF,null,null,t)}}const i=t=>{const e=t.next().value;switch(e.type){case n.LITERAL:return o.CreateLiteral(e.value);case n.OP_NOT:return o.CreateNot(i(t));case n.BINARY_AND:{const e=i(t),r=i(t);return o.CreateAnd(e,r)}case n.BINARY_OR:{const e=i(t),r=i(t);return o.CreateOr(e,r)}}return null},s=(t,e)=>t.isLeaf()?e(t.getLiteralValue()):t.op===n.OP_NOT?!s(t.left,e):t.op===n.BINARY_OR?s(t.left,e)||s(t.right,e):t.op===n.BINARY_AND?s(t.left,e)&&s(t.right,e):void 0;t.exports={make:i,nodeEvaluator:s}},function(t,e,r){"use strict";r.r(e),r.d(e,"OptinButton",(function(){return u})),r.d(e,"ConnectedOptinButton",(function(){return l}));var n=r(1),o=r(3),i=r(9),s=r(4),a=r(8),c=r(6);class u extends i.OptinStatus{static get properties(){return{...super.properties,frequency:{type:String,reflect:!0},defaultFrequency:a.b,optinButtonLabel:{type:String}}}handleClick(t){this.optinProduct(Object(c.a)(this),this.defaultFrequency),t.preventDefault()}render(){return n.c`
|
|
237
|
-
<slot name="default">
|
|
238
|
-
<button id="action-trigger" class="btn radio ${this.subscribed?"active":""}"></button>
|
|
239
|
-
<label for="action-trigger">
|
|
240
|
-
<slot>
|
|
241
|
-
<slot name="label"><og-text key="offerOptInLabel"></og-text></slot>
|
|
242
|
-
</slot>
|
|
243
|
-
</label>
|
|
244
|
-
</slot>
|
|
245
|
-
`}}const l=Object(s.connect)(i.mapStateToProps,{optinProduct:o.optinProduct})(u);e.default=l},function(t,e,r){"use strict";r.r(e),r.d(e,"OptoutButton",(function(){return a})),r.d(e,"ConnectedOptoutButton",(function(){return c}));var n=r(1),o=r(3),i=r(9),s=r(4);class a extends i.OptinStatus{static get properties(){return{...super.properties,label:{type:String}}}handleClick(t){this.optoutProduct(this.product),t.preventDefault()}render(){return n.c`
|
|
246
|
-
<slot name="default">
|
|
247
|
-
<button id="action-trigger" class="btn radio ${this.subscribed?"":"active"}"></button>
|
|
248
|
-
<label for="action-trigger">
|
|
249
|
-
<slot>
|
|
250
|
-
<og-text key="offerOptOutLabel"></og-text>
|
|
251
|
-
</slot>
|
|
252
|
-
</label>
|
|
253
|
-
</slot>
|
|
254
|
-
`}}const c=Object(s.connect)(i.mapStateToProps,{optoutProduct:o.optoutProduct})(a);e.default=c},function(t,e,r){"use strict";r.r(e),r.d(e,"OptinSelect",(function(){return l})),r.d(e,"ConnectedOptinSelect",(function(){return d}));var n=r(1),o=r(3),i=r(6),s=r(9),a=r(13),c=r(4),u=r(8);class l extends(Object(i.b)(s.OptinStatus)){static get properties(){return{...super.properties,frequencies:{type:Array,attribute:!1},frequency:{type:String},defaultFrequency:u.b}}static get styles(){return n.b`
|
|
219
|
+
`}};n(Ze,"FrequencyStatus");var Xe=n((t,e)=>({subscribed:V(e.product)(t),frequency:j(e.product)(t),productDefaultFrequency:Ct((e.product||{}).id)(t),...$(t,e,"frequencies",[]),...$(t,e,"defaultFrequency"),...ve(t,e)}),"mapStateToProps"),hs=h(Xe)(Ze);var Kr=class extends Gt(L){static get properties(){return{...super.properties,frequencies:{type:Array,attribute:!1},frequency:{type:String},defaultFrequency:te}}static get styles(){return w`
|
|
255
220
|
:host {
|
|
256
221
|
display: inline-block;
|
|
257
222
|
cursor: pointer;
|
|
@@ -261,26 +226,26 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
261
226
|
border-width: var(--og-select-border-width, 1px);
|
|
262
227
|
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
|
|
263
228
|
}
|
|
264
|
-
`}get isSelected(){return this.subscribed?this.frequency:"optedOut"}onOptinChange(
|
|
229
|
+
`}get isSelected(){return this.subscribed?this.frequency:"optedOut"}onOptinChange(e){e==="optedOut"?this.optoutProduct(this.product):this.productChangeFrequency(this.product,e)}render(){let{options:e,isSelected:r}=this.childOptions,o=e;return e.length||(o=[{value:"optedOut",text:u`
|
|
265
230
|
<og-text key="offerOptOutLabel"></og-text>
|
|
266
|
-
`},...(this.frequencies||[]).map(
|
|
231
|
+
`},...(this.frequencies||[]).map(s=>({value:s,text:Ke(s,this.defaultFrequency)}))]),u`
|
|
267
232
|
<og-select
|
|
268
|
-
.options="${
|
|
269
|
-
.selected="${
|
|
270
|
-
.onChange="${({target:{value:
|
|
233
|
+
.options="${o}"
|
|
234
|
+
.selected="${r}"
|
|
235
|
+
.onChange="${({target:{value:s}})=>this.onOptinChange(s)}"
|
|
271
236
|
></og-select>
|
|
272
|
-
`}}
|
|
237
|
+
`}};n(Kr,"OptinSelect");var ms=h((t,e)=>({...z(t,e),...Xe(t,e)}),{productChangeFrequency:Rt,optoutProduct:we})(Kr);v();N();var Zr=class extends A(F){static get styles(){return w`
|
|
273
238
|
:host[hidden] {
|
|
274
239
|
display: none;
|
|
275
240
|
}
|
|
276
241
|
:host {
|
|
277
242
|
display: inline-block;
|
|
278
243
|
}
|
|
279
|
-
`}static get properties(){return{...super.properties,upcomingOrderDate:{type:String,attribute:!1},auth:
|
|
244
|
+
`}static get properties(){return{...super.properties,upcomingOrderDate:{type:String,attribute:!1},auth:Ae,isPreview:{type:Boolean,attribute:!1},target:{type:String}}}constructor(){super();this.fetchOrders=()=>0,this.addEventListener("click",this.handleClick.bind(this))}updated(e){e.has("auth")&&this.auth&&!this.upcomingOrderDate&&!this.isPreview&&this.fetchOrders()}handleClick(){let e;if(!this.target&&this.offer)e=this.offer.querySelector("og-upsell-modal"),e||(e=this.offer.shadowRoot.querySelector("og-upsell-modal"));else if(this.target)e=document.querySelector(this.target);else throw Error("You must specify a target attribute or place this element as child of og-offer");e&&e.setAttribute("show",!0)}render(){return u`
|
|
280
245
|
<slot>
|
|
281
246
|
<og-next-upcoming-order></og-next-upcoming-order>
|
|
282
247
|
</slot>
|
|
283
|
-
`}}
|
|
248
|
+
`}};n(Zr,"UpsellButton");var Ec=n(t=>({isPreview:t.previewUpsellOffer}),"mapStateToProps"),gs=h(Ec,{fetchOrders:Nt})(Zr);v();N();var Xr=class extends A(F){static get properties(){return{...super.properties,defaultFrequency:te,auth:Ae,subscribed:{type:Boolean,attribute:!1},frequency:{type:String,attribute:!1},nextUpcomingOrder:{type:Object,attribute:!1},show:{type:Boolean,attribute:"show"},offerId:{type:String}}}constructor(){super();this.createIu=()=>0,this.concludeUpsell=()=>0}render(){return u`
|
|
284
249
|
<og-modal ?show=${this.show} @close=${()=>this.close()} @confirm=${()=>this.confirm()}>
|
|
285
250
|
<div slot="content">
|
|
286
251
|
<slot>
|
|
@@ -318,7 +283,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
318
283
|
</slot>
|
|
319
284
|
</span>
|
|
320
285
|
</og-modal>
|
|
321
|
-
`}set defaultFrequency(
|
|
286
|
+
`}set defaultFrequency(e){this._defaultFrequency=e}get defaultFrequency(){let e=this.querySelector("og-select-frequency");return e?e.defaultFrequency:this._defaultFrequency}confirm(){this.createIu(this.product,this.nextUpcomingOrder.public_id,1,this.subscribed,this.frequency||this.defaultFrequency),this.close()}close(){this.concludeUpsell(),this.removeAttribute("show")}};n(Xr,"UpsellModal");var Sc=n((t,e)=>({auth:t.auth,offerId:t.offerId,subscribed:V(e.product)(t),frequency:j(e.product)(t),...$(t,e,"defaultFrequency"),nextUpcomingOrder:t.previewUpsellOffer?{public_id:"preview-order-id"}:t.nextUpcomingOrder,isPreview:t.previewUpsellOffer}),"mapStateToProps"),ys=h(Sc,{concludeUpsell:on,createIu:un})(Xr);v();N();var eo=class extends L{static get properties(){return{...super.properties,frequency:{type:String}}}handleClick(e){this.subscribed?this.optoutProduct(this.product):this.optinProduct(this.product,this.frequency||this.defaultFrequency),e.preventDefault()}render(){return u`
|
|
322
287
|
<slot name="default">
|
|
323
288
|
<button id="action-trigger" class="btn checkbox ${this.subscribed?"active":""}"></button>
|
|
324
289
|
<label for="action-trigger">
|
|
@@ -327,13 +292,13 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
327
292
|
></slot>
|
|
328
293
|
</label>
|
|
329
294
|
</slot>
|
|
330
|
-
`}}
|
|
295
|
+
`}};n(eo,"OptinToggle");var bs=h(z,{optoutProduct:we,optinProduct:Q})(eo);v();var vc=n((t,e)=>`${t}${parseInt(e,10)>1?"s":""}`,"pluralize"),to=class extends Gr(x){static get properties(){return{pluralize:{type:Number},variant:{type:Number},i18n:{type:Object,attribute:!1},locale:{type:Object,attribute:!1},key:{type:String}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._textOverride=this.innerText.trim()}getText(){return this._textOverride?this._textOverride:this.getPluralizedText(this.getVariantText(this.key))}getVariantText(e){let r={...this.i18n,...this.offer&&this.offer.locale},o=typeof r[e]!="undefined"?r[e]:"";return typeof this.variant=="undefined"?o:o[this.variant]}getPluralizedText(e){return typeof this.pluralize=="undefined"?e:e&&vc(e,this.pluralize)}render(){return u`
|
|
331
296
|
${this.getText()}
|
|
332
|
-
`}}
|
|
333
|
-
${this.label} ${
|
|
334
|
-
`}renderFallback(){this.from,this.value,this.initial;return
|
|
335
|
-
${
|
|
336
|
-
`}}
|
|
297
|
+
`}};n(to,"Text");var wc=n(t=>({i18n:t.locale||{}}),"mapStateToProps"),_s=h(wc)(to);v();var Ne=class{constructor(e){this.value=e,this.className="DiscountAmount"}toString(){return`${this.value}`}};n(Ne,"DiscountAmount");var et=class extends Ne{constructor(e){super(e);this.className="DiscountPercent"}toString(){return`${super.toString()}%`}};n(et,"DiscountPercent");var ro=class extends et{constructor(e){super(e);this.className="ShippingDiscountPercent"}toString(){return this.value===100?"free shipping":super.toString()}};n(ro,"ShippingDiscountPercent");var oo="Discount Percent",no="Discount Amount",xs="total_price",Es="shipping_total",Ss="sub_total",so=n(({field:t,object:e,type:r,value:o})=>{let i=[[new et(o),{field:xs,object:"item",type:oo}],[new Ne(o),{field:xs,object:"item",type:no}],[new ro(o),{field:Es,object:"order",type:oo}],[new Ne(o),{field:Es,object:"order",type:no}],[new et(o),{field:Ss,object:"order",type:oo}],[new Ne(o),{field:Ss,object:"order",type:no}]].find(([,a])=>a.field===t&&a.object===e&&a.type===r);return i&&i[0]},"discountBuilder");function Tc(t){return!(so(t).className!==this.incentiveClass||this.incentiveValue&&this.incentiveValue.toString()!==t.value.toString())}n(Tc,"filterIncentives");var io=class extends A(x){static get properties(){return{...super.properties,incentives:{type:Object,attribute:!1},from:{type:String},label:{type:String},initial:{type:Boolean,default:!1},value:{type:Number}}}createRenderRoot(){return this}render(){let e=this.from,r=this.value,o=this.initial?"initial":"ongoing",s=(this.incentives[o]||[]).find(Tc.bind({incentiveClass:e,incentiveValue:r}));return u`
|
|
298
|
+
${this.label} ${s?so(s):this.renderFallback()}
|
|
299
|
+
`}renderFallback(){let e=this.from,r=this.value,o=this.initial?"initial":"ongoing";return u`
|
|
300
|
+
${so({field:"sub_total",object:"order",type:"Discount Percent",value:this.value})}
|
|
301
|
+
`}};n(io,"IncentiveText");var Oc=n((t,e)=>({incentives:(t.incentives||{})[e&&e.product&&e.product.id]||{}}),"mapStateToProps"),vs=h(Oc)(io);v();N();var ao=class extends Gt(Ze){static get properties(){return{...super.properties,defaultText:{type:String,attribute:"default-text"}}}static get styles(){return w`
|
|
337
302
|
:host {
|
|
338
303
|
display: inline-block;
|
|
339
304
|
cursor: pointer;
|
|
@@ -344,13 +309,15 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
344
309
|
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
|
|
345
310
|
z-index: 1;
|
|
346
311
|
}
|
|
347
|
-
`}set defaultFrequency(
|
|
312
|
+
`}set defaultFrequency(e){this._defaultFrequency=e}get defaultFrequency(){let{options:e,isSelected:r}=this.childOptions;return this.productDefaultFrequency?this.productDefaultFrequency:r||(e.length?e[0].value:this._defaultFrequency)}get currentFrequency(){return this.frequency||this.defaultFrequency}productChangeFrequency(e,r){this.frequency=r}render(){let{options:e}=this.childOptions;e.length||(e=(this.frequencies||[]).map(o=>({value:o,text:Ke(o,this.defaultFrequency)})));let r=this.defaultFrequency;return e=e.map(({text:o,value:s})=>({text:s===r?`${o} ${(this.defaultText||"").trim()}`.trim():o,value:s})),u`
|
|
348
313
|
<og-select
|
|
349
|
-
.options="${
|
|
314
|
+
.options="${e}"
|
|
350
315
|
.selected="${this.currentFrequency}"
|
|
351
|
-
.onChange="${({target:{value:
|
|
316
|
+
.onChange="${({target:{value:o}})=>{this.productChangeFrequency(this.product,o)}}"
|
|
352
317
|
></og-select>
|
|
353
|
-
`}}
|
|
318
|
+
`}};n(ao,"SelectFrequency");var ws=h(Xe,{productChangeFrequency:Rt})(ao);v();var Cc={day:{day:"2-digit"},"day-numeric":{day:"numeric"},"day-short":{weekday:"short"},"day-long":{weekday:"long"},month:{month:"2-digit"},"month-numeric":{month:"numeric"},"month-short":{month:"short"},"month-long":{month:"long"},year:{year:"2-digit"},"year-numeric":{year:"numeric"}};var Ts=n((t,e)=>t instanceof Date?(e||"").toString().replace(/\{\{([-\w]+)\}\}/g,r=>{let o=r.replace(/[{}]/g,""),s=Cc[o];if(typeof s=="undefined")return o;let a=new Intl.DateTimeFormat("en-us",s).formatToParts(t),[{value:c}]=a;return c}):t,"formatDate");var co=class extends x{static get properties(){return{value:{type:String,reflect:!0},format:{type:String}}}createRenderRoot(){return this}render(){return u`
|
|
319
|
+
${Ts(this.value,this.format||"{{month-long}} {{day}}, {{year-numeric}}")}
|
|
320
|
+
`}};n(co,"FormattedDate");var Pc=n(t=>({value:t.previewUpsellOffer?new Date:t.nextUpcomingOrder.place}),"mapStateToProps"),Os=h(Pc)(co);v();var Rs=oe(vt());N();ce();var Cs=n((t,e)=>n(async function(o){await o({type:Ue,payload:t}),await o({type:_e}),await o(Te({in_stock:{[e]:!0},eligibility_groups:{[e]:["subscription","upsell"]},result:"success",autoship:{[e]:!0},modifiers:{},module_view:{regular:"096135e6650111e9a444bc764e106cf4"},incentives_display:{"47c01e9aacbe40389b5c7325d79091aa":{field:"sub_total",object:"order",type:"Discount Percent",value:5},e6534b9d877f41e586c37b7d8abc3a58:{field:"total_price",object:"item",type:"Discount Percent",value:10},f35e842710b24929922db4a529eecd40:{field:"total_price",object:"item",type:"Discount Percent",value:10},"5be321d7c17f4e18a757212b9a20bfcc":{field:"total_price",object:"item",type:"Discount Percent",value:1}},incentives:{[e]:{initial:["5be321d7c17f4e18a757212b9a20bfcc"],ongoing:["e6534b9d877f41e586c37b7d8abc3a58","47c01e9aacbe40389b5c7325d79091aa","f35e842710b24929922db4a529eecd40"]}}}))},"setPreviewStandardOfferThunk"),"setPreviewStandardOffer"),Rc=n((t,e)=>n(async function(o,s){await o({type:Fe,payload:t});let{merchantId:i}=s();t?(await o(Te({in_stock:{[e]:!0},module_view:{regular:"096135e6650111e9a444bc764e106cf4"},default_frequencies:{[e]:{every:1,every_period:3}},eligibility_groups:{[e]:["subscription","upsell"]},result:"success",autoship:{[e]:!0},modifiers:{}})),await o(yr({count:1,next:null,previous:null,results:[{merchant:"0e5de2bedc5e11e3a2e4bc764e106cf4",customer:"TestCust",payment:"e98e789aba0111e9b90fbc764e107990",shipping_address:"b3a5816ae59611e78937bc764e1043b0",public_id:"23322d4a83eb11ea9a1ebc764e101db1",sub_total:"206.98",tax_total:"0.00",shipping_total:"10.00",discount_total:"0.00",total:"216.98",created:"2020-04-21 11:14:11",place:"2020-06-24 00:00:00",cancelled:null,tries:0,generic_error_count:0,status:1,type:1,order_merchant_id:null,rejected_message:null,extra_data:null,locked:!1,oos_free_shipping:!1}]})),await o(gr(i,"sig_field","ts","sig"))):await o(J())},"setPreviewUpsellOfferThunk"),"setPreviewUpsellOffer"),Ps=n((t,e,r)=>async function(o,s){switch(await o({type:G}),await o({type:Ue,payload:!1}),await o({type:Fe,payload:!1}),t){case"regular":o(Cs(!0,r.product.id));break;case"upsell":o(Rc(!0,r.product.id));break;case"subscribed":o(Cs(!0,r.product.id)),o(Q(r.product,"2_2"));break;default:}},"setPreview");N();var Ac=n((...t)=>JSON.stringify(t),"memoizeKey"),Nc=(0,Rs.default)((t,e)=>Object.assign({components:e},t),Ac),lo=class extends F{static get properties(){return{...super.properties,config:{type:Object,attribute:!1},product:us,productComponents:{type:Array,attribute:"product-components"},offerId:{type:String,attribute:!1},auth:Ae,preview:{type:String,attribute:"preview",reflect:"true"},location:{type:String},autoshipByDefault:{type:Boolean,attribute:"autoship-by-default"},productDefaultFrequency:{type:String,attribute:!1},locale:{type:Object,attribute:!0},firstOrderPlaceDate:{type:String,attribute:"first-order-place-date"},productToSubscribe:{type:String,attribute:"product-to-subscribe"},subscribed:{type:Boolean,reflect:!0},frequency:{type:String,reflect:!0}}}firstUpdated(){let e=Array.from(this.getAttributeNames()).find(r=>r.startsWith("preview-"));e==="preview-standard-offer"?this.preview="regular":e==="preview-upsell-offer"?this.preview="upsell":e==="preview-subscribed-offer"&&(this.preview="subscribed")}static get styles(){return w`
|
|
354
321
|
:host[hidden] {
|
|
355
322
|
display: none;
|
|
356
323
|
}
|
|
@@ -416,9 +383,91 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
416
383
|
background-color: var(--og-confirm-button-background, #00449e);
|
|
417
384
|
color: var(--og-confirm-button-color, #fff);
|
|
418
385
|
}
|
|
419
|
-
`}static get initialTemplate(){return
|
|
386
|
+
`}static get initialTemplate(){return`
|
|
387
|
+
<og-when test="regularEligible">
|
|
388
|
+
<div>
|
|
389
|
+
|
|
390
|
+
<og-optout-button>
|
|
391
|
+
<og-text key="offerOptOutLabel"></og-text>
|
|
392
|
+
</og-optout-button>
|
|
393
|
+
</div>
|
|
394
|
+
<div>
|
|
395
|
+
<og-optin-button>
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
<og-price discount>
|
|
399
|
+
<span slot="prepend">Subscribe and get</span>
|
|
400
|
+
<span slot="append">off</span>
|
|
401
|
+
</og-price>
|
|
402
|
+
<og-price regular></og-price>
|
|
403
|
+
<og-price subscription></og-price>
|
|
404
|
+
|
|
405
|
+
</og-optin-button>
|
|
406
|
+
<og-tooltip placement="top-right">
|
|
407
|
+
<div slot="trigger">
|
|
408
|
+
<og-text key="offerTooltipTrigger"></og-text>
|
|
409
|
+
</div>
|
|
410
|
+
<div slot="content">
|
|
411
|
+
<og-text key="offerTooltipContent"></og-text>
|
|
412
|
+
</div>
|
|
413
|
+
</og-tooltip>
|
|
414
|
+
</div>
|
|
415
|
+
<div style="margin-left: 1.5em">
|
|
416
|
+
<og-text key="offerEveryLabel"></og-text>
|
|
417
|
+
<og-select-frequency>
|
|
418
|
+
<option value="3_1" selected>3 Days</option>
|
|
419
|
+
<option value="1_2">1 Week</option>
|
|
420
|
+
<option value="1_3">1 Month</option>
|
|
421
|
+
</og-select-frequency>
|
|
422
|
+
</div>
|
|
423
|
+
</og-when>
|
|
424
|
+
|
|
425
|
+
<og-when test="upsellEligible">
|
|
426
|
+
<og-when test="!upcomingOrderContainsProduct">
|
|
427
|
+
<div class="og-iu-offer">
|
|
428
|
+
<og-text key="upsellButtonLabel"></og-text>
|
|
429
|
+
<og-upsell-button>
|
|
430
|
+
<button type="button">
|
|
431
|
+
<og-text key="upsellButtonContent"></og-text>
|
|
432
|
+
<og-next-upcoming-order></og-next-upcoming-order>
|
|
433
|
+
</button>
|
|
434
|
+
</og-upsell-button>
|
|
435
|
+
<og-upsell-modal>
|
|
436
|
+
<og-text key="upsellModalContent"></og-text>
|
|
437
|
+
<br />
|
|
438
|
+
|
|
439
|
+
<og-optout-button>
|
|
440
|
+
<og-text key="upsellModalOptOutLabel"></og-text>
|
|
441
|
+
</og-optout-button>
|
|
442
|
+
|
|
443
|
+
<br />
|
|
444
|
+
|
|
445
|
+
<og-optin-button>
|
|
446
|
+
<og-text key="upsellModalOptInLabel"></og-text>
|
|
447
|
+
</og-optin-button>
|
|
448
|
+
<br />
|
|
449
|
+
|
|
450
|
+
<og-text key="offerEveryLabel"></og-text>
|
|
451
|
+
<og-select-frequency>
|
|
452
|
+
<option value="3_1" selected>3 Days</option>
|
|
453
|
+
<option value="1_2">1 Week</option>
|
|
454
|
+
<option value="1_3">1 Month</option>
|
|
455
|
+
</og-select-frequency>
|
|
456
|
+
|
|
457
|
+
<button slot="confirm" class="og-modal__btn og-modal__btn-primary">
|
|
458
|
+
<og-text key="upsellModalConfirmLabel"></og-text>
|
|
459
|
+
</button>
|
|
460
|
+
<button slot="cancel" class="og-modal__btn"><og-text key="upsellModalCancelLabel"></og-text></button>
|
|
461
|
+
</og-upsell-modal>
|
|
462
|
+
</div>
|
|
463
|
+
</og-when>
|
|
464
|
+
<og-when test="upcomingOrderContainsProduct">
|
|
465
|
+
The product is in your next upcomming order
|
|
466
|
+
</og-when>
|
|
467
|
+
</og-when>
|
|
468
|
+
`}constructor(){super();this.module="pdp",this.product={},this.productComponents=[],this.fetchOffer=()=>0,this.fetchOrders=()=>0,this.productHasChangedComponents=()=>0,this.setFirstOrderPlaceDate=()=>0,this.setProductToSubscribe=()=>0,this.productChangeFrequency=()=>0}applyTemplate(e){super.applyTemplate(e);let{locale:r}=e;this.locale=r;let o=new CustomEvent("template-changed");this.dispatchEvent(o)}updated(e){if(e.has("preview")&&this.setPreview(this.preview,e.get("preview"),this),this.frequency=this.defaultFrequency,e.has("product")&&this.product.id&&!this.isPreview&&this.fetchOffer(this.product.id),e.has("firstOrderPlaceDate")&&this.product.id&&!this.isPreview&&this.setFirstOrderPlaceDate(this.product.id,this.firstOrderPlaceDate),e.has("productToSubscribe")&&this.product.id&&!this.isPreview&&this.setProductToSubscribe(this.product.id,this.productToSubscribe),e.has("auth")&&this.auth&&!this.isPreview&&this.fetchOrders(),e.has("productComponents")){let r=Nc(this.product,this.productComponents),o=Object.assign({},this.product,{components:e.get("productComponents")});R(r,o)||this.productHasChangedComponents(r,o)}(e.has("offerId")||e.has("autoshipByDefault")||e.has("location")||e.has("product"))&&this.offerId&&this.autoshipByDefault&&this.location==="cart"&&this.product.id&&this.optinProduct&&!(this.optedin||[]).find(r=>R(r,this.product))&&this.optinProduct({...this.product,...this.productComponents.length&&{components:this.productComponents}},this.defaultFrequency)}get isPreview(){return this.preview}render(){return u`
|
|
420
469
|
<slot></slot>
|
|
421
|
-
`}get defaultFrequency(){
|
|
470
|
+
`}get defaultFrequency(){let e=this.productFrequency||this.productDefaultFrequency;if(e)return e;let r=this.querySelector("og-select-frequency");return r&&r.currentFrequency?r.currentFrequency:this.getOption("defaultFrequency")}};n(lo,"Offer");var kc=n((t,e)=>({config:t.config,auth:t.auth,offerId:((t.productOffer||{})[(e.product||{}).id]||[])[0],productFrequency:j(e.product)(t),productDefaultFrequency:Ct((e.product||{}).id)(t),...$(t,e,"autoshipByDefault",dr(t)[(e.product||{}).id]),...Qo(e.product)(t)&&{autoshipByDefault:!1},optedin:Ot(t),subscribed:V(e.product)(t),...ve(t)}),"mapStateToProps"),As=h(kc,{fetchOffer:cn,fetchOrders:Nt,productHasChangedComponents:rn,optinProduct:Q,setFirstOrderPlaceDate:mn,setProductToSubscribe:gn,setPreview:Ps})(lo);v();var Qt=class extends x{constructor(){super();this.showCancelButton=!0,this.showConfirmButton=!0}static get properties(){return{title:{type:String,attribute:!1},content:{type:String,attribute:!1},confirmText:{type:String,attribute:!1},cancelText:{type:String,attribute:!1},showCancelButton:{type:Boolean},showConfirmButton:{type:Boolean},show:{type:Boolean,attribute:"show"}}}static get styles(){return w`
|
|
422
471
|
:host[hidden] {
|
|
423
472
|
display: none;
|
|
424
473
|
}
|
|
@@ -530,7 +579,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
530
579
|
.btn {
|
|
531
580
|
cursor: pointer;
|
|
532
581
|
}
|
|
533
|
-
`}close(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("close"))}confirm(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("confirm"))}get confirmButton(){return this.showConfirmButton?
|
|
582
|
+
`}close(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("close"))}confirm(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("confirm"))}get confirmButton(){return this.showConfirmButton?u`
|
|
534
583
|
<span @click="${()=>this.confirm()}">
|
|
535
584
|
<slot name="confirm" class="btn">
|
|
536
585
|
<button class="og-modal__btn og-modal__btn-primary og-modal__confirm" @click="${()=>this.confirm()}">
|
|
@@ -538,7 +587,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
538
587
|
</button>
|
|
539
588
|
</slot>
|
|
540
589
|
</span>
|
|
541
|
-
`:
|
|
590
|
+
`:u``}get cancelButton(){return this.showCancelButton?u`
|
|
542
591
|
<span @click="${()=>this.close()}" class="btn">
|
|
543
592
|
<slot name="cancel">
|
|
544
593
|
<button class="og-modal__btn og-modal__cancel" @click="${()=>this.close()}">
|
|
@@ -546,7 +595,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
546
595
|
</button>
|
|
547
596
|
</slot>
|
|
548
597
|
</span>
|
|
549
|
-
`:
|
|
598
|
+
`:u``}render(){return this.show?u`
|
|
550
599
|
<div class="og-modal is-open" aria-hidden="true">
|
|
551
600
|
<div class="og-modal__overlay" tabindex="-1">
|
|
552
601
|
<div class="og-modal__container" role="dialog" aria-modal="true">
|
|
@@ -565,7 +614,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
565
614
|
</div>
|
|
566
615
|
</div>
|
|
567
616
|
</div>
|
|
568
|
-
`:
|
|
617
|
+
`:u``}};n(Qt,"Modal");v();var Jt=class extends x{static get styles(){return w`
|
|
569
618
|
:host {
|
|
570
619
|
display: inline-block;
|
|
571
620
|
color: inherit;
|
|
@@ -624,10 +673,10 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
624
673
|
line-height: 0.2em;
|
|
625
674
|
transform: scaleY(0.5);
|
|
626
675
|
}
|
|
627
|
-
`}static get properties(){return{options:{type:Array},selected:{type:String}}}render(){return
|
|
676
|
+
`}static get properties(){return{options:{type:Array},selected:{type:String}}}render(){return u`
|
|
628
677
|
<select @change="${this.onChange}" .value="${this.selected}">
|
|
629
|
-
${this.options.map(
|
|
630
|
-
<option value="${
|
|
678
|
+
${this.options.map(e=>u`
|
|
679
|
+
<option value="${e.value}" ?selected=${this.selected===e.value}>${e.text}</option>
|
|
631
680
|
`)}
|
|
632
681
|
</select>
|
|
633
682
|
<span>▼</span>
|
|
@@ -635,7 +684,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
635
684
|
<path d="M10.5 15l7.5 7.5 7.5-7.5z" />
|
|
636
685
|
<path d="M0 0h36v36h-36z" fill="none" />
|
|
637
686
|
</svg> -->
|
|
638
|
-
`}}
|
|
687
|
+
`}};n(Jt,"Select");v();var Kt=class extends x{static get properties(){return{placement:{type:String,default:"top"}}}static get styles(){return w`
|
|
639
688
|
:host[hidden] {
|
|
640
689
|
display: none;
|
|
641
690
|
}
|
|
@@ -782,7 +831,7 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
782
831
|
pointer-events: auto;
|
|
783
832
|
transform: translateY(0px);
|
|
784
833
|
}
|
|
785
|
-
`}connectedCallback(){super.connectedCallback(),this.showTooltip=this.showTooltip.bind(this),this.addEventListener("mouseenter",this.showTooltip)}showTooltip(){
|
|
834
|
+
`}connectedCallback(){super.connectedCallback(),this.showTooltip=this.showTooltip.bind(this),this.addEventListener("mouseenter",this.showTooltip)}showTooltip(){let r=this.shadowRoot.querySelector(".trigger").getBoundingClientRect(),o=this.shadowRoot.querySelector(".content"),s=o.getBoundingClientRect();!this.placement||this.placement==="top"||this.placement==="bottom"?o.style.left=`${(-1*s.width+r.width)/2}px`:(this.placement==="left"||this.placement==="right")&&(o.style.top=`${(-1*s.height+r.height)/2}px`)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mouseenter",this.showTooltip),this.removeEventListener("mouseout",this.hideTooltip)}render(){return u`
|
|
786
835
|
<span class="tooltip">
|
|
787
836
|
<span class="trigger">
|
|
788
837
|
<slot name="trigger">
|
|
@@ -795,9 +844,12 @@ const Q=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
795
844
|
</slot>
|
|
796
845
|
</div>
|
|
797
846
|
</span>
|
|
798
|
-
`}}
|
|
799
|
-
<slot></slot>
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
847
|
+
`}};n(Kt,"Tooltip");var{TestWizard:qc}=(ks(),Ns);function uo(){let t="og-test-wizard";customElements.get(t)||customElements.define(t,qc);let e=document.createElement(t);document.body.appendChild(e)}n(uo,"default");var po=[79,71,68,69,86],Is=n(()=>{if(window.OG_OFFERS_TEST_MODE_ENABLE)return;window.OG_OFFERS_TEST_MODE_ENABLE=!0;let t=0;document.addEventListener("keyup",async function(e){if(e.which===po[t]){let o=po[t];setTimeout(function(){t<=o&&(t=0)},5e3),t+=1,t>=po.length&&uo()}else t=0},!1)},"enable");Y();ce();v();var fo=class extends A(F){static get properties(){return{...super.properties,regular:{type:Boolean,reflect:!0},subscription:{type:Boolean,reflect:!0},discount:{type:Boolean,reflect:!0},frequency:{type:Object},productPlans:{type:Object}}}get value(){let e=this.frequency||this.offer&&this.offer.defaultFrequency,o=(this.productPlans[this.product.id]||{})[e]||[];if(!o)return"";let[s,i,a]=o;return a===s?"":this.regular?s:this.discount?i:a}render(){let e=this.value;return e?u`
|
|
848
|
+
<slot name="prepend"></slot>
|
|
849
|
+
${e}
|
|
850
|
+
<slot name="append"></slot>
|
|
851
|
+
`:u`
|
|
852
|
+
<slot></slot>
|
|
853
|
+
`}};n(fo,"Price");var Uc=n((t,e)=>({productPlans:t.productPlans,frequency:j(e.product)(t)}),"mapStateToProps"),qs=h(Uc)(fo);Is();var C,_={};function Us(t){return C.dispatch(_r(t)),_}n(Us,"setEnvironment");function Fs(t){return C.dispatch(nn(t)),_}n(Fs,"setMerchantId");function Ds(t){return C.dispatch(sn(t)),_}n(Ds,"setAuthUrl");function Ls(t=[]){return Sr(C.getState(),t)}n(Ls,"getProductsForPurchasePost");function js(t=[]){return Sr(C.getState(),t)}n(js,"getOptins");function Ms(){C.dispatch(ln())}n(Ms,"clear");function Vs(t){typeof t=="function"&&document.addEventListener("optin-changed",e=>t(e.detail))}n(Vs,"addOptinChangedCallback");function $s(){document.addEventListener("optin-changed",t=>t.stopPropagation(),!0)}n($s,"disableOptinChangedCallbacks");function Bs(){try{customElements.define("og-when",ls),customElements.define("og-text",_s),customElements.define("og-incentive-text",vs),customElements.define("og-offer",As),customElements.define("og-select-frequency",ws),customElements.define("og-optout-button",fs),customElements.define("og-optin-toggle",bs),customElements.define("og-optin-status",ps),customElements.define("og-optin-button",ds),customElements.define("og-optin-select",ms),customElements.define("og-upsell-button",gs),customElements.define("og-frequency-status",hs),customElements.define("og-modal",Qt),customElements.define("og-select",Jt),customElements.define("og-tooltip",Kt),customElements.define("og-upsell-modal",ys),customElements.define("og-next-upcoming-order",Os),customElements.define("og-price",qs)}catch(t){console.warn(t)}_.register=()=>0}n(Bs,"register");function Hs(t){return window.og=window.og||{},t===!1?delete window.og:window.og.previewMode=!0,this}n(Hs,"previewMode");function zs(t){return C.dispatch(dn(t)),_}n(zs,"config");function Gs(t){return C.dispatch(pn(t)),_}n(Gs,"setLocale");function Ws(t,e,r){return C.dispatch(fn(t,e,r)),_}n(Ws,"addTemplate");function Ys(t){return C.dispatch(hn(t)),_}n(Ys,"setTemplates");function Qs(t){return _}n(Qs,"setPublicPath");function Js(t,e,r,o=C){if(t&&e&&r){let s=[];r.product?s.push(r.product):r.cart&&Array.isArray(r.cart.products)&&(s=s.concat(r.cart.products));let{apiUrl:i}=hr({},_r(e)),{sessionId:a}=o.getState();a&&s.forEach(c=>{W.fetchOffer(i,t,a,`${c}`,"pdp")}),r.product_discounts&&typeof r.product_discounts=="object"&&o.dispatch({type:xt,payload:r.product_discounts})}}n(Js,"resolveSettings");function ho(t,e,r){return _.isReady?(console.warn("og.offers has been initialized already. Skipping."),_):(C=On(),_.store=C,_.resolveSettings(t,e,window.og_settings,C),wo(C),t&&_.setMerchantId(t),e&&_.setEnvironment(e),r&&_.setAuthUrl(r),window.addEventListener("storage",En(C)),t&&e&&(C.dispatch(kt()),C.dispatch(an()),_.register()),_.isReady=!0,_)}n(ho,"initialize");var Fc=ho;Object.assign(_,{setEnvironment:Us,setMerchantId:Fs,setAuthUrl:Ds,getProductsForPurchasePost:Ls,getOptins:js,clear:Ms,addOptinChangedCallback:Vs,disableOptinChangedCallbacks:$s,register:Bs,previewMode:Hs,config:zs,setLocale:Gs,addTemplate:Ws,setTemplates:Ys,setPublicPath:Qs,resolveSettings:Js,initialize:ho});window.OG=window.OG||{};Object.assign(window.OG,_);Object.assign(_.initialize,_);tr();return Dc;})();
|
|
854
|
+
; return lib; });
|
|
855
|
+
//# sourceMappingURL=offers.js.map
|