1function isCustomCheckoutPage(){const e=document.body?.classList;return e?.contains("woocommerce-checkout")||e?.contains("woocommerce-order-pay")||e?.contains("woocommerce-add-payment-method")}class MPCustomCheckoutHandler{static FORM_SELECTORS={CLASSIC:"form[name=checkout]",BLOCKS:".wc-block-components-form.wc-block-checkout__form",ORDER_REVIEW:"form#order_review"};static FORM_IDS={CLASSIC_CHECKOUT:"checkout",BLOCKS_CHECKOUT:"blocks_checkout_form",PAY_FOR_ORDER:"order_review"};static FORM_DISCOVERY_TIMEOUT_MS=3e4;static FORM_DISCOVERY_RETRY_INTERVAL_MS=500;static hasDependencies(){return"function"==typeof MPCardForm&&"function"==typeof MPThreeDSHandler&&"function"==typeof MPEventHandler&&"object"==typeof CheckoutPage&&"object"==typeof CheckoutElements&&this.hasSdkDependency()}static hasSdkDependency(){return"function"==typeof window.mpSdkInstance?.cardForm||"function"==typeof MercadoPago}static waitForDependencies(){return this.hasDependencies()?Promise.resolve(!0):new Promise((e=>{let t=0;const o=()=>{this.hasDependencies()?e(!0):(t+=this.FORM_DISCOVERY_RETRY_INTERVAL_MS,t>=this.FORM_DISCOVERY_TIMEOUT_MS?e(!1):setTimeout(o,this.FORM_DISCOVERY_RETRY_INTERVAL_MS))};o()}))}static reportInitializationFailure(e){"function"==typeof window.sendMetric&&window.sendMetric(e,"custom_checkout_initialization","mp_custom_checkout_initialization_error")}constructor(e,t,o){this.cardForm=e,this.threeDSHandler=t,this.eventHandler=o,this.init()}
1async init(){if(!this.isCheckoutPage())return;if(!1===await this.setupFormConfiguration())return;if(!await this.waitForJQuery())return MPCustomCheckoutHandler.reportInitializationFailure("jquery_timeout"),void console.error("Mercado Pago checkout dependencies did not become available in time.");this.eventHandler.triggeredPaymentMethodSelectedEvent||jQuery("body").trigger("payment_method_selected"),this.eventHandler.bindEvents()}async setupFormConfiguration(){try{const e=await this.getFormConfig();return e.element&&(e.element.id=e.formId),this.syncFormIds(e.formId),!0}catch(e){return MPCustomCheckoutHandler.reportInitializationFailure("form_discovery_timeout"),console.error("Mercado Pago checkout form was not rendered in time."),!1}}getFormConfig(){const e=this.findFormConfig();return e?Promise.resolve(e):new Promise(((e,t)=>{let o,n,i;const r=()=>{o&&o.disconnect(),clearTimeout(n),clearTimeout(i)},c=()=>{const t=this.findFormConfig();return!!t&&(r(),e(t),!0)},s=()=>{c()||(n=setTimeout(s,MPCustomCheckoutHandler.FORM_DISCOVERY_RETRY_INTERVAL_MS))};if(i=setTimeout((()=>{r(),t(new Error("Checkout form discovery timed out."))}),MPCustomCheckoutHandler.FORM_DISCOVERY_TIMEOUT_MS),"undefined"!=typeof MutationObserver)return o=new MutationObserver(c),o.observe(document.documentElement,{childList:!0,subtree:!0}),void c();s()}))}isCheckoutPage(){return isCustomCheckoutPage()}findFormConfig(){const e=document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.CLASSIC),t=document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.BLOCKS),o=document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.ORDER_REVIEW);return e?{element:e,formId:MPCustomCheckoutHandler.FORM_IDS.CLASSIC_CHECKOUT}:t?{element:t,formId:MPCustomCheckoutHandler.FORM_IDS.BLOCKS_CHECKOUT}:o?{element:o,formId:MPCustomCheckoutHandler.FORM_IDS.PAY_FOR_ORDER}:null}waitForJQuery(){return"function"==typeof jQuery?Promise.resolve(!0):new Promise((e=>{let t=0;const o=()=>{"function"!=typeof jQuery?(t+=MPCustomCheckoutHandler.FORM_DISCOVERY_RETRY_INTERVAL_MS,t>=MPCustomCheckoutHandler.FORM_DISCOVERY_TIMEOUT_MS?e(!1):setTimeout(o,MPCustomCheckoutHandler.FORM_DISCOVERY_RETRY_INTERVAL_MS)):e(!0)};o()}))}syncFormIds(e){this.eventHandler.mpFormId=e,this.cardForm.mpFormId=e}}async function initializeCustomCheckout(){if(isCustomCheckoutPage()&&!window.mpCustomCheckoutHandler&&!window.mpCustomCheckoutInitializationInProgress){window.mpCustomCheckoutInitializationInProgress=!0;try{if(!await MPCustomCheckoutHandler.waitForDependencies())return MPCustomCheckoutHandler.reportInitializationFailure("dependencies_timeout"),void console.error("Mercado Pago checkout dependencies did not become available in time.");const e=new MPCardForm,t=new MPThreeDSHandler,o=new MPEventHandler(e,t),n=new MPCustomCheckoutHandler(e,t,o);window.mpCustomCheckoutHandler=n,window.mpEventHandler=o}finally{window.mpCustomCheckoutInitializationInProgress=!1}}}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",initializeCustomCheckout,{once:!0}):initializeCustomCheckout();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.