UNPKG

@redotech/redo-hydrogen

Version:

Utilities to enable and disable Redo coverage on Hydrogen stores

10 lines 52 kB
"use strict";var e=require("react"),t=require("react-router"),r=require("@shopify/hydrogen"),n=require("react-dom");function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var a=o(e),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)};function l(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function l(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,l)}c((n=n.apply(e,t||[])).next())})}function c(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(c){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}}function s(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var u,d={exports:{}},f={};var p,m,v={}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */function h(){return p||(p=1,"production"!==process.env.NODE_ENV&&function(){var t=e,r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),h=Symbol.iterator;var y=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=y.ReactDebugCurrentFrame,o=n.getStackAddendum();""!==o&&(t+="%s",r=r.concat([o]));var a=r.map(function(e){return String(e)});a.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,a)}("error",e,r)}var b;function x(e){return e.displayName||"Context"}function _(e){if(null==e)return null;if("number"==typeof e.tag&&g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case o:return"Fragment";case n:return"Portal";case i:return"Profiler";case a:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case c:return x(e)+".Consumer";case l:return x(e._context)+".Provider";case s:return function(e,t,r){var n=e.displayName;if(n)return n;var o=t.displayName||t.name||"";return""!==o?r+"("+o+")":r}(e,e.render,"ForwardRef");case f:var t=e.displayName||null;return null!==t?t:_(e.type)||"Memo";case p:var r=e,m=r._payload,v=r._init;try{return _(v(m))}catch(e){return null}}return null}b=Symbol.for("react.module.reference");var w,E,j,I,k,C,S,O=Object.assign,R=0;function A(){}A.__reactDisabledLog=!0;var T,N=y.ReactCurrentDispatcher;function P(e,t,r){if(void 0===T)try{throw Error()}catch(e){var n=e.stack.trim().match(/\n( *(at )?)/);T=n&&n[1]||""}return"\n"+T+e}var D,F=!1,B="function"==typeof WeakMap?WeakMap:Map;function M(e,t){if(!e||F)return"";var r,n=D.get(e);if(void 0!==n)return n;F=!0;var o,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=N.current,N.current=null,function(){if(0===R){w=console.log,E=console.info,j=console.warn,I=console.error,k=console.group,C=console.groupCollapsed,S=console.groupEnd;var e={configurable:!0,enumerable:!0,value:A,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}R++}();try{if(t){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(e){r=e}Reflect.construct(e,[],i)}else{try{i.call()}catch(e){r=e}e.call(i.prototype)}}else{try{throw Error()}catch(e){r=e}e()}}catch(t){if(t&&r&&"string"==typeof t.stack){for(var l=t.stack.split("\n"),c=r.stack.split("\n"),s=l.length-1,u=c.length-1;s>=1&&u>=0&&l[s]!==c[u];)u--;for(;s>=1&&u>=0;s--,u--)if(l[s]!==c[u]){if(1!==s||1!==u)do{if(s--,--u<0||l[s]!==c[u]){var d="\n"+l[s].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,d),d}}while(s>=1&&u>=0);break}}}finally{F=!1,N.current=o,function(){if(0===--R){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},e,{value:w}),info:O({},e,{value:E}),warn:O({},e,{value:j}),error:O({},e,{value:I}),group:O({},e,{value:k}),groupCollapsed:O({},e,{value:C}),groupEnd:O({},e,{value:S})})}R<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var f=e?e.displayName||e.name:"",p=f?P(f):"";return"function"==typeof e&&D.set(e,p),p}function U(e,t,r){if(null==e)return"";if("function"==typeof e)return M(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return P(e);switch(e){case u:return P("Suspense");case d:return P("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case s:return M(e.render,!1);case f:return U(e.type,t,r);case p:var o=e,a=o._payload,i=o._init;try{return U(i(a),t,r)}catch(e){}}return""}D=new B;var z=Object.prototype.hasOwnProperty,L={},$=y.ReactDebugCurrentFrame;function W(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);$.setExtraStackFrame(r)}else $.setExtraStackFrame(null)}var q=Array.isArray;function V(e){return q(e)}function H(e){return""+e}function G(e){if(function(e){try{return H(e),!1}catch(e){return!0}}(e))return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),H(e)}var J,X,Y=y.ReactCurrentOwner,K={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,t,n,o,a){var i,l={},c=null,s=null;for(i in void 0!==n&&(G(n),c=""+n),function(e){if(z.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(G(t.key),c=""+t.key),function(e){if(z.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(s=t.ref,function(e){"string"==typeof e.ref&&Y.current}(t)),t)z.call(t,i)&&!K.hasOwnProperty(i)&&(l[i]=t[i]);if(e&&e.defaultProps){var u=e.defaultProps;for(i in u)void 0===l[i]&&(l[i]=u[i])}if(c||s){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;c&&function(e,t){var r=function(){J||(J=!0,g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(l,d),s&&function(e,t){var r=function(){X||(X=!0,g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(l,d)}return function(e,t,n,o,a,i,l){var c={$$typeof:r,type:e,key:t,ref:n,props:l,_owner:i,_store:{}};return Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}(e,c,s,a,o,Y.current,l)}var Z,ee=y.ReactCurrentOwner,te=y.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);te.setExtraStackFrame(r)}else te.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}function oe(){if(ee.current){var e=_(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ae={};function ie(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=oe();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!ae[r]){ae[r]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+_(e._owner.type)+"."),re(e),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),re(null)}}}function le(e,t){if("object"==typeof e)if(V(e))for(var r=0;r<e.length;r++){var n=e[r];ne(n)&&ie(n,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var o=function(e){if(null===e||"object"!=typeof e)return null;var t=h&&e[h]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof o&&o!==e.entries)for(var a,i=o.call(e);!(a=i.next()).done;)ne(a.value)&&ie(a.value,t)}}function ce(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==s&&r.$$typeof!==f)return;t=r.propTypes}if(t){var n=_(r);!function(e,t,r,n,o){var a=Function.call.bind(z);for(var i in e)if(a(e,i)){var l=void 0;try{if("function"!=typeof e[i]){var c=Error((n||"React class")+": "+r+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw c.name="Invariant Violation",c}l=e[i](t,i,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(e){l=e}!l||l instanceof Error||(W(o),g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,i,typeof l),W(null)),l instanceof Error&&!(l.message in L)&&(L[l.message]=!0,W(o),g("Failed %s type: %s",r,l.message),W(null))}}(t,e.props,"prop",n,e)}else if(void 0!==r.PropTypes&&!Z){Z=!0,g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_(r)||"Unknown")}"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var se={};function ue(e,t,n,v,h,y){var x=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===i||e===a||e===u||e===d||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===p||e.$$typeof===f||e.$$typeof===l||e.$$typeof===c||e.$$typeof===s||e.$$typeof===b||void 0!==e.getModuleId)}(e);if(!x){var w="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(w+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var E;w+=oe(),null===e?E="null":V(e)?E="array":void 0!==e&&e.$$typeof===r?(E="<"+(_(e.type)||"Unknown")+" />",w=" Did you accidentally export a JSX literal instead of a component?"):E=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,w)}var j=Q(e,t,n,h,y);if(null==j)return j;if(x){var I=t.children;if(void 0!==I)if(v)if(V(I)){for(var k=0;k<I.length;k++)le(I[k],e);Object.freeze&&Object.freeze(I)}else g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else le(I,e)}if(z.call(t,"key")){var C=_(e),S=Object.keys(t).filter(function(e){return"key"!==e}),O=S.length>0?"{key: someKey, "+S.join(": ..., ")+": ...}":"{key: someKey}";if(!se[C+O])g('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',O,C,S.length>0?"{"+S.join(": ..., ")+": ...}":"{}",C),se[C+O]=!0}return e===o?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){re(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),re(null);break}}null!==e.ref&&(re(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}(j):ce(j),j}var de=function(e,t,r){return ue(e,t,r,!1)},fe=function(e,t,r){return ue(e,t,r,!0)};v.Fragment=o,v.jsx=de,v.jsxs=fe}()),v}var y,g=(m||(m=1,"production"===process.env.NODE_ENV?d.exports=function(){if(u)return f;u=1;var t=e,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,n){var l,c={},s=null,u=null;for(l in void 0!==n&&(s=""+n),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,l)&&!i.hasOwnProperty(l)&&(c[l]=t[l]);if(e&&e.defaultProps)for(l in t=e.defaultProps)void 0===c[l]&&(c[l]=t[l]);return{$$typeof:r,type:e,key:s,ref:u,props:c,_owner:a.current}}return f.Fragment=n,f.jsx=l,f.jsxs=l,f}():d.exports=h()),d.exports);exports.RedoErrorType=void 0,(y=exports.RedoErrorType||(exports.RedoErrorType={})).ApiBadRequest="API_BAD_REQUEST",y.ApiServerError="API_SERVER_ERROR",y.ApiUnknownError="API_UNKNOWN_ERROR";var b="api.getredo.com",x=[b],_=function(e){return Array.isArray(e.lines)&&"linesAdd"in e&&"function"==typeof e.linesAdd},w=function(e){var t;return E(e)?e.lines.nodes:_(e)?e.lines:null!==(t=e.lines.nodes)&&void 0!==t?t:e.lines.edges.map(function(e){return e.node})},E=function(e){var t;return"isOptimistic"in e&&null!==(t=e.isOptimistic)&&void 0!==t&&t},j=function(e){return l(void 0,[e],void 0,function(e){var t,r,n=e.cart,o=e.fetcher,a=e.waitCartIdle,i=e.cartInfoToEnable;return c(this,function(e){switch(e.label){case 0:return n?[3,2]:[4,C({cart:n,fetcher:o,waitCartIdle:a,cartInfoToEnable:i})];case 1:return[2,e.sent()];case 2:return t=w(n).filter(function(e){return"re:do"===e.merchandise.product.vendor}),r=null==t?void 0:t.filter(function(e){return e.merchandise.id==="gid://shopify/ProductVariant/".concat(i.variantId)}),0!==t.length?[3,4]:[4,C({cart:n,fetcher:o,waitCartIdle:a,cartInfoToEnable:i})];case 3:return[2,e.sent()];case 4:return 1!==t.length||1!==r.length||1!==r[0].quantity?[3,5]:[2];case 5:return[4,I({cart:n,fetcher:o,waitCartIdle:a,lineIds:t.map(function(e){return e.id})})];case 6:return e.sent(),[4,C({cart:n,fetcher:o,waitCartIdle:a,cartInfoToEnable:i})];case 7:e.sent(),e.label=8;case 8:return[2]}})})},I=function(e){return l(void 0,[e],void 0,function(e){var t,n,o=e.cart,a=e.fetcher,i=e.waitCartIdle,l=e.lineIds;return c(this,function(e){switch(e.label){case 0:return t={action:r.CartForm.ACTIONS.LinesRemove,inputs:{lineIds:l}},o&&_(o)?(o.linesRemove(l),[4,i()]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,a.submit((n={},n[r.CartForm.INPUT_NAME]=JSON.stringify(t),n),{method:"POST",action:"/cart"})];case 3:e.sent(),e.label=4;case 4:return[2]}})})},k=function(e){return l(void 0,[e],void 0,function(e){var t,r=e.cart,n=e.fetcher,o=e.waitCartIdle;return c(this,function(e){switch(e.label){case 0:return r?0===(t=w(r).filter(function(e){return"re:do"===e.merchandise.product.vendor})).length?[3,2]:[4,I({cart:r,fetcher:n,waitCartIdle:o,lineIds:t.map(function(e){return e.id})})]:(console.error("No cart"),[2]);case 1:e.sent(),e.label=2;case 2:return[2]}})})},C=function(e){return l(void 0,[e],void 0,function(e){var t,n,o,a=e.waitCartIdle,i=e.cart,l=e.fetcher,s=e.cartInfoToEnable;return c(this,function(e){switch(e.label){case 0:return t={merchandiseId:"gid://shopify/ProductVariant/".concat(s.variantId),quantity:1},n={action:r.CartForm.ACTIONS.LinesAdd,inputs:{lines:[t]}},i&&_(i)?(i.linesAdd([t]),[4,a()]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,l.submit((o={},o[r.CartForm.INPUT_NAME]=JSON.stringify(n),o),{method:"POST",action:"/cart"})];case 3:e.sent(),e.label=4;case 4:return[2]}})})};var S=function(e){return l(void 0,[e],void 0,function(e){var t,n,o,a,i,l,s,u=e.cart,d=e.fetcher,f=e.waitCartIdle,p=e.cartInfoToEnable,m=e.enabled;return c(this,function(e){switch(e.label){case 0:return t={key:(null==p?void 0:p.cartAttribute)||"redo_opted_in_from_cart",value:m.toString()},n=(null==u?void 0:u.attributes)||[],(o=new Map(n.map(function(e){return[e.key,e.value]}))).set(t.key,t.value),(a=function(){try{var e=localStorage.getItem("redoConciergeConversationIds");if(!e)return null;var t=JSON.parse(e),r=Date.now(),n=t.filter(function(e){return e.expiresAt>r}).map(function(e){return e.conversationId});return n.length>0?n:null}catch(e){return null}}())&&a.length>0&&o.set("redo.conciergeAssisted",JSON.stringify({conciergeConversationIds:a})),i=Array.from(o.entries()).map(function(e){var t=e[0],r=e[1];return{key:t,value:null!=r?r:""}}),l={action:r.CartForm.ACTIONS.AttributesUpdateInput,inputs:{attributes:i}},u&&_(u)?(u.cartAttributesUpdate(i),[4,f()]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,d.submit((s={},s[r.CartForm.INPUT_NAME]=JSON.stringify(l),s),{method:"POST",action:"/cart"})];case 3:e.sent(),e.label=4;case 4:return[2]}})})};var O,R,A=e.createContext({enabled:!1,loading:!0}),T=function(){var r=e.useContext(A),n=function(r){var n=this,o=t.useFetcher(r),a=e.useRef(null),s=e.useRef(null);s.current||(s.current=new Promise(function(e){a.current=e}));var u=e.useCallback(function(){s.current=new Promise(function(e){a.current=e})},[s,a]),d=e.useCallback(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return l(n,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return o.submit.apply(o,e),[4,s.current];case 1:return t.sent(),[2]}})})},[o,s]);return e.useEffect(function(){var e;"idle"===o.state&&(o.data&&(null===(e=a.current)||void 0===e||e.call(a,o.data)),u())},[o,u]),i(i({},o),{submit:d})}(),o=function(t){var r=e.useRef(null),n=e.useRef(null);n.current||(n.current=new Promise(function(e){r.current=e}));var o=e.useCallback(function(){n.current=new Promise(function(e){r.current=e})},[n,r]),a=e.useCallback(function(){return l(void 0,void 0,void 0,function(){return c(this,function(e){return[2,n.current]})})},[t,n]);return e.useEffect(function(){var e,n;t&&(_(t)?"idle"===t.status&&(null===(n=r.current)||void 0===n||n.call(r,t),o()):(null===(e=r.current)||void 0===e||e.call(r,t),o()))},[t,o]),a}(r.cart);return e.useEffect(function(){!r.loading&&r.cartInfoToEnable&&k({cart:r.cart,fetcher:n,waitCartIdle:o,cartInfoToEnable:r.cartInfoToEnable})},[r.loading]),{enable:function(){return l(void 0,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return r.loading||!r.cartInfoToEnable?[2,!1]:[4,j({fetcher:n,waitCartIdle:o,cart:r.cart,cartInfoToEnable:r.cartInfoToEnable})];case 1:return e.sent(),[4,S({cart:r.cart,fetcher:n,waitCartIdle:o,cartInfoToEnable:r.cartInfoToEnable,enabled:!0})];case 2:return e.sent(),[2,!0]}})})},disable:function(){return l(void 0,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return r.cartInfoToEnable?[4,k({fetcher:n,waitCartIdle:o,cart:r.cart,cartInfoToEnable:r.cartInfoToEnable})]:[2,!1];case 1:return e.sent(),[4,S({cart:r.cart,fetcher:n,waitCartIdle:o,cartInfoToEnable:r.cartInfoToEnable,enabled:!1})];case 2:return e.sent(),[2,!0]}})})},get loading(){return r.loading},get eligible(){var e;return!(this.loading||!this.price||!this.cartProduct||!(null===(e=this.cart)||void 0===e?void 0:e.cost))},get enabled(){return r.enabled},get price(){var e,t,n,o=null===(n=null===(t=null===(e=r.cartInfoToEnable)||void 0===e?void 0:e.selectedVariant)||void 0===t?void 0:t.price)||void 0===n?void 0:n.amount;if(o&&"NaN"!==Number(o).toString())return Number(o)},get cart(){return r.cart},get cartProduct(){var e;return null===(e=r.cartInfoToEnable)||void 0===e?void 0:e.selectedVariant},get cartAttribute(){var e;return null===(e=r.cartInfoToEnable)||void 0===e?void 0:e.cartAttribute},get storeId(){return r.storeId},get errors(){return r.errors}}};function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},N.apply(null,arguments)}var P=function(e){return a.createElement("svg",N({xmlns:"http://www.w3.org/2000/svg",width:24,height:24},e),O||(O=a.createElement("path",{fill:"currentColor",d:"M12 1a11 11 0 1 0 11 11A11 11 0 0 0 12 1m0 19a8 8 0 1 1 8-8 8 8 0 0 1-8 8",opacity:.25})),R||(R=a.createElement("path",{fill:"currentColor",d:"M10.14 1.16a11 11 0 0 0-9 8.92A1.59 1.59 0 0 0 2.46 12a1.52 1.52 0 0 0 1.65-1.3 8 8 0 0 1 6.66-6.61A1.42 1.42 0 0 0 12 2.69a1.57 1.57 0 0 0-1.86-1.53"},a.createElement("animateTransform",{attributeName:"transform",dur:"0.75s",repeatCount:"indefinite",type:"rotate",values:"0 12 12;360 12 12"}))))};function D(e,t){return l(this,arguments,void 0,function(e,t,r){return void 0===r&&(r=new Error("timeout")),c(this,function(n){return[2,Promise.race([e,new Promise(function(e,n){return setTimeout(function(){return n(r)},t)})])]})})}var F,B=function(e){var t=e.redoCoverageClient,r=e.cart,n=e.storeId;return new Promise(function(e,o){fetch("https://".concat(b,"/v2.2/stores/").concat(n,"/checkout-buttons-ui"),{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(n){return l(void 0,void 0,void 0,function(){var a,i;return c(this,function(l){switch(l.label){case 0:return[4,n.json()];case 1:return(a=l.sent()).html?(i=M({redoCoverageClient:t,cart:r,ui:a}))?[2,e(i)]:[2,o(null)]:[2,e(null)]}})})})})},M=function(e){var t=e.redoCoverageClient,r=e.cart,n=e.ui;if(!t.eligible||!t.price||!(null==r?void 0:r.cost))return null;var o=r.cost.subtotalAmount.currencyCode;"XXX"===o&&(o="USD");var a=!!w(r).some(function(e){var t,r;return"re:do"===(null===(r=null===(t=e.merchandise)||void 0===t?void 0:t.product)||void 0===r?void 0:r.vendor)}),i=new Intl.NumberFormat("en-US",{style:"currency",currency:o}).format(Number(r.cost.subtotalAmount.amount)+(a?0:t.price));return i&&i.length&&!i.includes("NaN")?(n.html=n.html.replaceAll("%combinedPrice%",i),n):null},U=function(e,t){return null===e?null:t(e)?e:U(e.parentElement,t)};function z(){return z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},z.apply(null,arguments)}var L,$=function(e){return a.createElement("svg",z({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},e),a.createElement("g",{"data-name":"Layer 2"},a.createElement("g",{"data-name":"Layer 1"},a.createElement("circle",{cx:50,cy:50,r:46.5,fill:"none",stroke:"currentColor",className:"info_svg__cls-1",style:{strokeMiterlimit:10,strokeWidth:7}}),F||(F=a.createElement("path",{fill:"currentColor",d:"M50 25a4.49 4.49 0 0 1 4.51 4.5A4.43 4.43 0 0 1 50 33.92a4.36 4.36 0 0 1-4.43-4.43A4.42 4.42 0 0 1 50 25m-3.39 16.43h6.78V75h-6.78Z"})))))};function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},W.apply(null,arguments)}var q,V,H=function(e){return a.createElement("svg",W({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 25 24"},e),L||(L=a.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"m9.667 11.5 2 2 4.5-4.5m4.5 3c0 4.908-5.355 8.478-7.303 9.615-.22.129-.332.194-.488.227a1.1 1.1 0 0 1-.42 0c-.155-.034-.266-.098-.487-.227C10.02 20.478 4.667 16.908 4.667 12V7.217c0-.799 0-1.199.13-1.542a2 2 0 0 1 .547-.79c.276-.243.65-.383 1.399-.664l5.362-2.01c.208-.078.311-.117.418-.133a1 1 0 0 1 .287 0c.106.016.21.055.418.133l5.362 2.01c.749.28 1.123.421 1.399.664a2 2 0 0 1 .547.79c.13.343.13.743.13 1.542z"})))};function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},G.apply(null,arguments)}var J,X,Y=function(e){return a.createElement("svg",G({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 36 36"},e),q||(q=a.createElement("g",{filter:"url(#featured-package-check_svg__a)"},a.createElement("path",{stroke:"#D6D6D6",d:"M2.5 7A5.5 5.5 0 0 1 8 1.5h20A5.5 5.5 0 0 1 33.5 7v20a5.5 5.5 0 0 1-5.5 5.5H8A5.5 5.5 0 0 1 2.5 27z",shapeRendering:"crispEdges"}),a.createElement("path",{stroke:"#424242",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.333,d:"M23.667 13.852 18 17m0 0-5.667-3.148M18 17v6.333m1.333-.407-.815.453c-.189.105-.284.157-.384.178a.7.7 0 0 1-.268 0c-.1-.02-.195-.073-.384-.178l-4.933-2.74c-.2-.112-.3-.167-.373-.246a.7.7 0 0 1-.142-.243C12 20.048 12 19.934 12 19.706v-5.412c0-.228 0-.342.034-.444a.7.7 0 0 1 .142-.243c.073-.079.173-.134.373-.245l4.933-2.74c.189-.106.284-.158.384-.179a.7.7 0 0 1 .268 0c.1.02.195.073.384.178l4.933 2.74c.2.112.3.167.373.246q.097.107.142.243c.034.102.034.216.034.444v3.04M15 12l6 3.333M20.667 21 22 22.333l2.667-2.666"}))),V||(V=a.createElement("defs",null,a.createElement("filter",{id:"featured-package-check_svg__a",width:36,height:36,x:0,y:0,colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse"},a.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),a.createElement("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),a.createElement("feOffset",{dy:1}),a.createElement("feGaussianBlur",{stdDeviation:1}),a.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),a.createElement("feColorMatrix",{values:"0 0 0 0 0.0627451 0 0 0 0 0.0941176 0 0 0 0 0.156863 0 0 0 0.05 0"}),a.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_632_1403"}),a.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_632_1403",result:"shape"})))))};function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},K.apply(null,arguments)}var Q,Z,ee=function(e){return a.createElement("svg",K({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 36 36"},e),J||(J=a.createElement("g",{filter:"url(#featured-laptop-2_svg__a)"},a.createElement("path",{stroke:"#D6D6D6",d:"M2.5 7A5.5 5.5 0 0 1 8 1.5h20A5.5 5.5 0 0 1 33.5 7v20a5.5 5.5 0 0 1-5.5 5.5H8A5.5 5.5 0 0 1 2.5 27z",shapeRendering:"crispEdges"}),a.createElement("path",{stroke:"#424242",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.333,d:"M24 19.667V13.8c0-.747 0-1.12-.145-1.405a1.33 1.33 0 0 0-.583-.583c-.285-.145-.659-.145-1.405-.145h-7.734c-.746 0-1.12 0-1.405.145-.251.128-.455.332-.583.583C12 12.68 12 13.053 12 13.8v5.867m1.111 2.666h9.778c.413 0 .62 0 .79-.045.46-.123.819-.483.942-.943.046-.17.046-.376.046-.79 0-.206 0-.31-.023-.394a.67.67 0 0 0-.471-.472c-.085-.022-.189-.022-.395-.022H12.222c-.207 0-.31 0-.395.022a.67.67 0 0 0-.471.472c-.023.085-.023.188-.023.395 0 .413 0 .62.046.79.123.46.482.819.943.942.169.045.376.045.789.045"}))),X||(X=a.createElement("defs",null,a.createElement("filter",{id:"featured-laptop-2_svg__a",width:36,height:36,x:0,y:0,colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse"},a.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),a.createElement("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),a.createElement("feOffset",{dy:1}),a.createElement("feGaussianBlur",{stdDeviation:1}),a.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),a.createElement("feColorMatrix",{values:"0 0 0 0 0.0627451 0 0 0 0 0.0941176 0 0 0 0 0.156863 0 0 0 0.05 0"}),a.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_635_1424"}),a.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_635_1424",result:"shape"})))))};function te(){return te=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},te.apply(null,arguments)}var re,ne,oe=function(e){return a.createElement("svg",te({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 36 36"},e),Q||(Q=a.createElement("g",{filter:"url(#featured-refresh-cw-3_svg__a)"},a.createElement("path",{stroke:"#D6D6D6",d:"M2.5 7A5.5 5.5 0 0 1 8 1.5h20A5.5 5.5 0 0 1 33.5 7v20a5.5 5.5 0 0 1-5.5 5.5H8A5.5 5.5 0 0 1 2.5 27z",shapeRendering:"crispEdges"}),a.createElement("path",{stroke:"#424242",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.333,d:"M19.333 23.667s.567-.081 2.91-2.424a6 6 0 0 0-2.91-10.094m0 12.518h4m-4 0v-4m-2.666-9.333s-.567.08-2.91 2.424a6 6 0 0 0 2.91 10.093m0-12.517h-4m4 0v4"}))),Z||(Z=a.createElement("defs",null,a.createElement("filter",{id:"featured-refresh-cw-3_svg__a",width:36,height:36,x:0,y:0,colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse"},a.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),a.createElement("feColorMatrix",{in:"SourceAlpha",result:"hardAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),a.createElement("feOffset",{dy:1}),a.createElement("feGaussianBlur",{stdDeviation:1}),a.createElement("feComposite",{in2:"hardAlpha",operator:"out"}),a.createElement("feColorMatrix",{values:"0 0 0 0 0.0627451 0 0 0 0 0.0941176 0 0 0 0 0.156863 0 0 0 0.05 0"}),a.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow_632_1398"}),a.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow_632_1398",result:"shape"})))))};function ae(){return ae=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ae.apply(null,arguments)}var ie,le,ce,se=function(e){return a.createElement("svg",ae({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 800 255"},e),re||(re=a.createElement("path",{fill:"#141414",d:"M0 0h800v255H0z"})),ne||(ne=a.createElement("path",{fill:"#fff",fillRule:"evenodd",d:"M715.79 184.078c27.298-18.606 29.78-45.844 29.78-57.929 0-20.524-7.827-34.527-12.217-41.049-9.354-13.427-25.962-27.622-61.66-30.5-6.108-.575-12.026-.575-18.135-.575-30.161.384-46.579 7.29-58.032 15.154-11.072 7.48-29.207 24.553-29.207 58.697 0 8.631.572 26.279 14.89 43.734 6.681 8.057 13.362 12.468 16.989 14.578 10.881 6.522 28.253 12.852 56.887 12.852 19.09 0 30.926-2.301 38.752-4.603 8.018-2.302 14.89-5.563 21.953-10.359m-32.07-90.154c4.963 4.411 12.217 15.345 12.217 32.609 0 15.345-6.109 32.609-21.189 39.323-7.254 3.261-15.845 3.261-18.136 3.261-8.208 0-29.97-1.727-37.988-25.896-2.482-7.097-2.672-14.003-2.672-16.496 0-16.497 7.254-32.801 23.098-39.515 5.918-2.494 11.072-3.07 17.372-3.07 7.254 0 10.881.96 14.317 2.11 6.49 2.303 11.072 5.755 12.981 7.674m-144.931 78.645c13.744-16.112 14.317-38.172 14.317-44.31 0-7.289-.382-24.553-11.836-41.049-8.017-11.7-21.762-24.936-53.069-27.622a224 224 0 0 0-16.035-.575h-76.549v135.424h85.521c13.554 0 18.517-.959 25.389-2.686 8.209-2.11 14.317-5.371 17.181-6.905 8.017-4.604 12.79-9.399 15.081-12.277m-45.243-74.042c11.836 9.208 12.408 24.361 12.408 28.581 0 3.645-.191 10.934-4.39 19.566-3.245 6.905-9.163 14.386-25.771 16.496a64 64 0 0 1-8.4.576h-24.625V91.238h23.098l.445-.001c3.947-.017 17.525-.073 27.235 7.29m-120.925 95.91H228.685V59.013h142.218V89.32h-93.921v22.251h86.857v30.499h-86.857v21.676h95.639zm-216.774 0h53.26l-33.598-54.093c6.872-1.727 9.354-2.686 12.599-4.604 16.99-9.399 18.326-27.43 18.326-33.76 0-12.276-4.39-20.333-6.872-24.36-10.881-17.265-28.253-18.607-46.388-18.607H53.908v135.424h48.488v-49.298h25.58zm.381-99.17c1.909 2.685 2.1 5.754 2.1 6.905 0 1.534-.191 4.604-2.672 7.673-3.055 3.644-7.827 4.795-16.99 4.795h-36.27V89.704h40.088c5.154 0 10.499.767 13.744 5.562",clipRule:"evenodd"})))};function ue(){return ue=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ue.apply(null,arguments)}var de=function(e){return a.createElement("svg",ue({xmlns:"http://www.w3.org/2000/svg",width:24,height:24,fill:"none"},e),ie||(ie=a.createElement("circle",{cx:12,cy:12,r:12,fill:"#A6A9BA",opacity:.2})),le||(le=a.createElement("g",{stroke:"#14181F",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:.5,strokeWidth:1.5,clipPath:"url(#modal-close-button_svg__a)"},a.createElement("path",{d:"m15.6 15.598-7.2-7.2M15.6 8.398l-7.2 7.2"}))),ce||(ce=a.createElement("defs",null,a.createElement("clipPath",{id:"modal-close-button_svg__a"},a.createElement("path",{fill:"#fff",d:"M7.2 7.2h9.6v9.6H7.2z"})))))};var fe=function(t){var r,o=t.open,a=t.onClose,i=t.infoModalLogoUrl,l=t.infoModalImageUrl,c=t.modalContent;if(r="\n ".concat(pe,"\n ").concat(me,"\n \n @media (max-width: 768px) {\n .redo-info-modal__container {\n flex-direction: column !important;\n align-items: stretch !important;\n overflow: auto !important;\n width: 95% !important;\n }\n \n .redo-info-modal__sideImageContainer {\n width: 100% !important;\n min-width: unset !important;\n max-height: 140px !important;\n overflow: hidden !important;\n }\n \n .redo-info-modal__sideImageContainer img {\n height: 140px !important;\n max-height: 140px !important;\n }\n \n .redo-info-modal__contentContainer {\n width: 100% !important;\n box-sizing: border-box !important;\n }\n }\n "),e.useEffect(function(){var e=document.createElement("style");return e.textContent=r,document.head.appendChild(e),function(){(null==e?void 0:e.parentElement)&&e.parentElement.removeChild(e)}},[r]),!o)return g.jsx(g.Fragment,{});var s=g.jsx("div",{className:"redo-info-modal__backgroundContainer",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:99999,transform:"translateZ(0)",opacity:1,transition:"opacity 0.2s ease-in-out",animation:"fadeIn 0.2s ease-in-out"},onClick:a,children:g.jsxs("div",{className:"redo-info-modal__container",style:{backgroundColor:"white",borderRadius:"8px",width:"700px",maxWidth:"900px",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e5,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"left",maxHeight:"95%",boxShadow:"0 4px 8px 0 rgba(0, 0, 0, 0.2)",opacity:1,transition:"opacity 0.2s ease-in-out, transform 0.2s ease-in-out",animation:"slideIn 0.2s ease-in-out forwards",minHeight:"100px"},onClick:function(e){return e.stopPropagation()},children:[g.jsx("button",{className:"redo-info-modal__closeButton",onClick:a,style:{position:"absolute",right:"16px",top:"16px",border:"none",background:"none",fontSize:"20px",cursor:"pointer",padding:"4px",zIndex:1},children:g.jsx(de,{})}),l?g.jsx("div",{className:"redo-info-modal__sideImageContainer",style:{minWidth:"200px",width:"200px",backgroundImage:"url(".concat(l,")"),backgroundSize:"cover",backgroundPosition:"center center",borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px",alignSelf:"stretch"}}):null,c||g.jsxs("div",{className:"redo-info-modal__contentContainer",style:{padding:"24px",fontFamily:'Inter, "Helvetica Neue", Arial, sans-serif'},children:[g.jsx("div",{className:"redo-info-modal__logoContainer",style:{width:"100%",height:"100%",display:"block",marginBottom:"8px"},children:i?g.jsx("img",{src:i,className:"redo-info-modal__logo",style:{width:"auto",height:"112px",display:"block"}}):g.jsx(se,{width:"112px",height:"112px",display:"block"})}),g.jsx("p",{style:{fontSize:"20px",fontWeight:"600"},className:"redo-info-modal__title",children:"Checkout with confidence"}),g.jsx("p",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},className:"redo-info-modal__description",children:"Shop with confidence, knowing your purchases are protected every step of the way."}),g.jsxs("div",{className:"redo-info-modal__benefitsContainer",style:{marginBottom:"24px"},children:[g.jsx("div",{className:"redo-info-modal__benefit",style:{marginBottom:"16px"},children:g.jsxs("div",{className:"redo-info-modal__benefitIconContainer",style:{display:"flex",flexDirection:"row",alignItems:"flex-start",justifyContent:"flex-start",gap:"10px"},children:[g.jsx("div",{className:"redo-info-modal__benefitIcon",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px"},children:g.jsx(oe,{height:"32",width:"32"})}),g.jsxs("div",{className:"redo-info-modal__benefitTextContainer",style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[g.jsx("p",{className:"redo-info-modal__benefitText",style:{fontSize:"16px",fontWeight:"600",marginBottom:"4px"},children:"Free returns & exchanges"}),g.jsx("p",{className:"redo-info-modal__benefitSmallText",style:{fontSize:"12px",color:"#666"},children:"Return or exchange your items for free. If you're not completely satisfied, we've got you covered."})]})]})}),g.jsx("div",{className:"redo-info-modal__benefit",style:{marginBottom:"16px"},children:g.jsxs("div",{className:"redo-info-modal__benefitIconContainer",style:{display:"flex",flexDirection:"row",alignItems:"flex-start",gap:"10px"},children:[g.jsx("div",{className:"redo-info-modal__benefitIcon",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px"},children:g.jsx(Y,{height:"32",width:"32"})}),g.jsxs("div",{className:"redo-info-modal__benefitTextContainer",style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[g.jsx("p",{className:"redo-info-modal__benefitText",style:{fontSize:"16px",fontWeight:"600",marginBottom:"4px"},children:"Package protection"}),g.jsx("p",{className:"redo-info-modal__benefitSmallText",style:{fontSize:"12px",color:"#666"},children:"Rest assured, if your package is lost, stolen, or damaged, we've got you covered."})]})]})}),g.jsx("div",{className:"redo-info-modal__benefit",style:{marginBottom:"16px"},children:g.jsxs("div",{className:"redo-info-modal__benefitIconContainer",style:{display:"flex",flexDirection:"row",alignItems:"flex-start",gap:"10px"},children:[g.jsx("div",{className:"redo-info-modal__benefitIcon",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px"},children:g.jsx(ee,{height:"32",width:"32"})}),g.jsxs("div",{className:"redo-info-modal__benefitTextContainer",style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[g.jsx("p",{className:"redo-info-modal__benefitText",style:{fontSize:"16px",fontWeight:"600",marginBottom:"4px"},children:"Easy return portal"}),g.jsx("p",{className:"redo-info-modal__benefitSmallText",style:{fontSize:"12px",color:"#666"},children:"Skip all the back and forth, and submit your return in a few clicks."})]})]})})]}),g.jsxs("p",{className:"redo-info-modal__footerText",style:{fontSize:"12px",color:"#666"},children:["By purchasing Redo, you agree and have read the"," ",g.jsx("a",{href:"https://www.getredo.com/privacy-policy",target:"_blank",rel:"noopener noreferrer",style:{color:"#000",textDecoration:"underline"},children:"Privacy Policy"})," ","and"," ",g.jsx("a",{href:"https://www.getredo.com/terms-conditions",target:"_blank",rel:"noopener noreferrer",style:{color:"#000",textDecoration:"underline"},children:"Terms and Conditions"}),". Redo is subject to Merchant's Return Policy."]})]})]})});return n.createPortal(s,document.body)},pe="\n @keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n",me="\n @keyframes slideIn {\n from {\n opacity: 0;\n transform: translate(-50%, -48%);\n }\n to {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n",ve="data-redo-preorder-disabled",he="data-redo-original-disabled";function ye(){for(var e,t,r,n,o,a=null!==document.querySelector("purple-dot-learn-more"),i=(o=document.querySelectorAll('button[name="add"], button[type="submit"], .product-form__submit'),Array.from(o).filter(function(e){var t,r,n=null!==(r=null===(t=e.textContent)||void 0===t?void 0:t.toLowerCase().trim())&&void 0!==r?r:"";return n.includes("add to cart")||n.includes("add to bag")})),l=0,c=i;l<c.length;l++){var s=c[l];if(a){if(!s.hasAttribute(ve)&&(s.hasAttribute(he)||s.setAttribute(he,String(s.disabled)),s.setAttribute(ve,"true"),s.disabled=!0,s.style.opacity="0.5",s.style.cursor="not-allowed",s.style.pointerEvents="none",!(null===(e=s.parentElement)||void 0===e?void 0:e.querySelector(".redo-preorder-msg")))){var u=document.createElement("div");u.className="redo-preorder-msg",u.textContent="Preorder items cannot be added during exchanges",u.style.cssText="color: #d63031; font-size: 12px; margin-top: 8px; font-weight: 500;",null===(t=s.parentElement)||void 0===t||t.insertBefore(u,s.nextSibling)}}else if(s.hasAttribute(ve)){var d="true"===s.getAttribute(he);s.removeAttribute(ve),s.removeAttribute(he),s.disabled=d,s.style.opacity="",s.style.cursor="",s.style.pointerEvents="",null===(n=null===(r=s.parentElement)||void 0===r?void 0:r.querySelector(".redo-preorder-msg"))||void 0===n||n.remove()}}}exports.REDO_REQUIRED_HOSTNAMES=x,exports.RedoCheckoutButtons=function(t){var r,n=T(),o=n.cart,a=(null===(r=n.cart)||void 0===r?void 0:r.checkoutUrl)||"/checkout",i=e.useState(null),s=i[0],u=i[1],d=e.useState(!1),f=d[0],p=d[1];e.useEffect(function(){l(void 0,void 0,void 0,function(){var e;return c(this,function(t){switch(t.label){case 0:return n.eligible&&o&&n.storeId?[4,B({redoCoverageClient:n,cart:o,storeId:n.storeId})]:[2];case 1:return(e=t.sent())&&u(e),[2]}})})},[o,n.eligible,n.price,n.storeId]);return g.jsx("div",{children:s?g.jsxs("div",{onClick:function(e){return l(void 0,void 0,void 0,function(){var r,o,i,s;return c(this,function(u){switch(u.label){case 0:if(!(r=e.target).dataset)return[2];if(o=U(r,function(e){var t;return"coverage-button"===(null===(t=e.dataset)||void 0===t?void 0:t.target)}),i=U(r,function(e){var t;return"non-coverage-button"===(null===(t=e.dataset)||void 0===t?void 0:t.target)}),!o&&!i)return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),[4,(d=!!o,l(void 0,void 0,void 0,function(){var e,r;return c(this,function(o){switch(o.label){case 0:if(!n||!n.enable||!n.disable)return console.error("Required redoCoverageClient methods not available"),[2];p(!0),o.label=1;case 1:return o.trys.push([1,5,6,7]),[4,D((d?n.enable:n.disable)(),8e3)];case 2:return e=o.sent(),t.onClick?[4,t.onClick(e)]:[3,4];case 3:o.sent(),o.label=4;case 4:return[3,7];case 5:return r=o.sent(),console.error(r),[3,7];case 6:return setTimeout(function(){p(!1)},2e3),[7];case 7:return[2]}})}))];case 2:return u.sent(),[3,4];case 3:return s=u.sent(),console.error("Failed to update coverage state:",s),[3,4];case 4:window.location.href=a,u.label=5;case 5:return[2]}var d})})},style:{position:"relative"},children:[s.css?g.jsx("style",{children:s.css}):"",g.jsx("div",{dangerouslySetInnerHTML:{__html:s.html},style:{opacity:f?.25:1,transition:"opacity 0.2s ease-in-out"}}),f&&g.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1},children:g.jsx(P,{})})]}):t.children})},exports.RedoInfoCard=function(t){var r=t.showInfoIcon,n=void 0===r||r,o=t.onInfoClick,a=t.infoCardImageUrl,i=t.infoModalLogoUrl,l=t.infoModalImageUrl,c=t.infoModalContent,s=T(),u=s.price,d=s.eligible,f=e.useState(!1),p=f[0],m=f[1];return d?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"redo-info-card__container","data-target":"info-card-container",style:{display:"flex",borderRadius:"4px",padding:"12px",alignItems:"center",gap:"12px",marginTop:"8px"},children:[g.jsx("div",{className:"redo-info-card__imageContainer",style:{width:"44px",height:"44px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0},children:a?g.jsx("img",{src:a,alt:"Redo Info",className:"redo-info-card__image",style:{width:"100%",height:"100%",objectFit:"contain"}}):g.jsx(H,{viewBox:"0 0 24 24",style:{width:"100%",height:"100%",color:"black",display:"block"}})}),g.jsx("div",{className:"redo-info-card__content","data-target":"text-and-buttons-container",style:{flex:1},children:g.jsxs("div",{className:"redo-info-card__textWrapper",style:{display:"flex",flexDirection:"column"},children:[g.jsxs("span",{className:"redo-info-card__title","data-target":"toggle-label",style:{color:"#000000",fontSize:"14px",fontWeight:600,display:"flex",alignItems:"center",gap:"5px",verticalAlign:"middle"},children:["Checkout+",n&&g.jsx("span",{className:"redo-info-card__infoIconWrapper","data-target":"toggle-info",children:g.jsx("button",{className:"redo-info-card__infoButton","data-target":"toggle-info-button",onClick:function(){o?o():m(!0)},type:"button",style:{border:"none",background:"none",padding:0,cursor:"pointer",color:"#969696",display:"flex",alignItems:"center",justifyContent:"center"},children:g.jsx($,{style:{width:"16px",height:"16px",verticalAlign:"middle"},className:"redo-info-card__infoIcon"})})})]}),g.jsx("p",{className:"redo-info-card__subtext","data-target":"toggle-subtext",style:{color:"#000000",fontSize:"12px",lineHeight:"16px"},children:"Free Returns + Package Protection"})]})}),g.jsx("div",{className:"redo-info-card__priceContainer",children:g.jsxs("p",{style:{color:"#000000",fontSize:"14px",fontWeight:400},className:"redo-info-card__price","data-target":"price",children:["$",u]})})]}),!o&&g.jsx(fe,{open:p,onClose:function(){return m(!1)},infoModalLogoUrl:i,infoModalImageUrl:l,modalContent:c})]}):g.jsx(g.Fragment,{})},exports.RedoProvider=function(t){var r=t.cart,n=t.storeId,o=t.children,a=e.useState(),i=a[0],u=a[1],d=e.useState(!0),f=d[0],p=d[1],m=e.useState([]),v=m[0],h=m[1],y=function(e){return v.find(function(t){return t.type===e.type})||h(s(s([],v,!0),[e],!1)),e};e.useEffect(function(){var e,t,o,a,i,s,d;if(r&&n&&!E(r)){var f=w(r);fetch("https://".concat(b,"/v2.2/stores/").concat(n,"/coverage-products"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cart:{lineItems:f.map(function(e){var t,r,n,o,a,i,l,c,s,u,d;return{id:e.id,originalPrice:{amount:null===(r=null===(t=e.merchandise)||void 0===t?void 0:t.price)||void 0===r?void 0:r.amount,currency:null===(o=null===(n=e.merchandise)||void 0===n?void 0:n.price)||void 0===o?void 0:o.currencyCode},priceTotal:{amount:null===(i=null===(a=e.cost)||void 0===a?void 0:a.totalAmount)||void 0===i?void 0:i.amount,currency:null===(c=null===(l=e.cost)||void 0===l?void 0:l.totalAmount)||void 0===c?void 0:c.currencyCode},product:{id:null===(u=null===(s=e.merchandise)||void 0===s?void 0:s.product)||void 0===u?void 0:u.id},variant:{id:null===(d=e.merchandise)||void 0===d?void 0:d.id},quantity:e.quantity}}),priceTotal:{amount:null===(t=null===(e=r.cost)||void 0===e?void 0:e.totalAmount)||void 0===t?void 0:t.amount,currency:null===(a=null===(o=r.cost)||void 0===o?void 0:o.totalAmount)||void 0===a?void 0:a.currencyCode}},customer:{id:(null===(s=null===(i=r.buyerIdentity)||void 0===i?void 0:i.customer)||void 0===s?void 0:s.id)||"",country:null===(d=r.buyerIdentity)||void 0===d?void 0:d.countryCode}})}).then(function(e){return l(void 0,void 0,void 0,function(){var t,r,n,o,a,i,l,s,d,f,m,v;return c(this,function(c){switch(c.label){case 0:return 500!==e.status?[3,2]:(t=y,a={type:exports.RedoErrorType.ApiServerError,message:"Internal server error occured when getting available coverage products from Redo API.. Check your inputs are correct and storeId have been configured. Reach out to Redo support if the issue persists."},i={},[4,e.json()]);case 1:return t.apply(void 0,[(a.context=(i.json=c.sent(),i),a)]),[2];case 2:return 400!==e.status?[3,4]:(r=y,l={type:exports.RedoErrorType.ApiBadRequest,message:"Bad request when getting available coverage products from Redo API. Check that the