(()=>{"use strict";var t={n:a=>{var e=a&&a.__esModule?()=>a.default:()=>a;return t.d(e,{a:e}),e},d:(a,e)=>{for(var i in e)t.o(e,i)&&!t.o(a,i)&&Object.defineProperty(a,i,{enumerable:!0,get:e[i]})},o:(t,a)=>Object.prototype.hasOwnProperty.call(t,a),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};t.r(a),t.d(a,{default:()=>c});const e=window.jQuery;var i=t.n(e);const s=window.wcPPCP.utils,n=window.wp.apiFetch;var r=t.n(n);const d=window.wcPPCP.actions;var o=t.n(d);const c=new class{constructor(){this.actions=new(o()),this.data=(0,s.getSetting)("cart"),this.page=(0,s.getSetting)("generalData").page,this.processing=!1,i()(document.body).on("updated_wc_div",this.onCartUpdated.bind(this)),i()(document.body).on("updated_cart_totals",this.onCartUpdated.bind(this)),i()(document.body).on("updated_checkout",this.onUpdatedCheckout.bind(this)),i()(document.body).on("wc_fragments_refreshed wc_fragments_loaded",this.onCartFragmentsChanged.bind(this)),document.addEventListener("wc-ppcp:mini-cart-ready",({detail:t})=>{this.actions.doAction("mini_cart_ready",this)}),document.addEventListener("wc-ppcp:mini-cart-updated",this.onMiniCartUpdated.bind(this))}async onCartUpdated(t){let a;window?.wcPPCPCartData?.cart?(a=window.wcPPCPCartData,this.data={...this.data,...a.cart}):a=await this.refreshData(),(0,s.setSetting)("queryParams",this.data.queryParams),this.actions.doAction("cart_updated",a,this),window.wcPPCPCartData=null}onMiniCartUpdated({detail:t}){const a=t.cart||null;a&&a?.extensions?.wc_ppcp?.cart&&(this.data={...this.data,...a.extensions.wc_ppcp.cart},this.actions.doAction("mini_cart_updated",this))}on(t,a){this.actions.addAction(t,a)}trigger(t,...a){this.actions.doAction(t,...a)}applyFilters(t,...a){return this.actions.applyFilters(t,...a)}async onUpdatedCheckout(t,a){let e={};if(a?.fragments?.wc_ppcp_data){e=a.fragments.wc_ppcp_data;const{cart:t,queryParams:i=null}=e;this.data={...this.data,...t},i&&(0,s.setSetting)("queryParams",i)}this.actions.doAction("updated_checkout",e,a)}onCartFragmentsChanged(){setTimeout(()=>{window.wcPPCPMiniCartUpdate&&(this.data={...this.data,...wcPPCPMiniCartUpdate}),this.actions.doAction("fragments_changed",this)},250)}getData(){return(0,s.getSetting)("cart")}getCurrency(){return this.actions.applyFilters("cart_get_currency",this.data.currency,this)}getCountryCode(){return this.data.countryCode}needsShipping(){return this.actions.applyFilters("cart_needs_shipping",this.data?.needsShipping,this)}isEmpty(){return this.data?.isEmpty}isPaymentMethodAvailable(t){var a;return null!==(a=this.data?.availablePaymentMethods?.includes(t))&&void 0!==a&&a}async refreshData(t=null){if(!this.processing)try{this.processing=!0;const t=await r()({method:"POST",url:(0,s.getRestRoute)("cart/refresh"),data:{page:this.page}});return this.data={...this.data,...t.cart},this.data.queryParams=t.queryParams,t}catch(t){console.log(t)}finally{this.processing=!1}}async addToCart(t){return r()({method:"POST",url:(0,s.getRestRoute)("cart/item"),data:await this.actions.applyFiltersAsync("add_to_cart_data",t,this)}).then(t=>(t.cart&&(this.data={...this.data,...t.cart}),t)).catch(t=>{throw t})}removeCartItem(t){return r()({method:"DELETE",url:(0,s.getRestRoute)("cart/item"),data:{key:t}}).then(t=>{this.data={...this.data,...t.cart}}).catch(t=>{console.log("Error removing item from cart. ",t)})}async updateShipping(t){return r()({method:"POST",url:(0,s.getRestRoute)("cart/shipping"),data:t}).then(t=>(t.code||(this.data={...this.data,...t}),this.sanitizeResponse(t))).catch(t=>{throw t})}async updateBilling(t){return r()({method:"POST",url:(0,s.getRestRoute)("cart/billing"),data:t}).then(t=>(t.code||(this.data={...this.data,...t.cart}),t)).catch(t=>{throw t})}async createOrder(t){return r()({method:"POST",url:(0,s.getRestRoute)("cart/order"),data:await this.actions.applyFiltersAsync("create_order_data",t)}).then(t=>this.sanitizeResponse(t))}async doOrderPay(t,a={}){const e=(0,s.getSetting)("order");return r()({method:"POST",url:(0,s.getRestRoute)("order/pay"),data:{payment_method:t,...a,...e}}).then(t=>this.sanitizeResponse(t))}getTotal(t="string"){let a=this.data?.total||0;return"string"===t&&(a=a.toString()),this.actions.applyFilters("cart_total",a,this)}getTotalCents(){return this.actions.applyFilters("cart_total_cents",parseInt(this.data?.totalCents||0),this)}getLineItems(){return this.data.lineItems||[]}getShippingOptions(){return this.data.shippingOptions||[]}getSelectedShippingMethod(){return this.data.selectedShippingMethod||""}sanitizeResponse(t){return"string"==typeof t?t=t.replace(/<[^>]*>/g,""):Array.isArray(t)&&(t=this.sanitizeResponse(t[0])),t}};(this.wcPPCP=this.wcPPCP||{}).cart=a})();
(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>r});const r=class{constructor(e){this.page=e}getPage(){return this.page}isCheckout(){return"checkout"===this.page}isExpressCheckout(){return"express_checkout"===this.page}isCart(){return"cart"===this.page}isProduct(){return"product"===this.page}isOrderPay(){return"order_pay"===this.page}isAddPaymentMethod(){return"add_payment_method"===this.page}};(this.wcPPCP=this.wcPPCP||{}).context=t})();
(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{getPaymentMethod:()=>d,getPaymentMethods:()=>n,registerPaymentMethod:()=>r});const o={},r=e=>{o[e.id]=e},n=()=>o,d=e=>o[e]?o[e]:null;(this.wcPPCP=this.wcPPCP||{}).paymentMethods=t})();
(()=>{"use strict";var e={n:t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},d:(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{BaseController:()=>c,CartController:()=>m,CheckoutController:()=>y,ExpressCheckoutController:()=>P,MiniCartController:()=>b,ProductController:()=>p});const i=window.jQuery;var s=e.n(i);const n=window.wp.apiFetch;var a=e.n(n);const r=window.wcPPCP.utils,o=window.lodash,d=class{constructor(e,t){this.context=e,this.controller=t}populate(e,t={}){(this.context.isCheckout()||this.context.isExpressCheckout())&&this.syncDOMToMap(t),e?.billing&&this.populateBilling(e.billing,t),e?.shipping&&!t.skipShipping&&t.needsShipping&&this.populateShipping(e.shipping,t)}syncDOMToMap(e={}){["first_name","last_name","company","address_1","address_2","city","state","postcode","country","email","phone"].forEach(e=>{const t=s()(`[name="billing_${e}"]`);t.length&&(0,r.setFieldValue)(e,t.val(),"billing")}),e.needsShipping&&["first_name","last_name","company","address_1","address_2","city","state","postcode","country","phone"].forEach(e=>{const t=s()(`[name="shipping_${e}"]`);t.length&&(0,r.setFieldValue)(e,t.val(),"shipping")})}populateBilling(e,t){const{email:i,phone:n,...a}=e;(0,o.isEmpty)(a)||(this.context.isCheckout()||this.context.isExpressCheckout()?(0,r.isValidAddress)(a,["first_name","last_name","phone"])&&!(0,o.isEqual)(this.controller.getCartAddress("billing",!0),(0,o.omit)(a,["first_name","last_name"]))&&(this.controller.update_required=!0,this.populateAddressFields(a,"billing"),s()(document.body).one("updated_checkout",()=>{this.populateAddressFields(a,"billing")})):this.populateAddressFields(a,"billing")),i&&(this.context.isCheckout()&&(0,r.isValid)("billing_email")||(0,r.setFieldValue)("billing_email",i)),n&&((0,r.setFieldValue)("billing_phone",n),t.needsShipping&&(0,r.setFieldValue)("shipping_phone",n))}populateShipping(e,t){const{phone:i,...n}=e;if(!(0,o.isEmpty)(n))if(this.context.isCheckout()||this.context.isExpressCheckout()){const e=this.controller.getCartFullAddress("shipping",!0);(0,o.isEqual)(e,n)||(this.controller.update_required=!0,this.populateAddressFields(n,"shipping"),s()(document.body).one("updated_checkout",()=>{this.populateAddressFields(n,"shipping")})),(0,r.isValidAddress)(this.controller.getCartFullAddress("billing",!0),["phone","email"])||(n.first_name&&n.last_name&&!(0,r.isValid)("billing_first_name")&&!(0,r.isValid)("billing_last_name")&&((0,r.setFieldValue)("first_name",n.first_name,"billing"),(0,r.setFieldValue)("last_name",n.last_name,"billing")),this.populateAddressFields(n,"billing"))}else this.populateAddressFields(n,"shipping"),(0,r.isValidAddress)(this.controller.getCartFullAddress("billing",!0),["phone","email"])||this.populateAddressFields(n,"billing");i&&(0,r.setFieldValue)("shipping_phone",i),(this.context.isCheckout()||this.context.isExpressCheckout())&&this.maybeShipToDifferentAddress()}maybeShipToDifferentAddress(){if(s()('[name="ship_to_different_address"]')?.length){const e=this.controller.getCartFullAddress("billing"),t=this.controller.getCartFullAddress("shipping"),i=!(0,o.isEqual)(e,t);s()('[name="ship_to_different_address"]').prop("checked",i).trigger("change")}}populateAddressFields(e,t){for(let i in e)(0,r.setFieldValue)(i,e[i],t)}},h=window.wcPPCP.actions;var l=e.n(h);class c{static attributionDataStored=!1;constructor({id:e,settings:t,cart:i,context:s,gateway:n,container:a=null,paymentElementSelector:r=null}){this.id=e,this.cart=i,this.gateway=n,this.context=s,this.settings=t,this.container=a||`li.payment_method_${e}`,this.paymentElementSelector=r,this.order_field_key=n.getOrderFieldKey(),this.billing_token_key=n.getTokenFieldKey(),this.isPaymentMethodAvailable=!0,this.fields=new d(this.context,this),this.actions=new(l()),this.gateway.setController(this),this.gateway.initialize()}initialize(){this.loadPayPalScript().then(async()=>{await this.createPaymentElement()})}loadPayPalScript(){return new Promise((e,t)=>{(0,r.loadPayPalSdk)(this.getPayPalSDKArgs()).then(t=>{this.paypal=t,this.gateway.setPayPal(t),e()}).catch(e=>{console.log(e),e?.code&&this.submitError((0,r.getErrorMessage)(e)),t()})})}getPayPalSDKArgs(){return(0,r.getPayPalQueryParams)()}async createPaymentElement(){if(this.configurationError=null,!this.cart.isPaymentMethodAvailable(this.gateway.id))return this.isPaymentMethodAvailable=!1,void this.onPaymentUnavailable();let e=!1;try{e=await this.gateway.canMakePayment()}catch(t){e=!1,t instanceof r.ConfigurationError?this.configurationError=t.message:console.error("Payment method availability check failed:",t)}if(!e)return this.isPaymentMethodAvailable=!1,void this.onPaymentUnavailable();this.isPaymentMethodAvailable=!0;const t=this.getElementContainer();if(t&&this.gateway.shouldCreateElement(t)){if(t instanceof NodeList)for(let e=0;e<t.length;e++){const i=t[e];await this.gateway.createPaymentElement(i)}else await this.gateway.createPaymentElement(t);this.$paymentElement=s()(t),this.onPaymentElementReady()}}getPaymentElement(){return this.$paymentElement}destroyPaymentElement(){this.gateway.destroyPaymentElement?.()}disablePaymentElement(e=!1){this.gateway.disablePaymentElement?.(),e&&this?.$paymentElement&&this.$paymentElement.addClass("disabled")}enablePaymentElement(){this.gateway.enablePaymentElement?.(),this.$paymentElement&&this.$paymentElement.removeClass("disabled")}displayPaymentElement(){this.getPaymentElement()?.show()}hidePaymentElement(){this.getPaymentElement()?.hide()}needsShipping(){return this.cart.needsShipping()}getElementContainer(){return null}onPaymentUnavailable(){this.actions.doAction("payment_unavailable",this)}onPaymentElementReady(){this.actions.doAction("payment_element_ready",this)}onCancel(){this.enablePaymentElement()}onError(e,t){this.currentError?(this.submitError(this.currentError),this.currentError=null):this.submitError(e),this.enablePaymentElement(),s()(document.body).triggerHandler("wc_ppcp_on_error",[this,t,e])}fetchBillingToken(e){return a()({method:"GET",path:`/wc-ppcp/v1/billing-agreement/token/${e}`})}createPaymentToken(e,t={}){return a()({method:"POST",path:"/wc-ppcp/v1/vault/payment-tokens",data:{setup_token:e,...t}})}createOrder(e,t){return this.cart.createOrder({...e,payment_method:this.id}).catch(e=>(this.currentError=e,e))}async createVaultSetupToken(e={}){return this.disablePaymentElement(!0),a()({method:"POST",url:(0,r.getRestPath)("/wc-ppcp/v1/vault/setup-tokens"),data:await this.actions.applyFiltersAsync("create_vault_token_data",{context:this.context.getPage(),payment_method:this.id,...e})}).then(e=>e.id).catch(e=>{throw this.currentError=e,this.enablePaymentElement(),e})}onShippingChange(e){return this.cart.updateShipping({...e,payment_method:this.id}).then(e=>e).catch(e=>{throw e})}onBillingChange(e){return this.cart.updateBilling({payment_method:this.id,...e}).then(e=>e).catch(e=>{throw e})}submitError(e){}getShippingPrefix(){return"shipping"}getCartAddress(e,t=!1){return{address_1:(0,r.getFieldValue)("address_1",e,t),address_2:(0,r.getFieldValue)("address_2",e,t),state:(0,r.getFieldValue)("state",e,t),city:(0,r.getFieldValue)("city",e,t),postcode:(0,r.getFieldValue)("postcode",e,t),country:(0,r.getFieldValue)("country",e,t)}}getCartFullAddress(e,t=!1){return{first_name:(0,r.getFieldValue)("first_name",e,t),last_name:(0,r.getFieldValue)("last_name",e,t),address_1:(0,r.getFieldValue)("address_1",e,t),address_2:(0,r.getFieldValue)("address_2",e,t),state:(0,r.getFieldValue)("state",e,t),city:(0,r.getFieldValue)("city",e,t),postcode:(0,r.getFieldValue)("postcode",e,t),country:(0,r.getFieldValue)("country",e,t)}}onClick(){this.storeAttributionValues()}async validate(){return!0}populateCheckoutFields(e){let t=this.actions.applyFilters("field_population_options",{skipShipping:!1,needsShipping:this.needsShipping()},this);this.fields.populate(e,t),this.actions.doAction("after_populate_checkout_fields",this)}submit(e=null){return e&&this.populateCheckoutFields(e),this.showProcessing(),a()({method:"POST",url:(0,r.getRestRoute)("cart/checkout"),data:this.getCartCheckoutData()}).then(e=>{if(e.result&&"success"==e.result)window.location=e.redirect;else if(e.messages)return this.submitError(e.messages)}).catch(e=>{e.code&&this.submitError(e.message)})}getCartCheckoutData(){return{payment_method:this.id,context:this.context.getPage(),...(0,r.fieldsToJson)()}}getProcessingSelector(){return"body"}showProcessing(){s()(this.getProcessingSelector())?.block({message:this.getProcessingMessage(),overlayCSS:{background:"#fff",opacity:.6}})}hideProcessing(){s()(this.getProcessingSelector())?.unblock()}getProcessingMessage(){return'<div class="wc-ppcp-loader">\n                        <div></div>\n                        <div></div>\n                        <div></div>\n                      </div>'}getFullName(e){const t=[(0,r.getFieldValue)("first_name",e),(0,r.getFieldValue)("last_name",e)].filter(Boolean);return 0==t.length?null:1==t.length?t[0]:`${t[0]} ${t[1]}`}updateGatewaySettings(e){const t=`${this.id}_data`;e[t]&&(this.gateway.settings={...this.gateway.settings,...e[t]})}isOrderAttributionEnabled(){return"undefined"!=typeof wc_order_attribution&&null!==document.querySelector("wc-order-attribution-inputs")}storeAttributionValues(){if(c.attributionDataStored)return;if(this.context.isCheckout()||!this.isOrderAttributionEnabled())return;const e=wc_order_attribution.params.prefix;s()('input[type="hidden"][name^="'+e+'"]').each((e,t)=>{var i=s()(t),n=i.attr("name");(0,r.setFieldValue)(n,i.val(),null)}),c.attributionDataStored=!0}getLineItems(){return this.cart.getLineItems()}getShippingOptions(){return this.cart.getShippingOptions()}getSelectedShippingMethod(){return this.cart.getSelectedShippingMethod()}getCurrency(){return this.cart.getCurrency()}getTotal(e="string"){return this.cart.getTotal()}getTotalCents(){return this.cart.getTotalCents()}}const u=c;class p extends u{_excludedKeys=["add-to-cart","quantity","variation_id"];constructor(e,t){super(t),this.product=e}initialize(){this.actions.addAction("found_variation",this.onFoundVariation.bind(this)),this.actions.addAction("reset_variation",this.onResetVariation.bind(this)),this.setMaxWidth(),super.initialize()}onPaymentElementReady(){super.onPaymentElementReady(),this.product.isVariableProduct()&&(this.product.isVariationSelected()&&this.product?.variation?.is_in_stock?this.enablePaymentElement():this.disablePaymentElement(!0))}onPaymentUnavailable(){super.onPaymentUnavailable(),s()(`li.payment_method_${this.gateway.id}`).hide()}needsShipping(){return this.cart.isEmpty()?this.product.needsShipping():super.needsShipping()}getElementContainer(){const e=`wc-${this.id}-product-button-container`,t=document.querySelectorAll(`.${e}`);return t&&t.length>0?t:document.getElementById(e)}setMaxWidth(){if("add_to_cart"==this.settings?.product?.button_width){this.buttonWidth=s()("form.cart div.quantity").outerWidth(!0)+s()(".single_add_to_cart_button").outerWidth();var e=s()(".single_add_to_cart_button").css("marginLeft");e&&(this.buttonWidth+=parseInt(e.replace("px",""))),s()(this.container).css("max-width",this.buttonWidth+"px")}}submitError(e){this.hideProcessing(),(0,r.submitErrorMessage)(e,"div.woocommerce-notices-wrapper")}addToCart(){return this.cart.addToCart({payment_method:this.id,product_id:this.product.getId(),variation_id:this.product.getVariationId(),qty:this.product.getQuantity(),variation:this.product.getVariationData(),needs_setup_token:this.settings.needsSetupToken,...(0,r.convertFormToJson)(s()("form.cart"),this._excludedKeys)}).then(e=>{if(!e.code)return this._cartItemKey=e.cart_item_key,e.order_id;this.currentError=e}).catch(e=>(this.currentError=e,this.submitError(e)))}createOrder(){return this.addToCart()}createVaultSetupToken(e={}){return this.addToCart().then(()=>super.createVaultSetupToken(e))}async removeCartItem(){this._cartItemKey&&await this.cart.removeCartItem(this._cartItemKey)}onFoundVariation(e,t){e?(this.destroyPaymentElement(),this.createPaymentElement()):t.variation.is_in_stock?this.enablePaymentElement():this.disablePaymentElement(!0)}onResetVariation(){this.disablePaymentElement(!0)}onCancel(){this.removeCartItem().finally(()=>{super.onCancel()})}getTotal(e){return this.cart.isEmpty()?this.product.getTotal(e):super.getTotal(e)}getTotalCents(){return this.cart.isEmpty()?this.product.getTotalCents():super.getTotalCents()}getLineItems(){return this.cart.isEmpty()?this.product.getLineItems():super.getLineItems()}}class m extends u{initialize(){this.actions.addAction("cart_updated",this.onCartUpdated.bind(this)),s()(window).on("resize",this.doCartHtml.bind(this)),s()(document).on("change",'input[name^="shipping_method"]',this.onShippingSelected.bind(this)),super.initialize(),this.doCartHtml()}getElementContainer(){return document.getElementById(`wc-${this.id}-cart-button-container`)}onCartUpdated(e){super.initialize(),this.doCartHtml()}onShippingSelected(){this.storeAttributionValues()}submitError(e){this.hideProcessing(),(0,r.submitErrorMessage)(e,"div.woocommerce-notices-wrapper","checkout")}doCartHtml(){const e=s()(".checkout-button"),t=e.outerWidth();t&&s()(".wc-ppcp-cart-payments__container").length&&s()(".wc-ppcp-cart-payments__container").width(t),"none"!==e.css("float")&&s()(".wc-ppcp-cart-payments__container ").css("float",e.css("float"))}onPaymentElementReady(){super.onPaymentElementReady(),s()(".wc-ppcp-cart-payments__container").show()}onPaymentUnavailable(){super.onPaymentUnavailable(),s()(`li.payment_method_${this.gateway.id}`).hide()}}const g=window.wcPPCP.paymentMethods;class y extends u{constructor(e){super(e),this.order=e.order,this.shippingAddressChanged=!1,this.promises=[]}initialize(){super.initialize(),this.actions.addAction("updated_checkout",this.updatedCheckout.bind(this)),s()(document.body).on("update_checkout",this.updateCheckout.bind(this)),this.context.isCheckout()?(s()(document.body).on("payment_method_selected",this.paymentMethodSelected.bind(this)),s()("form.checkout").on(`checkout_place_order_${this.id}`,this.onCheckoutPlaceOrder.bind(this))):(s()(document.body).on("change",'input[name="payment_method"]',this.paymentMethodSelected.bind(this)),s()(document.body).on("click","#place_order",this.onClickPlaceOrder.bind(this))),s()(document.body).on("checkout_error",this.onCheckoutError.bind(this)),s()(document.body).on("click",`.wc-${this.gateway.id}-cancel__payment`,this.cancelPayment.bind(this)),s()(document.body).on("change",'[name="terms"]',this.handleTermsClick.bind(this)),s()(document.body).on("change",'[type="checkbox"]',this.handleCheckboxChange.bind(this)),s()(document.body).on("change",`[name="wc-${this.id}-payment-token"]`,this.onPaymentTokenClick.bind(this)),window.addEventListener("hashchange",this.handleHashError.bind(this)),this.handleOrderPay()}async createPaymentElement(){await Promise.all(this.promises),this.promises=[],!this.context.isCheckout()||this.isEnabledForCheckoutSection()?super.createPaymentElement().then(()=>{this.paymentMethodSelected()}):this.hidePaymentMethodRow()}isEnabledForCheckoutSection(){var e;return null===(e=this.gateway.settings?.sections?.includes("checkout"))||void 0===e||e}hidePaymentMethodRow(){this.context.isOrderPay()?s()(`form#order_review li.payment_method_${this.id}`).hide():s()(`form.checkout li.payment_method_${this.id}`).hide()}onPaymentUnavailable(){if(super.onPaymentUnavailable(),!this.configurationError)return void this.hidePaymentMethodRow();const e=(0,r.isAdminUser)()?this.gateway.settings?.i18n?.unavailable_admin||this.configurationError:this.gateway.settings?.i18n?.unavailable||"Payment method unavailable",t=s()(`div.payment_method_${this.id}`).find(`.wc-${this.id}-payment-method__container`);t.find(".woocommerce-info").remove(),t.prepend(`<div class="woocommerce-info"><p>${e}</p></div>`)}needsShipping(){return this.context.isOrderPay()?this.order.needsShipping():!this.context.isAddPaymentMethod()&&this.cart.needsShipping()}getCurrency(){return this.context.isOrderPay()?this.order.getCurrency():super.getCurrency()}getTotal(e="string"){return this.context.isOrderPay()?this.order.getTotal():super.getTotal(e)}getTotalCents(){return this.context.isOrderPay()?this.order.getTotalCents():super.getTotalCents()}getLineItems(){return this.context.isOrderPay()?this.order.getLineItems():super.getLineItems()}updatedCheckout(e){super.initialize(),this.paymentMethodSelected(),(this.isOrderReview()||this.isReadyToCheckout())&&this.displayPaymentReadyMessage()}updateCheckout(){this.promises.push(new Promise(e=>{s()(document.body).one("updated_checkout",()=>{e()})}))}paymentMethodSelected(){if(this.isPaymentGatewaySelected()){if(!this.isPaymentMethodAvailable)return void this.displayPlaceOrderButton();this.gateway.supports("place_order_button")?(this.displayPlaceOrderButton(),this.isReadyToCheckout()&&this.isPaymentSectionPlacement()&&this.hidePaymentElement()):this.isReadyToCheckout()||this.isSavedPaymentMethodSelected()?this.displayPlaceOrderButton():(this.displayPaymentElement(),this.hidePlaceOrderButton())}else if(!this.gateway.supports("place_order_button")){this.hidePaymentElement();const e=s()('[name="payment_method"]:checked')?.val();e&&!(0,g.getPaymentMethod)(e)&&this.displayPlaceOrderButton()}}handleHashError(e){var t=e.newURL.match(/ppcp_error=(.*)/);if(t){const{1:e}=t;"true"==e&&(this.displayPaymentElement(),history.pushState({},"",window.location.pathname+window.location.search))}}isOrderReview(){let e=window?.location?.search?.match(/_ppcp_order_review=(.*)/);return e?.length>0}handleOrderPay(){if(this.isOrderReview())try{let e=window?.location?.search?.match(/_ppcp_order_review=(.*)/);const{1:t}=e,{payment_method:i,paypal_order:n,fields:a}=JSON.parse(atob(decodeURIComponent(t)));if((0,r.setFieldValue)(this.order_field_key,n,""),!(0,o.isEmpty)(a))for(let e in a)(0,r.setFieldValue)(e,a[e],"");if(this.hidePaymentElement(),this.needsShipping()&&s()('[name="ship_to_different_address"]')?.length){const e=!(0,o.isEqual)(this.getCartAddress("billing"),this.getCartAddress("shipping"));s()('[name="ship_to_different_address"]').prop("checked",e).trigger("change")}}catch(e){console.log(e)}}createOrder(e,t){if(this.context.isOrderPay())return this.order.createOrder(this.id);{const e={...this.convertFormToData(),context:this.context.getPage(),payment_method:this.id};return this.cart.createOrder(e)}}createVaultSetupToken(e={}){return this.context.isOrderPay()||(e={...this.convertFormToData(),context:this.context.getPage(),payment_method:this.id}),super.createVaultSetupToken(e)}displayPlaceOrderButton(){this.getPlaceOrderButton()?.removeClass("wc-ppcp-hide-button")}hidePlaceOrderButton(){this.getPlaceOrderButton()?.addClass("wc-ppcp-hide-button")}getPlaceOrderButton(){let e=s()("#place_order");return e.length||(e=s()('[name="woocommerce_checkout_place_order"]')),e.length||(e=s()('form.checkout button[type="submit"]')),e.length||(e=s()('form[id="order_review"] button[type="submit"]')),e}getButtonPlacement(){return this.settings?.buttonPlacement||"place_order"}isPlaceOrderPlacement(){return"place_order"===this.getButtonPlacement()}isPaymentSectionPlacement(){return"payment_method"===this.getButtonPlacement()}getElementContainer(){if(this.paymentElementSelector)return document.querySelector(this.paymentElementSelector);const e=this.getButtonPlacement(),t=`wc-${this.id}-checkout-container`,i=`.${t}`,n="place_order"===e&&!this.gateway.supports("place_order_button");return document.querySelector(i)||(n?this.getPlaceOrderButton().after(`<div class="${t}"></div>`):"payment_method"===e&&s()(`div.payment_method_${this.id}`).find(`.wc-${this.id}-payment-method__container`).append(`<div class="${t}"></div>`)),n&&s()(i).hide(),document.querySelector(i)}isPaymentGatewaySelected(){return s()('[name="payment_method"]:checked')?.val()===this.id}submitError(e){return"validation_errors"===e?.code?(this.getForm().find(".input-text, select, input:checkbox").trigger("validate").trigger("blur"),(0,r.submitErrorMessage)(e.data.messages,this.getForm(),"checkout")):(0,r.submitErrorMessage)(e,this.getForm(),"checkout")}getShippingPrefix(){return s()('[name="ship_to_different_address"]')?.length&&s()('[name="ship_to_different_address"]').is(":checked")?"shipping":"billing"}isCheckoutReviewRequired(e){return!(!this.needsShipping()||!this.actions.applyFilters("is_checkout_review_required",!this.shippingAddressChanged,this)||(0,o.isEmpty)(e.shipping_address)||(0,o.isEqual)({city:e.shipping_address.city,state:e.shipping_address.state,postal_code:e.shipping_address.postal_code,country_code:e.shipping_address.country_code},{city:(0,r.getFieldValue)("shipping_city"),state:(0,r.getFieldValue)("shipping_state"),postal_code:(0,r.getFieldValue)("shipping_postcode"),country_code:(0,r.getFieldValue)("shipping_country")}))}getForm(){return this.context.isCheckout()||this.context.isExpressCheckout()?s()(this.container).closest("form.checkout"):s()(this.container).closest("form")}validateTerms(){return!s()('[name="terms"]').filter(":visible").length||s()('[name="terms"]').is(":checked")}onClickPlaceOrder(e){this.isPaymentGatewaySelected()&&(this.onCheckoutPlaceOrder(e,null)||e.preventDefault())}onCheckoutPlaceOrder(e,t=null){if(this.isSavedPaymentMethodSelected())return!0;if(this.isReadyToCheckout()||this.gateway.isPaymentReady?.())return!0;if(!this.validateSync())return!1;if(this.gateway.supports("place_order_button")&&this.isPaymentSectionPlacement()&&!this.isReadyToCheckout())return this.submitError((0,r.getErrorMessage)({code:"order_button_click"}).replace("%s",this.gateway.settings.title)),!1;try{this.gateway.validatePaymentElement()}catch(e){return this.submitError(e),!1}return!this.gateway.supports("create_payment_method")||(this.gateway.createPaymentMethod(t).catch(e=>{this.submitError(e)}),!1)}isTermsVisible(){return s()('[name="terms"]').filter(":visible").length>0}handleTermsClick(){this.isPlaceOrderPlacement()&&this.gateway.supports("disable_for_terms")&&s()('[name="terms"]').filter(":visible").length&&(s()('[name="terms"]').is(":checked")?this.enablePaymentElement():this.disablePaymentElement())}handleCheckboxChange(){setTimeout(()=>{this.isTermsVisible()&&this.handleTermsClick()},250)}onPaymentTokenClick(e){this.isSavedPaymentMethodSelected()?(this.hidePaymentElement(),this.displayPlaceOrderButton()):(this.displayPaymentElement(),this.gateway.supports("place_order_button")||this.hidePlaceOrderButton())}validateSync(){return!(this.isPlaceOrderPlacement()&&!this.validateTerms()&&(this.submitError({code:"terms"}),1))}async validate(){if(!this.validateSync())return!1;if(this.context.isCheckout())try{this.gateway.supports("api_form_validation")&&await this.apiFormValidation(),this.gateway.supports("form_validation")&&(this.isCheckoutFormValid()||(this.disablePaymentElement(!0),await this.apiFormValidation().finally(()=>{this.enablePaymentElement()})))}catch(e){return this.submitError(e),!1}return!0}onShippingChange(e){if(e?.shipping_method){let t=(0,r.extractShippingMethod)(e.shipping_method);for(let e of Object.keys(t)){const i=t[e],n=s()(`[name="shipping_method[${e}]"][value="${i}"]`);n.length?n.prop("checked",!0):this.update_required=!0}}return e.address&&(this.shippingAddressChanged=!(0,o.isEqual)(e.address,{city:(0,r.getFieldValue)("shipping_city"),state:(0,r.getFieldValue)("shipping_state"),postcode:(0,r.getFieldValue)("shipping_postcode"),country:(0,r.getFieldValue)("shipping_country")})),e={...this.convertFormToData(),...e},this.actions.doAction("checkout_on_shipping_change",e,this),super.onShippingChange(e)}displayPaymentReadyMessage(){s()(`.wc-${this.gateway.id}-popup__container`).hide(),s()(`.wc-${this.gateway.id}-order-review-message__container`).show();const e=s()(`.wc-${this.gateway.id}-order-review__message`).text().replace("%s",s()("#place_order").text());s()(`.wc-${this.gateway.id}-order-review__message`).text(e)}hidePaymentReadyMessage(){s()(`.wc-${this.gateway.id}-popup__container`).show(),s()(`.wc-${this.gateway.id}-order-review-message__container`).hide()}cancelPayment(e){e.preventDefault(),(0,r.setFieldValue)(this.order_field_key,"",""),(0,r.setFieldValue)(`${this.gateway.id}_payment_token`,null,null),this.hidePaymentReadyMessage(),this.displayPaymentElement(),this.gateway.supports("place_order_button")||this.hidePlaceOrderButton()}getProcessingSelector(){return this.container}getProcessingMessage(){return null}fetchBillingToken(e){return this.showProcessing(),super.fetchBillingToken(e).then(e=>(this.hideProcessing(),e))}isReadyToCheckout(){return!(!(0,r.getFieldValue)(this.order_field_key,null)&&!(0,r.getFieldValue)(`${this.gateway.id}_payment_token`,null))}convertFormToData(){return(0,r.convertFormToJson)(s()("form.checkout"))}submit(e=null){e&&this.populateCheckoutFields(e),this.gateway.supports("create_payment_method")||(this.hidePaymentElement(),this.displayPlaceOrderButton()),this.update_required?this.triggerCheckoutUpdate(e):(this.isPaymentSectionPlacement()&&!this.context.isExpressCheckout()||this.submitForm(e),this.isPaymentSectionPlacement()&&this.displayPaymentReadyMessage())}triggerCheckoutUpdate(e){return new Promise(t=>{s()(document.body).one("updated_checkout",()=>{e?.vaultSetupToken&&this.needsShipping()?this.displayPaymentReadyMessage():this.submitForm(e),t()}),s()('[name="billing_country"],[name="billing_state"]').trigger("change"),this.shipToDifferentAddressChecked()&&s()('[name="shipping_country"],[name="shipping_state"]').trigger("change"),s()(document.body).trigger("update_checkout",{update_shipping_method:!1})})}submitForm(e){this.actions.applyFilters("checkout_submit_form",!0,e,this)&&this.getForm().submit()}shipToDifferentAddressChecked(){return!!s()('[name="ship_to_different_address"]')?.length&&s()('[name="ship_to_different_address"]').is(":checked")}getPaymentType(){return"checkout"}isValidationEnabled(){return this.settings.checkoutValidationEnabled}isSavedPaymentMethodSelected(){const e=`[name="wc-${this.id}-payment-token"]:checked`;return this.isPaymentGatewaySelected()&&s()(e).length>0&&"new"!==s()(e).val()}apiFormValidation(){const e={...this.convertFormToData(),context:this.context.getPage(),payment_method:this.id};return a()({method:"POST",url:(0,r.getRestRoute)("checkout/validation"),data:e}).catch(e=>{throw e})}onCheckoutError(){this.isPaymentGatewaySelected()&&(this.enablePlaceOrderButton(),this.isReadyToCheckout()&&this.displayPaymentReadyMessage(),this.actions.doAction(`checkout_error_${this.gateway.id}`,this))}enablePlaceOrderButton(){this.getPlaceOrderButton().prop("disabled",!1)}isCheckoutFormValid(){const e=[];return s()(".validate-required:visible").each((t,i)=>{const n=s()(i).find("input, select, textarea").first();if(n.length&&n.is(":visible")){const t=n.attr("name");"checkbox"===n.attr("type")?n.is(":checked")||e.push(t):""!==n.val()&&null!==n.val()||e.push(t)}}),0===e.length}}const _=y;class P extends _{initialize(){this.actions.addAction("updated_checkout",this.updatedCheckout.bind(this)),this.loadPayPalScript().then(async()=>{this.createPaymentElement()})}updatedCheckout(e){this.paypal&&this.createPaymentElement(),this.updateGatewaySettings(e)}needsShipping(){return this.cart.needsShipping()}validate(){return!0}submit(e=null){super.submit(e);const t=super.getElementContainer();t&&s()(t).hide()}getElementContainer(){if(this.settings?.expressElement){const e=document.querySelector(this.settings.expressElement);if(e)return e}return document.getElementById(`wc-${this.id}-express-button`)}onPaymentElementReady(){this.actions.doAction("payment_element_ready",this);const e=this.getElementContainer();e&&(s()(e).show(),this.addExpressClasses(s()(e))),s()(".wc-ppcp-express-checkout").show()}addExpressClasses(e){if(e.length&&this.gateway.buttons){const t=Object.keys(this.gateway.buttons).length;e.addClass(`button-count_${t}`)}}onClick(){s()('[name="terms"]').prop("checked",!0).trigger("change"),s()(`[name="payment_method"][value="${this.id}"]`).prop("checked",!0).trigger("click"),s()(`[name="wc-${this.id}-payment-token"][value="new"]`).trigger("click")}paymentMethodSelected(){}hidePaymentElement(){}}class b extends u{initialize(){this.actions.addAction("fragments_changed",this.onFragmentsChanged.bind(this)),this.actions.addAction("mini_cart_ready",this.onMiniCartReady.bind(this)),this.actions.addAction("mini_cart_updated",this.onMiniCartReady.bind(this)),super.initialize()}onFragmentsChanged(){this.cart.isEmpty()||super.initialize()}onMiniCartReady(){super.initialize()}onPaymentElementReady(){super.onPaymentElementReady(),s()(this.getElementContainer()).show()}getElementContainer(){const e=document.querySelectorAll(`.wc-ppcp-minicart-${this.id}`);return e&&e.length>0?e:(s()(".woocommerce-mini-cart__buttons").append(`<a id="wc-ppcp-minicart-${this.id}"></a>`),document.getElementById(`wc-ppcp-minicart-${this.id}`))}}(this.wcPPCP=this.wcPPCP||{}).controllers=t})();
(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var s in n)t.o(n,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:n[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wcPPCP.cart;var n=t.n(e);const s=window.wcPPCP.utils,i=window.wcPPCP.controllers,a=window.wcPPCP.context;var r=t.n(a);const o=window.jQuery;var l=t.n(o);const c=window.wcPPCP.actions;var p=t.n(c);const h=class{constructor({id:t,settings:e,controller:n}){this.id=t,this.settings=e,this.controller=n,this.paypal=null,this.capabilities=[],"payment_method"===this.settings.buttonPlacement&&this.capabilities.push("place_order_button"),this.actions=new(p())}initialize(){}setController(t){this.controller=t}setPayPal(t){this.paypal=t}async canMakePayment(){return!0}shouldCreateElement(t){return!0}async createPaymentElement(t){throw new Error("Must implement createPaymentElement()")}getOrderFieldKey(){return`${this.id}_paypal_order_id`}getTokenFieldKey(){return`${this.id}_payment_token`}enablePaymentElement(){}disablePaymentElement(){}destroyPaymentElement(){}validatePaymentElement(){return!0}supports(t){return this.capabilities.includes(t)}},d=class extends h{async onApprove(t,e=null){return t.orderID&&(0,s.setFieldValue)(this.getOrderFieldKey(),t.orderID,null),t.vaultSetupToken?this.handleVaultSetupToken(t):this.handleDirectPayment(t,e)}async handleVaultSetupToken(t){try{const e=await this.controller.createPaymentToken(t.vaultSetupToken,{order_id:t.orderID}),n=this.extractTokenCheckoutData(e);(0,s.setFieldValue)(`${this.id}_payment_token`,e.id,null),this.controller.submit(n)}catch(t){this.controller.submitError(t)}}async handleDirectPayment(t,e){try{let t={};if(e&&e.order){const n=await e.order.get();t=this.extractStandardizedCheckoutData(n)}this.controller.submit(t)}catch(t){this.controller.submitError(t)}}extractStandardizedCheckoutData(t){const e={};if(t?.payer){let n={};t.payer.address&&(n={...(0,s.convertPayPalAddressToCart)(t.payer.address)}),t.payer.name&&(n.first_name=t.payer.name.given_name,n.last_name=t.payer.name.surname),t.payer.email_address&&(n.email=t.payer.email_address),t.payer.phone?.phone_number?.national_number&&(n.phone=t.payer.phone.phone_number.national_number),e.billing=n}if(t?.purchase_units?.[0]?.shipping){let n={};const i=t.purchase_units[0].shipping;if(i.address&&(n={...(0,s.convertPayPalAddressToCart)(i.address)}),i.name?.full_name){const t=(0,s.extractFullName)(i.name.full_name);n.first_name=t[0],n.last_name=t[1]}e.shipping=n}return e}extractTokenCheckoutData(t){const e={};if(t?.payment_source?.paypal){let n={};const i=t.payment_source.paypal;if(i.name&&(n.first_name=i.name.given_name||"",n.last_name=i.name.surname||""),i.email_address&&(n.email=i.email_address),i.phone?.phone_number?.national_number&&(n.phone=i.phone.phone_number.national_number),e.billing=n,i.shipping?.address){let t={};const n=i.shipping;if(t={...(0,s.convertPayPalAddressToCart)(n.address)},n.name?.full_name){const e=(0,s.extractFullName)(n.name.full_name);t.first_name=e[0],t.last_name=e[1]}e.shipping=t}}if(t?.payment_source?.card){let n={};const i=t.payment_source.card;if(i.name){const t=(0,s.extractFullName)(i.name);n.first_name=t[0],n.last_name=t[1]}if(i.billing_address){const t=(0,s.convertPayPalAddressToCart)(i.billing_address);n={...n,...t}}e.billing=n}return e}onCancel(t,e){this.orderId=t?.orderID||null,l()(document.body).triggerHandler("wc_ppcp_on_cancel",[this,e,t]),this.controller.onCancel()}onError(t,e=null){this.controller.onError(t,e)}onDestroy(t){l()(document.body).triggerHandler("wc_ppcp_on_destroy",[this.controller,t])}},u=class extends d{constructor(t){super(t),this.capabilities=[...this.capabilities,"disable_for_terms"],this.buttonActions={},this.buttons={}}initialize(){this.controller.context.isCheckout()&&this.actions.addFilter("field_population_options",this.getFieldOptions.bind(this),10,2)}getFieldOptions(t,e){return e===this.controller&&e.isPaymentGatewaySelected()&&(t.skipShipping=!!this.settings.paypalAddressDisabled),t}shouldCreateElement(t){return!l()(t).find(".paypal-buttons").length}async canMakePayment(){return!!this.paypal}async createPaymentElement(t){this.buttons={},this.buttonActions={};const e=this.getFunding(this.controller.context.getPage()),n=this.getSortedFunding(e),s=[];for(const e of n){const n=this.getButtonOptions(e),i=this.paypal.Buttons(n);this.buttons[e]=i,i.isEligible()&&s.push(i.render(t).catch(()=>{}))}return await Promise.all(s),this.buttons}getFunding(t){const e=[],n=this.settings;return this.controller.context.isProduct()?(this.settings?.product?.funding?.includes("paypal")&&e.push(this.paypal.FUNDING.PAYPAL),this.settings?.product?.funding?.includes("paylater")&&e.push(this.paypal.FUNDING.PAYLATER),this.settings?.product?.funding?.includes("card")&&e.push(this.paypal.FUNDING.CARD)):(this.isFundingActive("paypal")&&n?.paypal_sections?.includes(t)&&e.push(this.paypal.FUNDING.PAYPAL),this.isFundingActive("paylater")&&n?.paylater_sections?.includes(t)&&e.push(this.paypal.FUNDING.PAYLATER),this.isFundingActive("card")&&n?.credit_card_sections?.includes(t)&&e.push(this.paypal.FUNDING.CARD),this.isFundingActive("venmo")&&n?.venmo_sections?.includes(t)&&e.push(this.paypal.FUNDING.VENMO)),e}getSortedFunding(t){const e=this.settings.buttons_order||[];return t.sort((t,n)=>e.indexOf(t)<e.indexOf(n)?-1:1),t}getButtonOptions(t){const e={fundingSource:t,style:this.getButtonStyle(t),onInit:(e,n)=>{this.buttonActions[t]=n,l()(document.body).triggerHandler("wc_ppcp_on_init",[this.controller,t]),(this.controller.context.isCheckout()||this.controller.context.isOrderPay())&&this.controller.isTermsVisible()&&this.controller.handleTermsClick(),this.controller.context.isProduct()&&this.controller?.$paymentElement?.length&&this.controller.$paymentElement.is(".disabled")&&this.disablePaymentElement()},onClick:(...e)=>this.onClick(t),onApprove:(t,e)=>this.onApprove(t,e),onCancel:(e=null)=>this.onCancel(e,t),onError:e=>{this.onError(e,t)},onDestroy:()=>{this.onDestroy(t)},createOrder:(t,e)=>this.controller.createOrder(t,e)};return this.controller.needsShipping()&&t!==this.paypal.FUNDING.VENMO&&(e.onShippingChange=(...t)=>this.onShippingChange(...t)),this.settings.needsSetupToken&&(e.createOrder=null,e.createVaultSetupToken=(...t)=>this.controller.createVaultSetupToken()),e}async onShippingChange(t,e){const n=(0,s.convertPayPalAddressToCart)(t?.shipping_address||{},!0),i=t?.selected_shipping_option?.id||"";try{return(await this.controller.onShippingChange({address:n,shipping_method:i,order_id:t.orderID})).code?e.reject():e.resolve()}catch(t){return e.reject()}}onClick(t){this.controller.onClick(),this.controller.validate(),l()(document.body).triggerHandler("wc_ppcp_on_click",[this.controller,t])}getButtonStyle(t){let e=null;switch(t){case this.paypal.FUNDING.PAYPAL:e=this.settings?.buttons?.paypal;break;case this.paypal.FUNDING.PAYLATER:e=this.settings?.buttons?.paylater;break;case this.paypal.FUNDING.CARD:e={...this.settings?.buttons?.card},e.tagline?(delete e.tagline,e.layout="vertical"):e.layout="horizontal";break;case this.paypal.FUNDING.VENMO:const{color:t="",label:n="",...s}=this.settings?.buttons?.paypal;e=s}return e?.height&&(e.height=parseInt(e.height)),e}enablePaymentElement(){Object.keys(this.buttonActions||{}).forEach(t=>{this.buttonActions[t]?.enable()})}disablePaymentElement(){Object.keys(this.buttonActions||{}).forEach(t=>{this.buttonActions[t]?.disable()})}destroyPaymentElement(){Object.keys(this.buttons||{}).forEach(t=>{this.buttons[t]?.close&&this.buttons[t].close()}),this.buttons={},this.buttonActions={}}isFundingActive(t){return this.settings?.funding?.includes(t)}};if((0,s.isPluginConnected)()){const t=(0,s.getSetting)("ppcp_data"),e=new u({id:"ppcp",cart:n(),settings:t,controller:null});new i.CartController({id:"ppcp",cart:n(),context:new(r())("cart"),gateway:e,settings:t}).initialize()}(this.wcPPCP=this.wcPPCP||{}).paypalCart={}})();
function wcml_reset_cart_fragments(){try{document.body.dispatchEvent(new Event("wc_fragment_refresh")),sessionStorage.removeItem("wc_fragments")}catch(err){}}function wcml_cart_clear_removed_items(){var xhr=new XMLHttpRequest,formData=new FormData;formData.append("action","wcml_cart_clear_removed_items"),formData.append("wcml_nonce",document.querySelector("#wcml_clear_removed_items_nonce").value),xhr.open("POST",woocommerce_params.ajax_url),xhr.onload=function(){200===xhr.status&&(window.location=window.location.href)},xhr.send(formData)}document.addEventListener("DOMContentLoaded",(function(){document.addEventListener("click",(function(e){e.target.matches(".wcml_removed_cart_items_clear")&&(e.preventDefault(),wcml_cart_clear_removed_items())}))})),document.addEventListener("DOMContentLoaded",(function(){if(sessionStorage.getItem("wc_cart_created")){var name;actions.current_language!=sessionStorage.getItem("wcml_current_language")&&(sessionStorage.setItem("wcml_current_language",actions.current_language),actions.force_reset=1),(!sessionStorage.getItem("woocommerce_cart_hash")&&(name="woocommerce_cart_hash",!document.cookie.match("(^|;)\\s*"+name+"\\s*=\\s*([^;]+)")?.pop())||1==actions.force_reset)&&setTimeout(wcml_reset_cart_fragments,0)}}));
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function a(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return a(r||e)},p,p.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(e,t,r){"use strict";var n=e("./init"),a={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=a},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),a=e("./helpers/utils"),i={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",id:"id",platform:"plt",format:"fmt",tactic:"tct"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return i.aliases.main.type+"="+e.type+i.delimiter+i.aliases.main.source+"="+e.source+i.delimiter+i.aliases.main.medium+"="+e.medium+i.delimiter+i.aliases.main.campaign+"="+e.campaign+i.delimiter+i.aliases.main.content+"="+e.content+i.delimiter+i.aliases.main.term+"="+e.term+i.delimiter+i.aliases.main.id+"="+e.id+i.delimiter+i.aliases.main.platform+"="+e.platform+i.delimiter+i.aliases.main.format+"="+e.format+i.delimiter+i.aliases.main.tactic+"="+e.tactic},extra:function(e){return i.aliases.extra.fire_date+"="+a.setDate(new Date,e)+i.delimiter+i.aliases.extra.entrance_point+"="+document.location.href+i.delimiter+i.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return i.aliases.udata.visits+"="+e+i.delimiter+i.aliases.udata.ip+"="+t+i.delimiter+i.aliases.udata.agent+"="+navigator.userAgent},session:function(e){return i.aliases.session.pages_seen+"="+e+i.delimiter+i.aliases.session.current_page+"="+document.location.href},promo:function(e){return i.aliases.promo+"="+a.setLeadingZeroToInt(a.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=i},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={useBase64:!1,setBase64Flag:function(e){this.useBase64=e},encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,a){var i,s;if(r){var o=new Date;o.setTime(o.getTime()+60*r*1e3),i="; expires="+o.toGMTString()}else i="";s=n&&!a?";domain=."+n:"";var c=this.encodeData(t);this.useBase64&&(c=btoa(c).replace(/=+$/,"")),document.cookie=this.encodeData(e)+"="+c+i+s+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var a=r[n];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t)){var i=a.substring(t.length,a.length);if(/^[A-Za-z0-9+/]+$/.test(i))try{i=atob(i.padEnd(4*Math.ceil(i.length/4),"="))}catch(s){}return this.decodeData(i)}}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var a in e)e.hasOwnProperty(a)&&t.push(e[a]);for(var i=0;i<t.length;i++){var s;r[this.unsbjs(t[i])]={},s=this.get(t[i])?this.get(t[i]).split(n):[];for(var o=0;o<s.length;o++){var c=s[o].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[i])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},a=14;a--;)n[t.key[a]]=r[a]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,a){r&&(n[t.q.name][r]=a)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=(e||window.location.search.substring(1)).split("&"),n=0;n<r.length;n++){var a=r[n].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var i=[t[a[0]],a[1]];t[a[0]]=i}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),a=t||0===t?t:-r;return e.setHours(n+r+a),e.getFullYear()+"-"+this.setLeadingZeroToInt(e.getMonth()+1,2)+"-"+this.setLeadingZeroToInt(e.getDate(),2)+" "+this.setLeadingZeroToInt(e.getHours(),2)+":"+this.setLeadingZeroToInt(e.getMinutes(),2)+":"+this.setLeadingZeroToInt(e.getSeconds(),2)},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),a=e("./terms"),i=e("./helpers/cookies"),s=e("./helpers/uri"),o=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){var t,r,p,f,m,d,l,g,h,y,_,v,b,x=c.fetch(e),k=s.getParam(),w=x.domain.host,q=x.domain.isolate,I=x.lifetime;function j(e){switch(e){case a.traffic.utm:t=a.traffic.utm,r="undefined"!=typeof k.utm_source?k.utm_source:"undefined"!=typeof k.gclid?"google":"undefined"!=typeof k.yclid?"yandex":a.none,p="undefined"!=typeof k.utm_medium?k.utm_medium:"undefined"!=typeof k.gclid?"cpc":"undefined"!=typeof k.yclid?"cpc":a.none,f="undefined"!=typeof k.utm_campaign?k.utm_campaign:"undefined"!=typeof k[x.campaign_param]?k[x.campaign_param]:"undefined"!=typeof k.gclid?"google_cpc":"undefined"!=typeof k.yclid?"yandex_cpc":a.none,m="undefined"!=typeof k.utm_content?k.utm_content:"undefined"!=typeof k[x.content_param]?k[x.content_param]:a.none,l=k.utm_id||a.none,g=k.utm_source_platform||a.none,h=k.utm_creative_format||a.none,y=k.utm_marketing_tactic||a.none,d="undefined"!=typeof k.utm_term?k.utm_term:"undefined"!=typeof k[x.term_param]?k[x.term_param]:function(){var e=document.referrer;if(k.utm_term)return k.utm_term;if(!(e&&s.parse(e).host&&s.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return s.getParam(s.parse(document.referrer).query).text}catch(t){return!1}}()||a.none;break;case a.traffic.organic:t=a.traffic.organic,r=r||s.getHost(document.referrer),p=a.referer.organic,f=a.none,m=a.none,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;case a.traffic.referral:t=a.traffic.referral,r=r||s.getHost(document.referrer),p=p||a.referer.referral,f=a.none,m=s.parse(document.referrer).path,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;case a.traffic.typein:t=a.traffic.typein,r=x.typein_attributes.source,p=x.typein_attributes.medium,f=a.none,m=a.none,d=a.none,l=a.none,g=a.none,h=a.none,y=a.none;break;default:t=a.oops,r=a.oops,p=a.oops,f=a.oops,m=a.oops,d=a.oops,l=a.oops,g=a.oops,h=a.oops,y=a.oops}var i={type:t,source:r,medium:p,campaign:f,content:m,term:d,id:l,platform:g,format:h,tactic:y};return n.pack.main(i)}function R(e){var t=document.referrer;switch(e){case a.traffic.organic:return!!t&&H(t)&&function(e){var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp("yandex")+"\\..{2,9}$"),n=new RegExp(".*"+o.escapeRegexp("text")+"=.*"),a=new RegExp("^(?:www\\.)?"+o.escapeRegexp("google")+"\\..{2,9}$");if(s.parse(e).query&&s.parse(e).host.match(t)&&s.parse(e).query.match(n))return r="yandex",!0;if(s.parse(e).host.match(a))return r="google",!0;if(!s.parse(e).query)return!1;for(var i=0;i<x.organics.length;i++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(x.organics[i].host)+"$","i"))&&s.parse(e).query.match(new RegExp(".*"+o.escapeRegexp(x.organics[i].param)+"=.*","i")))return r=x.organics[i].display||x.organics[i].host,!0;if(i+1===x.organics.length)return!1}}(t);case a.traffic.referral:return!!t&&H(t)&&function(e){if(!(x.referrals.length>0))return r=s.getHost(e),!0;for(var t=0;t<x.referrals.length;t++){if(s.parse(e).host.match(new RegExp("^(?:.*\\.)?"+o.escapeRegexp(x.referrals[t].host)+"$","i")))return r=x.referrals[t].display||x.referrals[t].host,p=x.referrals[t].medium||a.referer.referral,!0;if(t+1===x.referrals.length)return r=s.getHost(e),!0}}(t);default:return!1}}function H(e){if(x.domain){if(q)return s.getHost(e)!==s.getHost(w);var t=new RegExp("^(?:.*\\.)?"+o.escapeRegexp(w)+"$","i");return!s.getHost(e).match(t)}return s.getHost(e)!==s.getHost(document.location.href)}function D(){i.set(n.containers.current_extra,n.pack.extra(x.timezone_offset),I,w,q),i.get(n.containers.first_extra)||i.set(n.containers.first_extra,n.pack.extra(x.timezone_offset),I,w,q)}return i.setBase64Flag(x.base64),u.go(I,w,q),i.set(n.containers.current,function(){var e;if("undefined"!=typeof k.utm_source||"undefined"!=typeof k.utm_medium||"undefined"!=typeof k.utm_campaign||"undefined"!=typeof k.utm_content||"undefined"!=typeof k.utm_term||"undefined"!=typeof k.utm_id||"undefined"!=typeof k.utm_source_platform||"undefined"!=typeof k.utm_creative_format||"undefined"!=typeof k.utm_marketing_tactic||"undefined"!=typeof k.gclid||"undefined"!=typeof k.yclid||"undefined"!=typeof k[x.campaign_param]||"undefined"!=typeof k[x.term_param]||"undefined"!=typeof k[x.content_param])D(),e=j(a.traffic.utm);else if(R(a.traffic.organic))D(),e=j(a.traffic.organic);else if(!i.get(n.containers.session)&&R(a.traffic.referral))D(),e=j(a.traffic.referral);else{if(i.get(n.containers.first)||i.get(n.containers.current))return i.get(n.containers.current);D(),e=j(a.traffic.typein)}return e}(),I,w,q),i.get(n.containers.first)||i.set(n.containers.first,i.get(n.containers.current),I,w,q),i.get(n.containers.udata)?(_=parseInt(i.parse(n.containers.udata)[i.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,_=i.get(n.containers.session)?_:_+1,v=n.pack.user(_,x.user_ip)):(_=1,v=n.pack.user(_,x.user_ip)),i.set(n.containers.udata,v,I,w,q),i.get(n.containers.session)?(b=parseInt(i.parse(n.containers.session)[i.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,b+=1):b=1,i.set(n.containers.session,n.pack.session(b),x.session_length,w,q),x.promocode&&!i.get(n.containers.promocode)&&i.set(n.containers.promocode,n.pack.promo(x.promocode),I,w,q),i.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),a=e("./helpers/cookies");t.exports={go:function(e,t,r){var i,s=this.migrations,o={l:e,d:t,i:r};if(a.get(n.containers.first)||a.get(n.service.migrations)){if(!a.get(n.service.migrations))for(i=0;i<s.length;i++)s[i].go(s[i].id,o)}else{var c=[];for(i=0;i<s.length;i++)c.push(s[i].id);var u="";for(i=0;i<c.length;i++)u+=c[i]+"=1",i<c.length-1&&(u+=n.delimiter);a.set(n.service.migrations,u,o.l,o.d,o.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",i=e+"=0",s=function(e,t,r){return t||r?e:n.delimiter};try{var o=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&o.push(n.containers[c]);for(var u=0;u<o.length;u++)if(a.get(o[u])){var p=a.get(o[u]).replace(/(\|)?\|(\|)?/g,s);a.destroy(o[u],t.d,t.i),a.destroy(o[u],t.d,!t.i),a.set(o[u],p,t.l,t.d,t.i)}a.get(n.containers.session)&&a.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),a.set(n.service.migrations,r,t.l,t.d,t.i)}catch(f){a.set(n.service.migrations,i,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),a=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.base64=t.base64||!1,r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:a.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var i=0;i<t.referrals.length;i++)t.referrals[i].host&&r.referrals.push(t.referrals[i]);if(r.organics=[],t.organics&&t.organics.length>0)for(var s=0;s<t.organics.length;s++)t.organics[s].host&&t.organics[s].param&&r.organics.push(t.organics[s]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
!function(t){"use strict";const e=t.params,n=(document.querySelector.bind(document),(t,e)=>e.split(".").reduce((t,e)=>t&&t[e],t)),i=()=>null,s=t=>null===t||t===undefined?"":t,o="wc/store/checkout";function a(t){document.querySelectorAll("wc-order-attribution-inputs").forEach((t,e)=>{e>0&&t.remove()});for(const e of document.querySelectorAll("wc-order-attribution-inputs"))e.values=t}function r(t){window.wp&&window.wp.data&&window.wp.data.dispatch&&window.wc&&window.wc.wcBlocksData&&window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).setExtensionData("woocommerce/order-attribution",t,!0)}function c(){return"undefined"!=typeof sbjs}function d(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const e=window.wp.data.subscribe(function(){e(),r(t.getAttributionData())},o)}}t.getAttributionData=function(){const s=e.allowTracking&&c()?n:i,o=c()?sbjs.get:{},a=Object.entries(t.fields).map(([t,e])=>[t,s(o,e)]);return Object.fromEntries(a)},t.setOrderTracking=function(n){if(e.allowTracking=n,n){if(!c())return;sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),base64:Boolean(e.base64),timezone_offset:"0"})}else!function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();const i=t.getAttributionData();a(i),r(i)},t.setOrderTracking(e.allowTracking),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d):d(),window.customElements.define("wc-order-attribution-inputs",class extends HTMLElement{constructor(){if(super(),this._fieldNames=Object.keys(t.fields),this.hasOwnProperty("_values")){let t=this.values;delete this.values,this.values=t||{}}}connectedCallback(){this.innerHTML="";const t=new DocumentFragment;for(const n of this._fieldNames){const i=document.createElement("input");i.type="hidden",i.name=`${e.prefix}${n}`,i.value=s(this.values&&this.values[n]||""),t.appendChild(i)}this.appendChild(t)}set values(t){if(this._values=t,this.isConnected)for(const t of this._fieldNames){const n=this.querySelector(`input[name="${e.prefix}${t}"]`);n?n.value=s(this.values[t]):console.warn(`Field "${t}" not found. `+"Most likely, the '<wc-order-attribution-inputs>' element was manipulated.")}}get values(){return this._values}})}(window.wc_order_attribution);