(()=>{"use strict";const e=window.wp.element,t=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"pplcz/parcel-shop-summary-block","version":"1.0.0","title":"Selection block","category":"woocommerce","parent":["woocommerce/checkout-order-summary-block","woocommerce/cart-order-summary-block"],"attributes":{"lock":{"type":"object","default":{"remove":true,"move":false}}},"textdomain":"checkout-block-example","editorScript":"file:./build/index.js"}'),c=window.wc.blocksCheckout,a=window.wp.data,o=window.wp.i18n,n=e=>e.shipping_rates.find((e=>e.rate_id.indexOf("pplcz_")>-1&&e.selected)),l=(e,t)=>n(e)?.meta_data?.find((e=>e.key===t))?.value,r=({parcelShop:t})=>t?(0,e.createElement)("small",null,(0,e.createElement)("strong",null,(0,o.__)("Výdejní místo","ppl-cz")),(0,e.createElement)("br",null),(0,e.createElement)("span",null,t.name)," ",(0,e.createElement)("a",{href:"#",onClick:e=>{e.preventDefault(),PplMap((()=>{}),{lat:t?.gps?.latitude,lng:t?.gps?.longitude})}},"[",(0,o.__)("na mapě","ppl-cz"),"]"),(0,e.createElement)("br",null),(0,e.createElement)("span",null,t.street),(0,e.createElement)("br",null),(0,e.createElement)("span",null,t.zipCode," ",t.city),(0,e.createElement)("br",null)):null,s=({cart:t,payment:c})=>{const a=t.shippingRates[0],o=a&&(e=>!!parseInt(l(e,"mapEnabled")))(a)?n(a):void 0,s=(e=>!!parseInt(l(e,"parcelRequired")))(a),p=(e=>e.extensions?.pplcz_parcelshop?.parcelData)(t);return(0,e.useEffect)((()=>{if(!a)return;const e="wc-block-components-shipping-address-hide-send-address";return o&&s&&p?document.body.classList.add(e):document.body.classList.remove(e),()=>{document.body.classList.remove(e)}}),[o?.rate_id,s,p]),a&&o&&s&&p?(0,e.createElement)("div",{className:"wp-block-woocommerce-checkout-order-summary-shipping-block wc-block-components-totals-wrapper"},(0,e.createElement)("div",{className:"wc-block-components-totals-item"},(0,e.createElement)(r,{parcelShop:p}))):null},p={metadata:t,component:()=>{const{cart:t,payment:c}=(0,a.useSelect)((e=>({cart:e("wc/store/cart").getCartData(),payment:e("wc/store/payment").getActivePaymentMethod()})));return t&&c&&t.shippingRates?.length?(0,e.createElement)(s,{cart:t,payment:c}):null}};(0,c.registerCheckoutBlock)(p),wp.hooks.addAction("experimental__woocommerce_blocks-checkout-render-checkout-form","parcel-shop-summary-block",(()=>{const e=wp.data.select("wc/store/payment").getActivePaymentMethod();window.wc.blocksCheckout.extensionCartUpdate({namespace:"pplcz_refresh_payment",data:{payment_method:e}})})),wp.hooks.addAction("experimental__woocommerce_blocks-checkout-set-active-payment-method","parcel-shop-summary-block",(e=>{window.wc.blocksCheckout.extensionCartUpdate({namespace:"pplcz_refresh_payment",data:{payment_method:e.value||e.paymentMethodSlug}})}))})();