Files
php_assessment_2/wp-content/plugins/woocommerce-payments/dist/checkout.js
T

1 line
92 KiB
JavaScript
Raw Normal View History

2025-02-05 23:15:46 +01:00
(()=>{var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&(t=n.currentScript.src),!t)){var o=n.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(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),e.p=window.wcpayAssets.url,(()=>{"use strict";const e=e=>"undefined"!=typeof wcpayConfig?wcpayConfig[e]:t(e),t=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={address_1:"shipping_address_1",address_2:"shipping_address_2",city:"shipping_city",state:"shipping_state",postcode:"shipping_postcode",country:"shipping_country",first_name:"shipping_first_name",last_name:"shipping_last_name"},o={address_1:"billing_address_1",address_2:"billing_address_2",city:"billing_city",state:"billing_state",postcode:"billing_postcode",country:"billing_country",first_name:"billing_first_name",last_name:"billing_last_name"},r=(e,t="always")=>Object.keys(e).filter((t=>"link"!==t&&e[t].isReusable)).reduce(((e,n)=>(e[n]=t,e)),{}),a=()=>{const e=document.querySelector('input[name="payment_method"][value*="woocommerce_payments"]:checked');return e?e.value.replace("woocommerce_payments_","").replace("woocommerce_payments","")||"card":null},i=e=>{const n={},o=function(e){if(t("cartContainsSubscription"))return!0;const n=document.querySelector(`.wcpay-upe-form[data-payment-method-type="${e}"]`);if(!n)return!1;const o=n.querySelector(`#wc-${c(e)}-new-payment-method`);return o?.checked||!1}(e)?"always":"never";var a;return n.terms=r(t("paymentMethodsConfig"),o),!t("isCheckout")||t("isOrderPay")||t("isChangingPayment")||(n.fields={billingDetails:(a=t("enabledBillingFields"),{name:a.billing_first_name||a.billing_last_name?"never":"auto",email:a.billing_email?"never":"auto",phone:a.billing_phone?"never":"auto",address:{country:a.billing_country?"never":"auto",line1:a.billing_address_1?"never":"auto",line2:a.billing_address_2?"never":"auto",city:a.billing_city?"never":"auto",state:a.billing_state?"never":"auto",postalCode:a.billing_postcode?"never":"auto"}})}),window.wcpayCustomerData&&(n.defaultValues={billingDetails:{name:window.wcpayCustomerData.name,email:window.wcpayCustomerData.email,address:{country:window.wcpayCustomerData.billing_country}}}),n};function c(e){const t="woocommerce_payments";return"card"===e?t:`${t}_${e}`}const s=(e,t)=>{e.append(`<input type="hidden" id="wcpay-payment-method" name="wcpay-payment-method" value="${t}" />`)},l=e=>void 0!==e.link&&void 0!==e.card,u=e=>{const n=t("paymentMethodsConfig"),o=e.dataset.paymentMethodType,r=n[o].countries,i=a();let c=e?.closest("form.checkout, form#add_payment_method")?.querySelector('[name="billing_country"]');c||(c=document.querySelector("#billing_country"));const s=c?.value||window?.wcpayCustomerData?.billing_country||"",l=e?.closest(".wc_payment_method");if(r.includes(s))l.style.removeProperty("display");else if(l.style.display="none",o===i){const e=document.querySelector('input[name="payment_method"][value="woocommerce_payments"]');e?.click()}},d=window.wp.i18n,m=["color","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"],p=["fontFamily","fontSize","lineHeight","letterSpacing","fontWeight","fontVariation","textDecoration","textShadow","textTransform","-webkit-font-smoothing","-moz-osx-font-smoothing","transition"],h=["backgroundColor","border","borderTop","borderRight","borderBottom","borderLeft","borderRadius","borderWidth","borderColor","borderStyle","borderTopWidth","borderTopColor","borderTopStyle","borderRightWidth","borderRightColor","borderRightStyle","borderBottomWidth","borderBottomColor","borderBottomStyle","borderLeftWi