// source --> https://worldmobile.international/wp-content/plugins/woocommerce-payments/dist/express-checkout.js?ver=11.0.0 
(()=>{var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var o in a)e.o(a,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:a[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};(()=>{var t;globalThis.importScripts&&(t=globalThis.location+"");var a=globalThis.document;if(!t&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(t=a.currentScript.src),!t)){var o=a.getElementsByTagName("script");if(o.length)for(var r=o.length-1;r>-1&&(!t||!/^http(s?):/.test(t));)t=o[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),e.p=window.wcpayAssets.url,(()=>{"use strict";const t=window.wp.i18n,a=window.wp.hooks,o=e=>"undefined"!=typeof wcpayConfig&&void 0!==wcpayConfig[e]?wcpayConfig[e]:r(e),r=e=>{let t=null;if("undefined"!=typeof wcpay_upe_config)t=wcpay_upe_config;else{if("object"!=typeof wc||void 0===wc.wcSettings)return null;t=wc.wcSettings.getSetting("woocommerce_payments_data")||{}}return t[e]||null},n=e=>"object"==typeof wcpayExpressCheckoutParams&&wcpayExpressCheckoutParams.hasOwnProperty(e)?wcpayExpressCheckoutParams[e]:null;class s{constructor(e,t){this.options=e,this.stripe=null,this.stripePlatform=null,this.request=t}createStripe(e,t,a="",o=[]){const r={locale:t};return a&&(r.stripeAccount=a),o&&(r.betas=o),new Stripe(e,r)}async getStripeForUPE(e){return this.options.forceNetworkSavedCards=r("paymentMethodsConfig")[e].forceNetworkSavedCards,this.getStripe()}async getStripe(e=!1){let t=0;for(;!window.Stripe;)if(await new Promise(e=>setTimeout(e,100)),t+=100,t>6e5)throw new Error("Stripe object not found");return this.__getStripe(e)}__getStripe(e=!1){const{publishableKey:t,accountId:a,forceNetworkSavedCards:o,locale:r,isStripeLinkEnabled:n}=this.options;if(o&&!e)return this.stripePlatform||(this.stripePlatform=this.createStripe(t,r)),this.stripePlatform;if(!this.stripe){let e=["card_country_event_beta_1"];n&&(e=e.concat(["link_autofill_modal_beta_1"])),this.stripe=this.createStripe(t,r,a,e)}return this.stripe}async loadStripeForExpressCheckout(){try{return await this.getStripe(!0)}catch(e){return{error:e}}}confirmIntent(e,t=!1){const a=e.match(/#wcpay-confirm-(pi|si):([^:]+):([^:]+):([^:]+)(?::(.+))?$/);if(!a)return!0;const r="si"===a[1];let s=a[2];const i=a[3],c=a[4],p=a[5]||null,l=e.indexOf("order-pay"),u=l>-1&&e.substring(l).match(/\d+/);return u&&(s=u[0]),(async()=>{const{locale:e,publishableKey:t}=this.options,a=o("accountIdForIntentConfirmation");if(r){const e=await this.getStripe(!0);return p?e.confirmSetup({clientSecret:i,confirmParams:{confirmation_token:p},redirect:"if_required"}):e.handleNextAction({clientSecret:i})}return a?this.createStripe(t,e,a).confirmCardPayment(i):(await this.getStripe(!0)).handleNextAction({clientSecret:i})})().then(e=>{let a=null;e.paymentIntent?.last_payment_error&&(a={message:e.paymentIntent.last_payment_error.message}),"requires_action"===e.paymentIntent?.status&&(a={message:"Payment requires additional action."});const r=e.paymentIntent&&e.paymentIntent.id||e.setupIntent&&e.setupIntent.id||e.error&&e.error.payment_intent&&e.error.payment_intent.id||e.error.setup_intent&&e.error.setup_intent.id,i=n("ajax_url")??o("ajaxUrl"),p=o("isChangingPayment");return[this.request(i,{action:"update_order_status",order_id:s,_ajax_nonce:c,intent_id:r,should_save_payment_method:t?"true":"false",is_changing_payment:p?"true":"false"}),a,e.error]}).then(([e,t,a])=>{if(a)throw a;return e.then(e=>{const a="string"==typeof e?JSON.parse(e):e;if(a.error)throw a.error;if(t)throw t;return a.return_url})})}async setupIntent(e,t=""){const a=await this.request(o("ajaxUrl"),{action:"create_setup_intent","wcpay-payment-method":e,_ajax_nonce:o("createSetupIntentNonce"),"wcpay-fraud-prevention-token":window.wcpayFraudPreventionToken??"","wcpay-fingerprint":t});if(!a.success)throw a.data.error;if("succeeded"===a.data.status)return a.data;const r=await this.getStripe(),n=await r.confirmCardSetup(a.data.client_secret),{setupIntent:s,error:i}=n;if(i)throw i;return s}expressCheckoutAddToCart(e){const t=o("wcAjaxUrl"),a=o("addToCartNonce");return this.request(((e,t,a="wcpay_")=>e.toString().replace("%%endpoint%%",a+t))(t,"add_to_cart"),{security:a,...e})}}jQuery(e=>{e("input[name=wc_deposit_option],input[name=wc_deposit_payment_plan]").on("change",()=>{(0,a.doAction)("wcpay.express-checkout.update-button-data")})}),(0,a.addFilter)("wcpay.express-checkout.cart-add-item","automattic/wcpay/express-checkout",e=>{const t={};return jQuery("input[name=wc_deposit_option]").length&&(t.wc_deposit_option=jQuery("input[name=wc_deposit_option]:checked").val()),jQuery("input[name=wc_deposit_payment_plan]").length&&(t.wc_deposit_payment_plan=jQuery("input[name=wc_deposit_payment_plan]:checked").val()),{...e,...t}});const i="wcpay-express-checkout__order-attribution-inputs",c=()=>{(()=>{if(document.getElementById(i))return;const e=document.createElement("wc-order-attribution-inputs");e.id=i,document.body.appendChild(e)})(),window?.wc_order_attribution?.setOrderTracking(window?.wc_order_attribution?.params?.allowTracking)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",c):c(),(0,a.addFilter)("wcpay.express-checkout.cart-place-order-extension-data","automattic/wcpay/express-checkout",e=>{const t=jQuery("#wcpay-express-checkout__order-attribution-inputs input");if(!t.length)return e;const a={};return t.each(function(){const e=jQuery(this).attr("name").replace("wc_order_attribution_",""),t=jQuery(this).val();e&&t&&(a[e]=t)}),{...e,"woocommerce/order-attribution":a}});let p=null,l=null;const u=()=>jQuery(l),d={init:({elementId:e,$separator:t})=>{l=e,p=t},getButtonSeparator:()=>p,blockButton:()=>{u().data("blockUI.isBlocked")||u().block({message:null})},unblockButton:()=>{d.showContainer(),u().unblock()},renderButton:e=>{u()?.length&&e.mount(l)},hideContainer:()=>{u().removeClass("is-ready").hide()},showContainer:()=>{u().addClass("is-ready").show()}},m=d,y=(e,t,a=!1)=>{let o;return function(){const r=this,n=arguments,s=a&&!o;clearTimeout(o),o=setTimeout(()=>{o=null,a||t.apply(r,n)},e),s&&t.apply(r,n)}},_=e=>void 0!==window.wcpayExpressCheckoutParams?window.wcpayExpressCheckoutParams[e]??null:void 0!==window.wc?.wcSettings?window.wc.wcSettings.getSetting("ece_data")?.[e]??null:null,h=()=>document.querySelector(".single_add_to_cart_button")||document.querySelector('.wp-block-add-to-cart-with-options button[type="submit"]'),w=()=>{const e=document.querySelector(".single_add_to_cart_button");if(e?.value)return e.value;const t=document.querySelector('form.cart input[name="product_id"]');if(t?.value)return t.value;const a=document.querySelector('.wp-block-add-to-cart-with-options input[name="add-to-cart"]');return a?.value},g=()=>{const e=document.querySelector(".quantity .qty");return e&&parseFloat(e.value)||1},f=()=>!!document.querySelector(".wp-block-add-to-cart-with-options"),b=()=>document.querySelectorAll(".wp-block-add-to-cart-with-options .wp-block-woocommerce-add-to-cart-with-options-variation-selector-attribute"),k=()=>{const e=[];return b().forEach(t=>{let a;try{a=JSON.parse(t.dataset.wpContext)?.name}catch(e){a=void 0}if(!a)return;const o=t.querySelector("select"),r=o?o.value:t.querySelector('[aria-checked="true"]')?.value;r&&e.push({attribute:a,value:r})}),e},x=()=>{if(f()){const e=document.querySelector(".wp-block-add-to-cart-with-options");return!!e&&e.classList.contains("is-invalid")}const e=h();return!!e&&e.classList.contains("disabled")};jQuery(e=>{e(document.body).on("woocommerce_variation_has_changed",async()=>{(0,a.doAction)("wcpay.express-checkout.update-button-data")});const t=b();if(t.length){let e=null;const o=new MutationObserver(y(250,()=>{const t=JSON.stringify(k());t!==e&&(e=t,(0,a.doAction)("wcpay.express-checkout.update-button-data"))}));t.forEach(e=>o.observe(e,{subtree:!0,childList:!0,attributes:!0}))}}),jQuery(e=>{if("product"!==_("button_context"))return;const t=e(".quantity");t.on("input",".qty",()=>{m.blockButton()}),t.on("input",".qty",y(250,async()=>{(0,a.doAction)("wcpay.express-checkout.update-button-data")}))}),(0,a.addFilter)("wcpay.express-checkout.cart-add-item","automattic/wcpay/express-checkout",e=>{const t={...e},a=document.querySelector('.single_variation_wrap input[name="product_id"]');a&&(t.id=parseInt(a.value,10));const o=f()?k():(()=>{const e=document.querySelector(".variations_form");if(!e)return[];const t=[];return e.querySelectorAll(".variations select").forEach(e=>{const a=e.dataset.attribute_name||e.dataset.name;if(!a)return;const o=document.querySelector(`label[for="${a.replace("attribute_","")}"]`);o&&t.push({attribute:Array.from(o.childNodes)[0].textContent,value:e.value||""}),t.push({attribute:a,value:e.value||""})}),t})();return o.length&&(t.variation=[...e.variation,...o]),t}),(0,a.addFilter)("wcpay.express-checkout.map-line-items","automattic/wcpay/express-checkout",e=>({...e,items:e.items.filter(e=>!e.extensions?.bundles?.bundled_by)}));const v=window.wp.htmlEntities,C=(e,t)=>{const a=_("checkout")?.stripe_minor_unit??2,o=e*10**(a-t.currency_minor_unit);return a<t.currency_minor_unit?Math.round(o):o},S=e=>{const o=_("checkout").display_prices_with_tax,r=(0,a.applyFilters)("wcpay.express-checkout.map-line-items",e),n=r.items.map(e=>({amount:C(o&&e.totals?parseInt(e.totals.line_subtotal,10)+parseInt(e.totals.line_subtotal_tax,10):parseInt(e.totals?.line_subtotal||e.prices.price,10),e.totals||e.prices),name:[e.name,e.quantity>1&&`(x${e.quantity})`,e.variation&&e.variation.length>0&&"-",e.variation&&e.variation.map(e=>`${e.attribute}: ${e.value}`).join(", "),e.item_data&&e.item_data.length>0&&"-",e.item_data&&e.item_data.map(e=>`${e.name||e.key}: ${e.value}`).join(", ")].filter(Boolean).map(v.decodeEntities).join(" ")})),s=parseInt(r.totals.total_shipping||"0",10);s&&n.push({amount:C(o?s+parseInt(r.totals.total_shipping_tax||"0",10):s,r.totals),name:(0,t.__)("Shipping","woocommerce-payments")});const i=parseInt(r.totals.total_discount||"0",10);i&&n.push({amount:-C(o?i+parseInt(r.totals.total_discount_tax||"0",10):i,r.totals),name:(0,t.__)("Discount","woocommerce-payments")});const c=parseInt(r.totals.total_fees||"0",10);c&&n.push({amount:C(o?c+parseInt(r.totals.total_fees_tax||"0",10):c,r.totals),name:(0,t.__)("Fees","woocommerce-payments")});const p=parseInt(r.totals.total_tax||"0",10);p&&!o&&n.push({amount:C(p,r.totals),name:(0,t.__)("Tax","woocommerce-payments")});const l=parseInt(r.totals.total_refund||"0",10);return l&&n.push({amount:-C(l,r.totals),name:(0,t.__)("Refund","woocommerce-payments")}),C(parseInt(r.totals.total_price,10)-parseInt(r.totals.total_refund||0,10),r.totals)<n.reduce((e,{amount:t})=>e+t,0)?[]:n},P=e=>{const t=_("checkout").display_prices_with_tax,o=e.shipping_rates?.[0]?.shipping_rates||[],r=(0,a.applyFilters)("wcpay.express-checkout.shipping-rates",o,e);return r&&0!==r.length?r.sort((e,t)=>e.selected===t.selected?0:e.selected?-1:1).slice(0,9).map(e=>({id:e.rate_id,displayName:(0,v.decodeEntities)(e.name),amount:C(t?parseInt(e.price,10)+parseInt(e.taxes,10):parseInt(e.price,10),e),deliveryEstimate:[e.meta_data.find(e=>"pickup_address"===e.key)?.value,e.meta_data.find(e=>"pickup_details"===e.key)?.value].filter(Boolean).map(v.decodeEntities).join(" - ")})):[]},I=e=>{const t=e?.extensions?.subscriptions;return!!t&&t.trial_length>0},E=e=>{const t=e?.extensions?.subscriptions;if(!t||!Array.isArray(t))return null;for(const e of t){const t=e.shipping_rates?.[0]?.shipping_rates;if(t?.length>0)return t}return null},T=e=>!(!e?.items||!e?.extensions?.subscriptions)&&(!!e.items.some(I)&&(!(e.shipping_rates?.[0]?.shipping_rates?.length>0)&&null!==E(e))),q=e=>!(!e?.items||!e?.extensions?.subscriptions)&&e.items.some(I),j=e=>!!q(e)&&0===parseInt(e.totals?.total_price||"0",10),A=e=>{const t=e?.extensions?.subscriptions;if(!t||!Array.isArray(t))return null;let a=0,o=0,r=0,n=0,s=0,i=2;const c=[];if(t.forEach(e=>{if(!e.totals?.total_price)return;a+=parseInt(e.totals.total_price,10),o+=parseInt(e.totals.total_items||"0",10),r+=parseInt(e.totals.total_tax||"0",10);const t=e.shipping_rates?.[0]?.shipping_rates?.find(e=>e.selected);t?(n+=parseInt(t.price||"0",10),s+=parseInt(t.taxes||"0",10)):(n+=parseInt(e.totals.total_shipping||"0",10),s+=parseInt(e.totals.total_shipping_tax||"0",10)),i=e.totals.currency_minor_unit??i,e.totals.tax_lines&&c.push(...e.totals.tax_lines)}),0===a)return null;const p=t[0]?.totals||e.totals;return{amount:a,currencyMinorUnit:i,totals:{...p,total_price:String(a),total_items:String(o),total_tax:String(r),total_shipping:String(n),total_shipping_tax:String(s),tax_lines:c}}},F=e=>{const a=e.totals,o=parseInt(a.total_price,10),r=a.currency_minor_unit??2,n=a.currency_prefix??"",s=a.currency_suffix??"",i=a.currency_decimal_separator??".",c=a.currency_thousand_separator??",",p=(o/Math.pow(10,r)).toFixed(r).split("."),l=p[0].replace(/\B(?=(\d{3})+(?!\d))/g,c),u=`${n}${p[1]?`${l}${i}${p[1]}`:l}${s}`,d=(m=e.billing_period,(y=e.billing_interval??1)>1?{day:(0,t.sprintf)((0,t._n)("%d day","%d days",y,"woocommerce-payments"),y),week:(0,t.sprintf)((0,t._n)("%d week","%d weeks",y,"woocommerce-payments"),y),month:(0,t.sprintf)((0,t._n)("%d month","%d months",y,"woocommerce-payments"),y),year:(0,t.sprintf)((0,t._n)("%d year","%d years",y,"woocommerce-payments"),y)}[m]||`${y} ${m}s`:{day:(0,t.__)("day","woocommerce-payments"),week:(0,t.__)("week","woocommerce-payments"),month:(0,t.__)("month","woocommerce-payments"),year:(0,t.__)("year","woocommerce-payments")}[m]||m);var m,y;return(0,t.sprintf)((0,t.__)("%1$s / %2$s","woocommerce-payments"),u,d)};(0,a.addFilter)("wcpay.express-checkout.total-amount","automattic/wcpay/express-checkout/wc-subscriptions",(e,t)=>{if(!j(t))return e;const a=A(t);return a?C(a.amount,a.totals):e}),(0,a.addFilter)("wcpay.express-checkout.is-cart-eligible","automattic/wcpay/express-checkout/wc-subscriptions",(e,t)=>{if(e)return!0;if(j(t)){const e=A(t);return null!==e&&e.amount>0}return e}),(0,a.addFilter)("wcpay.express-checkout.shipping-rates","automattic/wcpay/express-checkout/wc-subscriptions",(e,t)=>e&&e.length>0?e:T(t)&&E(t)||e),(0,a.addFilter)("wcpay.express-checkout.shipping-package-id","automattic/wcpay/express-checkout/wc-subscriptions",(e,t,a)=>{if(!T(t))return e;const o=t?.extensions?.subscriptions;if(!o||!Array.isArray(o))return e;for(const e of o){const t=e.shipping_rates;if(t&&Array.isArray(t))for(const e of t){const t=e?.shipping_rates?.some(e=>e.rate_id===a);if(t&&e.package_id)return e.package_id}}return e}),(0,a.addFilter)("wcpay.express-checkout.map-line-items","automattic/wcpay/express-checkout/wc-subscriptions",e=>{if(!q(e))return e;const a=e?.extensions?.subscriptions;if(!a||!Array.isArray(a))return e;const o=0===parseInt(e.totals?.total_price||"0",10),r=[...e.items],n=(0,t.__)("Recurring total","woocommerce-payments");if(a.forEach(a=>{const s=e.items.filter(e=>e.extensions?.subscriptions?.billing_period===a.billing_period).length;if(0===s)return;const i=Math.round(parseInt(a.totals?.total_items||"0",10)/s);r.forEach((e,s)=>{const c=e.extensions?.subscriptions;c&&c.trial_length>0&&c.billing_period===a.billing_period&&((e.item_data||[]).some(e=>e.name===n)||(r[s]={...e,name:`${e.name} (${(0,t.__)("recurring","woocommerce-payments")})`,...o&&{totals:{...e.totals,line_subtotal:String(i),line_total:String(i)}},item_data:[...e.item_data||[],{name:(0,t.__)("Recurring total","woocommerce-payments"),value:(0,t.sprintf)((0,t.__)("%1$s on %2$s","woocommerce-payments"),F(a),a.next_payment_date)}]}))})}),!o)return{...e,items:r};const s=A(e);return s?{...e,items:r,totals:{...e.totals,total_price:String(s.amount),total_items:s.totals.total_items||"0",total_tax:s.totals.total_tax||"0",total_shipping:s.totals.total_shipping||"0",total_shipping_tax:s.totals.total_shipping_tax||"0",tax_lines:s.totals.tax_lines||[]}}:{...e,items:r}}),(0,a.addFilter)("wcpay.express-checkout.resolved-currency","automattic/wcpay/express-checkout/wcpbc",e=>"undefined"!=typeof wc_price_based_country_ajax_geo_params?(e=>new Promise(t=>{const a=jQuery(document.body),o=[],r=e=>{o.forEach(e=>e()),t(e)},n=(e,t)=>{t?.code&&r(String(t.code).toLowerCase())};a.on("wc_price_based_country_set_currency_params",n),o.push(()=>a.off("wc_price_based_country_set_currency_params",n));const s=setTimeout(()=>a.triggerHandler("wc_price_based_country_ajax_geolocation"),3e3);o.push(()=>clearTimeout(s));const i=setTimeout(async()=>r(await e),6e3);o.push(()=>clearTimeout(i))}))(e):e),(0,a.addFilter)("wcpay.express-checkout.resolved-currency","automattic/wcpay/express-checkout/mccy-async",e=>{if("undefined"==typeof wcpayAsyncPriceConfig)return e;const t=window.wcpayAsyncCurrency?.ready;return t&&"function"==typeof t.then?new Promise(a=>{const o=setTimeout(async()=>a(await e),6e3);t.then(t=>{clearTimeout(o),a(t?String(t).toLowerCase():e)})}):e});const $=e=>{let t="undefined"==typeof wcpaySettings?4:parseInt(window?.wcpaySettings?.defaultExpressCheckoutBorderRadius||4,10);const a=_("button");return t=a?.radius??t,void 0!==e&&(t=Number(e?.borderRadius)??t),{variables:{borderRadius:`${t}px`,spacingUnit:"6px"}}};let R=null;const N=e=>R||e;let B=null;const M=()=>B,O=e=>(e=>{const t=e?.extensions?.subscriptions;if(Array.isArray(t)&&t.length>0)return!0;const a=e?.items;return!!Array.isArray(a)&&a.some(e=>(e=>{if(Array.isArray(e))return e.length>0;if("object"!=typeof e||null===e)return!1;const t=e.billing_period,a=e.billing_interval;return"string"==typeof t&&t.length>0&&"number"==typeof a&&a>0})(e?.extensions?.subscriptions))})(e)?"off_session":null;function U(){return _("flags")?.isEceUsingConfirmationTokens??!0}const L=e=>{if(!e)return"";const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstChild?t.firstChild.textContent:""},Q=(e,t,a)=>{const o=document.querySelector(`${e} [name="${t}"]`);if(o)if("SELECT"===o.tagName&&/country|state/.test(t)){const e=Array.from(o.options).find(e=>e.value===a||e.textContent.trim().toLowerCase()===a.toLowerCase());e&&(o.value=e.value,jQuery(o).trigger("change").trigger("close"))}else o.value=a,jQuery(o).trigger("change")},z=window.lodash;window.wp.domReady;const D=(e,t={})=>{if(!1===(o("isShopperTrackingEnabled")??n("is_shopper_tracking_enabled")))return;const a=o("platformTrackerNonce")??n("nonce")?.platform_tracker,r=o("ajaxUrl")??n("ajax_url"),s=new FormData;s.append("tracksNonce",a),s.append("action","platform_tracks"),s.append("tracksEventName",e),s.append("tracksEventProp",JSON.stringify(t)),fetch(r,{method:"post",body:s}).then(e=>e.json())},H=(0,z.debounce)(({source:e})=>{D("applepay_button_load",{source:e})},1e3),W=(0,z.debounce)(({source:e})=>{D("gpay_button_load",{source:e})},1e3),X=window.wp.apiFetch;var G=e.n(X);const J=window.wp.url;class K{cartRequestHeaders={};async _request(e){const t=await G()({...e,parse:!1,path:(0,J.addQueryArgs)(e.path,{currency:N(_("checkout").currency_code).toUpperCase()}),headers:(0,z.omitBy)({Nonce:_("nonce").store_api_nonce,"X-WooPayments-Tokenized-Cart-Nonce":_("nonce").tokenized_cart_nonce,"X-WooPayments-Tokenized-Cart-Session-Nonce":"product"===_("button_context")?_("nonce").tokenized_cart_session_nonce:void 0,...this.cartRequestHeaders,...e.headers},z.isNil)});return this.cartRequestHeaders=(0,z.omitBy)({Nonce:t.headers.get("Nonce"),"X-WooPayments-Tokenized-Cart-Session":t.headers.get("X-WooPayments-Tokenized-Cart-Session")},z.isNil),t.json()}async placeOrder(e){const t=M();return await this._request({method:"POST",path:"/wc/store/v1/checkout",headers:{"X-WooPayments-Tokenized-Cart":!0,...t&&{"X-WooPayments-Payment-Currency":t},...this.cartRequestHeaders},data:e})}async getCart(){return await this._request({method:"GET",path:"/wc/store/v1/cart"})}useSeparateCart(){this.cartRequestHeaders={"X-WooPayments-Tokenized-Cart-Session":""}}deleteAfterRequest(){this.cartRequestHeaders={"X-WooPayments-Tokenized-Cart-Is-Ephemeral-Cart":"1"}}async updateCustomer(e){return await this._request({method:"POST",path:"/wc/store/v1/cart/update-customer",headers:{"X-WooPayments-Tokenized-Cart":!0,...this.cartRequestHeaders},data:e})}async selectShippingRate(e){return await this._request({method:"POST",path:"/wc/store/v1/cart/select-shipping-rate",data:e})}async addProductToCart(){const e={id:w(),quantity:g(),variation:[]};return await this._request({method:"POST",path:"/wc/store/v1/cart/add-item",data:(0,a.applyFilters)("wcpay.express-checkout.cart-add-item",e)})}async emptyCart(){try{let e=await this._request({method:"GET",path:"/wc/store/v1/cart"});for(;e.items.length>0;)e=await this._request({method:"POST",path:"/wc/store/v1/cart/remove-item",data:{key:e.items[0].key}})}catch(e){}}}const V=(e,t)=>({first_name:e?.split(" ")?.slice(0,1)?.join(" ")??"",last_name:e?.split(" ")?.slice(1)?.join(" ")??"",company:t.organization??"",address_1:t.line1??"",address_2:t.line2??"",city:t.city??"",state:t.state??"",postcode:t.postal_code??"",country:t.country??""}),Y=(e,t,a=!0,o=[])=>{const r=e.billingDetails?.name||"",n=e.billingDetails?.address??{},s=e.billingDetails?.phone?.replace(/[() -]/g,"")??e.payerPhone?.replace(/[() -]/g,"")??"";return{customer_note:e.order_comments,billing_address:{first_name:r.split(" ")?.slice(0,1)?.join(" ")??"",last_name:r.split(" ")?.slice(1)?.join(" ")||"-",company:n.organization??"",address_1:n.line1??"",address_2:n.line2??"",city:n.city??"",state:n.state??"",postcode:n.postal_code??"",country:n.country??"",email:e.billingDetails?.email??"",phone:s},shipping_address:e.shippingAddress?{...V(e.shippingAddress.name||"",e.shippingAddress.address),phone:s}:void 0,payment_method:"woocommerce_payments",payment_data:[{key:"payment_method",value:"card"},{key:"wcpay-fraud-prevention-token",value:window.wcpayFraudPreventionToken??""},{key:a?"wcpay-confirmation-token":"wcpay-payment-method",value:t},{key:"express_payment_type",value:e.expressPaymentType},{key:"wcpay-express-payment-method-types",value:JSON.stringify(o)}]}};let Z=null,ee=null,te=new K;const ae=()=>te,oe=e=>{const t=M(),a=e?.totals?.currency_code?.toLowerCase();return Boolean(t&&a&&t!==a)},re=e=>(0,t.sprintf)((0,t.__)("This express payment started in %1$s and cannot switch to %2$s for the address you selected. Choose a different shipping address, or use the regular checkout to pay in %2$s.","woocommerce-payments"),M().toUpperCase(),e.totals.currency_code.toUpperCase()),ne=e=>({amount:(0,a.applyFilters)("wcpay.express-checkout.total-amount",C(parseInt(e.totals.total_price,10)-parseInt(e.totals.total_refund||0,10),e.totals),e),...U()?{setupFutureUsage:O(e)}:{}}),se=()=>{jQuery.blockUI({message:null,overlayCSS:{background:"#fff",opacity:.6}})},ie=()=>{jQuery.unblockUI()},ce=["woocommerce_rest_invalid_billing_email","woocommerce_rest_invalid_order","woocommerce_rest_invalid_user","woocommerce_rest_invalid_address","woocommerce_rest_invalid_address_country"];class pe{orderId;key;billingEmail="";cachedCartData={};constructor({orderId:e,key:t,billingEmail:a=""}){this.orderId=e,this.key=t,this.billingEmail=a}async placeOrder(e){const t=e.billing_address?.email,a=e.billing_address?.phone,o=this.cachedCartData.billing_address,r=this.cachedCartData.shipping_address,n=o&&{...o,email:o.email||t,phone:o.phone||a},s=r&&{...r,phone:r.phone||a},i=n?.email;try{const t=await G()({method:"POST",path:`/wc/store/v1/checkout/${this.orderId}`,headers:{Nonce:_("nonce").store_api_nonce},data:{...e,key:this.key,billing_email:this.billingEmail,billing_address:n,shipping_address:s}});return i&&(this.billingEmail=i),t}catch(e){throw i&&!ce.includes(e?.code)&&(this.billingEmail=i),e}}async getCart(){return this.cachedCartData=await G()({method:"GET",path:(0,J.addQueryArgs)(`/wc/store/v1/order/${this.orderId}`,{key:this.key,billing_email:this.billingEmail})})}}let le=null;const ue=async()=>{if("product"!==_("button_context"))return await ae().getCart();const e=new K;return e.useSeparateCart(),e.deleteAfterRequest(),await e.addProductToCart()},de=()=>le?(0,a.applyFilters)("wcpay.express-checkout.total-amount",C(parseInt(le.totals.total_price,10)-parseInt(le.totals.total_refund||0,10),le.totals),le):"product"===_("button_context")&&_("product")?_("product")?.total.amount:void 0;let me;jQuery(e=>{if(_("has_block")&&"pay_for_order"!==_("button_context"))return;const r=_("stripe").publishableKey;if(!r)return;const n=new s({publishableKey:r,accountId:_("stripe").accountId,locale:_("stripe").locale},(e,t)=>new Promise((a,o)=>{jQuery.post(e,t).then(a).fail(o)}));var i;"pay_for_order"===_("button_context")&&(i=new pe({orderId:o("order_id"),key:o("key"),billingEmail:o("billing_email")}),te=i),m.init({elementId:"#wcpay-express-checkout-element",$separator:jQuery("#wcpay-express-checkout-button-separator")});const c={abortPayment:t=>{ie(),e(".woocommerce-error").remove();const a=e(".woocommerce-notices-wrapper").first();a.length&&(a.append(e('<div class="woocommerce-error" />').text(t)),e("html, body").animate({scrollTop:a.find(".woocommerce-error").offset().top},600))},completePayment:e=>{se(),window.location=e},startExpressCheckoutElement:async e=>{let o="",r=Promise.resolve();const s=await n.getStripe(),i=_("flags")?.isEceUsingConfirmationTokens??!0,p=_("is_manual_capture")??!1,l=_("has_subscription")??!1,{setupFutureUsage:u=(l?"off_session":null)}=e,d=e.enabledMethods??_("enabled_methods")??[],y=[d.includes("payment_request")&&"card",d.includes("amazon_pay")&&"amazon_pay"].filter(Boolean);var w;me=s.elements({mode:"payment",amount:e.total,currency:(w=e.currency,B=w||null),...i?{paymentMethodTypes:y}:{paymentMethodCreation:"manual"},...i&&p?{captureMethod:"manual"}:{},...i&&u?{setupFutureUsage:u}:{},appearance:$(),locale:_("stripe")?.locale??"en"});const g=me.create("expressCheckout",(()=>{const e=_("button"),t=_("enabled_methods")??[],a=(e,t)=>{switch(t){case"dark":default:return"black";case"light":return"white";case"light-outline":return"googlePay"===e?"white":"white-outline"}},o="default"===e?.type?"plain":e?.type??"buy",r="default"===e?.type?"plain":e?.type??"plain",n=t.includes("payment_request");return{paymentMethods:{applePay:n?"always":"never",googlePay:n?"always":"never",amazonPay:t.includes("amazon_pay")?"auto":"never",link:"never",paypal:"never",klarna:"never"},layout:{overflow:"never"},buttonTheme:{googlePay:a("googlePay",e?.theme??"black"),applePay:a("applePay",e?.theme??"black")},buttonType:{googlePay:o,applePay:r},buttonHeight:Math.min(Math.max(parseInt(e?.height??"48",10),40),55)}})());m.renderButton(g),g.on("loaderror",()=>{document.getElementById("wcpay-woopay-button")||m.getButtonSeparator().hide()}),g.on("click",function(e){if(o="",_("login_confirmation"))return void(e=>{const t=_("login_confirmation");if(!t)return;let a=t.message;a=a.replace(/\*\*.*?\*\*/,{apple_pay:"Apple Pay",google_pay:"Google Pay",amazon_pay:"Amazon Pay",paypal:"PayPal",link:"Link"}[e]),a=a.replace(/\*\*/g,""),confirm(a)&&(window.location.href=t.redirect_url)})(e.expressPaymentType);if("product"===_("button_context")){if(x())return void window.alert((()=>{if(f())return!1;const e=h();return!!e&&e.classList.contains("wc-variation-is-unavailable")})()?window?.wc_add_to_cart_variation_params?.i18n_unavailable_text||(0,t.__)("Sorry, this product is unavailable. Please choose a different combination.","woocommerce-payments"):(0,t.__)("Please select your product options before proceeding.","woocommerce-payments"));ae().useSeparateCart(),r=ae().addProductToCart(),r.catch(()=>{o=(0,t.__)("There was an error processing the product with this payment method. Please add the product to the cart, instead.","woocommerce-payments"),ae().emptyCart(),g.unmount(),me=null,c.abortPayment(o),m.hideContainer(),m.getButtonSeparator().hide()}).finally(()=>{r=Promise.resolve()})}const a=le?{shippingAddressRequired:"pay_for_order"!==_("button_context")&&le.needs_shipping,shippingRates:P(le),phoneNumberRequired:_("checkout")?.needs_payer_phone??!1,lineItems:S(le)}:"product"===_("button_context")&&_("product")?{shippingAddressRequired:_("product")?.needs_shipping??!1,phoneNumberRequired:_("checkout")?.needs_payer_phone??!1,lineItems:(_("product")?.displayItems??[]).map(({label:e,amount:t})=>({name:e,amount:t}))}:void 0,n=a.shippingRates&&0!==a.shippingRates.length?a.shippingRates:[{id:"pending",displayName:(0,t.__)("Pending","woocommerce-payments"),amount:0}];(async function({expressPaymentType:e}){se(),((e,t)=>{const a={google_pay:"gpay_button_click",apple_pay:"applepay_button_click"}[e];a&&D(a,{source:t})})(e,_("button_context"))})(e),e.resolve({business:{name:_("store_name")},emailRequired:!0,...a,shippingRates:a.shippingAddressRequired?n:void 0,allowedShippingCountries:_("checkout").allowed_shipping_countries})}),g.on("shippingaddresschange",async e=>(await r,o?e.resolve():(async(e,t,a)=>{Z=e.address;try{const o=await te.updateCustomer({shipping_address:V(e.name,e.address)});if(oe(o))return a?.(re(o)),void e.reject();const r=P(o);if(0===r.length)return void e.reject();await t.update(ne(o)),ee=o,e.resolve({shippingRates:r,lineItems:S(o)})}catch(t){e.reject()}})(e,me,c.abortPayment))),g.on("shippingratechange",async e=>(async(e,t,o=null,r)=>{const n=ee||o;try{const o=await te.selectShippingRate({package_id:(0,a.applyFilters)("wcpay.express-checkout.shipping-package-id",0,n,e.shippingRate.id),rate_id:e.shippingRate.id});if(oe(o))return r?.(re(o)),void e.reject();ee=o,await t.update(ne(o)),e.resolve({lineItems:S(o)})}catch(t){e.reject()}})(e,me,le,c.abortPayment)),g.on("confirm",async e=>{if(!o)return(async(e,o,r,n,s,i,c=[])=>{const{error:p}=await r.submit();if(p)return s(p.message);const l=U();let u;try{u=await async function(e,t,a){if(a){const{confirmationToken:a,error:o}=await e.createConfirmationToken({elements:t});if(o)throw o;return a.id}const{paymentMethod:o,error:r}=await e.createPaymentMethod({elements:t});if(r)throw r;return o.id}(o,r,l)}catch(e){return s(e.message)}try{const t=await te.placeOrder({...Y(i,u,l,c),extensions:(0,a.applyFilters)("wcpay.express-checkout.cart-place-order-extension-data",{})});if("success"!==t.payment_result.payment_status)return s(L(t.message??t.payment_result?.payment_details.find(e=>"errorMessage"===e.key)?.value??""));let o=t.payment_result.redirect_url;if(!o){const e=t.payment_result.payment_details?.find(e=>"redirect"===e.key);o=e?.value||""}const r=e.confirmIntent(o);n(!0===r?o:await r)}catch(e){return e.json&&(e=await Promise.resolve(e.json())),s(L(e.message||e.payment_result?.payment_details.find(e=>"errorMessage"===e.key)?.value||(0,t.__)("There was a problem processing the order.","woocommerce-payments")))}})(n,s,me,c.completePayment,c.abortPayment,e,y);c.abortPayment(o)}),g.on("cancel",()=>{"product"===_("button_context")&&r.finally(()=>{ae().emptyCart()}),Z&&(e=>{const t=_("button_context"),a=_("has_block");var o;["cart","checkout"].includes(t)&&(a?wc?.blocksCheckout?.extensionCartUpdate({namespace:"woopayments/express-checkout/refresh-ui",data:{}}):(o=e.country,["CA","GB"].includes(o)||(e=>{const t=_("button_context"),a=(o=e,{first_name:o?.recipient?.split(" ")?.slice(0,1)?.join(" ")??"",last_name:o?.recipient?.split(" ")?.slice(1)?.join(" ")??"",company:"",address_1:o?.addressLine?.[0]??"",address_2:o?.addressLine?.[1]??"",city:o?.city??"",state:o?.state??"",country:o?.country??"",postcode:o?.postal_code??""});var o;const r=["country","state","city","postcode"];"cart"===t?(r.forEach(e=>{a[e]&&Q("form.woocommerce-shipping-calculator",`calc_shipping_${e}`,a[e])}),document.querySelector('form.woocommerce-shipping-calculator [name="calc_shipping"]')?.click()):"checkout"===t&&r.forEach(e=>{a[e]&&Q("form.woocommerce-checkout",`billing_${e}`,a[e])})})(e)))})(Z),Z=null,ie()}),g.on("ready",e=>{(async function({availablePaymentMethods:e}){e&&(({paymentMethods:e,source:t})=>{const a={googlePay:W,applePay:H};for(const o of e){const e=a[o];e&&e({source:t})}})({paymentMethods:Object.entries(e).filter(([e,t])=>t).map(([e,t])=>e),source:_("button_context")})})(e),e?.availablePaymentMethods&&Object.values(e.availablePaymentMethods).filter(Boolean).length&&(m.showContainer(),m.getButtonSeparator().show())})},init:async()=>{(0,a.removeAction)("wcpay.express-checkout.update-button-data","automattic/wcpay/express-checkout");const t="product"===_("button_context"),o=(_("product")?.currency||_("checkout")?.currency_code||"").toLowerCase();t&&await async function(e,t){const o=(e||"").toLowerCase(),r=(0,a.applyFilters)("wcpay.express-checkout.resolved-currency",Promise.resolve(o),t);let n=o;try{const e=await r;"string"==typeof e&&e&&(n=e.toLowerCase())}catch(e){}return R=n||null,n}(o,{buttonContext:"product"}),t&&"bundle"===_("product")?.product_type&&(wcpayExpressCheckoutParams.product=void 0);const r=t&&N(o)!==o;if(!le&&(!_("product")||r))try{le=await ue()}catch(e){}le&&(wcpayExpressCheckoutParams.product=void 0);const n=de(),s=(0,a.applyFilters)("wcpay.express-checkout.is-cart-eligible",n>0,le),i=le?.extensions?.wcpay?.express_checkout_methods;let p;Array.isArray(i)?p=(e=>{const t=_("methods_enabled_at_location")??[];return e.filter(e=>t.includes(e))})(i):r&&(p=(_("enabled_methods")??[]).includes("payment_request")?["payment_request"]:[]);const l=r&&Array.isArray(p)&&0===p.length;!s||l?(m.hideContainer(),m.getButtonSeparator().hide()):le?await c.startExpressCheckoutElement({total:n,currency:le.totals.currency_code.toLowerCase(),enabledMethods:p,setupFutureUsage:O(le)}):t&&_("product")?await c.startExpressCheckoutElement({total:n,currency:N(o),enabledMethods:p,setupFutureUsage:_("has_subscription")?"off_session":null}):(m.hideContainer(),m.getButtonSeparator().hide()),(0,a.addAction)("wcpay.express-checkout.update-button-data","automattic/wcpay/express-checkout",async()=>{if("product"===_("button_context")&&x())m.unblockButton();else{e(".woocommerce-error").remove();try{m.blockButton();const e=de();le=await ue(),wcpayExpressCheckoutParams.product=null,m.unblockButton();const t=de(),o={..._("flags")?.isEceUsingConfirmationTokens??1?{setupFutureUsage:O(le)}:{},...t!==e&&t>0?{amount:t}:{}};me?Object.keys(o).length&&await me.update(o):c.init(),(0,a.applyFilters)("wcpay.express-checkout.is-cart-eligible",t>0,le)?(m.showContainer(),m.getButtonSeparator().show()):(m.hideContainer(),m.getButtonSeparator().hide())}catch(e){m.hideContainer()}}})}};"checkout"===_("button_context")&&"pay_for_order"!==_("button_context")||c.init(),e(document.body).on("updated_cart_totals",()=>{le=null,c.init()}),e(document.body).on("updated_checkout",()=>{le=null,c.init()})})})()})();