File: /home/emerlux/public_html/wp-content/plugins/woocommerce-mercadopago/build/pse.block.js
(()=>{"use strict";var e={20:(e,t,s)=>{var n=s(609),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,c=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function p(e,t,s){var n,a={},p=null,l=null;for(n in void 0!==s&&(p=""+s),void 0!==t.key&&(p=""+t.key),void 0!==t.ref&&(l=t.ref),t)r.call(t,n)&&!i.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:o,type:e,key:p,ref:l,props:a,_owner:c.current}}t.Fragment=a,t.jsx=p,t.jsxs=p},609:e=>{e.exports=window.React},848:(e,t,s)=>{e.exports=s(20)}},t={};const s=window.wc.wcBlocksRegistry,n=window.wc.wcSettings,o=window.wp.element,a=window.wp.htmlEntities,r="mercadopago_blocks_update_cart";var c=function s(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,s),a.exports}(848);const i=({labelMessage:e,helperInvalid:t,helperEmpty:s,helperWrong:n,inputName:o,hiddenId:a,inputDataCheckout:r,selectId:i,selectName:p,selectDataCheckout:l,flagError:d,documents:u,validate:m})=>(0,c.jsx)("div",{className:"mp-checkout-ticket-input-document",children:(0,c.jsx)("input-document",{"label-message":e,"helper-invalid":t,"helper-empty":s,"helper-wrong":n,"input-name":o,"hidden-id":a,"input-data-checkout":r,"select-id":i,"select-name":p,"select-data-checkout":l,"flag-error":d,documents:u,validate:m})}),p=({description:e,linkText:t,linkSrc:s,checkoutClass:n="pro"})=>(0,c.jsx)("div",{className:`mp-checkout-${n}-terms-and-conditions`,children:(0,c.jsx)("terms-and-conditions",{description:e,"link-text":t,"link-src":s})}),l=({title:e,description:t,linkText:s,linkSrc:n})=>(0,c.jsx)("div",{className:"mp-test-mode-container",children:(0,c.jsx)("test-mode",{title:e,description:t,"link-text":s,"link-src":n})}),d=({name:e,label:t,optional:s,options:n,helperMessage:o,hiddenId:a,defaultOption:r})=>(0,c.jsx)("input-select",{name:e,label:t,options:n,optional:s,"helper-message":o,"hidden-id":a,"default-option":r}),u=({text:e,imgSrc:t,id:s})=>(0,c.jsxs)("div",{id:s,className:"row-image-select",children:[(0,c.jsx)("img",{src:t}),(0,c.jsx)("p",{children:e})]});var m;const _="mp_checkout_blocks",h="woo-mercado-pago-pse",y=(0,n.getSetting)("woo-mercado-pago-pse_data",{}),k=(0,a.decodeEntities)(y.title)||"Checkout Pse",g=e=>{const{PaymentMethodLabel:t}=e.components,s=(0,a.decodeEntities)(y?.params?.fee_title||""),n=`${k} ${s}`;return(0,c.jsx)(u,{text:n,imgSrc:y.params.checkout_blocks_row_image_src})},x=e=>{(e=>{const{extensionCartUpdate:t}=wc.blocksCheckout,{eventRegistration:s,emitResponse:n}=e,{onPaymentSetup:a,onCheckoutSuccess:c,onCheckoutFail:i}=s;(0,o.useEffect)((()=>{((e,t)=>{e({namespace:r,data:{action:"add",gateway:t}})})(t,h);const e=a((()=>({type:n.responseTypes.SUCCESS})));return()=>(((e,t)=>{e({namespace:r,data:{action:"remove",gateway:t}})})(t,h),e())}),[a]),(0,o.useEffect)((()=>{const e=c((async e=>{const t=e.processingResponse;return sendMetric("MP_PSE_BLOCKS_SUCCESS",t.paymentStatus,_),{type:n.responseTypes.SUCCESS}}));return()=>e()}),[c]),(0,o.useEffect)((()=>{const e=i((e=>{const t=e.processingResponse;return sendMetric("MP_PSE_BLOCKS_ERROR",t.paymentStatus,_),{type:n.responseTypes.FAIL,messageContext:n.noticeContexts.PAYMENTS,message:t.paymentDetails.message}}));return()=>e()}),[i])})(e);const{test_mode_title:t,test_mode_description:s,test_mode_link_text:n,test_mode_link_src:a,input_document_label:u,input_document_helper_empty:m,input_document_helper_invalid:k,input_document_helper_wrong:g,pse_text_label:x,person_type_label:f,amount:S,site_id:v,terms_and_conditions_description:b,terms_and_conditions_link_text:j,terms_and_conditions_link_src:E,test_mode:w,financial_institutions:C,financial_institutions_label:N,financial_institutions_helper:R,financial_placeholder:T,message_error_amount:P}=y.params;if(null==S)return(0,c.jsx)(c.Fragment,{children:(0,c.jsx)("p",{className:"alert-message",children:P})});const O=(0,o.useRef)(null),{eventRegistration:M,emitResponse:I}=e,{onPaymentSetup:q}=M;let L={labelMessage:u,helperInvalid:k,helperEmpty:m,helperWrong:g,validate:"true",selectId:"doc_type",flagError:"mercadopago_pse[docNumberError]",inputName:"mercadopago_pse[docNumber]",selectName:"mercadopago_pse[docType]",documents:'["CC","CE","NIT"]'};return(0,o.useEffect)((()=>{const e=q((async()=>{const e=document.querySelector(".mp-checkout-pse-input-document").querySelector(".mp-input-document > input-helper > div"),t={"mercadopago_pse[site_id]":v,"mercadopago_pse[amount]":S.toString(),"mercadopago_pse[doc_type]":O.current.querySelector("#doc_type")?.value,"mercadopago_pse[doc_number]":O.current.querySelector("#form-checkout__identificationNumber-container > input")?.value,"mercadopago_pse[bank]":O.current.querySelector("#mercadopago_pse\\[bank\\]").value,"mercadopago_pse[person_type]":O.current.querySelector("#mercadopago_pse\\[person_type\\]").value};L.documents&&""===t["mercadopago_pse[doc_number]"]&&o(e,"flex");let s=document.querySelector("#mercadopago_pse\\[bank\\]"),n=document.querySelector(".mp-checkout-pse-bank").querySelector("input-helper > div");function o(e,t){e&&e.style&&(e.style.display=t)}function a(e){return e&&"flex"===e.style.display}return""!==s.value&&T!==s.value||o(n,"flex"),{type:a(n)||a(e)?I.responseTypes.ERROR:I.responseTypes.SUCCESS,meta:{paymentMethodData:t}}}));return()=>e()}),[I.responseTypes.ERROR,I.responseTypes.SUCCESS,q]),(0,c.jsxs)("div",{className:"mp-checkout-container",children:[(0,c.jsx)("p",{className:"mp-checkout-pse-text","data-cy":"checkout-pse-text",children:x}),(0,c.jsx)("div",{className:"mp-checkout-pse-container",children:(0,c.jsxs)("div",{ref:O,className:"mp-checkout-pse-content",children:[w?(0,c.jsx)(l,{title:t,description:s,"link-text":n,"link-src":a}):null,(0,c.jsx)("div",{className:"mp-checkout-pse-person",children:(0,c.jsx)(d,{name:"mercadopago_pse[person_type]",label:f,optional:!1,options:'[{"id":"individual", "description": "individual"},{"id":"association", "description": "asociación"}]'})}),(0,c.jsx)("div",{className:"mp-checkout-pse-input-document",children:L.documents?(0,c.jsx)(i,{...L}):null}),(0,c.jsx)("div",{className:"mp-checkout-pse-bank",children:(0,c.jsx)(d,{name:"mercadopago_pse[bank]",label:N,optional:!1,options:C,"hidden-id":"hidden-financial-pse","helper-message":R,"default-option":T})}),(0,c.jsx)("div",{id:"mp-box-loading"})]})}),(0,c.jsx)(p,{description:b,linkText:j,linkSrc:E,checkoutClass:"pse"})]})},f={name:h,label:(0,c.jsx)(g,{}),content:(0,c.jsx)(x,{}),edit:(0,c.jsx)(x,{}),canMakePayment:()=>!0,ariaLabel:k,supports:{features:null!==(m=y?.supports)&&void 0!==m?m:[]}};(0,s.registerPaymentMethod)(f)})();