(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[52],{136:function(e,t,s){"use strict";var n=s(0);s(195),t.a=()=>Object(n.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},195:function(e,t){},205:function(e,t,s){"use strict";s.d(t,"b",(function(){return F})),s.d(t,"a",(function(){return H}));var n=s(0),a=s(20),r=s(8);let c,o;!function(e){e.PRISTINE="pristine",e.STARTED="started",e.PROCESSING="processing",e.ERROR="has_error",e.FAILED="failed",e.SUCCESS="success",e.COMPLETE="complete"}(c||(c={})),function(e){e.SET_REGISTERED_PAYMENT_METHODS="set_registered_payment_methods",e.SET_REGISTERED_EXPRESS_PAYMENT_METHODS="set_registered_express_payment_methods",e.SET_SHOULD_SAVE_PAYMENT_METHOD="set_should_save_payment_method",e.SET_ACTIVE_PAYMENT_METHOD="set_active_payment_method"}(o||(o={}));const i={currentStatus:c.PRISTINE,shouldSavePaymentMethod:!1,activePaymentMethod:"",paymentMethodData:{payment_method:""},errorMessage:"",paymentMethods:{},expressPaymentMethods:{}},d={setPaymentStatus:()=>({pristine:()=>{},started:()=>{},processing:()=>{},completed:()=>{},error:e=>{},failed:(e,t)=>{},success:(e,t)=>{}}),currentStatus:{isPristine:!0,isStarted:!1,isProcessing:!1,isFinished:!1,hasError:!1,hasFailed:!1,isSuccessful:!1,isDoingExpressPayment:!1},paymentStatuses:c,paymentMethodData:{},errorMessage:"",activePaymentMethod:"",activeSavedToken:"",setActivePaymentMethod:()=>{},customerPaymentMethods:{},paymentMethods:{},expressPaymentMethods:{},paymentMethodsInitialized:!1,expressPaymentMethodsInitialized:!1,onPaymentProcessing:()=>()=>()=>{},setExpressPaymentError:()=>{},isExpressPaymentMethodActive:!1,setShouldSavePayment:()=>{},shouldSavePayment:!1};var l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,{type:t,paymentMethodData:s,shouldSavePaymentMethod:n=!1,errorMessage:a="",paymentMethods:r={},paymentMethod:d=""}=arguments.length>1?arguments[1]:void 0;switch(t){case c.PRISTINE:return{...i,...e,errorMessage:"",currentStatus:c.PRISTINE};case c.STARTED:return{...e,currentStatus:c.STARTED};case c.ERROR:return e.currentStatus!==c.ERROR?{...e,currentStatus:c.ERROR,errorMessage:a||e.errorMessage}:e;case c.FAILED:return e.currentStatus!==c.FAILED?{...e,currentStatus:c.FAILED,paymentMethodData:s||e.paymentMethodData,errorMessage:a||e.errorMessage}:e;case c.SUCCESS:return e.currentStatus!==c.SUCCESS?{...e,currentStatus:c.SUCCESS,paymentMethodData:s||e.paymentMethodData}:e;case c.PROCESSING:return e.currentStatus!==c.PROCESSING?{...e,currentStatus:c.PROCESSING,errorMessage:""}:e;case c.COMPLETE:return e.currentStatus!==c.COMPLETE?{...e,currentStatus:c.COMPLETE}:e;case o.SET_REGISTERED_PAYMENT_METHODS:return{...e,paymentMethods:r};case o.SET_REGISTERED_EXPRESS_PAYMENT_METHODS:return{...e,expressPaymentMethods:r};case o.SET_SHOULD_SAVE_PAYMENT_METHOD:return{...e,shouldSavePaymentMethod:n};case o.SET_ACTIVE_PAYMENT_METHOD:return{...e,activePaymentMethod:d,paymentMethodData:s||e.paymentMethodData}}},u=s(1),m=s(17),p=s(32),h=s(2),S=s(50),y=s(23),E=s.n(y),g=s(29),b=s(49),M=s(33),O=s(31),v=s(64);const P=(e,t,s,a)=>{const[c,o]=Object(n.useState)(!1),{isEditor:i}=Object(g.a)(),{selectedRates:d}=Object(v.a)(),{billingAddress:l,shippingAddress:m}=Object(b.b)(),y=Object(p.a)(d),O=Object(p.a)(s),P=Object(M.a)(),{cartTotals:_,cartIsLoading:f,cartNeedsShipping:j,paymentRequirements:R}=P,T=Object(n.useRef)({cart:P,cartTotals:_,cartNeedsShipping:j,billingData:l,billingAddress:l,shippingAddress:m,selectedShippingMethods:y,paymentRequirements:R}),{createErrorNotice:A}=Object(r.useDispatch)("core/notices");Object(n.useEffect)(()=>{T.current={cart:P,cartTotals:_,cartNeedsShipping:j,get billingData(){return E()("billingData",{alternative:"billingAddress",plugin:"woocommerce-gutenberg-products-block",link:"https://github.com/woocommerce/woocommerce-blocks/pull/6369"}),this.billingAddress},billingAddress:l,shippingAddress:m,selectedShippingMethods:y,paymentRequirements:R}},[P,_,j,l,m,y,R]);const D=Object(n.useCallback)(async()=>{let s={};const n=e=>{s={...s,[e.name]:e}};for(let e=0;e{f||C()},[C,P,y,l,f]),c},_=e=>({type:e}),f=e=>({type:c.ERROR,errorMessage:e}),j=e=>{let{errorMessage:t,paymentMethodData:s}=e;return{type:c.FAILED,errorMessage:t,paymentMethodData:s}},R=e=>{let{paymentMethodData:t}=e;return{type:c.SUCCESS,paymentMethodData:t}},T=e=>({type:o.SET_REGISTERED_PAYMENT_METHODS,paymentMethods:e}),A=e=>({type:o.SET_REGISTERED_EXPRESS_PAYMENT_METHODS,paymentMethods:e}),D=e=>({type:o.SET_SHOULD_SAVE_PAYMENT_METHOD,shouldSavePaymentMethod:e}),C=(e,t)=>({type:o.SET_ACTIVE_PAYMENT_METHOD,paymentMethod:e,paymentMethodData:t});var I=s(66),N=s(35),k=s(93),w=s(201);var x=s(203),Y=s(198);const L=Object(n.createContext)(d),F=()=>Object(n.useContext)(L),H=e=>{let{children:t}=e;const{isProcessing:s,isIdle:o,isCalculating:d,hasError:u}=Object(N.b)(),{isEditor:p,getPreviewData:S}=Object(g.a)(),{setValidationErrors:y}=Object(Y.b)(),{createErrorNotice:E,removeNotice:b}=Object(r.useDispatch)("core/notices"),{isSuccessResponse:M,isErrorResponse:v,isFailResponse:F,noticeContexts:H}=Object(O.d)(),[G,U]=Object(n.useReducer)(k.b,{}),{onPaymentProcessing:z}=(e=>Object(n.useMemo)(()=>({onPaymentProcessing:Object(w.a)("payment_processing",e)}),[e]))(U),B=Object(n.useRef)(G);Object(n.useEffect)(()=>{B.current=G},[G]);const[V,X]=Object(n.useReducer)(l,i),{dispatchActions:K,setPaymentStatus:$}=(e=>{const{setBillingAddress:t,setShippingAddress:s}=Object(I.a)();return{dispatchActions:Object(n.useMemo)(()=>({setRegisteredPaymentMethods:t=>{e(T(t))},setRegisteredExpressPaymentMethods:t=>{e(A(t))},setShouldSavePayment:t=>{e(D(t))},setActivePaymentMethod:function(t){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(C(t,s))}}),[e]),setPaymentStatus:Object(n.useCallback)(()=>({pristine:()=>e(_(c.PRISTINE)),started:()=>e(_(c.STARTED)),processing:()=>e(_(c.PROCESSING)),completed:()=>e(_(c.COMPLETE)),error:t=>e(f(t)),failed:function(s,n){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;a&&t(a),e(j({errorMessage:s||"",paymentMethodData:n||{}}))},success:function(n){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;a&&t(a),void 0!==typeof r&&null!=r&&r.address&&s(r.address),e(R({paymentMethodData:n}))}}),[e,t,s])}})(X),q=(e=>{const t=Object(m.getPaymentMethods)(),{noticeContexts:s}=Object(O.d)(),n=new Set([...Object(h.getSetting)("paymentGatewaySortOrder",[]),...Object.keys(t)]);return P(e,t,Array.from(n),s.PAYMENTS)})(K.setRegisteredPaymentMethods),J=(e=>{const t=Object(m.getExpressPaymentMethods)(),{noticeContexts:s}=Object(O.d)();return P(e,t,Object.keys(t),s.EXPRESS_PAYMENTS)})(K.setRegisteredExpressPaymentMethods),W=Object(n.useMemo)(()=>p?S("previewSavedPaymentMethods"):q?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(0===Object.keys(e).length)return{};const t=Object(h.getSetting)("customerPaymentMethods",{}),s=Object.keys(t),n={};return s.forEach(s=>{const a=t[s].filter(t=>{var s;let{method:{gateway:n}}=t;return n in e&&(null===(s=e[n].supports)||void 0===s?void 0:s.showSavedCards)});a.length&&(n[s]=a)}),n}(V.paymentMethods):{},[p,S,q,V.paymentMethods]),Q=Object(n.useCallback)(e=>{e?E(e,{id:"wc-express-payment-error",context:H.EXPRESS_PAYMENTS}):b("wc-express-payment-error",H.EXPRESS_PAYMENTS)},[E,H.EXPRESS_PAYMENTS,b]),Z=Object.keys(V.expressPaymentMethods).includes(V.activePaymentMethod),ee=Object(n.useMemo)(()=>({isPristine:V.currentStatus===c.PRISTINE,isStarted:V.currentStatus===c.STARTED,isProcessing:V.currentStatus===c.PROCESSING,isFinished:[c.ERROR,c.FAILED,c.SUCCESS].includes(V.currentStatus),hasError:V.currentStatus===c.ERROR,hasFailed:V.currentStatus===c.FAILED,isSuccessful:V.currentStatus===c.SUCCESS,isDoingExpressPayment:V.currentStatus!==c.PRISTINE&&Z}),[V.currentStatus,Z]);Object(n.useEffect)(()=>{const e=Object.keys(V.paymentMethods);if(!q||!e.length)return;const t=[...e,...Object.keys(V.expressPaymentMethods)];if(V.activePaymentMethod&&t.includes(V.activePaymentMethod))return;$().pristine();const s=Object.keys(W).flatMap(e=>W[e])[0]||void 0;if(s){const e=s.tokenId.toString(),t=s.method.gateway,n=`wc-${t}-payment-token`;K.setActivePaymentMethod(t,{token:e,payment_method:t,[n]:e,isSavedToken:!0})}else K.setActivePaymentMethod(Object.keys(V.paymentMethods)[0])},[q,V.paymentMethods,V.expressPaymentMethods,K,$,V.activePaymentMethod,W]),Object(n.useEffect)(()=>{!s||u||d||ee.isFinished||$().processing()},[s,u,d,ee.isFinished,$]),Object(n.useEffect)(()=>{o&&!ee.isSuccessful&&$().pristine()},[o,ee.isSuccessful,$]),Object(n.useEffect)(()=>{u&&ee.isSuccessful&&$().pristine()},[u,ee.isSuccessful,$]),Object(n.useEffect)(()=>{ee.isProcessing&&(b("wc-payment-error",H.PAYMENTS),Object(x.b)(B.current,"payment_processing",{}).then(e=>{let t,s;var n,a,r,c,o,i;if(e.forEach(e=>{M(e)&&(t=e),(v(e)||F(e))&&(s=e)}),t&&!s)$().success(null===(n=t)||void 0===n||null===(a=n.meta)||void 0===a?void 0:a.paymentMethodData,null===(r=t)||void 0===r||null===(c=r.meta)||void 0===c?void 0:c.billingAddress,null===(o=t)||void 0===o||null===(i=o.meta)||void 0===i?void 0:i.shippingData);else if(s&&F(s)){var d,l,u,m,p,h;s.message&&s.message.length&&E(s.message,{id:"wc-payment-error",isDismissible:!1,context:(null===(h=s)||void 0===h?void 0:h.messageContext)||H.PAYMENTS}),$().failed(null===(d=s)||void 0===d?void 0:d.message,null===(l=s)||void 0===l||null===(u=l.meta)||void 0===u?void 0:u.paymentMethodData,null===(m=s)||void 0===m||null===(p=m.meta)||void 0===p?void 0:p.billingAddress)}else if(s){var S,g;s.message&&s.message.length&&E(s.message,{id:"wc-payment-error",isDismissible:!1,context:(null===(g=s)||void 0===g?void 0:g.messageContext)||H.PAYMENTS}),$().error(s.message),y(null===(S=s)||void 0===S?void 0:S.validationErrors)}else $().success()}))},[ee.isProcessing,y,$,b,H.PAYMENTS,M,F,v,E]);const te="object"==typeof V.paymentMethodData&&Object(a.b)(V.paymentMethodData,"token")?V.paymentMethodData.token+"":"",se={setPaymentStatus:$,currentStatus:ee,paymentStatuses:c,paymentMethodData:V.paymentMethodData,errorMessage:V.errorMessage,activePaymentMethod:V.activePaymentMethod,activeSavedToken:te,setActivePaymentMethod:K.setActivePaymentMethod,onPaymentProcessing:z,customerPaymentMethods:W,paymentMethods:V.paymentMethods,expressPaymentMethods:V.expressPaymentMethods,paymentMethodsInitialized:q,expressPaymentMethodsInitialized:J,setExpressPaymentError:Q,isExpressPaymentMethodActive:Z,shouldSavePayment:V.shouldSavePaymentMethod,setShouldSavePayment:K.setShouldSavePayment};return Object(n.createElement)(L.Provider,{value:se},t)}},263:function(e,t,s){"use strict";var n=s(12),a=s.n(n),r=s(0),c=s(43),o=s(5),i=s.n(o),d=s(136);s(264),t.a=e=>{let{className:t,showSpinner:s=!1,children:n,variant:o="contained",...l}=e;const u=i()("wc-block-components-button",t,o,{"wc-block-components-button--loading":s});return Object(r.createElement)(c.a,a()({className:u},l),s&&Object(r.createElement)(d.a,null),Object(r.createElement)("span",{className:"wc-block-components-button__text"},n))}},264:function(e,t){},271:function(e,t){},274:function(e,t,s){"use strict";s.d(t,"b",(function(){return c})),s.d(t,"a",(function(){return o}));var n=s(32),a=s(205);const r=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{paymentMethods:t,expressPaymentMethods:s,paymentMethodsInitialized:r,expressPaymentMethodsInitialized:c}=Object(a.b)(),o=Object(n.a)(t),i=Object(n.a)(s);return{paymentMethods:e?i:o,isInitialized:e?c:r}},c=()=>r(!1),o=()=>r(!0)},277:function(e,t,s){"use strict";var n=s(12),a=s.n(n),r=s(0),c=s(5),o=s.n(c);const i=e=>"wc-block-components-payment-method-icon wc-block-components-payment-method-icon--"+e;var d=e=>{let{id:t,src:s=null,alt:n=""}=e;return s?Object(r.createElement)("img",{className:i(t),src:s,alt:n}):null},l=s(46);const u=[{id:"alipay",alt:"Alipay",src:l.l+"payment-methods/alipay.svg"},{id:"amex",alt:"American Express",src:l.l+"payment-methods/amex.svg"},{id:"bancontact",alt:"Bancontact",src:l.l+"payment-methods/bancontact.svg"},{id:"diners",alt:"Diners Club",src:l.l+"payment-methods/diners.svg"},{id:"discover",alt:"Discover",src:l.l+"payment-methods/discover.svg"},{id:"eps",alt:"EPS",src:l.l+"payment-methods/eps.svg"},{id:"giropay",alt:"Giropay",src:l.l+"payment-methods/giropay.svg"},{id:"ideal",alt:"iDeal",src:l.l+"payment-methods/ideal.svg"},{id:"jcb",alt:"JCB",src:l.l+"payment-methods/jcb.svg"},{id:"laser",alt:"Laser",src:l.l+"payment-methods/laser.svg"},{id:"maestro",alt:"Maestro",src:l.l+"payment-methods/maestro.svg"},{id:"mastercard",alt:"Mastercard",src:l.l+"payment-methods/mastercard.svg"},{id:"multibanco",alt:"Multibanco",src:l.l+"payment-methods/multibanco.svg"},{id:"p24",alt:"Przelewy24",src:l.l+"payment-methods/p24.svg"},{id:"sepa",alt:"Sepa",src:l.l+"payment-methods/sepa.svg"},{id:"sofort",alt:"Sofort",src:l.l+"payment-methods/sofort.svg"},{id:"unionpay",alt:"Union Pay",src:l.l+"payment-methods/unionpay.svg"},{id:"visa",alt:"Visa",src:l.l+"payment-methods/visa.svg"},{id:"wechat",alt:"WeChat",src:l.l+"payment-methods/wechat.svg"}];var m=s(52);s(271),t.a=e=>{let{icons:t=[],align:s="center",className:n}=e;const c=(e=>{const t={};return e.forEach(e=>{let s={};"string"==typeof e&&(s={id:e,alt:e,src:null}),"object"==typeof e&&(s={id:e.id||"",alt:e.alt||"",src:e.src||null}),s.id&&Object(m.a)(s.id)&&!t[s.id]&&(t[s.id]=s)}),Object.values(t)})(t);if(0===c.length)return null;const i=o()("wc-block-components-payment-method-icons",{"wc-block-components-payment-method-icons--align-left":"left"===s,"wc-block-components-payment-method-icons--align-right":"right"===s},n);return Object(r.createElement)("div",{className:i},c.map(e=>{const t={...e,...(s=e.id,u.find(e=>e.id===s)||{})};var s;return Object(r.createElement)(d,a()({key:"payment-method-icon-"+e.id},t))}))}},32:function(e,t,s){"use strict";s.d(t,"a",(function(){return c}));var n=s(0),a=s(13),r=s.n(a);function c(e){const t=Object(n.useRef)(e);return r()(e,t.current)||(t.current=e),t.current}},377:function(e,t,s){"use strict";s.d(t,"a",(function(){return n}));const n=e=>Object.values(e).reduce((e,t)=>(null!==t.icons&&(e=e.concat(t.icons)),e),[])},429:function(e,t,s){"use strict";s.r(t);var n=s(0),a=s(1),r=s(10),c=s(41),o=s(274),i=s(33),d=s(277),l=s(377),u=s(2),m=s(46),p=s(263),h=s(205),S=s(5),y=s.n(S);const E=()=>{const{paymentMethods:e}=Object(o.b)();return Object(n.createElement)(d.a,{icons:Object(l.a)(e)})};t.default=e=>{let{className:t}=e;const{cartTotals:s}=Object(i.a)(),o=Object(u.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(s.total_items,10)+parseInt(s.total_items_tax,10):parseInt(s.total_items,10);return Object(n.createElement)("div",{className:y()(t,"wc-block-mini-cart__footer")},Object(n.createElement)(r.TotalsItem,{className:"wc-block-mini-cart__footer-subtotal",currency:Object(c.getCurrencyFromPriceResponse)(s),label:Object(a.__)("Subtotal","woocommerce"),value:o,description:Object(a.__)("Shipping, taxes, and discounts calculated at checkout.","woocommerce")}),Object(n.createElement)("div",{className:"wc-block-mini-cart__footer-actions"},m.c&&Object(n.createElement)(p.a,{className:"wc-block-mini-cart__footer-cart",href:m.c,variant:"outlined"},Object(a.__)("View my cart","woocommerce")),m.d&&Object(n.createElement)(p.a,{className:"wc-block-mini-cart__footer-checkout",href:m.d},Object(a.__)("Go to checkout","woocommerce"))),Object(n.createElement)(h.a,null,Object(n.createElement)(E,null)))}},49:function(e,t,s){"use strict";s.d(t,"b",(function(){return c})),s.d(t,"a",(function(){return o}));var n=s(0),a=s(66);const r=Object(n.createContext)({isInitialized:!1,billingAddress:{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",email:"",phone:""},shippingAddress:{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},setBillingAddress:()=>{},setShippingAddress:()=>{}}),c=()=>Object(n.useContext)(r),o=e=>{let{children:t}=e;const s=Object(a.a)();return Object(n.createElement)(r.Provider,{value:s},t)}},64:function(e,t,s){"use strict";s.d(t,"a",(function(){return l}));var n=s(6),a=s(8),r=s(0),c=s(13),o=s.n(c),i=s(20),d=s(68);const l=()=>{const{shippingRates:e,needsShipping:t,hasCalculatedShipping:s,isLoadingRates:c}=Object(a.useSelect)(e=>{const t=e(n.CART_STORE_KEY);return{shippingRates:t.getShippingRates(),needsShipping:t.getNeedsShipping(),hasCalculatedShipping:t.getHasCalculatedShipping(),isLoadingRates:t.isCustomerDataUpdating()}}),{isSelectingRate:l,selectShippingRate:u}=Object(d.a)(),m=Object(r.useRef)({});return Object(r.useEffect)(()=>{const t=(e=>Object.fromEntries(e.map(e=>{var t;let{package_id:s,shipping_rates:n}=e;return[s,null===(t=n.find(e=>e.selected))||void 0===t?void 0:t.rate_id]})))(e);Object(i.a)(t)&&!o()(m.current,t)&&(m.current=t)},[e]),{isSelectingRate:l,selectedRates:m.current,selectShippingRate:u,shippingRates:e,needsShipping:t,hasCalculatedShipping:s,isLoadingRates:c}}},66:function(e,t,s){"use strict";s.d(t,"a",(function(){return r}));var n=s(8),a=s(6);const r=()=>{const{customerData:e,isInitialized:t}=Object(n.useSelect)(e=>{const t=e(a.CART_STORE_KEY);return{customerData:t.getCustomerData(),isInitialized:t.hasFinishedResolution("getCartData")}}),{setShippingAddress:s,setBillingAddress:r}=Object(n.useDispatch)(a.CART_STORE_KEY);return{isInitialized:t,billingAddress:e.billingAddress,shippingAddress:e.shippingAddress,setBillingAddress:r,setShippingAddress:s}}},68:function(e,t,s){"use strict";s.d(t,"a",(function(){return i}));var n=s(8),a=s(0),r=s(6),c=s(74),o=s(58);const i=()=>{const e=Object(c.a)(),{dispatchCheckoutEvent:t}=Object(o.a)(),{selectShippingRate:s}=Object(n.useDispatch)(r.CART_STORE_KEY);return{selectShippingRate:Object(a.useCallback)((n,a)=>{s(n,a).then(()=>{t("set-selected-shipping-rate",{shippingRateId:n})}).catch(t=>{e(t)})},[s,t,e]),isSelectingRate:Object(n.useSelect)(e=>e(r.CART_STORE_KEY).isShippingRateBeingSelected(),[])}}},74:function(e,t,s){"use strict";s.d(t,"a",(function(){return a}));var n=s(0);const a=()=>{const[,e]=Object(n.useState)();return Object(n.useCallback)(t=>{e(()=>{throw t})},[])}}}]);