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

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
0
Versions
68
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.10.0-beta.2 to 1.10.0

dist/warnIf-a3b0e384.js

2

dist/headless.cjs.js

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

"use strict";var we=Object.defineProperty,fe=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var j=(o,e,t)=>e in o?we(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,P=(o,e)=>{for(var t in e||(e={}))ie.call(e,t)&&j(o,t,e[t]);if(_)for(var t of _(e))re.call(e,t)&&j(o,t,e[t]);return o},q=(o,e)=>fe(o,Pe(e));var se=(o,e)=>{var t={};for(var n in o)ie.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&_)for(var n of _(o))e.indexOf(n)<0&&re.call(o,n)&&(t[n]=o[n]);return t};var w=(o,e,t)=>(j(o,typeof e!="symbol"?e+"":e,t),t),be=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var b=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)};var y=(o,e,t)=>(be(o,e,"access private method"),t);var h=(o,e,t)=>new Promise((n,a)=>{var r=i=>{try{s(t.next(i))}catch(c){a(c)}},d=i=>{try{s(t.throw(i))}catch(c){a(c)}},s=i=>i.done?n(i.value):Promise.resolve(i.value).then(r,d);s((t=t.apply(o,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./warnIf-df0c60c0.cjs");function ke(){return typeof window!="undefined"}const k=class{constructor(){ke()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=l.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.10.0-beta.2");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),k.messagingService=new l.MessagingService({target:n.contentWindow,targetOrigin:e}),k.isCommunicationReady=new Promise(a=>{var d;const r=s=>{var i;s.data.type==="headlessSDK:init"&&(a(),(i=k.messagingService)==null||i.removeListener(r))};(d=k.messagingService)==null||d.onReceive(r)})}request(n){return h(this,arguments,function*({api:e,payload:t}){return yield k.isCommunicationReady,new Promise((a,r)=>{var s,i;(s=k.messagingService)==null||s.send({type:e,data:t});const d=c=>{var g;const{type:p,data:u}=c.data;p===e&&(u.status==="resolved"?a(u.payload):r(u.payload),(g=k.messagingService)==null||g.removeListener(d))};(i=k.messagingService)==null||i.onReceive(d)})})}postMessage(e){var t;(t=k.messagingService)==null||t.send({type:e})}};let C=k;w(C,"messagingService",null),w(C,"isCommunicationReady");class F{constructor(){w(this,"promise");w(this,"resolve");w(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Ae(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function v(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function oe(o){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!o.includes(t))return t;return null}function de(o){return(Array.isArray(o)?o.length:Object.keys(o).length)===0}function O(o,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const r=document.createElement("script");r.src=o,r.id=e,r.addEventListener("load",()=>{t(void 0)}),r.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(r)})}function Ee(o){return new Promise(e=>{setTimeout(()=>{e("done")},o*1e3)})}const le=new Set(["method","customerBalance","savedCard"]);var M,K,R,Y,H,ce,$,pe,N,ue,L,x,V,he,D,me,T,ge,W,ye;class Ie{constructor(e){b(this,M);b(this,R);b(this,H);b(this,$);b(this,N);b(this,L);b(this,V);b(this,D);b(this,T);b(this,W);w(this,"options");w(this,"sdkApiHandler",new C);w(this,"sdkEmbed");w(this,"vaultSubmitListener",{current:null});w(this,"mountedCardElements",[]);w(this,"googlePaymentsClient",null);w(this,"cardForm",{collect:()=>h(this,null,function*(){l.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=oe(this.mountedCardElements);l.throwIf(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return y(this,R,Y).call(this,{accessToken:t})}),pay:s=>h(this,[s],function*({intentId:e,cardData:t,saveCard:n,billingData:a,shippingData:r,installmentPlanData:d}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:a,shippingData:r,cardEmbed:t,saveCard:n,installmentPlanData:d}})}),createCardToken:n=>h(this,[n],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new l.SDKEmbed(q(P({},e),{headless:!0})),y(this,D,me).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}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(l.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),l.throwIf(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:P({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:n,useWalletBalance:a,metaData:r,installmentPlanData:d}){return l.throwIf(!le.has(t),`type must be a valid one (${[...le].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:n,lang:this.sdkEmbed.lang,useWalletBalance:a,metaData:r,installmentPlanData:d}})}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 l.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(c){return h(this,arguments,function*({intentId:e,currency:t,amount:n,countryCode:a,onCancel:r=()=>{},onError:d,onComplete:s,billingData:i={}}){if(yield O("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const p=new ApplePaySession(3,{countryCode:a,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`},requiredShippingContactFields:["email"]}),{state:u,intent:g}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(u==="FORM_FIELDS"){if(de(i))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:i}})}}catch(A){throw yield this.resetSelectedMethod(e),A}const f=new F;return p.onvalidatemerchant=A=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{secret:g.secret,validationUrl:A.validationURL,parentOrigin:window.location.origin}}).then(I=>p.completeMerchantValidation(I)).catch(d),p.onpaymentauthorized=A=>{var I;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:A.payment.token}),receiptBillingData:{email:(I=A.payment.shippingContact)==null?void 0:I.emailAddress}}}).then(U=>{p.completePayment(ApplePaySession.STATUS_SUCCESS),s==null||s(),f.resolve(U)}).catch(()=>{p.completePayment(ApplePaySession.STATUS_FAILURE),d==null||d(),f.reject(void 0)})},p.oncancel=r,p.begin(),f.promise})}renderGooglePayButton(n){return h(this,null,function*(){var a=n,{onClick:e}=a,t=se(a,["onClick"]);var s;const r=document.getElementById("moneyHash-google-pay-button");l.throwIf(!r,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield O("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((s=this.options.googlePay)==null?void 0:s.environment)||"PRODUCTION"});const d=y(this,M,K).call(this);this.googlePaymentsClient.isReadyToPay(d).then(i=>{if(i.result){const c=this.googlePaymentsClient.createButton(q(P({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:d.allowedPaymentMethods,onClick:e}));r==null||r.replaceChildren(c)}else throw new Error("Google Pay is not ready to pay!")}).catch(i=>{console.dir(i)})})}generateGooglePayReceipt({nativePayData:e,onCancel:t}){return l.throwIf(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "generateGooglePayReceipt"'),l.throwIf(!e,"nativePayData is required to generate Apple Pay receipt!"),l.throwIf(!e.amount,"nativePayData.amount is required to generate Apple Pay receipt!"),this.googlePaymentsClient.loadPaymentData(q(P({},y(this,M,K).call(this,e)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${e.amount}`,currencyCode:e.currency_code,countryCode:e.country_code},merchantInfo:{merchantName:e.merchant_name,merchantId:e.merchant_id},emailRequired:!0})).then(n=>({receipt:n.paymentMethodData.tokenizationData.token,receiptBillingData:{email:n.email}})).catch(n=>(n.statusCode==="CANCELED"?t==null||t():console.dir(n),Promise.reject(n)))}generateApplePayReceipt(n){return h(this,arguments,function*({nativePayData:e,onCancel:t=()=>{}}){if(yield O("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),l.throwIf(!e,"nativePayData is required to generate Apple Pay receipt!"),!e)return{receipt:"",receiptBillingData:{}};if(l.throwIf(!e.amount,"nativePayData.amount is required to generate Apple Pay receipt!"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const a=new ApplePaySession(3,{countryCode:e.country_code,currencyCode:e.currency_code,supportedNetworks:e.supported_networks,merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${e.amount}`},requiredShippingContactFields:["email"]}),r=new F;return a.onvalidatemerchant=d=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{methodId:e.method_id,validationUrl:d.validationURL,parentOrigin:window.location.origin}}).then(s=>a.completeMerchantValidation(s)).catch(s=>r.reject(s)),a.onpaymentauthorized=d=>{var i;const s={receipt:JSON.stringify({token:d.payment.token}),receiptBillingData:{email:(i=d.payment.shippingContact)==null?void 0:i.emailAddress}};a.completePayment(ApplePaySession.STATUS_SUCCESS),r.resolve(s)},a.oncancel=t,a.begin(),r.promise})}submitPaymentReceipt({intentId:e,nativeReceiptData:t}){return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:t.receipt,receiptBillingData:t.receiptBillingData}})}payWithGooglePay(a){return h(this,arguments,function*({intentId:e,billingData:t={},onCancel:n}){l.throwIf(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let r=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(r.state==="FORM_FIELDS"){if(de(t))throw new Error("Billing data is missing while calling payWithGooglePay");r=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(s){throw yield this.resetSelectedMethod(e),s}const{__nativePayData__:d}=r;return d?this.generateGooglePayReceipt({nativePayData:d,onCancel:n}).then(s=>this.submitPaymentReceipt({intentId:e,nativeReceiptData:s})):r})}renderForm(e){return l.throwIf(!e.selector,"selector is required for renderForm"),l.throwIf(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){l.warnIf(!!e&&!l.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...l.supportedLanguages].join(" | ")})`);const t=l.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return l.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=>{l.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=[],r={},d=new Map;let s=!1;return y(this,V,he).call(this,a),{create:({elementType:i,elementOptions:c})=>{var I,U;const p=new Map;let u=null;const g=P(P({},t),c.classes),f=((I=g==null?void 0:g.focus)==null?void 0:I.split(" "))||["MoneyHashElement--focus"],A=((U=g==null?void 0:g.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const m=document.querySelector(c.selector);l.throwIf(!m,`Couldn't find an element with selector ${c.selector}!`),m.classList.add("MoneyHashElement"),a.push(B=>{var z,J,X,Q,Z,ee,te,ae,ne;const{type:E,data:S}=B.data;if(E===`${i}@mount`&&(r[i]=S.isValid,(z=p.get(`${i}@mount`))==null||z()),E===`${i}@focus`){m.classList.add(...f),(J=p.get(`${i}@focus`))==null||J();return}if(E===`${i}@blur`){m.classList.remove(...f),(X=p.get(`${i}@blur`))==null||X();return}if(E===`${i}@error`){S.isValid?m.classList.remove(...A):m.classList.add(...A),(Q=p.get(`${i}@error`))==null||Q(S);return}if(E===`${i}@changeInput`){if((Z=p.get(`${i}@changeInput`))==null||Z({isValid:S.isValid,length:S.length}),r[i]=S.isValid,d.get("validityChange")){const G=Object.values(r).every(Boolean);G!==s&&((ee=d.get("validityChange"))==null||ee(G),s=G)}return}if(E===`${i}@cardNumberChange`){(te=p.get(`${i}@cardNumberChange`))==null||te(S);return}if(E===`${i}@key:Backspace`){(ae=p.get(`${i}@key:Backspace`))==null||ae();return}E===`${i}@key:Enter`&&((ne=p.get(`${i}@key:Enter`))==null||ne())}),u=y(this,T,ge).call(this,{container:m,elementType:i,elementOptions:c,styles:P(P({},e),c.styles),fontSourceCss:n}),this.mountedCardElements.push(i)},on:(m,B)=>{p.set(`${i}@${m}`,B)},off:m=>p.delete(`${i}@${m}`),focus:()=>{var m;(m=u==null?void 0:u.contentWindow)==null||m.postMessage({type:"focus"},v())},blur:()=>{var m;(m=u==null?void 0:u.contentWindow)==null||m.postMessage({type:"blur"},v())},clear:()=>{var m;(m=u==null?void 0:u.contentWindow)==null||m.postMessage({type:"clear"},v())}}},on:(i,c)=>{d.set(i,c)}}}submitForm(i){return h(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:a,saveCard:r,paymentMethod:d="CARD",installmentPlanData:s}){let c;if(t){const u=oe(this.mountedCardElements);l.throwIf(!!u,`You must mount ${u} element!`),c=yield y(this,R,Y).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:d,lang:this.sdkEmbed.lang,billingData:n,shippingData:a,cardEmbed:c,saveCard:r,installmentPlanData:s}})})}selectInstallmentPlan(a){return h(this,arguments,function*({intentId:e,planId:t,issuerCode:n}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:n,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(a){return h(this,arguments,function*({first6Digits:e,amount:t,currency:n}){return l.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:n,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(a){return h(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:n}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:n,lang:this.sdkEmbed.lang}})})}renderUrl(r){return h(this,arguments,function*({intentId:e,url:t,renderStrategy:n,options:a}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),n){case"IFRAME":return y(this,H,ce).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return y(this,$,pe).call(this,{url:t,intentId:e,options:a});case"REDIRECT":return y(this,N,ue).call(this,{url:t,options:a});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const n=new Date(e),a=setInterval(()=>h(this,null,function*(){const r=new Date;n<r&&(clearInterval(a),t())}),1e3);return()=>clearInterval(a)}}M=new WeakSet,K=function(e){var n,a;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[P({type:"CARD",parameters:{allowedAuthMethods:((n=this.options.googlePay)==null?void 0:n.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((a=this.options.googlePay)==null?void 0:a.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},R=new WeakSet,Y=function(t){return h(this,arguments,function*({accessToken:e}){const n=new F;this.vaultSubmitListener.current=d=>{const{type:s,data:i}=d.data;s==="vaultSubmit:success"&&n.resolve(i),s==="vaultSubmit:error"&&n.reject(i)};const a=y(this,W,ye).call(this,{accessToken:e}),r=yield n.promise;return a.remove(),r})},H=new WeakSet,ce=function(n){return h(this,arguments,function*({intentId:e,url:t}){const a=document.querySelector("#rendered-url-iframe-container");l.throwIf(!a,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const r=document.createElement("iframe");r.src=t,r.style.setProperty("border","0","important"),r.style.setProperty("width","100%","important"),r.style.setProperty("height","100%","important"),a==null||a.replaceChildren(r),yield y(this,L,x).call(this,{intentId:e}),r.remove()})},$=new WeakSet,pe=function(a){return h(this,arguments,function*({intentId:e,url:t,options:n={}}){const{width:r=600,height:d=400,left:s=200,top:i=200}=n.window||{},c=window.open(t,"",`width=${r},height=${d},left=${s},top=${i}`);l.throwIf(!c,"Popup blocked by browser!"),yield y(this,L,x).call(this,{intentId:e,isUsingPopUp:!0}),c==null||c.close()})},N=new WeakSet,ue=function(n){return h(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},L=new WeakSet,x=function(n){return h(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const a=new F,r=d=>h(this,null,function*(){var i,c,p,u;if(d.origin!==l.getIframeUrl())return;const{type:s}=d.data;if(s==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[g]=yield Promise.all([this.getIntentDetails(e),Ee(2)]),f=g.transaction.status.split(".")[1];f==="successful"||f.startsWith("pending")?(c=(i=this.options).onComplete)==null||c.call(i,P({type:this.options.type},g)):(u=(p=this.options).onFail)==null||u.call(p,P({type:this.options.type},g)),a.resolve(()=>null),window.removeEventListener("message",r)}});return window.addEventListener("message",r),a.promise})},V=new WeakSet,he=function(e){const t=n=>{n.origin===v()&&e.forEach(a=>{a(n)})};window.addEventListener("message",t)},D=new WeakSet,me=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},T=new WeakSet,ge=function({container:e,elementType:t,elementOptions:n,styles:a,fontSourceCss:r}){var c,p,u,g,f;const d=v(),s=new URL(`${d}/vaultField/vaultField.html`);r&&s.searchParams.set("fontSourceCss",r),s.searchParams.set("host",btoa(window.location.origin)),s.searchParams.set("type",t),((c=n.validation)==null?void 0:c.required)!==void 0&&s.searchParams.set("required",`${(p=n.validation)==null?void 0:p.required}`),s.searchParams.set("placeholder",(u=n.placeholder)!=null?u:""),s.searchParams.set("inputMode",(g=n.inputMode)!=null?g:""),s.searchParams.set("lang",this.sdkEmbed.lang),s.searchParams.set("direction",(a==null?void 0:a.direction)||""),s.searchParams.set("color",JSON.stringify(a!=null&&a.color?a.color:"#000")),s.searchParams.set("placeholderColor",(a==null?void 0:a.placeholderColor)||"#ccc"),s.searchParams.set("backgroundColor",(a==null?void 0:a.backgroundColor)||"transparent"),s.searchParams.set("fontSize",(a==null?void 0:a.fontSize)||""),s.searchParams.set("fontFamily",(a==null?void 0:a.fontFamily)||""),s.searchParams.set("fontWeight",`${a==null?void 0:a.fontWeight}`),s.searchParams.set("fontStyle",(a==null?void 0:a.fontStyle)||""),s.searchParams.set("padding",(a==null?void 0:a.padding)||"");const i=document.createElement("iframe");return i.src=s.toString(),i.style.height=(f=a==null?void 0:a.height)!=null?f:"40px",i.style.setProperty("overflow","hidden","important"),i.style.setProperty("display","block","important"),i.style.setProperty("width","100%","important"),i.style.setProperty("maxWidth","100%","important"),i.style.setProperty("border","0","important"),i.style.setProperty("margin","0","important"),i.style.setProperty("padding","0","important"),i.style.setProperty("userSelect","none","important"),i.style.setProperty("colorScheme","light only","important"),e.replaceChildren(i),i},W=new WeakSet,ye=function({accessToken:e}){const t=v(),n=Ae(),a=new URL(`${t}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${n}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang);const r=document.createElement("iframe");return r.id="moneyhash-submit-iframe",r.src=a.toString(),r.hidden=!0,document.body.appendChild(r),r};exports.IFrameSandboxOptions=l.IFrameSandboxOptions;exports.default=Ie;
"use strict";var we=Object.defineProperty,fe=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var j=(o,e,t)=>e in o?we(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,P=(o,e)=>{for(var t in e||(e={}))ie.call(e,t)&&j(o,t,e[t]);if(_)for(var t of _(e))re.call(e,t)&&j(o,t,e[t]);return o},q=(o,e)=>fe(o,Pe(e));var se=(o,e)=>{var t={};for(var n in o)ie.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&_)for(var n of _(o))e.indexOf(n)<0&&re.call(o,n)&&(t[n]=o[n]);return t};var w=(o,e,t)=>(j(o,typeof e!="symbol"?e+"":e,t),t),be=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var b=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)};var y=(o,e,t)=>(be(o,e,"access private method"),t);var h=(o,e,t)=>new Promise((n,a)=>{var r=i=>{try{s(t.next(i))}catch(c){a(c)}},d=i=>{try{s(t.throw(i))}catch(c){a(c)}},s=i=>i.done?n(i.value):Promise.resolve(i.value).then(r,d);s((t=t.apply(o,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./warnIf-d328964e.cjs");function ke(){return typeof window!="undefined"}const k=class{constructor(){ke()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=l.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.10.0");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),k.messagingService=new l.MessagingService({target:n.contentWindow,targetOrigin:e}),k.isCommunicationReady=new Promise(a=>{var d;const r=s=>{var i;s.data.type==="headlessSDK:init"&&(a(),(i=k.messagingService)==null||i.removeListener(r))};(d=k.messagingService)==null||d.onReceive(r)})}request(n){return h(this,arguments,function*({api:e,payload:t}){return yield k.isCommunicationReady,new Promise((a,r)=>{var s,i;(s=k.messagingService)==null||s.send({type:e,data:t});const d=c=>{var g;const{type:p,data:u}=c.data;p===e&&(u.status==="resolved"?a(u.payload):r(u.payload),(g=k.messagingService)==null||g.removeListener(d))};(i=k.messagingService)==null||i.onReceive(d)})})}postMessage(e){var t;(t=k.messagingService)==null||t.send({type:e})}};let C=k;w(C,"messagingService",null),w(C,"isCommunicationReady");class F{constructor(){w(this,"promise");w(this,"resolve");w(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Ae(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function v(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function oe(o){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!o.includes(t))return t;return null}function de(o){return(Array.isArray(o)?o.length:Object.keys(o).length)===0}function O(o,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const r=document.createElement("script");r.src=o,r.id=e,r.addEventListener("load",()=>{t(void 0)}),r.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(r)})}function Ee(o){return new Promise(e=>{setTimeout(()=>{e("done")},o*1e3)})}const le=new Set(["method","customerBalance","savedCard"]);var M,K,R,Y,H,ce,$,pe,N,ue,L,x,V,he,D,me,T,ge,W,ye;class Ie{constructor(e){b(this,M);b(this,R);b(this,H);b(this,$);b(this,N);b(this,L);b(this,V);b(this,D);b(this,T);b(this,W);w(this,"options");w(this,"sdkApiHandler",new C);w(this,"sdkEmbed");w(this,"vaultSubmitListener",{current:null});w(this,"mountedCardElements",[]);w(this,"googlePaymentsClient",null);w(this,"cardForm",{collect:()=>h(this,null,function*(){l.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=oe(this.mountedCardElements);l.throwIf(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return y(this,R,Y).call(this,{accessToken:t})}),pay:s=>h(this,[s],function*({intentId:e,cardData:t,saveCard:n,billingData:a,shippingData:r,installmentPlanData:d}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:a,shippingData:r,cardEmbed:t,saveCard:n,installmentPlanData:d}})}),createCardToken:n=>h(this,[n],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new l.SDKEmbed(q(P({},e),{headless:!0})),y(this,D,me).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}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(l.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),l.throwIf(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:P({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:n,useWalletBalance:a,metaData:r,installmentPlanData:d}){return l.throwIf(!le.has(t),`type must be a valid one (${[...le].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:n,lang:this.sdkEmbed.lang,useWalletBalance:a,metaData:r,installmentPlanData:d}})}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 l.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(c){return h(this,arguments,function*({intentId:e,currency:t,amount:n,countryCode:a,onCancel:r=()=>{},onError:d,onComplete:s,billingData:i={}}){if(yield O("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const p=new ApplePaySession(3,{countryCode:a,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`},requiredShippingContactFields:["email"]}),{state:u,intent:g}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(u==="FORM_FIELDS"){if(de(i))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:i}})}}catch(A){throw yield this.resetSelectedMethod(e),A}const f=new F;return p.onvalidatemerchant=A=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{secret:g.secret,validationUrl:A.validationURL,parentOrigin:window.location.origin}}).then(I=>p.completeMerchantValidation(I)).catch(d),p.onpaymentauthorized=A=>{var I;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:A.payment.token}),receiptBillingData:{email:(I=A.payment.shippingContact)==null?void 0:I.emailAddress}}}).then(U=>{p.completePayment(ApplePaySession.STATUS_SUCCESS),s==null||s(),f.resolve(U)}).catch(()=>{p.completePayment(ApplePaySession.STATUS_FAILURE),d==null||d(),f.reject(void 0)})},p.oncancel=r,p.begin(),f.promise})}renderGooglePayButton(n){return h(this,null,function*(){var a=n,{onClick:e}=a,t=se(a,["onClick"]);var s;const r=document.getElementById("moneyHash-google-pay-button");l.throwIf(!r,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield O("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((s=this.options.googlePay)==null?void 0:s.environment)||"PRODUCTION"});const d=y(this,M,K).call(this);this.googlePaymentsClient.isReadyToPay(d).then(i=>{if(i.result){const c=this.googlePaymentsClient.createButton(q(P({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:d.allowedPaymentMethods,onClick:e}));r==null||r.replaceChildren(c)}else throw new Error("Google Pay is not ready to pay!")}).catch(i=>{console.dir(i)})})}generateGooglePayReceipt({nativePayData:e,onCancel:t}){return l.throwIf(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "generateGooglePayReceipt"'),l.throwIf(!e,"nativePayData is required to generate Google Pay receipt!"),l.throwIf(!e.amount,"nativePayData.amount is required to generate Google Pay receipt!"),this.googlePaymentsClient.loadPaymentData(q(P({},y(this,M,K).call(this,e)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${e.amount}`,currencyCode:e.currency_code,countryCode:e.country_code},merchantInfo:{merchantName:e.merchant_name,merchantId:e.merchant_id},emailRequired:!0})).then(n=>({receipt:n.paymentMethodData.tokenizationData.token,receiptBillingData:{email:n.email}})).catch(n=>(n.statusCode==="CANCELED"?t==null||t():console.dir(n),Promise.reject(n)))}generateApplePayReceipt(n){return h(this,arguments,function*({nativePayData:e,onCancel:t=()=>{}}){if(yield O("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),l.throwIf(!e,"nativePayData is required to generate Apple Pay receipt!"),!e)return{receipt:"",receiptBillingData:{}};if(l.throwIf(!e.amount,"nativePayData.amount is required to generate Apple Pay receipt!"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const a=new ApplePaySession(3,{countryCode:e.country_code,currencyCode:e.currency_code,supportedNetworks:e.supported_networks,merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${e.amount}`},requiredShippingContactFields:["email"]}),r=new F;return a.onvalidatemerchant=d=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{methodId:e.method_id,validationUrl:d.validationURL,parentOrigin:window.location.origin}}).then(s=>a.completeMerchantValidation(s)).catch(s=>{a.abort(),r.reject(s)}),a.onpaymentauthorized=d=>{var i;const s={receipt:JSON.stringify({token:d.payment.token}),receiptBillingData:{email:(i=d.payment.shippingContact)==null?void 0:i.emailAddress}};a.completePayment(ApplePaySession.STATUS_SUCCESS),r.resolve(s)},a.oncancel=t,a.begin(),r.promise})}submitPaymentReceipt({intentId:e,nativeReceiptData:t}){return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:t.receipt,receiptBillingData:t.receiptBillingData}})}payWithGooglePay(a){return h(this,arguments,function*({intentId:e,billingData:t={},onCancel:n}){l.throwIf(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let r=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(r.state==="FORM_FIELDS"){if(de(t))throw new Error("Billing data is missing while calling payWithGooglePay");r=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(s){throw yield this.resetSelectedMethod(e),s}const{__nativePayData__:d}=r;return d?this.generateGooglePayReceipt({nativePayData:d,onCancel:n}).then(s=>this.submitPaymentReceipt({intentId:e,nativeReceiptData:s})):r})}renderForm(e){return l.throwIf(!e.selector,"selector is required for renderForm"),l.throwIf(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){l.warnIf(!!e&&!l.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...l.supportedLanguages].join(" | ")})`);const t=l.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return l.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=>{l.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=[],r={},d=new Map;let s=!1;return y(this,V,he).call(this,a),{create:({elementType:i,elementOptions:c})=>{var I,U;const p=new Map;let u=null;const g=P(P({},t),c.classes),f=((I=g==null?void 0:g.focus)==null?void 0:I.split(" "))||["MoneyHashElement--focus"],A=((U=g==null?void 0:g.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const m=document.querySelector(c.selector);l.throwIf(!m,`Couldn't find an element with selector ${c.selector}!`),m.classList.add("MoneyHashElement"),a.push(G=>{var z,J,X,Q,Z,ee,te,ae,ne;const{type:E,data:S}=G.data;if(E===`${i}@mount`&&(r[i]=S.isValid,(z=p.get(`${i}@mount`))==null||z()),E===`${i}@focus`){m.classList.add(...f),(J=p.get(`${i}@focus`))==null||J();return}if(E===`${i}@blur`){m.classList.remove(...f),(X=p.get(`${i}@blur`))==null||X();return}if(E===`${i}@error`){S.isValid?m.classList.remove(...A):m.classList.add(...A),(Q=p.get(`${i}@error`))==null||Q(S);return}if(E===`${i}@changeInput`){if((Z=p.get(`${i}@changeInput`))==null||Z({isValid:S.isValid,length:S.length}),r[i]=S.isValid,d.get("validityChange")){const B=Object.values(r).every(Boolean);B!==s&&((ee=d.get("validityChange"))==null||ee(B),s=B)}return}if(E===`${i}@cardNumberChange`){(te=p.get(`${i}@cardNumberChange`))==null||te(S);return}if(E===`${i}@key:Backspace`){(ae=p.get(`${i}@key:Backspace`))==null||ae();return}E===`${i}@key:Enter`&&((ne=p.get(`${i}@key:Enter`))==null||ne())}),u=y(this,T,ge).call(this,{container:m,elementType:i,elementOptions:c,styles:P(P({},e),c.styles),fontSourceCss:n}),this.mountedCardElements.push(i)},on:(m,G)=>{p.set(`${i}@${m}`,G)},off:m=>p.delete(`${i}@${m}`),focus:()=>{var m;(m=u==null?void 0:u.contentWindow)==null||m.postMessage({type:"focus"},v())},blur:()=>{var m;(m=u==null?void 0:u.contentWindow)==null||m.postMessage({type:"blur"},v())},clear:()=>{var m;(m=u==null?void 0:u.contentWindow)==null||m.postMessage({type:"clear"},v())}}},on:(i,c)=>{d.set(i,c)}}}submitForm(i){return h(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:a,saveCard:r,paymentMethod:d="CARD",installmentPlanData:s}){let c;if(t){const u=oe(this.mountedCardElements);l.throwIf(!!u,`You must mount ${u} element!`),c=yield y(this,R,Y).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:d,lang:this.sdkEmbed.lang,billingData:n,shippingData:a,cardEmbed:c,saveCard:r,installmentPlanData:s}})})}selectInstallmentPlan(a){return h(this,arguments,function*({intentId:e,planId:t,issuerCode:n}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:n,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(a){return h(this,arguments,function*({first6Digits:e,amount:t,currency:n}){return l.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:n,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(a){return h(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:n}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:n,lang:this.sdkEmbed.lang}})})}renderUrl(r){return h(this,arguments,function*({intentId:e,url:t,renderStrategy:n,options:a}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),n){case"IFRAME":return y(this,H,ce).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return y(this,$,pe).call(this,{url:t,intentId:e,options:a});case"REDIRECT":return y(this,N,ue).call(this,{url:t,options:a});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const n=new Date(e),a=setInterval(()=>h(this,null,function*(){const r=new Date;n<r&&(clearInterval(a),t())}),1e3);return()=>clearInterval(a)}}M=new WeakSet,K=function(e){var n,a;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[P({type:"CARD",parameters:{allowedAuthMethods:((n=this.options.googlePay)==null?void 0:n.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((a=this.options.googlePay)==null?void 0:a.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},R=new WeakSet,Y=function(t){return h(this,arguments,function*({accessToken:e}){const n=new F;this.vaultSubmitListener.current=d=>{const{type:s,data:i}=d.data;s==="vaultSubmit:success"&&n.resolve(i),s==="vaultSubmit:error"&&n.reject(i)};const a=y(this,W,ye).call(this,{accessToken:e}),r=yield n.promise;return a.remove(),r})},H=new WeakSet,ce=function(n){return h(this,arguments,function*({intentId:e,url:t}){const a=document.querySelector("#rendered-url-iframe-container");l.throwIf(!a,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const r=document.createElement("iframe");r.src=t,r.style.setProperty("border","0","important"),r.style.setProperty("width","100%","important"),r.style.setProperty("height","100%","important"),a==null||a.replaceChildren(r),yield y(this,L,x).call(this,{intentId:e}),r.remove()})},$=new WeakSet,pe=function(a){return h(this,arguments,function*({intentId:e,url:t,options:n={}}){const{width:r=600,height:d=400,left:s=200,top:i=200}=n.window||{},c=window.open(t,"",`width=${r},height=${d},left=${s},top=${i}`);l.throwIf(!c,"Popup blocked by browser!"),yield y(this,L,x).call(this,{intentId:e,isUsingPopUp:!0}),c==null||c.close()})},N=new WeakSet,ue=function(n){return h(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},L=new WeakSet,x=function(n){return h(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const a=new F,r=d=>h(this,null,function*(){var i,c,p,u;if(d.origin!==l.getIframeUrl())return;const{type:s}=d.data;if(s==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[g]=yield Promise.all([this.getIntentDetails(e),Ee(2)]),f=g.transaction.status.split(".")[1];f==="successful"||f.startsWith("pending")?(c=(i=this.options).onComplete)==null||c.call(i,P({type:this.options.type},g)):(u=(p=this.options).onFail)==null||u.call(p,P({type:this.options.type},g)),a.resolve(()=>null),window.removeEventListener("message",r)}});return window.addEventListener("message",r),a.promise})},V=new WeakSet,he=function(e){const t=n=>{n.origin===v()&&e.forEach(a=>{a(n)})};window.addEventListener("message",t)},D=new WeakSet,me=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},T=new WeakSet,ge=function({container:e,elementType:t,elementOptions:n,styles:a,fontSourceCss:r}){var c,p,u,g,f;const d=v(),s=new URL(`${d}/vaultField/vaultField.html`);r&&s.searchParams.set("fontSourceCss",r),s.searchParams.set("host",btoa(window.location.origin)),s.searchParams.set("type",t),((c=n.validation)==null?void 0:c.required)!==void 0&&s.searchParams.set("required",`${(p=n.validation)==null?void 0:p.required}`),s.searchParams.set("placeholder",(u=n.placeholder)!=null?u:""),s.searchParams.set("inputMode",(g=n.inputMode)!=null?g:""),s.searchParams.set("lang",this.sdkEmbed.lang),s.searchParams.set("direction",(a==null?void 0:a.direction)||""),s.searchParams.set("color",JSON.stringify(a!=null&&a.color?a.color:"#000")),s.searchParams.set("placeholderColor",(a==null?void 0:a.placeholderColor)||"#ccc"),s.searchParams.set("backgroundColor",(a==null?void 0:a.backgroundColor)||"transparent"),s.searchParams.set("fontSize",(a==null?void 0:a.fontSize)||""),s.searchParams.set("fontFamily",(a==null?void 0:a.fontFamily)||""),s.searchParams.set("fontWeight",`${a==null?void 0:a.fontWeight}`),s.searchParams.set("fontStyle",(a==null?void 0:a.fontStyle)||""),s.searchParams.set("padding",(a==null?void 0:a.padding)||"");const i=document.createElement("iframe");return i.src=s.toString(),i.style.height=(f=a==null?void 0:a.height)!=null?f:"40px",i.style.setProperty("overflow","hidden","important"),i.style.setProperty("display","block","important"),i.style.setProperty("width","100%","important"),i.style.setProperty("maxWidth","100%","important"),i.style.setProperty("border","0","important"),i.style.setProperty("margin","0","important"),i.style.setProperty("padding","0","important"),i.style.setProperty("userSelect","none","important"),i.style.setProperty("colorScheme","light only","important"),e.replaceChildren(i),i},W=new WeakSet,ye=function({accessToken:e}){const t=v(),n=Ae(),a=new URL(`${t}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${n}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang);const r=document.createElement("iframe");return r.id="moneyhash-submit-iframe",r.src=a.toString(),r.hidden=!0,document.body.appendChild(r),r};exports.IFrameSandboxOptions=l.IFrameSandboxOptions;exports.default=Ie;

@@ -48,4 +48,4 @@ var fe = Object.defineProperty, ke = Object.defineProperties;

});
import { M as Ee, g as pe, S as Se, t as u, w as ve, s as O } from "./warnIf-6c9f3798.js";
import { I as He } from "./warnIf-6c9f3798.js";
import { M as Ee, g as pe, S as Se, t as u, w as ve, s as O } from "./warnIf-a3b0e384.js";
import { I as He } from "./warnIf-a3b0e384.js";
function Ce() {

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

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

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

]);
var R, Y, I, x, H, ue, $, me, N, he, L, z, V, ge, D, ye, W, we, T, Pe;
var R, Y, I, x, H, ue, $, me, N, he, L, z, V, ge, D, ye, W, we, G, Pe;
class _e {

@@ -176,3 +176,3 @@ constructor(e) {

k(this, W);
k(this, T);
k(this, G);
w(this, "options");

@@ -619,6 +619,6 @@ w(this, "sdkApiHandler", new M());

!e,
"nativePayData is required to generate Apple Pay receipt!"
"nativePayData is required to generate Google Pay receipt!"
), u(
!e.amount,
"nativePayData.amount is required to generate Apple Pay receipt!"
"nativePayData.amount is required to generate Google Pay receipt!"
), this.googlePaymentsClient.loadPaymentData(q(f({}, y(this, R, Y).call(this, e)), {

@@ -688,3 +688,5 @@ transactionInfo: {

(r) => a.completeMerchantValidation(r)
).catch((r) => s.reject(r)), a.onpaymentauthorized = (d) => {
).catch((r) => {
a.abort(), s.reject(r);
}), a.onpaymentauthorized = (d) => {
var i;

@@ -944,5 +946,5 @@ const r = {

`Couldn't find an element with selector ${l.selector}!`
), h.classList.add("MoneyHashElement"), a.push((B) => {
), h.classList.add("MoneyHashElement"), a.push((T) => {
var J, X, Q, Z, ee, te, ae, ne, ie;
const { type: E, data: v } = B.data;
const { type: E, data: v } = T.data;
if (E === `${i}@mount` && (s[i] = v.isValid, (J = c.get(`${i}@mount`)) == null || J()), E === `${i}@focus`) {

@@ -965,6 +967,6 @@ h.classList.add(...P), (X = c.get(`${i}@focus`)) == null || X();

}), s[i] = v.isValid, d.get("validityChange")) {
const G = Object.values(s).every(Boolean);
G !== r && ((te = d.get("validityChange")) == null || te(
G
), r = G);
const B = Object.values(s).every(Boolean);
B !== r && ((te = d.get("validityChange")) == null || te(
B
), r = B);
}

@@ -992,4 +994,4 @@ return;

},
on: (h, B) => {
c.set(`${i}@${h}`, B);
on: (h, T) => {
c.set(`${i}@${h}`, T);
},

@@ -1246,3 +1248,3 @@ off: (h) => c.delete(`${i}@${h}`),

};
const a = y(this, T, Pe).call(this, {
const a = y(this, G, Pe).call(this, {
accessToken: e

@@ -1355,3 +1357,3 @@ }), s = yield n.promise;

return i.src = r.toString(), i.style.height = (P = a == null ? void 0 : a.height) != null ? P : "40px", i.style.setProperty("overflow", "hidden", "important"), i.style.setProperty("display", "block", "important"), i.style.setProperty("width", "100%", "important"), i.style.setProperty("maxWidth", "100%", "important"), i.style.setProperty("border", "0", "important"), i.style.setProperty("margin", "0", "important"), i.style.setProperty("padding", "0", "important"), i.style.setProperty("userSelect", "none", "important"), i.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(i), i;
}, T = new WeakSet(), Pe = function({ accessToken: e }) {
}, G = new WeakSet(), Pe = function({ accessToken: e }) {
const t = C(), n = Me(), a = new URL(

@@ -1358,0 +1360,0 @@ `${t}/vaultSubmit/vaultSubmit.html`

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

(function(d,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(d=typeof globalThis!="undefined"?globalThis:d||self,l(d.MoneyHash={}))})(this,function(d){var N,ee,D,te,B,we,W,be,j,Pe,V,ie,G,ke,K,Ae,Y,ve,x,Ee;"use strict";var Ie=Object.defineProperty,Le=Object.defineProperties;var Ue=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var Z=(d,l,c)=>l in d?Ie(d,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[l]=c,A=(d,l)=>{for(var c in l||(l={}))ge.call(l,c)&&Z(d,c,l[c]);if(z)for(var c of z(l))ye.call(l,c)&&Z(d,c,l[c]);return d},J=(d,l)=>Le(d,Ue(l));var fe=(d,l)=>{var c={};for(var E in d)ge.call(d,E)&&l.indexOf(E)<0&&(c[E]=d[E]);if(d!=null&&z)for(var E of z(d))l.indexOf(E)<0&&ye.call(d,E)&&(c[E]=d[E]);return c};var w=(d,l,c)=>(Z(d,typeof l!="symbol"?l+"":l,c),c),_e=(d,l,c)=>{if(!l.has(d))throw TypeError("Cannot "+c)};var M=(d,l,c)=>{if(l.has(d))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(d):l.set(d,c)};var v=(d,l,c)=>(_e(d,l,"access private method"),c);var f=(d,l,c)=>new Promise((E,I)=>{var O=C=>{try{q(c.next(C))}catch(H){I(H)}},u=C=>{try{q(c.throw(C))}catch(H){I(H)}},q=C=>C.done?E(C.value):Promise.resolve(C.value).then(O,u);q((c=c.apply(d,l)).next())});class l{constructor(e){w(this,"target");w(this,"targetOrigin");w(this,"listeners");w(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 c(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function E(){return typeof window!="undefined"}const R=class{constructor(){E()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=c(),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.10.0-beta.2");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),R.messagingService=new l({target:n.contentWindow,targetOrigin:e}),R.isCommunicationReady=new Promise(i=>{var o;const s=r=>{var a;r.data.type==="headlessSDK:init"&&(i(),(a=R.messagingService)==null||a.removeListener(s))};(o=R.messagingService)==null||o.onReceive(s)})}request(n){return f(this,arguments,function*({api:e,payload:t}){return yield R.isCommunicationReady,new Promise((i,s)=>{var r,a;(r=R.messagingService)==null||r.send({type:e,data:t});const o=m=>{var g;const{type:h,data:p}=m.data;h===e&&(p.status==="resolved"?i(p.payload):s(p.payload),(g=R.messagingService)==null||g.removeListener(o))};(a=R.messagingService)==null||a.onReceive(o)})})}postMessage(e){var t;(t=R.messagingService)==null||t.send({type:e})}};let I=R;w(I,"messagingService",null),w(I,"isCommunicationReady");const O=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];function u(b,e){if(b)throw new Error(e)}const q=new Set(["payment","payout"]),C=new Set(["en","fr","ar"]);class H{constructor(e){w(this,"options");w(this,"messagingService",null);w(this,"iframe",null);w(this,"isCommunicationReady",null);u(!q.has(e.type),`MoneyHash constructor must be called with valid type (${[...q].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,sandbox:n,onHeightChange:i}){var m,h;(m=this.messagingService)==null||m.abortService();const s=c(),o=new URL(`${s}/embed/${this.options.type}/${t}`);o.searchParams.set("sdk","true"),o.searchParams.set("parent",window.location.origin),o.searchParams.set("version","js@1.10.0-beta.2"),i&&o.searchParams.set("onDimensionsChange","true");const r=(h=this.options.locale)==null?void 0:h.split("-")[0];r&&o.searchParams.set("lang",r),this.iframe=document.createElement("iframe"),this.iframe.src=o.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",n&&n.forEach(p=>{var g;O.includes(p)&&((g=this.iframe)==null||g.sandbox.add(p))});const a=document.querySelector(e);return u(!a,`Couldn't find an element with selector ${e}!`),a.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:s}),this.isCommunicationReady=new Promise(p=>{var P;const g=k=>{var S;k.data.type==="sdk:init"&&(p(),(S=this.messagingService)==null||S.removeListener(g))};(P=this.messagingService)==null||P.onReceive(g)}),this.messagingService.onReceive((p,g)=>{var S,U,y,$;const{type:P,data:k}=p.data;switch(P){case"sdk:init":{g({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(U=(S=this.options).onComplete)==null||U.call(S,A({type:this.options.type},k)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{($=(y=this.options).onFail)==null||$.call(y,A({type:this.options.type},k)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{i==null||i(k.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return f(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 f(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class T{constructor(){w(this,"promise");w(this,"resolve");w(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Se(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function F(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function ae(b){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!b.includes(t))return t;return null}function se(b){return(Array.isArray(b)?b.length:Object.keys(b).length)===0}function X(b,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const s=document.createElement("script");s.src=b,s.id=e,s.addEventListener("load",()=>{t(void 0)}),s.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(s)})}function Ce(b){return new Promise(e=>{setTimeout(()=>{e("done")},b*1e3)})}function Re(b,e){b&&console.warn(e)}const ne=new Set(["method","customerBalance","savedCard"]);class Me{constructor(e){M(this,N);M(this,D);M(this,B);M(this,W);M(this,j);M(this,V);M(this,G);M(this,K);M(this,Y);M(this,x);w(this,"options");w(this,"sdkApiHandler",new I);w(this,"sdkEmbed");w(this,"vaultSubmitListener",{current:null});w(this,"mountedCardElements",[]);w(this,"googlePaymentsClient",null);w(this,"cardForm",{collect:()=>f(this,null,function*(){u(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=ae(this.mountedCardElements);u(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return v(this,D,te).call(this,{accessToken:t})}),pay:r=>f(this,[r],function*({intentId:e,cardData:t,saveCard:n,billingData:i,shippingData:s,installmentPlanData:o}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:i,shippingData:s,cardEmbed:t,saveCard:n,installmentPlanData:o}})}),createCardToken:n=>f(this,[n],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new H(J(A({},e),{headless:!0})),v(this,K,Ae).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}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(u(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),u(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:A({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:n,useWalletBalance:i,metaData:s,installmentPlanData:o}){return u(!ne.has(t),`type must be a valid one (${[...ne].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:n,lang:this.sdkEmbed.lang,useWalletBalance:i,metaData:s,installmentPlanData:o}})}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(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 f(this,arguments,function*({intentId:e,currency:t,amount:n,countryCode:i,onCancel:s=()=>{},onError:o,onComplete:r,billingData:a={}}){if(yield X("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const h=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`},requiredShippingContactFields:["email"]}),{state:p,intent:g}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(p==="FORM_FIELDS"){if(se(a))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:a}})}}catch(k){throw yield this.resetSelectedMethod(e),k}const P=new T;return h.onvalidatemerchant=k=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{secret:g.secret,validationUrl:k.validationURL,parentOrigin:window.location.origin}}).then(S=>h.completeMerchantValidation(S)).catch(o),h.onpaymentauthorized=k=>{var S;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:k.payment.token}),receiptBillingData:{email:(S=k.payment.shippingContact)==null?void 0:S.emailAddress}}}).then(U=>{h.completePayment(ApplePaySession.STATUS_SUCCESS),r==null||r(),P.resolve(U)}).catch(()=>{h.completePayment(ApplePaySession.STATUS_FAILURE),o==null||o(),P.reject(void 0)})},h.oncancel=s,h.begin(),P.promise})}renderGooglePayButton(n){return f(this,null,function*(){var i=n,{onClick:e}=i,t=fe(i,["onClick"]);var r;const s=document.getElementById("moneyHash-google-pay-button");u(!s,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield X("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((r=this.options.googlePay)==null?void 0:r.environment)||"PRODUCTION"});const o=v(this,N,ee).call(this);this.googlePaymentsClient.isReadyToPay(o).then(a=>{if(a.result){const m=this.googlePaymentsClient.createButton(J(A({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:o.allowedPaymentMethods,onClick:e}));s==null||s.replaceChildren(m)}else throw new Error("Google Pay is not ready to pay!")}).catch(a=>{console.dir(a)})})}generateGooglePayReceipt({nativePayData:e,onCancel:t}){return u(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "generateGooglePayReceipt"'),u(!e,"nativePayData is required to generate Apple Pay receipt!"),u(!e.amount,"nativePayData.amount is required to generate Apple Pay receipt!"),this.googlePaymentsClient.loadPaymentData(J(A({},v(this,N,ee).call(this,e)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${e.amount}`,currencyCode:e.currency_code,countryCode:e.country_code},merchantInfo:{merchantName:e.merchant_name,merchantId:e.merchant_id},emailRequired:!0})).then(n=>({receipt:n.paymentMethodData.tokenizationData.token,receiptBillingData:{email:n.email}})).catch(n=>(n.statusCode==="CANCELED"?t==null||t():console.dir(n),Promise.reject(n)))}generateApplePayReceipt(n){return f(this,arguments,function*({nativePayData:e,onCancel:t=()=>{}}){if(yield X("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),u(!e,"nativePayData is required to generate Apple Pay receipt!"),!e)return{receipt:"",receiptBillingData:{}};if(u(!e.amount,"nativePayData.amount is required to generate Apple Pay receipt!"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const i=new ApplePaySession(3,{countryCode:e.country_code,currencyCode:e.currency_code,supportedNetworks:e.supported_networks,merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${e.amount}`},requiredShippingContactFields:["email"]}),s=new T;return i.onvalidatemerchant=o=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{methodId:e.method_id,validationUrl:o.validationURL,parentOrigin:window.location.origin}}).then(r=>i.completeMerchantValidation(r)).catch(r=>s.reject(r)),i.onpaymentauthorized=o=>{var a;const r={receipt:JSON.stringify({token:o.payment.token}),receiptBillingData:{email:(a=o.payment.shippingContact)==null?void 0:a.emailAddress}};i.completePayment(ApplePaySession.STATUS_SUCCESS),s.resolve(r)},i.oncancel=t,i.begin(),s.promise})}submitPaymentReceipt({intentId:e,nativeReceiptData:t}){return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:t.receipt,receiptBillingData:t.receiptBillingData}})}payWithGooglePay(i){return f(this,arguments,function*({intentId:e,billingData:t={},onCancel:n}){u(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let s=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(s.state==="FORM_FIELDS"){if(se(t))throw new Error("Billing data is missing while calling payWithGooglePay");s=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(r){throw yield this.resetSelectedMethod(e),r}const{__nativePayData__:o}=s;return o?this.generateGooglePayReceipt({nativePayData:o,onCancel:n}).then(r=>this.submitPaymentReceipt({intentId:e,nativeReceiptData:r})):s})}renderForm(e){return u(!e.selector,"selector is required for renderForm"),u(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){Re(!!e&&!C.has(e),`Invalid locale. Supported languages (${[...C].join(" | ")})`);const t=C.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return u(!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(!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 i=[],s={},o=new Map;let r=!1;return v(this,G,ke).call(this,i),{create:({elementType:a,elementOptions:m})=>{var S,U;const h=new Map;let p=null;const g=A(A({},t),m.classes),P=((S=g==null?void 0:g.focus)==null?void 0:S.split(" "))||["MoneyHashElement--focus"],k=((U=g==null?void 0:g.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const y=document.querySelector(m.selector);u(!y,`Couldn't find an element with selector ${m.selector}!`),y.classList.add("MoneyHashElement"),i.push($=>{var re,oe,de,le,ce,pe,he,me,ue;const{type:L,data:_}=$.data;if(L===`${a}@mount`&&(s[a]=_.isValid,(re=h.get(`${a}@mount`))==null||re()),L===`${a}@focus`){y.classList.add(...P),(oe=h.get(`${a}@focus`))==null||oe();return}if(L===`${a}@blur`){y.classList.remove(...P),(de=h.get(`${a}@blur`))==null||de();return}if(L===`${a}@error`){_.isValid?y.classList.remove(...k):y.classList.add(...k),(le=h.get(`${a}@error`))==null||le(_);return}if(L===`${a}@changeInput`){if((ce=h.get(`${a}@changeInput`))==null||ce({isValid:_.isValid,length:_.length}),s[a]=_.isValid,o.get("validityChange")){const Q=Object.values(s).every(Boolean);Q!==r&&((pe=o.get("validityChange"))==null||pe(Q),r=Q)}return}if(L===`${a}@cardNumberChange`){(he=h.get(`${a}@cardNumberChange`))==null||he(_);return}if(L===`${a}@key:Backspace`){(me=h.get(`${a}@key:Backspace`))==null||me();return}L===`${a}@key:Enter`&&((ue=h.get(`${a}@key:Enter`))==null||ue())}),p=v(this,Y,ve).call(this,{container:y,elementType:a,elementOptions:m,styles:A(A({},e),m.styles),fontSourceCss:n}),this.mountedCardElements.push(a)},on:(y,$)=>{h.set(`${a}@${y}`,$)},off:y=>h.delete(`${a}@${y}`),focus:()=>{var y;(y=p==null?void 0:p.contentWindow)==null||y.postMessage({type:"focus"},F())},blur:()=>{var y;(y=p==null?void 0:p.contentWindow)==null||y.postMessage({type:"blur"},F())},clear:()=>{var y;(y=p==null?void 0:p.contentWindow)==null||y.postMessage({type:"clear"},F())}}},on:(a,m)=>{o.set(a,m)}}}submitForm(a){return f(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:i,saveCard:s,paymentMethod:o="CARD",installmentPlanData:r}){let m;if(t){const p=ae(this.mountedCardElements);u(!!p,`You must mount ${p} element!`),m=yield v(this,D,te).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:o,lang:this.sdkEmbed.lang,billingData:n,shippingData:i,cardEmbed:m,saveCard:s,installmentPlanData:r}})})}selectInstallmentPlan(i){return f(this,arguments,function*({intentId:e,planId:t,issuerCode:n}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:n,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(i){return f(this,arguments,function*({first6Digits:e,amount:t,currency:n}){return u(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:n,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(i){return f(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:n}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:n,lang:this.sdkEmbed.lang}})})}renderUrl(s){return f(this,arguments,function*({intentId:e,url:t,renderStrategy:n,options:i}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),n){case"IFRAME":return v(this,B,we).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return v(this,W,be).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return v(this,j,Pe).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const n=new Date(e),i=setInterval(()=>f(this,null,function*(){const s=new Date;n<s&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}N=new WeakSet,ee=function(e){var n,i;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[A({type:"CARD",parameters:{allowedAuthMethods:((n=this.options.googlePay)==null?void 0:n.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((i=this.options.googlePay)==null?void 0:i.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},D=new WeakSet,te=function(t){return f(this,arguments,function*({accessToken:e}){const n=new T;this.vaultSubmitListener.current=o=>{const{type:r,data:a}=o.data;r==="vaultSubmit:success"&&n.resolve(a),r==="vaultSubmit:error"&&n.reject(a)};const i=v(this,x,Ee).call(this,{accessToken:e}),s=yield n.promise;return i.remove(),s})},B=new WeakSet,we=function(n){return f(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");u(!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 v(this,V,ie).call(this,{intentId:e}),s.remove()})},W=new WeakSet,be=function(i){return f(this,arguments,function*({intentId:e,url:t,options:n={}}){const{width:s=600,height:o=400,left:r=200,top:a=200}=n.window||{},m=window.open(t,"",`width=${s},height=${o},left=${r},top=${a}`);u(!m,"Popup blocked by browser!"),yield v(this,V,ie).call(this,{intentId:e,isUsingPopUp:!0}),m==null||m.close()})},j=new WeakSet,Pe=function(n){return f(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},V=new WeakSet,ie=function(n){return f(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new T,s=o=>f(this,null,function*(){var a,m,h,p;if(o.origin!==c())return;const{type:r}=o.data;if(r==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[g]=yield Promise.all([this.getIntentDetails(e),Ce(2)]),P=g.transaction.status.split(".")[1];P==="successful"||P.startsWith("pending")?(m=(a=this.options).onComplete)==null||m.call(a,A({type:this.options.type},g)):(p=(h=this.options).onFail)==null||p.call(h,A({type:this.options.type},g)),i.resolve(()=>null),window.removeEventListener("message",s)}});return window.addEventListener("message",s),i.promise})},G=new WeakSet,ke=function(e){const t=n=>{n.origin===F()&&e.forEach(i=>{i(n)})};window.addEventListener("message",t)},K=new WeakSet,Ae=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},Y=new WeakSet,ve=function({container:e,elementType:t,elementOptions:n,styles:i,fontSourceCss:s}){var m,h,p,g,P;const o=F(),r=new URL(`${o}/vaultField/vaultField.html`);s&&r.searchParams.set("fontSourceCss",s),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((m=n.validation)==null?void 0:m.required)!==void 0&&r.searchParams.set("required",`${(h=n.validation)==null?void 0:h.required}`),r.searchParams.set("placeholder",(p=n.placeholder)!=null?p:""),r.searchParams.set("inputMode",(g=n.inputMode)!=null?g:""),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 a=document.createElement("iframe");return a.src=r.toString(),a.style.height=(P=i==null?void 0:i.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},x=new WeakSet,Ee=function({accessToken:e}){const t=F(),n=Se(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("vault_api_url",`${n}/api/v1/tokens/`),i.searchParams.set("access_token",e),i.searchParams.set("lang",this.sdkEmbed.lang);const s=document.createElement("iframe");return s.id="moneyhash-submit-iframe",s.src=i.toString(),s.hidden=!0,document.body.appendChild(s),s},d.IFrameSandboxOptions=O,d.default=Me,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(d,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(d=typeof globalThis!="undefined"?globalThis:d||self,l(d.MoneyHash={}))})(this,function(d){var N,ee,D,te,B,we,W,be,j,Pe,V,ie,G,ke,K,ve,Y,Ae,x,Ee;"use strict";var Ie=Object.defineProperty,Le=Object.defineProperties;var Ue=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var Z=(d,l,c)=>l in d?Ie(d,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[l]=c,v=(d,l)=>{for(var c in l||(l={}))ge.call(l,c)&&Z(d,c,l[c]);if(z)for(var c of z(l))ye.call(l,c)&&Z(d,c,l[c]);return d},J=(d,l)=>Le(d,Ue(l));var fe=(d,l)=>{var c={};for(var E in d)ge.call(d,E)&&l.indexOf(E)<0&&(c[E]=d[E]);if(d!=null&&z)for(var E of z(d))l.indexOf(E)<0&&ye.call(d,E)&&(c[E]=d[E]);return c};var w=(d,l,c)=>(Z(d,typeof l!="symbol"?l+"":l,c),c),_e=(d,l,c)=>{if(!l.has(d))throw TypeError("Cannot "+c)};var M=(d,l,c)=>{if(l.has(d))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(d):l.set(d,c)};var A=(d,l,c)=>(_e(d,l,"access private method"),c);var f=(d,l,c)=>new Promise((E,I)=>{var O=C=>{try{q(c.next(C))}catch(H){I(H)}},u=C=>{try{q(c.throw(C))}catch(H){I(H)}},q=C=>C.done?E(C.value):Promise.resolve(C.value).then(O,u);q((c=c.apply(d,l)).next())});class l{constructor(e){w(this,"target");w(this,"targetOrigin");w(this,"listeners");w(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 c(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function E(){return typeof window!="undefined"}const R=class{constructor(){E()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=c(),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.10.0");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),R.messagingService=new l({target:n.contentWindow,targetOrigin:e}),R.isCommunicationReady=new Promise(i=>{var o;const a=r=>{var s;r.data.type==="headlessSDK:init"&&(i(),(s=R.messagingService)==null||s.removeListener(a))};(o=R.messagingService)==null||o.onReceive(a)})}request(n){return f(this,arguments,function*({api:e,payload:t}){return yield R.isCommunicationReady,new Promise((i,a)=>{var r,s;(r=R.messagingService)==null||r.send({type:e,data:t});const o=m=>{var g;const{type:h,data:p}=m.data;h===e&&(p.status==="resolved"?i(p.payload):a(p.payload),(g=R.messagingService)==null||g.removeListener(o))};(s=R.messagingService)==null||s.onReceive(o)})})}postMessage(e){var t;(t=R.messagingService)==null||t.send({type:e})}};let I=R;w(I,"messagingService",null),w(I,"isCommunicationReady");const O=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];function u(b,e){if(b)throw new Error(e)}const q=new Set(["payment","payout"]),C=new Set(["en","fr","ar"]);class H{constructor(e){w(this,"options");w(this,"messagingService",null);w(this,"iframe",null);w(this,"isCommunicationReady",null);u(!q.has(e.type),`MoneyHash constructor must be called with valid type (${[...q].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,sandbox:n,onHeightChange:i}){var m,h;(m=this.messagingService)==null||m.abortService();const a=c(),o=new URL(`${a}/embed/${this.options.type}/${t}`);o.searchParams.set("sdk","true"),o.searchParams.set("parent",window.location.origin),o.searchParams.set("version","js@1.10.0"),i&&o.searchParams.set("onDimensionsChange","true");const r=(h=this.options.locale)==null?void 0:h.split("-")[0];r&&o.searchParams.set("lang",r),this.iframe=document.createElement("iframe"),this.iframe.src=o.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",n&&n.forEach(p=>{var g;O.includes(p)&&((g=this.iframe)==null||g.sandbox.add(p))});const s=document.querySelector(e);return u(!s,`Couldn't find an element with selector ${e}!`),s.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:a}),this.isCommunicationReady=new Promise(p=>{var P;const g=k=>{var S;k.data.type==="sdk:init"&&(p(),(S=this.messagingService)==null||S.removeListener(g))};(P=this.messagingService)==null||P.onReceive(g)}),this.messagingService.onReceive((p,g)=>{var S,U,y,$;const{type:P,data:k}=p.data;switch(P){case"sdk:init":{g({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(U=(S=this.options).onComplete)==null||U.call(S,v({type:this.options.type},k)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{($=(y=this.options).onFail)==null||$.call(y,v({type:this.options.type},k)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{i==null||i(k.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return f(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 f(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class T{constructor(){w(this,"promise");w(this,"resolve");w(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Se(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function F(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function se(b){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!b.includes(t))return t;return null}function ae(b){return(Array.isArray(b)?b.length:Object.keys(b).length)===0}function X(b,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=b,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(a)})}function Ce(b){return new Promise(e=>{setTimeout(()=>{e("done")},b*1e3)})}function Re(b,e){b&&console.warn(e)}const ne=new Set(["method","customerBalance","savedCard"]);class Me{constructor(e){M(this,N);M(this,D);M(this,B);M(this,W);M(this,j);M(this,V);M(this,G);M(this,K);M(this,Y);M(this,x);w(this,"options");w(this,"sdkApiHandler",new I);w(this,"sdkEmbed");w(this,"vaultSubmitListener",{current:null});w(this,"mountedCardElements",[]);w(this,"googlePaymentsClient",null);w(this,"cardForm",{collect:()=>f(this,null,function*(){u(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=se(this.mountedCardElements);u(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return A(this,D,te).call(this,{accessToken:t})}),pay:r=>f(this,[r],function*({intentId:e,cardData:t,saveCard:n,billingData:i,shippingData:a,installmentPlanData:o}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:i,shippingData:a,cardEmbed:t,saveCard:n,installmentPlanData:o}})}),createCardToken:n=>f(this,[n],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new H(J(v({},e),{headless:!0})),A(this,K,ve).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}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(u(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),u(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:v({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:n,useWalletBalance:i,metaData:a,installmentPlanData:o}){return u(!ne.has(t),`type must be a valid one (${[...ne].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:n,lang:this.sdkEmbed.lang,useWalletBalance:i,metaData:a,installmentPlanData:o}})}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(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 f(this,arguments,function*({intentId:e,currency:t,amount:n,countryCode:i,onCancel:a=()=>{},onError:o,onComplete:r,billingData:s={}}){if(yield X("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const h=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`},requiredShippingContactFields:["email"]}),{state:p,intent:g}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(p==="FORM_FIELDS"){if(ae(s))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:s}})}}catch(k){throw yield this.resetSelectedMethod(e),k}const P=new T;return h.onvalidatemerchant=k=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{secret:g.secret,validationUrl:k.validationURL,parentOrigin:window.location.origin}}).then(S=>h.completeMerchantValidation(S)).catch(o),h.onpaymentauthorized=k=>{var S;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:k.payment.token}),receiptBillingData:{email:(S=k.payment.shippingContact)==null?void 0:S.emailAddress}}}).then(U=>{h.completePayment(ApplePaySession.STATUS_SUCCESS),r==null||r(),P.resolve(U)}).catch(()=>{h.completePayment(ApplePaySession.STATUS_FAILURE),o==null||o(),P.reject(void 0)})},h.oncancel=a,h.begin(),P.promise})}renderGooglePayButton(n){return f(this,null,function*(){var i=n,{onClick:e}=i,t=fe(i,["onClick"]);var r;const a=document.getElementById("moneyHash-google-pay-button");u(!a,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield X("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((r=this.options.googlePay)==null?void 0:r.environment)||"PRODUCTION"});const o=A(this,N,ee).call(this);this.googlePaymentsClient.isReadyToPay(o).then(s=>{if(s.result){const m=this.googlePaymentsClient.createButton(J(v({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:o.allowedPaymentMethods,onClick:e}));a==null||a.replaceChildren(m)}else throw new Error("Google Pay is not ready to pay!")}).catch(s=>{console.dir(s)})})}generateGooglePayReceipt({nativePayData:e,onCancel:t}){return u(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "generateGooglePayReceipt"'),u(!e,"nativePayData is required to generate Google Pay receipt!"),u(!e.amount,"nativePayData.amount is required to generate Google Pay receipt!"),this.googlePaymentsClient.loadPaymentData(J(v({},A(this,N,ee).call(this,e)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${e.amount}`,currencyCode:e.currency_code,countryCode:e.country_code},merchantInfo:{merchantName:e.merchant_name,merchantId:e.merchant_id},emailRequired:!0})).then(n=>({receipt:n.paymentMethodData.tokenizationData.token,receiptBillingData:{email:n.email}})).catch(n=>(n.statusCode==="CANCELED"?t==null||t():console.dir(n),Promise.reject(n)))}generateApplePayReceipt(n){return f(this,arguments,function*({nativePayData:e,onCancel:t=()=>{}}){if(yield X("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),u(!e,"nativePayData is required to generate Apple Pay receipt!"),!e)return{receipt:"",receiptBillingData:{}};if(u(!e.amount,"nativePayData.amount is required to generate Apple Pay receipt!"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const i=new ApplePaySession(3,{countryCode:e.country_code,currencyCode:e.currency_code,supportedNetworks:e.supported_networks,merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${e.amount}`},requiredShippingContactFields:["email"]}),a=new T;return i.onvalidatemerchant=o=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{methodId:e.method_id,validationUrl:o.validationURL,parentOrigin:window.location.origin}}).then(r=>i.completeMerchantValidation(r)).catch(r=>{i.abort(),a.reject(r)}),i.onpaymentauthorized=o=>{var s;const r={receipt:JSON.stringify({token:o.payment.token}),receiptBillingData:{email:(s=o.payment.shippingContact)==null?void 0:s.emailAddress}};i.completePayment(ApplePaySession.STATUS_SUCCESS),a.resolve(r)},i.oncancel=t,i.begin(),a.promise})}submitPaymentReceipt({intentId:e,nativeReceiptData:t}){return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:t.receipt,receiptBillingData:t.receiptBillingData}})}payWithGooglePay(i){return f(this,arguments,function*({intentId:e,billingData:t={},onCancel:n}){u(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let a=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(a.state==="FORM_FIELDS"){if(ae(t))throw new Error("Billing data is missing while calling payWithGooglePay");a=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(r){throw yield this.resetSelectedMethod(e),r}const{__nativePayData__:o}=a;return o?this.generateGooglePayReceipt({nativePayData:o,onCancel:n}).then(r=>this.submitPaymentReceipt({intentId:e,nativeReceiptData:r})):a})}renderForm(e){return u(!e.selector,"selector is required for renderForm"),u(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){Re(!!e&&!C.has(e),`Invalid locale. Supported languages (${[...C].join(" | ")})`);const t=C.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return u(!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(!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 i=[],a={},o=new Map;let r=!1;return A(this,G,ke).call(this,i),{create:({elementType:s,elementOptions:m})=>{var S,U;const h=new Map;let p=null;const g=v(v({},t),m.classes),P=((S=g==null?void 0:g.focus)==null?void 0:S.split(" "))||["MoneyHashElement--focus"],k=((U=g==null?void 0:g.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const y=document.querySelector(m.selector);u(!y,`Couldn't find an element with selector ${m.selector}!`),y.classList.add("MoneyHashElement"),i.push($=>{var re,oe,de,le,ce,pe,he,me,ue;const{type:L,data:_}=$.data;if(L===`${s}@mount`&&(a[s]=_.isValid,(re=h.get(`${s}@mount`))==null||re()),L===`${s}@focus`){y.classList.add(...P),(oe=h.get(`${s}@focus`))==null||oe();return}if(L===`${s}@blur`){y.classList.remove(...P),(de=h.get(`${s}@blur`))==null||de();return}if(L===`${s}@error`){_.isValid?y.classList.remove(...k):y.classList.add(...k),(le=h.get(`${s}@error`))==null||le(_);return}if(L===`${s}@changeInput`){if((ce=h.get(`${s}@changeInput`))==null||ce({isValid:_.isValid,length:_.length}),a[s]=_.isValid,o.get("validityChange")){const Q=Object.values(a).every(Boolean);Q!==r&&((pe=o.get("validityChange"))==null||pe(Q),r=Q)}return}if(L===`${s}@cardNumberChange`){(he=h.get(`${s}@cardNumberChange`))==null||he(_);return}if(L===`${s}@key:Backspace`){(me=h.get(`${s}@key:Backspace`))==null||me();return}L===`${s}@key:Enter`&&((ue=h.get(`${s}@key:Enter`))==null||ue())}),p=A(this,Y,Ae).call(this,{container:y,elementType:s,elementOptions:m,styles:v(v({},e),m.styles),fontSourceCss:n}),this.mountedCardElements.push(s)},on:(y,$)=>{h.set(`${s}@${y}`,$)},off:y=>h.delete(`${s}@${y}`),focus:()=>{var y;(y=p==null?void 0:p.contentWindow)==null||y.postMessage({type:"focus"},F())},blur:()=>{var y;(y=p==null?void 0:p.contentWindow)==null||y.postMessage({type:"blur"},F())},clear:()=>{var y;(y=p==null?void 0:p.contentWindow)==null||y.postMessage({type:"clear"},F())}}},on:(s,m)=>{o.set(s,m)}}}submitForm(s){return f(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:i,saveCard:a,paymentMethod:o="CARD",installmentPlanData:r}){let m;if(t){const p=se(this.mountedCardElements);u(!!p,`You must mount ${p} element!`),m=yield A(this,D,te).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:o,lang:this.sdkEmbed.lang,billingData:n,shippingData:i,cardEmbed:m,saveCard:a,installmentPlanData:r}})})}selectInstallmentPlan(i){return f(this,arguments,function*({intentId:e,planId:t,issuerCode:n}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:n,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(i){return f(this,arguments,function*({first6Digits:e,amount:t,currency:n}){return u(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:n,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(i){return f(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:n}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:n,lang:this.sdkEmbed.lang}})})}renderUrl(a){return f(this,arguments,function*({intentId:e,url:t,renderStrategy:n,options:i}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),n){case"IFRAME":return A(this,B,we).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return A(this,W,be).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return A(this,j,Pe).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const n=new Date(e),i=setInterval(()=>f(this,null,function*(){const a=new Date;n<a&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}N=new WeakSet,ee=function(e){var n,i;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[v({type:"CARD",parameters:{allowedAuthMethods:((n=this.options.googlePay)==null?void 0:n.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((i=this.options.googlePay)==null?void 0:i.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},D=new WeakSet,te=function(t){return f(this,arguments,function*({accessToken:e}){const n=new T;this.vaultSubmitListener.current=o=>{const{type:r,data:s}=o.data;r==="vaultSubmit:success"&&n.resolve(s),r==="vaultSubmit:error"&&n.reject(s)};const i=A(this,x,Ee).call(this,{accessToken:e}),a=yield n.promise;return i.remove(),a})},B=new WeakSet,we=function(n){return f(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");u(!i,"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"),i==null||i.replaceChildren(a),yield A(this,V,ie).call(this,{intentId:e}),a.remove()})},W=new WeakSet,be=function(i){return f(this,arguments,function*({intentId:e,url:t,options:n={}}){const{width:a=600,height:o=400,left:r=200,top:s=200}=n.window||{},m=window.open(t,"",`width=${a},height=${o},left=${r},top=${s}`);u(!m,"Popup blocked by browser!"),yield A(this,V,ie).call(this,{intentId:e,isUsingPopUp:!0}),m==null||m.close()})},j=new WeakSet,Pe=function(n){return f(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},V=new WeakSet,ie=function(n){return f(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new T,a=o=>f(this,null,function*(){var s,m,h,p;if(o.origin!==c())return;const{type:r}=o.data;if(r==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[g]=yield Promise.all([this.getIntentDetails(e),Ce(2)]),P=g.transaction.status.split(".")[1];P==="successful"||P.startsWith("pending")?(m=(s=this.options).onComplete)==null||m.call(s,v({type:this.options.type},g)):(p=(h=this.options).onFail)==null||p.call(h,v({type:this.options.type},g)),i.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),i.promise})},G=new WeakSet,ke=function(e){const t=n=>{n.origin===F()&&e.forEach(i=>{i(n)})};window.addEventListener("message",t)},K=new WeakSet,ve=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},Y=new WeakSet,Ae=function({container:e,elementType:t,elementOptions:n,styles:i,fontSourceCss:a}){var m,h,p,g,P;const o=F(),r=new URL(`${o}/vaultField/vaultField.html`);a&&r.searchParams.set("fontSourceCss",a),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((m=n.validation)==null?void 0:m.required)!==void 0&&r.searchParams.set("required",`${(h=n.validation)==null?void 0:h.required}`),r.searchParams.set("placeholder",(p=n.placeholder)!=null?p:""),r.searchParams.set("inputMode",(g=n.inputMode)!=null?g:""),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 s=document.createElement("iframe");return s.src=r.toString(),s.style.height=(P=i==null?void 0:i.height)!=null?P:"40px",s.style.setProperty("overflow","hidden","important"),s.style.setProperty("display","block","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("maxWidth","100%","important"),s.style.setProperty("border","0","important"),s.style.setProperty("margin","0","important"),s.style.setProperty("padding","0","important"),s.style.setProperty("userSelect","none","important"),s.style.setProperty("colorScheme","light only","important"),e.replaceChildren(s),s},x=new WeakSet,Ee=function({accessToken:e}){const t=F(),n=Se(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("vault_api_url",`${n}/api/v1/tokens/`),i.searchParams.set("access_token",e),i.searchParams.set("lang",this.sdkEmbed.lang);const a=document.createElement("iframe");return a.id="moneyhash-submit-iframe",a.src=i.toString(),a.hidden=!0,document.body.appendChild(a),a},d.IFrameSandboxOptions=O,d.default=Me,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

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

"use strict";var d=Object.defineProperty;var a=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var n=(t,e,s)=>(a(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-df0c60c0.cjs");class o{constructor(e){n(this,"options");n(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start(e){return r.throwIf(!e.selector,"selector is required for start"),r.throwIf(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}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 d=Object.defineProperty;var a=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var n=(t,e,s)=>(a(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-d328964e.cjs");class o{constructor(e){n(this,"options");n(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start(e){return r.throwIf(!e.selector,"selector is required for start"),r.throwIf(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}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 n = Object.defineProperty;
var i = (t, e, s) => e in t ? n(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var r = (t, e, s) => (i(t, typeof e != "symbol" ? e + "" : e, s), s);
import { S as o, t as d, w as u, s as a } from "./warnIf-6c9f3798.js";
import { S as o, t as d, w as u, s as a } from "./warnIf-a3b0e384.js";
class c {

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

@@ -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 $=Object.defineProperty;var U=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var b=(i,s,t)=>s in i?$(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,S=(i,s)=>{for(var t in s||(s={}))A.call(s,t)&&b(i,t,s[t]);if(U)for(var t of U(s))_.call(s,t)&&b(i,t,s[t]);return i};var o=(i,s,t)=>(b(i,typeof s!="symbol"?s+"":s,t),t);var E=(i,s,t)=>new Promise((l,m)=>{var g=r=>{try{u(t.next(r))}catch(a){m(a)}},v=r=>{try{u(t.throw(r))}catch(a){m(a)}},u=r=>r.done?l(r.value):Promise.resolve(r.value).then(g,v);u((t=t.apply(i,s)).next())});const i=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];class s{constructor(e){o(this,"target");o(this,"targetOrigin");o(this,"listeners");o(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 t(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function l(a,e){if(a)throw new Error(e)}const m=new Set(["payment","payout"]),g=new Set(["en","fr","ar"]);class v{constructor(e){o(this,"options");o(this,"messagingService",null);o(this,"iframe",null);o(this,"isCommunicationReady",null);l(!m.has(e.type),`MoneyHash constructor must be called with valid type (${[...m].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,sandbox:R,onHeightChange:w}){var M,O;(M=this.messagingService)==null||M.abortService();const I=t(),d=new URL(`${I}/embed/${this.options.type}/${n}`);d.searchParams.set("sdk","true"),d.searchParams.set("parent",window.location.origin),d.searchParams.set("version","js@1.10.0-beta.2"),w&&d.searchParams.set("onDimensionsChange","true");const L=(O=this.options.locale)==null?void 0:O.split("-")[0];L&&d.searchParams.set("lang",L),this.iframe=document.createElement("iframe"),this.iframe.src=d.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",R&&R.forEach(h=>{var c;i.includes(h)&&((c=this.iframe)==null||c.sandbox.add(h))});const k=document.querySelector(e);return l(!k,`Couldn't find an element with selector ${e}!`),k.replaceChildren(this.iframe),this.messagingService=new s({target:this.iframe.contentWindow,targetOrigin:I}),this.isCommunicationReady=new Promise(h=>{var y;const c=p=>{var f;p.data.type==="sdk:init"&&(h(),(f=this.messagingService)==null||f.removeListener(c))};(y=this.messagingService)==null||y.onReceive(c)}),this.messagingService.onReceive((h,c)=>{var f,F,C,P;const{type:y,data:p}=h.data;switch(y){case"sdk:init":{c({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(F=(f=this.options).onComplete)==null||F.call(f,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(P=(C=this.options).onFail)==null||P.call(C,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{w==null||w(p.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return E(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 E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function u(a,e){a&&console.warn(e)}class r{constructor(e){o(this,"options");o(this,"sdkEmbed");this.options=e,this.sdkEmbed=new v(e)}start(e){return l(!e.selector,"selector is required for start"),l(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}setLocale(e){u(!!e&&!g.has(e),`Invalid locale. Supported languages (${[...g].join(" | ")})`);const n=g.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return r});
(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 $=Object.defineProperty;var U=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var b=(i,s,t)=>s in i?$(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,S=(i,s)=>{for(var t in s||(s={}))A.call(s,t)&&b(i,t,s[t]);if(U)for(var t of U(s))_.call(s,t)&&b(i,t,s[t]);return i};var o=(i,s,t)=>(b(i,typeof s!="symbol"?s+"":s,t),t);var E=(i,s,t)=>new Promise((l,m)=>{var g=r=>{try{u(t.next(r))}catch(a){m(a)}},v=r=>{try{u(t.throw(r))}catch(a){m(a)}},u=r=>r.done?l(r.value):Promise.resolve(r.value).then(g,v);u((t=t.apply(i,s)).next())});const i=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];class s{constructor(e){o(this,"target");o(this,"targetOrigin");o(this,"listeners");o(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 t(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function l(a,e){if(a)throw new Error(e)}const m=new Set(["payment","payout"]),g=new Set(["en","fr","ar"]);class v{constructor(e){o(this,"options");o(this,"messagingService",null);o(this,"iframe",null);o(this,"isCommunicationReady",null);l(!m.has(e.type),`MoneyHash constructor must be called with valid type (${[...m].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,sandbox:R,onHeightChange:w}){var M,O;(M=this.messagingService)==null||M.abortService();const I=t(),d=new URL(`${I}/embed/${this.options.type}/${n}`);d.searchParams.set("sdk","true"),d.searchParams.set("parent",window.location.origin),d.searchParams.set("version","js@1.10.0"),w&&d.searchParams.set("onDimensionsChange","true");const L=(O=this.options.locale)==null?void 0:O.split("-")[0];L&&d.searchParams.set("lang",L),this.iframe=document.createElement("iframe"),this.iframe.src=d.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",R&&R.forEach(h=>{var c;i.includes(h)&&((c=this.iframe)==null||c.sandbox.add(h))});const k=document.querySelector(e);return l(!k,`Couldn't find an element with selector ${e}!`),k.replaceChildren(this.iframe),this.messagingService=new s({target:this.iframe.contentWindow,targetOrigin:I}),this.isCommunicationReady=new Promise(h=>{var y;const c=p=>{var f;p.data.type==="sdk:init"&&(h(),(f=this.messagingService)==null||f.removeListener(c))};(y=this.messagingService)==null||y.onReceive(c)}),this.messagingService.onReceive((h,c)=>{var f,F,C,P;const{type:y,data:p}=h.data;switch(y){case"sdk:init":{c({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(F=(f=this.options).onComplete)==null||F.call(f,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(P=(C=this.options).onFail)==null||P.call(C,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{w==null||w(p.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return E(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 E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function u(a,e){a&&console.warn(e)}class r{constructor(e){o(this,"options");o(this,"sdkEmbed");this.options=e,this.sdkEmbed=new v(e)}start(e){return l(!e.selector,"selector is required for start"),l(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}setLocale(e){u(!!e&&!g.has(e),`Invalid locale. Supported languages (${[...g].join(" | ")})`);const n=g.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return r});
{
"name": "@moneyhash/js-sdk",
"version": "1.10.0-beta.2",
"version": "1.10.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