Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
6
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moneyhash/js-sdk - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2-beta.0

dist/warnIf-daa85568.js

4

dist/headless.cjs.js

@@ -1,2 +0,2 @@

"use strict";var se=Object.defineProperty,oe=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var q=(s,e,t)=>e in s?se(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,k=(s,e)=>{for(var t in e||(e={}))ce.call(e,t)&&q(s,t,e[t]);if(J)for(var t of J(e))le.call(e,t)&&q(s,t,e[t]);return s},K=(s,e)=>oe(s,de(e));var v=(s,e,t)=>(q(s,typeof e!="symbol"?e+"":e,t),t),ue=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var b=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)};var P=(s,e,t)=>(ue(s,e,"access private method"),t);var w=(s,e,t)=>new Promise((o,r)=>{var a=n=>{try{i(t.next(n))}catch(l){r(l)}},c=n=>{try{i(t.throw(n))}catch(l){r(l)}},i=n=>n.done?o(n.value):Promise.resolve(n.value).then(a,c);i((t=t.apply(s,e)).next())});const h=require("./warnIf-b3156a58.cjs");function pe(){return typeof window!="undefined"}const y=class{constructor(){pe()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=h.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.5.1");const o=document.createElement("iframe");o.id="moneyhash-headless-sdk",o.src=t.toString(),o.hidden=!0,document.body.appendChild(o),y.messagingService=new h.MessagingService({target:o.contentWindow,targetOrigin:e}),y.isCommunicationReady=new Promise(r=>{var c;const a=i=>{var n;i.data.type==="headlessSDK:init"&&(r(),(n=y.messagingService)==null||n.removeListener(a))};(c=y.messagingService)==null||c.onReceive(a)})}request(o){return w(this,arguments,function*({api:e,payload:t}){return yield y.isCommunicationReady,new Promise((r,a)=>{var i,n;(i=y.messagingService)==null||i.send({type:e,data:t});const c=l=>{var u;const{type:d,data:p}=l.data;d===e&&(p.status==="resolved"?r(p.payload):a(p.payload),(u=y.messagingService)==null||u.removeListener(c))};(n=y.messagingService)==null||n.onReceive(c)})})}postMessage(e){var t;(t=y.messagingService)==null||t.send({type:e})}};let L=y;v(L,"messagingService",null),v(L,"isCommunicationReady");class G{constructor(){v(this,"promise");v(this,"resolve");v(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function he(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function S(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function Q(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function me(s){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!s.includes(t))return t;return null}function ge(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function fe(s,e){return new Promise((t,o)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=s,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{o(new Error("Script failed to load"))}),document.body.appendChild(a)})}function we(s){return new Promise(e=>{setTimeout(()=>{e("done")},s*1e3)})}const X=new Set(["method","customerBalance","savedCard"]);var C,Z,U,ee,R,te,A,N,M,re,$,ne,_,ae,F,ie;class ve{constructor(e){b(this,C);b(this,U);b(this,R);b(this,A);b(this,M);b(this,$);b(this,_);b(this,F);v(this,"options");v(this,"sdkApiHandler",new L);v(this,"sdkEmbed");v(this,"vaultSubmitListener",{current:null});v(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new h.SDKEmbed(K(k({},e),{headless:!0})),P(this,$,ne).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:o,metaData:r}){return h.throwIf(!X.has(t),`type must be a valid one (${[...X].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:o,lang:this.sdkEmbed.lang,metaData:r}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return h.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return w(this,arguments,function*({intentId:e,currency:t,amount:o,countryCode:r,onCancel:a=()=>{},onError:c,onComplete:i,billingData:n={}}){if(yield fe("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:r,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${o}`}}),{state:p,intent:u}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(p==="INTENT_FORM"){if(ge(n))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:n}})}}catch(m){throw yield this.resetSelectedMethod(e),m}d.onvalidatemerchant=m=>{fetch(`${Q()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:u.secret,validation_url:m.validationURL})}).then(f=>f.ok?f.json():Promise.reject()).then(f=>d.completeMerchantValidation(f)).catch(c)},d.onpaymentauthorized=m=>{fetch(`${Q()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:m.payment.token,secret:u.secret})}).then(f=>f.ok?f.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),i()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),c()})},d.oncancel=a,d.begin()})}renderForm({selector:e,intentId:t}){return h.throwIf(!e,"selector is required for renderForm"),h.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){h.warnIf(!!e&&!h.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...h.supportedLanguages].join(" | ")})`);const t=h.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return h.throwIf(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(o=>{h.throwIf(!o.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:o}){const r=[],a={},c=new Map;let i=!1;return P(this,M,re).call(this,r),{create:({elementType:n,elementOptions:l})=>{var D,W;const d=new Map,p=document.querySelector(l.selector);h.throwIf(!p,`Couldn't find an element with selector ${l.selector}!`);let u=null;p.classList.add("MoneyHashElement");const m=k(k({},t),l.classes),f=((D=m==null?void 0:m.focus)==null?void 0:D.split(" "))||["MoneyHashElement--focus"],H=((W=m==null?void 0:m.error)==null?void 0:W.split(" "))||["MoneyHashElement--error"];return r.push(g=>{var j,x,T,B,Y,O,z;const{type:E,data:I}=g.data;if(E===`${n}@mount`&&(a[n]=I.isValid,(j=d.get(`${n}@mount`))==null||j()),E===`${n}@focus`){p.classList.add(...f),(x=d.get(`${n}@focus`))==null||x();return}if(E===`${n}@blur`){p.classList.remove(...f),(T=d.get(`${n}@blur`))==null||T();return}if(E===`${n}@error`){I.isValid?p.classList.remove(...H):p.classList.add(...H),(B=d.get(`${n}@error`))==null||B(I);return}if(E===`${n}@changeInput`){if((Y=d.get(`${n}@changeInput`))==null||Y({isValid:I.isValid,length:I.length}),a[n]=I.isValid,c.get("validityChange")){const V=Object.values(a).every(Boolean);V!==i&&((O=c.get("validityChange"))==null||O(V),i=V)}return}E===`${n}@cardNumberChange`&&((z=d.get(`${n}@cardNumberChange`))==null||z(I))}),{mount:()=>{this.mountedCardElements.push(n),u=P(this,_,ae).call(this,{container:p,elementType:n,elementOptions:l,styles:k(k({},e),l.styles),fontSourceCss:o})},on:(g,E)=>{d.set(`${n}@${g}`,E)},off:g=>d.delete(`${n}@${g}`),focus:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"focus"},S())},blur:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"blur"},S())},clear:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"clear"},S())}}},on:(n,l)=>{c.set(n,l)}}}submitForm(c){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:o,shippingData:r,saveCard:a}){const i=me(this.mountedCardElements);h.throwIf(!!i,`You must mount ${i} element!`);const n=new G;let l,d;t&&(this.vaultSubmitListener.current=u=>{const{type:m,data:f}=u.data;m==="vaultSubmit:success"&&n.resolve(f),m==="vaultSubmit:error"&&n.reject(f)},d=P(this,F,ie).call(this,{accessToken:t,saveCard:a}),l=yield n.promise);const p=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:o,shippingData:r,cardEmbed:l}});return d&&d.remove(),p})}submitCvv(o){return w(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(a){return w(this,arguments,function*({intentId:e,url:t,renderStrategy:o,options:r}){switch(o){case"IFRAME":return P(this,C,Z).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return P(this,U,ee).call(this,{url:t,intentId:e,options:r});case"REDIRECT":return P(this,R,te).call(this,{url:t,options:r});default:return null}})}onExpiration(e,t){if(!e)return h.warnIf(!0,`No expiration date provided!, make sure to check for it before usage
"use strict";var se=Object.defineProperty,oe=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var q=(s,e,t)=>e in s?se(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,k=(s,e)=>{for(var t in e||(e={}))ce.call(e,t)&&q(s,t,e[t]);if(J)for(var t of J(e))le.call(e,t)&&q(s,t,e[t]);return s},K=(s,e)=>oe(s,de(e));var v=(s,e,t)=>(q(s,typeof e!="symbol"?e+"":e,t),t),ue=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var b=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)};var P=(s,e,t)=>(ue(s,e,"access private method"),t);var w=(s,e,t)=>new Promise((o,r)=>{var a=n=>{try{i(t.next(n))}catch(l){r(l)}},c=n=>{try{i(t.throw(n))}catch(l){r(l)}},i=n=>n.done?o(n.value):Promise.resolve(n.value).then(a,c);i((t=t.apply(s,e)).next())});const h=require("./warnIf-fba58e46.cjs");function pe(){return typeof window!="undefined"}const y=class{constructor(){pe()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=h.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.5.2-beta.0");const o=document.createElement("iframe");o.id="moneyhash-headless-sdk",o.src=t.toString(),o.hidden=!0,document.body.appendChild(o),y.messagingService=new h.MessagingService({target:o.contentWindow,targetOrigin:e}),y.isCommunicationReady=new Promise(r=>{var c;const a=i=>{var n;i.data.type==="headlessSDK:init"&&(r(),(n=y.messagingService)==null||n.removeListener(a))};(c=y.messagingService)==null||c.onReceive(a)})}request(o){return w(this,arguments,function*({api:e,payload:t}){return yield y.isCommunicationReady,new Promise((r,a)=>{var i,n;(i=y.messagingService)==null||i.send({type:e,data:t});const c=l=>{var p;const{type:d,data:u}=l.data;d===e&&(u.status==="resolved"?r(u.payload):a(u.payload),(p=y.messagingService)==null||p.removeListener(c))};(n=y.messagingService)==null||n.onReceive(c)})})}postMessage(e){var t;(t=y.messagingService)==null||t.send({type:e})}};let L=y;v(L,"messagingService",null),v(L,"isCommunicationReady");class G{constructor(){v(this,"promise");v(this,"resolve");v(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function he(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function S(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function Q(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function me(s){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!s.includes(t))return t;return null}function ge(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function fe(s,e){return new Promise((t,o)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=s,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{o(new Error("Script failed to load"))}),document.body.appendChild(a)})}function we(s){return new Promise(e=>{setTimeout(()=>{e("done")},s*1e3)})}const X=new Set(["method","customerBalance","savedCard"]);var C,Z,U,ee,R,te,A,N,M,re,$,ne,_,ae,F,ie;class ve{constructor(e){b(this,C);b(this,U);b(this,R);b(this,A);b(this,M);b(this,$);b(this,_);b(this,F);v(this,"options");v(this,"sdkApiHandler",new L);v(this,"sdkEmbed");v(this,"vaultSubmitListener",{current:null});v(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new h.SDKEmbed(K(k({},e),{headless:!0})),P(this,$,ne).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:o,metaData:r}){return h.throwIf(!X.has(t),`type must be a valid one (${[...X].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:o,lang:this.sdkEmbed.lang,metaData:r}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return h.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return w(this,arguments,function*({intentId:e,currency:t,amount:o,countryCode:r,onCancel:a=()=>{},onError:c,onComplete:i,billingData:n={}}){if(yield fe("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:r,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${o}`}}),{state:u,intent:p}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(u==="INTENT_FORM"){if(ge(n))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:n}})}}catch(m){throw yield this.resetSelectedMethod(e),m}d.onvalidatemerchant=m=>{fetch(`${Q()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:p.secret,validation_url:m.validationURL})}).then(f=>f.ok?f.json():Promise.reject()).then(f=>d.completeMerchantValidation(f)).catch(c)},d.onpaymentauthorized=m=>{fetch(`${Q()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:m.payment.token,secret:p.secret})}).then(f=>f.ok?f.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),i()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),c()})},d.oncancel=a,d.begin()})}renderForm({selector:e,intentId:t}){return h.throwIf(!e,"selector is required for renderForm"),h.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){h.warnIf(!!e&&!h.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...h.supportedLanguages].join(" | ")})`);const t=h.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return h.throwIf(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(o=>{h.throwIf(!o.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:o}){const r=[],a={},c=new Map;let i=!1;return P(this,M,re).call(this,r),{create:({elementType:n,elementOptions:l})=>{var D,W;const d=new Map;let u=null,p;const m=k(k({},t),l.classes),f=((D=m==null?void 0:m.focus)==null?void 0:D.split(" "))||["MoneyHashElement--focus"],H=((W=m==null?void 0:m.error)==null?void 0:W.split(" "))||["MoneyHashElement--error"];return{mount:()=>{p=document.querySelector(l.selector),h.throwIf(!p,`Couldn't find an element with selector ${l.selector}!`),p.classList.add("MoneyHashElement"),r.push(g=>{var j,x,T,B,Y,O,z;const{type:E,data:I}=g.data;if(E===`${n}@mount`&&(a[n]=I.isValid,(j=d.get(`${n}@mount`))==null||j()),E===`${n}@focus`){p.classList.add(...f),(x=d.get(`${n}@focus`))==null||x();return}if(E===`${n}@blur`){p.classList.remove(...f),(T=d.get(`${n}@blur`))==null||T();return}if(E===`${n}@error`){I.isValid?p.classList.remove(...H):p.classList.add(...H),(B=d.get(`${n}@error`))==null||B(I);return}if(E===`${n}@changeInput`){if((Y=d.get(`${n}@changeInput`))==null||Y({isValid:I.isValid,length:I.length}),a[n]=I.isValid,c.get("validityChange")){const V=Object.values(a).every(Boolean);V!==i&&((O=c.get("validityChange"))==null||O(V),i=V)}return}E===`${n}@cardNumberChange`&&((z=d.get(`${n}@cardNumberChange`))==null||z(I))}),u=P(this,_,ae).call(this,{container:p,elementType:n,elementOptions:l,styles:k(k({},e),l.styles),fontSourceCss:o}),this.mountedCardElements.push(n)},on:(g,E)=>{d.set(`${n}@${g}`,E)},off:g=>d.delete(`${n}@${g}`),focus:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"focus"},S())},blur:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"blur"},S())},clear:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"clear"},S())}}},on:(n,l)=>{c.set(n,l)}}}submitForm(c){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:o,shippingData:r,saveCard:a}){const i=me(this.mountedCardElements);h.throwIf(!!i,`You must mount ${i} element!`);const n=new G;let l,d;t&&(this.vaultSubmitListener.current=p=>{const{type:m,data:f}=p.data;m==="vaultSubmit:success"&&n.resolve(f),m==="vaultSubmit:error"&&n.reject(f)},d=P(this,F,ie).call(this,{accessToken:t,saveCard:a}),l=yield n.promise);const u=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:o,shippingData:r,cardEmbed:l}});return d&&d.remove(),u})}submitCvv(o){return w(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(a){return w(this,arguments,function*({intentId:e,url:t,renderStrategy:o,options:r}){switch(o){case"IFRAME":return P(this,C,Z).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return P(this,U,ee).call(this,{url:t,intentId:e,options:r});case"REDIRECT":return P(this,R,te).call(this,{url:t,options:r});default:return null}})}onExpiration(e,t){if(!e)return h.warnIf(!0,`No expiration date provided!, make sure to check for it before usage

@@ -7,2 +7,2 @@ if (intentDetails.intent.expirationDate) {

})
}`),()=>{};const o=new Date(e),r=setInterval(()=>w(this,null,function*(){const a=new Date;o<a&&(clearInterval(r),t())}),1e3);return()=>clearInterval(r)}}C=new WeakSet,Z=function(o){return w(this,arguments,function*({intentId:e,url:t}){const r=document.querySelector("#rendered-url-iframe-container");h.throwIf(!r,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const a=document.createElement("iframe");a.src=t,a.style.setProperty("border","0","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("height","100%","important"),r==null||r.replaceChildren(a),yield P(this,A,N).call(this,{intentId:e}),a.remove()})},U=new WeakSet,ee=function(r){return w(this,arguments,function*({intentId:e,url:t,options:o={}}){const{width:a=600,height:c=400,left:i=200,top:n=200}=o.window||{},l=window.open(t,"",`width=${a},height=${c},left=${i},top=${n}`);h.throwIf(!l,"Popup blocked by browser!"),yield P(this,A,N).call(this,{intentId:e,isUsingPopUp:!0}),l==null||l.close()})},R=new WeakSet,te=function(o){return w(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},A=new WeakSet,N=function(o){return w(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const r=new G,a=c=>w(this,null,function*(){var n,l,d,p;if(c.origin!==h.getIframeUrl())return;const{type:i}=c.data;if(i==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[u]=yield Promise.all([this.getIntentDetails(e),we(2)]),m=u.transaction.status.split(".")[1];m==="successful"||m.startsWith("pending")?(l=(n=this.options).onComplete)==null||l.call(n,k({type:this.options.type},u)):(p=(d=this.options).onFail)==null||p.call(d,k({type:this.options.type},u)),r.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),r.promise})},M=new WeakSet,re=function(e){const t=o=>{o.origin===S()&&e.forEach(r=>{r(o)})};window.addEventListener("message",t)},$=new WeakSet,ne=function(e){const t=o=>{e.current&&e.current(o)};window.addEventListener("message",t)},_=new WeakSet,ae=function({container:e,elementType:t,elementOptions:o,styles:r,fontSourceCss:a}){var l,d,p,u;const c=S(),i=new URL(`${c}/vaultField/vaultField.html`);a&&i.searchParams.set("fontSourceCss",a),i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("type",t),((l=o.validation)==null?void 0:l.required)!==void 0&&i.searchParams.set("required",`${(d=o.validation)==null?void 0:d.required}`),i.searchParams.set("placeholder",(p=o.placeholder)!=null?p:""),i.searchParams.set("lang",this.sdkEmbed.lang),i.searchParams.set("direction",(r==null?void 0:r.direction)||""),i.searchParams.set("color",JSON.stringify(r!=null&&r.color?r.color:"#000")),i.searchParams.set("placeholderColor",(r==null?void 0:r.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(r==null?void 0:r.backgroundColor)||"transparent"),i.searchParams.set("fontSize",(r==null?void 0:r.fontSize)||""),i.searchParams.set("fontFamily",(r==null?void 0:r.fontFamily)||""),i.searchParams.set("fontWeight",`${r==null?void 0:r.fontWeight}`),i.searchParams.set("fontStyle",(r==null?void 0:r.fontStyle)||""),i.searchParams.set("padding",(r==null?void 0:r.padding)||"");const n=document.createElement("iframe");return n.src=i.toString(),n.style.height=(u=r==null?void 0:r.height)!=null?u:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n),n},F=new WeakSet,ie=function({accessToken:e,saveCard:t}){const o=S(),r=he(),a=new URL(`${o}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&a.searchParams.set("save_card",`${t}`);const c=document.createElement("iframe");return c.id="moneyhash-submit-iframe",c.src=a.toString(),c.hidden=!0,document.body.appendChild(c),c};module.exports=ve;
}`),()=>{};const o=new Date(e),r=setInterval(()=>w(this,null,function*(){const a=new Date;o<a&&(clearInterval(r),t())}),1e3);return()=>clearInterval(r)}}C=new WeakSet,Z=function(o){return w(this,arguments,function*({intentId:e,url:t}){const r=document.querySelector("#rendered-url-iframe-container");h.throwIf(!r,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const a=document.createElement("iframe");a.src=t,a.style.setProperty("border","0","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("height","100%","important"),r==null||r.replaceChildren(a),yield P(this,A,N).call(this,{intentId:e}),a.remove()})},U=new WeakSet,ee=function(r){return w(this,arguments,function*({intentId:e,url:t,options:o={}}){const{width:a=600,height:c=400,left:i=200,top:n=200}=o.window||{},l=window.open(t,"",`width=${a},height=${c},left=${i},top=${n}`);h.throwIf(!l,"Popup blocked by browser!"),yield P(this,A,N).call(this,{intentId:e,isUsingPopUp:!0}),l==null||l.close()})},R=new WeakSet,te=function(o){return w(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},A=new WeakSet,N=function(o){return w(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const r=new G,a=c=>w(this,null,function*(){var n,l,d,u;if(c.origin!==h.getIframeUrl())return;const{type:i}=c.data;if(i==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[p]=yield Promise.all([this.getIntentDetails(e),we(2)]),m=p.transaction.status.split(".")[1];m==="successful"||m.startsWith("pending")?(l=(n=this.options).onComplete)==null||l.call(n,k({type:this.options.type},p)):(u=(d=this.options).onFail)==null||u.call(d,k({type:this.options.type},p)),r.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),r.promise})},M=new WeakSet,re=function(e){const t=o=>{o.origin===S()&&e.forEach(r=>{r(o)})};window.addEventListener("message",t)},$=new WeakSet,ne=function(e){const t=o=>{e.current&&e.current(o)};window.addEventListener("message",t)},_=new WeakSet,ae=function({container:e,elementType:t,elementOptions:o,styles:r,fontSourceCss:a}){var l,d,u,p;const c=S(),i=new URL(`${c}/vaultField/vaultField.html`);a&&i.searchParams.set("fontSourceCss",a),i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("type",t),((l=o.validation)==null?void 0:l.required)!==void 0&&i.searchParams.set("required",`${(d=o.validation)==null?void 0:d.required}`),i.searchParams.set("placeholder",(u=o.placeholder)!=null?u:""),i.searchParams.set("lang",this.sdkEmbed.lang),i.searchParams.set("direction",(r==null?void 0:r.direction)||""),i.searchParams.set("color",JSON.stringify(r!=null&&r.color?r.color:"#000")),i.searchParams.set("placeholderColor",(r==null?void 0:r.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(r==null?void 0:r.backgroundColor)||"transparent"),i.searchParams.set("fontSize",(r==null?void 0:r.fontSize)||""),i.searchParams.set("fontFamily",(r==null?void 0:r.fontFamily)||""),i.searchParams.set("fontWeight",`${r==null?void 0:r.fontWeight}`),i.searchParams.set("fontStyle",(r==null?void 0:r.fontStyle)||""),i.searchParams.set("padding",(r==null?void 0:r.padding)||"");const n=document.createElement("iframe");return n.src=i.toString(),n.style.height=(p=r==null?void 0:r.height)!=null?p:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n),n},F=new WeakSet,ie=function({accessToken:e,saveCard:t}){const o=S(),r=he(),a=new URL(`${o}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&a.searchParams.set("save_card",`${t}`);const c=document.createElement("iframe");return c.id="moneyhash-submit-iframe",c.src=a.toString(),c.hidden=!0,document.body.appendChild(c),c};module.exports=ve;

@@ -24,18 +24,18 @@ var ce = Object.defineProperty, le = Object.defineProperties;

var f = (s, e, t) => new Promise((o, r) => {
var a = (n) => {
var n = (a) => {
try {
i(t.next(n));
i(t.next(a));
} catch (l) {
r(l);
}
}, c = (n) => {
}, c = (a) => {
try {
i(t.throw(n));
i(t.throw(a));
} catch (l) {
r(l);
}
}, i = (n) => n.done ? o(n.value) : Promise.resolve(n.value).then(a, c);
}, i = (a) => a.done ? o(a.value) : Promise.resolve(a.value).then(n, c);
i((t = t.apply(s, e)).next());
});
import { M as ge, g as te, S as fe, t as P, w as Q, s as q } from "./warnIf-1fdf6f75.js";
import { M as ge, g as te, S as fe, t as P, w as Q, s as q } from "./warnIf-daa85568.js";
function ve() {

@@ -52,3 +52,3 @@ return typeof window != "undefined";

const e = te(), t = new URL(`${e}/embed/headless-sdk`);
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.5.1");
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.5.2-beta.0");
const o = document.createElement("iframe");

@@ -60,7 +60,7 @@ o.id = "moneyhash-headless-sdk", o.src = t.toString(), o.hidden = !0, document.body.appendChild(o), w.messagingService = new ge({

var c;
const a = (i) => {
var n;
i.data.type === "headlessSDK:init" && (r(), (n = w.messagingService) == null || n.removeListener(a));
const n = (i) => {
var a;
i.data.type === "headlessSDK:init" && (r(), (a = w.messagingService) == null || a.removeListener(n));
};
(c = w.messagingService) == null || c.onReceive(a);
(c = w.messagingService) == null || c.onReceive(n);
});

@@ -73,4 +73,4 @@ }

}) {
return yield w.isCommunicationReady, new Promise((r, a) => {
var i, n;
return yield w.isCommunicationReady, new Promise((r, n) => {
var i, a;
(i = w.messagingService) == null || i.send({

@@ -81,7 +81,7 @@ type: e,

const c = (l) => {
var u;
const { type: d, data: p } = l.data;
d === e && (p.status === "resolved" ? r(p.payload) : a(p.payload), (u = w.messagingService) == null || u.removeListener(c));
var p;
const { type: d, data: u } = l.data;
d === e && (u.status === "resolved" ? r(u.payload) : n(u.payload), (p = w.messagingService) == null || p.removeListener(c));
};
(n = w.messagingService) == null || n.onReceive(c);
(a = w.messagingService) == null || a.onReceive(c);
});

@@ -140,8 +140,8 @@ });

}
const a = document.createElement("script");
a.src = s, a.id = e, a.addEventListener("load", () => {
const n = document.createElement("script");
n.src = s, n.id = e, n.addEventListener("load", () => {
t(void 0);
}), a.addEventListener("error", () => {
}), n.addEventListener("error", () => {
o(new Error("Script failed to load"));
}), document.body.appendChild(a);
}), document.body.appendChild(n);
});

@@ -161,3 +161,3 @@ }

]);
var C, re, U, ne, R, ae, I, H, M, ie, $, se, _, oe, F, de;
var C, re, U, ae, R, ne, I, H, M, ie, $, se, _, oe, F, de;
class Le {

@@ -389,7 +389,7 @@ constructor(e) {

countryCode: r,
onCancel: a = () => {
onCancel: n = () => {
},
onError: c,
onComplete: i,
billingData: n = {}
billingData: a = {}
}) {

@@ -411,3 +411,3 @@ if (yield be(

}
}), { state: p, intent: u } = yield this.proceedWith({
}), { state: u, intent: p } = yield this.proceedWith({
intentId: e,

@@ -418,4 +418,4 @@ type: "method",

try {
if (p === "INTENT_FORM") {
if (Pe(n))
if (u === "INTENT_FORM") {
if (Pe(a))
throw new Error(

@@ -430,3 +430,3 @@ "Billing data is missing while calling payWithApplePay"

lang: this.sdkEmbed.lang,
billingData: n
billingData: a
}

@@ -445,3 +445,3 @@ });

body: JSON.stringify({
secret: u.secret,
secret: p.secret,
validation_url: m.validationURL

@@ -460,3 +460,3 @@ })

token_data: m.payment.token,
secret: u.secret
secret: p.secret
})

@@ -468,3 +468,3 @@ }).then((g) => g.ok ? g.json() : Promise.reject()).then(() => {

});
}, d.oncancel = a, d.begin();
}, d.oncancel = n, d.begin();
});

