File: /home/kbdhpghp/atenaleaders.com.br/wp-content/plugins/woocommerce-mercadopago/build/yape.block.js
(()=>{"use strict";const e=window.React,t=window.wc.wcBlocksRegistry,o=window.wc.wcSettings,a=window.wp.element,n=window.wp.htmlEntities,c="mercadopago_blocks_update_cart",s=({description:t,linkText:o,linkSrc:a,checkoutClass:n="pro"})=>(0,e.createElement)("div",{className:`mp-checkout-${n}-terms-and-conditions`},(0,e.createElement)("terms-and-conditions",{description:t,"link-text":o,"link-src":a})),r=({title:t,description:o,linkText:a,linkSrc:n})=>(0,e.createElement)("div",{className:"mp-checkout-pro-test-mode"},(0,e.createElement)("test-mode",{title:t,description:o,"link-text":a,"link-src":n})),i=({labelMessage:t,emptyErrorMessage:o,invalidErrorMessage:a})=>(0,e.createElement)("input-field",{"label-message":t,"empty-error-message":o,"invalid-error-message":a}),m=({label:t,src:o,emptyErrorMessage:a,invalidErrorMessage:n,tooltipText:c})=>(0,e.createElement)("input-code",{label:t,src:o,"empty-error-message":a,"invalid-error-message":n,"tooltip-text":c}),l=({message:t,src:o,icon:a,footerText:n})=>(0,e.createElement)("checkout-notice",{message:t,src:o,icon:a,"footer-text":n}),p=(e,t,o)=>{const a={name:e,message:t,target:o,plugin:{version:wc_mercadopago_custom_checkout_params.plugin_version},platform:{name:"woocommerce",uri:window.location.href,version:wc_mercadopago_custom_checkout_params.platform_version,location:`${wc_mercadopago_custom_checkout_params.location}_${wc_mercadopago_custom_checkout_params.theme}`}};navigator.sendBeacon("https://api.mercadopago.com/v1/plugins/melidata/errors",JSON.stringify(a))};var d;const _="mp_checkout_blocks",u="woo-mercado-pago-yape",y=(0,o.getSetting)("woo-mercado-pago-yape_data",{}),g=(0,n.decodeEntities)(y.title)||"Checkout Yape",k=t=>{(e=>{const{extensionCartUpdate:t}=wc.blocksCheckout,{eventRegistration:o,emitResponse:n}=e,{onPaymentSetup:s,onCheckoutSuccess:r,onCheckoutFail:i}=o;(0,a.useEffect)((()=>{((e,t)=>{e({namespace:c,data:{action:"add",gateway:t}})})(t,u);const e=s((()=>({type:n.responseTypes.SUCCESS})));return()=>(((e,t)=>{e({namespace:c,data:{action:"remove",gateway:t}})})(t,u),e())}),[s]),(0,a.useEffect)((()=>{const e=r((async e=>{const t=e.processingResponse;return p("MP_YAPE_BLOCKS_SUCCESS",t.paymentStatus,_),{type:n.responseTypes.SUCCESS}}));return()=>e()}),[r]),(0,a.useEffect)((()=>{const e=i((e=>{const t=e.processingResponse;return p("MP_YAPE_BLOCKS_ERROR",t.paymentStatus,_),{type:n.responseTypes.FAIL,messageContext:n.noticeContexts.PAYMENTS,message:t.paymentDetails.message}}));return()=>e()}),[i])})(t);const{test_mode:o,test_mode_title:n,test_mode_description:d,test_mode_link_text:g,test_mode_link_src:k,terms_and_conditions_description:E,terms_and_conditions_link_text:h,terms_and_conditions_link_src:w,input_field_label:v,yape_title:S,yape_subtitle:f,input_code_icon:b,checkout_notice_icon_one:C,checkout_notice_icon_two:R,checkout_notice_message:T,input_code_label:x,footer_text:M,yape_tooltip_text:N,yape_input_code_error_message1:P,yape_input_code_error_message2:B,yape_phone_number_error_message1:O,yape_phone_number_error_message2:U}=y.params,A=(0,a.useRef)(null),{eventRegistration:L,emitResponse:$}=t,{onPaymentSetup:F}=L;return window.mpFormId="blocks_checkout_form",window.mpCheckoutForm=document.querySelector(".wc-block-components-form.wc-block-checkout__form"),(0,a.useEffect)((()=>{const e=F((async()=>{const e=getCodeValue(),t=document.getElementById("checkout__yapePhoneNumber").value.replaceAll(" ","");if(""===e&&""===t)return document.getElementsByTagName("input-field")[0].validate(),document.getElementsByTagName("input-code")[0].validate(),{type:$.responseTypes.ERROR};const o={otp:e,phoneNumber:t},a={},n=new MercadoPago(wc_mercadopago_yape_checkout_params.public_key).yape(o);try{const e=await n.create();a["mercadopago_yape[token]"]=e.id}catch(e){return console.warn("Token creation error: ",e),{type:$.responseTypes.ERROR}}return{type:$.responseTypes.SUCCESS,meta:{paymentMethodData:a}}}));return()=>e()}),[F,$.responseTypes.ERROR,$.responseTypes.SUCCESS]),(0,e.createElement)("div",null,(0,e.createElement)("div",{className:"mp-checkout-custom-load"},(0,e.createElement)("div",{className:"spinner-card-form"})),(0,e.createElement)("div",{className:"mp-checkout-yape-container"},(0,e.createElement)("div",{ref:A,className:"mp-checkout-yape-content"},(0,e.createElement)("div",{className:"mp-checkout-yape-test-mode"},o?(0,e.createElement)(r,{title:n,description:d,linkText:g,linkSrc:k}):null),(0,e.createElement)("div",{className:"mp-checkout-yape-title-container"},(0,e.createElement)("h2",{className:"mp-checkout-yape-title"},S),(0,e.createElement)("p",{className:"mp-checkout-yape-subtitle"},f)),(0,e.createElement)("div",{className:"mp-checkout-yape-inputs"},(0,e.createElement)(i,{labelMessage:v,emptyErrorMessage:O,invalidErrorMessage:U}),(0,e.createElement)(m,{label:x,src:b,emptyErrorMessage:P,invalidErrorMessage:B,tooltipText:N})),(0,e.createElement)(l,{message:T,src:C,icon:R},"footerText=",M)),(0,e.createElement)("div",{className:"mp-checkout-yape-terms-and-conditions"},(0,e.createElement)(s,{description:E,linkText:h,linkSrc:w}))),(0,e.createElement)("div",{id:"mercadopago-utilities",style:{display:"none"}},(0,e.createElement)("input",{type:"hidden",id:"yapeToken",name:"mercadopago_yape[token]"})))},E={name:u,label:(0,e.createElement)((t=>{const{PaymentMethodLabel:o}=t.components,a=(0,n.decodeEntities)(y?.params?.fee_title||""),c=`${g} ${a}`;return(0,e.createElement)(o,{text:c})}),null),content:(0,e.createElement)(k,null),edit:(0,e.createElement)(k,null),canMakePayment:()=>!0,ariaLabel:g,supports:{features:null!==(d=y?.supports)&&void 0!==d?d:[]}};(0,t.registerPaymentMethod)(E)})();