!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e){let o,t=e[0],n=1;for(;n<e.length;){const a=e[n],c=e[n+1];if(n+=2,("optionalAccess"===a||"optionalCall"===a)&&null==t)return;"access"===a||"optionalAccess"===a?(o=t,t=c(t)):"call"!==a&&"optionalCall"!==a||(t=c(((...e)=>t.call(o,...e))),o=void 0)}return t}!function(){jQuery((function(e){e(document).ajaxError((function(){"function"==typeof window._depayUnmountLoading&&window._depayUnmountLoading()})),e(document).ajaxComplete((function(){"function"==typeof window._depayUnmountLoading&&window._depayUnmountLoading()})),e("form.woocommerce-checkout").on("submit",(async()=>{if(e("form.woocommerce-checkout").serialize().match("payment_method=depay_wc_payments")){let{unmount:e}=await DePayWidgets.Loading({text:"Loading payment data..."});setTimeout(e,1e4)}}))}));const o=async()=>{if(window.location.hash.startsWith("#wc-depay-checkout-")){const o=window.location.hash.match(/wc-depay-checkout-(.*?)@/)[1],t=JSON.parse(await wp.apiRequest({path:`/depay/wc/checkouts/${o}`,method:"POST",headers:{"X-WP-Nonce":e([wpApiSettings,"optionalAccess",e=>e.nonce])}}).catch((o=>{"rest_cookie_invalid_nonce"===e([o,"optionalAccess",e=>e.responseJSON,"optionalAccess",e=>e.code])&&window.location.reload(!0)})));if(t.redirect)return void(window.location=t.redirect);let n={accept:t.map((e=>({...e,protocolFee:"1.5%"}))),closed:()=>{window.location.hash="",window.location.reload(!0)},track:{method:e=>new Promise(((t,n)=>{try{wp.apiRequest({path:`/depay/wc/checkouts/${o}/track`,method:"POST",data:e}).done((()=>t({status:200}))).fail(((e,o)=>n(o)))}catch(e){n()}})),poll:{method:()=>new Promise(((e,t)=>{wp.apiRequest({path:"/depay/wc/release",method:"POST",data:{checkout_id:o}}).done((o=>{e(o)})).fail(e)}))}}};window.DEPAY_WC_CURRENCY&&"store"==window.DEPAY_WC_CURRENCY.displayCurrency&&e([window,"access",e=>e.DEPAY_WC_CURRENCY,"access",e=>e.storeCurrency,"optionalAccess",e=>e.length])&&(n.currency=window.DEPAY_WC_CURRENCY.storeCurrency),DePayWidgets.Payment(n)}};document.addEventListener("DOMContentLoaded",o),window.addEventListener("hashchange",o)}()}));