@@ -588,3 +588,3 @@ }

elements({ styles: e, classes: t, fontSourceCss: o }) {
const r = [], a = {}, c = /* @__PURE__ */ new Map();
const r = [], n = {}, c = /* @__PURE__ */ new Map();
let i = !1;

@@ -613,13 +613,6 @@ return y(this, M, ie).call(this, r), {

*/
create: ({ elementType: n, elementOptions: l }) => {
create: ({ elementType: a, elementOptions: l }) => {
var W, j;
const d = /* @__PURE__ */ new Map(), p = document.querySelector(
l.selector
);
P(
!p,
`Couldn't find an element with selector ${l.selector}!`
);
let u = null;
p.classList.add("MoneyHashElement");
const d = /* @__PURE__ */ new Map();
let u = null, p;
const m = k(k({}, t), l.classes), g = ((W = m == null ? void 0 : m.focus) == null ? void 0 : W.split(" ")) || [

@@ -630,42 +623,51 @@ "MoneyHashElement--focus"

];
return r.push((h) => {
var x, T, B, Y, O, z, J;
const { type: E, data: S } = h.data;
if (E === `${n}@mount` && (a[n] = S.isValid, (x = d.get(`${n}@mount`)) == null || x()), E === `${n}@focus`) {
p.classList.add(...g), (T = d.get(`${n}@focus`)) == null || T();
return;
}
if (E === `${n}@blur`) {
p.classList.remove(...g), (B = d.get(`${n}@blur`)) == null || B();
return;
}
if (E === `${n}@error`) {
S.isValid ? p.classList.remove(...D) : p.classList.add(...D), (Y = d.get(`${n}@error`)) == null || Y(S);
return;
}
if (E === `${n}@changeInput`) {
if ((O = d.get(`${n}@changeInput`)) == null || O({
isValid: S.isValid,
length: S.length
}), a[n] = S.isValid, c.get("validityChange")) {
const V = Object.values(a).every(Boolean);
V !== i && ((z = c.get("validityChange")) == null || z(V), i = V);
}
return;
}
E === `${n}@cardNumberChange` && ((J = d.get(`${n}@cardNumberChange`)) == null || J(S));
}), {
return {
mount: () => {
this.mountedCardElements.push(n), u = y(this, _, oe).call(this, {
p = document.querySelector(
l.selector
), P(
!p,
`Couldn't find an element with selector ${l.selector}!`
), p.classList.add("MoneyHashElement"), r.push((h) => {
var x, T, B, Y, O, z, J;
const { type: E, data: S } = h.data;
if (E === `${a}@mount` && (n[a] = S.isValid, (x = d.get(`${a}@mount`)) == null || x()), E === `${a}@focus`) {
p.classList.add(...g), (T = d.get(`${a}@focus`)) == null || T();
return;
}
if (E === `${a}@blur`) {
p.classList.remove(...g), (B = d.get(`${a}@blur`)) == null || B();
return;
}
if (E === `${a}@error`) {
S.isValid ? p.classList.remove(...D) : p.classList.add(...D), (Y = d.get(`${a}@error`)) == null || Y(S);
return;
}
if (E === `${a}@changeInput`) {
if ((O = d.get(`${a}@changeInput`)) == null || O({
isValid: S.isValid,
length: S.length
}), n[a] = S.isValid, c.get("validityChange")) {
const V = Object.values(n).every(Boolean);
V !== i && ((z = c.get("validityChange")) == null || z(
V
), i = V);
}
return;
}
E === `${a}@cardNumberChange` && ((J = d.get(`${a}@cardNumberChange`)) == null || J(
S
));
}), u = y(this, _, oe).call(this, {
container: p,
elementType: n,
elementType: a,
elementOptions: l,
styles: k(k({}, e), l.styles),
fontSourceCss: o
});
}), this.mountedCardElements.push(a);
},
on: (h, E) => {
d.set(`${n}@${h}`, E);
d.set(`${a}@${h}`, E);
},
off: (h) => d.delete(`${n}@${h}`),
off: (h) => d.delete(`${a}@${h}`),
focus: () => {

@@ -694,4 +696,4 @@ var h;

},
on: (n, l) => {
c.set(n, l);
on: (a, l) => {
c.set(a, l);
}

@@ -720,3 +722,3 @@ };

shippingData: r,
saveCard: a
saveCard: n
}) {

@@ -728,9 +730,9 @@ const i = ye(this.mountedCardElements);

);
const n = new X();
const a = new X();
let l, d;
t && (this.vaultSubmitListener.current = (u) => {
const { type: m, data: g } = u.data;
m === "vaultSubmit:success" && n.resolve(g), m === "vaultSubmit:error" && n.reject(g);
}, d = y(this, F, de).call(this, { accessToken: t, saveCard: a }), l = yield n.promise);
const p = yield this.sdkApiHandler.request({
t && (this.vaultSubmitListener.current = (p) => {
const { type: m, data: g } = p.data;
m === "vaultSubmit:success" && a.resolve(g), m === "vaultSubmit:error" && a.reject(g);
}, d = y(this, F, de).call(this, { accessToken: t, saveCard: n }), l = yield a.promise);
const u = yield this.sdkApiHandler.request({
api: "sdk:submitNativeForm",

@@ -746,3 +748,3 @@ payload: {

});
return d && d.remove(), p;
return d && d.remove(), u;
});

@@ -784,3 +786,3 @@ }

*/
renderUrl(a) {
renderUrl(n) {
return f(this, arguments, function* ({

@@ -796,5 +798,5 @@ intentId: e,

case "POPUP_IFRAME":
return y(this, U, ne).call(this, { url: t, intentId: e, options: r });
return y(this, U, ae).call(this, { url: t, intentId: e, options: r });
case "REDIRECT":
return y(this, R, ae).call(this, { url: t, options: r });
return y(this, R, ne).call(this, { url: t, options: r });
default:

@@ -830,4 +832,4 @@ return null;

const o = new Date(e), r = setInterval(() => f(this, null, function* () {
const a = new Date();
o < a && (clearInterval(r), t());
const n = new Date();
o < n && (clearInterval(r), t());
}), 1e3);

@@ -847,6 +849,6 @@ return () => clearInterval(r);

);
const a = document.createElement("iframe");
a.src = t, a.style.setProperty("border", "0", "important"), a.style.setProperty("width", "100%", "important"), a.style.setProperty("height", "100%", "important"), r == null || r.replaceChildren(a), yield y(this, I, H).call(this, { intentId: e }), a.remove();
const n = document.createElement("iframe");
n.src = t, n.style.setProperty("border", "0", "important"), n.style.setProperty("width", "100%", "important"), n.style.setProperty("height", "100%", "important"), r == null || r.replaceChildren(n), yield y(this, I, H).call(this, { intentId: e }), n.remove();
});
}, U = new WeakSet(), ne = function(r) {
}, U = new WeakSet(), ae = function(r) {
return f(this, arguments, function* ({

@@ -858,14 +860,14 @@ intentId: e,

const {
width: a = 600,
width: n = 600,
height: c = 400,
left: i = 200,
top: n = 200
top: a = 200
} = o.window || {}, l = window.open(
t,
"",
`width=${a},height=${c},left=${i},top=${n}`
`width=${n},height=${c},left=${i},top=${a}`
);
P(!l, "Popup blocked by browser!"), yield y(this, I, H).call(this, { intentId: e, isUsingPopUp: !0 }), l == null || l.close();
});
}, R = new WeakSet(), ae = function(o) {
}, R = new WeakSet(), ne = function(o) {
return f(this, arguments, function* ({

@@ -886,4 +888,4 @@ url: e,

}) {
const r = new X(), a = (c) => f(this, null, function* () {
var n, l, d, p;
const r = new X(), n = (c) => f(this, null, function* () {
var a, l, d, u;
if (c.origin !== te())

@@ -894,14 +896,14 @@ return;

t && this.sdkApiHandler.postMessage("EmbedResultClose");
const [u] = yield Promise.all([
const [p] = yield Promise.all([
this.getIntentDetails(e),
Ee(2)
]), m = u.transaction.status.split(".")[1];
m === "successful" || m.startsWith("pending") ? (l = (n = this.options).onComplete) == null || l.call(n, k({
]), m = p.transaction.status.split(".")[1];
m === "successful" || m.startsWith("pending") ? (l = (a = this.options).onComplete) == null || l.call(a, k({
type: this.options.type
}, u)) : (p = (d = this.options).onFail) == null || p.call(d, k({
}, p)) : (u = (d = this.options).onFail) == null || u.call(d, k({
type: this.options.type
}, u)), r.resolve(() => null), window.removeEventListener("message", a);
}, p)), r.resolve(() => null), window.removeEventListener("message", n);
}
});
return window.addEventListener("message", a), r.promise;
return window.addEventListener("message", n), r.promise;
});

@@ -925,10 +927,10 @@ }, M = new WeakSet(), ie = function(e) {

styles: r,
fontSourceCss: a
fontSourceCss: n
}) {
var l, d, p, u;
var l, d, u, p;
const c = A(), i = new URL(`${c}/vaultField/vaultField.html`);
a && i.searchParams.set("fontSourceCss", a), i.searchParams.set("host", btoa(window.location.origin)), i.searchParams.set("type", t), ((l = o.validation) == null ? void 0 : l.required) !== void 0 && i.searchParams.set(
n && i.searchParams.set("fontSourceCss", n), i.searchParams.set("host", btoa(window.location.origin)), i.searchParams.set("type", t), ((l = o.validation) == null ? void 0 : l.required) !== void 0 && i.searchParams.set(
"required",
`${(d = o.validation) == null ? void 0 : d.required}`
), i.searchParams.set("placeholder", (p = o.placeholder) != null ? p : ""), i.searchParams.set("lang", this.sdkEmbed.lang), i.searchParams.set("direction", (r == null ? void 0 : r.direction) || ""), i.searchParams.set(
), i.searchParams.set("placeholder", (u = o.placeholder) != null ? u : ""), i.searchParams.set("lang", this.sdkEmbed.lang), i.searchParams.set("direction", (r == null ? void 0 : r.direction) || ""), i.searchParams.set(
"color",

@@ -943,4 +945,4 @@ JSON.stringify(r != null && r.color ? r.color : "#000")

), i.searchParams.set("fontSize", (r == null ? void 0 : r.fontSize) || ""), i.searchParams.set("fontFamily", (r == null ? void 0 : r.fontFamily) || ""), i.searchParams.set("fontWeight", `${r == null ? void 0 : r.fontWeight}`), i.searchParams.set("fontStyle", (r == null ? void 0 : r.fontStyle) || ""), i.searchParams.set("padding", (r == null ? void 0 : r.padding) || "");
const n = document.createElement("iframe");
return n.src = i.toString(), n.style.height = (u = r == null ? void 0 : r.height) != null ? u : "40px", n.style.setProperty("overflow", "hidden", "important"), n.style.setProperty("display", "block", "important"), n.style.setProperty("width", "100%", "important"), n.style.setProperty("maxWidth", "100%", "important"), n.style.setProperty("border", "0", "important"), n.style.setProperty("margin", "0", "important"), n.style.setProperty("padding", "0", "important"), n.style.setProperty("userSelect", "none", "important"), n.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(n), n;
const a = document.createElement("iframe");
return a.src = i.toString(), a.style.height = (p = r == null ? void 0 : r.height) != null ? p : "40px", a.style.setProperty("overflow", "hidden", "important"), a.style.setProperty("display", "block", "important"), a.style.setProperty("width", "100%", "important"), a.style.setProperty("maxWidth", "100%", "important"), a.style.setProperty("border", "0", "important"), a.style.setProperty("margin", "0", "important"), a.style.setProperty("padding", "0", "important"), a.style.setProperty("userSelect", "none", "important"), a.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(a), a;
}, F = new WeakSet(), de = function({

@@ -950,8 +952,8 @@ accessToken: e,

}) {
const o = A(), r = we(), a = new URL(
const o = A(), r = we(), n = new URL(
`${o}/vaultSubmit/vaultSubmit.html`
);
a.searchParams.set("host", btoa(window.location.origin)), a.searchParams.set("vault_api_url", `${r}/api/v1/tokens/`), a.searchParams.set("access_token", e), a.searchParams.set("lang", this.sdkEmbed.lang), t !== void 0 && a.searchParams.set("save_card", `${t}`);
n.searchParams.set("host", btoa(window.location.origin)), n.searchParams.set("vault_api_url", `${r}/api/v1/tokens/`), n.searchParams.set("access_token", e), n.searchParams.set("lang", this.sdkEmbed.lang), t !== void 0 && n.searchParams.set("save_card", `${t}`);
const c = document.createElement("iframe");
return c.id = "moneyhash-submit-iframe", c.src = a.toString(), c.hidden = !0, document.body.appendChild(c), c;
return c.id = "moneyhash-submit-iframe", c.src = n.toString(), c.hidden = !0, document.body.appendChild(c), c;
};

@@ -958,0 +960,0 @@ export {

@@ -1,2 +0,2 @@

(function(l,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o():typeof define=="function"&&define.amd?define(o):(l=typeof globalThis!="undefined"?globalThis:l||self,l.MoneyHash=o())})(this,function(){var q,oe,j,de,D,ce,F,z,W,le,x,he,T,me,O,ue;"use strict";var we=Object.defineProperty,be=Object.defineProperties;var Ee=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var Y=(l,o,u)=>o in l?we(l,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[o]=u,k=(l,o)=>{for(var u in o||(o={}))Pe.call(o,u)&&Y(l,u,o[u]);if(re)for(var u of re(o))Se.call(o,u)&&Y(l,u,o[u]);return l},ae=(l,o)=>be(l,Ee(o));var y=(l,o,u)=>(Y(l,typeof o!="symbol"?o+"":o,u),u),ke=(l,o,u)=>{if(!o.has(l))throw TypeError("Cannot "+u)};var A=(l,o,u)=>{if(o.has(l))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(l):o.set(l,u)};var L=(l,o,u)=>(ke(l,o,"access private method"),u);var E=(l,o,u)=>new Promise((I,w)=>{var V=S=>{try{$(u.next(S))}catch(_){w(_)}},M=S=>{try{$(u.throw(S))}catch(_){w(_)}},$=S=>S.done?I(S.value):Promise.resolve(S.value).then(V,M);$((u=u.apply(l,o)).next())});class l{constructor(e){y(this,"target");y(this,"targetOrigin");y(this,"listeners");y(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function o(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function u(){return typeof window!="undefined"}const P=class{constructor(){u()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=o(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.5.1");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),P.messagingService=new l({target:r.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(i=>{var h;const s=a=>{var n;a.data.type==="headlessSDK:init"&&(i(),(n=P.messagingService)==null||n.removeListener(s))};(h=P.messagingService)==null||h.onReceive(s)})}request(r){return E(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((i,s)=>{var a,n;(a=P.messagingService)==null||a.send({type:e,data:t});const h=m=>{var c;const{type:d,data:p}=m.data;d===e&&(p.status==="resolved"?i(p.payload):s(p.payload),(c=P.messagingService)==null||c.removeListener(h))};(n=P.messagingService)==null||n.onReceive(h)})})}postMessage(e){var t;(t=P.messagingService)==null||t.send({type:e})}};let I=P;y(I,"messagingService",null),y(I,"isCommunicationReady");function w(f,e){if(f)throw new Error(e)}const V=new Set(["payment","payout"]),M=new Set(["en","fr","ar"]);class ${constructor(e){y(this,"options");y(this,"messagingService",null);y(this,"iframe",null);y(this,"isCommunicationReady",null);w(!V.has(e.type),`MoneyHash constructor must be called with valid type (${[...V].join(" | ")})!`),this.options=e}get lang(){var t;return((t=this.options.locale)==null?void 0:t.split("-")[0])||"en"}render({selector:e,intentId:t}){var a,n;(a=this.messagingService)==null||a.abortService();const r=o(),i=new URL(`${r}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.5.1");const s=(n=this.options.locale)==null?void 0:n.split("-")[0];s&&i.searchParams.set("lang",s),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const h=document.querySelector(e);return w(!h,`Couldn't find an element with selector ${e}!`),h.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:r}),this.isCommunicationReady=new Promise(m=>{var p;const d=c=>{var g;c.data.type==="sdk:init"&&(m(),(g=this.messagingService)==null||g.removeListener(d))};(p=this.messagingService)==null||p.onReceive(d)}),this.messagingService.onReceive((m,d)=>{var g,v,H,N;const{type:p,data:c}=m.data;switch(p){case"sdk:init":{d({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(v=(g=this.options).onComplete)==null||v.call(g,k({type:this.options.type},c)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(N=(H=this.options).onFail)==null||N.call(H,k({type:this.options.type},c)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return E(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class S{constructor(){y(this,"promise");y(this,"resolve");y(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function _(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function U(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function J(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function pe(f){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!f.includes(t))return t;return null}function ge(f){return(Array.isArray(f)?f.length:Object.keys(f).length)===0}function fe(f,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const s=document.createElement("script");s.src=f,s.id=e,s.addEventListener("load",()=>{t(void 0)}),s.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(s)})}function ye(f){return new Promise(e=>{setTimeout(()=>{e("done")},f*1e3)})}function K(f,e){f&&console.warn(e)}const G=new Set(["method","customerBalance","savedCard"]);class ve{constructor(e){A(this,q);A(this,j);A(this,D);A(this,F);A(this,W);A(this,x);A(this,T);A(this,O);y(this,"options");y(this,"sdkApiHandler",new I);y(this,"sdkEmbed");y(this,"vaultSubmitListener",{current:null});y(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new $(ae(k({},e),{headless:!0})),L(this,x,he).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:r,metaData:i}){return w(!G.has(t),`type must be a valid one (${[...G].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return w(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(m){return E(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:i,onCancel:s=()=>{},onError:h,onComplete:a,billingData:n={}}){if(yield fe("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{state:p,intent:c}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(p==="INTENT_FORM"){if(ge(n))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:n}})}}catch(g){throw yield this.resetSelectedMethod(e),g}d.onvalidatemerchant=g=>{fetch(`${J()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:c.secret,validation_url:g.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>d.completeMerchantValidation(v)).catch(h)},d.onpaymentauthorized=g=>{fetch(`${J()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:c.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),h()})},d.oncancel=s,d.begin()})}renderForm({selector:e,intentId:t}){return w(!e,"selector is required for renderForm"),w(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){K(!!e&&!M.has(e),`Invalid locale. Supported languages (${[...M].join(" | ")})`);const t=M.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return w(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(r=>{w(!r.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:r}){const i=[],s={},h=new Map;let a=!1;return L(this,W,le).call(this,i),{create:({elementType:n,elementOptions:m})=>{var N,Q;const d=new Map,p=document.querySelector(m.selector);w(!p,`Couldn't find an element with selector ${m.selector}!`);let c=null;p.classList.add("MoneyHashElement");const g=k(k({},t),m.classes),v=((N=g==null?void 0:g.focus)==null?void 0:N.split(" "))||["MoneyHashElement--focus"],H=((Q=g==null?void 0:g.error)==null?void 0:Q.split(" "))||["MoneyHashElement--error"];return i.push(b=>{var X,Z,ee,te,ie,ne,se;const{type:R,data:C}=b.data;if(R===`${n}@mount`&&(s[n]=C.isValid,(X=d.get(`${n}@mount`))==null||X()),R===`${n}@focus`){p.classList.add(...v),(Z=d.get(`${n}@focus`))==null||Z();return}if(R===`${n}@blur`){p.classList.remove(...v),(ee=d.get(`${n}@blur`))==null||ee();return}if(R===`${n}@error`){C.isValid?p.classList.remove(...H):p.classList.add(...H),(te=d.get(`${n}@error`))==null||te(C);return}if(R===`${n}@changeInput`){if((ie=d.get(`${n}@changeInput`))==null||ie({isValid:C.isValid,length:C.length}),s[n]=C.isValid,h.get("validityChange")){const B=Object.values(s).every(Boolean);B!==a&&((ne=h.get("validityChange"))==null||ne(B),a=B)}return}R===`${n}@cardNumberChange`&&((se=d.get(`${n}@cardNumberChange`))==null||se(C))}),{mount:()=>{this.mountedCardElements.push(n),c=L(this,T,me).call(this,{container:p,elementType:n,elementOptions:m,styles:k(k({},e),m.styles),fontSourceCss:r})},on:(b,R)=>{d.set(`${n}@${b}`,R)},off:b=>d.delete(`${n}@${b}`),focus:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"focus"},U())},blur:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"blur"},U())},clear:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"clear"},U())}}},on:(n,m)=>{h.set(n,m)}}}submitForm(h){return E(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:i,saveCard:s}){const a=pe(this.mountedCardElements);w(!!a,`You must mount ${a} element!`);const n=new S;let m,d;t&&(this.vaultSubmitListener.current=c=>{const{type:g,data:v}=c.data;g==="vaultSubmit:success"&&n.resolve(v),g==="vaultSubmit:error"&&n.reject(v)},d=L(this,O,ue).call(this,{accessToken:t,saveCard:s}),m=yield n.promise);const p=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:i,cardEmbed:m}});return d&&d.remove(),p})}submitCvv(r){return E(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(s){return E(this,arguments,function*({intentId:e,url:t,renderStrategy:r,options:i}){switch(r){case"IFRAME":return L(this,q,oe).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return L(this,j,de).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return L(this,D,ce).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return K(!0,`No expiration date provided!, make sure to check for it before usage
(function(l,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o():typeof define=="function"&&define.amd?define(o):(l=typeof globalThis!="undefined"?globalThis:l||self,l.MoneyHash=o())})(this,function(){var q,oe,j,de,D,ce,F,z,W,le,x,he,T,me,O,ue;"use strict";var we=Object.defineProperty,be=Object.defineProperties;var Ee=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var Y=(l,o,p)=>o in l?we(l,o,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[o]=p,k=(l,o)=>{for(var p in o||(o={}))Pe.call(o,p)&&Y(l,p,o[p]);if(re)for(var p of re(o))Se.call(o,p)&&Y(l,p,o[p]);return l},ae=(l,o)=>be(l,Ee(o));var y=(l,o,p)=>(Y(l,typeof o!="symbol"?o+"":o,p),p),ke=(l,o,p)=>{if(!o.has(l))throw TypeError("Cannot "+p)};var A=(l,o,p)=>{if(o.has(l))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(l):o.set(l,p)};var L=(l,o,p)=>(ke(l,o,"access private method"),p);var E=(l,o,p)=>new Promise((I,w)=>{var V=S=>{try{$(p.next(S))}catch(_){w(_)}},M=S=>{try{$(p.throw(S))}catch(_){w(_)}},$=S=>S.done?I(S.value):Promise.resolve(S.value).then(V,M);$((p=p.apply(l,o)).next())});class l{constructor(e){y(this,"target");y(this,"targetOrigin");y(this,"listeners");y(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function o(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function p(){return typeof window!="undefined"}const P=class{constructor(){p()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=o(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.5.2-beta.0");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),P.messagingService=new l({target:r.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(i=>{var h;const s=a=>{var n;a.data.type==="headlessSDK:init"&&(i(),(n=P.messagingService)==null||n.removeListener(s))};(h=P.messagingService)==null||h.onReceive(s)})}request(r){return E(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((i,s)=>{var a,n;(a=P.messagingService)==null||a.send({type:e,data:t});const h=u=>{var m;const{type:d,data:c}=u.data;d===e&&(c.status==="resolved"?i(c.payload):s(c.payload),(m=P.messagingService)==null||m.removeListener(h))};(n=P.messagingService)==null||n.onReceive(h)})})}postMessage(e){var t;(t=P.messagingService)==null||t.send({type:e})}};let I=P;y(I,"messagingService",null),y(I,"isCommunicationReady");function w(f,e){if(f)throw new Error(e)}const V=new Set(["payment","payout"]),M=new Set(["en","fr","ar"]);class ${constructor(e){y(this,"options");y(this,"messagingService",null);y(this,"iframe",null);y(this,"isCommunicationReady",null);w(!V.has(e.type),`MoneyHash constructor must be called with valid type (${[...V].join(" | ")})!`),this.options=e}get lang(){var t;return((t=this.options.locale)==null?void 0:t.split("-")[0])||"en"}render({selector:e,intentId:t}){var a,n;(a=this.messagingService)==null||a.abortService();const r=o(),i=new URL(`${r}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.5.2-beta.0");const s=(n=this.options.locale)==null?void 0:n.split("-")[0];s&&i.searchParams.set("lang",s),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const h=document.querySelector(e);return w(!h,`Couldn't find an element with selector ${e}!`),h.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:r}),this.isCommunicationReady=new Promise(u=>{var c;const d=m=>{var g;m.data.type==="sdk:init"&&(u(),(g=this.messagingService)==null||g.removeListener(d))};(c=this.messagingService)==null||c.onReceive(d)}),this.messagingService.onReceive((u,d)=>{var g,v,H,N;const{type:c,data:m}=u.data;switch(c){case"sdk:init":{d({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(v=(g=this.options).onComplete)==null||v.call(g,k({type:this.options.type},m)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(N=(H=this.options).onFail)==null||N.call(H,k({type:this.options.type},m)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return E(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class S{constructor(){y(this,"promise");y(this,"resolve");y(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function _(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function U(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function J(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function pe(f){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!f.includes(t))return t;return null}function ge(f){return(Array.isArray(f)?f.length:Object.keys(f).length)===0}function fe(f,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const s=document.createElement("script");s.src=f,s.id=e,s.addEventListener("load",()=>{t(void 0)}),s.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(s)})}function ye(f){return new Promise(e=>{setTimeout(()=>{e("done")},f*1e3)})}function K(f,e){f&&console.warn(e)}const G=new Set(["method","customerBalance","savedCard"]);class ve{constructor(e){A(this,q);A(this,j);A(this,D);A(this,F);A(this,W);A(this,x);A(this,T);A(this,O);y(this,"options");y(this,"sdkApiHandler",new I);y(this,"sdkEmbed");y(this,"vaultSubmitListener",{current:null});y(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new $(ae(k({},e),{headless:!0})),L(this,x,he).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}proceedWith({intentId:e,type:t,id:r,metaData:i}){return w(!G.has(t),`type must be a valid one (${[...G].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return w(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(u){return E(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:i,onCancel:s=()=>{},onError:h,onComplete:a,billingData:n={}}){if(yield fe("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{state:c,intent:m}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(c==="INTENT_FORM"){if(ge(n))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:n}})}}catch(g){throw yield this.resetSelectedMethod(e),g}d.onvalidatemerchant=g=>{fetch(`${J()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:m.secret,validation_url:g.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>d.completeMerchantValidation(v)).catch(h)},d.onpaymentauthorized=g=>{fetch(`${J()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:m.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),h()})},d.oncancel=s,d.begin()})}renderForm({selector:e,intentId:t}){return w(!e,"selector is required for renderForm"),w(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){K(!!e&&!M.has(e),`Invalid locale. Supported languages (${[...M].join(" | ")})`);const t=M.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return w(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(r=>{w(!r.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:r}){const i=[],s={},h=new Map;let a=!1;return L(this,W,le).call(this,i),{create:({elementType:n,elementOptions:u})=>{var N,Q;const d=new Map;let c=null,m;const g=k(k({},t),u.classes),v=((N=g==null?void 0:g.focus)==null?void 0:N.split(" "))||["MoneyHashElement--focus"],H=((Q=g==null?void 0:g.error)==null?void 0:Q.split(" "))||["MoneyHashElement--error"];return{mount:()=>{m=document.querySelector(u.selector),w(!m,`Couldn't find an element with selector ${u.selector}!`),m.classList.add("MoneyHashElement"),i.push(b=>{var X,Z,ee,te,ie,ne,se;const{type:R,data:C}=b.data;if(R===`${n}@mount`&&(s[n]=C.isValid,(X=d.get(`${n}@mount`))==null||X()),R===`${n}@focus`){m.classList.add(...v),(Z=d.get(`${n}@focus`))==null||Z();return}if(R===`${n}@blur`){m.classList.remove(...v),(ee=d.get(`${n}@blur`))==null||ee();return}if(R===`${n}@error`){C.isValid?m.classList.remove(...H):m.classList.add(...H),(te=d.get(`${n}@error`))==null||te(C);return}if(R===`${n}@changeInput`){if((ie=d.get(`${n}@changeInput`))==null||ie({isValid:C.isValid,length:C.length}),s[n]=C.isValid,h.get("validityChange")){const B=Object.values(s).every(Boolean);B!==a&&((ne=h.get("validityChange"))==null||ne(B),a=B)}return}R===`${n}@cardNumberChange`&&((se=d.get(`${n}@cardNumberChange`))==null||se(C))}),c=L(this,T,me).call(this,{container:m,elementType:n,elementOptions:u,styles:k(k({},e),u.styles),fontSourceCss:r}),this.mountedCardElements.push(n)},on:(b,R)=>{d.set(`${n}@${b}`,R)},off:b=>d.delete(`${n}@${b}`),focus:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"focus"},U())},blur:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"blur"},U())},clear:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"clear"},U())}}},on:(n,u)=>{h.set(n,u)}}}submitForm(h){return E(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:i,saveCard:s}){const a=pe(this.mountedCardElements);w(!!a,`You must mount ${a} element!`);const n=new S;let u,d;t&&(this.vaultSubmitListener.current=m=>{const{type:g,data:v}=m.data;g==="vaultSubmit:success"&&n.resolve(v),g==="vaultSubmit:error"&&n.reject(v)},d=L(this,O,ue).call(this,{accessToken:t,saveCard:s}),u=yield n.promise);const c=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:i,cardEmbed:u}});return d&&d.remove(),c})}submitCvv(r){return E(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(s){return E(this,arguments,function*({intentId:e,url:t,renderStrategy:r,options:i}){switch(r){case"IFRAME":return L(this,q,oe).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return L(this,j,de).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return L(this,D,ce).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return K(!0,`No expiration date provided!, make sure to check for it before usage

@@ -7,2 +7,2 @@ if (intentDetails.intent.expirationDate) {

})
}`),()=>{};const r=new Date(e),i=setInterval(()=>E(this,null,function*(){const s=new Date;r<s&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}return q=new WeakSet,oe=function(r){return E(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");w(!i,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const s=document.createElement("iframe");s.src=t,s.style.setProperty("border","0","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("height","100%","important"),i==null||i.replaceChildren(s),yield L(this,F,z).call(this,{intentId:e}),s.remove()})},j=new WeakSet,de=function(i){return E(this,arguments,function*({intentId:e,url:t,options:r={}}){const{width:s=600,height:h=400,left:a=200,top:n=200}=r.window||{},m=window.open(t,"",`width=${s},height=${h},left=${a},top=${n}`);w(!m,"Popup blocked by browser!"),yield L(this,F,z).call(this,{intentId:e,isUsingPopUp:!0}),m==null||m.close()})},D=new WeakSet,ce=function(r){return E(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},F=new WeakSet,z=function(r){return E(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new S,s=h=>E(this,null,function*(){var n,m,d,p;if(h.origin!==o())return;const{type:a}=h.data;if(a==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[c]=yield Promise.all([this.getIntentDetails(e),ye(2)]),g=c.transaction.status.split(".")[1];g==="successful"||g.startsWith("pending")?(m=(n=this.options).onComplete)==null||m.call(n,k({type:this.options.type},c)):(p=(d=this.options).onFail)==null||p.call(d,k({type:this.options.type},c)),i.resolve(()=>null),window.removeEventListener("message",s)}});return window.addEventListener("message",s),i.promise})},W=new WeakSet,le=function(e){const t=r=>{r.origin===U()&&e.forEach(i=>{i(r)})};window.addEventListener("message",t)},x=new WeakSet,he=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},T=new WeakSet,me=function({container:e,elementType:t,elementOptions:r,styles:i,fontSourceCss:s}){var m,d,p,c;const h=U(),a=new URL(`${h}/vaultField/vaultField.html`);s&&a.searchParams.set("fontSourceCss",s),a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("type",t),((m=r.validation)==null?void 0:m.required)!==void 0&&a.searchParams.set("required",`${(d=r.validation)==null?void 0:d.required}`),a.searchParams.set("placeholder",(p=r.placeholder)!=null?p:""),a.searchParams.set("lang",this.sdkEmbed.lang),a.searchParams.set("direction",(i==null?void 0:i.direction)||""),a.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),a.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),a.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),a.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),a.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),a.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),a.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),a.searchParams.set("padding",(i==null?void 0:i.padding)||"");const n=document.createElement("iframe");return n.src=a.toString(),n.style.height=(c=i==null?void 0:i.height)!=null?c:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n),n},O=new WeakSet,ue=function({accessToken:e,saveCard:t}){const r=U(),i=_(),s=new URL(`${r}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("host",btoa(window.location.origin)),s.searchParams.set("vault_api_url",`${i}/api/v1/tokens/`),s.searchParams.set("access_token",e),s.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&s.searchParams.set("save_card",`${t}`);const h=document.createElement("iframe");return h.id="moneyhash-submit-iframe",h.src=s.toString(),h.hidden=!0,document.body.appendChild(h),h},ve});
}`),()=>{};const r=new Date(e),i=setInterval(()=>E(this,null,function*(){const s=new Date;r<s&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}return q=new WeakSet,oe=function(r){return E(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");w(!i,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const s=document.createElement("iframe");s.src=t,s.style.setProperty("border","0","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("height","100%","important"),i==null||i.replaceChildren(s),yield L(this,F,z).call(this,{intentId:e}),s.remove()})},j=new WeakSet,de=function(i){return E(this,arguments,function*({intentId:e,url:t,options:r={}}){const{width:s=600,height:h=400,left:a=200,top:n=200}=r.window||{},u=window.open(t,"",`width=${s},height=${h},left=${a},top=${n}`);w(!u,"Popup blocked by browser!"),yield L(this,F,z).call(this,{intentId:e,isUsingPopUp:!0}),u==null||u.close()})},D=new WeakSet,ce=function(r){return E(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},F=new WeakSet,z=function(r){return E(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new S,s=h=>E(this,null,function*(){var n,u,d,c;if(h.origin!==o())return;const{type:a}=h.data;if(a==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[m]=yield Promise.all([this.getIntentDetails(e),ye(2)]),g=m.transaction.status.split(".")[1];g==="successful"||g.startsWith("pending")?(u=(n=this.options).onComplete)==null||u.call(n,k({type:this.options.type},m)):(c=(d=this.options).onFail)==null||c.call(d,k({type:this.options.type},m)),i.resolve(()=>null),window.removeEventListener("message",s)}});return window.addEventListener("message",s),i.promise})},W=new WeakSet,le=function(e){const t=r=>{r.origin===U()&&e.forEach(i=>{i(r)})};window.addEventListener("message",t)},x=new WeakSet,he=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},T=new WeakSet,me=function({container:e,elementType:t,elementOptions:r,styles:i,fontSourceCss:s}){var u,d,c,m;const h=U(),a=new URL(`${h}/vaultField/vaultField.html`);s&&a.searchParams.set("fontSourceCss",s),a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("type",t),((u=r.validation)==null?void 0:u.required)!==void 0&&a.searchParams.set("required",`${(d=r.validation)==null?void 0:d.required}`),a.searchParams.set("placeholder",(c=r.placeholder)!=null?c:""),a.searchParams.set("lang",this.sdkEmbed.lang),a.searchParams.set("direction",(i==null?void 0:i.direction)||""),a.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),a.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),a.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),a.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),a.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),a.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),a.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),a.searchParams.set("padding",(i==null?void 0:i.padding)||"");const n=document.createElement("iframe");return n.src=a.toString(),n.style.height=(m=i==null?void 0:i.height)!=null?m:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n),n},O=new WeakSet,ue=function({accessToken:e,saveCard:t}){const r=U(),i=_(),s=new URL(`${r}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("host",btoa(window.location.origin)),s.searchParams.set("vault_api_url",`${i}/api/v1/tokens/`),s.searchParams.set("access_token",e),s.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&s.searchParams.set("save_card",`${t}`);const h=document.createElement("iframe");return h.id="moneyhash-submit-iframe",h.src=s.toString(),h.hidden=!0,document.body.appendChild(h),h},ve});

@@ -1,1 +0,1 @@

"use strict";var n=Object.defineProperty;var d=(t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var a=(t,e,s)=>(d(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-b3156a58.cjs");class o{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start({selector:e,intentId:s}){return r.throwIf(!e,"selector is required for start"),r.throwIf(!s,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:s})}setLocale(e){r.warnIf(!!e&&!r.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...r.supportedLanguages].join(" | ")})`);const s=r.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(s)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=o;
"use strict";var n=Object.defineProperty;var d=(t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var a=(t,e,s)=>(d(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-fba58e46.cjs");class o{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start({selector:e,intentId:s}){return r.throwIf(!e,"selector is required for start"),r.throwIf(!s,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:s})}setLocale(e){r.warnIf(!!e&&!r.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...r.supportedLanguages].join(" | ")})`);const s=r.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(s)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=o;
var o = Object.defineProperty;
var n = (r, s, e) => s in r ? o(r, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[s] = e;
var t = (r, s, e) => (n(r, typeof s != "symbol" ? s + "" : s, e), e);
import { S as i, t as d, w as u, s as a } from "./warnIf-1fdf6f75.js";
import { S as i, t as d, w as u, s as a } from "./warnIf-daa85568.js";
class b {

@@ -6,0 +6,0 @@ constructor(s) {

@@ -1,1 +0,1 @@

(function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=s())})(this,function(){"use strict";var F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,s,t)=>s in i?F(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,w=(i,s)=>{for(var t in s||(s={}))U.call(s,t)&&v(i,t,s[t]);if(O)for(var t of O(s))$.call(s,t)&&v(i,t,s[t]);return i};var a=(i,s,t)=>(v(i,typeof s!="symbol"?s+"":s,t),t);var b=(i,s,t)=>new Promise((g,o)=>{var p=r=>{try{h(t.next(r))}catch(e){o(e)}},f=r=>{try{h(t.throw(r))}catch(e){o(e)}},h=r=>r.done?g(r.value):Promise.resolve(r.value).then(p,f);h((t=t.apply(i,s)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(n=>n!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(n=>{n(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function s(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function t(r,e){if(r)throw new Error(e)}const g=new Set(["payment","payout"]),o=new Set(["en","fr","ar"]);class p{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!g.has(e.type),`MoneyHash constructor must be called with valid type (${[...g].join(" | ")})!`),this.options=e}get lang(){var n;return((n=this.options.locale)==null?void 0:n.split("-")[0])||"en"}render({selector:e,intentId:n}){var L,M;(L=this.messagingService)==null||L.abortService();const S=s(),c=new URL(`${S}/embed/${this.options.type}/${n}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.5.1");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const m=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(m))};(l=this.messagingService)==null||l.onReceive(m)}),this.messagingService.onReceive((y,m)=>{var d,I,k,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{m({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(I=(d=this.options).onComplete)==null||I.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(k=this.options).onFail)==null||C.call(k,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(this,null,function*(){var n;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(n=this.messagingService)==null||n.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function f(r,e){r&&console.warn(e)}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new p(e)}start({selector:e,intentId:n}){return t(!e,"selector is required for start"),t(!n,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:n})}setLocale(e){f(!!e&&!o.has(e),`Invalid locale. Supported languages (${[...o].join(" | ")})`);const n=o.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
(function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=s())})(this,function(){"use strict";var F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,s,t)=>s in i?F(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,w=(i,s)=>{for(var t in s||(s={}))U.call(s,t)&&v(i,t,s[t]);if(O)for(var t of O(s))$.call(s,t)&&v(i,t,s[t]);return i};var a=(i,s,t)=>(v(i,typeof s!="symbol"?s+"":s,t),t);var b=(i,s,t)=>new Promise((g,o)=>{var p=r=>{try{h(t.next(r))}catch(e){o(e)}},f=r=>{try{h(t.throw(r))}catch(e){o(e)}},h=r=>r.done?g(r.value):Promise.resolve(r.value).then(p,f);h((t=t.apply(i,s)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(n=>n!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(n=>{n(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function s(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function t(r,e){if(r)throw new Error(e)}const g=new Set(["payment","payout"]),o=new Set(["en","fr","ar"]);class p{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!g.has(e.type),`MoneyHash constructor must be called with valid type (${[...g].join(" | ")})!`),this.options=e}get lang(){var n;return((n=this.options.locale)==null?void 0:n.split("-")[0])||"en"}render({selector:e,intentId:n}){var L,M;(L=this.messagingService)==null||L.abortService();const S=s(),c=new URL(`${S}/embed/${this.options.type}/${n}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.5.2-beta.0");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const m=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(m))};(l=this.messagingService)==null||l.onReceive(m)}),this.messagingService.onReceive((y,m)=>{var d,I,k,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{m({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(I=(d=this.options).onComplete)==null||I.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(k=this.options).onFail)==null||C.call(k,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(this,null,function*(){var n;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(n=this.messagingService)==null||n.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function f(r,e){r&&console.warn(e)}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new p(e)}start({selector:e,intentId:n}){return t(!e,"selector is required for start"),t(!n,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:n})}setLocale(e){f(!!e&&!o.has(e),`Invalid locale. Supported languages (${[...o].join(" | ")})`);const n=o.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
{
"name": "@moneyhash/js-sdk",
"version": "1.5.1",
"version": "1.5.2-beta.0",
"description": "MoneyHash JavaScript SDK",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc