@ordergroove/offers 2.34.0 → 2.34.1-alpha-PR-737-9.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle-report.html +41 -31
- package/dist/examples.js +278 -121
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +138 -63
- package/dist/offers.js.map +3 -3
- package/examples/index.js +17 -1
- package/package.json +3 -3
- package/src/components/OptinButton.js +11 -2
- package/src/components/OptinStatus.js +2 -0
- package/src/components/PrepaidButton.js +98 -0
- package/src/components/PrepaidSelect.js +74 -0
- package/src/components/PrepaidStatus.js +61 -0
- package/src/components/PrepaidToggle.js +6 -36
- package/src/components/__tests__/OptinButton.spec.js +10 -0
- package/src/components/__tests__/PrepaidButton.spec.js +77 -0
- package/src/components/__tests__/PrepaidSelect.spec.js +81 -0
- package/src/components/__tests__/PrepaidToggle.spec.js +8 -16
- package/src/components/__tests__/utils.js +15 -0
- package/src/core/reducer.js +3 -1
- package/src/make-api.js +4 -0
package/dist/offers.js
CHANGED
|
@@ -8,8 +8,8 @@ else {
|
|
|
8
8
|
window.og['offers'] = factory();
|
|
9
9
|
}
|
|
10
10
|
})(()=>{
|
|
11
|
-
var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.getOwnPropertyDescriptor;var ka=Object.getOwnPropertyNames;var qa=Object.getPrototypeOf,Da=Object.prototype.hasOwnProperty;var kn=t=>ot(t,"__esModule",{value:!0}),n=(t,e)=>ot(t,"name",{value:e,configurable:!0});var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var _e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Mr=(t,e)=>{kn(t);for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},Ua=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ka(e))!Da.call(t,o)&&o!=="default"&&ot(t,o,{get:()=>e[o],enumerable:!(r=Ia(e,o))||r.enumerable});return t},ce=t=>Ua(kn(ot(t!=null?Na(qa(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Dt=_e((qt,$n)=>{(function(t,e){typeof qt=="object"&&typeof $n!="undefined"?e(qt):typeof define=="function"&&define.amd?define(["exports"],e):(t=t||self,e(t.throttleDebounce={}))})(qt,function(t){"use strict";function e(o,s,i,a){var c,l=!1,p=0;function f(){c&&clearTimeout(c)}n(f,"clearExistingTimeout");function u(){f(),l=!0}n(u,"cancel"),typeof s!="boolean"&&(a=i,i=s,s=void 0);function h(){for(var w=arguments.length,_=new Array(w),m=0;m<w;m++)_[m]=arguments[m];var S=this,C=Date.now()-p;if(l)return;function b(){p=Date.now(),i.apply(S,_)}n(b,"exec");function y(){c=void 0}n(y,"clear"),a&&!c&&b(),f(),a===void 0&&C>o?b():s!==!0&&(c=setTimeout(a?y:b,a===void 0?o-C:o))}return n(h,"wrapper"),h.cancel=u,h}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})})});function Hn(){return typeof window.og_auth!="undefined"?Ut(window.og_auth):null}async function za(t=100){return new Promise(e=>{setTimeout(()=>e(Hn()),t)})}async function Gn(t,e=Ha,r=Ga){let o;if(o=Ut(Hn())||Ut(e()),o)return o;if(t&&typeof t=="string"){let s=await fetch(t);s.status>=200&&s.status<300&&(o=e()||await(Ba(s)?s.json():Promise.resolve(r(t)).then(e)))}else o||(o=await za());if(o=Ut(o),o)return o;throw new Error("Unauthorized")}var Vn,Ha,Ut,Ga,Ba,Bn=E(()=>{Vn=/^og_auth=/,Ha=n((t=Vn)=>(document.cookie.split(/;\s*/).find(e=>e.match(t))||"").replace(Vn,""),"c"),Ut=n(t=>{if(typeof t=="object")return t;let e=String(t||"").split("|");return e.length===3?{sig_field:e[0],ts:parseInt(e[1],10),sig:e[2]}:null},"r"),Ga=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"),Ba=n(t=>(t.headers.get("content-type")||"").indexOf("application/json")!==-1,"d");n(Hn,"a");n(za,"f");n(Gn,"u")});var N,D,U,re,Fe,J,R,st,Le,Ft,zn,Lt,Se,Yn,Mt,it,jt,Wn,Me,je,$e,Jn,Kn,$t,Qn,Vt,Ve,Zn,Ht,He,at,ct,Br,Gt,Bt,Ee,le,zt,Yt,B,K,pe,xe,Wt,ve,Te,Jt,Kt,Xn,j=E(()=>{N="OPTIN_PRODUCT",D="OPTOUT_PRODUCT",U="PRODUCT_CHANGE_FREQUENCY",re="PRODUCT_CHANGE_PREPAID_SHIPMENTS",Fe="SET_MERCHANT_ID",J="REQUEST_OFFER",R="RECEIVE_OFFER",st="PRODUCT_HAS_CHANGED",Le="CREATED_SESSION_ID",Ft="SET_AUTH_URL",zn="REQUEST_AUTH",Lt="AUTHORIZE",Se="UNAUTHORIZED",Yn="REQUEST_ORDERS",Mt="RECEIVE_ORDERS",it="CART_PRODUCT_KEY_HAS_CHANGED",jt="RECEIVE_ORDER_ITEMS",Wn="FETCH_RESPONSE_ERROR",Me="SET_ENVIRONMENT_STAGING",je="SET_ENVIRONMENT_DEV",$e="SET_ENVIRONMENT_PROD",Jn="CONCLUDE_UPSELL",Kn="REQUEST_CREATE_IU_ORDER",$t="CREATE_ONE_TIME",Qn="REQUEST_CONVERT_ONE_TIME",Vt="CONVERT_ONE_TIME",Ve="CHECKOUT",Zn="RECEIVE_FETCH",Ht="SET_LOCALE",He="SET_CONFIG",at="SET_PREVIEW_STANDARD_OFFER",ct="SET_PREVIEW_UPSELL_OFFER",Br="SET_PREVIEW_PREPAID_OFFER",Gt="ADD_TEMPLATE",Bt="SET_TEMPLATES",Ee="LOCAL_STORAGE_CHANGE",le="LOCAL_STORAGE_CLEAR",zt="SET_FIRST_ORDER_PLACE_DATE",Yt="SET_PRODUCT_TO_SUBSCRIBE",B="RECEIVE_PRODUCT_PLANS",K="SETUP_PRODUCT",pe="SETUP_CART",xe="pdp",Wt="dev",ve="staging",Te="prod",Jt="static.ordergroove.com",Kt="staging.static.ordergroove.com",Xn="og-cart-updated"});var pt=_e((Ru,as)=>{var Ya="Expected a function",es="__lodash_hash_undefined__",Wa="[object Function]",Ja="[object GeneratorFunction]",Ka=/[\\^$.*+?()[\]{}|]/g,Qa=/^\[object .+?Constructor\]$/,Za=typeof window=="object"&&window&&window.Object===Object&&window,Xa=typeof self=="object"&&self&&self.Object===Object&&self,ts=Za||Xa||Function("return this")();function ec(t,e){return t==null?void 0:t[e]}n(ec,"getValue");function tc(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}n(tc,"isHostObject");var rc=Array.prototype,oc=Function.prototype,rs=Object.prototype,zr=ts["__core-js_shared__"],os=function(){var t=/[^.]+$/.exec(zr&&zr.keys&&zr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ns=oc.toString,Yr=rs.hasOwnProperty,nc=rs.toString,sc=RegExp("^"+ns.call(Yr).replace(Ka,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ic=rc.splice,ac=ss(ts,"Map"),lt=ss(Object,"create");function Oe(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(Oe,"Hash");function cc(){this.__data__=lt?lt(null):{}}n(cc,"hashClear");function lc(t){return this.has(t)&&delete this.__data__[t]}n(lc,"hashDelete");function pc(t){var e=this.__data__;if(lt){var r=e[t];return r===es?void 0:r}return Yr.call(e,t)?e[t]:void 0}n(pc,"hashGet");function uc(t){var e=this.__data__;return lt?e[t]!==void 0:Yr.call(e,t)}n(uc,"hashHas");function dc(t,e){var r=this.__data__;return r[t]=lt&&e===void 0?es:e,this}n(dc,"hashSet");Oe.prototype.clear=cc;Oe.prototype.delete=lc;Oe.prototype.get=pc;Oe.prototype.has=uc;Oe.prototype.set=dc;function Ge(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(Ge,"ListCache");function fc(){this.__data__=[]}n(fc,"listCacheClear");function hc(t){var e=this.__data__,r=Qt(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():ic.call(e,r,1),!0}n(hc,"listCacheDelete");function mc(t){var e=this.__data__,r=Qt(e,t);return r<0?void 0:e[r][1]}n(mc,"listCacheGet");function gc(t){return Qt(this.__data__,t)>-1}n(gc,"listCacheHas");function yc(t,e){var r=this.__data__,o=Qt(r,t);return o<0?r.push([t,e]):r[o][1]=e,this}n(yc,"listCacheSet");Ge.prototype.clear=fc;Ge.prototype.delete=hc;Ge.prototype.get=mc;Ge.prototype.has=gc;Ge.prototype.set=yc;function Pe(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(Pe,"MapCache");function bc(){this.__data__={hash:new Oe,map:new(ac||Ge),string:new Oe}}n(bc,"mapCacheClear");function _c(t){return Zt(this,t).delete(t)}n(_c,"mapCacheDelete");function Sc(t){return Zt(this,t).get(t)}n(Sc,"mapCacheGet");function Ec(t){return Zt(this,t).has(t)}n(Ec,"mapCacheHas");function xc(t,e){return Zt(this,t).set(t,e),this}n(xc,"mapCacheSet");Pe.prototype.clear=bc;Pe.prototype.delete=_c;Pe.prototype.get=Sc;Pe.prototype.has=Ec;Pe.prototype.set=xc;function Qt(t,e){for(var r=t.length;r--;)if(wc(t[r][0],e))return r;return-1}n(Qt,"assocIndexOf");function vc(t){if(!is(t)||Oc(t))return!1;var e=Cc(t)||tc(t)?sc:Qa;return e.test(Pc(t))}n(vc,"baseIsNative");function Zt(t,e){var r=t.__data__;return Tc(e)?r[typeof e=="string"?"string":"hash"]:r.map}n(Zt,"getMapData");function ss(t,e){var r=ec(t,e);return vc(r)?r:void 0}n(ss,"getNative");function Tc(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}n(Tc,"isKeyable");function Oc(t){return!!os&&os in t}n(Oc,"isMasked");function Pc(t){if(t!=null){try{return ns.call(t)}catch{}try{return t+""}catch{}}return""}n(Pc,"toSource");function Wr(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(Ya);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(Wr.Cache||Pe),r}n(Wr,"memoize");Wr.Cache=Pe;function wc(t,e){return t===e||t!==t&&e!==e}n(wc,"eq");function Cc(t){var e=is(t)?nc.call(t):"";return e==Wa||e==Ja}n(Cc,"isFunction");function is(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}n(is,"isObject");as.exports=Wr});var Xt,Jr,ut,dt,er,cs,ls,Rc,Ac,Nc,Ic,kc,ft,Kr,qc,ps,ht,Dc,ue,de=E(()=>{Xt=ce(pt()),Jr=n((...t)=>JSON.stringify(t),"memoizeKey"),ut=n(t=>(...e)=>fetch(...t(...e)).then(r=>r.json()),"withFetchJson"),dt=n(t=>(e,...r)=>{if(!e)throw Error("host required");let[o,s={}]=t(...r);return[`${e.replace(/\/+$/,"")}${o}`,s]},"withHost"),er=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"),cs=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"),ls=n((t=[])=>(Array.isArray(t)?t:Object.entries(t)).map(([e,r])=>[e,encodeURIComponent(r)].join("=")).join("&"),"toQuery"),Rc=n(t=>JSON.stringify([].concat(t).map(e=>typeof e=="object"?e.id:e).filter(e=>e)),"toProductId"),Ac=(0,Xt.default)(ut(dt((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=ls([["session_id",e],["page_type",1],["p",Rc(r)],["module_view",JSON.stringify(["regular"])]]);return[`/offer/${t}/${o}?${s}`]})),Jr),Nc=(0,Xt.default)(ut(dt(er((t=1,e="place")=>[`/orders/?${ls([["status",t],["ordering",e],["exclude_prepaid_orders","true"]])}`]))),Jr),Ic=(0,Xt.default)(ut(dt(er(t=>{if(!t)throw Error("orderId required");return[`/items/?order=${t}`]}))),Jr),kc=ut(dt(er(cs((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}}]})))),ft=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"),Kr=n(t=>t.match(/^\d+_\d$/),"isFrequencyValid"),qc=n((t,e)=>String.prototype.localeCompare.call(t&&t.split("_").reverse().join("_"),e&&e.split("_").reverse().join("_")),"compareFrequencies"),ps=n(t=>[...new Set(t&&t.split(/\s+/))].filter(Kr).sort(qc),"parseFrequenciesList"),ht=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"),Dc=ut(dt(er(cs((t,e,r)=>{if(!t)throw Error("item required");if(!e)throw Error("frequency required");let o=ft(e);if(!o)throw Error("invalid frequency");return["/subscriptions/create_from_item/",{body:{item:t.public_id,offer:r,...o}}]})))),ue={fetchOffer:Ac,fetchOrders:Nc,fetchItems:Ic,createOneTime:kc,convertOneTimeToSubscription:Dc}});var Qr,L,mt=E(()=>{I();Qr=gt(),L={shopify:typeof window.Shopify!="undefined",shopify_selling_plans:typeof(Qr==null?void 0:Qr.dataset.shopifySellingPlans)!="undefined"}});function Uc(t,e){return t===e}function Fc(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}function Lc(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Uc,r=null,o=null;return function(){return Fc(e,r,arguments)||(o=t.apply(null,arguments)),r=arguments,o}}function Mc(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}function jc(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(),p=Mc(i),f=t.apply(void 0,[function(){return c++,l.apply(null,arguments)}].concat(r)),u=t(function(){for(var h=[],w=p.length,_=0;_<w;_++)h.push(p[_].apply(null,arguments));return f.apply(null,h)});return u.resultFunc=l,u.dependencies=p,u.recomputations=function(){return c},u.resetRecomputations=function(){return c=0},u}}var Q,us=E(()=>{n(Uc,"defaultEqualityCheck");n(Fc,"areArgumentsShallowlyEqual");n(Lc,"defaultMemoize");n(Mc,"getDependencies");n(jc,"createSelectorCreator");Q=jc(Lc)});function $c(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}function Vc(t,e,r){let o=ht(r);return L.shopify_selling_plans?ee(t,e,o):o}var z,k,yt,ds,Zr,Hc,Gc,Bc,zc,Yc,Z,tr,fs,rr,or,X,nr,sr,Be,Xr,H,ze,F=E(()=>{us();z=ce(pt());de();mt();I();z.default.Cache=Map;n($c,"arraysEqual");n(Vc,"resolveFrequency");k=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))||$c((t.components||[]).sort(),(e.components||[]).sort()))),"isSameProduct"),yt=n(t=>t.optedin||[],"optedinSelector"),ds=n(t=>t.optedout||[],"optedoutSelector"),Zr=n(t=>t.autoshipByDefault||{},"autoshipSelector"),Hc=n(t=>t.defaultFrequencies||{},"defaultFrequenciesSelector"),Gc=n(t=>{var e;return((e=t==null?void 0:t.config)==null?void 0:e.frequencies)||[]},"sellingPlansSelector"),Bc=n(t=>{var e;return((e=t==null?void 0:t.config)==null?void 0:e.frequenciesEveryPeriod)||[]},"frequenciesEveryPeriodSelector"),zc=n(t=>{var e;return((e=t==null?void 0:t.config)==null?void 0:e.prepaidSellingPlans)||[]},"prepaidSellingPlansSelector"),Yc=n(t=>(t==null?void 0:t.prepaidShipmentsSelected)||{},"prepaidShipmentsSelectedSelector"),Z=(0,z.default)(t=>Q(yt,ds,Zr,(e,r,o)=>{let s=e.find(i=>k(t,i));return s||(r.find(i=>k(t,i))?!1:t&&o[t.id]?{id:t.id}:!1)}),t=>JSON.stringify(t)),tr=(0,z.default)(t=>Q(yt,e=>{let r=e.find(o=>k(t,o));return r||!1}),t=>JSON.stringify(t)),fs=(0,z.default)(t=>Q(yt,e=>e.some(r=>k(t,r)&&r.prepaidShipments)),t=>JSON.stringify(t)),rr=(0,z.default)(t=>Q(Yc,e=>e[t.id]||null),t=>JSON.stringify(t)),or=(0,z.default)(t=>Q(ds,e=>e.find(r=>k(t,r)))),X=(0,z.default)(t=>Q(Z(t),e=>e&&e.frequency||null)),nr=(0,z.default)(t=>Q(Z(t),e=>e&&e.prepaidShipments||null)),sr=(0,z.default)(t=>Q(zc,e=>{var o;return(((o=e[x(t)])==null?void 0:o.map(({numberShipments:s})=>s))||[]).sort((s,i)=>s-i)})),Be=(0,z.default)(t=>Q(Hc,Gc,Bc,(e,r,o)=>e[x(t)]&&Vc(r,o,e[x(t)])||null)),Xr=n(t=>t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),"kebabCase"),H=n((t,e,r,o)=>({[r]:t.config&&t.config[r]||e&&e.hasAttribute&&e.hasAttribute(Xr(r))&&e[r]||e.offer&&typeof(e.offer[r]!=="undefined")&&e.offer[r]||o}),"configSelector"),ze=n(t=>({templates:t.templates||[]}),"templatesSelector")});function ir(t){document.readyState==="loading"?window.addEventListener("DOMContentLoaded",t):t()}function gt(){return document.querySelector([`script[src^="https://${Jt}"]`,`script[src^="https://${Kt}"]`,`script[src^="http://${Jt}"]`,`script[src^="http://${Kt}"]`].join(","))}function eo(){let t=gt();if(!t)return[];let e=new URL(t.src),r=e.host.startsWith(ve)?ve:Te,o=e.pathname.split("/")[1];return!r&&!o?[]:[o,r,t]}function ms(t){if(t.isReady())return;console.info("OG offers are auto initializing");let[e,r]=eo();if(!r&&!e)return;let o=document.createElement("script");o.onload=()=>console.info("OG pull initialization chunk for merchant",e,r),o.onerror=()=>t.initialize(e,r),o.src=`${window.location.protocol}//${r===Te?Jt:Kt}/${e}/main.js?initOnly=true`,document.head.appendChild(o)}function ys(t){let e=document.cookie.match(`(^|;) ?${t}=([^;]*)(;|$)`);return e?e[2]:null}function bs(t,e,r){let o=t.querySelector(`[name="${e}"]`);if(o&&!r){o.remove();return}!o&&r&&(o=document.createElement("input"),o.type="hidden",o.name=e,t.appendChild(o)),o&&(o.value=r)}function We(t,e){let[[r],o]=t.reduce((s,i)=>s[k(e,i)?0:1].push(i)&&s,[[],[]]);return[r||{},o||[]]}var x,hs,to,gs,Ye,we,ar,ee,I=E(()=>{mt();j();F();n(ir,"onReady");n(gt,"getMainJs");n(eo,"resolveEnvAndMerchant");x=n(t=>{var r;if(!t)return"";let e=`${t.id||t}`;return((r=L)==null?void 0:r.shopify_selling_plans)&&(e=e.split(":")[0]),e},"safeProductId"),hs=n((t,e)=>{var r;if(L.shopify_selling_plans){let o=(r=e.frequencies)==null?void 0:r.indexOf(t);if(o>=0&&e.frequenciesEveryPeriod[o])return e.frequenciesEveryPeriod[o]}return t},"safeOgFrequency"),to=n((t,e)=>{var o;if(!`${t}`.includes("_"))return t;let r=(o=e.frequenciesEveryPeriod)==null?void 0:o.indexOf(t);return r>=0&&e.frequenciesEveryPeriod[r]?e.frequencies[r]:t},"frequencyToSellingPlan");n(ms,"autoInitializeOffers");gs=n(t=>{document.cookie=`${t}=; expires=Thu, 01 Jan 1970 00:00:01 GMT;`},"clearCookie");n(ys,"getCookieValue");Ye=n(t=>!!(t&&(t==null?void 0:t.includes("_"))),"isOgFrequency"),we=n((t=[])=>(t==null?void 0:t[0])||null,"getFirstSellingPlan"),ar=n((t=[],e=[])=>{var r;return!!(((r=L)==null?void 0:r.shopify_selling_plans)&&t.length&&e.length)},"hasShopifySellingPlans"),ee=n((t,e,r)=>{if(t.length!==e.length)return null;let o=e.findIndex(s=>s===r);return o>=0?t[o]:null},"mapFrequencyToSellingPlan");n(bs,"getOrCreateHidden");n(We,"getMatchingProductIfExists")});var oe,Je,_s,cr,Ss,Es,xs,ro,Wc,bt,fe,vs,lr,Ts,Jc,oo,no,pr,so,Os,Ce,io,Kc,Ps,ws,Qc,Zc,Xc,el,Cs,Rs,As,Ns,Is,ks,qs,q=E(()=>{Bn();j();de();I();oe=n((t,e,r)=>({type:N,payload:{product:t,frequency:e,offer:r}}),"optinProduct"),Je=n((t,e)=>({type:D,payload:{product:t,offer:e}}),"optoutProduct"),_s=n((t,e)=>({type:st,payload:{newProduct:t,product:e}}),"productHasChangedComponents"),cr=n((t,e,r)=>({type:U,payload:{product:t,frequency:e,offer:r}}),"productChangeFrequency"),Ss=n((t,e,r)=>({type:re,payload:{product:t,prepaidShipments:e,offer:r}}),"productChangePrepaidShipments"),Es=n(t=>({type:Jn,payload:{product:t}}),"concludeUpsell"),xs=n(t=>({type:Fe,payload:t}),"setMerchantId"),ro=n(t=>({type:Le,payload:`${t}.${Math.floor(Math.random()*999999)}.${Math.round(new Date().getTime()/1e3)}`}),"createSessionId"),Wc=n(t=>({type:zn,payload:t}),"requestAuth"),bt=n((t,e,r,o)=>({type:Lt,payload:{public_id:t,sig_field:e,ts:r,sig:o}}),"authorize"),fe=n(t=>({type:Se,payload:t}),"unauthorized"),vs=n(t=>({type:Ft,payload:t}),"setAuthUrl"),lr=n(t=>({type:Zn,payload:t}),"fetchDone"),Ts=n((t=Gn)=>n(function(r,o){if(window.og&&window.og.previewMode)return r(fe({message:"Offers are running in preview mode"}));let{merchantId:s,authUrl:i}=o(),a=Wc(i);return r(a),t(i).then(({sig_field:c,ts:l,sig:p})=>r(bt(s,c,l,p)),c=>r(fe(c))).finally(()=>r(lr(a)))},"fetchAuthThunk"),"fetchAuth"),Jc=n((t,e)=>({type:Yn,payload:{status:t,ordering:e}}),"requestOrders"),oo=n(t=>({type:Mt,payload:t}),"receiveOrders"),no=n(t=>({type:jt,payload:t}),"receiveItems"),pr=n((t=1,e="place")=>n(function(o,s){let{environment:{legoUrl:i},auth:a}=s();if(!a)return o(fe("No auth set."));let c=Jc(t,e);return o(c),ue.fetchOrders(i,a,t,e).then(l=>{if(l.results){o(oo(l));let p=(l.results[0]||{}).public_id;if(p)return ue.fetchItems(i,a,p).then(f=>o(no(f)))}return o(fe(l.detail)),null},l=>o(fe(l))).finally(()=>o(lr(c)))},"fetchOrdersThunk"),"fetchOrders"),so=n(t=>{switch(t){case Wt:return{type:je,payload:t};case ve:return{type:Me,payload:t};case Te:return{type:$e,payload:t};default:throw new Error(`${t} is not a supported environment`)}},"setEnvironment"),Os=n(()=>(t,e)=>{let{merchantId:r,sessionId:o}=e();return(!o||r&&!o.startsWith(r))&&t(ro(r)),o},"requestSessionId"),Ce=n((t,e)=>({type:R,payload:{...t,offer:e}}),"receiveOffer"),io=n(t=>({type:Wn,payload:t}),"fetchResponseError"),Kc=n((t,e=xe,r)=>({type:J,payload:{product:t,module:e,offer:r}}),"requestOffer"),Ps=n((t,e=xe,r)=>n(function(s,i){let{merchantId:a,sessionId:c,environment:{apiUrl:l}}=i(),p=Kc(t,e,r);s(p);let f=x(t);return f?ue.fetchOffer(l,a,c,f,e).then(u=>s(Ce(u,r)),u=>s(io(u))).finally(()=>s(lr(p))):null},"fetchOfferThunk"),"fetchOffer"),ws=n(()=>({type:Ve}),"checkout"),Qc=n((t,e,r,o)=>({type:Kn,payload:{product:t,order:e,quantity:r,offerId:o}}),"requestCreateOneTime"),Zc=n(t=>({type:$t,payload:t}),"receiveCreateOneTime"),Xc=n((t,e)=>({type:Qn,payload:{item:t,frequency:e}}),"requestConvertOneTimeToSubscription"),el=n((t,e)=>({type:Vt,payload:{response:t,product:e}}),"receiveConvertOneTime"),Cs=n((t,e,r,o=!1,s=null)=>n(function(a,c){let{auth:l,config:p,environment:{legoUrl:f},previewUpsellOffer:u,offerId:h}=c();if(!l)return a(fe("No auth set."));let w=hs(s,p),_=Qc(t,e,r,h);return a(_),(u?Promise.resolve({legoUrl:f,product:t,order:e,quantity:r,offer:h}):ue.createOneTime(f,l,t.id,e,r,h)).then(m=>(a(Zc(m)),o?(a(Xc(m,w)),(u?Promise.resolve({item:m,frequency:w}):ue.convertOneTimeToSubscription(f,l,m,w,h)).then(S=>a(el(S,t)),S=>a(io(S)))):m),m=>a(io(m))).finally(()=>a(lr(_)))},"createIuThunk"),"createIu"),Rs=n(t=>({type:Ht,payload:t}),"setLocale"),As=n(t=>({type:He,payload:t}),"setConfig"),Ns=n((t,e,r)=>({type:Gt,payload:{selector:t,markup:e,config:r}}),"addTemplate"),Is=n(t=>({type:Bt,payload:t}),"setTemplates"),ks=n((t,e)=>({type:zt,payload:{product:t,firstOrderPlaceDate:e}}),"setFirstOrderPlaceDate"),qs=n((t,e)=>({type:Yt,payload:{product:t,productToSubscribe:e}}),"setProductToSubscribe")});var uo,Re,Ae=E(()=>{uo=typeof window!="undefined"&&window.customElements!=null&&window.customElements.polyfillWrapFlushCallback!==void 0,Re=n((t,e,r=null)=>{for(;e!==r;){let o=e.nextSibling;t.removeChild(e),e=o}},"removeNodes")});var G,fo,Qs,Qe,Ne,Zs,St,te,fr,he=E(()=>{G=`{{lit-${String(Math.random()).slice(2)}}}`,fo=`<!--${G}-->`,Qs=new RegExp(`${G}|${fo}`),Qe="$lit$",Ne=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:p,values:{length:f}}=e;for(;l<f;){let u=i.nextNode();if(u===null){i.currentNode=s.pop();continue}if(c++,u.nodeType===1){if(u.hasAttributes()){let h=u.attributes,{length:w}=h,_=0;for(let m=0;m<w;m++)Zs(h[m].name,Qe)&&_++;for(;_-- >0;){let m=p[l],S=fr.exec(m)[2],C=S.toLowerCase()+Qe,b=u.getAttribute(C);u.removeAttribute(C);let y=b.split(Qs);this.parts.push({type:"attribute",index:c,name:S,strings:y}),l+=y.length-1}}u.tagName==="TEMPLATE"&&(s.push(u),i.currentNode=u.content)}else if(u.nodeType===3){let h=u.data;if(h.indexOf(G)>=0){let w=u.parentNode,_=h.split(Qs),m=_.length-1;for(let S=0;S<m;S++){let C,b=_[S];if(b==="")C=te();else{let y=fr.exec(b);y!==null&&Zs(y[2],Qe)&&(b=b.slice(0,y.index)+y[1]+y[2].slice(0,-Qe.length)+y[3]),C=document.createTextNode(b)}w.insertBefore(C,u),this.parts.push({type:"node",index:++c})}_[m]===""?(w.insertBefore(te(),u),o.push(u)):u.data=_[m],l+=m}}else if(u.nodeType===8)if(u.data===G){let h=u.parentNode;(u.previousSibling===null||c===a)&&(c++,h.insertBefore(te(),u)),a=c,this.parts.push({type:"node",index:c}),u.nextSibling===null?u.data="":(o.push(u),c--),l++}else{let h=-1;for(;(h=u.data.indexOf(G,h+1))!==-1;)this.parts.push({type:"node",index:-1}),l++}}for(let u of o)u.parentNode.removeChild(u)}};n(Ne,"Template");Zs=n((t,e)=>{let r=t.length-e.length;return r>=0&&t.slice(r)===e},"endsWith"),St=n(t=>t.index!==-1,"isTemplatePartActive"),te=n(()=>document.createComment(""),"createMarker"),fr=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/});function mo(t,e){let{element:{content:r},parts:o}=t,s=document.createTreeWalker(r,ho,null,!1),i=Et(o),a=o[i],c=-1,l=0,p=[],f=null;for(;s.nextNode();){c++;let u=s.currentNode;for(u.previousSibling===f&&(f=null),e.has(u)&&(p.push(u),f===null&&(f=u)),f!==null&&l++;a!==void 0&&a.index===c;)a.index=f!==null?-1:a.index-l,i=Et(o,i),a=o[i]}p.forEach(u=>u.parentNode.removeChild(u))}function Xs(t,e,r=null){let{element:{content:o},parts:s}=t;if(r==null){o.appendChild(e);return}let i=document.createTreeWalker(o,ho,null,!1),a=Et(s),c=0,l=-1;for(;i.nextNode();)for(l++,i.currentNode===r&&(c=cl(e),r.parentNode.insertBefore(e,r));a!==-1&&s[a].index===l;){if(c>0){for(;a!==-1;)s[a].index+=c,a=Et(s,a);return}a=Et(s,a)}}var ho,cl,Et,ei=E(()=>{he();ho=133;n(mo,"removeNodesFromTemplate");cl=n(t=>{let e=t.nodeType===11?0:1,r=document.createTreeWalker(t,ho,null,!1);for(;r.nextNode();)e++;return e},"countNodes"),Et=n((t,e=-1)=>{for(let r=e+1;r<t.length;r++){let o=t[r];if(St(o))return r}return-1},"nextActiveIndexInTemplateParts");n(Xs,"insertNodeIntoTemplate")});var ll,Ie,go=E(()=>{ll=new WeakMap,Ie=n(t=>typeof t=="function"&&ll.has(t),"isDirective")});var $,hr,yo=E(()=>{$={},hr={}});var me,mr=E(()=>{Ae();he();me=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=uo?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],!St(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 p=this.processor.handleTextExpression(this.options);p.insertAfterNode(l.previousSibling),this.__parts.push(p)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,c.name,c.strings,this.options));i++}return uo&&(document.adoptNode(e),customElements.upgrade(e)),e}};n(me,"TemplateInstance")});var ti,ul,ne,gr=E(()=>{Ae();he();ti=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),ul=` ${G} `,ne=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=fr.exec(i);c===null?r+=i+(o?ul:fo):r+=i.substr(0,c.index)+c[1]+c[2]+Qe+c[3]+G}return r+=this.strings[e],r}getTemplateElement(){let e=document.createElement("template"),r=this.getHTML();return ti!==void 0&&(r=ti.createHTML(r)),e.innerHTML=r,e}};n(ne,"TemplateResult")});var yr,br,Ze,xt,se,vt,Tt,_r,ri,Ot,dl,Sr=E(()=>{go();Ae();yo();mr();gr();he();yr=n(t=>t===null||!(typeof t=="object"||typeof t=="function"),"isPrimitive"),br=n(t=>Array.isArray(t)||!!(t&&t[Symbol.iterator]),"isIterable"),Ze=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 xt(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"||!br(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(yr(c)||!br(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(Ze,"AttributeCommitter");xt=class{constructor(e){this.value=void 0,this.committer=e}setValue(e){e!==$&&(!yr(e)||e!==this.value)&&(this.value=e,Ie(e)||(this.committer.dirty=!0))}commit(){for(;Ie(this.value);){let e=this.value;this.value=$,e(this)}this.value!==$&&this.committer.commit()}};n(xt,"AttributePart");se=class{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(te()),this.endNode=e.appendChild(te())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=te()),e.__insert(this.endNode=te())}insertAfterPart(e){e.__insert(this.startNode=te()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(this.startNode.parentNode===null)return;for(;Ie(this.__pendingValue);){let r=this.__pendingValue;this.__pendingValue=$,r(this)}let e=this.__pendingValue;e!==$&&(yr(e)?e!==this.value&&this.__commitText(e):e instanceof ne?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):br(e)?this.__commitIterable(e):e===hr?(this.value=hr,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 me&&this.value.template===r)this.value.update(e.values);else{let o=new me(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 se(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){Re(this.startNode.parentNode,e.nextSibling,this.endNode)}};n(se,"NodePart");vt=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(;Ie(this.__pendingValue);){let r=this.__pendingValue;this.__pendingValue=$,r(this)}if(this.__pendingValue===$)return;let e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=$}};n(vt,"BooleanAttributePart");Tt=class extends Ze{constructor(e,r,o){super(e,r,o);this.single=o.length===2&&o[0]===""&&o[1]===""}_createPart(){return new _r(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}};n(Tt,"PropertyCommitter");_r=class extends xt{};n(_r,"PropertyPart");ri=!1;(()=>{try{let t={get capture(){return ri=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch{}})();Ot=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(;Ie(this.__pendingValue);){let i=this.__pendingValue;this.__pendingValue=$,i(this)}if(this.__pendingValue===$)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=dl(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=$}handleEvent(e){typeof this.value=="function"?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}};n(Ot,"EventPart");dl=n(t=>t&&(ri?{capture:t.capture,passive:t.passive,once:t.once}:t.capture),"getOptions")});function bo(t){let e=ke.get(t.type);e===void 0&&(e={stringsArray:new WeakMap,keyString:new Map},ke.set(t.type,e));let r=e.stringsArray.get(t.strings);if(r!==void 0)return r;let o=t.strings.join(G);return r=e.keyString.get(o),r===void 0&&(r=new Ne(t,t.getTemplateElement()),e.keyString.set(o,r)),e.stringsArray.set(t.strings,r),r}var ke,Er=E(()=>{he();n(bo,"templateFactory");ke=new Map});var ge,_o,So=E(()=>{Ae();Sr();Er();ge=new WeakMap,_o=n((t,e,r)=>{let o=ge.get(e);o===void 0&&(Re(e,e.firstChild),ge.set(e,o=new se(Object.assign({templateFactory:bo},r))),o.appendInto(e)),o.setValue(t),o.commit()},"render")});var xr,Eo,xo=E(()=>{Sr();xr=class{handleAttributeExpressions(e,r,o,s){let i=r[0];return i==="."?new Tt(e,r.slice(1),o).parts:i==="@"?[new Ot(e,r.slice(1),s.eventContext)]:i==="?"?[new vt(e,r.slice(1),o)]:new Ze(e,r,o).parts}handleTextExpression(e){return new se(e)}};n(xr,"DefaultTemplateProcessor");Eo=new xr});var d,vo=E(()=>{xo();gr();xo();go();Ae();yo();Sr();So();Er();mr();gr();he();typeof window!="undefined"&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");d=n((t,...e)=>new ne(t,e,"html",Eo),"html")});var ni,vr,hl,ml,gl,si,yl,ii,ai=E(()=>{Ae();ei();So();Er();mr();he();vo();ni=n((t,e)=>`${t}--${e}`,"getTemplateCacheKey"),vr=!0;typeof window.ShadyCSS=="undefined"?vr=!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."),vr=!1);hl=n(t=>e=>{let r=ni(e.type,t),o=ke.get(r);o===void 0&&(o={stringsArray:new WeakMap,keyString:new Map},ke.set(r,o));let s=o.stringsArray.get(e.strings);if(s!==void 0)return s;let i=e.strings.join(G);if(s=o.keyString.get(i),s===void 0){let a=e.getTemplateElement();vr&&window.ShadyCSS.prepareTemplateDom(a,t),s=new Ne(e,a),o.keyString.set(i,s)}return o.stringsArray.set(e.strings,s),s},"shadyTemplateFactory"),ml=["html","svg"],gl=n(t=>{ml.forEach(e=>{let r=ke.get(ni(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)}),mo(o,i)})})},"removeStylesFromLitTemplates"),si=new Set,yl=n((t,e,r)=>{si.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 p=0;p<i;p++){let f=s[p];f.parentNode.removeChild(f),a.textContent+=f.textContent}gl(t);let c=o.content;r?Xs(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 p=new Set;p.add(a),mo(r,p)}},"prepareTemplateStyles"),ii=n((t,e,r)=>{if(!r||typeof r!="object"||!r.scopeName)throw new Error("The `scopeName` option is required.");let o=r.scopeName,s=ge.has(e),i=vr&&e.nodeType===11&&!!e.host,a=i&&!si.has(o),c=a?document.createDocumentFragment():e;if(_o(t,c,Object.assign({templateFactory:hl(o)},r)),a){let l=ge.get(c);ge.delete(c);let p=l.value instanceof me?l.value.template:void 0;yl(o,c,p),Re(e,e.firstChild),e.appendChild(c),ge.set(e,l)}!s&&i&&window.ShadyCSS.styleElement(e.host)},"render")});var ci,To,li,Oo,Po,wo,Co,Ro,Ao,Pt,No=E(()=>{window.JSCompiler_renameProperty=(t,e)=>t;To={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}},li=n((t,e)=>e!==t&&(e===e||t===t),"notEqual"),Oo={attribute:!0,type:String,converter:To,reflect:!1,hasChanged:li},Po=1,wo=1<<2,Co=1<<3,Ro=1<<4,Ao="finalized",Pt=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=Oo){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)||Oo}static finalize(){let e=Object.getPrototypeOf(this);if(e.hasOwnProperty(Ao)||e.finalize(),this[Ao]=!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=li){return o(e,r)}static _propertyValueFromAttribute(e,r){let o=r.type,s=r.converter||To,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||To.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=Oo){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|Co,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._updateState=this._updateState&~Co}}_attributeToProperty(e,r){if(this._updateState&Co)return;let o=this.constructor,s=o._attributeToPropertyMap.get(e);if(s!==void 0){let i=o.getPropertyOptions(s);this._updateState=this._updateState|Ro,this[s]=o._propertyValueFromAttribute(r,i),this._updateState=this._updateState&~Ro}}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&Ro)&&(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|wo;try{await this._updatePromise}catch{}let e=this.performUpdate();return e!=null&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return this._updateState&wo}get hasUpdated(){return this._updateState&Po}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&Po||(this._updateState=this._updateState|Po,this.firstUpdated(r)),this.updated(r))}_markUpdated(){this._changedProperties=new Map,this._updateState=this._updateState&~wo}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(Pt,"UpdatingElement");ci=Ao;Pt[ci]=!0});var pi,mf,ui=E(()=>{pi=Element.prototype,mf=pi.msMatchesSelector||pi.webkitMatchesSelector});var Tr,Io,wt,di,bl,v,ko=E(()=>{Tr=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Io=Symbol(),wt=class{constructor(e,r){if(r!==Io)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return this._styleSheet===void 0&&(Tr?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}};n(wt,"CSSResult");di=n(t=>new wt(String(t),Io),"unsafeCSS"),bl=n(t=>{if(t instanceof wt)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"),
|
|
11
|
+
var lib=(()=>{var Ua=Object.create;var ct=Object.defineProperty;var Fa=Object.getOwnPropertyDescriptor;var La=Object.getOwnPropertyNames;var Ma=Object.getPrototypeOf,ja=Object.prototype.hasOwnProperty;var Fn=t=>ct(t,"__esModule",{value:!0}),n=(t,e)=>ct(t,"name",{value:e,configurable:!0});var v=(t,e)=>()=>(t&&(e=t(t=0)),e);var Oe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$r=(t,e)=>{Fn(t);for(var r in e)ct(t,r,{get:e[r],enumerable:!0})},$a=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of La(e))!ja.call(t,o)&&o!=="default"&&ct(t,o,{get:()=>e[o],enumerable:!(r=Fa(e,o))||r.enumerable});return t},de=t=>$a(Fn(ct(t!=null?Ua(Ma(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var jt=Oe((Mt,Bn)=>{(function(t,e){typeof Mt=="object"&&typeof Bn!="undefined"?e(Mt):typeof define=="function"&&define.amd?define(["exports"],e):(t=t||self,e(t.throttleDebounce={}))})(Mt,function(t){"use strict";function e(o,s,i,a){var c,l=!1,p=0;function f(){c&&clearTimeout(c)}n(f,"clearExistingTimeout");function d(){f(),l=!0}n(d,"cancel"),typeof s!="boolean"&&(a=i,i=s,s=void 0);function h(){for(var w=arguments.length,E=new Array(w),m=0;m<w;m++)E[m]=arguments[m];var x=this,C=Date.now()-p;if(l)return;function _(){p=Date.now(),i.apply(x,E)}n(_,"exec");function y(){c=void 0}n(y,"clear"),a&&!c&&_(),f(),a===void 0&&C>o?_():s!==!0&&(c=setTimeout(a?y:_,a===void 0?o-C:o))}return n(h,"wrapper"),h.cancel=d,h}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})})});function Wn(){return typeof window.og_auth!="undefined"?$t(window.og_auth):null}async function Qa(t=100){return new Promise(e=>{setTimeout(()=>e(Wn()),t)})}async function Yn(t,e=Ya,r=Ja){let o;if(o=$t(Wn())||$t(e()),o)return o;if(t&&typeof t=="string"){let s=await fetch(t);s.status>=200&&s.status<300&&(o=e()||await(Ka(s)?s.json():Promise.resolve(r(t)).then(e)))}else o||(o=await Qa());if(o=$t(o),o)return o;throw new Error("Unauthorized")}var zn,Ya,$t,Ja,Ka,Jn=v(()=>{zn=/^og_auth=/,Ya=n((t=zn)=>(document.cookie.split(/;\s*/).find(e=>e.match(t))||"").replace(zn,""),"c"),$t=n(t=>{if(typeof t=="object")return t;let e=String(t||"").split("|");return e.length===3?{sig_field:e[0],ts:parseInt(e[1],10),sig:e[2]}:null},"r"),Ja=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"),Ka=n(t=>(t.headers.get("content-type")||"").indexOf("application/json")!==-1,"d");n(Wn,"a");n(Qa,"f");n(Yn,"u")});var I,U,F,se,Ve,K,R,pt,He,Vt,Kn,Ht,Pe,Qn,Gt,ut,Bt,Zn,Ge,Be,ze,Xn,es,zt,ts,Wt,We,rs,Yt,Ye,dt,ft,Wr,Jt,Kt,Te,fe,Qt,Zt,z,Q,he,we,Xt,Ce,Re,er,tr,os,j=v(()=>{I="OPTIN_PRODUCT",U="OPTOUT_PRODUCT",F="PRODUCT_CHANGE_FREQUENCY",se="PRODUCT_CHANGE_PREPAID_SHIPMENTS",Ve="SET_MERCHANT_ID",K="REQUEST_OFFER",R="RECEIVE_OFFER",pt="PRODUCT_HAS_CHANGED",He="CREATED_SESSION_ID",Vt="SET_AUTH_URL",Kn="REQUEST_AUTH",Ht="AUTHORIZE",Pe="UNAUTHORIZED",Qn="REQUEST_ORDERS",Gt="RECEIVE_ORDERS",ut="CART_PRODUCT_KEY_HAS_CHANGED",Bt="RECEIVE_ORDER_ITEMS",Zn="FETCH_RESPONSE_ERROR",Ge="SET_ENVIRONMENT_STAGING",Be="SET_ENVIRONMENT_DEV",ze="SET_ENVIRONMENT_PROD",Xn="CONCLUDE_UPSELL",es="REQUEST_CREATE_IU_ORDER",zt="CREATE_ONE_TIME",ts="REQUEST_CONVERT_ONE_TIME",Wt="CONVERT_ONE_TIME",We="CHECKOUT",rs="RECEIVE_FETCH",Yt="SET_LOCALE",Ye="SET_CONFIG",dt="SET_PREVIEW_STANDARD_OFFER",ft="SET_PREVIEW_UPSELL_OFFER",Wr="SET_PREVIEW_PREPAID_OFFER",Jt="ADD_TEMPLATE",Kt="SET_TEMPLATES",Te="LOCAL_STORAGE_CHANGE",fe="LOCAL_STORAGE_CLEAR",Qt="SET_FIRST_ORDER_PLACE_DATE",Zt="SET_PRODUCT_TO_SUBSCRIBE",z="RECEIVE_PRODUCT_PLANS",Q="SETUP_PRODUCT",he="SETUP_CART",we="pdp",Xt="dev",Ce="staging",Re="prod",er="static.ordergroove.com",tr="staging.static.ordergroove.com",os="og-cart-updated"});var mt=Oe((Fu,us)=>{var Za="Expected a function",ns="__lodash_hash_undefined__",Xa="[object Function]",ec="[object GeneratorFunction]",tc=/[\\^$.*+?()[\]{}|]/g,rc=/^\[object .+?Constructor\]$/,oc=typeof window=="object"&&window&&window.Object===Object&&window,nc=typeof self=="object"&&self&&self.Object===Object&&self,ss=oc||nc||Function("return this")();function sc(t,e){return t==null?void 0:t[e]}n(sc,"getValue");function ic(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}n(ic,"isHostObject");var ac=Array.prototype,cc=Function.prototype,is=Object.prototype,Yr=ss["__core-js_shared__"],as=function(){var t=/[^.]+$/.exec(Yr&&Yr.keys&&Yr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),cs=cc.toString,Jr=is.hasOwnProperty,lc=is.toString,pc=RegExp("^"+cs.call(Jr).replace(tc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),uc=ac.splice,dc=ls(ss,"Map"),ht=ls(Object,"create");function Ae(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(Ae,"Hash");function fc(){this.__data__=ht?ht(null):{}}n(fc,"hashClear");function hc(t){return this.has(t)&&delete this.__data__[t]}n(hc,"hashDelete");function mc(t){var e=this.__data__;if(ht){var r=e[t];return r===ns?void 0:r}return Jr.call(e,t)?e[t]:void 0}n(mc,"hashGet");function gc(t){var e=this.__data__;return ht?e[t]!==void 0:Jr.call(e,t)}n(gc,"hashHas");function yc(t,e){var r=this.__data__;return r[t]=ht&&e===void 0?ns:e,this}n(yc,"hashSet");Ae.prototype.clear=fc;Ae.prototype.delete=hc;Ae.prototype.get=mc;Ae.prototype.has=gc;Ae.prototype.set=yc;function Je(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(Je,"ListCache");function bc(){this.__data__=[]}n(bc,"listCacheClear");function _c(t){var e=this.__data__,r=rr(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():uc.call(e,r,1),!0}n(_c,"listCacheDelete");function Sc(t){var e=this.__data__,r=rr(e,t);return r<0?void 0:e[r][1]}n(Sc,"listCacheGet");function Ec(t){return rr(this.__data__,t)>-1}n(Ec,"listCacheHas");function xc(t,e){var r=this.__data__,o=rr(r,t);return o<0?r.push([t,e]):r[o][1]=e,this}n(xc,"listCacheSet");Je.prototype.clear=bc;Je.prototype.delete=_c;Je.prototype.get=Sc;Je.prototype.has=Ec;Je.prototype.set=xc;function Ne(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(Ne,"MapCache");function vc(){this.__data__={hash:new Ae,map:new(dc||Je),string:new Ae}}n(vc,"mapCacheClear");function Oc(t){return or(this,t).delete(t)}n(Oc,"mapCacheDelete");function Pc(t){return or(this,t).get(t)}n(Pc,"mapCacheGet");function Tc(t){return or(this,t).has(t)}n(Tc,"mapCacheHas");function wc(t,e){return or(this,t).set(t,e),this}n(wc,"mapCacheSet");Ne.prototype.clear=vc;Ne.prototype.delete=Oc;Ne.prototype.get=Pc;Ne.prototype.has=Tc;Ne.prototype.set=wc;function rr(t,e){for(var r=t.length;r--;)if(kc(t[r][0],e))return r;return-1}n(rr,"assocIndexOf");function Cc(t){if(!ps(t)||Ac(t))return!1;var e=Ic(t)||ic(t)?pc:rc;return e.test(Nc(t))}n(Cc,"baseIsNative");function or(t,e){var r=t.__data__;return Rc(e)?r[typeof e=="string"?"string":"hash"]:r.map}n(or,"getMapData");function ls(t,e){var r=sc(t,e);return Cc(r)?r:void 0}n(ls,"getNative");function Rc(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}n(Rc,"isKeyable");function Ac(t){return!!as&&as in t}n(Ac,"isMasked");function Nc(t){if(t!=null){try{return cs.call(t)}catch{}try{return t+""}catch{}}return""}n(Nc,"toSource");function Kr(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(Za);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(Kr.Cache||Ne),r}n(Kr,"memoize");Kr.Cache=Ne;function kc(t,e){return t===e||t!==t&&e!==e}n(kc,"eq");function Ic(t){var e=ps(t)?lc.call(t):"";return e==Xa||e==ec}n(Ic,"isFunction");function ps(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}n(ps,"isObject");us.exports=Kr});var nr,Qr,gt,yt,sr,ds,fs,qc,Dc,Uc,Fc,Lc,bt,Zr,Mc,hs,_t,jc,me,ge=v(()=>{nr=de(mt()),Qr=n((...t)=>JSON.stringify(t),"memoizeKey"),gt=n(t=>(...e)=>fetch(...t(...e)).then(r=>r.json()),"withFetchJson"),yt=n(t=>(e,...r)=>{if(!e)throw Error("host required");let[o,s={}]=t(...r);return[`${e.replace(/\/+$/,"")}${o}`,s]},"withHost"),sr=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"),ds=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"),fs=n((t=[])=>(Array.isArray(t)?t:Object.entries(t)).map(([e,r])=>[e,encodeURIComponent(r)].join("=")).join("&"),"toQuery"),qc=n(t=>JSON.stringify([].concat(t).map(e=>typeof e=="object"?e.id:e).filter(e=>e)),"toProductId"),Dc=(0,nr.default)(gt(yt((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=fs([["session_id",e],["page_type",1],["p",qc(r)],["module_view",JSON.stringify(["regular"])]]);return[`/offer/${t}/${o}?${s}`]})),Qr),Uc=(0,nr.default)(gt(yt(sr((t=1,e="place")=>[`/orders/?${fs([["status",t],["ordering",e],["exclude_prepaid_orders","true"]])}`]))),Qr),Fc=(0,nr.default)(gt(yt(sr(t=>{if(!t)throw Error("orderId required");return[`/items/?order=${t}`]}))),Qr),Lc=gt(yt(sr(ds((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}}]})))),bt=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"),Zr=n(t=>t.match(/^\d+_\d$/),"isFrequencyValid"),Mc=n((t,e)=>String.prototype.localeCompare.call(t&&t.split("_").reverse().join("_"),e&&e.split("_").reverse().join("_")),"compareFrequencies"),hs=n(t=>[...new Set(t&&t.split(/\s+/))].filter(Zr).sort(Mc),"parseFrequenciesList"),_t=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"),jc=gt(yt(sr(ds((t,e,r)=>{if(!t)throw Error("item required");if(!e)throw Error("frequency required");let o=bt(e);if(!o)throw Error("invalid frequency");return["/subscriptions/create_from_item/",{body:{item:t.public_id,offer:r,...o}}]})))),me={fetchOffer:Dc,fetchOrders:Uc,fetchItems:Fc,createOneTime:Lc,convertOneTimeToSubscription:jc}});var Xr,L,St=v(()=>{q();Xr=Et(),L={shopify:typeof window.Shopify!="undefined",shopify_selling_plans:typeof(Xr==null?void 0:Xr.dataset.shopifySellingPlans)!="undefined"}});function $c(t,e){return t===e}function Vc(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}function Hc(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$c,r=null,o=null;return function(){return Vc(e,r,arguments)||(o=t.apply(null,arguments)),r=arguments,o}}function Gc(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}function Bc(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(),p=Gc(i),f=t.apply(void 0,[function(){return c++,l.apply(null,arguments)}].concat(r)),d=t(function(){for(var h=[],w=p.length,E=0;E<w;E++)h.push(p[E].apply(null,arguments));return f.apply(null,h)});return d.resultFunc=l,d.dependencies=p,d.recomputations=function(){return c},d.resetRecomputations=function(){return c=0},d}}var Z,ms=v(()=>{n($c,"defaultEqualityCheck");n(Vc,"areArgumentsShallowlyEqual");n(Hc,"defaultMemoize");n(Gc,"getDependencies");n(Bc,"createSelectorCreator");Z=Bc(Hc)});function zc(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}function Wc(t,e,r){let o=_t(r);return L.shopify_selling_plans?oe(t,e,o):o}var W,D,xt,gs,eo,Yc,Jc,Kc,Qc,Zc,X,ir,ys,ee,ar,te,H,re,Ke,to,G,Qe,N=v(()=>{ms();W=de(mt());ge();St();q();W.default.Cache=Map;n(zc,"arraysEqual");n(Wc,"resolveFrequency");D=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))||zc((t.components||[]).sort(),(e.components||[]).sort()))),"isSameProduct"),xt=n(t=>t.optedin||[],"optedinSelector"),gs=n(t=>t.optedout||[],"optedoutSelector"),eo=n(t=>t.autoshipByDefault||{},"autoshipSelector"),Yc=n(t=>t.defaultFrequencies||{},"defaultFrequenciesSelector"),Jc=n(t=>{var e;return((e=t==null?void 0:t.config)==null?void 0:e.frequencies)||[]},"sellingPlansSelector"),Kc=n(t=>{var e;return((e=t==null?void 0:t.config)==null?void 0:e.frequenciesEveryPeriod)||[]},"frequenciesEveryPeriodSelector"),Qc=n(t=>{var e;return((e=t==null?void 0:t.config)==null?void 0:e.prepaidSellingPlans)||[]},"prepaidSellingPlansSelector"),Zc=n(t=>(t==null?void 0:t.prepaidShipmentsSelected)||{},"prepaidShipmentsSelectedSelector"),X=(0,W.default)(t=>Z(xt,gs,eo,(e,r,o)=>{let s=e.find(i=>D(t,i));return s||(r.find(i=>D(t,i))?!1:t&&o[t.id]?{id:t.id}:!1)}),t=>JSON.stringify(t)),ir=(0,W.default)(t=>Z(xt,e=>{let r=e.find(o=>D(t,o));return r||!1}),t=>JSON.stringify(t)),ys=(0,W.default)(t=>Z(xt,e=>e.some(r=>D(t,r)&&r.prepaidShipments)),t=>JSON.stringify(t)),ee=(0,W.default)(t=>Z(Zc,e=>e[t.id]||null),t=>JSON.stringify(t)),ar=(0,W.default)(t=>Z(gs,e=>e.find(r=>D(t,r)))),te=(0,W.default)(t=>Z(X(t),e=>e&&e.frequency||null)),H=(0,W.default)(t=>Z(X(t),e=>e&&e.prepaidShipments||null)),re=(0,W.default)(t=>Z(Qc,e=>{var o;return(((o=e[O(t)])==null?void 0:o.map(({numberShipments:s})=>s))||[]).sort((s,i)=>s-i)})),Ke=(0,W.default)(t=>Z(Yc,Jc,Kc,(e,r,o)=>e[O(t)]&&Wc(r,o,e[O(t)])||null)),to=n(t=>t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),"kebabCase"),G=n((t,e,r,o)=>({[r]:t.config&&t.config[r]||e&&e.hasAttribute&&e.hasAttribute(to(r))&&e[r]||e.offer&&typeof(e.offer[r]!=="undefined")&&e.offer[r]||o}),"configSelector"),Qe=n(t=>({templates:t.templates||[]}),"templatesSelector")});function cr(t){document.readyState==="loading"?window.addEventListener("DOMContentLoaded",t):t()}function Et(){return document.querySelector([`script[src^="https://${er}"]`,`script[src^="https://${tr}"]`,`script[src^="http://${er}"]`,`script[src^="http://${tr}"]`].join(","))}function ro(){let t=Et();if(!t)return[];let e=new URL(t.src),r=e.host.startsWith(Ce)?Ce:Re,o=e.pathname.split("/")[1];return!r&&!o?[]:[o,r,t]}function _s(t){if(t.isReady())return;console.info("OG offers are auto initializing");let[e,r]=ro();if(!r&&!e)return;let o=document.createElement("script");o.onload=()=>console.info("OG pull initialization chunk for merchant",e,r),o.onerror=()=>t.initialize(e,r),o.src=`${window.location.protocol}//${r===Re?er:tr}/${e}/main.js?initOnly=true`,document.head.appendChild(o)}function Es(t){let e=document.cookie.match(`(^|;) ?${t}=([^;]*)(;|$)`);return e?e[2]:null}function xs(t,e,r){let o=t.querySelector(`[name="${e}"]`);if(o&&!r){o.remove();return}!o&&r&&(o=document.createElement("input"),o.type="hidden",o.name=e,t.appendChild(o)),o&&(o.value=r)}function Xe(t,e){let[[r],o]=t.reduce((s,i)=>s[D(e,i)?0:1].push(i)&&s,[[],[]]);return[r||{},o||[]]}var O,bs,oo,Ss,Ze,ke,lr,oe,q=v(()=>{St();j();N();n(cr,"onReady");n(Et,"getMainJs");n(ro,"resolveEnvAndMerchant");O=n(t=>{var r;if(!t)return"";let e=`${t.id||t}`;return((r=L)==null?void 0:r.shopify_selling_plans)&&(e=e.split(":")[0]),e},"safeProductId"),bs=n((t,e)=>{var r;if(L.shopify_selling_plans){let o=(r=e.frequencies)==null?void 0:r.indexOf(t);if(o>=0&&e.frequenciesEveryPeriod[o])return e.frequenciesEveryPeriod[o]}return t},"safeOgFrequency"),oo=n((t,e)=>{var o;if(!`${t}`.includes("_"))return t;let r=(o=e.frequenciesEveryPeriod)==null?void 0:o.indexOf(t);return r>=0&&e.frequenciesEveryPeriod[r]?e.frequencies[r]:t},"frequencyToSellingPlan");n(_s,"autoInitializeOffers");Ss=n(t=>{document.cookie=`${t}=; expires=Thu, 01 Jan 1970 00:00:01 GMT;`},"clearCookie");n(Es,"getCookieValue");Ze=n(t=>!!(t&&(t==null?void 0:t.includes("_"))),"isOgFrequency"),ke=n((t=[])=>(t==null?void 0:t[0])||null,"getFirstSellingPlan"),lr=n((t=[],e=[])=>{var r;return!!(((r=L)==null?void 0:r.shopify_selling_plans)&&t.length&&e.length)},"hasShopifySellingPlans"),oe=n((t,e,r)=>{if(t.length!==e.length)return null;let o=e.findIndex(s=>s===r);return o>=0?t[o]:null},"mapFrequencyToSellingPlan");n(xs,"getOrCreateHidden");n(Xe,"getMatchingProductIfExists")});var ie,et,vs,pr,ye,Os,Ps,no,Xc,vt,be,Ts,ur,ws,el,so,io,dr,ao,Cs,Ie,co,tl,Rs,As,rl,ol,nl,sl,Ns,ks,Is,qs,Ds,Us,Fs,A=v(()=>{Jn();j();ge();q();ie=n((t,e,r)=>({type:I,payload:{product:t,frequency:e,offer:r}}),"optinProduct"),et=n((t,e)=>({type:U,payload:{product:t,offer:e}}),"optoutProduct"),vs=n((t,e)=>({type:pt,payload:{newProduct:t,product:e}}),"productHasChangedComponents"),pr=n((t,e,r)=>({type:F,payload:{product:t,frequency:e,offer:r}}),"productChangeFrequency"),ye=n((t,e,r)=>({type:se,payload:{product:t,prepaidShipments:e,offer:r}}),"productChangePrepaidShipments"),Os=n(t=>({type:Xn,payload:{product:t}}),"concludeUpsell"),Ps=n(t=>({type:Ve,payload:t}),"setMerchantId"),no=n(t=>({type:He,payload:`${t}.${Math.floor(Math.random()*999999)}.${Math.round(new Date().getTime()/1e3)}`}),"createSessionId"),Xc=n(t=>({type:Kn,payload:t}),"requestAuth"),vt=n((t,e,r,o)=>({type:Ht,payload:{public_id:t,sig_field:e,ts:r,sig:o}}),"authorize"),be=n(t=>({type:Pe,payload:t}),"unauthorized"),Ts=n(t=>({type:Vt,payload:t}),"setAuthUrl"),ur=n(t=>({type:rs,payload:t}),"fetchDone"),ws=n((t=Yn)=>n(function(r,o){if(window.og&&window.og.previewMode)return r(be({message:"Offers are running in preview mode"}));let{merchantId:s,authUrl:i}=o(),a=Xc(i);return r(a),t(i).then(({sig_field:c,ts:l,sig:p})=>r(vt(s,c,l,p)),c=>r(be(c))).finally(()=>r(ur(a)))},"fetchAuthThunk"),"fetchAuth"),el=n((t,e)=>({type:Qn,payload:{status:t,ordering:e}}),"requestOrders"),so=n(t=>({type:Gt,payload:t}),"receiveOrders"),io=n(t=>({type:Bt,payload:t}),"receiveItems"),dr=n((t=1,e="place")=>n(function(o,s){let{environment:{legoUrl:i},auth:a}=s();if(!a)return o(be("No auth set."));let c=el(t,e);return o(c),me.fetchOrders(i,a,t,e).then(l=>{if(l.results){o(so(l));let p=(l.results[0]||{}).public_id;if(p)return me.fetchItems(i,a,p).then(f=>o(io(f)))}return o(be(l.detail)),null},l=>o(be(l))).finally(()=>o(ur(c)))},"fetchOrdersThunk"),"fetchOrders"),ao=n(t=>{switch(t){case Xt:return{type:Be,payload:t};case Ce:return{type:Ge,payload:t};case Re:return{type:ze,payload:t};default:throw new Error(`${t} is not a supported environment`)}},"setEnvironment"),Cs=n(()=>(t,e)=>{let{merchantId:r,sessionId:o}=e();return(!o||r&&!o.startsWith(r))&&t(no(r)),o},"requestSessionId"),Ie=n((t,e)=>({type:R,payload:{...t,offer:e}}),"receiveOffer"),co=n(t=>({type:Zn,payload:t}),"fetchResponseError"),tl=n((t,e=we,r)=>({type:K,payload:{product:t,module:e,offer:r}}),"requestOffer"),Rs=n((t,e=we,r)=>n(function(s,i){let{merchantId:a,sessionId:c,environment:{apiUrl:l}}=i(),p=tl(t,e,r);s(p);let f=O(t);return f?me.fetchOffer(l,a,c,f,e).then(d=>s(Ie(d,r)),d=>s(co(d))).finally(()=>s(ur(p))):null},"fetchOfferThunk"),"fetchOffer"),As=n(()=>({type:We}),"checkout"),rl=n((t,e,r,o)=>({type:es,payload:{product:t,order:e,quantity:r,offerId:o}}),"requestCreateOneTime"),ol=n(t=>({type:zt,payload:t}),"receiveCreateOneTime"),nl=n((t,e)=>({type:ts,payload:{item:t,frequency:e}}),"requestConvertOneTimeToSubscription"),sl=n((t,e)=>({type:Wt,payload:{response:t,product:e}}),"receiveConvertOneTime"),Ns=n((t,e,r,o=!1,s=null)=>n(function(a,c){let{auth:l,config:p,environment:{legoUrl:f},previewUpsellOffer:d,offerId:h}=c();if(!l)return a(be("No auth set."));let w=bs(s,p),E=rl(t,e,r,h);return a(E),(d?Promise.resolve({legoUrl:f,product:t,order:e,quantity:r,offer:h}):me.createOneTime(f,l,t.id,e,r,h)).then(m=>(a(ol(m)),o?(a(nl(m,w)),(d?Promise.resolve({item:m,frequency:w}):me.convertOneTimeToSubscription(f,l,m,w,h)).then(x=>a(sl(x,t)),x=>a(co(x)))):m),m=>a(co(m))).finally(()=>a(ur(E)))},"createIuThunk"),"createIu"),ks=n(t=>({type:Yt,payload:t}),"setLocale"),Is=n(t=>({type:Ye,payload:t}),"setConfig"),qs=n((t,e,r)=>({type:Jt,payload:{selector:t,markup:e,config:r}}),"addTemplate"),Ds=n(t=>({type:Kt,payload:t}),"setTemplates"),Us=n((t,e)=>({type:Qt,payload:{product:t,firstOrderPlaceDate:e}}),"setFirstOrderPlaceDate"),Fs=n((t,e)=>({type:Zt,payload:{product:t,productToSubscribe:e}}),"setProductToSubscribe")});var ho,qe,De=v(()=>{ho=typeof window!="undefined"&&window.customElements!=null&&window.customElements.polyfillWrapFlushCallback!==void 0,qe=n((t,e,r=null)=>{for(;e!==r;){let o=e.nextSibling;t.removeChild(e),e=o}},"removeNodes")});var B,mo,ei,rt,Ue,ti,Pt,ne,mr,_e=v(()=>{B=`{{lit-${String(Math.random()).slice(2)}}}`,mo=`<!--${B}-->`,ei=new RegExp(`${B}|${mo}`),rt="$lit$",Ue=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:p,values:{length:f}}=e;for(;l<f;){let d=i.nextNode();if(d===null){i.currentNode=s.pop();continue}if(c++,d.nodeType===1){if(d.hasAttributes()){let h=d.attributes,{length:w}=h,E=0;for(let m=0;m<w;m++)ti(h[m].name,rt)&&E++;for(;E-- >0;){let m=p[l],x=mr.exec(m)[2],C=x.toLowerCase()+rt,_=d.getAttribute(C);d.removeAttribute(C);let y=_.split(ei);this.parts.push({type:"attribute",index:c,name:x,strings:y}),l+=y.length-1}}d.tagName==="TEMPLATE"&&(s.push(d),i.currentNode=d.content)}else if(d.nodeType===3){let h=d.data;if(h.indexOf(B)>=0){let w=d.parentNode,E=h.split(ei),m=E.length-1;for(let x=0;x<m;x++){let C,_=E[x];if(_==="")C=ne();else{let y=mr.exec(_);y!==null&&ti(y[2],rt)&&(_=_.slice(0,y.index)+y[1]+y[2].slice(0,-rt.length)+y[3]),C=document.createTextNode(_)}w.insertBefore(C,d),this.parts.push({type:"node",index:++c})}E[m]===""?(w.insertBefore(ne(),d),o.push(d)):d.data=E[m],l+=m}}else if(d.nodeType===8)if(d.data===B){let h=d.parentNode;(d.previousSibling===null||c===a)&&(c++,h.insertBefore(ne(),d)),a=c,this.parts.push({type:"node",index:c}),d.nextSibling===null?d.data="":(o.push(d),c--),l++}else{let h=-1;for(;(h=d.data.indexOf(B,h+1))!==-1;)this.parts.push({type:"node",index:-1}),l++}}for(let d of o)d.parentNode.removeChild(d)}};n(Ue,"Template");ti=n((t,e)=>{let r=t.length-e.length;return r>=0&&t.slice(r)===e},"endsWith"),Pt=n(t=>t.index!==-1,"isTemplatePartActive"),ne=n(()=>document.createComment(""),"createMarker"),mr=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/});function yo(t,e){let{element:{content:r},parts:o}=t,s=document.createTreeWalker(r,go,null,!1),i=Tt(o),a=o[i],c=-1,l=0,p=[],f=null;for(;s.nextNode();){c++;let d=s.currentNode;for(d.previousSibling===f&&(f=null),e.has(d)&&(p.push(d),f===null&&(f=d)),f!==null&&l++;a!==void 0&&a.index===c;)a.index=f!==null?-1:a.index-l,i=Tt(o,i),a=o[i]}p.forEach(d=>d.parentNode.removeChild(d))}function ri(t,e,r=null){let{element:{content:o},parts:s}=t;if(r==null){o.appendChild(e);return}let i=document.createTreeWalker(o,go,null,!1),a=Tt(s),c=0,l=-1;for(;i.nextNode();)for(l++,i.currentNode===r&&(c=fl(e),r.parentNode.insertBefore(e,r));a!==-1&&s[a].index===l;){if(c>0){for(;a!==-1;)s[a].index+=c,a=Tt(s,a);return}a=Tt(s,a)}}var go,fl,Tt,oi=v(()=>{_e();go=133;n(yo,"removeNodesFromTemplate");fl=n(t=>{let e=t.nodeType===11?0:1,r=document.createTreeWalker(t,go,null,!1);for(;r.nextNode();)e++;return e},"countNodes"),Tt=n((t,e=-1)=>{for(let r=e+1;r<t.length;r++){let o=t[r];if(Pt(o))return r}return-1},"nextActiveIndexInTemplateParts");n(ri,"insertNodeIntoTemplate")});var hl,Fe,bo=v(()=>{hl=new WeakMap,Fe=n(t=>typeof t=="function"&&hl.has(t),"isDirective")});var $,gr,_o=v(()=>{$={},gr={}});var Se,yr=v(()=>{De();_e();Se=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=ho?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],!Pt(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 p=this.processor.handleTextExpression(this.options);p.insertAfterNode(l.previousSibling),this.__parts.push(p)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,c.name,c.strings,this.options));i++}return ho&&(document.adoptNode(e),customElements.upgrade(e)),e}};n(Se,"TemplateInstance")});var ni,gl,ae,br=v(()=>{De();_e();ni=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),gl=` ${B} `,ae=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=mr.exec(i);c===null?r+=i+(o?gl:mo):r+=i.substr(0,c.index)+c[1]+c[2]+rt+c[3]+B}return r+=this.strings[e],r}getTemplateElement(){let e=document.createElement("template"),r=this.getHTML();return ni!==void 0&&(r=ni.createHTML(r)),e.innerHTML=r,e}};n(ae,"TemplateResult")});var _r,Sr,ot,wt,ce,Ct,Rt,Er,si,At,yl,xr=v(()=>{bo();De();_o();yr();br();_e();_r=n(t=>t===null||!(typeof t=="object"||typeof t=="function"),"isPrimitive"),Sr=n(t=>Array.isArray(t)||!!(t&&t[Symbol.iterator]),"isIterable"),ot=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 wt(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"||!Sr(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(_r(c)||!Sr(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(ot,"AttributeCommitter");wt=class{constructor(e){this.value=void 0,this.committer=e}setValue(e){e!==$&&(!_r(e)||e!==this.value)&&(this.value=e,Fe(e)||(this.committer.dirty=!0))}commit(){for(;Fe(this.value);){let e=this.value;this.value=$,e(this)}this.value!==$&&this.committer.commit()}};n(wt,"AttributePart");ce=class{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(ne()),this.endNode=e.appendChild(ne())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=ne()),e.__insert(this.endNode=ne())}insertAfterPart(e){e.__insert(this.startNode=ne()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(this.startNode.parentNode===null)return;for(;Fe(this.__pendingValue);){let r=this.__pendingValue;this.__pendingValue=$,r(this)}let e=this.__pendingValue;e!==$&&(_r(e)?e!==this.value&&this.__commitText(e):e instanceof ae?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):Sr(e)?this.__commitIterable(e):e===gr?(this.value=gr,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 Se&&this.value.template===r)this.value.update(e.values);else{let o=new Se(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 ce(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){qe(this.startNode.parentNode,e.nextSibling,this.endNode)}};n(ce,"NodePart");Ct=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(;Fe(this.__pendingValue);){let r=this.__pendingValue;this.__pendingValue=$,r(this)}if(this.__pendingValue===$)return;let e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=$}};n(Ct,"BooleanAttributePart");Rt=class extends ot{constructor(e,r,o){super(e,r,o);this.single=o.length===2&&o[0]===""&&o[1]===""}_createPart(){return new Er(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}};n(Rt,"PropertyCommitter");Er=class extends wt{};n(Er,"PropertyPart");si=!1;(()=>{try{let t={get capture(){return si=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch{}})();At=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(;Fe(this.__pendingValue);){let i=this.__pendingValue;this.__pendingValue=$,i(this)}if(this.__pendingValue===$)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=yl(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=$}handleEvent(e){typeof this.value=="function"?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}};n(At,"EventPart");yl=n(t=>t&&(si?{capture:t.capture,passive:t.passive,once:t.once}:t.capture),"getOptions")});function So(t){let e=Le.get(t.type);e===void 0&&(e={stringsArray:new WeakMap,keyString:new Map},Le.set(t.type,e));let r=e.stringsArray.get(t.strings);if(r!==void 0)return r;let o=t.strings.join(B);return r=e.keyString.get(o),r===void 0&&(r=new Ue(t,t.getTemplateElement()),e.keyString.set(o,r)),e.stringsArray.set(t.strings,r),r}var Le,vr=v(()=>{_e();n(So,"templateFactory");Le=new Map});var Ee,Eo,xo=v(()=>{De();xr();vr();Ee=new WeakMap,Eo=n((t,e,r)=>{let o=Ee.get(e);o===void 0&&(qe(e,e.firstChild),Ee.set(e,o=new ce(Object.assign({templateFactory:So},r))),o.appendInto(e)),o.setValue(t),o.commit()},"render")});var Or,vo,Oo=v(()=>{xr();Or=class{handleAttributeExpressions(e,r,o,s){let i=r[0];return i==="."?new Rt(e,r.slice(1),o).parts:i==="@"?[new At(e,r.slice(1),s.eventContext)]:i==="?"?[new Ct(e,r.slice(1),o)]:new ot(e,r,o).parts}handleTextExpression(e){return new ce(e)}};n(Or,"DefaultTemplateProcessor");vo=new Or});var u,Po=v(()=>{Oo();br();Oo();bo();De();_o();xr();xo();vr();yr();br();_e();typeof window!="undefined"&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");u=n((t,...e)=>new ae(t,e,"html",vo),"html")});var ai,Pr,_l,Sl,El,ci,xl,li,pi=v(()=>{De();oi();xo();vr();yr();_e();Po();ai=n((t,e)=>`${t}--${e}`,"getTemplateCacheKey"),Pr=!0;typeof window.ShadyCSS=="undefined"?Pr=!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."),Pr=!1);_l=n(t=>e=>{let r=ai(e.type,t),o=Le.get(r);o===void 0&&(o={stringsArray:new WeakMap,keyString:new Map},Le.set(r,o));let s=o.stringsArray.get(e.strings);if(s!==void 0)return s;let i=e.strings.join(B);if(s=o.keyString.get(i),s===void 0){let a=e.getTemplateElement();Pr&&window.ShadyCSS.prepareTemplateDom(a,t),s=new Ue(e,a),o.keyString.set(i,s)}return o.stringsArray.set(e.strings,s),s},"shadyTemplateFactory"),Sl=["html","svg"],El=n(t=>{Sl.forEach(e=>{let r=Le.get(ai(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)}),yo(o,i)})})},"removeStylesFromLitTemplates"),ci=new Set,xl=n((t,e,r)=>{ci.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 p=0;p<i;p++){let f=s[p];f.parentNode.removeChild(f),a.textContent+=f.textContent}El(t);let c=o.content;r?ri(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 p=new Set;p.add(a),yo(r,p)}},"prepareTemplateStyles"),li=n((t,e,r)=>{if(!r||typeof r!="object"||!r.scopeName)throw new Error("The `scopeName` option is required.");let o=r.scopeName,s=Ee.has(e),i=Pr&&e.nodeType===11&&!!e.host,a=i&&!ci.has(o),c=a?document.createDocumentFragment():e;if(Eo(t,c,Object.assign({templateFactory:_l(o)},r)),a){let l=Ee.get(c);Ee.delete(c);let p=l.value instanceof Se?l.value.template:void 0;xl(o,c,p),qe(e,e.firstChild),e.appendChild(c),Ee.set(e,l)}!s&&i&&window.ShadyCSS.styleElement(e.host)},"render")});var ui,To,di,wo,Co,Ro,Ao,No,ko,Nt,Io=v(()=>{window.JSCompiler_renameProperty=(t,e)=>t;To={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}},di=n((t,e)=>e!==t&&(e===e||t===t),"notEqual"),wo={attribute:!0,type:String,converter:To,reflect:!1,hasChanged:di},Co=1,Ro=1<<2,Ao=1<<3,No=1<<4,ko="finalized",Nt=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=wo){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)||wo}static finalize(){let e=Object.getPrototypeOf(this);if(e.hasOwnProperty(ko)||e.finalize(),this[ko]=!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=di){return o(e,r)}static _propertyValueFromAttribute(e,r){let o=r.type,s=r.converter||To,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||To.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=wo){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|Ao,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._updateState=this._updateState&~Ao}}_attributeToProperty(e,r){if(this._updateState&Ao)return;let o=this.constructor,s=o._attributeToPropertyMap.get(e);if(s!==void 0){let i=o.getPropertyOptions(s);this._updateState=this._updateState|No,this[s]=o._propertyValueFromAttribute(r,i),this._updateState=this._updateState&~No}}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&No)&&(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|Ro;try{await this._updatePromise}catch{}let e=this.performUpdate();return e!=null&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return this._updateState&Ro}get hasUpdated(){return this._updateState&Co}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&Co||(this._updateState=this._updateState|Co,this.firstUpdated(r)),this.updated(r))}_markUpdated(){this._changedProperties=new Map,this._updateState=this._updateState&~Ro}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(Nt,"UpdatingElement");ui=ko;Nt[ui]=!0});var fi,vf,hi=v(()=>{fi=Element.prototype,vf=fi.msMatchesSelector||fi.webkitMatchesSelector});var Tr,qo,kt,mi,vl,b,Do=v(()=>{Tr=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qo=Symbol(),kt=class{constructor(e,r){if(r!==qo)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return this._styleSheet===void 0&&(Tr?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}};n(kt,"CSSResult");mi=n(t=>new kt(String(t),qo),"unsafeCSS"),vl=n(t=>{if(t instanceof kt)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"),b=n((t,...e)=>{let r=e.reduce((o,s,i)=>o+vl(s)+t[i+1],t[0]);return new kt(r,qo)},"css")});var gi,P,S=v(()=>{pi();Io();Io();hi();Po();Do();Do();(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");gi={},P=class extends Nt{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&&!Tr){let o=Array.prototype.slice.call(r.cssRules).reduce((s,i)=>s+i.cssText,"");return mi(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):Tr?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!==gi&&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 gi}};n(P,"LitElement");P.finalized=!0;P.render=li});var wr=Oe((qf,yi)=>{var Ol={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"};yi.exports=Ol});var _i=Oe((Df,bi)=>{var Me=wr(),Pl=n(t=>{let e="",r=[];for(let o of t){let s=o.charCodeAt(0);switch(s){case Me.PAR_OPEN:case Me.PAR_CLOSE:case Me.OP_NOT:case Me.BINARY_AND:case Me.BINARY_OR:e&&(r.push({type:Me.LITERAL,value:e}),e=""),r.push({type:s,value:o});break;default:e+=o}}return e&&r.push({type:Me.LITERAL,value:e}),r},"Tokenizer");bi.exports=Pl});var Ei=Oe((Uf,Si)=>{var xe=wr(),Tl=n(t=>{let e=[],r=[];return t.forEach(s=>{switch(s.type){case xe.LITERAL:e.unshift(s);break;case xe.BINARY_AND:case xe.BINARY_OR:case xe.OP_NOT:case xe.PAR_OPEN:r.push(s);break;case xe.PAR_CLOSE:for(;r.length&&r[r.length-1].type!==xe.PAR_OPEN;)e.unshift(r.pop());r.pop(),r.length&&r[r.length-1].type===xe.OP_NOT&&e.unshift(r.pop());break;default:break}}),r.length&&[...r.reverse(),...e]||e},"PolishNotation"),wl=n(function*(t){for(let e=0;e<t.length-1;e++)yield t[e];return t[t.length-1]},"PolishGenerator");Si.exports={PolishNotation:Tl,PolishGenerator:wl}});var vi=Oe((Ff,xi)=>{var V=wr(),Y=class{constructor(e,r,o,s){this.op=e,this.left=r,this.right=o,this.literal=s}isLeaf(){return this.op===V.LEAF}isAtomic(){return this.isLeaf()||this.op===V.OP_NOT&&this.left.isLeaf()}getLiteralValue(){return this.literal}static CreateAnd(e,r){return new Y(V.BINARY_AND,e,r)}static CreateNot(e){return new Y(V.OP_NOT,e)}static CreateOr(e,r){return new Y(V.BINARY_OR,e,r)}static CreateLiteral(e){return new Y(V.LEAF,null,null,e)}};n(Y,"ExpNode");var nt=n(t=>{let e=t.next().value;switch(e.type){case V.LITERAL:return Y.CreateLiteral(e.value);case V.OP_NOT:return Y.CreateNot(nt(t));case V.BINARY_AND:{let r=nt(t),o=nt(t);return Y.CreateAnd(r,o)}case V.BINARY_OR:{let r=nt(t),o=nt(t);return Y.CreateOr(r,o)}}return null},"make"),st=n((t,e)=>{if(t.isLeaf())return e(t.getLiteralValue());if(t.op===V.OP_NOT)return!st(t.left,e);if(t.op===V.BINARY_OR)return st(t.left,e)||st(t.right,e);if(t.op===V.BINARY_AND)return st(t.left,e)&&st(t.right,e)},"nodeEvaluator");xi.exports={make:nt,nodeEvaluator:st}});var wi=Oe((Lf,Ti)=>{var Cl=_i(),Oi=Ei(),Pi=vi(),Rl=n((t,e)=>{let r=Cl(t),o=Oi.PolishNotation(r),s=Oi.PolishGenerator(o),i=Pi.make(s);return Pi.nodeEvaluator(i,e)},"parse");Ti.exports={parse:Rl}});var aa={};$r(aa,{TestWizard:()=>qr,default:()=>cp});var qr,cp,ca=v(()=>{S();A();qr=class extends P{static get styles(){return b`
|
|
13
13
|
:host {
|
|
14
14
|
position: fixed;
|
|
15
15
|
top: 5em;
|
|
@@ -67,11 +67,11 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
67
67
|
a {
|
|
68
68
|
color: white;
|
|
69
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?
|
|
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
71
|
<div class="message error">No offer element found on the page</div>
|
|
72
|
-
`:this.results.map((e,r)=>
|
|
72
|
+
`:this.results.map((e,r)=>u`
|
|
73
73
|
<div>For offer tag with product = "${e.product}"</div>
|
|
74
|
-
${e.messages.map(o=>
|
|
74
|
+
${e.messages.map(o=>u`
|
|
75
75
|
<div class="message ${o.type}">
|
|
76
76
|
${o.name}
|
|
77
77
|
</div>
|
|
@@ -100,16 +100,16 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
100
100
|
upsell product is in next order
|
|
101
101
|
</button>
|
|
102
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(
|
|
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(Ie({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(io({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
104
|
<div>
|
|
105
|
-
${this.testsRan?this.resultsCodeBlock():
|
|
105
|
+
${this.testsRan?this.resultsCodeBlock():u`
|
|
106
106
|
<div>Click the button to run tests</div>
|
|
107
107
|
`}
|
|
108
108
|
<button ?disabled=${this.disabled} @click="${this.runTests.bind(this)}" class="primary">Run Test</button>
|
|
109
109
|
</div>
|
|
110
|
-
`}};n(Ir,"TestWizard");ep=Ir});var _u={};Mr(_u,{addOptinChangedCallback:()=>Qp,addTemplate:()=>Zp,autoInit:()=>yu,clear:()=>Xp,config:()=>eu,default:()=>bu,disableOptinChangedCallbacks:()=>tu,getOptins:()=>ru,getProductsForPurchasePost:()=>ou,initialize:()=>nu,isReady:()=>Kp,offers:()=>O,platform:()=>L,previewMode:()=>su,register:()=>iu,resolveSettings:()=>au,setAuthUrl:()=>cu,setEnvironment:()=>lu,setLocale:()=>pu,setMerchantId:()=>uu,setPublicPath:()=>du,setTemplates:()=>fu,setupCart:()=>hu,setupProduct:()=>mu,setupProducts:()=>gu,store:()=>wa});function jr(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(jr,"symbolObservablePonyfill");var Ue;typeof self!="undefined"?Ue=self:typeof window!="undefined"||typeof window!="undefined"?Ue=window:typeof module!="undefined"?Ue=module:Ue=Function("return this")();var Fa=jr(Ue),$r=Fa;var Vr=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),nt={INIT:"@@redux/INIT"+Vr(),REPLACE:"@@redux/REPLACE"+Vr(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Vr()},"PROBE_UNKNOWN_ACTION")};function La(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(La,"isPlainObject");function Hr(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(Hr)(t,e)}if(typeof t!="function")throw new Error("Expected the reducer to be a function.");var s=t,i=e,a=[],c=a,l=!1;function p(){c===a&&(c=a.slice())}n(p,"ensureCanMutateNextListeners");function f(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}n(f,"getState");function u(m){if(typeof m!="function")throw new Error("Expected the listener to be a function.");if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var S=!0;return p(),c.push(m),n(function(){if(!!S){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.");S=!1,p();var b=c.indexOf(m);c.splice(b,1),a=null}},"unsubscribe")}n(u,"subscribe");function h(m){if(!La(m))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof m.type=="undefined")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=s(i,m)}finally{l=!1}for(var S=a=c,C=0;C<S.length;C++){var b=S[C];b()}return m}n(h,"dispatch");function w(m){if(typeof m!="function")throw new Error("Expected the nextReducer to be a function.");s=m,h({type:nt.REPLACE})}n(w,"replaceReducer");function _(){var m,S=u;return m={subscribe:n(function(b){if(typeof b!="object"||b===null)throw new TypeError("Expected the observer to be an object.");function y(){b.next&&b.next(f())}n(y,"observeState"),y();var It=S(y);return{unsubscribe:It}},"subscribe")},m[$r]=function(){return this},m}return n(_,"observable"),h({type:nt.INIT}),o={dispatch:h,subscribe:u,getState:f,replaceReducer:w},o[$r]=_,o}n(Hr,"createStore");function Ma(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(Ma,"getUndefinedStateErrorMessage");function ja(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:nt.INIT});if(typeof o=="undefined")throw new Error('Reducer "'+e+`" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:nt.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+nt.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.")})}n(ja,"assertReducerShape");function kt(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{ja(r)}catch(l){c=l}return n(function(p,f){if(p===void 0&&(p={}),c)throw c;if(!1)var u;for(var h=!1,w={},_=0;_<i.length;_++){var m=i[_],S=r[m],C=p[m],b=S(C,f);if(typeof b=="undefined"){var y=Ma(m,f);throw new Error(y)}w[m]=b,h=h||b!==C}return h=h||i.length!==Object.keys(p).length,h?w:p},"combination")}n(kt,"combineReducers");function qn(t,e){return function(){return e(t.apply(this,arguments))}}n(qn,"bindActionCreator");function Dn(t,e){if(typeof t=="function")return qn(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]=qn(s,e))}return r}n(Dn,"bindActionCreators");function $a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n($a,"_defineProperty");function Un(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(Un,"ownKeys");function Va(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Un(r,!0).forEach(function(o){$a(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Un(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n(Va,"_objectSpread2");function Gr(){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(Gr,"compose");function Fn(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(o){return function(){var s=o.apply(void 0,arguments),i=n(function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},"dispatch"),a={getState:s.getState,dispatch:n(function(){return i.apply(void 0,arguments)},"dispatch")},c=e.map(function(l){return l(a)});return i=Gr.apply(void 0,c)(s.dispatch),Va({},s,{dispatch:i})}}}n(Fn,"applyMiddleware");function Ln(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(Ln,"createThunkMiddleware");var Mn=Ln();Mn.withExtraArgument=Ln;var jn=Mn;var Ds=ce(Dt());q();j();var _t="OG_STATE",Us=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),ao=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),Fs=n(()=>ao()?{}:Us(localStorage.getItem(_t)),"loadState"),tl=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"),Ls=n(t=>{if(ao())return;let e=tl(t);e&&localStorage.getItem(_t)!==e&&localStorage.setItem(_t,e)},"saveState"),Ms=n(t=>(0,Ds.throttle)(500,e=>{if(ao())return;let{key:r,newValue:o}=e;r===_t&&o===null?(t.dispatch({type:le}),setTimeout(()=>t.dispatch(Os()),0)):r===_t&&t.dispatch({type:Ee,newValue:Us(o)})}),"listenLocalStorageChanges");var js=ce(Dt());j();F();var rl=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),$s=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>rl("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),ol=[{expressions:[({type:t}={})=>t===N,({type:t}={})=>t===U],fn:$s(!0)},{expressions:[({type:t}={})=>t===D],fn:$s(!1)}],Vs=n(t=>e=>r=>{let o=t.getState();ol.forEach(s=>{s.expressions.some(i=>i(r,o))&&s.fn(r)}),e(r)},"dispatchMiddleware"),Hs=n(t=>e=>r=>{var s;let o;switch(r.type){case R:case D:case N:case U:o=new CustomEvent(`og-${r.type.toLowerCase().replace(/_/g,"-")}`,{bubbles:!0,cancelable:!0,detail:r.payload}),(((s=r.payload)==null?void 0:s.offer)||document).dispatchEvent(o);break;default:}(o==null?void 0:o.defaultPrevented)||e(r)},"offerEvents"),Gs=n(t=>e=>r=>{e(r);let o=(0,js.throttle)(500,()=>{Ls({...t.getState()})});r.type!==Ee&&o()},"localStorageMiddleware");q();j();var co=n(()=>{let t,e;return[new Promise((r,o)=>{t=r,e=o}),t,e]},"waitFor");function Bs(t){let[e,r]=co(),[o,s]=co(),[i,a]=co();o.then(l=>{let{sessionId:p}=t.getState();!p||l&&!p.startsWith(l)?t.dispatch(ro(l)):a(p)});let c=Promise.all([o,e,i]);return c.then(()=>{var l;window.addEventListener("storage",Ms(t)),((l=t.getState().auth)==null?void 0:l.ts)||t.dispatch(Ts())}),l=>async p=>{je===p.type||Me===p.type||$e===p.type?r(p.payload):Fe===p.type?s(p.payload):Le===p.type?a(p.payload):await c,l(p)}}n(Bs,"waitUntilOffersReady");function zs(t,...e){if(window.og&&window.og.store)return window.og.store;let r=window.og&&window.og.previewMode,o=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"Ordergroove Offers"}):Gr,s=[Bs,jn,Vs,Hs],i={};if(!r)try{i=Fs(),s.push(Gs)}catch{}let a=o(Fn(...s,...e.filter(l=>l))),c=Hr(t,i,a);return window.og=window.og||{},window.og.store=c,c}n(zs,"makeStore");var nl=Object.defineProperty,ur=n((t,e)=>nl(t,"name",{value:e,configurable:!0}),"i"),sl=ur(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),Ys=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],Ws=ur(t=>(e,r)=>{Ys.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function lo(t=window.opener,e=window.og){let r=ur(o=>{let s=sl(Ys),i=Ws(o.source),a=o.data.options||{};if(s(o)&&o.data.ogType==="READY"){let c="//static.ordergroove.com/@ordergroove/offers-live-editor/0.6.1/dist/";c.startsWith("//")&&(c=window.location.protocol+c),c.endsWith("/")||(c+="/"),import(`${c}client.js`).then(({initializeClient:l})=>{l({isMessageAllowed:s,broadcastMessage:i,options:a,og:e}),window.removeEventListener("message",r)})}},"handleReady");t&&t!==window&&(window.addEventListener("message",r),Ws(t)("READY"))}n(lo,"f");ur(lo,"offersLiveEditor");var dr=null,il=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),Js=n(t=>{if(!dr)throw new Error("Missing redux store.");return dr},"resolveStore"),al=n((t,e)=>r=>{let{getState:o,dispatch:s}=Js(r),i=t?t(o(),r):{},a=e(s,r);Object.assign(r,i,a)},"createRecalcProps"),g=n((t,e=il)=>r=>{let s=al(t,typeof e=="function"?e:i=>Dn(e,i));return class extends r{get store(){return dr}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=Js(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"),Ks=n(t=>{dr=t},"setStore");de();var po=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],...ft(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"),Ke=n((t={})=>{let e={};return Object.entries(t).forEach(([r,o])=>{Object.entries(o).forEach(([s,i])=>{let a={};i&&!Array.isArray(i)?a=i:a={frequency:s,prepaidShipments:null,regularPrice:i[0],subscriptionPrice:i[2],discountRate:i[1]},e[r]?e[r].push(a):e[r]=[a]})}),e},"getObjectStructuredProductPlans");q();P();var Ni=ce(Ti());P();var Ol=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"),Oi=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var qo=n(t=>{let e=Oi(t);if(!e){let r=t.offer;r&&(e=Oi(r))}return e},"resolveProduct"),Pl=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),Do=n(t=>class extends t{get offer(){return Pl(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 Do(t){get product(){return qo(this)}},"withProduct"),Pr=n(t=>class extends t{get childOptions(){let e=[],r=null;return this.querySelectorAll("option").forEach(o=>{let s=Ol(o.value),i=o.innerText.trim();e.push({value:s,text:i}),!r&&o.selected&&(r=s)}),{options:e,isSelected:r}}},"withChildOptions");var wr={};Mr(wr,{autoshipByDefault:()=>wl,eligibilityGroups:()=>Fo,eligible:()=>Pi,hasPrepaidOptions:()=>Il,hasUpcomingOrder:()=>Ri,hasUpsellGroup:()=>Ci,inStock:()=>Uo,optedout:()=>Al,prepaidEligible:()=>Cl,prepaidSubscribed:()=>Nl,regularEligible:()=>ql,subscribed:()=>Rl,subscriptionEligible:()=>wi,upcomingOrderContainsProduct:()=>kl,upsellEligible:()=>Ai});F();I();var Uo=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),Pi=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),wl=n((t,e)=>(t.autoshipByDefault||{})[(e.product||{}).id]||!1,"autoshipByDefault"),wi=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&Pi(t,e)&&Uo(t,e),"subscriptionEligible"),Fo=n((t,e)=>{let r=x((e.product||{}).id);return(t.eligibilityGroups||{})[r]||null},"eligibilityGroups"),Ci=n((t,e)=>{let r=Fo(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),Cl=n((t,e)=>{let r=Fo(t,e);return(r==null?void 0:r.some(o=>o==="prepaid"))||!1},"prepaidEligible"),Rl=n((t,e)=>tr(e.product)(t),"subscribed"),Al=n((t,e)=>or(e.product)(t),"optedout"),Nl=n((t,e)=>fs(e.product)(t),"prepaidSubscribed"),Il=n((t,e)=>sr(e.product.id)(t).length>0,"hasPrepaidOptions"),Ri=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),kl=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),Ai=n((t,e)=>{var r;return!((r=e.offer)==null?void 0:r.isCart)&&t.offerId&&t.offerId!=="0"&&t.auth&&Uo(t,e)&&Ri(t)&&Ci(t,e)},"upsellEligible"),ql=n((t,e)=>wi(t,e)&&!Ai(t,e),"regularEligible");var Dl=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),Lo=class extends A(T){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){if(!this.test)return d``;let e=Dl(this.test);return e=e.replace(/(![a-zA-Z]+)/g,"($1)"),Ni.default.parse(e,o=>wr[o]&&wr[o](this.state,this))?d`
|
|
110
|
+
`}};n(qr,"TestWizard");cp=qr});var wu={};$r(wu,{addOptinChangedCallback:()=>su,addTemplate:()=>iu,autoInit:()=>Pu,clear:()=>au,config:()=>cu,default:()=>Tu,disableOptinChangedCallbacks:()=>lu,getOptins:()=>pu,getProductsForPurchasePost:()=>uu,initialize:()=>du,isReady:()=>nu,offers:()=>T,platform:()=>L,previewMode:()=>fu,register:()=>hu,resolveSettings:()=>mu,setAuthUrl:()=>gu,setEnvironment:()=>yu,setLocale:()=>bu,setMerchantId:()=>_u,setPublicPath:()=>Su,setTemplates:()=>Eu,setupCart:()=>xu,setupProduct:()=>vu,setupProducts:()=>Ou,store:()=>ka});function Vr(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(Vr,"symbolObservablePonyfill");var $e;typeof self!="undefined"?$e=self:typeof window!="undefined"||typeof window!="undefined"?$e=window:typeof module!="undefined"?$e=module:$e=Function("return this")();var Va=Vr($e),Hr=Va;var Gr=n(function(){return Math.random().toString(36).substring(7).split("").join(".")},"randomString"),lt={INIT:"@@redux/INIT"+Gr(),REPLACE:"@@redux/REPLACE"+Gr(),PROBE_UNKNOWN_ACTION:n(function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Gr()},"PROBE_UNKNOWN_ACTION")};function Ha(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(Ha,"isPlainObject");function Br(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(Br)(t,e)}if(typeof t!="function")throw new Error("Expected the reducer to be a function.");var s=t,i=e,a=[],c=a,l=!1;function p(){c===a&&(c=a.slice())}n(p,"ensureCanMutateNextListeners");function f(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}n(f,"getState");function d(m){if(typeof m!="function")throw new Error("Expected the listener to be a function.");if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var x=!0;return p(),c.push(m),n(function(){if(!!x){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");x=!1,p();var _=c.indexOf(m);c.splice(_,1),a=null}},"unsubscribe")}n(d,"subscribe");function h(m){if(!Ha(m))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(typeof m.type=="undefined")throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,i=s(i,m)}finally{l=!1}for(var x=a=c,C=0;C<x.length;C++){var _=x[C];_()}return m}n(h,"dispatch");function w(m){if(typeof m!="function")throw new Error("Expected the nextReducer to be a function.");s=m,h({type:lt.REPLACE})}n(w,"replaceReducer");function E(){var m,x=d;return m={subscribe:n(function(_){if(typeof _!="object"||_===null)throw new TypeError("Expected the observer to be an object.");function y(){_.next&&_.next(f())}n(y,"observeState"),y();var Ft=x(y);return{unsubscribe:Ft}},"subscribe")},m[Hr]=function(){return this},m}return n(E,"observable"),h({type:lt.INIT}),o={dispatch:h,subscribe:d,getState:f,replaceReducer:w},o[Hr]=E,o}n(Br,"createStore");function Ga(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(Ga,"getUndefinedStateErrorMessage");function Ba(t){Object.keys(t).forEach(function(e){var r=t[e],o=r(void 0,{type:lt.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:lt.PROBE_UNKNOWN_ACTION()})=="undefined")throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+lt.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(Ba,"assertReducerShape");function Lt(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{Ba(r)}catch(l){c=l}return n(function(p,f){if(p===void 0&&(p={}),c)throw c;if(!1)var d;for(var h=!1,w={},E=0;E<i.length;E++){var m=i[E],x=r[m],C=p[m],_=x(C,f);if(typeof _=="undefined"){var y=Ga(m,f);throw new Error(y)}w[m]=_,h=h||_!==C}return h=h||i.length!==Object.keys(p).length,h?w:p},"combination")}n(Lt,"combineReducers");function Ln(t,e){return function(){return e(t.apply(this,arguments))}}n(Ln,"bindActionCreator");function Mn(t,e){if(typeof t=="function")return Ln(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]=Ln(s,e))}return r}n(Mn,"bindActionCreators");function za(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}n(za,"_defineProperty");function jn(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(jn,"ownKeys");function Wa(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?jn(r,!0).forEach(function(o){za(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):jn(r).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}n(Wa,"_objectSpread2");function zr(){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(zr,"compose");function $n(){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=zr.apply(void 0,c)(s.dispatch),Wa({},s,{dispatch:i})}}}n($n,"applyMiddleware");function Vn(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(Vn,"createThunkMiddleware");var Hn=Vn();Hn.withExtraArgument=Vn;var Gn=Hn;var Ls=de(jt());A();j();var Ot="OG_STATE",Ms=n(t=>{try{return t===null?void 0:JSON.parse(t)}catch{return}},"safeParseState"),lo=n(()=>window.og&&window.og.previewMode,"isPreviewMode"),js=n(()=>lo()?{}:Ms(localStorage.getItem(Ot)),"loadState"),il=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"),$s=n(t=>{if(lo())return;let e=il(t);e&&localStorage.getItem(Ot)!==e&&localStorage.setItem(Ot,e)},"saveState"),Vs=n(t=>(0,Ls.throttle)(500,e=>{if(lo())return;let{key:r,newValue:o}=e;r===Ot&&o===null?(t.dispatch({type:fe}),setTimeout(()=>t.dispatch(Cs()),0)):r===Ot&&t.dispatch({type:Te,newValue:Ms(o)})}),"listenLocalStorageChanges");var Hs=de(jt());j();N();var al=n((t,e,r=document)=>r.dispatchEvent(new CustomEvent(t,{detail:e})),"dispatchEvent"),Gs=n(t=>({payload:{product:{id:e,components:r}={}}={}}={})=>setTimeout(()=>al("optin-changed",{productId:e,components:r,optedIn:t}),0),"dispatchOptinChangedEvent"),cl=[{expressions:[({type:t}={})=>t===I,({type:t}={})=>t===F],fn:Gs(!0)},{expressions:[({type:t}={})=>t===U],fn:Gs(!1)}],Bs=n(t=>e=>r=>{let o=t.getState();cl.forEach(s=>{s.expressions.some(i=>i(r,o))&&s.fn(r)}),e(r)},"dispatchMiddleware"),zs=n(t=>e=>r=>{var s;let o;switch(r.type){case R:case U:case I:case F:o=new CustomEvent(`og-${r.type.toLowerCase().replace(/_/g,"-")}`,{bubbles:!0,cancelable:!0,detail:r.payload}),(((s=r.payload)==null?void 0:s.offer)||document).dispatchEvent(o);break;default:}(o==null?void 0:o.defaultPrevented)||e(r)},"offerEvents"),Ws=n(t=>e=>r=>{e(r);let o=(0,Hs.throttle)(500,()=>{$s({...t.getState()})});r.type!==Te&&o()},"localStorageMiddleware");A();j();var po=n(()=>{let t,e;return[new Promise((r,o)=>{t=r,e=o}),t,e]},"waitFor");function Ys(t){let[e,r]=po(),[o,s]=po(),[i,a]=po();o.then(l=>{let{sessionId:p}=t.getState();!p||l&&!p.startsWith(l)?t.dispatch(no(l)):a(p)});let c=Promise.all([o,e,i]);return c.then(()=>{var l;window.addEventListener("storage",Vs(t)),((l=t.getState().auth)==null?void 0:l.ts)||t.dispatch(ws())}),l=>async p=>{Be===p.type||Ge===p.type||ze===p.type?r(p.payload):Ve===p.type?s(p.payload):He===p.type?a(p.payload):await c,l(p)}}n(Ys,"waitUntilOffersReady");function Js(t,...e){if(window.og&&window.og.store)return window.og.store;let r=window.og&&window.og.previewMode,o=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({name:"Ordergroove Offers"}):zr,s=[Ys,Gn,Bs,zs],i={};if(!r)try{i=js(),s.push(Ws)}catch{}let a=o($n(...s,...e.filter(l=>l))),c=Br(t,i,a);return window.og=window.og||{},window.og.store=c,c}n(Js,"makeStore");var ll=Object.defineProperty,fr=n((t,e)=>ll(t,"name",{value:e,configurable:!0}),"i"),pl=fr(t=>e=>t.indexOf(e.origin)>=0,"createIsMessageAllowed"),Ks=["https://rc3.ordergroove.com","https://rc3.stg.ordergroove.com","http://localhost:3000",window.location.origin],Qs=fr(t=>(e,r)=>{Ks.forEach(o=>t.postMessage({ogType:e,...r},o))},"createBroadcastMessage");function uo(t=window.opener,e=window.og){let r=fr(o=>{let s=pl(Ks),i=Qs(o.source),a=o.data.options||{};if(s(o)&&o.data.ogType==="READY"){let c="//static.ordergroove.com/@ordergroove/offers-live-editor/0.6.1/dist/";c.startsWith("//")&&(c=window.location.protocol+c),c.endsWith("/")||(c+="/"),import(`${c}client.js`).then(({initializeClient:l})=>{l({isMessageAllowed:s,broadcastMessage:i,options:a,og:e}),window.removeEventListener("message",r)})}},"handleReady");t&&t!==window&&(window.addEventListener("message",r),Qs(t)("READY"))}n(uo,"f");fr(uo,"offersLiveEditor");var hr=null,ul=n(t=>({dispatch:t}),"defaultMapDispatchToProps"),Zs=n(t=>{if(!hr)throw new Error("Missing redux store.");return hr},"resolveStore"),dl=n((t,e)=>r=>{let{getState:o,dispatch:s}=Zs(r),i=t?t(o(),r):{},a=e(s,r);Object.assign(r,i,a)},"createRecalcProps"),g=n((t,e=ul)=>r=>{let s=dl(t,typeof e=="function"?e:i=>Mn(e,i));return class extends r{get store(){return hr}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._storeUnsubscribe=Zs(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"),Xs=n(t=>{hr=t},"setStore");ge();var fo=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],...bt(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"),tt=n((t={})=>{let e={};return Object.entries(t).forEach(([r,o])=>{Object.entries(o).forEach(([s,i])=>{let a={};i&&!Array.isArray(i)?a=i:a={frequency:s,prepaidShipments:null,regularPrice:i[0],subscriptionPrice:i[2],discountRate:i[1]},e[r]?e[r].push(a):e[r]=[a]})}),e},"getObjectStructuredProductPlans");A();S();var qi=de(wi());S();var Al=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"),Ci=n(t=>t.hasAttribute("product")&&{id:t.getAttribute("product"),...t.hasAttribute("product-components")&&{components:JSON.parse(t.getAttribute("product-components"))}},"buildProduct");var Uo=n(t=>{let e=Ci(t);if(!e){let r=t.offer;r&&(e=Ci(r))}return e},"resolveProduct"),Nl=n(t=>{let e=t;for(;e;){if(e.tagName==="OG-OFFER")return e;e=e.nodeType===11?e.host:e.parentNode}},"resolveOffer"),Fo=n(t=>class extends t{get offer(){return Nl(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"),k=n(t=>class extends Fo(t){get product(){return Uo(this)}},"withProduct"),Cr=n(t=>class extends t{get childOptions(){let e=[],r=null;return this.querySelectorAll("option").forEach(o=>{let s=Al(o.value),i=o.innerText.trim();e.push({value:s,text:i}),!r&&o.selected&&(r=s)}),{options:e,isSelected:r}}},"withChildOptions");var Rr={};$r(Rr,{autoshipByDefault:()=>kl,eligibilityGroups:()=>Mo,eligible:()=>Ri,hasPrepaidOptions:()=>Fl,hasUpcomingOrder:()=>ki,hasUpsellGroup:()=>Ni,inStock:()=>Lo,optedout:()=>Dl,prepaidEligible:()=>Il,prepaidSubscribed:()=>Ul,regularEligible:()=>Ml,subscribed:()=>ql,subscriptionEligible:()=>Ai,upcomingOrderContainsProduct:()=>Ll,upsellEligible:()=>Ii});N();q();var Lo=n((t,e)=>(t.inStock||{})[(e.product||{}).id],"inStock"),Ri=n((t,e)=>(t.autoshipEligible||{})[(e.product||{}).id]||!1,"eligible"),kl=n((t,e)=>(t.autoshipByDefault||{})[(e.product||{}).id]||!1,"autoshipByDefault"),Ai=n((t,e)=>(t.offerId&&t.offerId!=="0"||!1)&&Ri(t,e)&&Lo(t,e),"subscriptionEligible"),Mo=n((t,e)=>{let r=O((e.product||{}).id);return(t.eligibilityGroups||{})[r]||null},"eligibilityGroups"),Ni=n((t,e)=>{let r=Mo(t,e);return r===null||!!r.find(o=>o==="upsell"||o==="impulse_upsell")},"hasUpsellGroup"),Il=n((t,e)=>{let r=Mo(t,e);return(r==null?void 0:r.some(o=>o==="prepaid"))||!1},"prepaidEligible"),ql=n((t,e)=>ir(e.product)(t),"subscribed"),Dl=n((t,e)=>ar(e.product)(t),"optedout"),Ul=n((t,e)=>ys(e.product)(t),"prepaidSubscribed"),Fl=n((t,e)=>re(e.product.id)(t).length>0,"hasPrepaidOptions"),ki=n(t=>!!(t.nextUpcomingOrder&&t.nextUpcomingOrder.public_id),"hasUpcomingOrder"),Ll=n((t,e)=>(t.nextUpcomingOrder&&t.nextUpcomingOrder.products||[]).includes((e.product||{}).id),"upcomingOrderContainsProduct"),Ii=n((t,e)=>{var r;return!((r=e.offer)==null?void 0:r.isCart)&&t.offerId&&t.offerId!=="0"&&t.auth&&Lo(t,e)&&ki(t)&&Ni(t,e)},"upsellEligible"),Ml=n((t,e)=>Ai(t,e)&&!Ii(t,e),"regularEligible");var jl=n(t=>t.replace(/(\r\n|\n|\r|\s)+/gm,""),"removeWhitespace"),jo=class extends k(P){static get properties(){return{...super.properties,state:{type:Object,attribute:!1},test:{type:String}}}render(){if(!this.test)return u``;let e=jl(this.test);return e=e.replace(/(![a-zA-Z]+)/g,"($1)"),qi.default.parse(e,o=>Rr[o]&&Rr[o](this.state,this))?u`
|
|
111
111
|
<slot></slot>
|
|
112
|
-
`:
|
|
112
|
+
`:u``}shouldUpdate(e){return e.size&&(this.product&&this.product.id in this.state.autoshipEligible&&this.product.id in this.state.inStock||!this.product.id)}};n(jo,"When");var $l=n(t=>({state:t}),"mapStateToProps"),Di=g($l)(jo);S();A();S();N();ge();var Ui={type:Object,converter:{toAttribute(t){return t==null?t:JSON.stringify(t)},fromAttribute(t){return t&&t.match(/[{[]/)?JSON.parse(t):{id:t}}}},ve={type:String,attribute:"default-frequency",converter:{fromAttribute(t){return t&&Zr(t)?t:null}}},Ar={type:Boolean,attribute:!0,reflect:!0},it={type:Object,attribute:!1};S();N();var Vl=n(t=>class extends t{getOption(e,r=e){let o=to(e);if(this.hasAttribute(o)){let s=this.getAttribute(o);return s.toString().toLowerCase()==="true"?!0:s.toString().toLowerCase()==="false"?!1:s}if(this.template&&this.template.config&&typeof this.template.config[r]!="undefined")return this.template.config[r];if(this.config&&typeof this.config[r]!="undefined")return this.config[r]}applyTemplate(e){this.template=e;let r=typeof e.markup=="undefined"?this.constructor.initialTemplate:e.markup;r&&this._templateMarkup!==r&&(this._templateMarkup=r,this.innerHTML=r)}refreshTemplate(){if(this._templates&&this._templates.length){let e=this._templates.find(({selector:r})=>{try{return this.matches(r)}catch{return!1}});this.applyTemplate(e||{})}}set templates(e){this._templates=e,this.refreshTemplate()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.constructor.initialTemplate&&!this.innerHTML.trim()&&(this.innerHTML=this.constructor.initialTemplate)}},"withTemplate"),M=Vl(P);var J=class extends k(M){static get properties(){return{subscribed:Ar,frequencyMatch:{type:Boolean,reflect:!0,attribute:"frequency-match"},productDefaultFrequency:{type:String},defaultFrequency:{type:String},frequencies:{type:Array}}}static get styles(){return b`
|
|
113
113
|
:host {
|
|
114
114
|
cursor: default;
|
|
115
115
|
display: inline-block;
|
|
@@ -172,27 +172,27 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
172
172
|
text-align: center;
|
|
173
173
|
overflow: visible;
|
|
174
174
|
}
|
|
175
|
-
`}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?
|
|
175
|
+
`}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`
|
|
176
176
|
<slot name="subscribed"></slot>
|
|
177
177
|
<slot name="frequency-mismatch"></slot>
|
|
178
|
-
`:this.subscribed&&this.defaultFrequency===this.frequency?
|
|
178
|
+
`:this.subscribed&&this.defaultFrequency===this.frequency?u`
|
|
179
179
|
<slot name="subscribed"></slot>
|
|
180
180
|
<slot name="frequency-match"></slot>
|
|
181
|
-
`:this.subscribed&&this.defaultFrequency!==this.frequency?
|
|
181
|
+
`:this.subscribed&&this.defaultFrequency!==this.frequency?u`
|
|
182
182
|
<slot name="subscribed"></slot>
|
|
183
183
|
<slot name="frequency-mismatch"></slot>
|
|
184
|
-
`:
|
|
184
|
+
`:u`
|
|
185
185
|
<slot name="not-subscribed"></slot>
|
|
186
|
-
`}};n(
|
|
186
|
+
`}};n(J,"OptinStatus");var le=n((t,e={})=>({subscribed:X(e.product)(t),frequency:te(e.product)(t),productDefaultFrequency:Ke((e.product||{}).id)(t),prepaidShipmentsOptedIn:H(e.product)(t),...G(t,e,"defaultFrequency"),...G(t,e,"frequencies"),...Qe(t,e)}),"mapStateToProps"),Fi=g(le)(J);q();St();var $o=class extends J{static get properties(){return{...super.properties,frequency:{type:String,reflect:!0},defaultFrequency:ve,optinButtonLabel:{type:String},prepaidShipmentsOptedIn:{type:Number},disableWhenPrepaidEnabled:{type:Boolean,reflect:!0,attribute:"disable-when-prepaid-enabled"}}}updated(e){if(e.has("subscribed")||e.has("frequencies")){if(L.shopify_selling_plans&&this.store){let r=this.getAttribute("default-frequency");r=oo(r,this.store.getState().config),this.sellingPlanFreq=r}this.frequencyMatch=this.frequency===this.optinFrequency}}get optinFrequency(){let e;return this.sellingPlanFreq?e=this.sellingPlanFreq:this.hasAttribute("default-frequency")?e=this.getAttribute("default-frequency"):e=this.offer?this.offer.defaultFrequency:this.defaultFrequency,L.shopify_selling_plans&&this.store&&(e=oo(e,this.store.getState().config)),e}handleClick(e){this.optinProduct(Uo(this),this.optinFrequency,this.offer),e.preventDefault()}get isActive(){return this.disableWhenPrepaidEnabled&&this.prepaidShipmentsOptedIn>0?!1:this.subscribed}render(){return u`
|
|
187
187
|
<slot name="default">
|
|
188
|
-
<button id="action-trigger" class="btn radio ${this.
|
|
188
|
+
<button id="action-trigger" class="btn radio ${this.isActive?" active":""}"></button>
|
|
189
189
|
<label for="action-trigger">
|
|
190
190
|
<slot>
|
|
191
191
|
<slot name="label"><og-text key="offerOptInLabel"></og-text></slot>
|
|
192
192
|
</slot>
|
|
193
193
|
</label>
|
|
194
194
|
</slot>
|
|
195
|
-
`}};n(
|
|
195
|
+
`}};n($o,"OptinButton");var Li=g(le,{optinProduct:ie})($o);S();A();var Vo=class extends J{static get properties(){return{...super.properties,label:{type:String}}}handleClick(e){this.optoutProduct(this.product,this.offer),e.preventDefault()}render(){return u`
|
|
196
196
|
<slot name="default">
|
|
197
197
|
<button id="action-trigger" class="btn radio ${this.subscribed?"":"active"}"></button>
|
|
198
198
|
<label for="action-trigger">
|
|
@@ -201,32 +201,32 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
201
201
|
</slot>
|
|
202
202
|
</label>
|
|
203
203
|
</slot>
|
|
204
|
-
`}};n(
|
|
204
|
+
`}};n(Vo,"OptoutButton");var Mi=g(le,{optoutProduct:et})(Vo);S();A();S();N();ge();var je=n((t,e)=>{let{every:r,every_period:o}=bt(t);return r&&o?u`
|
|
205
205
|
${r}
|
|
206
206
|
<og-text key="frequencyPeriods" variant="${o}" pluralize="${r}"></og-text>
|
|
207
|
-
${e&&e===t?
|
|
207
|
+
${e&&e===t?u`
|
|
208
208
|
<og-text key="defaultFrequencyCopy"></og-text>
|
|
209
209
|
`:""}
|
|
210
|
-
`:t},"frequencyText"),
|
|
210
|
+
`:t},"frequencyText"),It=class extends k(M){static get properties(){return{...super.properties,disabled:{type:Boolean},subscribed:Ar,frequency:{type:String},defaultFrequency:ve,productDefaultFrequency:{type:String},config:{type:Object},frequencies:{converter:{fromAttribute:hs}}}}static get styles(){return b`
|
|
211
211
|
:host[hidden] {
|
|
212
212
|
display: none;
|
|
213
213
|
}
|
|
214
214
|
:host {
|
|
215
215
|
display: inline-block;
|
|
216
216
|
}
|
|
217
|
-
`}constructor(){super();this.frequencies=[]}render(){let e=this.frequency||this.defaultFrequency;return
|
|
217
|
+
`}constructor(){super();this.frequencies=[]}render(){let e=this.frequency||this.defaultFrequency;return u`
|
|
218
218
|
<span>
|
|
219
|
-
${this.subscribed&&
|
|
220
|
-
<slot name="subscribed">${
|
|
219
|
+
${this.subscribed&&u`
|
|
220
|
+
<slot name="subscribed">${je(e)} </slot>
|
|
221
221
|
`||""}
|
|
222
|
-
${!this.subscribed&&
|
|
222
|
+
${!this.subscribed&&u`
|
|
223
223
|
<slot name="not-subscribed"></slot>
|
|
224
224
|
`||""}
|
|
225
|
-
${this.subscribed&&this.defaultFrequency&&this.defaultFrequency!==this.frequency&&
|
|
225
|
+
${this.subscribed&&this.defaultFrequency&&this.defaultFrequency!==this.frequency&&u`
|
|
226
226
|
<slot name="frequency-mismatch"></slot>
|
|
227
227
|
`||""}
|
|
228
228
|
</span>
|
|
229
|
-
`}};n(
|
|
229
|
+
`}};n(It,"FrequencyStatus");var qt=n((t,e)=>{var r,o;return{subscribed:X(e.product)(t),frequency:te(e.product)(t),productDefaultFrequency:Ke((e.product||{}).id)(t),configDefaultFrequency:(r=t.config)==null?void 0:r.defaultFrequency,frequenciesText:(o=t.config)==null?void 0:o.frequenciesText,config:t.config,...G(t,e,"frequencies"),...G(t,e,"defaultFrequency"),...Qe(t,e)}},"mapStateToProps"),ji=g(qt)(It);N();var Ho=class extends Cr(J){static get properties(){return{...super.properties,frequencies:{type:Array,attribute:!1},frequency:{type:String},defaultFrequency:ve}}static get styles(){return b`
|
|
230
230
|
:host {
|
|
231
231
|
display: inline-block;
|
|
232
232
|
cursor: pointer;
|
|
@@ -236,24 +236,24 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
236
236
|
border-width: var(--og-select-border-width, 1px);
|
|
237
237
|
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
|
|
238
238
|
}
|
|
239
|
-
`}get currentFrequency(){return this.subscribed?this.frequency||this.productDefaultFrequency||this.defaultFrequency:"optedOut"}onOptinChange(e){e==="optedOut"?this.optoutProduct(this.product,this.offer):this.productChangeFrequency(this.product,e,this.offer)}render(){var o;let{options:e}=this.childOptions,r;return((o=this.frequencies)==null?void 0:o.length)?r=[e.find(s=>s.value==="optedOut"),...this.frequencies.map((s,i)=>({value:s,text:this.frequenciesText&&i in this.frequenciesText?this.frequenciesText[i]:
|
|
239
|
+
`}get currentFrequency(){return this.subscribed?this.frequency||this.productDefaultFrequency||this.defaultFrequency:"optedOut"}onOptinChange(e){e==="optedOut"?this.optoutProduct(this.product,this.offer):this.productChangeFrequency(this.product,e,this.offer)}render(){var o;let{options:e}=this.childOptions,r;return((o=this.frequencies)==null?void 0:o.length)?r=[e.find(s=>s.value==="optedOut"),...this.frequencies.map((s,i)=>({value:s,text:this.frequenciesText&&i in this.frequenciesText?this.frequenciesText[i]:je(s,this.defaultFrequency)}))]:r=e,u`
|
|
240
240
|
<og-select
|
|
241
241
|
.options="${r}"
|
|
242
242
|
.selected="${this.currentFrequency}"
|
|
243
243
|
.onChange="${({target:{value:s}})=>this.onOptinChange(s)}"
|
|
244
244
|
></og-select>
|
|
245
|
-
`}};n(
|
|
245
|
+
`}};n(Ho,"OptinSelect");var $i=g((t,e)=>({...le(t,e),...qt(t,e),...G(t,e,"frequencies")}),{productChangeFrequency:pr,optoutProduct:et})(Ho);S();A();var Go=class extends k(M){static get styles(){return b`
|
|
246
246
|
:host[hidden] {
|
|
247
247
|
display: none;
|
|
248
248
|
}
|
|
249
249
|
:host {
|
|
250
250
|
display: inline-block;
|
|
251
251
|
}
|
|
252
|
-
`}static get properties(){return{...super.properties,upcomingOrderDate:{type:String,attribute:!1},auth:
|
|
252
|
+
`}static get properties(){return{...super.properties,upcomingOrderDate:{type:String,attribute:!1},auth:it,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`
|
|
253
253
|
<slot>
|
|
254
254
|
<og-next-upcoming-order></og-next-upcoming-order>
|
|
255
255
|
</slot>
|
|
256
|
-
`}};n(
|
|
256
|
+
`}};n(Go,"UpsellButton");var Hl=n(t=>({isPreview:t.previewUpsellOffer}),"mapStateToProps"),Vi=g(Hl,{fetchOrders:dr})(Go);S();A();N();var Bo=class extends k(M){static get properties(){return{...super.properties,defaultFrequency:ve,auth:it,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`
|
|
257
257
|
<og-modal ?show=${this.show} @close=${()=>this.close()} @confirm=${()=>this.confirm()}>
|
|
258
258
|
<div slot="content">
|
|
259
259
|
<slot>
|
|
@@ -291,7 +291,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
291
291
|
</slot>
|
|
292
292
|
</span>
|
|
293
293
|
</og-modal>
|
|
294
|
-
`}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(
|
|
294
|
+
`}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(Bo,"UpsellModal");var Gl=n((t,e)=>({auth:t.auth,offerId:t.offerId,subscribed:X(e.product)(t),frequency:te(e.product)(t),...G(t,e,"defaultFrequency"),nextUpcomingOrder:t.previewUpsellOffer?{public_id:"preview-order-id"}:t.nextUpcomingOrder,isPreview:t.previewUpsellOffer}),"mapStateToProps"),Hi=g(Gl,{concludeUpsell:Os,createIu:Ns})(Bo);S();A();var zo=class extends J{static get properties(){return{...super.properties,frequency:{type:String}}}static get styles(){return b`
|
|
295
295
|
:host {
|
|
296
296
|
cursor: default;
|
|
297
297
|
display: inline-block;
|
|
@@ -323,7 +323,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
323
323
|
transform: scale(1.6);
|
|
324
324
|
margin-left: 2px;
|
|
325
325
|
}
|
|
326
|
-
`}handleClick(e){this.subscribed?this.optoutProduct(this.product,this.offer):this.optinProduct(this.product,this.frequency||this.productDefaultFrequency||this.defaultFrequency,this.offer),e.preventDefault()}render(){return
|
|
326
|
+
`}handleClick(e){this.subscribed?this.optoutProduct(this.product,this.offer):this.optinProduct(this.product,this.frequency||this.productDefaultFrequency||this.defaultFrequency,this.offer),e.preventDefault()}render(){return u`
|
|
327
327
|
<slot name="default">
|
|
328
328
|
<button id="action-trigger" class="btn checkbox ${this.subscribed?"active":""}"></button>
|
|
329
329
|
<label for="action-trigger">
|
|
@@ -332,13 +332,13 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
332
332
|
></slot>
|
|
333
333
|
</label>
|
|
334
334
|
</slot>
|
|
335
|
-
`}};n(
|
|
335
|
+
`}};n(zo,"OptinToggle");var Gi=g(le,{optoutProduct:et,optinProduct:ie})(zo);S();var Bl=n((t,e)=>`${t}${parseInt(e,10)>1?"s":""}`,"pluralize"),Wo=class extends Fo(P){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&&Bl(e,this.pluralize)}render(){return u`
|
|
336
336
|
${this.getText()}
|
|
337
|
-
`}};n(
|
|
338
|
-
${this.label} ${s?
|
|
339
|
-
`}renderFallback(){return
|
|
340
|
-
${
|
|
341
|
-
`}};n(
|
|
337
|
+
`}};n(Wo,"Text");var zl=n(t=>({i18n:t.locale||{}}),"mapStateToProps"),Bi=g(zl)(Wo);S();q();var at=class{constructor(e){this.value=e,this.className="DiscountAmount"}toString(){return`${this.value}`}};n(at,"DiscountAmount");var Dt=class extends at{constructor(e){super(e);this.className="DiscountPercent"}toString(){return`${super.toString()}%`}};n(Dt,"DiscountPercent");var Yo=class extends Dt{constructor(e){super(e);this.className="ShippingDiscountPercent"}toString(){return this.value===100?"free shipping":super.toString()}};n(Yo,"ShippingDiscountPercent");var Jo="Discount Percent",Ko="Discount Amount",zi="total_price",Wi="shipping_total",Yi="sub_total",Qo=n(({field:t,object:e,type:r,value:o})=>{let i=[[new Dt(o),{field:zi,object:"item",type:Jo}],[new at(o),{field:zi,object:"item",type:Ko}],[new Yo(o),{field:Wi,object:"order",type:Jo}],[new at(o),{field:Wi,object:"order",type:Ko}],[new Dt(o),{field:Yi,object:"order",type:Jo}],[new at(o),{field:Yi,object:"order",type:Ko}]].find(([,a])=>a.field===t&&a.object===e&&a.type===r);return i&&i[0]},"discountBuilder");function Wl(t){return!(Qo(t).className!==this.incentiveClass||this.incentiveValue&&this.incentiveValue.toString()!==t.value.toString())}n(Wl,"filterIncentives");var Zo=class extends k(P){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(Wl.bind({incentiveClass:e,incentiveValue:r}));return u`
|
|
338
|
+
${this.label} ${s?Qo(s):this.renderFallback()}
|
|
339
|
+
`}renderFallback(){return u`
|
|
340
|
+
${Qo({field:"sub_total",object:"order",type:"Discount Percent",value:this.value})}
|
|
341
|
+
`}};n(Zo,"IncentiveText");var Yl=n((t,e)=>{var r;return{incentives:(t.incentives||{})[e&&(e==null?void 0:e.product)&&O((r=e==null?void 0:e.product)==null?void 0:r.id)]||{}}},"mapStateToProps"),Ji=g(Yl)(Zo);S();A();var Xo=class extends Cr(It){static get properties(){return{...super.properties,defaultText:{type:String,attribute:"default-text"}}}static get styles(){return b`
|
|
342
342
|
:host {
|
|
343
343
|
display: inline-block;
|
|
344
344
|
cursor: pointer;
|
|
@@ -349,17 +349,17 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
349
349
|
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
|
|
350
350
|
z-index: 1;
|
|
351
351
|
}
|
|
352
|
-
`}set defaultFrequency(e){this._defaultFrequency=e}get defaultFrequency(){var s,i;let{options:e,isSelected:r}=this.childOptions,o;if(this.productDefaultFrequency?o=this.productDefaultFrequency:r?o=r:e.length?o=e[0].value:o=this._defaultFrequency,((s=this.frequencies)==null?void 0:s.length)&&o&&((i=this.config)==null?void 0:i.frequenciesEveryPeriod)){let a=this.config.frequenciesEveryPeriod.findIndex(c=>c===o);if(a>=0)return this.frequencies[a]}return o}get currentFrequency(){return this.frequency?this.frequency:this.defaultFrequency}productChangeFrequency(e,r){this.frequency=r}render(){var o;let e,r=this.defaultFrequency;return((o=this.frequencies)==null?void 0:o.length)?e=this.frequencies.map((s,i)=>{let a;return this.config.frequenciesEveryPeriod&&i in this.config.frequenciesEveryPeriod?a=
|
|
352
|
+
`}set defaultFrequency(e){this._defaultFrequency=e}get defaultFrequency(){var s,i;let{options:e,isSelected:r}=this.childOptions,o;if(this.productDefaultFrequency?o=this.productDefaultFrequency:r?o=r:e.length?o=e[0].value:o=this._defaultFrequency,((s=this.frequencies)==null?void 0:s.length)&&o&&((i=this.config)==null?void 0:i.frequenciesEveryPeriod)){let a=this.config.frequenciesEveryPeriod.findIndex(c=>c===o);if(a>=0)return this.frequencies[a]}return o}get currentFrequency(){return this.frequency?this.frequency:this.defaultFrequency}productChangeFrequency(e,r){this.frequency=r}render(){var o;let e,r=this.defaultFrequency;return((o=this.frequencies)==null?void 0:o.length)?e=this.frequencies.map((s,i)=>{let a;return this.config.frequenciesEveryPeriod&&i in this.config.frequenciesEveryPeriod?a=je(this.config.frequenciesEveryPeriod[i],r):this.frequenciesText&&i in this.frequenciesText?a=this.frequenciesText[i]:a=je(s,this.defaultFrequency),{value:s,text:a}}):{options:e}=this.childOptions,e.length||(e=(this.frequencies||[]).map(s=>({value:s,text:je(s,r)}))),e=e.map(({text:s,value:i})=>({text:i===r?u`
|
|
353
353
|
${s} ${this.defaultText||""}
|
|
354
|
-
`:s,value:i})),
|
|
354
|
+
`:s,value:i})),u`
|
|
355
355
|
<og-select
|
|
356
356
|
.options="${e}"
|
|
357
357
|
.selected="${this.currentFrequency}"
|
|
358
358
|
.onChange="${({target:{value:s}})=>{this.productChangeFrequency(this.product,s,this.offer)}}"
|
|
359
359
|
></og-select>
|
|
360
|
-
`}};n(
|
|
361
|
-
${
|
|
362
|
-
`}};n(
|
|
360
|
+
`}};n(Xo,"SelectFrequency");var Ki=g(qt,{productChangeFrequency:pr})(Xo);S();var Jl={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 Qi=n((t,e)=>t instanceof Date?(e||"").toString().replace(/\{\{([-\w]+)\}\}/g,r=>{let o=r.replace(/[{}]/g,""),s=Jl[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 en=class extends P{static get properties(){return{value:{type:String,reflect:!0},format:{type:String}}}createRenderRoot(){return this}render(){return u`
|
|
361
|
+
${Qi(this.value,this.format||"{{month-long}} {{day}}, {{year-numeric}}")}
|
|
362
|
+
`}};n(en,"FormattedDate");var Kl=n(t=>({value:t.previewUpsellOffer?new Date:t.nextUpcomingOrder.place}),"mapStateToProps"),Zi=g(Kl)(en);S();var ta=de(mt());A();j();var Xi=n((t,e,r)=>n(async function(s){await s({type:dt,payload:t}),await s({type:Pe}),await s(Ie({in_stock:{[e]:!0},eligibility_groups:{[e]:["subscription","upsell"]},result:"success",autoship:{[e]:!0},autoship_by_default:{[e]:!1},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"]}}},r))},"setPreviewStandardOfferThunk"),"setPreviewStandardOffer"),Ql=n((t,e)=>(Object.entries(e).forEach(([r,o])=>{if(Object.prototype.hasOwnProperty.call(t,r)){let s=t[r].concat(o),i=[...new Set(s.map(a=>JSON.stringify(a)))];t[r]=i.map(a=>JSON.parse(a))}else t[r]=o}),t),"mergeProductPlansToState"),Zl=n((t,e,r)=>n(async function(s,i){await s({type:ft,payload:t});let{merchantId:a}=i();t?(await s(Ie({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},autoship_by_default:{[e]:!1},modifiers:{}},r)),await s(so({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 s(vt(a,"sig_field","ts","sig"))):await s(be())},"setPreviewUpsellOfferThunk"),"setPreviewUpsellOffer"),Xl=n((t,e,r)=>n(async function(s,i){let a=i().productPlans;await s({type:Wr,payload:t}),await s({type:Pe}),await s(Ie({in_stock:{[e]:!0},eligibility_groups:{[e]:["subscription","upsell","prepaid"]},result:"success",autoship:{[e]:!0},autoship_by_default:{[e]:!1},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"]}}},r)),await s({type:z,payload:Ql(a,tt({[e]:[{frequency:"1_3",regularPrice:"$15.00",subscriptionPrice:"$12.00",discountRate:"25%",prepaidShipments:3,regularPrepaidPrice:"$36.00",prepaidSavingsPerShipment:"$3.00",prepaidSavingsTotal:"$9.00",prepaidExtraSavingsPercentage:"10%"},{frequency:"1_3",regularPrice:"$15.00",subscriptionPrice:"$12.00",discountRate:"20%",prepaidShipments:6,regularPrepaidPrice:"$72.00",prepaidSavingsPerShipment:"$3.00",prepaidSavingsTotal:"$18.00",prepaidExtraSavingsPercentage:"10%"},{frequency:"1_3",regularPrice:"$15.00",subscriptionPrice:"$12.00",discountRate:"20%",prepaidShipments:12,regularPrepaidPrice:"$144.00",prepaidSavingsPerShipment:"$3.00",prepaidSavingsTotal:"$36.00",prepaidExtraSavingsPercentage:"10%"}]}))}),await s({type:Ye,payload:{prepaidSellingPlans:{[e]:[{numberShipments:3,sellingPlan:"1_3"},{numberShipments:6,sellingPlan:"1_3"},{numberShipments:12,sellingPlan:"1_3"}]}}})},"setPreviewPrepaidThunk"),"setPreviewPrepaid"),ea=n((t,e,r)=>async function(o,s){switch(await o({type:fe}),await o({type:dt,payload:!1}),await o({type:ft,payload:!1}),t){case"regular":o(Xi(!0,r.product.id,r));break;case"upsell":o(Zl(!0,r.product.id,r));break;case"subscribed":o(Xi(!0,r.product.id,r)),o(ie(r.product,"2_2"));break;case"prepaid":o(Xl(!0,r.product.id,r)),o(ie(r.product,"1_3"));break;default:}},"setPreview");A();N();q();j();var ep=n((...t)=>JSON.stringify(t),"memoizeKey"),tp=(0,ta.default)((t,e)=>Object.assign({components:e},t),ep),tn=class extends M{static get properties(){return{...super.properties,config:{type:Object,attribute:!1},product:Ui,productComponents:{type:Array,attribute:"product-components"},offerId:{type:String,attribute:!1},auth:it,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},productFrequency:{type:String},isCart:{type:Boolean,attribute:"cart"},optedin:{type:Object},variationId:{type:String}}}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":e==="preview-prepaid-offer"&&(this.preview="prepaid")}static get styles(){return b`
|
|
363
363
|
:host[hidden] {
|
|
364
364
|
display: none;
|
|
365
365
|
}
|
|
@@ -508,9 +508,9 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
508
508
|
</og-when>
|
|
509
509
|
</og-when>
|
|
510
510
|
|
|
511
|
-
`}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{id:r,locale:o}=e;this.variationId=r,this.locale=o;let s=new CustomEvent("template-changed");this.dispatchEvent(s)}updated(e){if(e.has("preview")&&this.setPreview(this.preview,e.get("preview"),this),this.frequency=this.defaultFrequency,e.has("product")&&!this.isPreview&&
|
|
511
|
+
`}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{id:r,locale:o}=e;this.variationId=r,this.locale=o;let s=new CustomEvent("template-changed");this.dispatchEvent(s)}updated(e){if(e.has("preview")&&this.setPreview(this.preview,e.get("preview"),this),this.frequency=this.defaultFrequency,e.has("product")&&!this.isPreview&&cr(()=>this.fetchOffer(this.product.id,we,this)),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=tp(this.product,this.productComponents),o=Object.assign({},this.product,{components:e.get("productComponents")});D(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.isCart)&&this.product.id&&this.optinProduct&&!(this.optedin||[]).find(r=>D(r,this.product))&&this.optinProduct({...this.product,...this.productComponents.length&&{components:this.productComponents}},this.defaultFrequency,this)}get isPreview(){return this.preview||window.og.previewMode}render(){return u`
|
|
512
512
|
<slot></slot>
|
|
513
|
-
`}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(
|
|
513
|
+
`}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(tn,"Offer");var rp=n((t,e)=>({config:t.config,auth:t.auth,offerId:((t.productOffer||{})[(e.product||{}).id]||[])[0],productFrequency:te(e.product)(t),productDefaultFrequency:Ke((e.product||{}).id)(t),...G(t,e,"autoshipByDefault",eo(t)[(e.product||{}).id]),...ar(e.product)(t)&&{autoshipByDefault:!1},optedin:xt(t),subscribed:X(e.product)(t),...Qe(t)}),"mapStateToProps"),ra=g(rp,{fetchOffer:Rs,fetchOrders:dr,productHasChangedComponents:vs,optinProduct:ie,setFirstOrderPlaceDate:Us,setProductToSubscribe:Fs,setPreview:ea})(tn);S();var Nr=class extends P{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 b`
|
|
514
514
|
:host[hidden] {
|
|
515
515
|
display: none;
|
|
516
516
|
}
|
|
@@ -622,7 +622,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
622
622
|
.btn {
|
|
623
623
|
cursor: pointer;
|
|
624
624
|
}
|
|
625
|
-
`}close(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("close"))}confirm(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("confirm"))}get confirmButton(){return this.showConfirmButton?
|
|
625
|
+
`}close(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("close"))}confirm(){this.removeAttribute("show"),this.dispatchEvent(new CustomEvent("confirm"))}get confirmButton(){return this.showConfirmButton?u`
|
|
626
626
|
<span @click="${()=>this.confirm()}">
|
|
627
627
|
<slot name="confirm" class="btn">
|
|
628
628
|
<button class="og-modal__btn og-modal__btn-primary og-modal__confirm" @click="${()=>this.confirm()}">
|
|
@@ -630,7 +630,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
630
630
|
</button>
|
|
631
631
|
</slot>
|
|
632
632
|
</span>
|
|
633
|
-
`:
|
|
633
|
+
`:u``}get cancelButton(){return this.showCancelButton?u`
|
|
634
634
|
<span @click="${()=>this.close()}" class="btn">
|
|
635
635
|
<slot name="cancel">
|
|
636
636
|
<button class="og-modal__btn og-modal__cancel" @click="${()=>this.close()}">
|
|
@@ -638,7 +638,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
638
638
|
</button>
|
|
639
639
|
</slot>
|
|
640
640
|
</span>
|
|
641
|
-
`:
|
|
641
|
+
`:u``}render(){return this.show?u`
|
|
642
642
|
<div class="og-modal is-open" aria-hidden="true">
|
|
643
643
|
<div class="og-modal__overlay" tabindex="-1">
|
|
644
644
|
<div class="og-modal__container" role="dialog" aria-modal="true">
|
|
@@ -657,7 +657,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
657
657
|
</div>
|
|
658
658
|
</div>
|
|
659
659
|
</div>
|
|
660
|
-
`:
|
|
660
|
+
`:u``}};n(Nr,"Modal");S();var kr=class extends P{static get styles(){return b`
|
|
661
661
|
:host {
|
|
662
662
|
display: inline-block;
|
|
663
663
|
color: inherit;
|
|
@@ -709,9 +709,9 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
709
709
|
line-height: 0.2em;
|
|
710
710
|
transform: scaleY(0.5);
|
|
711
711
|
}
|
|
712
|
-
`}static get properties(){return{options:{type:Array},selected:{type:String}}}render(){return
|
|
712
|
+
`}static get properties(){return{options:{type:Array},selected:{type:String}}}render(){return u`
|
|
713
713
|
<select @change="${n(r=>this.onChange(r),"handleOnChange")}">
|
|
714
|
-
${this.options.map(r=>
|
|
714
|
+
${this.options.map(r=>u`
|
|
715
715
|
<option
|
|
716
716
|
value="${r.value}"
|
|
717
717
|
?selected=${r.value===this.selected}
|
|
@@ -721,7 +721,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
721
721
|
`)}
|
|
722
722
|
</select>
|
|
723
723
|
<span>▼</span>
|
|
724
|
-
`}};n(
|
|
724
|
+
`}};n(kr,"Select");S();var Ir=class extends P{static get properties(){return{placement:{type:String,default:"bottom"}}}static get styles(){return b`
|
|
725
725
|
:host[hidden] {
|
|
726
726
|
display: none;
|
|
727
727
|
}
|
|
@@ -871,7 +871,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
871
871
|
pointer-events: auto;
|
|
872
872
|
transform: translateY(0px);
|
|
873
873
|
}
|
|
874
|
-
`}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
|
|
874
|
+
`}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`
|
|
875
875
|
<span class="tooltip">
|
|
876
876
|
<span class="trigger">
|
|
877
877
|
<slot name="trigger">
|
|
@@ -884,7 +884,7 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
884
884
|
</slot>
|
|
885
885
|
</div>
|
|
886
886
|
</span>
|
|
887
|
-
`}};n(
|
|
887
|
+
`}};n(Ir,"Tooltip");S();N();A();S();N();A();var pe=class extends k(P){static get properties(){return{options:{type:Array},shipmentsOptedIn:{type:Number},prepaidShipmentsSelected:{type:Number},defaultPrepaidShipments:{type:Number,attribute:"default-prepaid-shipments"}}}get checked(){return this.shipmentsOptedIn>1}get selectedNumberOfShipments(){return this.prepaidShipmentsSelected||this.shipmentsOptedIn||this.getDefaultPrepaidShipments()}getDefaultPrepaidShipments(){return this.options.includes(this.defaultPrepaidShipments)?this.defaultPrepaidShipments:this.options[1]||this.options[0]}handleChange(e){e.target.checked?this.productChangePrepaidShipments(this.product,this.selectedNumberOfShipments,this.offer):this.productChangePrepaidShipments(this.product,null,this.offer)}handleSelect({target:{value:e}}){let r=+e;this.productChangePrepaidShipments(this.product,r,this.offer)}render(){return u``}};n(pe,"PrepaidStatus");var op=n((t,e)=>({options:re(e.product.id)(t),shipmentsOptedIn:H(e.product)(t),prepaidShipmentsSelected:ee(e.product)(t)}),"mapStateToProps"),Ym=g(op,{productChangePrepaidShipments:ye})(pe);var rn=class extends pe{constructor(){super();this.options=[],this.text="shipments"}static get properties(){return{...super.properties,text:{type:String}}}static get styles(){return b`
|
|
888
888
|
og-select {
|
|
889
889
|
display: inline-block;
|
|
890
890
|
cursor: pointer;
|
|
@@ -901,40 +901,115 @@ var lib=(()=>{var Na=Object.create;var ot=Object.defineProperty;var Ia=Object.ge
|
|
|
901
901
|
accent-color: var(--og-prepaid-checkbox-color, black);
|
|
902
902
|
border-radius: 4px;
|
|
903
903
|
}
|
|
904
|
-
`}
|
|
904
|
+
`}render(){if(this.options.length===0)return u``;let e=this.options.map(r=>({value:r,text:`${r} ${this.text}`}));return u`
|
|
905
905
|
<div>
|
|
906
906
|
<input id="cbx" type="checkbox" .checked=${this.checked} @change=${this.handleChange} />
|
|
907
907
|
<label for="cbx">
|
|
908
908
|
<slot name="label">Prepay for</slot>
|
|
909
|
-
${this.options.length>1?
|
|
909
|
+
${this.options.length>1?u`
|
|
910
910
|
<og-select
|
|
911
911
|
.options=${e}
|
|
912
|
-
.selected=${this.
|
|
912
|
+
.selected=${this.selectedNumberOfShipments}
|
|
913
913
|
.onChange="${r=>this.handleSelect(r)}"
|
|
914
914
|
></og-select>
|
|
915
|
-
`:
|
|
915
|
+
`:u`
|
|
916
916
|
<span>${e[0].text}</span>
|
|
917
917
|
`}
|
|
918
918
|
<slot name="append"></slot>
|
|
919
919
|
</label>
|
|
920
920
|
</div>
|
|
921
|
-
`}};n(
|
|
921
|
+
`}};n(rn,"PrepaidToggle");var np=n((t,e)=>({options:re(e.product.id)(t),shipmentsOptedIn:H(e.product)(t),prepaidShipmentsSelected:ee(e.product)(t)}),"mapStateToProps"),oa=g(np,{productChangePrepaidShipments:ye})(rn);S();N();q();var on=class extends k(M){static get properties(){return{...super.properties,shipmentsOptedIn:{type:Number},productPlans:{type:Object},prepaidShipmentsSelected:{type:Number},totalPrice:{type:Boolean,reflect:!0,attribute:"total-price"},perDeliveryPrice:{type:Boolean,reflect:!0,attribute:"per-delivery-price"},totalSavings:{type:Boolean,reflect:!0,attribute:"total-savings"},perDeliverySavings:{type:Boolean,reflect:!0,attribute:"per-delivery-savings"},percentageSavings:{type:Boolean,reflect:!0,attribute:"percentage-savings"},extraPercentageSavings:{type:Boolean,reflect:!0,attribute:"extra-percentage-savings"},numberOfShipments:{type:Boolean,reflect:!0,attribute:"number-of-shipments"}}}static get styles(){return b`
|
|
922
922
|
:host {
|
|
923
923
|
display: inline-block;
|
|
924
924
|
text-indent: initial;
|
|
925
925
|
}
|
|
926
|
-
`}get value(){let e=
|
|
926
|
+
`}get value(){let e=O(this.product),r=this.productPlans[e]||[],o=this.prepaidShipmentsSelected?this.prepaidShipmentsSelected:this.shipmentsOptedIn,s=r.find(h=>h.prepaidShipments>1&&h.prepaidShipments===o);if(!s&&(s=r.find(h=>h.prepaidShipments>1),!s))return"";let{discountRate:i,subscriptionPrice:a,prepaidShipments:c,regularPrepaidPrice:l,prepaidSavingsPerShipment:p,prepaidSavingsTotal:f,prepaidExtraSavingsPercentage:d}=s;return this.totalPrice?l:this.perDeliveryPrice?a:this.totalSavings?f:this.perDeliverySavings?p:this.percentageSavings?i:this.extraPercentageSavings?d:this.numberOfShipments?c:""}render(){let e=this.value;return e?u`
|
|
927
927
|
<slot name="prepend"></slot>
|
|
928
928
|
${e}
|
|
929
929
|
<slot name="append"></slot>
|
|
930
|
-
`:
|
|
930
|
+
`:u`
|
|
931
931
|
<slot name="fallback"></slot>
|
|
932
|
-
`}};n(
|
|
932
|
+
`}};n(on,"PrepaidData");var sp=n((t,e)=>({shipmentsOptedIn:H(e.product)(t),prepaidShipmentsSelected:ee(e.product)(t),productPlans:t.productPlans}),"mapStateToProps"),na=g(sp)(on);S();N();A();var nn=class extends pe{constructor(){super();this.addEventListener("click",this.handleClick.bind(this))}static get styles(){return b`
|
|
933
|
+
:host {
|
|
934
|
+
cursor: pointer;
|
|
935
|
+
display: inline-block;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
:host[hidden] {
|
|
939
|
+
display: none;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
.btn {
|
|
943
|
+
position: relative;
|
|
944
|
+
width: var(--og-radio-width, 1.4em);
|
|
945
|
+
height: var(--og-radio-height, 1.4em);
|
|
946
|
+
margin: var(--og-radio-margin, 0);
|
|
947
|
+
padding: 0;
|
|
948
|
+
border: 1px solid var(--og-primary-color, var(--og-border-color, black));
|
|
949
|
+
background: #fff;
|
|
950
|
+
border-radius: 100%;
|
|
951
|
+
vertical-align: middle;
|
|
952
|
+
color: var(--og-primary-color, var(--og-btn-color, black));
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
.radio {
|
|
956
|
+
text-indent: -9999px;
|
|
957
|
+
flex-shrink: 0;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
.radio {
|
|
961
|
+
border-color: var(--og-checkbox-border-color, black);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
.radio.active::after {
|
|
965
|
+
position: absolute;
|
|
966
|
+
left: 0;
|
|
967
|
+
top: 0;
|
|
968
|
+
width: 100%;
|
|
969
|
+
height: 100%;
|
|
970
|
+
box-sizing: border-box;
|
|
971
|
+
background: var(--og-checkbox-border-color, black);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
.radio.active::after {
|
|
975
|
+
content: ' ';
|
|
976
|
+
border-radius: 100%;
|
|
977
|
+
border: 2px solid #fff;
|
|
978
|
+
}
|
|
979
|
+
`}handleClick(e){this.checked?this.productChangePrepaidShipments(this.product,null,this.offer):this.productChangePrepaidShipments(this.product,this.selectedNumberOfShipments,this.offer),e.preventDefault()}render(){return u`
|
|
980
|
+
<slot name="default">
|
|
981
|
+
<button id="action-trigger" class="btn radio ${this.checked?"active":""}"></button>
|
|
982
|
+
<label for="action-trigger">
|
|
983
|
+
<slot name="label"><og-text key="prepaidOptInLabel"></og-text></slot>
|
|
984
|
+
</label>
|
|
985
|
+
</slot>
|
|
986
|
+
`}};n(nn,"PrepaidButton");var ip=n((t,e)=>({options:re(e.product.id)(t),shipmentsOptedIn:H(e.product)(t),prepaidShipmentsSelected:ee(e.product)(t)}),"mapStateToProps"),sa=g(ip,{productChangePrepaidShipments:ye})(nn);S();N();A();var sn=class extends pe{constructor(){super();this.options=[],this.text="shipments"}static get properties(){return{...super.properties,text:{type:String}}}static get styles(){return b`
|
|
987
|
+
og-select {
|
|
988
|
+
display: inline-block;
|
|
989
|
+
cursor: pointer;
|
|
990
|
+
background-color: var(--og-select-bg-color, #fff);
|
|
991
|
+
border: var(--og-select-border, 1px solid #aaa);
|
|
992
|
+
border-width: var(--og-select-border-width, 1px);
|
|
993
|
+
box-shadow: 0 1px 0 1px rgba(0, 0, 0, 0.04);
|
|
994
|
+
z-index: 1;
|
|
995
|
+
}
|
|
996
|
+
`}render(){if(this.options.length===0)return u``;let e=this.options.map(r=>({value:r,text:`${r} ${this.text}`}));return u`
|
|
997
|
+
${this.options.length>1?u`
|
|
998
|
+
<og-select
|
|
999
|
+
.options=${e}
|
|
1000
|
+
.selected=${this.selectedNumberOfShipments}
|
|
1001
|
+
.onChange="${r=>this.handleSelect(r)}"
|
|
1002
|
+
></og-select>
|
|
1003
|
+
`:u`
|
|
1004
|
+
<span>${e[0].text}</span>
|
|
1005
|
+
`}
|
|
1006
|
+
<slot name="append"></slot>
|
|
1007
|
+
`}};n(sn,"PrepaidSelect");var ap=n((t,e)=>({options:re(e.product.id)(t),shipmentsOptedIn:H(e.product)(t),prepaidShipmentsSelected:ee(e.product)(t)}),"mapStateToProps"),ia=g(ap,{productChangePrepaidShipments:ye})(sn);var{TestWizard:lp}=(ca(),aa);function an(){let t="og-test-wizard";customElements.get(t)||customElements.define(t,lp);let e=document.createElement(t);document.body.appendChild(e)}n(an,"default");var cn=[79,71,68,69,86],la=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===cn[t]){let o=cn[t];setTimeout(function(){t<=o&&(t=0)},5e3),t+=1,t>=cn.length&&an()}else t=0},!1)},"enable");ge();j();N();ge();q();var Dr=n((t=[],e)=>{switch(e.type){case fe:return[];case Te:return e.newValue?e.newValue.optedin:t;case I:case F:{let[{prepaidShipments:c,...l},p]=Xe(t,e.payload.product);return p.concat({...l,...e.payload.product,frequency:e.payload.frequency})}case se:let{payload:r}=e,[{prepaidShipments:o,...s},i]=Xe(t,r.product),a={...s,...r.product};return r.prepaidShipments&&(a.prepaidShipments=r.prepaidShipments),i.concat(a);case U:return t.filter(c=>!D(e.payload.product,c));case pt:return t.map(c=>D(e.payload.product,c)?{...c,...e.payload.newProduct}:c);case Wt:return t.filter(c=>!D(e.payload.product,c));case We:return[];default:return t}},"optedin"),ln=n((t=[],e)=>{switch(e.type){case fe:return[];case Te:return e.newValue?e.newValue.optedout:t;case I:case F:return t.filter(s=>!D(e.payload.product,s));case U:let[r,o]=Xe(t,e.payload.product);return o.concat({...r,...e.payload.product,frequency:e.payload.frequency});case pt:return t.map(s=>D(e.payload.product,s)?{...s,...e.payload.newProduct}:s);case We:return[];default:return t}},"optedout"),pn=n((t={},{type:e,payload:r})=>{switch(e){case Gt: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 Bt:return{...t,products:(r.results||[]).map(o=>o.product)};case zt:return{...t,...r,public_id:r.order,...r.product&&{products:(t.products||[]).concat(r.product)}};default:return t}},"nextUpcomingOrder"),pp=n((t={},e)=>{switch(e.type){case R:return{...t,...e.payload.autoship};default:return t}},"autoshipEligible"),up=n((t={},e)=>{switch(e.type){case K:return{...t};case R:return{...t,...e.payload.in_stock};default:return t}},"inStock"),un=n((t={},e)=>{switch(e.type){case R:return{...t,...e.payload.eligibility_groups};default:return t}},"eligibilityGroups"),pa=n((t,e)=>t.map(r=>({...e[r],id:[r][0]})),"mapIncentive"),dn=n((t={},e)=>{switch(e.type){case R: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||[],...pa(i,e.payload.incentives_display)],ongoing:[...s.ongoing||[],...pa(a,e.payload.incentives_display)]}),{})}),{})};default:return t}},"incentives"),dp=n((t={},e)=>{switch(e.type){case I:case F:return{...t,[O(e.payload.product)]:e.payload.frequency};case U:return{...t,[O(e.payload.product)]:void 0};default:return t}},"frequency"),fn=n((t=!1,e)=>{switch(e.type){case Ht:return{...e.payload};case Pe:return!1;default:return t}},"auth"),hn=n((t="",e)=>{switch(e.type){case Ve:return e.payload;default:return t}},"merchantId"),mn=n((t=null,e)=>{switch(e.type){case Vt:return e.payload;default:return t}},"authUrl"),fp=n((t={},e)=>{switch(e.type){case R:return{...t,offerId:(e.payload.module_view||{}).regular,...e.payload.modifiers};default:return t}},"offer"),gn=n((t="",e)=>{switch(e.type){case R:return(e.payload.module_view||{}).regular||"";default:return t}},"offerId"),yn=n((t=null,e)=>{switch(e.type){case fe:return null;case He:return e.payload;default:return t}},"sessionId"),hp=n((t={},e)=>{switch(e.type){case R:return{...t,...Object.entries(e.payload.autoship).map(([r])=>({[r]:Object.keys(e.payload.modifiers)})).reduce((r,o)=>({...r,...o}))};case We:return{};default:return t}},"productOffer"),bn=n((t={},e)=>{switch(e.type){case Qt:return{...t,[O(e.payload.product)]:e.payload.firstOrderPlaceDate};default:return t}},"firstOrderPlaceDate"),_n=n((t={},e)=>{switch(e.type){case Zt:return{...t,[O(e.payload.product)]:e.payload.productToSubscribe};default:return t}},"productToSubscribe"),Ut=n((t={},e)=>{switch(e.type){case Ge:return{...t,name:Ce,apiUrl:"https://staging.offers.ordergroove.com",legoUrl:"https://staging.restapi.ordergroove.com"};case Be:return{...t,name:Xt,apiUrl:"https://dev.offers.ordergroove.com",legoUrl:"https://dev.restapi.ordergroove.com"};case ze:return{...t,name:Re,apiUrl:"https://offers.ordergroove.com",legoUrl:"https://restapi.ordergroove.com"};default:return t}},"environment"),Sn=n((t={offerOptInLabel:"Subscribe to save",offerIncentiveText:"Save {{ogIncentive DiscountPercent}} when you subscribe",offerOptOutLabel:"Deliver one-time only",offerEveryLabel:"Delivery Every",offerTooltipTrigger:"[?]",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:"(Most Popular)",frequencyPeriods:{"1":"day","2":"week","3":"month"},prepaidOptInLabel:"Prepaid Subscription",prepaidShipmentsLabel:"Number of prepaid shipments"},e)=>{switch(e.type){case Yt:return{...t,...e.payload};default:return t}},"locale"),mp=n((t={offerType:"radio"},e)=>{switch(e.type){case Ye:return{...t,...e.payload,defaultFrequency:e.payload.defaultFrequency?_t(e.payload.defaultFrequency):t.defaultFrequency,frequenciesEveryPeriod:[],frequencies:e.payload.frequencies?e.payload.frequencies.map(_t):t.frequencies};default:return t}},"config"),En=n((t=!1,e)=>{switch(e.type){case dt:return e.payload;default:return t}},"previewStandardOffer"),xn=n((t=!1,e)=>{switch(e.type){case ft:return e.payload;default:return t}},"previewUpsellOffer");var vn=n((t=[],e)=>{switch(e.type){case R:return{...t,...e.payload.autoship_by_default};default:return t}},"autoshipByDefault"),On=n((t=[],e)=>{switch(e.type){case R:return{...t,...e.payload.default_frequencies};default:return t}},"defaultFrequencies"),Pn=n((t=[],e)=>{switch(e.type){case Kt:return[...e.payload||[]];case Jt:return[e.payload,...t];default:return t}},"templates"),gp=n((t={},e)=>{switch(e.type){case z:return tt(e.payload);default:return t}},"productPlans"),Tn=n((t={},e)=>{switch(e.type){case ut:let{[e.payload.oldCartProductKey]:r,...o}=t;return{...o,[e.payload.newCartProductKey]:r};case se:return e.payload.prepaidShipments?{...t,[e.payload.product.id]:e.payload.prepaidShipments}:t;default:return t}},"prepaidShipmentsSelected"),Ur=Lt({optedin:Dr,optedout:ln,nextUpcomingOrder:pn,autoshipEligible:pp,inStock:up,eligibilityGroups:un,incentives:dn,frequency:dp,auth:fn,merchantId:hn,authUrl:mn,offer:fp,offerId:gn,sessionId:yn,productOffer:hp,firstOrderPlaceDate:bn,productToSubscribe:_n,environment:Ut,locale:Sn,config:mp,previewStandardOffer:En,previewUpsellOffer:xn,autoshipByDefault:vn,defaultFrequencies:On,templates:Pn,productPlans:gp,prepaidShipmentsSelected:Tn});j();S();N();q();var wn=class extends k(M){static get properties(){return{...super.properties,regular:{type:Boolean,reflect:!0},subscription:{type:Boolean,reflect:!0},discount:{type:Boolean,reflect:!0},payAsYouGo:{type:Boolean,reflect:!0,attribute:"pay-as-you-go"},frequency:{type:Object},productPlans:{type:Object}}}get value(){var l;let e=O(this.product),r=this.frequency||this.configDefaultFrequency||((l=this.offer)==null?void 0:l.defaultFrequency),o=this.productPlans[e]||[];if(this.payAsYouGo){let p=o.find(f=>f.prepaidShipments===null||f.prepaidShipments===void 0);return p?p.subscriptionPrice:""}let s=o.find(p=>p.frequency===r);if(!s)return"";let{regularPrice:i,discountRate:a,subscriptionPrice:c}=s;return c===i?"":this.regular?i:this.discount?a:c}render(){let e=this.value;return e?u`
|
|
933
1008
|
<slot name="prepend"></slot>
|
|
934
1009
|
${e}
|
|
935
1010
|
<slot name="append"></slot>
|
|
936
|
-
`:
|
|
1011
|
+
`:u`
|
|
937
1012
|
<slot name="fallback"></slot>
|
|
938
|
-
`}};n(vn,"Price");var lp=n((t,e)=>{var r;return{productPlans:t.productPlans,configDefaultFrequency:(r=t.config)==null?void 0:r.defaultFrequency,frequency:X(e.product)(t)}},"mapStateToProps"),ia=g(lp)(vn);I();function Tn(t){na(),Ks(t);try{customElements.define("og-when",Ii),customElements.define("og-text",Vi),customElements.define("og-incentive-text",zi),customElements.define("og-offer",Xi),customElements.define("og-select-frequency",Yi),customElements.define("og-optout-button",Ui),customElements.define("og-optin-toggle",$i),customElements.define("og-optin-status",qi),customElements.define("og-optin-button",Di),customElements.define("og-optin-select",Li),customElements.define("og-upsell-button",Mi),customElements.define("og-frequency-status",Fi),customElements.define("og-modal",Rr),customElements.define("og-select",Ar),customElements.define("og-tooltip",Nr),customElements.define("og-upsell-modal",ji),customElements.define("og-next-upcoming-order",Ji),customElements.define("og-price",ia),customElements.define("og-prepaid-toggle",ea),customElements.define("og-prepaid-data",ta)}catch{console.info("OG WebComponents already registered, skipping.")}let e=!1,r={store:t,isReady:()=>e,setEnvironment(o){return t.dispatch(so(o)),this},setMerchantId(o){return t.dispatch(xs(o)),this},setAuthUrl(o){return t.dispatch(vs(o)),this},getProductsForPurchasePost(o=[]){return po(t.getState(),o)},getOptins(o=[]){return po(t.getState(),o)},clear(){t.dispatch(ws())},addOptinChangedCallback(o){typeof o=="function"&&document.addEventListener("optin-changed",s=>o(s.detail))},disableOptinChangedCallbacks(){document.addEventListener("optin-changed",o=>o.stopPropagation(),!0)},register(){},previewMode(o){return window.og=window.og||{},o===!1?delete window.og:window.og.previewMode=!0,this},config(o){return t.dispatch(As(o)),this},setLocale(o){return t.dispatch(Rs(o)),this},addTemplate(o,s,i){return t.dispatch(Ns(o,s,i)),this},setTemplates(o){return t.dispatch(Is(o)),this},setPublicPath(o){return this},resolveSettings(o,s,i,a=t){if(o&&s&&i){let c=[];i.product?c.push(i.product):i.cart&&Array.isArray(i.cart.products)&&(c=c.concat(i.cart.products));let{apiUrl:l}=Nt({},so(s)),{sessionId:p}=a.getState();p&&c.forEach(f=>{let u=x(f);ue.fetchOffer(l,o,p,`${u}`,xe)}),i.product_discounts&&typeof i.product_discounts=="object"&&a.dispatch({type:B,payload:i.product_discounts})}},initialize(o,s,i){var c;e?console.warn("og.offers has been initialized already. Skipping."):r.resolveSettings(o,s,window.og_settings,t);let a=t.getState();return o&&o!==a.merchantId&&r.setMerchantId(o),s&&s!==((c=a.environment)==null?void 0:c.name)&&r.setEnvironment(s),i&&r.setAuthUrl(i),e=!0,this}};return window.OG=window.OG||{},Object.assign(window.OG,r),Object.assign(r.initialize,r),lo(window.opener,r),r}n(Tn,"makeApi");j();I();var ae=n(t=>t===null?"":`$${t.toString().replace(/(\d\d)$/,".$1")}`,"money"),Dr=n(t=>`${t}%`,"percentage");var Ur=n(t=>{var e,r;return Array.isArray((e=t.selling_plan)==null?void 0:e.options)&&((r=t.selling_plan)==null?void 0:r.options.some(o=>(o==null?void 0:o.name)==="Shipment amount"))},"isPrepaidAllocation"),Fr=n(t=>{if(t&&t.length>1){let e=t.find(r=>(r==null?void 0:r.name)==="Shipment amount").value.split(" ");return e.length>0?+e[0]:null}return null},"getPrepaidShipmentsNumberFromOptions"),pp=n(t=>{var e;return(t.selling_plan_id||((e=t.selling_plan)==null?void 0:e.id)).toString()},"getAllocationFrequency"),up=n(t=>ae(t.compare_at_price),"getAllocationRegularPrice"),dp=n(t=>{var e;if(Ur(t)){let r=Fr((e=t.selling_plan)==null?void 0:e.options),o=Math.round(t.price/r);return ae(o)}return ae(t.price)},"getAllocationSubscriptionPrice"),aa=n((t,e)=>Math.round((t.compare_at_price-e)*100/t.compare_at_price),"getPrepaidPercentage"),fp=n(t=>{var r,o,s;if(Ur(t)){let i=Fr((r=t.selling_plan)==null?void 0:r.options),a=t.price/i,c=aa(t,a);return Dr(c)}let e="";return((o=t.price_adjustments[0])==null?void 0:o.value_type)==="percentage"?e=Dr(t.price_adjustments[0].value):((s=t.price_adjustments[0])==null?void 0:s.value)?e=ae(t.price_adjustments[0].value):t.compare_at_price&&(e=ae(t.compare_at_price-t.price)),e},"getAllocationDiscountRate"),hp=n(t=>{var e;return Ur(t)?Fr((e=t.selling_plan)==null?void 0:e.options):null},"getAllocationNumberOfShipments"),mp=n((t,e,r)=>{var p,f;let o=Fr((p=t.selling_plan)==null?void 0:p.options),s=t.price/o,i=t.compare_at_price-s,a=aa(t,s),c=(f=r==null?void 0:r.price_adjustments)==null?void 0:f[0],l=c&&c.value_type==="percentage"?c.value:null;return e.regularPrepaidPrice=ae(t.price),e.prepaidSavingsPerShipment=ae(Math.round(i)),e.prepaidSavingsTotal=ae(Math.round(i*o)),l&&a&&(e.prepaidExtraSavingsPercentage=Dr(a-l)),e},"addPrepaidPriceAndSavings"),On="Subscribe and Save",gp=n((t,e=[])=>{t.selling_plan||(t.selling_plan=e.find(o=>o.id===t.selling_plan_id));let r={frequency:pp(t),regularPrice:up(t),subscriptionPrice:dp(t),discountRate:fp(t),prepaidShipments:hp(t)};if(Ur(t)){let o=e.find(s=>s.group_name===On&&s.options.length===1);return mp(t,r,o)}return r},"mapSellingPlanToDiscount"),Pn=n((t,e,r=[])=>[...t,gp(e,r)],"sellingPlanAllocationsReducer"),ca=n(t=>t.selling_plan_groups.reduce((e,r)=>[...e,...r.selling_plans.map(o=>({...o,group_name:r.name}))],[]),"getSellingPlans");var la=n((t,e,r)=>{let o=Object.keys(t).filter(s=>s.startsWith(e.toString()));return o.length?{...t,...o.reduce((s,i)=>({...s,[i]:r}),{})}:t},"overrideLineKey"),pa=n((t,e,r)=>{if(!r)return null;if(!Ye(r))return r;if(ar(t,e)){let o=ee(t,e,r);return o||we(t)}return r},"getDefaultSellingPlan"),yp=n((t,e)=>t.map(r=>{var o,s,i,a,c,l,p;return Ye(r==null?void 0:r.frequency)?{...r,frequency:ar((o=e==null?void 0:e.config)==null?void 0:o.frequencies,(s=e==null?void 0:e.config)==null?void 0:s.frequenciesEveryPeriod)?ee((i=e==null?void 0:e.config)==null?void 0:i.frequencies,(a=e==null?void 0:e.config)==null?void 0:a.frequenciesEveryPeriod,r.frequency)||ee((c=e==null?void 0:e.config)==null?void 0:c.frequencies,(l=e==null?void 0:e.config)==null?void 0:l.frequenciesEveryPeriod,e.defaultFrequency)||we((p=e==null?void 0:e.config)==null?void 0:p.frequencies):r.frequency}:r}),"mapExistingOptinsFromOfferResponse"),bp=n(({autoship:t={},autoship_by_default:e={},default_frequencies:r={},in_stock:o={}},s,i)=>Object.keys(t).reduce((a,c)=>{if(!s.some(l=>l.id===c)){if(!(t[c]&&e[c]&&o[c]))return a;let{config:{frequencies:l,frequenciesEveryPeriod:p}={},defaultFrequency:f}=i,u=r[c],h;return r[c]&&ar(l,p)?h=ee(l,p,`${u.every}_${u.every_period}`)||pa(l,p,f)||we(l):r[c]?h=`${u.every}_${u.every_period}`:h=pa(l,p,f)||"_",a.concat({id:c,frequency:h})}return a},[]),"reduceNewOptinsFromOfferResponse"),ua=n(t=>t==null?void 0:t.selling_plan_groups.find(r=>r.name===On),"getOGSellingPlanGroup"),_p=n((t,e)=>({...la(t,e.id,e.available),[e.id]:e.available}),"productOrVariantInStockReducer"),da=n((t,[e])=>({...t,[e]:!0}),"productTrue"),fa=n((t,e)=>{let r=x(e.key);return{...t,[e.key]:t[r]||null}},"reduceProductCartLine"),Sp=n(t=>t.name.toUpperCase().includes("PREPAID"),"isPrepaidSellingPlanGroup"),Ep=n((t,e)=>{if(!t||t.length===0)return[];if(!e||e.length===0)return t;let r=e.reduce((o,s)=>(Sp(s)||o.push(...s.selling_plans.map(i=>i.id)),o),[]);return t.filter(o=>r.includes(o.selling_plan_id))},"filterNonPrepaidSellingPlans"),xp=n((t={},e)=>{if(B===e.type)return Object.entries(e.payload).reduce(da,t);if(pe===e.type){let{payload:r}=e;return r.items.reduce(fa,t)}if(K===e.type){let{payload:{product:r}}=e;return[r,...(r==null?void 0:r.variants)||[]].reduce((o,s)=>{let i=Ep(s==null?void 0:s.selling_plan_allocations,r==null?void 0:r.selling_plan_groups);return{...la(o,s.id,(i==null?void 0:i.length)>0),[s.id]:(i==null?void 0:i.length)>0}},t)}return t},"autoshipEligible");function vp(t){let e=["day","week","month"].findIndex(o=>t.toLowerCase().includes(o))+1,r=(t.match(/(\d+)/)||["",1])[1];return r&&e?`${r}_${e}`:null}n(vp,"textToFreq");function ha(t){var e;return(e=t==null?void 0:t.selling_plans)==null?void 0:e.map(({options:r})=>r||[]).flat().map(({value:r})=>vp(r))}n(ha,"sellingPlansToEveryPeriod");function ma(t){var e;return(e=t==null?void 0:t.selling_plans)==null?void 0:e.map(({id:r})=>`${r}`)}n(ma,"sellingPlansToFrequencies");function ga(t){var r;let e=(r=t==null?void 0:t.options.find(({name:o})=>o==="Shipment amount"))==null?void 0:r.value.split(" ")[0];return e?Number(e):void 0}n(ga,"getPrepaidShipments");function Tp(t){return t.reduce((e,r)=>{let o=r.name.split("-")[1],s=r.selling_plans.map(i=>({numberShipments:ga(i),sellingPlan:String(i.id)}));return{...e,[o]:s}},{})}n(Tp,"getPrepaidSellingPlans");var Op=n((t={frequencies:[],offerType:"radio",frequenciesEveryPeriod:[]},e)=>{var r,o;if(B===e.type){let s=[...new Set(Object.values(e.payload).map(Object.keys).flat())];return{...t,frequencies:s}}if(K===e.type){let{payload:{offer:s,product:i}}=e,a={},c=ua(i),l=ma(c);if(l==null?void 0:l.length){let f=ha(c),u=((o=(r=c.options)==null?void 0:r[0])==null?void 0:o.values)||l,h=t.defaultFrequency;h&&Ye(h)&&(h=ee(l,f,h)||we(l)||h),a={frequencies:l,frequenciesEveryPeriod:f,frequenciesText:u,...h?{defaultFrequency:h}:{}}}let p=i==null?void 0:i.selling_plan_groups.filter(f=>/^Prepaid-.*/.test(f.name));return p.length&&(a={...a,prepaidSellingPlans:{...t.prepaidSellingPlans,...Tp(p)}}),{...t,...a}}if(R===e.type){let{payload:{offer:s}}=e,{defaultFrequency:i,config:{frequencies:a,frequenciesEveryPeriod:c}={}}=s;return Ye(i)?{...t,defaultFrequency:ee(a,c,i)||we(a)||i}:{...t,defaultFrequency:i}}return t},"config"),Pp=n((t={},e)=>{if(B===e.type)return Object.entries(e.payload).reduce(da,t);if(pe===e.type)return e.payload.items.reduce(fa,t);if(K===e.type){let{payload:{product:r}}=e;return[r,...r==null?void 0:r.variants].reduce(_p,t)||t}return J===e.type&&e.payload.product===null?{...t}:t},"inStock"),wp=n((t={},e)=>t,"offer");function Cp({prepaidShipments:t,offer:e,product:r}){var o;if(t){let s=x(r.id),i=(o=e.config.prepaidSellingPlans[s])==null?void 0:o.find(a=>a.numberShipments===t);return i?i.sellingPlan:null}return e.config.frequencies[0]}n(Cp,"getFrequencyForPrepaidShipments");function Rp(t){let e=ga(t.selling_plan_allocation.selling_plan),r={id:t.key,frequency:`${t.selling_plan_allocation.selling_plan.id}`};return e&&(r.prepaidShipments=e),r}n(Rp,"getOptedInItem");var Ap=n((t=[],e)=>{if(pe===e.type){let r=e.payload;return t.filter(o=>!o.id.includes(":")).concat(r.items.reduce((o,s)=>s.selling_plan_allocation?[...o,Rp(s)]:o,[]))}if(R===e.type){let{offer:r={},...o}=e.payload,s=yp(t,r),i=bp(o,s,r);return[...s,...i]}if(K===e.type){let{product:r}=e.payload,o=ua(r);if(!o)return t;let s=ma(o),i=ha(o);return t.map(a=>Ye(a.frequency)?{...a,frequency:ee(s,i,a.frequency)||we(s)}:a)}if(re===e.type){let{payload:r}=e,o=kr(t,e),[s,i]=We(o,r.product);return i.concat({...s,...r.product,frequency:Cp(r)})}return kr(t,e)},"optedin"),Np=n((t={},e)=>t,"productOffer"),Ip=n((t={},e)=>{if(K===e.type){let{payload:{product:r}}=e,o=ca(r);return[r,...r==null?void 0:r.variants].reduce((s,i)=>{var a;return{...s,[i.id]:(a=i.selling_plan_allocations)==null?void 0:a.reduce((c,l)=>Pn(c,l,o),[])}},t)||t}return pe===e.type?e.payload.items.reduce((o,s)=>s.selling_plan_allocation?{...o,[s.key]:Pn([],s.selling_plan_allocation)}:o,t)||t:B===e.type?Ke(e.payload):t},"productPlans"),kp=kt({auth:ln,authUrl:un,autoshipByDefault:_n,autoshipEligible:xp,config:Op,defaultFrequencies:Sn,eligibilityGroups:an,environment:Nt,firstOrderPlaceDate:hn,incentives:cn,inStock:Pp,locale:gn,merchantId:pn,nextUpcomingOrder:sn,offer:wp,offerId:dn,optedin:Ap,optedout:nn,previewStandardOffer:yn,previewUpsellOffer:bn,productOffer:Np,productPlans:Ip,productToSubscribe:mn,sessionId:fn,templates:En,prepaidShipmentsSelected:xn});function wn(t,e){return window.og&&window.og.previewMode?qr(t,e):kp(t,e)}n(wn,"shopifyReducer");var ba=ce(pt()),_a=ce(Dt());j();F();I();j();function ya(t,e,r){let o=`[name="id"][value="${t}"]`,s=`form[action="/cart/add"] option[value="${t}"]`;if(!e)return;let i=document.querySelectorAll(o);i.length||(i=document.querySelectorAll(s)),[...i].forEach(a=>{let c=a.form,l=c==null?void 0:c.querySelector(`[name="${e}"]`);l||(l=document.createElement("input"),l.type="hidden",l.name=`attributes[${e}]`,c==null||c.appendChild(l)),l.value=r})}n(ya,"updateTrackingInputs");function Cn(){return`og__${Math.ceil(new Date().getTime()/1e3)}`}n(Cn,"getTrackingKey");function qp(t,e){var f,u,h,w;if(!((f=t.payload.offer)==null?void 0:f.autoshipByDefault))return;let o=(u=t.payload.offer)==null?void 0:u.product.id,s=Cn(),i=((h=t.payload.offer)==null?void 0:h.location)||"",a=((w=t.payload.offer)==null?void 0:w.variationId)||"",c=Lr(o,e),p=[o,N.toLowerCase(),i,c,a].join(",");ya(o,s,p)}n(qp,"addDefaultToSubTracking");function Rn(t){return e=>r=>{switch(e(r),r.type){case N:case D:case U:let o=r.payload.offer,s=An(r);o&&!o.isCart&&ya(o.product.id,s[0],s[1]);break;case R:qp(r,t);break;default:}}}n(Rn,"shopifyTrackingMiddleware");var va,Ta,Sa=((Ta=(va=window.Shopify)==null?void 0:va.routes)==null?void 0:Ta.root)||"/",Dp="/cart",Up=`${Sa}cart.js`,Fp=`${Sa}products/`,Lp='[id^="shopify-section-"][id$=__cart-items], [id^="shopify-section-"][id$="__cart-footer"],#cart-live-region-text,#cart-icon-bubble',Mp=n(t=>(0,_a.debounce)(100,!1,function(e){let{id:r}=Object.fromEntries([...new FormData(e).entries()]);r?t.setAttribute("product",r):t.removeAttribute("product")}),"makeSyncProductId");async function jp(t,e){let r=$p(e);if(r)try{let s=await xa(r);t.dispatch({type:K,payload:{product:s,offer:e}})}catch(s){console.warn("OG: Unable to fetch product details for PDP",s)}let o=e.closest("form");if(!o){let s=e.parentElement;for(;s&&(o=s.querySelector('form[action$="/cart/add"]'),!(o||s.tagName.toLowerCase()==="body"));)s=s.parentElement}if(o){let s=Mp(e);o.addEventListener("change",a=>s(o)),new MutationObserver(()=>s(o)).observe(o,{subtree:!0,childList:!0})}else console.info("no /cart/add form found for og-offer",e)}n(jp,"setupPdp");var Ea=n(async()=>await(await fetch(Up)).json(),"getCart");function $p(t){return[()=>t==null?void 0:t.dataset.shopifyProductHandle,()=>{var e,r;return(((r=(e=document.querySelector('[href$=".oembed"]'))==null?void 0:e.getAttribute("href"))==null?void 0:r.match(/\/([^\/]+)\.oembed$/))||[])[1]},()=>{var e,r;return(document.querySelector('meta[property="og:type"][content="product"]')&&((r=(e=document.querySelector('meta[property="og:url"][content]'))==null?void 0:e.getAttribute("content"))==null?void 0:r.match(/\/([^\/]+)$/))||[])[1]},()=>{var e;return(e=[...document.querySelectorAll("[type$=json]")].map(r=>JSON.parse(r.textContent||"{}")).find(r=>r.handle&&r.price))==null?void 0:e.handle}].reduce((e,r)=>e||r(),"")}n($p,"guessProductHandle");var xa=(0,ba.default)(async t=>(await fetch(`${Fp}${t}.js`)).json());async function Vp(t,e){let r=await Ea(),{items:o}=r;t.dispatch({type:pe,payload:r});let s=Number(e.product.id);s<=o.length&&e.setAttribute("product",o[s-1].key),(await Promise.all(Array.from(new Set(o.map(({handle:a})=>a))).map(xa))).forEach(a=>t.dispatch({type:K,payload:{product:a,offer:e}}))}n(Vp,"setupCart");async function Hp(t,e){var i,a;let r=t.payload.offer,o=t.payload.frequency||Lr(t.payload.product.id,e),s=An(t);if(!!(r==null?void 0:r.isCart))try{r.style.pointerEvents="none",r.style.opacity=".7";let c=Array.from(document.querySelectorAll(Lp)),l=t.payload.product.id,p=await Ea(),f=(i=p==null?void 0:p.items)==null?void 0:i.findIndex(y=>y.key===l),u=p.items[f],h=u.quantity,w=x(l),_=await fetch("/cart/change.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:l,quantity:h,attributes:Object.fromEntries([s]),properties:u.properties,selling_plan:o||null,sections:c.map(y=>y.id.replace(/^shopify-section-/,""))})});if(_.status!==200)throw new Error("Cart not updated");let m=await _.json(),S=p.items.length===m.items.length?m.items[f].key:(a=m.items.find(y=>y.quantity===h&&y.product_id===w&&(!o&&!y.selling_plan_allocation||(y==null?void 0:y.selling_plan_allocation.selling_plan.id)===o)))==null?void 0:a.key;S&&(e.dispatch({type:it,payload:{oldCartProductKey:l,newCartProductKey:S}}),r.setAttribute("product",S)),e.dispatch({type:pe,payload:m});let C=new CustomEvent(Xn,{bubbles:!0,cancelable:!0});if(r.dispatchEvent(C),C.defaultPrevented)return;let b=m.sections;Object.values(b).length?c.forEach(y=>{let It=y.id.replace(/^shopify-section-/,"");if(!(It in b))return;let Aa=b[It],In=new DOMParser().parseFromString(Aa.toString()||"","text/html").getElementById(y.id);In&&(y.innerHTML=In.innerHTML)}):window.location.pathname.startsWith(Dp)&&window.location.reload()}catch(c){console.log("OG Error updating cart",c)}finally{r.style.pointerEvents="auto",r.style.opacity="1"}}n(Hp,"synchronizeCartOptin");function An(t){var a,c;let e=t.payload.product.id;if(!e)return[];let r=Cn(),o=((a=t.payload.offer)==null?void 0:a.location)||"",s=((c=t.payload.offer)==null?void 0:c.variationId)||"",i=[e,t.type.toLowerCase(),o];switch(t.type){case J:case D:i.push(""),i.push(s);break;case N:case U:i.push(t.payload.frequency),i.push(s);break;default:return[]}return[r,i.join(",")]}n(An,"getTrackingEvent");function Lr(t,e){var s;return(s=tr({id:t})(e.getState()))==null?void 0:s.frequency}n(Lr,"getSubscribedFrequency");function Gp(t,e){e.isCart||[...document.querySelectorAll('form[action$="/cart/add"] [name=id]')].forEach(r=>{let o=r.value,s=Lr(o,t);bs(r.form,"selling_plan",s)})}n(Gp,"synchronizeSellingPlan");function Nn(t){return e=>r=>{var o;switch(r.type){case N:case D:case U:break;case J:((o=r.payload.offer)==null?void 0:o.isCart)?Vp(t,r.payload.offer):jp(t,r.payload.offer);break;default:}switch(e(r),r.type){case N:case D:case U:case re:Hp(r,t);case J:case R:case K:Gp(t,r.payload.offer);break;default:}}}n(Nn,"shopifyMiddleware");mt();I();q();I();var Bp="/apps/subscriptions/auth/",Oa="og_auth_begin",zp="og_auth_end",Yp=n(t=>{let[e,r,o,s]=atob(t).split("|");return{id:e,signature:o,timestamp:r,email:s}},"parseIntegrationTempAuth");async function Pa({store:t}){var s;let[e]=eo(),r=gt(),o=(r==null?void 0:r.dataset.customer)?Yp(r.dataset.customer):(s=window.ogShopifyConfig)==null?void 0:s.customer;if(o){let i=await Jp(o);if(i){let[a,c,l]=i.split("|");t.dispatch(bt(e,a,Number(c),l))}}else gs("og_auth")}n(Pa,"authorizeShopifyCustomer");async function Wp(t){try{let r=await(await fetch(`${Bp}?customer=${t.id}&customer_signature=${t.signature}&customer_timestamp=${t.timestamp}`)).text(),o=r.lastIndexOf(Oa);if(o<0)throw"Invalid response from OG auth endpoint";return JSON.parse(r.substring(o+Oa.length,r.lastIndexOf(zp)))}catch(e){console.error(e)}}n(Wp,"fetchOGSignature");async function Jp(t){let e=ys("og_auth");if(e)return e;let{customerId:r,timestamp:o,signature:s}=await Wp(t);if(!r)return"";let i=new Date,a=btoa(s);i.setTime(i.getTime()+2*60*60*1e3);let c=`${r}|${o}|${a};expires=${i.toUTCString()}`;return document.cookie=`og_auth=${c};secure;path=/`,c}n(Jp,"getOrCreateAuthCookie");var Ca,wa=zs(...((Ca=L)==null?void 0:Ca.shopify_selling_plans)?[wn,Nn]:[qr],L.shopify&&Rn),O=Tn(wa),Kp=O.isReady,Qp=O.addOptinChangedCallback,Zp=O.addTemplate,Xp=O.clear,eu=O.config,tu=O.disableOptinChangedCallbacks,ru=O.getOptins,ou=O.getProductsForPurchasePost,nu=O.initialize,su=O.previewMode,iu=O.register,au=O.resolveSettings,cu=O.setAuthUrl,lu=O.setEnvironment,pu=O.setLocale,uu=O.setMerchantId,du=O.setPublicPath,fu=O.setTemplates,hu=O.setupCart,mu=O.setupProduct,gu=O.setupProducts,yu=n(()=>ms(O),"autoInit");var bu=O.initialize,Ra;((Ra=L)==null?void 0:Ra.shopify_selling_plans)&&ir(()=>Pa(O));return _u;})();
|
|
1013
|
+
`}};n(wn,"Price");var yp=n((t,e)=>{var r;return{productPlans:t.productPlans,configDefaultFrequency:(r=t.config)==null?void 0:r.defaultFrequency,frequency:te(e.product)(t)}},"mapStateToProps"),ua=g(yp)(wn);q();function Cn(t){la(),Xs(t);try{customElements.define("og-when",Di),customElements.define("og-text",Bi),customElements.define("og-incentive-text",Ji),customElements.define("og-offer",ra),customElements.define("og-select-frequency",Ki),customElements.define("og-optout-button",Mi),customElements.define("og-optin-toggle",Gi),customElements.define("og-optin-status",Fi),customElements.define("og-optin-button",Li),customElements.define("og-optin-select",$i),customElements.define("og-upsell-button",Vi),customElements.define("og-frequency-status",ji),customElements.define("og-modal",Nr),customElements.define("og-select",kr),customElements.define("og-tooltip",Ir),customElements.define("og-upsell-modal",Hi),customElements.define("og-next-upcoming-order",Zi),customElements.define("og-price",ua),customElements.define("og-prepaid-toggle",oa),customElements.define("og-prepaid-data",na),customElements.define("og-prepaid-button",sa),customElements.define("og-prepaid-select",ia)}catch{console.info("OG WebComponents already registered, skipping.")}let e=!1,r={store:t,isReady:()=>e,setEnvironment(o){return t.dispatch(ao(o)),this},setMerchantId(o){return t.dispatch(Ps(o)),this},setAuthUrl(o){return t.dispatch(Ts(o)),this},getProductsForPurchasePost(o=[]){return fo(t.getState(),o)},getOptins(o=[]){return fo(t.getState(),o)},clear(){t.dispatch(As())},addOptinChangedCallback(o){typeof o=="function"&&document.addEventListener("optin-changed",s=>o(s.detail))},disableOptinChangedCallbacks(){document.addEventListener("optin-changed",o=>o.stopPropagation(),!0)},register(){},previewMode(o){return window.og=window.og||{},o===!1?delete window.og:window.og.previewMode=!0,this},config(o){return t.dispatch(Is(o)),this},setLocale(o){return t.dispatch(ks(o)),this},addTemplate(o,s,i){return t.dispatch(qs(o,s,i)),this},setTemplates(o){return t.dispatch(Ds(o)),this},setPublicPath(o){return this},resolveSettings(o,s,i,a=t){if(o&&s&&i){let c=[];i.product?c.push(i.product):i.cart&&Array.isArray(i.cart.products)&&(c=c.concat(i.cart.products));let{apiUrl:l}=Ut({},ao(s)),{sessionId:p}=a.getState();p&&c.forEach(f=>{let d=O(f);me.fetchOffer(l,o,p,`${d}`,we)}),i.product_discounts&&typeof i.product_discounts=="object"&&a.dispatch({type:z,payload:i.product_discounts})}},initialize(o,s,i){var c;e?console.warn("og.offers has been initialized already. Skipping."):r.resolveSettings(o,s,window.og_settings,t);let a=t.getState();return o&&o!==a.merchantId&&r.setMerchantId(o),s&&s!==((c=a.environment)==null?void 0:c.name)&&r.setEnvironment(s),i&&r.setAuthUrl(i),e=!0,this}};return window.OG=window.OG||{},Object.assign(window.OG,r),Object.assign(r.initialize,r),uo(window.opener,r),r}n(Cn,"makeApi");j();q();var ue=n(t=>t===null?"":`$${t.toString().replace(/(\d\d)$/,".$1")}`,"money"),Fr=n(t=>`${t}%`,"percentage");var Lr=n(t=>{var e,r;return Array.isArray((e=t.selling_plan)==null?void 0:e.options)&&((r=t.selling_plan)==null?void 0:r.options.some(o=>(o==null?void 0:o.name)==="Shipment amount"))},"isPrepaidAllocation"),Mr=n(t=>{if(t&&t.length>1){let e=t.find(r=>(r==null?void 0:r.name)==="Shipment amount").value.split(" ");return e.length>0?+e[0]:null}return null},"getPrepaidShipmentsNumberFromOptions"),bp=n(t=>{var e;return(t.selling_plan_id||((e=t.selling_plan)==null?void 0:e.id)).toString()},"getAllocationFrequency"),_p=n(t=>ue(t.compare_at_price),"getAllocationRegularPrice"),Sp=n(t=>{var e;if(Lr(t)){let r=Mr((e=t.selling_plan)==null?void 0:e.options),o=Math.round(t.price/r);return ue(o)}return ue(t.price)},"getAllocationSubscriptionPrice"),da=n((t,e)=>Math.round((t.compare_at_price-e)*100/t.compare_at_price),"getPrepaidPercentage"),Ep=n(t=>{var r,o,s;if(Lr(t)){let i=Mr((r=t.selling_plan)==null?void 0:r.options),a=t.price/i,c=da(t,a);return Fr(c)}let e="";return((o=t.price_adjustments[0])==null?void 0:o.value_type)==="percentage"?e=Fr(t.price_adjustments[0].value):((s=t.price_adjustments[0])==null?void 0:s.value)?e=ue(t.price_adjustments[0].value):t.compare_at_price&&(e=ue(t.compare_at_price-t.price)),e},"getAllocationDiscountRate"),xp=n(t=>{var e;return Lr(t)?Mr((e=t.selling_plan)==null?void 0:e.options):null},"getAllocationNumberOfShipments"),vp=n((t,e,r)=>{var p,f;let o=Mr((p=t.selling_plan)==null?void 0:p.options),s=t.price/o,i=t.compare_at_price-s,a=da(t,s),c=(f=r==null?void 0:r.price_adjustments)==null?void 0:f[0],l=c&&c.value_type==="percentage"?c.value:null;return e.regularPrepaidPrice=ue(t.price),e.prepaidSavingsPerShipment=ue(Math.round(i)),e.prepaidSavingsTotal=ue(Math.round(i*o)),l&&a&&(e.prepaidExtraSavingsPercentage=Fr(a-l)),e},"addPrepaidPriceAndSavings"),Rn="Subscribe and Save",Op=n((t,e=[])=>{t.selling_plan||(t.selling_plan=e.find(o=>o.id===t.selling_plan_id));let r={frequency:bp(t),regularPrice:_p(t),subscriptionPrice:Sp(t),discountRate:Ep(t),prepaidShipments:xp(t)};if(Lr(t)){let o=e.find(s=>s.group_name===Rn&&s.options.length===1);return vp(t,r,o)}return r},"mapSellingPlanToDiscount"),An=n((t,e,r=[])=>[...t,Op(e,r)],"sellingPlanAllocationsReducer"),fa=n(t=>t.selling_plan_groups.reduce((e,r)=>[...e,...r.selling_plans.map(o=>({...o,group_name:r.name}))],[]),"getSellingPlans");var ha=n((t,e,r)=>{let o=Object.keys(t).filter(s=>s.startsWith(e.toString()));return o.length?{...t,...o.reduce((s,i)=>({...s,[i]:r}),{})}:t},"overrideLineKey"),ma=n((t,e,r)=>{if(!r)return null;if(!Ze(r))return r;if(lr(t,e)){let o=oe(t,e,r);return o||ke(t)}return r},"getDefaultSellingPlan"),Pp=n((t,e)=>t.map(r=>{var o,s,i,a,c,l,p;return Ze(r==null?void 0:r.frequency)?{...r,frequency:lr((o=e==null?void 0:e.config)==null?void 0:o.frequencies,(s=e==null?void 0:e.config)==null?void 0:s.frequenciesEveryPeriod)?oe((i=e==null?void 0:e.config)==null?void 0:i.frequencies,(a=e==null?void 0:e.config)==null?void 0:a.frequenciesEveryPeriod,r.frequency)||oe((c=e==null?void 0:e.config)==null?void 0:c.frequencies,(l=e==null?void 0:e.config)==null?void 0:l.frequenciesEveryPeriod,e.defaultFrequency)||ke((p=e==null?void 0:e.config)==null?void 0:p.frequencies):r.frequency}:r}),"mapExistingOptinsFromOfferResponse"),Tp=n(({autoship:t={},autoship_by_default:e={},default_frequencies:r={},in_stock:o={}},s,i)=>Object.keys(t).reduce((a,c)=>{if(!s.some(l=>l.id===c)){if(!(t[c]&&e[c]&&o[c]))return a;let{config:{frequencies:l,frequenciesEveryPeriod:p}={},defaultFrequency:f}=i,d=r[c],h;return r[c]&&lr(l,p)?h=oe(l,p,`${d.every}_${d.every_period}`)||ma(l,p,f)||ke(l):r[c]?h=`${d.every}_${d.every_period}`:h=ma(l,p,f)||"_",a.concat({id:c,frequency:h})}return a},[]),"reduceNewOptinsFromOfferResponse"),ga=n(t=>t==null?void 0:t.selling_plan_groups.find(r=>r.name===Rn),"getOGSellingPlanGroup"),wp=n((t,e)=>({...ha(t,e.id,e.available),[e.id]:e.available}),"productOrVariantInStockReducer"),ya=n((t,[e])=>({...t,[e]:!0}),"productTrue"),ba=n((t,e)=>{let r=O(e.key);return{...t,[e.key]:t[r]||null}},"reduceProductCartLine"),Cp=n(t=>t.name.toUpperCase().includes("PREPAID"),"isPrepaidSellingPlanGroup"),Rp=n((t,e)=>{if(!t||t.length===0)return[];if(!e||e.length===0)return t;let r=e.reduce((o,s)=>(Cp(s)||o.push(...s.selling_plans.map(i=>i.id)),o),[]);return t.filter(o=>r.includes(o.selling_plan_id))},"filterNonPrepaidSellingPlans"),Ap=n((t={},e)=>{if(z===e.type)return Object.entries(e.payload).reduce(ya,t);if(he===e.type){let{payload:r}=e;return r.items.reduce(ba,t)}if(Q===e.type){let{payload:{product:r}}=e;return[r,...(r==null?void 0:r.variants)||[]].reduce((o,s)=>{let i=Rp(s==null?void 0:s.selling_plan_allocations,r==null?void 0:r.selling_plan_groups);return{...ha(o,s.id,(i==null?void 0:i.length)>0),[s.id]:(i==null?void 0:i.length)>0}},t)}return t},"autoshipEligible");function Np(t){let e=["day","week","month"].findIndex(o=>t.toLowerCase().includes(o))+1,r=(t.match(/(\d+)/)||["",1])[1];return r&&e?`${r}_${e}`:null}n(Np,"textToFreq");function _a(t){var e;return(e=t==null?void 0:t.selling_plans)==null?void 0:e.map(({options:r})=>r||[]).flat().map(({value:r})=>Np(r))}n(_a,"sellingPlansToEveryPeriod");function Sa(t){var e;return(e=t==null?void 0:t.selling_plans)==null?void 0:e.map(({id:r})=>`${r}`)}n(Sa,"sellingPlansToFrequencies");function Ea(t){var r;let e=(r=t==null?void 0:t.options.find(({name:o})=>o==="Shipment amount"))==null?void 0:r.value.split(" ")[0];return e?Number(e):void 0}n(Ea,"getPrepaidShipments");function kp(t){return t.reduce((e,r)=>{let o=r.name.split("-")[1],s=r.selling_plans.map(i=>({numberShipments:Ea(i),sellingPlan:String(i.id)}));return{...e,[o]:s}},{})}n(kp,"getPrepaidSellingPlans");var Ip=n((t={frequencies:[],offerType:"radio",frequenciesEveryPeriod:[]},e)=>{var r,o;if(z===e.type){let s=[...new Set(Object.values(e.payload).map(Object.keys).flat())];return{...t,frequencies:s}}if(Q===e.type){let{payload:{offer:s,product:i}}=e,a={},c=ga(i),l=Sa(c);if(l==null?void 0:l.length){let f=_a(c),d=((o=(r=c.options)==null?void 0:r[0])==null?void 0:o.values)||l,h=t.defaultFrequency;h&&Ze(h)&&(h=oe(l,f,h)||ke(l)||h),a={frequencies:l,frequenciesEveryPeriod:f,frequenciesText:d,...h?{defaultFrequency:h}:{}}}let p=i==null?void 0:i.selling_plan_groups.filter(f=>/^Prepaid-.*/.test(f.name));return p.length&&(a={...a,prepaidSellingPlans:{...t.prepaidSellingPlans,...kp(p)}}),{...t,...a}}if(R===e.type){let{payload:{offer:s}}=e,{defaultFrequency:i,config:{frequencies:a,frequenciesEveryPeriod:c}={}}=s;return Ze(i)?{...t,defaultFrequency:oe(a,c,i)||ke(a)||i}:{...t,defaultFrequency:i}}return t},"config"),qp=n((t={},e)=>{if(z===e.type)return Object.entries(e.payload).reduce(ya,t);if(he===e.type)return e.payload.items.reduce(ba,t);if(Q===e.type){let{payload:{product:r}}=e;return[r,...r==null?void 0:r.variants].reduce(wp,t)||t}return K===e.type&&e.payload.product===null?{...t}:t},"inStock"),Dp=n((t={},e)=>t,"offer");function Up({prepaidShipments:t,offer:e,product:r}){var o;if(t){let s=O(r.id),i=(o=e.config.prepaidSellingPlans[s])==null?void 0:o.find(a=>a.numberShipments===t);return i?i.sellingPlan:null}return e.config.frequencies[0]}n(Up,"getFrequencyForPrepaidShipments");function Fp(t){let e=Ea(t.selling_plan_allocation.selling_plan),r={id:t.key,frequency:`${t.selling_plan_allocation.selling_plan.id}`};return e&&(r.prepaidShipments=e),r}n(Fp,"getOptedInItem");var Lp=n((t=[],e)=>{if(he===e.type){let r=e.payload;return t.filter(o=>!o.id.includes(":")).concat(r.items.reduce((o,s)=>s.selling_plan_allocation?[...o,Fp(s)]:o,[]))}if(R===e.type){let{offer:r={},...o}=e.payload,s=Pp(t,r),i=Tp(o,s,r);return[...s,...i]}if(Q===e.type){let{product:r}=e.payload,o=ga(r);if(!o)return t;let s=Sa(o),i=_a(o);return t.map(a=>Ze(a.frequency)?{...a,frequency:oe(s,i,a.frequency)||ke(s)}:a)}if(se===e.type){let{payload:r}=e,o=Dr(t,e),[s,i]=Xe(o,r.product);return i.concat({...s,...r.product,frequency:Up(r)})}return Dr(t,e)},"optedin"),Mp=n((t={},e)=>t,"productOffer"),jp=n((t={},e)=>{if(Q===e.type){let{payload:{product:r}}=e,o=fa(r);return[r,...r==null?void 0:r.variants].reduce((s,i)=>{var a;return{...s,[i.id]:(a=i.selling_plan_allocations)==null?void 0:a.reduce((c,l)=>An(c,l,o),[])}},t)||t}return he===e.type?e.payload.items.reduce((o,s)=>s.selling_plan_allocation?{...o,[s.key]:An([],s.selling_plan_allocation)}:o,t)||t:z===e.type?tt(e.payload):t},"productPlans"),$p=Lt({auth:fn,authUrl:mn,autoshipByDefault:vn,autoshipEligible:Ap,config:Ip,defaultFrequencies:On,eligibilityGroups:un,environment:Ut,firstOrderPlaceDate:bn,incentives:dn,inStock:qp,locale:Sn,merchantId:hn,nextUpcomingOrder:pn,offer:Dp,offerId:gn,optedin:Lp,optedout:ln,previewStandardOffer:En,previewUpsellOffer:xn,productOffer:Mp,productPlans:jp,productToSubscribe:_n,sessionId:yn,templates:Pn,prepaidShipmentsSelected:Tn});function Nn(t,e){return window.og&&window.og.previewMode?Ur(t,e):$p(t,e)}n(Nn,"shopifyReducer");var va=de(mt()),Oa=de(jt());j();N();q();j();function xa(t,e,r){let o=`[name="id"][value="${t}"]`,s=`form[action="/cart/add"] option[value="${t}"]`;if(!e)return;let i=document.querySelectorAll(o);i.length||(i=document.querySelectorAll(s)),[...i].forEach(a=>{let c=a.form,l=c==null?void 0:c.querySelector(`[name="${e}"]`);l||(l=document.createElement("input"),l.type="hidden",l.name=`attributes[${e}]`,c==null||c.appendChild(l)),l.value=r})}n(xa,"updateTrackingInputs");function kn(){return`og__${Math.ceil(new Date().getTime()/1e3)}`}n(kn,"getTrackingKey");function Vp(t,e){var f,d,h,w;if(!((f=t.payload.offer)==null?void 0:f.autoshipByDefault))return;let o=(d=t.payload.offer)==null?void 0:d.product.id,s=kn(),i=((h=t.payload.offer)==null?void 0:h.location)||"",a=((w=t.payload.offer)==null?void 0:w.variationId)||"",c=jr(o,e),p=[o,I.toLowerCase(),i,c,a].join(",");xa(o,s,p)}n(Vp,"addDefaultToSubTracking");function In(t){return e=>r=>{switch(e(r),r.type){case I:case U:case F:let o=r.payload.offer,s=qn(r);o&&!o.isCart&&xa(o.product.id,s[0],s[1]);break;case R:Vp(r,t);break;default:}}}n(In,"shopifyTrackingMiddleware");var Ca,Ra,Pa=((Ra=(Ca=window.Shopify)==null?void 0:Ca.routes)==null?void 0:Ra.root)||"/",Hp="/cart",Gp=`${Pa}cart.js`,Bp=`${Pa}products/`,zp='[id^="shopify-section-"][id$=__cart-items], [id^="shopify-section-"][id$="__cart-footer"],#cart-live-region-text,#cart-icon-bubble',Wp=n(t=>(0,Oa.debounce)(100,!1,function(e){let{id:r}=Object.fromEntries([...new FormData(e).entries()]);r?t.setAttribute("product",r):t.removeAttribute("product")}),"makeSyncProductId");async function Yp(t,e){let r=Jp(e);if(r)try{let s=await wa(r);t.dispatch({type:Q,payload:{product:s,offer:e}})}catch(s){console.warn("OG: Unable to fetch product details for PDP",s)}let o=e.closest("form");if(!o){let s=e.parentElement;for(;s&&(o=s.querySelector('form[action$="/cart/add"]'),!(o||s.tagName.toLowerCase()==="body"));)s=s.parentElement}if(o){let s=Wp(e);o.addEventListener("change",a=>s(o)),new MutationObserver(()=>s(o)).observe(o,{subtree:!0,childList:!0})}else console.info("no /cart/add form found for og-offer",e)}n(Yp,"setupPdp");var Ta=n(async()=>await(await fetch(Gp)).json(),"getCart");function Jp(t){return[()=>t==null?void 0:t.dataset.shopifyProductHandle,()=>{var e,r;return(((r=(e=document.querySelector('[href$=".oembed"]'))==null?void 0:e.getAttribute("href"))==null?void 0:r.match(/\/([^\/]+)\.oembed$/))||[])[1]},()=>{var e,r;return(document.querySelector('meta[property="og:type"][content="product"]')&&((r=(e=document.querySelector('meta[property="og:url"][content]'))==null?void 0:e.getAttribute("content"))==null?void 0:r.match(/\/([^\/]+)$/))||[])[1]},()=>{var e;return(e=[...document.querySelectorAll("[type$=json]")].map(r=>JSON.parse(r.textContent||"{}")).find(r=>r.handle&&r.price))==null?void 0:e.handle}].reduce((e,r)=>e||r(),"")}n(Jp,"guessProductHandle");var wa=(0,va.default)(async t=>(await fetch(`${Bp}${t}.js`)).json());async function Kp(t,e){let r=await Ta(),{items:o}=r;t.dispatch({type:he,payload:r});let s=Number(e.product.id);s<=o.length&&e.setAttribute("product",o[s-1].key),(await Promise.all(Array.from(new Set(o.map(({handle:a})=>a))).map(wa))).forEach(a=>t.dispatch({type:Q,payload:{product:a,offer:e}}))}n(Kp,"setupCart");async function Qp(t,e){var i,a;let r=t.payload.offer,o=t.payload.frequency||jr(t.payload.product.id,e),s=qn(t);if(!!(r==null?void 0:r.isCart))try{r.style.pointerEvents="none",r.style.opacity=".7";let c=Array.from(document.querySelectorAll(zp)),l=t.payload.product.id,p=await Ta(),f=(i=p==null?void 0:p.items)==null?void 0:i.findIndex(y=>y.key===l),d=p.items[f],h=d.quantity,w=O(l),E=await fetch("/cart/change.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:l,quantity:h,attributes:Object.fromEntries([s]),properties:d.properties,selling_plan:o||null,sections:c.map(y=>y.id.replace(/^shopify-section-/,""))})});if(E.status!==200)throw new Error("Cart not updated");let m=await E.json(),x=p.items.length===m.items.length?m.items[f].key:(a=m.items.find(y=>y.quantity===h&&y.product_id===w&&(!o&&!y.selling_plan_allocation||(y==null?void 0:y.selling_plan_allocation.selling_plan.id)===o)))==null?void 0:a.key;x&&(e.dispatch({type:ut,payload:{oldCartProductKey:l,newCartProductKey:x}}),r.setAttribute("product",x)),e.dispatch({type:he,payload:m});let C=new CustomEvent(os,{bubbles:!0,cancelable:!0});if(r.dispatchEvent(C),C.defaultPrevented)return;let _=m.sections;Object.values(_).length?c.forEach(y=>{let Ft=y.id.replace(/^shopify-section-/,"");if(!(Ft in _))return;let Da=_[Ft],Un=new DOMParser().parseFromString(Da.toString()||"","text/html").getElementById(y.id);Un&&(y.innerHTML=Un.innerHTML)}):window.location.pathname.startsWith(Hp)&&window.location.reload()}catch(c){console.log("OG Error updating cart",c)}finally{r.style.pointerEvents="auto",r.style.opacity="1"}}n(Qp,"synchronizeCartOptin");function qn(t){var a,c;let e=t.payload.product.id;if(!e)return[];let r=kn(),o=((a=t.payload.offer)==null?void 0:a.location)||"",s=((c=t.payload.offer)==null?void 0:c.variationId)||"",i=[e,t.type.toLowerCase(),o];switch(t.type){case K:case U:i.push(""),i.push(s);break;case I:case F:i.push(t.payload.frequency),i.push(s);break;default:return[]}return[r,i.join(",")]}n(qn,"getTrackingEvent");function jr(t,e){var s;return(s=ir({id:t})(e.getState()))==null?void 0:s.frequency}n(jr,"getSubscribedFrequency");function Zp(t,e){e.isCart||[...document.querySelectorAll('form[action$="/cart/add"] [name=id]')].forEach(r=>{let o=r.value,s=jr(o,t);xs(r.form,"selling_plan",s)})}n(Zp,"synchronizeSellingPlan");function Dn(t){return e=>r=>{var o;switch(r.type){case I:case U:case F:break;case K:((o=r.payload.offer)==null?void 0:o.isCart)?Kp(t,r.payload.offer):Yp(t,r.payload.offer);break;default:}switch(e(r),r.type){case I:case U:case F:case se:Qp(r,t);case K:case R:case Q:Zp(t,r.payload.offer);break;default:}}}n(Dn,"shopifyMiddleware");St();q();A();q();var Xp="/apps/subscriptions/auth/",Aa="og_auth_begin",eu="og_auth_end",tu=n(t=>{let[e,r,o,s]=atob(t).split("|");return{id:e,signature:o,timestamp:r,email:s}},"parseIntegrationTempAuth");async function Na({store:t}){var s;let[e]=ro(),r=Et(),o=(r==null?void 0:r.dataset.customer)?tu(r.dataset.customer):(s=window.ogShopifyConfig)==null?void 0:s.customer;if(o){let i=await ou(o);if(i){let[a,c,l]=i.split("|");t.dispatch(vt(e,a,Number(c),l))}}else Ss("og_auth")}n(Na,"authorizeShopifyCustomer");async function ru(t){try{let r=await(await fetch(`${Xp}?customer=${t.id}&customer_signature=${t.signature}&customer_timestamp=${t.timestamp}`)).text(),o=r.lastIndexOf(Aa);if(o<0)throw"Invalid response from OG auth endpoint";return JSON.parse(r.substring(o+Aa.length,r.lastIndexOf(eu)))}catch(e){console.error(e)}}n(ru,"fetchOGSignature");async function ou(t){let e=Es("og_auth");if(e)return e;let{customerId:r,timestamp:o,signature:s}=await ru(t);if(!r)return"";let i=new Date,a=btoa(s);i.setTime(i.getTime()+2*60*60*1e3);let c=`${r}|${o}|${a};expires=${i.toUTCString()}`;return document.cookie=`og_auth=${c};secure;path=/`,c}n(ou,"getOrCreateAuthCookie");var Ia,ka=Js(...((Ia=L)==null?void 0:Ia.shopify_selling_plans)?[Nn,Dn]:[Ur],L.shopify&&In),T=Cn(ka),nu=T.isReady,su=T.addOptinChangedCallback,iu=T.addTemplate,au=T.clear,cu=T.config,lu=T.disableOptinChangedCallbacks,pu=T.getOptins,uu=T.getProductsForPurchasePost,du=T.initialize,fu=T.previewMode,hu=T.register,mu=T.resolveSettings,gu=T.setAuthUrl,yu=T.setEnvironment,bu=T.setLocale,_u=T.setMerchantId,Su=T.setPublicPath,Eu=T.setTemplates,xu=T.setupCart,vu=T.setupProduct,Ou=T.setupProducts,Pu=n(()=>_s(T),"autoInit");var Tu=T.initialize,qa;((qa=L)==null?void 0:qa.shopify_selling_plans)&&cr(()=>Na(T));return wu;})();
|
|
939
1014
|
; return lib; });
|
|
940
1015
|
//# sourceMappingURL=offers.js.map
|