OwlCyberSecurity - MANAGER
Edit File: product-button-frontend.js
(self.webpackChunkwebpackWcBlocksFrontendJsonp=self.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[409],{3942:(e,t,r)=>{"use strict";r.r(t),r.d(t,{Block:()=>D,default:()=>F});var o=r(1609),n=r(851),s=r(7723),a=r(7103),i=r(6087),c=r(7143),l=r(7594),d=r(8537),u=r(458),p=r.n(u),m=r(5703),_=r(3993),b=r(812);const y=e=>{const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.required&&(t.required=e.required),void 0!==e.hidden&&(t.hidden=e.hidden),void 0===e.label||e.optionalLabel||(t.optionalLabel=(0,s.sprintf)(/* translators: %s Field label. */ /* translators: %s Field label. */ (0,s.__)("%s (optional)","woocommerce"),e.label)),e.priority&&((0,_.isNumber)(e.priority)&&(t.index=e.priority),(0,_.isString)(e.priority)&&(t.index=parseInt(e.priority,10))),e.hidden&&(t.required=!1),t},g=Object.entries(b.iI).map((([e,t])=>[e,Object.entries(t).map((([e,t])=>[e,y(t)])).reduce(((e,[t,r])=>(e[t]=r,e)),{})])).reduce(((e,[t,r])=>(e[t]=r,e)),{});r(3832);const v=e=>{const t=((e,t,r="")=>{const o=r&&void 0!==g[r]?g[r]:{};return e.map((e=>({key:e,...m.defaultFields[e]||{},...o[e]||{},...t[e]||{}}))).sort(((e,t)=>e.index-t.index))})(b.Hw,{},e.country),r=Object.assign({},e);return t.forEach((({key:t="",hidden:o=!1})=>{o&&((e,t)=>e in t)(t,e)&&(r[t]="")})),r},E=(0,i.createContext)({isEditor:!1,currentPostId:0,currentView:"",previewData:{},getPreviewData:()=>({})}),C=window.CustomEvent||null,w=(e,t,r=!1,o=!1)=>{if("function"!=typeof jQuery)return()=>{};const n=()=>{((e,{bubbles:t=!1,cancelable:r=!1,element:o,detail:n={}})=>{if(!C)return;o||(o=document.body);const s=new C(e,{bubbles:t,cancelable:r,detail:n});o.dispatchEvent(s)})(t,{bubbles:r,cancelable:o})};return jQuery(document).on(e,n),()=>jQuery(document).off(e,n)},h=e=>{const t=null==e?void 0:e.detail;t&&t.preserveCartData||(0,c.dispatch)(l.CART_STORE_KEY).invalidateResolutionForStore()},f=e=>{(null!=e&&e.persisted||"back_forward"===(window.performance&&window.performance.getEntriesByType("navigation").length?window.performance.getEntriesByType("navigation")[0].type:""))&&(0,c.dispatch)(l.CART_STORE_KEY).invalidateResolutionForStore()},S=()=>{1===window.wcBlocksStoreCartListeners.count&&window.wcBlocksStoreCartListeners.remove(),window.wcBlocksStoreCartListeners.count--},T={first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},R={...T,email:""},k={total_items:"",total_items_tax:"",total_fees:"",total_fees_tax:"",total_discount:"",total_discount_tax:"",total_shipping:"",total_shipping_tax:"",total_price:"",total_tax:"",tax_lines:l.EMPTY_TAX_LINES,currency_code:"",currency_symbol:"",currency_minor_unit:2,currency_decimal_separator:"",currency_thousand_separator:"",currency_prefix:"",currency_suffix:""},N=e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[e,(0,d.decodeEntities)(t)]))),A={cartCoupons:l.EMPTY_CART_COUPONS,cartItems:l.EMPTY_CART_ITEMS,cartFees:l.EMPTY_CART_FEES,cartItemsCount:0,cartItemsWeight:0,crossSellsProducts:l.EMPTY_CART_CROSS_SELLS,cartNeedsPayment:!0,cartNeedsShipping:!0,cartItemErrors:l.EMPTY_CART_ITEM_ERRORS,cartTotals:k,cartIsLoading:!0,cartErrors:l.EMPTY_CART_ERRORS,billingAddress:R,shippingAddress:T,shippingRates:l.EMPTY_SHIPPING_RATES,isLoadingRates:!1,cartHasCalculatedShipping:!1,paymentMethods:l.EMPTY_PAYMENT_METHODS,paymentRequirements:l.EMPTY_PAYMENT_REQUIREMENTS,receiveCart:()=>{},receiveCartContents:()=>{},extensions:l.EMPTY_EXTENSIONS},P=(e={shouldSelect:!0})=>{const{isEditor:t,previewData:r}=(0,i.useContext)(E),o=null==r?void 0:r.previewCart,{shouldSelect:n}=e,s=(0,i.useRef)();(0,i.useEffect)((()=>((()=>{if(window.wcBlocksStoreCartListeners||(window.wcBlocksStoreCartListeners={count:0,remove:()=>{}}),(null===(e=window.wcBlocksStoreCartListeners)||void 0===e?void 0:e.count)>0)return void window.wcBlocksStoreCartListeners.count++;var e;document.body.addEventListener("wc-blocks_added_to_cart",h),document.body.addEventListener("wc-blocks_removed_from_cart",h),window.addEventListener("pageshow",f);const t=w("added_to_cart","wc-blocks_added_to_cart"),r=w("removed_from_cart","wc-blocks_removed_from_cart");window.wcBlocksStoreCartListeners.count=1,window.wcBlocksStoreCartListeners.remove=()=>{document.body.removeEventListener("wc-blocks_added_to_cart",h),document.body.removeEventListener("wc-blocks_removed_from_cart",h),window.removeEventListener("pageshow",f),t(),r()}})(),S)),[]);const a=(0,c.useSelect)(((e,{dispatch:r})=>{if(!n)return A;if(t)return{cartCoupons:o.coupons,cartItems:o.items,crossSellsProducts:o.cross_sells,cartFees:o.fees,cartItemsCount:o.items_count,cartItemsWeight:o.items_weight,cartNeedsPayment:o.needs_payment,cartNeedsShipping:o.needs_shipping,cartItemErrors:l.EMPTY_CART_ITEM_ERRORS,cartTotals:o.totals,cartIsLoading:!1,cartErrors:l.EMPTY_CART_ERRORS,billingData:R,billingAddress:R,shippingAddress:T,extensions:l.EMPTY_EXTENSIONS,shippingRates:o.shipping_rates,isLoadingRates:!1,cartHasCalculatedShipping:o.has_calculated_shipping,paymentRequirements:o.paymentRequirements,receiveCart:"function"==typeof(null==o?void 0:o.receiveCart)?o.receiveCart:()=>{},receiveCartContents:"function"==typeof(null==o?void 0:o.receiveCartContents)?o.receiveCartContents:()=>{}};const s=e(l.CART_STORE_KEY),a=s.getCartData(),i=s.getCartErrors(),c=s.getCartTotals(),d=!s.hasFinishedResolution("getCartData"),u=s.isCustomerDataUpdating(),{receiveCart:p,receiveCartContents:m}=r(l.CART_STORE_KEY),_=N(a.billingAddress),b=a.needsShipping?N(a.shippingAddress):_,y=a.fees.length>0?a.fees.map((e=>N(e))):l.EMPTY_CART_FEES;return{cartCoupons:a.coupons.length>0?a.coupons.map((e=>({...e,label:e.code}))):l.EMPTY_CART_COUPONS,cartItems:a.items,crossSellsProducts:a.crossSells,cartFees:y,cartItemsCount:a.itemsCount,cartItemsWeight:a.itemsWeight,cartNeedsPayment:a.needsPayment,cartNeedsShipping:a.needsShipping,cartItemErrors:a.errors,cartTotals:c,cartIsLoading:d,cartErrors:i,billingData:v(_),billingAddress:v(_),shippingAddress:v(b),extensions:a.extensions,shippingRates:a.shippingRates,isLoadingRates:u,cartHasCalculatedShipping:a.hasCalculatedShipping,paymentRequirements:a.paymentRequirements,receiveCart:p,receiveCartContents:m}}),[n]);return s.current&&p()(s.current,a)||(s.current=a),s.current},I=(e,t)=>{const r=e.find((({id:e})=>e===t));return r?r.quantity:0};var x=r(3249),L=r(2796),O=r(1616);r(1546);const M=({product:e,className:t,style:r})=>{const{id:u,permalink:p,add_to_cart:_,has_options:y,is_purchasable:g,is_in_stock:v}=e,{dispatchStoreEvent:E}=(0,a.y)(),{cartQuantity:C,addingToCart:w,addToCart:h}=(e=>{const{addItemToCart:t}=(0,c.useDispatch)(l.CART_STORE_KEY),{cartItems:r,cartIsLoading:o}=P(),{createErrorNotice:n,removeNotice:s}=(0,c.useDispatch)("core/notices"),[a,u]=(0,i.useState)(!1),p=(0,i.useRef)(I(r,e));return(0,i.useEffect)((()=>{const t=I(r,e);t!==p.current&&(p.current=t)}),[r,e]),{cartQuantity:Number.isFinite(p.current)?p.current:0,addingToCart:a,cartIsLoading:o,addToCart:(r=1)=>(u(!0),t(e,r).then((()=>{s("add-to-cart")})).catch((e=>{n((0,d.decodeEntities)(e.message),{id:"add-to-cart",context:"wc/all-products",isDismissible:!0})})).finally((()=>{u(!1)})))}})(u),f=Number.isFinite(C)&&C>0,S=!y&&g&&v,T=(0,d.decodeEntities)((null==_?void 0:_.description)||""),R=f?(0,s.sprintf)(/* translators: %s number of products in cart. */ /* translators: %s number of products in cart. */ (0,s._n)("%d in cart","%d in cart",C,"woocommerce"),C):(0,d.decodeEntities)((null==_?void 0:_.text)||(0,s.__)("Add to cart","woocommerce")),k=S?"button":"a",N={};return S?N.onClick=async()=>{await h(),E("cart-add-item",{product:e});const{cartRedirectAfterAdd:t}=(0,m.getSetting)("productsSettings");t&&(window.location.href=b.Vo)}:(N.href=p,N.rel="nofollow",N.onClick=()=>{E("product-view-link",{product:e})}),(0,o.createElement)(k,{...N,"aria-label":T,disabled:w,className:(0,n.A)(t,"wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button",{loading:w,added:f}),style:r},R)},Y=({className:e,style:t})=>(0,o.createElement)("button",{className:(0,n.A)("wp-block-button__link","wp-element-button","add_to_cart_button","wc-block-components-product-button__button","wc-block-components-product-button__button--placeholder",e),style:t,disabled:!0}),D=e=>{const{className:t,textAlign:r}=e,s=(0,x.p)(e),{parentClassName:a}=(0,L.useInnerBlockLayoutContext)(),{product:i}=(0,L.useProductDataContext)();return(0,o.createElement)("div",{className:(0,n.A)(t,"wp-block-button","wc-block-components-product-button",{[`${a}__product-add-to-cart`]:a,[`align-${r}`]:r})},i.id?(0,o.createElement)(M,{product:i,style:s.style,className:s.className}):(0,o.createElement)(Y,{style:s.style,className:s.className}))},F=(0,O.withProductDataContext)(D)},3249:(e,t,r)=>{"use strict";r.d(t,{p:()=>l});var o=r(851),n=r(3993),s=r(1194),a=r(9786);function i(e={}){const t={};return(0,a.getCSSRules)(e,{selector:""}).forEach((e=>{t[e.key]=e.value})),t}function c(e,t){return e&&t?`has-${(0,s.c)(t)}-${e}`:""}const l=e=>{const t=(e=>{const t=(0,n.isObject)(e)?e:{style:{}};let r=t.style;return(0,n.isString)(r)&&(r=JSON.parse(r)||{}),(0,n.isObject)(r)||(r={}),{...t,style:r}})(e),r=function(e){var t,r,s,a,l,d,u;const{backgroundColor:p,textColor:m,gradient:_,style:b}=e,y=c("background-color",p),g=c("color",m),v=function(e){if(e)return`has-${e}-gradient-background`}(_),E=v||(null==b||null===(t=b.color)||void 0===t?void 0:t.gradient);return{className:(0,o.A)(g,v,{[y]:!E&&!!y,"has-text-color":m||(null==b||null===(r=b.color)||void 0===r?void 0:r.text),"has-background":p||(null==b||null===(s=b.color)||void 0===s?void 0:s.background)||_||(null==b||null===(a=b.color)||void 0===a?void 0:a.gradient),"has-link-color":(0,n.isObject)(null==b||null===(l=b.elements)||void 0===l?void 0:l.link)?null==b||null===(d=b.elements)||void 0===d||null===(u=d.link)||void 0===u?void 0:u.color:void 0}),style:i({color:(null==b?void 0:b.color)||{}})}}(t),s=function(e){var t;const r=(null===(t=e.style)||void 0===t?void 0:t.border)||{};return{className:function(e){var t;const{borderColor:r,style:n}=e,s=r?c("border-color",r):"";return(0,o.A)({"has-border-color":!!r||!(null==n||null===(t=n.border)||void 0===t||!t.color),[s]:!!s})}(e),style:i({border:r})}}(t),a=function(e){var t;return{className:void 0,style:i({spacing:(null===(t=e.style)||void 0===t?void 0:t.spacing)||{}})}}(t),l=(e=>{const t=(0,n.isObject)(e.style.typography)?e.style.typography:{},r=(0,n.isString)(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:r,style:{fontSize:e.fontSize?`var(--wp--preset--font-size--${e.fontSize})`:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,textDecoration:t.textDecoration,textTransform:t.textTransform}}})(t);return{className:(0,o.A)(l.className,r.className,s.className,a.className),style:{...l.style,...r.style,...s.style,...a.style}}}},1546:()=>{}}]);