System.register(["./sanitize-legacy.f0efe7e6.js"],function(e,t){"use strict";var c,o,n,a,r,s,i;return{setters:[e=>{c=e.c,o=e.s,n=e.u,a=e.d,r=e.W,s=e.V,i=e.b}],execute:function(){e({a:function(){const{registerPlugin:e}=wp.plugins;e("acfw-coupons-summary",{render:_,scope:"woocommerce-checkout"})},i:function(){acfwfObj.components=m,acfwfObj.wc=f,acfwfObj.utils=l},r:function(){const{registerPlugin:e}=wp.plugins;e("acfwf-notices",{render:v,scope:"woocommerce-checkout"})}});const t=e("A","acfw_bogo"),l={debounce:(e,t)=>{let c;return function(...o){clearTimeout(c),c=setTimeout(()=>e(...o),t)}},hasBOGOCoupon:()=>!!c.getCartData().coupons.filter(e=>e.discount_type===t).length,sanitizeHtml:o},u=e=>{const{label:t,value:c,children:n}=e;return React.createElement("div",{className:"wp-block-woocommerce-checkout-order-summary-subtotal-block wc-block-components-totals-wrapper"},React.createElement("div",{className:"wc-block-components-totals-item"},React.createElement("span",{className:"wc-block-components-totals-item__label"},t),React.createElement("span",{className:"wc-block-components-totals-item__value"},React.createElement("div",{dangerouslySetInnerHTML:{__html:o(c)}})),React.createElement("div",{className:"wc-block-components-totals-item__description"},n)))},m={Accordion:e=>{const{useState:t,useEffect:c,useRef:o}=wp.element,{title:n,children:a,caret_img_src:r,auto_display_store_credits_redeem_form:s}=e,[i,l]=t(!1),u=o(null),m=()=>{if(l(!i),u.current){let e=u.current.style.maxHeight;e=parseInt(e.replace("px","")),e=e>0?0:u.current.scrollHeight,u.current.style.maxHeight=`${e}px`}};return c(()=>{"yes"===s&&(l(!0),m())},[s]),React.createElement("div",{className:"acfw-accordion"},React.createElement("div",{className:"acfw-accordion acfw-store-credits-checkout-ui "+(i?"show":"")},React.createElement("h3",{onClick:m},React.createElement("span",{className:"acfw-accordion-title"},n),(()=>{if(r)return React.createElement("span",{className:"caret"},React.createElement("img",{src:r}))})()),React.createElement("div",{className:"acfw-accordion-inner",ref:u},React.createElement("div",{className:"acfw-accordion-content"},a))))},OrderSummarySubtotalBlock:u},{extensionCartUpdate:d}=wc.blocksCheckout,f={dummyUpdateCart:()=>d({namespace:"acfwf_dummy_update",data:{}})},_=()=>{const e=n(e=>{var t;const c=e("wc/store/cart").getCartData(),{acfwf_block:o}=c.extensions;return o&&o.couponSummaries&&null!==(t=o.couponSummaries)&&void 0!==t?t:[]}),{ExperimentalDiscountsMeta:t}=wc.blocksCheckout;return e.length?React.createElement(t,null,e.map(e=>React.createElement(u,{label:e.coupon_code},React.createElement("div",{className:"acfwf-bogo-discount-summary-block",dangerouslySetInnerHTML:{__html:o(e.content)}})))):null},p="wc/checkout",w="wc/cart",g="core/notices",C={ACFWF_NOTICE_BOGO:"ACFWF_NOTICE_BOGO",ACFWF_NOTICE_CART_CONDITIONS:"ACFWF_NOTICE_CART_CONDITIONS",ACFWF_NOTICE_STORE_CREDIT:"ACFWF_NOTICE_STORE_CREDIT"},E=e=>{let t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText},b=e("c",{integration:"acfwf-wc-checkout-block"}),{wcSettings:h}=wc,O=e("g",e=>h.getSetting(`${e}_data`)),N=jQuery,k=()=>{const e=N(".acfw-checkout-ui-block"),t=e.find(".acfw-store-credits-checkout-ui"),c=e.find("h3");t.hasClass("show")||c.trigger("click"),setTimeout(function(){var t;window.scroll({top:null==e||null===(t=e.offset())||void 0===t?void 0:t.top,behavior:"smooth"}),e.find("input").trigger("focus")},400)};function T(){const e=n(e=>e(r).getHasCalculatedShipping()),{store_credits:t}=O(b.integration);if(!t)return null;const{apply_type:o,notice_store_credits_text:s}=t,{acfwf_block:i}=c.getCartData().extensions;"coupon"!==o&&e&&i.store_credits.notice&&(e=>{setTimeout(function(){a(g).createNotice("error",e,{context:p,id:C.ACFWF_NOTICE_STORE_CREDIT}),N(".acfw-reapply-sc-discount").on("click",k)},400)})(s)}const R=[w,p],v=()=>{R.forEach(e=>{a(g).removeNotices(Object.values(C).filter(e=>e),e)}),function(){const e=n(e=>e(r).getCartErrors()),t=n(e=>e(s).getValidationError("coupon")),c=e.find(e=>{return"woocommerce_rest_cart_coupon_error"===e.code&&(t=e.message,/<[^>]+>|&[a-z]+;/i.test(t));var t});if(c&&t){a(s).setValidationErrors({coupon:{message:" ",hidden:!1}});const e=c.message||"";a(g).createNotice("error",E(e),{context:w,id:C.ACFWF_NOTICE_CART_CONDITIONS})}}(),function(){const e=n(e=>e(r).getCartData()),{dummyUpdateCart:t}=acfwfObj.wc,c=i(r).isApplyingCoupon(),o=i(r).isRemovingCoupon();(c||o)&&t();const{acfwf_block:s}=e.extensions;if(!s||!s.bogo_deals)return null;const l=s.bogo_deals;l&&l.forEach(e=>{a(g).createNotice("info",E(e),{context:w,id:C.ACFWF_NOTICE_BOGO})})}(),T()}}}});
