(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[44],{146:function(e,t,n){"use strict";var o=n(0);n(215),t.a=()=>Object(o.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},147:function(e,t,n){"use strict";var o=n(0),c=n(1),a=n(4),r=n.n(a),l=(n(218),n(146));t.a=e=>{let{children:t,className:n,screenReaderLabel:a,showSpinner:s=!1,isLoading:i=!0}=e;return Object(o.createElement)("div",{className:r()(n,{"wc-block-components-loading-mask":i})},i&&s&&Object(o.createElement)(l.a,null),Object(o.createElement)("div",{className:r()({"wc-block-components-loading-mask__children":i}),"aria-hidden":i},t),i&&Object(o.createElement)("span",{className:"screen-reader-text"},a||Object(c.__)("Loading…","woocommerce")))}},19:function(e,t,n){"use strict";var o=n(0),c=n(4),a=n.n(c);t.a=e=>{let t,{label:n,screenReaderLabel:c,wrapperElement:r,wrapperProps:l={}}=e;const s=null!=n,i=null!=c;return!s&&i?(t=r||"span",l={...l,className:a()(l.className,"screen-reader-text")},Object(o.createElement)(t,l,c)):(t=r||o.Fragment,s&&i&&n!==c?Object(o.createElement)(t,l,Object(o.createElement)("span",{"aria-hidden":"true"},n),Object(o.createElement)("span",{className:"screen-reader-text"},c)):Object(o.createElement)(t,l,n))}},215:function(e,t){},218:function(e,t){},291:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var o=n(0),c=n(6),a=n(3);n(293);const r=e=>{let{errorMessage:t="",propertyName:n="",elementId:r=""}=e;const{validationError:l,validationErrorId:s}=Object(c.useSelect)(e=>{const t=e(a.VALIDATION_STORE_KEY);return{validationError:t.getValidationError(n),validationErrorId:t.getValidationErrorId(r)}});if(!t||"string"!=typeof t){if(null==l||!l.message||null!=l&&l.hidden)return null;t=l.message}return Object(o.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(o.createElement)("p",{id:s},t))};t.b=r},293:function(e,t){},294:function(e,t){},295:function(e,t,n){"use strict";var o=n(12),c=n.n(o),a=n(0),r=n(44),l=n(4),s=n.n(l),i=n(146);n(296),t.a=e=>{let{className:t,showSpinner:n=!1,children:o,variant:l="contained",...u}=e;const p=s()("wc-block-components-button",t,l,{"wc-block-components-button--loading":n});return Object(a.createElement)(r.a,c()({className:p},u),n&&Object(a.createElement)(i.a,null),Object(a.createElement)("span",{className:"wc-block-components-button__text"},o))}},296:function(e,t){},311:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var o=n(1),c=n(6),a=n(3),r=n(23),l=n(38);const s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{cartCoupons:t,cartIsLoading:n}=Object(l.a)(),{createErrorNotice:s}=Object(c.useDispatch)("core/notices"),{createNotice:i}=Object(c.useDispatch)("core/notices"),{setValidationErrors:u}=Object(c.useDispatch)(a.VALIDATION_STORE_KEY),{applyCoupon:p,removeCoupon:d,isApplyingCoupon:b,isRemovingCoupon:m}=Object(c.useSelect)((e,t)=>{let{dispatch:n}=t;const o=e(a.CART_STORE_KEY),c=n(a.CART_STORE_KEY);return{applyCoupon:c.applyCoupon,removeCoupon:c.removeCoupon,isApplyingCoupon:o.isApplyingCoupon(),isRemovingCoupon:o.isRemovingCoupon(),receiveApplyingCoupon:c.receiveApplyingCoupon}},[s,i]),O=t=>{p(t).then(n=>{!0===n&&i("info",Object(o.sprintf)(
/* translators: %s coupon code. */
Object(o.__)('Coupon code "%s" has been applied to your cart.',"woocommerce"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(e=>{u({coupon:{message:Object(r.decodeEntities)(e.message),hidden:!1}}),receiveApplyingCoupon("")})},E=t=>{d(t).then(n=>{!0===n&&i("info",Object(o.sprintf)(
/* translators: %s coupon code. */
Object(o.__)('Coupon code "%s" has been removed from your cart.',"woocommerce"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(t=>{s(t.message,{id:"coupon-form",context:e}),receiveApplyingCoupon("")})};return{appliedCoupons:t,isLoading:n,applyCoupon:O,removeCoupon:E,isApplyingCoupon:b,isRemovingCoupon:m}}},333:function(e,t,n){"use strict";var o=n(12),c=n.n(o),a=n(0),r=n(1),l=n(8),s=n(4),i=n.n(s),u=n(11),p=n(30),d=n(6),b=n(3),m=n(19);n(294);var O=Object(l.forwardRef)((e,t)=>{let{className:n,id:o,type:r="text",ariaLabel:l,ariaDescribedBy:s,label:u,screenReaderLabel:p,disabled:d,help:b,autoCapitalize:O="off",autoComplete:E="off",value:g="",onChange:v,required:j=!1,onBlur:f=(()=>{}),feedback:_,...h}=e;const[w,C]=Object(a.useState)(!1);return Object(a.createElement)("div",{className:i()("wc-block-components-text-input",n,{"is-active":w||g})},Object(a.createElement)("input",c()({type:r,id:o,value:g,ref:t,autoCapitalize:O,autoComplete:E,onChange:e=>{v(e.target.value)},onFocus:()=>C(!0),onBlur:e=>{f(e.target.value),C(!1)},"aria-label":l||u,disabled:d,"aria-describedby":b&&!s?o+"__help":s,required:j},h)),Object(a.createElement)(m.a,{label:u,screenReaderLabel:p||u,wrapperElement:"label",wrapperProps:{htmlFor:o},htmlFor:o}),!!b&&Object(a.createElement)("p",{id:o+"__help",className:"wc-block-components-text-input__help"},b),_)}),E=n(291);t.a=Object(u.withInstanceId)(e=>{let{className:t,instanceId:n,id:o,ariaDescribedBy:s,errorId:u,focusOnMount:m=!1,onChange:g,showError:v=!0,errorMessage:j="",value:f="",..._}=e;const[h,w]=Object(l.useState)(!0),C=Object(l.useRef)(null),{setValidationErrors:k,hideValidationError:y,clearValidationError:N}=Object(d.dispatch)(b.VALIDATION_STORE_KEY),I=void 0!==o?o:"textinput-"+n,A=void 0!==u?u:I,{validationError:R,validationErrorId:S}=Object(d.useSelect)(e=>{const t=e(b.VALIDATION_STORE_KEY);return{validationError:t.getValidationError(A),validationErrorId:t.getValidationErrorId(A)}}),L=Object(l.useCallback)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=C.current||null;if(!t)return;t.value=t.value.trim();const n=t.checkValidity();if(n)N(A);else{const n={[A]:{message:t.validationMessage||Object(r.__)("Invalid value.","woocommerce"),hidden:e}};k(n)}}),[N,A,k]);Object(l.useEffect)(()=>{var e;h&&m&&(null===(e=C.current)||void 0===e||e.focus()),w(!1)},[m,h,w]),Object(l.useEffect)(()=>{var e,t;(null===(e=C.current)||void 0===e||null===(t=e.ownerDocument)||void 0===t?void 0:t.activeElement)!==C.current&&L(!0)},[f,L]),Object(l.useEffect)(()=>()=>{N(A)},[N,A]),Object(p.a)(j)&&""!==j&&(R.message=j);const V=(null==R?void 0:R.message)&&!(null!=R&&R.hidden),T=v&&V&&S?S:s;return Object(a.createElement)(O,c()({className:i()(t,{"has-error":V}),"aria-invalid":!0===V,id:I,onBlur:()=>{L(!1)},feedback:v&&Object(a.createElement)(E.a,{errorMessage:j,propertyName:A}),ref:C,onChange:e=>{y(A),g(e)},ariaDescribedBy:T,value:f},_))})},355:function(e,t){},417:function(e,t,n){"use strict";var o=n(0),c=n(1),a=n(295),r=n(10),l=n(19),s=n(147),i=n(11),u=n(333),p=n(291),d=n(6),b=n(3);n(355),t.a=Object(i.withInstanceId)(e=>{let{instanceId:t,isLoading:n=!1,initialOpen:i=!1,onSubmit:m=(()=>{})}=e;const[O,E]=Object(o.useState)(""),g=Object(o.useRef)(!1),v="wc-block-components-totals-coupon__input-"+t,{validationError:j,validationErrorId:f}=Object(d.useSelect)(e=>{const t=e(b.VALIDATION_STORE_KEY);return{validationError:t.getValidationError("coupon"),validationErrorId:t.getValidationErrorId(v)}});return Object(o.useEffect)(()=>{g.current!==n&&(n||!O||j||E(""),g.current=n)},[n,O,j]),Object(o.createElement)(r.Panel,{className:"wc-block-components-totals-coupon",hasBorder:!1,initialOpen:i,title:Object(o.createElement)(l.a,{label:Object(c.__)("Coupon code","woocommerce"),screenReaderLabel:Object(c.__)("Apply a coupon code","woocommerce"),htmlFor:v})},Object(o.createElement)(s.a,{screenReaderLabel:Object(c.__)("Applying coupon…","woocommerce"),isLoading:n,showSpinner:!1},Object(o.createElement)("div",{className:"wc-block-components-totals-coupon__content"},Object(o.createElement)("form",{className:"wc-block-components-totals-coupon__form"},Object(o.createElement)(u.a,{id:v,errorId:"coupon",className:"wc-block-components-totals-coupon__input",label:Object(c.__)("Enter code","woocommerce"),value:O,ariaDescribedBy:f,onChange:e=>{E(e)},focusOnMount:!0,showError:!1}),Object(o.createElement)(a.a,{className:"wc-block-components-totals-coupon__button",disabled:n||!O,showSpinner:n,onClick:e=>{e.preventDefault(),m(O)},type:"submit"},Object(c.__)("Apply","woocommerce"))),Object(o.createElement)(p.b,{propertyName:"coupon",elementId:v}))))})},500:function(e,t,n){"use strict";n.r(t);var o=n(0),c=n(417),a=n(311),r=n(2),l=n(10);t.default=e=>{let{className:t=""}=e;const n=Object(r.getSetting)("couponsEnabled",!0),{applyCoupon:s,isApplyingCoupon:i}=Object(a.a)("wc/checkout");return n?Object(o.createElement)(l.TotalsWrapper,{className:t},Object(o.createElement)(c.a,{onSubmit:s,isLoading:i})):null}}}]);