!function(){"use strict";var e=window.wp.plugins,t=window.wp.element,o=window.wp.data;(0,e.registerPlugin)("paysera-cart-shipping-rates-validation",{render:()=>{const e="paysera-delivery-error",n="weight_error_message",{CART_STORE_KEY:a,VALIDATION_STORE_KEY:c}=window.wc.wcBlocksData,{selectShippingRate:r}=(0,o.useDispatch)(a),{setValidationErrors:i,clearValidationErrors:l}=(0,o.useDispatch)(c),s=(0,o.useSelect)((e=>e(a).getShippingRates()),[]),p=[],d=[];s.forEach((e=>{e.shipping_rates.filter((e=>{e.meta_data.length&&e.meta_data[0].key===n?p.push(e):d.push(e)}))}));const u=0!==d.length;(0,t.useEffect)((()=>{if(p.length>0){const e=requestAnimationFrame((()=>{h()}));return()=>{cancelAnimationFrame(e),l("shipping-option")}}}),[u,p.length]);const h=()=>{const e=document.querySelectorAll(".wc-block-components-shipping-rates-control__package label.wc-block-components-radio-control__option, .wc-block-components-shipping-rates-control__package .wc-block-components-radio-control__option-layout");e.forEach((t=>{p.forEach((o=>{if(g(t,o)||1===e.length){const e=t.querySelector("input");null!==e&&(e.setAttribute("disabled","disabled"),e.checked=!1),_(t)||o.meta_data.forEach((e=>{m(e)&&t?.querySelector(".wc-block-components-radio-control__label")?.append(E(e.value))}))}}))})),w()},g=(e,t)=>!0===e?.getAttribute("for")?.includes(t.rate_id),_=t=>0!==t?.querySelectorAll("."+e).length,m=e=>e.key===n,w=()=>{let e=p.find((e=>!0===e.selected));void 0!==e&&(e.selected=!1,r(d[0]?.rate_id))},E=t=>{let o=document.createElement("div");return o.textContent=t,o.classList.add(e),o};return(0,t.createElement)("span",null)},scope:"woocommerce-checkout"})}();