"use strict";(self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[]).push([[7413],{9490:(e,t,o)=>{o.d(t,{Z:()=>c});var i=o(5736);const c=({defaultTitle:e=(0,i.__)("Step","woocommerce"),defaultDescription:t=(0,i.__)("Step description text.","woocommerce"),defaultShowStepNumber:o=!0})=>({title:{type:"string",default:e},description:{type:"string",default:t},showStepNumber:{type:"boolean",default:o}})},8191:(e,t,o)=>{o.r(t),o.d(t,{default:()=>V});var i=o(9196),c=o(4184),n=o.n(c),s=o(721),r=o(711),p=o(9818),a=o(4801),l=o(5027),d=o(5271),h=o(5736),u=o(1789),g=o(8557),m=o(1984),_=o(1526),k=o(6520),w=o(9307),b=o(602),E=o(4617),v=o(4293);const f=({minRate:e,maxRate:t,multiple:o=!1})=>{if(void 0===e||void 0===t)return null;const c=(0,E.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(e.price,10)+parseInt(e.taxes,10):parseInt(e.price,10),n=(0,E.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(t.price,10)+parseInt(t.taxes,10):parseInt(t.price,10),s=0===c?(0,i.createElement)("em",null,(0,h.__)("free","woocommerce")):(0,i.createElement)(r.FormattedMonetaryAmount,{currency:(0,v.getCurrencyFromPriceResponse)(e),value:c});return(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},c!==n||o?(0,w.createInterpolateElement)(0===c&&0===n?"":(0,h.__)("from ","woocommerce"),{price:s}):s)};function x(e){return e?{min:e.reduce(((e,t)=>(0,b.Ep)(t.method_id)?e:void 0===e||parseInt(t.price,10)(0,b.Ep)(t.method_id)?e:void 0===e||parseInt(t.price,10)>parseInt(e.price,10)?t:e),void 0)}:{min:void 0,max:void 0}}function I(e){return e?{min:e.reduce(((e,t)=>(0,b.Ep)(t.method_id)&&(void 0===e||t.price(0,b.Ep)(t.method_id)&&(void 0===e||t.price>e.price)?t:e),void 0)}:{min:void 0,max:void 0}}const S=(0,h.__)("Local Pickup","woocommerce"),T=(0,h.__)("Shipping","woocommerce");o(6483);const C={hidden:!0,message:(0,h.__)("Shipping options are not available","woocommerce")},P=({checked:e,rate:t,showPrice:o,showIcon:c,toggleText:s,multiple:r})=>(0,i.createElement)(u.Z,{value:"pickup",className:n()("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===c&&(0,i.createElement)(m.Z,{icon:_.Z,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},s),!0===o&&(0,i.createElement)(f,{multiple:r,minRate:t.min,maxRate:t.max})),y=({checked:e,rate:t,showPrice:o,showIcon:c,toggleText:s,shippingCostRequiresAddress:r=!1})=>{const l=(0,p.useSelect)((e=>e(a.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(b.J3))))),d=r&&(()=>{const e=(0,p.select)("wc/store/validation"),t=e.getValidationError("shipping_state"),o=e.getValidationError("shipping_address_1"),i=e.getValidationError("shipping_country"),c=e.getValidationError("shipping_postcode");return[e.getValidationError("shipping_city"),t,o,i,c].some((e=>void 0!==e))})()&&!l,g=void 0!==t.min&&void 0!==t.max,{setValidationErrors:_,clearValidationError:E}=(0,p.useDispatch)(a.VALIDATION_STORE_KEY);(0,w.useEffect)((()=>{"shipping"!==e||g?E("shipping-rates-error"):_({"shipping-rates-error":C})}),[e,E,g,_]);const v=void 0===t.min||d?(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,h.__)("calculated with an address","woocommerce")):(0,i.createElement)(f,{minRate:t.min,maxRate:t.max});return(0,i.createElement)(u.Z,{value:"shipping",className:n()("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"shipping"===e})},!0===c&&(0,i.createElement)(m.Z,{icon:k.Z,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},s),!0===o&&v)},R=({checked:e,onChange:t,showPrice:o,showIcon:c,localPickupText:n,shippingText:s})=>{var r,p;const{shippingRates:a}=(0,l.V)(),d=(0,E.getSetting)("shippingCostRequiresAddress",!1);return(0,i.createElement)(g.Z,{id:"shipping-method",className:"wc-block-checkout__shipping-method-container",label:"options",onChange:t,checked:e},(0,i.createElement)(y,{checked:e,rate:x(null===(r=a[0])||void 0===r?void 0:r.shipping_rates),showPrice:o,showIcon:c,shippingCostRequiresAddress:d,toggleText:s||T}),(0,i.createElement)(P,{checked:e,rate:I(null===(p=a[0])||void 0===p?void 0:p.shipping_rates),multiple:a.length>1,showPrice:o,showIcon:c,toggleText:n||S}))},N={...(0,o(9490).Z)({defaultTitle:(0,h.__)("Shipping method","woocommerce"),defaultDescription:(0,h.__)("Select how you would like to receive your order.","woocommerce")}),className:{type:"string",default:""},showIcon:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},localPickupText:{type:"string",default:S},shippingText:{type:"string",default:T},lock:{type:"object",default:{move:!0,remove:!0}}},V=(0,s.withFilteredAttributes)(N)((({title:e,description:t,showStepNumber:o,children:c,className:s,showPrice:h,showIcon:u,shippingText:g,localPickupText:m})=>{const{checkoutIsProcessing:_,prefersCollection:k}=(0,p.useSelect)((e=>{const t=e(a.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:t.isProcessing(),prefersCollection:t.prefersCollection()}})),{setPrefersCollection:w}=(0,p.useDispatch)(a.CHECKOUT_STORE_KEY),{shippingRates:b,needsShipping:E,hasCalculatedShipping:v,isCollectable:f}=(0,l.V)();return E&&v&&b&&f&&d.oC?(0,i.createElement)(r.FormStep,{id:"shipping-method",disabled:_,className:n()("wc-block-checkout__shipping-method",s),title:e,description:t,showStepNumber:o},(0,i.createElement)(R,{checked:k?"pickup":"shipping",onChange:e=>{w("pickup"===e)},showPrice:h,showIcon:u,localPickupText:m,shippingText:g}),c):null}))}}]);