New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
0
Versions
82
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.3.0 to 1.3.1

dist/warnIf-5bb0d6ca.js

2

dist/headless.cjs.js

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

"use strict";var ne=Object.defineProperty,ie=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var q=(s,e,t)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,E=(s,e)=>{for(var t in e||(e={}))oe.call(e,t)&&q(s,t,e[t]);if(O)for(var t of O(e))de.call(e,t)&&q(s,t,e[t]);return s},z=(s,e)=>ie(s,se(e));var f=(s,e,t)=>(q(s,typeof e!="symbol"?e+"":e,t),t),ce=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var P=(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 v=(s,e,t)=>(ce(s,e,"access private method"),t);var w=(s,e,t)=>new Promise((n,a)=>{var o=r=>{try{i(t.next(r))}catch(l){a(l)}},d=r=>{try{i(t.throw(r))}catch(l){a(l)}},i=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,d);i((t=t.apply(s,e)).next())});const u=require("./warnIf-a53a88a2.cjs");function le(){return typeof window!="undefined"}const y=class{constructor(){le()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=u.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.3.0");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),y.messagingService=new u.MessagingService({target:n.contentWindow,targetOrigin:e}),y.isCommunicationReady=new Promise(a=>{var d;const o=i=>{var r;i.data.type==="headlessSDK:init"&&(a(),(r=y.messagingService)==null||r.removeListener(o))};(d=y.messagingService)==null||d.onReceive(o)})}request(n){return w(this,arguments,function*({api:e,payload:t}){return yield y.isCommunicationReady,new Promise((a,o)=>{var i,r;(i=y.messagingService)==null||i.send({type:e,data:t});const d=l=>{var m;const{type:c,data:h}=l.data;c===e&&(h.status==="resolved"?a(h.payload):o(h.payload),(m=y.messagingService)==null||m.removeListener(d))};(r=y.messagingService)==null||r.onReceive(d)})})}};let L=y;f(L,"messagingService",null),f(L,"isCommunicationReady");class J{constructor(){f(this,"promise");f(this,"resolve");f(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 N(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function K(){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 ue(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function pe(s,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const o=document.createElement("script");o.src=s,o.id=e,o.addEventListener("load",()=>{t(void 0)}),o.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(o)})}const G=new Set(["method","customerBalance","savedCard"]);var A,Q,C,X,U,Z,S,V,R,ee,_,te,M,re,$,ae;class ge{constructor(e){P(this,A);P(this,C);P(this,U);P(this,S);P(this,R);P(this,_);P(this,M);P(this,$);f(this,"options");f(this,"sdkApiHandler",new L);f(this,"sdkEmbed");f(this,"vaultSubmitListener",{current:null});f(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new u.SDKEmbed(z(E({},e),{headless:!0})),v(this,_,te).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:n,metaData:a}){return u.throwIf(!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:n,lang:this.sdkEmbed.lang,metaData:a}})}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 u.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:n,countryCode:a,onCancel:o=()=>{},onError:d,onComplete:i,billingData:r={}}){if(yield pe("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:a,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`}}),{state:h,intent:m}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(h==="INTENT_FORM"){if(ue(r))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:r}})}}catch(g){throw yield this.resetSelectedMethod(e),g}c.onvalidatemerchant=g=>{fetch(`${K()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:m.secret,validation_url:g.validationURL})}).then(p=>p.ok?p.json():Promise.reject()).then(p=>c.completeMerchantValidation(p)).catch(d)},c.onpaymentauthorized=g=>{fetch(`${K()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:m.secret})}).then(p=>p.ok?p.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),i()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),d()})},c.oncancel=o,c.begin()})}renderForm({selector:e,intentId:t}){return u.throwIf(!e,"selector is required for renderForm"),u.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){u.warnIf(!!e&&!u.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...u.supportedLanguages].join(" | ")})`);const t=u.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return u.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(n=>{u.throwIf(!n.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:n}){const a=[],o={},d=new Map;let i=!1;return v(this,R,ee).call(this,a),{create:({elementType:r,elementOptions:l})=>{var H,j;const c=new Map,h=document.querySelector(l.selector);u.throwIf(!h,`Couldn't find an element with selector ${l.selector}!`),h.classList.add("MoneyHashElement");const m=E(E({},t),l.classes),g=((H=m==null?void 0:m.focus)==null?void 0:H.split(" "))||["MoneyHashElement--focus"],p=((j=m==null?void 0:m.error)==null?void 0:j.split(" "))||["MoneyHashElement--error"];return a.push(k=>{var W,T,D,x,B,Y;const{type:b,data:I}=k.data;if(b===`${r}:init`&&(o[r]=I.isValid),b===`${r}@focus`){h.classList.add(...g),(W=c.get(`${r}@focus`))==null||W();return}if(b===`${r}@blur`){h.classList.remove(...g),(T=c.get(`${r}@blur`))==null||T();return}if(b===`${r}@error`){I.isValid?h.classList.remove(...p):h.classList.add(...p),(D=c.get(`${r}@error`))==null||D(I);return}if(b===`${r}@changeInput`){if((x=c.get(`${r}@changeInput`))==null||x(),o[r]=I.isValid,d.get("validityChange")){const F=Object.values(o).every(Boolean);F!==i&&((B=d.get("validityChange"))==null||B(F),i=F)}return}b===`${r}@cardNumberChange`&&((Y=c.get(`${r}@cardNumberChange`))==null||Y(I))}),{mount:()=>{this.mountedCardElements.push(r),v(this,M,re).call(this,{container:h,elementType:r,elementOptions:l,styles:E(E({},e),l.styles),fontSourceCss:n})},on:(k,b)=>{c.set(`${r}@${k}`,b)},off:k=>c.delete(`${r}@${k}`)}},on:(r,l)=>{d.set(r,l)}}}submitForm(d){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:a,saveCard:o}){const i=me(this.mountedCardElements);u.throwIf(!!i,`You must mount ${i} element!`);const r=new J;let l,c;t&&(this.vaultSubmitListener.current=m=>{const{type:g,data:p}=m.data;g==="vaultSubmit:success"&&r.resolve(p),g==="vaultSubmit:error"&&r.reject(p)},c=v(this,$,ae).call(this,{accessToken:t,saveCard:o}),l=yield r.promise);const h=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:n,shippingData:a,cardEmbed:l}});return c&&c.remove(),h})}submitCvv(n){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(e,t,n){return w(this,null,function*(){switch(t){case"IFRAME":return v(this,A,Q).call(this,e);case"POPUP_IFRAME":return v(this,C,X).call(this,e);case"REDIRECT":return v(this,U,Z).call(this,e,n);default:return null}})}}A=new WeakSet,Q=function(e){return w(this,null,function*(){const t=document.querySelector("#rendered-url-iframe-container");u.throwIf(!t,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const n=document.createElement("iframe");n.src=e,n.style.setProperty("border","0","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("height","100%","important"),t==null||t.replaceChildren(n),yield v(this,S,V).call(this),n.remove()})},C=new WeakSet,X=function(e){return w(this,null,function*(){const t=window.open(`${e}`,"","width=600,height=400,left=200,top=200");u.throwIf(!t,"Popup blocked by browser!"),yield v(this,S,V).call(this),t==null||t.close()})},U=new WeakSet,Z=function(e,t){return w(this,null,function*(){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},S=new WeakSet,V=function(){return w(this,null,function*(){const e=new J,t=n=>{var d,i,r,l;const{type:a,data:o}=n.data;switch(a){case"onComplete":(i=(d=this.options).onComplete)==null||i.call(d,E({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;case"onFail":(l=(r=this.options).onFail)==null||l.call(r,E({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;default:e.resolve(()=>null);break}};return window.addEventListener("message",t),e.promise})},R=new WeakSet,ee=function(e){const t=n=>{n.origin===N()&&e.forEach(a=>{a(n)})};window.addEventListener("message",t)},_=new WeakSet,te=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},M=new WeakSet,re=function({container:e,elementType:t,elementOptions:n,styles:a,fontSourceCss:o}){var l,c,h,m;const d=N(),i=new URL(`${d}/vaultField/vaultField.html`);o&&i.searchParams.set("fontSourceCss",o),i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("type",t),((l=n.validation)==null?void 0:l.required)!==void 0&&i.searchParams.set("required",`${(c=n.validation)==null?void 0:c.required}`),i.searchParams.set("placeholder",(h=n.placeholder)!=null?h:""),i.searchParams.set("lang",this.sdkEmbed.lang),i.searchParams.set("direction",(a==null?void 0:a.direction)||""),i.searchParams.set("color",a!=null&&a.color?JSON.stringify(a.color):"#000"),i.searchParams.set("placeholderColor",(a==null?void 0:a.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(a==null?void 0:a.backgroundColor)||"transparent"),i.searchParams.set("fontSize",(a==null?void 0:a.fontSize)||""),i.searchParams.set("fontFamily",(a==null?void 0:a.fontFamily)||""),i.searchParams.set("fontWeight",`${a==null?void 0:a.fontWeight}`),i.searchParams.set("fontStyle",(a==null?void 0:a.fontStyle)||""),i.searchParams.set("padding",(a==null?void 0:a.padding)||"");const r=document.createElement("iframe");r.src=i.toString(),r.style.height=(m=a==null?void 0:a.height)!=null?m:"40px",r.style.setProperty("overflow","hidden","important"),r.style.setProperty("display","block","important"),r.style.setProperty("width","100%","important"),r.style.setProperty("maxWidth","100%","important"),r.style.setProperty("border","0","important"),r.style.setProperty("margin","0","important"),r.style.setProperty("padding","0","important"),r.style.setProperty("userSelect","none","important"),r.style.setProperty("colorScheme","light only","important"),e.replaceChildren(r)},$=new WeakSet,ae=function({accessToken:e,saveCard:t}){const n=N(),a=he(),o=new URL(`${n}/vaultSubmit/vaultSubmit.html`);o.searchParams.set("host",btoa(window.location.origin)),o.searchParams.set("vault_api_url",`${a}/api/v1/tokens/`),o.searchParams.set("access_token",e),o.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&o.searchParams.set("save_card",`${t}`);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=o.toString(),d.hidden=!0,document.body.appendChild(d),d};module.exports=ge;
"use strict";var ne=Object.defineProperty,ie=Object.defineProperties;var se=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var q=(s,e,t)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,E=(s,e)=>{for(var t in e||(e={}))oe.call(e,t)&&q(s,t,e[t]);if(O)for(var t of O(e))de.call(e,t)&&q(s,t,e[t]);return s},z=(s,e)=>ie(s,se(e));var f=(s,e,t)=>(q(s,typeof e!="symbol"?e+"":e,t),t),ce=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var P=(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 v=(s,e,t)=>(ce(s,e,"access private method"),t);var w=(s,e,t)=>new Promise((n,a)=>{var o=r=>{try{i(t.next(r))}catch(l){a(l)}},d=r=>{try{i(t.throw(r))}catch(l){a(l)}},i=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,d);i((t=t.apply(s,e)).next())});const u=require("./warnIf-d5e4457f.cjs");function le(){return typeof window!="undefined"}const y=class{constructor(){le()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=u.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.3.1");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),y.messagingService=new u.MessagingService({target:n.contentWindow,targetOrigin:e}),y.isCommunicationReady=new Promise(a=>{var d;const o=i=>{var r;i.data.type==="headlessSDK:init"&&(a(),(r=y.messagingService)==null||r.removeListener(o))};(d=y.messagingService)==null||d.onReceive(o)})}request(n){return w(this,arguments,function*({api:e,payload:t}){return yield y.isCommunicationReady,new Promise((a,o)=>{var i,r;(i=y.messagingService)==null||i.send({type:e,data:t});const d=l=>{var m;const{type:c,data:h}=l.data;c===e&&(h.status==="resolved"?a(h.payload):o(h.payload),(m=y.messagingService)==null||m.removeListener(d))};(r=y.messagingService)==null||r.onReceive(d)})})}};let L=y;f(L,"messagingService",null),f(L,"isCommunicationReady");class J{constructor(){f(this,"promise");f(this,"resolve");f(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 N(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function K(){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 ue(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function pe(s,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const o=document.createElement("script");o.src=s,o.id=e,o.addEventListener("load",()=>{t(void 0)}),o.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(o)})}const G=new Set(["method","customerBalance","savedCard"]);var A,Q,C,X,U,Z,S,V,R,ee,_,te,M,re,$,ae;class ge{constructor(e){P(this,A);P(this,C);P(this,U);P(this,S);P(this,R);P(this,_);P(this,M);P(this,$);f(this,"options");f(this,"sdkApiHandler",new L);f(this,"sdkEmbed");f(this,"vaultSubmitListener",{current:null});f(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new u.SDKEmbed(z(E({},e),{headless:!0})),v(this,_,te).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:n,metaData:a}){return u.throwIf(!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:n,lang:this.sdkEmbed.lang,metaData:a}})}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 u.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:n,countryCode:a,onCancel:o=()=>{},onError:d,onComplete:i,billingData:r={}}){if(yield pe("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:a,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`}}),{state:h,intent:m}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(h==="INTENT_FORM"){if(ue(r))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:r}})}}catch(g){throw yield this.resetSelectedMethod(e),g}c.onvalidatemerchant=g=>{fetch(`${K()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:m.secret,validation_url:g.validationURL})}).then(p=>p.ok?p.json():Promise.reject()).then(p=>c.completeMerchantValidation(p)).catch(d)},c.onpaymentauthorized=g=>{fetch(`${K()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:m.secret})}).then(p=>p.ok?p.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),i()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),d()})},c.oncancel=o,c.begin()})}renderForm({selector:e,intentId:t}){return u.throwIf(!e,"selector is required for renderForm"),u.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){u.warnIf(!!e&&!u.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...u.supportedLanguages].join(" | ")})`);const t=u.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return u.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(n=>{u.throwIf(!n.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:n}){const a=[],o={},d=new Map;let i=!1;return v(this,R,ee).call(this,a),{create:({elementType:r,elementOptions:l})=>{var H,j;const c=new Map,h=document.querySelector(l.selector);u.throwIf(!h,`Couldn't find an element with selector ${l.selector}!`),h.classList.add("MoneyHashElement");const m=E(E({},t),l.classes),g=((H=m==null?void 0:m.focus)==null?void 0:H.split(" "))||["MoneyHashElement--focus"],p=((j=m==null?void 0:m.error)==null?void 0:j.split(" "))||["MoneyHashElement--error"];return a.push(k=>{var W,T,D,x,B,Y;const{type:b,data:I}=k.data;if(b===`${r}:init`&&(o[r]=I.isValid),b===`${r}@focus`){h.classList.add(...g),(W=c.get(`${r}@focus`))==null||W();return}if(b===`${r}@blur`){h.classList.remove(...g),(T=c.get(`${r}@blur`))==null||T();return}if(b===`${r}@error`){I.isValid?h.classList.remove(...p):h.classList.add(...p),(D=c.get(`${r}@error`))==null||D(I);return}if(b===`${r}@changeInput`){if((x=c.get(`${r}@changeInput`))==null||x(),o[r]=I.isValid,d.get("validityChange")){const F=Object.values(o).every(Boolean);F!==i&&((B=d.get("validityChange"))==null||B(F),i=F)}return}b===`${r}@cardNumberChange`&&((Y=c.get(`${r}@cardNumberChange`))==null||Y(I))}),{mount:()=>{this.mountedCardElements.push(r),v(this,M,re).call(this,{container:h,elementType:r,elementOptions:l,styles:E(E({},e),l.styles),fontSourceCss:n})},on:(k,b)=>{c.set(`${r}@${k}`,b)},off:k=>c.delete(`${r}@${k}`)}},on:(r,l)=>{d.set(r,l)}}}submitForm(d){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:a,saveCard:o}){const i=me(this.mountedCardElements);u.throwIf(!!i,`You must mount ${i} element!`);const r=new J;let l,c;t&&(this.vaultSubmitListener.current=m=>{const{type:g,data:p}=m.data;g==="vaultSubmit:success"&&r.resolve(p),g==="vaultSubmit:error"&&r.reject(p)},c=v(this,$,ae).call(this,{accessToken:t,saveCard:o}),l=yield r.promise);const h=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:n,shippingData:a,cardEmbed:l}});return c&&c.remove(),h})}submitCvv(n){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(e,t,n){return w(this,null,function*(){switch(t){case"IFRAME":return v(this,A,Q).call(this,e);case"POPUP_IFRAME":return v(this,C,X).call(this,e);case"REDIRECT":return v(this,U,Z).call(this,e,n);default:return null}})}}A=new WeakSet,Q=function(e){return w(this,null,function*(){const t=document.querySelector("#rendered-url-iframe-container");u.throwIf(!t,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const n=document.createElement("iframe");n.src=e,n.style.setProperty("border","0","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("height","100%","important"),t==null||t.replaceChildren(n),yield v(this,S,V).call(this),n.remove()})},C=new WeakSet,X=function(e){return w(this,null,function*(){const t=window.open(`${e}`,"","width=600,height=400,left=200,top=200");u.throwIf(!t,"Popup blocked by browser!"),yield v(this,S,V).call(this),t==null||t.close()})},U=new WeakSet,Z=function(e,t){return w(this,null,function*(){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},S=new WeakSet,V=function(){return w(this,null,function*(){const e=new J,t=n=>{var d,i,r,l;const{type:a,data:o}=n.data;switch(a){case"onComplete":(i=(d=this.options).onComplete)==null||i.call(d,E({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;case"onFail":(l=(r=this.options).onFail)==null||l.call(r,E({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;default:e.resolve(()=>null);break}};return window.addEventListener("message",t),e.promise})},R=new WeakSet,ee=function(e){const t=n=>{n.origin===N()&&e.forEach(a=>{a(n)})};window.addEventListener("message",t)},_=new WeakSet,te=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},M=new WeakSet,re=function({container:e,elementType:t,elementOptions:n,styles:a,fontSourceCss:o}){var l,c,h,m;const d=N(),i=new URL(`${d}/vaultField/vaultField.html`);o&&i.searchParams.set("fontSourceCss",o),i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("type",t),((l=n.validation)==null?void 0:l.required)!==void 0&&i.searchParams.set("required",`${(c=n.validation)==null?void 0:c.required}`),i.searchParams.set("placeholder",(h=n.placeholder)!=null?h:""),i.searchParams.set("lang",this.sdkEmbed.lang),i.searchParams.set("direction",(a==null?void 0:a.direction)||""),i.searchParams.set("color",JSON.stringify(a!=null&&a.color?a.color:"#000")),i.searchParams.set("placeholderColor",(a==null?void 0:a.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(a==null?void 0:a.backgroundColor)||"transparent"),i.searchParams.set("fontSize",(a==null?void 0:a.fontSize)||""),i.searchParams.set("fontFamily",(a==null?void 0:a.fontFamily)||""),i.searchParams.set("fontWeight",`${a==null?void 0:a.fontWeight}`),i.searchParams.set("fontStyle",(a==null?void 0:a.fontStyle)||""),i.searchParams.set("padding",(a==null?void 0:a.padding)||"");const r=document.createElement("iframe");r.src=i.toString(),r.style.height=(m=a==null?void 0:a.height)!=null?m:"40px",r.style.setProperty("overflow","hidden","important"),r.style.setProperty("display","block","important"),r.style.setProperty("width","100%","important"),r.style.setProperty("maxWidth","100%","important"),r.style.setProperty("border","0","important"),r.style.setProperty("margin","0","important"),r.style.setProperty("padding","0","important"),r.style.setProperty("userSelect","none","important"),r.style.setProperty("colorScheme","light only","important"),e.replaceChildren(r)},$=new WeakSet,ae=function({accessToken:e,saveCard:t}){const n=N(),a=he(),o=new URL(`${n}/vaultSubmit/vaultSubmit.html`);o.searchParams.set("host",btoa(window.location.origin)),o.searchParams.set("vault_api_url",`${a}/api/v1/tokens/`),o.searchParams.set("access_token",e),o.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&o.searchParams.set("save_card",`${t}`);const d=document.createElement("iframe");return d.id="moneyhash-submit-iframe",d.src=o.toString(),d.hidden=!0,document.body.appendChild(d),d};module.exports=ge;

@@ -39,3 +39,3 @@ var ie = Object.defineProperty, se = Object.defineProperties;

});
import { M as me, g as he, S as pe, t as w, w as ue, s as N } from "./warnIf-f9638a41.js";
import { M as me, g as he, S as pe, t as w, w as ue, s as N } from "./warnIf-5bb0d6ca.js";
function ge() {

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

const e = he(), 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.3.0");
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.3.1");
const n = document.createElement("iframe");

@@ -810,3 +810,3 @@ n.id = "moneyhash-headless-sdk", n.src = t.toString(), n.hidden = !0, document.body.appendChild(n), y.messagingService = new me({

"color",
a != null && a.color ? JSON.stringify(a.color) : "#000"
JSON.stringify(a != null && a.color ? a.color : "#000")
), i.searchParams.set(

@@ -813,0 +813,0 @@ "placeholderColor",

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

(function(c,a){typeof exports=="object"&&typeof module!="undefined"?module.exports=a():typeof define=="function"&&define.amd?define(a):(c=typeof globalThis!="undefined"?globalThis:c||self,c.MoneyHash=a())})(this,function(){var N,se,V,re,j,ae,M,z,T,oe,W,de,D,ce,O,le;"use strict";var fe=Object.defineProperty,ve=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var Y=(c,a,l)=>a in c?fe(c,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[a]=l,S=(c,a)=>{for(var l in a||(a={}))we.call(a,l)&&Y(c,l,a[l]);if(ie)for(var l of ie(a))be.call(a,l)&&Y(c,l,a[l]);return c},ne=(c,a)=>ve(c,ye(a));var f=(c,a,l)=>(Y(c,typeof a!="symbol"?a+"":a,l),l),Ee=(c,a,l)=>{if(!a.has(c))throw TypeError("Cannot "+l)};var L=(c,a,l)=>{if(a.has(c))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(c):a.set(c,l)};var k=(c,a,l)=>(Ee(c,a,"access private method"),l);var b=(c,a,l)=>new Promise((A,w)=>{var H=E=>{try{C(l.next(E))}catch(U){w(U)}},R=E=>{try{C(l.throw(E))}catch(U){w(U)}},C=E=>E.done?A(E.value):Promise.resolve(E.value).then(H,R);C((l=l.apply(c,a)).next())});class c{constructor(e){f(this,"target");f(this,"targetOrigin");f(this,"listeners");f(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 a(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function l(){return typeof window!="undefined"}const P=class{constructor(){l()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=a(),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.3.0");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),P.messagingService=new c({target:s.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(i=>{var h;const o=r=>{var n;r.data.type==="headlessSDK:init"&&(i(),(n=P.messagingService)==null||n.removeListener(o))};(h=P.messagingService)==null||h.onReceive(o)})}request(s){return b(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((i,o)=>{var r,n;(r=P.messagingService)==null||r.send({type:e,data:t});const h=p=>{var u;const{type:d,data:m}=p.data;d===e&&(m.status==="resolved"?i(m.payload):o(m.payload),(u=P.messagingService)==null||u.removeListener(h))};(n=P.messagingService)==null||n.onReceive(h)})})}};let A=P;f(A,"messagingService",null),f(A,"isCommunicationReady");function w(g,e){if(g)throw new Error(e)}const H=new Set(["payment","payout"]),R=new Set(["en","fr","ar"]);class C{constructor(e){f(this,"options");f(this,"messagingService",null);f(this,"iframe",null);f(this,"isCommunicationReady",null);w(!H.has(e.type),`MoneyHash constructor must be called with valid type (${[...H].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 r,n;(r=this.messagingService)==null||r.abortService();const s=a(),i=new URL(`${s}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.3.0");const o=(n=this.options.locale)==null?void 0:n.split("-")[0];o&&i.searchParams.set("lang",o),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 c({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(p=>{var m;const d=u=>{var v;u.data.type==="sdk:init"&&(p(),(v=this.messagingService)==null||v.removeListener(d))};(m=this.messagingService)==null||m.onReceive(d)}),this.messagingService.onReceive((p,d)=>{var v,y,_,$;const{type:m,data:u}=p.data;switch(m){case"sdk:init":{d({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(y=(v=this.options).onComplete)==null||y.call(v,S({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{($=(_=this.options).onFail)==null||$.call(_,S({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 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 b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class E{constructor(){f(this,"promise");f(this,"resolve");f(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function U(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function x(){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 he(g){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!g.includes(t))return t;return null}function me(g){return(Array.isArray(g)?g.length:Object.keys(g).length)===0}function pe(g,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const o=document.createElement("script");o.src=g,o.id=e,o.addEventListener("load",()=>{t(void 0)}),o.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(o)})}function ue(g,e){g&&console.warn(e)}const K=new Set(["method","customerBalance","savedCard"]);class ge{constructor(e){L(this,N);L(this,V);L(this,j);L(this,M);L(this,T);L(this,W);L(this,D);L(this,O);f(this,"options");f(this,"sdkApiHandler",new A);f(this,"sdkEmbed");f(this,"vaultSubmitListener",{current:null});f(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new C(ne(S({},e),{headless:!0})),k(this,W,de).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:s,metaData:i}){return w(!K.has(t),`type must be a valid one (${[...K].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,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(p){return b(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:i,onCancel:o=()=>{},onError:h,onComplete:r,billingData:n={}}){if(yield pe("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:`${s}`}}),{state:m,intent:u}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(m==="INTENT_FORM"){if(me(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(v){throw yield this.resetSelectedMethod(e),v}d.onvalidatemerchant=v=>{fetch(`${J()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:u.secret,validation_url:v.validationURL})}).then(y=>y.ok?y.json():Promise.reject()).then(y=>d.completeMerchantValidation(y)).catch(h)},d.onpaymentauthorized=v=>{fetch(`${J()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:v.payment.token,secret:u.secret})}).then(y=>y.ok?y.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),r()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),h()})},d.oncancel=o,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){ue(!!e&&!R.has(e),`Invalid locale. Supported languages (${[...R].join(" | ")})`);const t=R.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(s=>{w(!s.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:s}){const i=[],o={},h=new Map;let r=!1;return k(this,T,oe).call(this,i),{create:({elementType:n,elementOptions:p})=>{var _,$;const d=new Map,m=document.querySelector(p.selector);w(!m,`Couldn't find an element with selector ${p.selector}!`),m.classList.add("MoneyHashElement");const u=S(S({},t),p.classes),v=((_=u==null?void 0:u.focus)==null?void 0:_.split(" "))||["MoneyHashElement--focus"],y=(($=u==null?void 0:u.error)==null?void 0:$.split(" "))||["MoneyHashElement--error"];return i.push(F=>{var G,Q,X,Z,ee,te;const{type:I,data:q}=F.data;if(I===`${n}:init`&&(o[n]=q.isValid),I===`${n}@focus`){m.classList.add(...v),(G=d.get(`${n}@focus`))==null||G();return}if(I===`${n}@blur`){m.classList.remove(...v),(Q=d.get(`${n}@blur`))==null||Q();return}if(I===`${n}@error`){q.isValid?m.classList.remove(...y):m.classList.add(...y),(X=d.get(`${n}@error`))==null||X(q);return}if(I===`${n}@changeInput`){if((Z=d.get(`${n}@changeInput`))==null||Z(),o[n]=q.isValid,h.get("validityChange")){const B=Object.values(o).every(Boolean);B!==r&&((ee=h.get("validityChange"))==null||ee(B),r=B)}return}I===`${n}@cardNumberChange`&&((te=d.get(`${n}@cardNumberChange`))==null||te(q))}),{mount:()=>{this.mountedCardElements.push(n),k(this,D,ce).call(this,{container:m,elementType:n,elementOptions:p,styles:S(S({},e),p.styles),fontSourceCss:s})},on:(F,I)=>{d.set(`${n}@${F}`,I)},off:F=>d.delete(`${n}@${F}`)}},on:(n,p)=>{h.set(n,p)}}}submitForm(h){return b(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:i,saveCard:o}){const r=he(this.mountedCardElements);w(!!r,`You must mount ${r} element!`);const n=new E;let p,d;t&&(this.vaultSubmitListener.current=u=>{const{type:v,data:y}=u.data;v==="vaultSubmit:success"&&n.resolve(y),v==="vaultSubmit:error"&&n.reject(y)},d=k(this,O,le).call(this,{accessToken:t,saveCard:o}),p=yield n.promise);const m=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:s,shippingData:i,cardEmbed:p}});return d&&d.remove(),m})}submitCvv(s){return b(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t,s){return b(this,null,function*(){switch(t){case"IFRAME":return k(this,N,se).call(this,e);case"POPUP_IFRAME":return k(this,V,re).call(this,e);case"REDIRECT":return k(this,j,ae).call(this,e,s);default:return null}})}}return N=new WeakSet,se=function(e){return b(this,null,function*(){const t=document.querySelector("#rendered-url-iframe-container");w(!t,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const s=document.createElement("iframe");s.src=e,s.style.setProperty("border","0","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("height","100%","important"),t==null||t.replaceChildren(s),yield k(this,M,z).call(this),s.remove()})},V=new WeakSet,re=function(e){return b(this,null,function*(){const t=window.open(`${e}`,"","width=600,height=400,left=200,top=200");w(!t,"Popup blocked by browser!"),yield k(this,M,z).call(this),t==null||t.close()})},j=new WeakSet,ae=function(e,t){return b(this,null,function*(){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},M=new WeakSet,z=function(){return b(this,null,function*(){const e=new E,t=s=>{var h,r,n,p;const{type:i,data:o}=s.data;switch(i){case"onComplete":(r=(h=this.options).onComplete)==null||r.call(h,S({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;case"onFail":(p=(n=this.options).onFail)==null||p.call(n,S({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;default:e.resolve(()=>null);break}};return window.addEventListener("message",t),e.promise})},T=new WeakSet,oe=function(e){const t=s=>{s.origin===x()&&e.forEach(i=>{i(s)})};window.addEventListener("message",t)},W=new WeakSet,de=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},D=new WeakSet,ce=function({container:e,elementType:t,elementOptions:s,styles:i,fontSourceCss:o}){var p,d,m,u;const h=x(),r=new URL(`${h}/vaultField/vaultField.html`);o&&r.searchParams.set("fontSourceCss",o),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((p=s.validation)==null?void 0:p.required)!==void 0&&r.searchParams.set("required",`${(d=s.validation)==null?void 0:d.required}`),r.searchParams.set("placeholder",(m=s.placeholder)!=null?m:""),r.searchParams.set("lang",this.sdkEmbed.lang),r.searchParams.set("direction",(i==null?void 0:i.direction)||""),r.searchParams.set("color",i!=null&&i.color?JSON.stringify(i.color):"#000"),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),r.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),r.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),r.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),r.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),r.searchParams.set("padding",(i==null?void 0:i.padding)||"");const n=document.createElement("iframe");n.src=r.toString(),n.style.height=(u=i==null?void 0:i.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)},O=new WeakSet,le=function({accessToken:e,saveCard:t}){const s=x(),i=U(),o=new URL(`${s}/vaultSubmit/vaultSubmit.html`);o.searchParams.set("host",btoa(window.location.origin)),o.searchParams.set("vault_api_url",`${i}/api/v1/tokens/`),o.searchParams.set("access_token",e),o.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&o.searchParams.set("save_card",`${t}`);const h=document.createElement("iframe");return h.id="moneyhash-submit-iframe",h.src=o.toString(),h.hidden=!0,document.body.appendChild(h),h},ge});
(function(c,a){typeof exports=="object"&&typeof module!="undefined"?module.exports=a():typeof define=="function"&&define.amd?define(a):(c=typeof globalThis!="undefined"?globalThis:c||self,c.MoneyHash=a())})(this,function(){var N,se,V,re,j,ae,M,z,T,oe,W,de,D,ce,O,le;"use strict";var fe=Object.defineProperty,ve=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var Y=(c,a,l)=>a in c?fe(c,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[a]=l,S=(c,a)=>{for(var l in a||(a={}))we.call(a,l)&&Y(c,l,a[l]);if(ie)for(var l of ie(a))be.call(a,l)&&Y(c,l,a[l]);return c},ne=(c,a)=>ve(c,ye(a));var f=(c,a,l)=>(Y(c,typeof a!="symbol"?a+"":a,l),l),Ee=(c,a,l)=>{if(!a.has(c))throw TypeError("Cannot "+l)};var L=(c,a,l)=>{if(a.has(c))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(c):a.set(c,l)};var k=(c,a,l)=>(Ee(c,a,"access private method"),l);var b=(c,a,l)=>new Promise((A,w)=>{var H=E=>{try{C(l.next(E))}catch(U){w(U)}},R=E=>{try{C(l.throw(E))}catch(U){w(U)}},C=E=>E.done?A(E.value):Promise.resolve(E.value).then(H,R);C((l=l.apply(c,a)).next())});class c{constructor(e){f(this,"target");f(this,"targetOrigin");f(this,"listeners");f(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 a(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function l(){return typeof window!="undefined"}const P=class{constructor(){l()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=a(),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.3.1");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),P.messagingService=new c({target:s.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(i=>{var h;const o=r=>{var n;r.data.type==="headlessSDK:init"&&(i(),(n=P.messagingService)==null||n.removeListener(o))};(h=P.messagingService)==null||h.onReceive(o)})}request(s){return b(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((i,o)=>{var r,n;(r=P.messagingService)==null||r.send({type:e,data:t});const h=p=>{var u;const{type:d,data:m}=p.data;d===e&&(m.status==="resolved"?i(m.payload):o(m.payload),(u=P.messagingService)==null||u.removeListener(h))};(n=P.messagingService)==null||n.onReceive(h)})})}};let A=P;f(A,"messagingService",null),f(A,"isCommunicationReady");function w(g,e){if(g)throw new Error(e)}const H=new Set(["payment","payout"]),R=new Set(["en","fr","ar"]);class C{constructor(e){f(this,"options");f(this,"messagingService",null);f(this,"iframe",null);f(this,"isCommunicationReady",null);w(!H.has(e.type),`MoneyHash constructor must be called with valid type (${[...H].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 r,n;(r=this.messagingService)==null||r.abortService();const s=a(),i=new URL(`${s}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.3.1");const o=(n=this.options.locale)==null?void 0:n.split("-")[0];o&&i.searchParams.set("lang",o),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 c({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(p=>{var m;const d=u=>{var v;u.data.type==="sdk:init"&&(p(),(v=this.messagingService)==null||v.removeListener(d))};(m=this.messagingService)==null||m.onReceive(d)}),this.messagingService.onReceive((p,d)=>{var v,y,_,$;const{type:m,data:u}=p.data;switch(m){case"sdk:init":{d({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(y=(v=this.options).onComplete)==null||y.call(v,S({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{($=(_=this.options).onFail)==null||$.call(_,S({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 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 b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class E{constructor(){f(this,"promise");f(this,"resolve");f(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function U(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function x(){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 he(g){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!g.includes(t))return t;return null}function me(g){return(Array.isArray(g)?g.length:Object.keys(g).length)===0}function pe(g,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const o=document.createElement("script");o.src=g,o.id=e,o.addEventListener("load",()=>{t(void 0)}),o.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(o)})}function ue(g,e){g&&console.warn(e)}const K=new Set(["method","customerBalance","savedCard"]);class ge{constructor(e){L(this,N);L(this,V);L(this,j);L(this,M);L(this,T);L(this,W);L(this,D);L(this,O);f(this,"options");f(this,"sdkApiHandler",new A);f(this,"sdkEmbed");f(this,"vaultSubmitListener",{current:null});f(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new C(ne(S({},e),{headless:!0})),k(this,W,de).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:s,metaData:i}){return w(!K.has(t),`type must be a valid one (${[...K].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,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(p){return b(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:i,onCancel:o=()=>{},onError:h,onComplete:r,billingData:n={}}){if(yield pe("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:`${s}`}}),{state:m,intent:u}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(m==="INTENT_FORM"){if(me(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(v){throw yield this.resetSelectedMethod(e),v}d.onvalidatemerchant=v=>{fetch(`${J()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:u.secret,validation_url:v.validationURL})}).then(y=>y.ok?y.json():Promise.reject()).then(y=>d.completeMerchantValidation(y)).catch(h)},d.onpaymentauthorized=v=>{fetch(`${J()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:v.payment.token,secret:u.secret})}).then(y=>y.ok?y.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),r()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),h()})},d.oncancel=o,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){ue(!!e&&!R.has(e),`Invalid locale. Supported languages (${[...R].join(" | ")})`);const t=R.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(s=>{w(!s.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:s}){const i=[],o={},h=new Map;let r=!1;return k(this,T,oe).call(this,i),{create:({elementType:n,elementOptions:p})=>{var _,$;const d=new Map,m=document.querySelector(p.selector);w(!m,`Couldn't find an element with selector ${p.selector}!`),m.classList.add("MoneyHashElement");const u=S(S({},t),p.classes),v=((_=u==null?void 0:u.focus)==null?void 0:_.split(" "))||["MoneyHashElement--focus"],y=(($=u==null?void 0:u.error)==null?void 0:$.split(" "))||["MoneyHashElement--error"];return i.push(F=>{var G,Q,X,Z,ee,te;const{type:I,data:q}=F.data;if(I===`${n}:init`&&(o[n]=q.isValid),I===`${n}@focus`){m.classList.add(...v),(G=d.get(`${n}@focus`))==null||G();return}if(I===`${n}@blur`){m.classList.remove(...v),(Q=d.get(`${n}@blur`))==null||Q();return}if(I===`${n}@error`){q.isValid?m.classList.remove(...y):m.classList.add(...y),(X=d.get(`${n}@error`))==null||X(q);return}if(I===`${n}@changeInput`){if((Z=d.get(`${n}@changeInput`))==null||Z(),o[n]=q.isValid,h.get("validityChange")){const B=Object.values(o).every(Boolean);B!==r&&((ee=h.get("validityChange"))==null||ee(B),r=B)}return}I===`${n}@cardNumberChange`&&((te=d.get(`${n}@cardNumberChange`))==null||te(q))}),{mount:()=>{this.mountedCardElements.push(n),k(this,D,ce).call(this,{container:m,elementType:n,elementOptions:p,styles:S(S({},e),p.styles),fontSourceCss:s})},on:(F,I)=>{d.set(`${n}@${F}`,I)},off:F=>d.delete(`${n}@${F}`)}},on:(n,p)=>{h.set(n,p)}}}submitForm(h){return b(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:i,saveCard:o}){const r=he(this.mountedCardElements);w(!!r,`You must mount ${r} element!`);const n=new E;let p,d;t&&(this.vaultSubmitListener.current=u=>{const{type:v,data:y}=u.data;v==="vaultSubmit:success"&&n.resolve(y),v==="vaultSubmit:error"&&n.reject(y)},d=k(this,O,le).call(this,{accessToken:t,saveCard:o}),p=yield n.promise);const m=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:s,shippingData:i,cardEmbed:p}});return d&&d.remove(),m})}submitCvv(s){return b(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(e,t,s){return b(this,null,function*(){switch(t){case"IFRAME":return k(this,N,se).call(this,e);case"POPUP_IFRAME":return k(this,V,re).call(this,e);case"REDIRECT":return k(this,j,ae).call(this,e,s);default:return null}})}}return N=new WeakSet,se=function(e){return b(this,null,function*(){const t=document.querySelector("#rendered-url-iframe-container");w(!t,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const s=document.createElement("iframe");s.src=e,s.style.setProperty("border","0","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("height","100%","important"),t==null||t.replaceChildren(s),yield k(this,M,z).call(this),s.remove()})},V=new WeakSet,re=function(e){return b(this,null,function*(){const t=window.open(`${e}`,"","width=600,height=400,left=200,top=200");w(!t,"Popup blocked by browser!"),yield k(this,M,z).call(this),t==null||t.close()})},j=new WeakSet,ae=function(e,t){return b(this,null,function*(){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},M=new WeakSet,z=function(){return b(this,null,function*(){const e=new E,t=s=>{var h,r,n,p;const{type:i,data:o}=s.data;switch(i){case"onComplete":(r=(h=this.options).onComplete)==null||r.call(h,S({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;case"onFail":(p=(n=this.options).onFail)==null||p.call(n,S({type:this.options.type},o)),e.resolve(()=>null),window.removeEventListener("message",t);break;default:e.resolve(()=>null);break}};return window.addEventListener("message",t),e.promise})},T=new WeakSet,oe=function(e){const t=s=>{s.origin===x()&&e.forEach(i=>{i(s)})};window.addEventListener("message",t)},W=new WeakSet,de=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},D=new WeakSet,ce=function({container:e,elementType:t,elementOptions:s,styles:i,fontSourceCss:o}){var p,d,m,u;const h=x(),r=new URL(`${h}/vaultField/vaultField.html`);o&&r.searchParams.set("fontSourceCss",o),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((p=s.validation)==null?void 0:p.required)!==void 0&&r.searchParams.set("required",`${(d=s.validation)==null?void 0:d.required}`),r.searchParams.set("placeholder",(m=s.placeholder)!=null?m:""),r.searchParams.set("lang",this.sdkEmbed.lang),r.searchParams.set("direction",(i==null?void 0:i.direction)||""),r.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),r.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),r.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),r.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),r.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),r.searchParams.set("padding",(i==null?void 0:i.padding)||"");const n=document.createElement("iframe");n.src=r.toString(),n.style.height=(u=i==null?void 0:i.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)},O=new WeakSet,le=function({accessToken:e,saveCard:t}){const s=x(),i=U(),o=new URL(`${s}/vaultSubmit/vaultSubmit.html`);o.searchParams.set("host",btoa(window.location.origin)),o.searchParams.set("vault_api_url",`${i}/api/v1/tokens/`),o.searchParams.set("access_token",e),o.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&o.searchParams.set("save_card",`${t}`);const h=document.createElement("iframe");return h.id="moneyhash-submit-iframe",h.src=o.toString(),h.hidden=!0,document.body.appendChild(h),h},ge});

@@ -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-a53a88a2.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-d5e4457f.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-f9638a41.js";
import { S as i, t as d, w as u, s as a } from "./warnIf-5bb0d6ca.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.3.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});
(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.3.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});
{
"name": "@moneyhash/js-sdk",
"version": "1.3.0",
"version": "1.3.1",
"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