@payrails/web-sdk 2.7.10-RC.0 → 2.7.11-RC.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/package.json +3 -2
- package/payrails.d.ts +3 -314
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(){"use strict";var e=require("@braintree/uuid");function t(e,t,i,n){return new(i||(i=Promise))((function(o,s){function r(e){try{l(n.next(e))}catch(e){s(e)}}function a(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,a)}l((n=n.apply(e,t||[])).next())}))}function i(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function n(e,t,i,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,i):o?o.value=i:t.set(e,i),i}let o;exports.ElementType=void 0,function(e){e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.CVV="CVV",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR"}(exports.ElementType||(exports.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;const s=new Uint8Array(16);function r(){if(!o&&(o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!o))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(s)}const a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));var l,d={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,i){if(d.randomUUID&&!t&&!e)return d.randomUUID();const n=(e=e||{}).random||(e.rng||r)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return(a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST"}(l||(l={}));const E=({url:e,method:i=l.GET,token:n,body:o})=>t(void 0,void 0,void 0,(function*(){const t={method:i,headers:Object.assign(Object.assign(Object.assign({},u()),h(n)),p())};i===l.POST&&(t.body=JSON.stringify(o||{}));const s=yield fetch(e,t),r=yield s.json();if([401,403].includes(s.status))throw new _(e,i);if(!s.ok)throw new I(e,i,r);return{ok:s.ok,req:Object.assign({url:e},t),res:r}}));class _ extends Error{constructor(e,t){super(`[${t}] ${e} unauthorized`)}}class I extends Error{constructor(e,t,i){super(`[${t}] ${e} unsuccessful`),this.res=i}}const h=e=>({authorization:`Bearer ${e}`}),u=()=>({"x-idempotency-key":c()}),p=()=>({"x-client-version":"2.7.10-RC.0","x-client-type":"web-sdk"});class f{constructor(e,t,i){this.sdkConfig=e,this.execution=t,this.returnLinks=i}pay(e){return t(this,void 0,void 0,(function*(){const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount)throw new Error("SDK was not initialized with workflow execution");const{success:t="https://payrails.io/success",error:i="https://payrails.io/error",cancel:n="https://payrails.io/cancel"}=this.returnLinks||{};return E({url:this.execution.authorizeLink,method:l.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i}}})}))}confirm(e,i={}){return t(this,void 0,void 0,(function*(){const t=yield E({url:e,method:l.POST,token:this.sdkConfig.token,body:{data:i}}),n=yield this.pollForAuthorizationResult(t.res.links.execution);if(n.finalState)return n;const o=n.response.status.slice().sort(((e,t)=>new Date(t.time).getTime()-new Date(e.time).getTime()))[0].time,{res:s}=yield this.getExecution(t.res.links.execution,void 0,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}))}pollForAuthorizationResult(e,i=0){return t(this,void 0,void 0,(function*(){const t=(yield this.getExecution(e)).res,n=t.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],s=n.find((({code:e})=>"authorizeRequested"===e));if(!s&&i<10)return yield new Promise((e=>setTimeout(e,300))),this.pollForAuthorizationResult(e,i+1);if(!s)throw new Error("Authorization was not requested");const r=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(s.time))),a=r?r.time:s.time;let l=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(a)));if(!l){const{res:t}=yield this.getExecution(e,void 0,a);return l=t.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(a))),{finalState:l,response:t}}return{finalState:l,response:t}}))}getExecution(e,i,n){return t(this,void 0,void 0,(function*(){const t=new URLSearchParams;i&&i.length>0&&t.append("waitWhile[status]",`[${i.map((e=>`"${e}"`)).join(",")}]`),n&&t.append("waitWhile[lastStatusTime]",n);const o=`${e}${t.toString()?"?":""}${t.toString()}`;return E({url:o,token:this.sdkConfig.token})}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return E({url:e.requestUrl,method:l.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:e.sessionUrl,clientDomain:e.clientDomain||window.location.host}}})}))}}var N,T,v;!function(e){e.CARD="card",e.GOOGLE_PAY="googlePay",e.PAYPAL="payPal",e.APPLE_PAY="applePay"}(N||(N={})),function(e){e.ENABLED="enabled",e.CREATED="created"}(T||(T={}));class O{constructor(e){this.executionResponse=e}get lookup(){return this.executionResponse.initialResults.find((({body:{name:e}})=>"lookup"===e))}get holderReference(){return this.executionResponse.holderReference}get savedCreditCards(){return this.getStoredInstrumentForPaymentMethod(N.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(N.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(N.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(N.APPLE_PAY)}get paypalConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===N.PAYPAL));if(!e)throw new Error("trying to initialize paypal without config");return e.config||{}}get googlePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===N.GOOGLE_PAY));if(!e)throw new Error("trying to initialize google pay without config");return e?[e.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===N.APPLE_PAY));if(!e)throw new Error("apple pay config not found");return e.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var e;return(null===(e=this.lookup)||void 0===e?void 0:e.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var e;return null===(e=this.lookup)||void 0===e?void 0:e.body.links.authorize.href}get createSessionLink(){return this.response.links.startPaymentSession.href}get storedPaymentInstruments(){return this.availablePaymentMethods.flatMap((e=>e.paymentInstruments||[]))}getStoredInstrumentForPaymentMethod(e){var t;return(null===(t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e)))||void 0===t?void 0:t.paymentInstruments)||[]}}class L{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&n.setAttribute("class",i),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new Error("Element id is not set");return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new Error("Sub elements can not be rendered, please set id for the element");e.mount(this.selector)}))}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class A extends L{get bin(){var e;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(e=this.cardForm)||void 0===e?void 0:e.bin)||""}constructor(e,t,i,n){var o;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnLinks=n,this.selectedInstrument=null,this.element.innerText=(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var e;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{}))})),this.paymentExecutor=new f(this.sdkConfig,this.execution,this.returnLinks)}setDisabled(e){var t,i,n,o,s;this.element.classList.contains("disabled")!==e&&(null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onStateChanged)||void 0===i||i.call(t,e?"disabled":"enabled")),this.element.disabled=e,e?(this.element.classList.add("disabled"),(null===(n=this.options.styles)||void 0===n?void 0:n.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(e){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(e)}setSavedInstrument(e){this.selectedInstrument=e,this.setDisabled(!1)}setStyles(e){var t;const i=Object.assign(Object.assign({},null===(t=this.options.styles)||void 0===t?void 0:t.base),e);Object.keys(i).forEach((e=>{this.element.style[e]=i[e]}))}removeStyles(e){var t;const i=Object.keys((null===(t=this.options.styles)||void 0===t?void 0:t.base)||{});Object.keys(e).forEach((e=>{var t,n;i.includes(e)?this.element.style[e]=null===(n=null===(t=this.options.styles)||void 0===t?void 0:t.base)||void 0===n?void 0:n[e]:this.element.style[e]=""}))}setLabel(e){this.element.innerText=e}setCardForm(e){this.cardForm=e}triggerLoading(e){var t,i,n,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,e?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(n=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===n?void 0:n.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(e){var t,i;this.setDisabled(!1),this.triggerLoading(!1),(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options.events)||void 0===i||i.onAuthorizeFailed(e))}onPay(){var e,i,n,o,s,r,a,l,d,c;return t(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),null===(e=this.options.events)||void 0===e?void 0:e.onPaymentButtonClicked)try{if(!1===(yield null===(i=this.options.events)||void 0===i?void 0:i.onPaymentButtonClicked({bin:this.bin||""})))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked resolved to false"})}catch(e){return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked threw an error"})}try{const e=[{paymentMethodCode:N.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)e[0].paymentInstrumentId=null===(o=this.selectedInstrument)||void 0===o?void 0:o.id,e[0].paymentMethodCode=null===(s=this.selectedInstrument)||void 0===s?void 0:s.paymentMethod;else{const{tokenizedCardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.collectCardFormValues();e[0].paymentInstrumentData={vaultToken:null==t?void 0:t.instrumentId,card:{numberToken:null==t?void 0:t.card_number,securityCodeToken:null==t?void 0:t.security_code}},e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n}const t=yield this.paymentExecutor.pay(e);this.handleAuthorizationResult(t)}catch(e){e instanceof _||[401,403].includes(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.code)?(null===(l=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===l||l.call(a),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"API token is not valid or expired."})):e.toString().includes("Invalid token")?(null===(c=null===(d=this.options.events)||void 0===d?void 0:d.onPaymentSessionExpired)||void 0===c||c.call(d),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"Vault token is not valid or expired."})):this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:e.toString(),rawError:e})}}))}handleAuthorizationResult(e){var t,i,n;switch(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":"3ds"===(null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.actionRequired)&&this.handle3ds(e);break;default:this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed."})}}handle3ds(e){var i,n,o,s;try{null===(n=null===(i=this.options.events)||void 0===i?void 0:i.onThreeDSecureChallenge)||void 0===n||n.call(i)}catch(e){}const r=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.links["3ds"];if(r){const e=[[250,400],[390,400],[500,600],[600,400]],i=screen.width,n=e.reduce(((e,t)=>i>t[0]?t:e),[250,400]),o=document.createElement("iframe");o.setAttribute("id","payrails-3ds-frame"),o.setAttribute("src",r),o.setAttribute("width",n[0].toString()),o.setAttribute("height",n[1].toString());const a=document.createElement("div");a.setAttribute("id","payrails-3ds-challenge"),a.appendChild(o);const l=document.createElement("div");l.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){l.remove()})))),l.setAttribute("id","payrails-3ds-popup-background"),l.appendChild(a);const d=e=>t(this,void 0,void 0,(function*(){var t,i,n;if(e.data&&'{"type":"3DS-challenge-completed"}'===e.data){window.removeEventListener("message",d),l.remove();if(!(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e))&&(null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."});if(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)return void(null===(n=this.options.events)||void 0===n||n.onAuthorizeSuccess())}}));null===(s=document.querySelector("body"))||void 0===s||s.appendChild(l),window.addEventListener("message",d),a.style.width=`${n[0]+4}px`,a.style.height=`${n[1]+4}px`}}collectCardFormValues(){return t(this,void 0,void 0,(function*(){if(!this.cardForm)throw new Error("Trying to collect values from non-existent card form");return yield this.cardForm.collectValues()}))}}exports.AuthorizationFailureReasons=void 0,(v=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",v.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",v.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",v.UNKNOWN_ERROR="UNKNOWN_ERROR";var m="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function R(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y={},D={},S={};Object.defineProperty(S,"__esModule",{value:!0}),S.isntString=void 0,S.isntString=function(e){return"string"!=typeof e};var C={},g={};Object.defineProperty(g,"__esModule",{value:!0}),g.subscribers=g.childWindows=g.prefix=void 0,g.prefix="/*framebus*/",g.childWindows=[],g.subscribers={};var b={},w={},M={},P={};Object.defineProperty(P,"__esModule",{value:!0}),P.subscriptionArgsInvalid=void 0;var U=S;P.subscriptionArgsInvalid=function(e,t,i){return!!U.isntString(e)||("function"!=typeof t||U.isntString(i))};var V={},k={};Object.defineProperty(k,"__esModule",{value:!0}),k.hasOpener=void 0,k.hasOpener=function(e){return e.top===e&&(null!=e.opener&&(e.opener!==e&&!0!==e.opener.closed))},Object.defineProperty(V,"__esModule",{value:!0}),V.broadcast=void 0;var Y,x,F,G=k;function B(){if(Y)return M;Y=1,Object.defineProperty(M,"__esModule",{value:!0}),M.Framebus=void 0;var e=S,t=P,i=V,n=j(),o=g,s=function(){function s(e){void 0===e&&(e="*"),this.origin=e}return s.target=function(e){return void 0===e&&(e="*"),new s(e)},s.prototype.include=function(e){return null!=e&&(null!=e.Window&&(e.constructor===e.Window&&(o.childWindows.push(e),!0)))},s.prototype.target=function(e){return s.target(e)},s.prototype.emit=function(t,o,s){var r=this.origin;if(e.isntString(t))return!1;if(e.isntString(r))return!1;"function"==typeof o&&(s=o,o=void 0);var a=n.packagePayload(t,r,o,s);return!!a&&(i.broadcast(window.top||window.self,a,r),!0)},s.prototype.on=function(e,i){var n=this.origin;return!t.subscriptionArgsInvalid(e,i,n)&&(o.subscribers[n]=o.subscribers[n]||{},o.subscribers[n][e]=o.subscribers[n][e]||[],o.subscribers[n][e].push(i),!0)},s.prototype.off=function(e,i){var n=this.origin;if(t.subscriptionArgsInvalid(e,i,n))return!1;var s=o.subscribers[n]&&o.subscribers[n][e];if(!s)return!1;for(var r=0;r<s.length;r++)if(s[r]===i)return s.splice(r,1),!0;return!1},s}();return M.Framebus=s,M}function j(){if(F)return b;F=1,Object.defineProperty(b,"__esModule",{value:!0}),b.packagePayload=void 0;var t=function(){if(x)return w;x=1;var t=m&&m.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(w,"__esModule",{value:!0}),w.subscribeReplier=void 0;var i=B(),n=t(e);return w.subscribeReplier=function(e,t){var o=n.default();return i.Framebus.target(t).on(o,(function n(s,r){e(s,r),i.Framebus.target(t).off(o,n)})),o},w}(),i=g;return b.packagePayload=function(e,n,o,s){var r,a={event:e,origin:n};"function"==typeof s&&(a.reply=t.subscribeReplier(s,n)),a.eventData=o;try{r=i.prefix+JSON.stringify(a)}catch(e){throw new Error("Could not stringify event: "+e.message)}return r},b}V.broadcast=function e(t,i,n){var o,s=0;try{for(t.postMessage(i,n),G.hasOpener(t)&&e(t.opener.top,i,n);o=t.frames[s];)e(o,i,n),s++}catch(e){}},Object.defineProperty(C,"__esModule",{value:!0}),C.unpackPayload=void 0;var X=g,$=j();C.unpackPayload=function(e){var t;if(e.data.slice(0,X.prefix.length)!==X.prefix)return!1;try{t=JSON.parse(e.data.slice(X.prefix.length))}catch(e){return!1}if(t.reply){var i=e.origin,n=e.source,o=t.reply;t.reply=function(e){if(n){var t=$.packagePayload(o,i,e);t&&n.postMessage(t,i)}}}return t};var W={};Object.defineProperty(W,"__esModule",{value:!0}),W.dispatch=void 0;var K=g;W.dispatch=function(e,t,i,n,o){if(K.subscribers[e]&&K.subscribers[e][t]){var s=[];i&&s.push(i),n&&s.push(n);for(var r=0;r<K.subscribers[e][t].length;r++)K.subscribers[e][t][r].apply(o,s)}};var z={};Object.defineProperty(z,"__esModule",{value:!0}),z.broadcastToChildWindows=void 0;var H=V,q=g;z.broadcastToChildWindows=function(e,t,i){for(var n=q.childWindows.length-1;n>=0;n--){var o=q.childWindows[n];o.closed?q.childWindows.splice(n,1):i!==o&&H.broadcast(o.top,e,t)}},Object.defineProperty(D,"__esModule",{value:!0}),D.onmessage=void 0;var J=S,Z=C,Q=W,ee=z;D.onmessage=function(e){if(!J.isntString(e.data)){var t=Z.unpackPayload(e);if(t){var i=t.eventData,n=t.reply;Q.dispatch("*",t.event,i,n,e),Q.dispatch(e.origin,t.event,i,n,e),ee.broadcastToChildWindows(e.data,t.origin,e.source)}}},Object.defineProperty(y,"__esModule",{value:!0}),y.detach=y.attach=void 0;var te=D,ie=!1;y.attach=function(){ie||"undefined"==typeof window||(ie=!0,window.addEventListener("message",te.onmessage,!1))},y.detach=function(){ie=!1,window.removeEventListener("message",te.onmessage,!1)};var ne=y,oe=new(B().Framebus);ne.attach();var se=R(oe);const re={INITIALIZE_CLIENT:"%s1 - Initializing skyflow client.",CLIENT_INITIALIZED:"%s1 - Initialized skyflow client successfully.",CREATE_COLLECT_CONTAINER:"%s1 - Creating Collect container.",COLLECT_CONTAINER_CREATED:"%s1 - Created Collect container successfully.",CREATE_REVEAL_CONTAINER:"%s1 - Creating Reveal container.",REVEAL_CONTAINER_CREATED:"%s1 - Created Reveal container successfully.",VALIDATE_RECORDS:"%s1 - Validating insert records.",VALIDATE_DETOKENIZE_INPUT:"%s1 - Validating detokenize input.",VALIDATE_GET_INPUT:"%s1 - Validating get input.",VALIDATE_DELETE_INPUT:"%s1 - Validating delete input.",VALIDATE_COLLECT_RECORDS:"%s1 - Validating collect element input.",VALIDATE_REVEAL_RECORDS:"%s1 - Validating reveal element input.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",ELEMENT_REVEALED:"%s1 - %s2 Element revealed.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",REVEAL_SUBMIT_SUCCESS:"%s1 - Data has been revealed successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted successfully.",DETOKENIZE_SUCCESS:"%s1 - Data has been revealed successfully.",GET_SUCCESS:"%s1 - Data has been revealed successfully.",DELETE_SUCCESS:"%s1 - Data has been deleted successfully.",BEARER_TOKEN_LISTENER:"%s1 - Get bearer token listener added.",CAPTURED_BEARER_TOKEN_EVENT:"%s1 - Captured bearer token event.",BEARER_TOKEN_RESOLVED:"%s1 - GetBearerToken promise resolved successfully.",REUSE_BEARER_TOKEN:"%s1 - Reusing the bearer token.",PUREJS_CONTROLLER_INITIALIZED:"%s1 - SkyflowController initialized.",PUREJS_LISTENER_READY:"%s1 - Purejs listener ready.",EMIT_PURE_JS_CONTROLLER:"%s1 - Emitted Skyflow controller event.",INSERT_TRIGGERED:"%s1 - Insert method triggered.",DETOKENIZE_TRIGGERED:"%s1 - Detokenize method triggered.",GET_TRIGGERED:"%s1 - Get method triggered.",GET_BY_ID_TRIGGERED:"%s1 - Get method triggered.",DELETE_TRIGGERED:"%s1 - Delete method triggered.",EMIT_PURE_JS_REQUEST:"%s1 - Emitted %s2 request.",CAPTURE_PURE_JS_REQUEST:"%s1 - Captured %s2 event.",LISTEN_PURE_JS_REQUEST:"%s1 - Listening to %s2 event.",CAPTURE_PUREJS_FRAME:"%s1 - Captured SkyflowController frame ready event.",FETCH_RECORDS_RESOLVED:"%s1 - Detokenize request is resolved.",INSERT_RECORDS_RESOLVED:"%s1 - Insert request is resolved.",GET_RESOLVED:"%s1 - Get request is resolved.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",DELETE_RESOLVED:"%s1 - Delete request is resolved",EMIT_EVENT:"%s1 - %s2 event emitted",CAPTURE_EVENT:"%s1 - Captured event %s2",LISTEN_COLLECT_FRAME_READY:"%s1 - Listening to collect FRAME_READY event",EMIT_COLLECT_ELEMENT_FRAME_READY:"%s1 - Emitting collect element %s2 FRAME_READY event",ENTERED_COLLECT_FRAME_READY_CB:"%s1 - In IFrameForm constructor, Entered FRAME_READY callback",EXECUTE_COLLECT_ELEMENT_FRAME_READY_CB:"%s1 - In IFrameForm, executing collect element, %s2 FRAME_READY callback",CLIENT_METADATA_NOT_SET:"%s1 - Client metadata not set",EXECUTE_COLLECT_ELEMENT_INIT:"%s1 - calling Collect element init",INSIDE__COLLECT_ELEMENT_INIT:"%s1 - Inside Collect element init for %s2",CREATING_COLLECT_ELEMENT_FORM:"%s1 - Start, creating iframe form for %s2",COLLECT_FRAME_READY_CB:"%s1 - In FrameElements, executing collect element FRAME_READY cb for %s2, sending metadata",INSIDE_FRAME_ELEMENTS_CONSTRUCOTR:"%s1 - Inside FrameElements constructor",SETUP_IN_START:"%s1 - Inside FrameElements start(), calling setup",SETUP_IN_CONSTRUCTOR:"%s1 - Inside FrameElements constructor, calling setup",COLLECT_ELEMET_START:"%s1 - %s2, Collect Element start",COLLECT_CONTROLLER_START:"%s1 - %s2, Collect Controller start",REVEAL_ELEMENT_START:"%s1 - %s2, Reveal Element start",EMIT_COLLECT_FRAME_CONTROLLER_EVENT:"%s1 - Emit collect FrameController FRAME_READY event",EXECUTE_COLLECT_CONTROLLER_READY_CB:"%s1 - Executing collect FrameController FRAME_READY callback, set client metadata",IFRAMEFORM_CONSTRUCTOR_FRAME_READY_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for FRAME_READY event",IFRAMEFORM_CONSTRUCTOR_TOKENIZATION_LISTNER:"%s1 - In IFrameForm constructor, Adding listner for TOKENIZATION_REQUEST event",CURRENT_ENV:"%s1 - Client Env is %s2",CURRENT_LOG_LEVEL:"%s1 - Client LogLevel is %s2",VALIDATE_GET_BY_ID_INPUT:"%s1 - Validating getByID input."},ae={CLIENT_CONNECTION:"Interface: collect container - client connection not established. client info has not reached iframes",INVALID_BEARER_TOKEN:"Interface: init - Invalid token is generated from getBearerToken callback",BEARER_TOKEN_REJECTED:"Interface: init - GetBearerToken promise got rejected.",VAULTID_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultID is required.",EMPTY_VAULTID_IN_INIT:"Interface: init - Invalid client credentials. vaultID cannot be empty.",VAULTURL_IS_REQUIRED:"Interface: init - Invalid client credentials. vaultURL is required.",EMPTY_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. vaultURL cannot be empty.",INVALID_VAULTURL_IN_INIT:"Interface: init - Invalid client credentials. Expecting https://XYZ for vaultURL",GET_BEARER_TOKEN_IS_REQUIRED:"Interface: init - Invalid client credentials. getBearerToken is required.",EMPTY_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Container object cannot be empty.",INVALID_CONTAINER_TYPE:"Interface: client {containerType} container - Invalid container type. Invalid container object.",INVALID_COLLECT_VALUE:"Invalid value",INVALID_COLLECT_VALUE_WITH_LABEL:"Invalid %s1",REQUIRED_COLLECT_VALUE:"%s1 is required",DEFAULT_REQUIRED_COLLECT_VALUE:"Field is required",RECORDS_KEY_NOT_FOUND:"Interface: client insert - records object is required.",INVALID_RECORDS_IN_INSERT:"Interface: client insert - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_INSERT:"Interface: client insert - records array cannot be empty.",MISSING_TABLE_IN_INSERT:'Interface: client insert - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_INSERT:"Interface: client insert - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_INSERT:"Interface: client insert - table of type string is required at index %s1 in records array.",EMPTY_FIELDS_IN_INSERT:"Interface: client insert - fields cannot be empty in records array at index %s1",MISSING_FIELDS_IN_INSERT:'Interface: client insert - "fields" key is required in records array at index %s1',INVALID_FIELDS_IN_INSERT:"Interface: client insert - fields of type object is required at index %s1 in records array.",INVALID_TOKENS_IN_INSERT:"Interface: client insert - Invalid tokens in options. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_DELETE:"Interface: client delete - records object is required.",INVALID_RECORDS_IN_DELETE:"Interface: client delete - Invalid records. records object should be an array.",EMPTY_RECORDS_IN_DELETE:"Interface: client delete - records array cannot be empty.",MISSING_TABLE_IN_DELETE:'Interface: client delete - "table" key is required in records array at index %s1',EMPTY_TABLE_IN_DELETE:"Interface: client delete - table cannot be empty in records array at index %s1",INVALID_TABLE_IN_DELETE:"Interface: client delete - table of type string is required at index %s1 in records array.",MISSING_ID_IN_DELETE:'Interface: client delete - "id" key is required in records array at index %s1',EMPTY_ID_IN_DELETE:"Interface: client delete - id cannot be empty in records array at index %s1",INVALID_ID_IN_DELETE:"Interface: client delete - id of type string is required at index %s1 in records array.",DELETE_RECORDS_REJECTED:"Interface: client delete - delete request is rejected.",INVALID_TOKENS_IN_COLLECT:"Interface: collect container - Invalid tokens. tokens of type boolean is required.",RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:'Interface: collect container - "records" key not found in additionalFields',INVALID_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records should be an array inside additionalFields",EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - records object cannot be empty in additionalFields",MISSING_TABLE_IN_ADDITIONAL_FIELDS:'Interface: collect container - "table" key not found in additionalFields records at index %s1',INVALID_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid table name in additionalFields records at index %s1",INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid skyflow id in additionalFields records at index %s1",MISSING_FIELDS_IN_ADDITIONAL_FIELDS:'Interface: collect container - "fields" key not found in additionalFields records at index %s1',INVALID_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - Provide valid fields in additionalFields records at index %s1",RECORDS_KEY_NOT_FOUND_DETOKENIZE:"Interface: client detokenize - records object is required.",EMPTY_RECORDS_DETOKENIZE:"Interface: client detokenize - records array cannot be empty.",INVALID_RECORDS_IN_DETOKENIZE:"Interface: client detokenize - Invalid records. records object should be an array.",MISSING_TOKEN_IN_DETOKENIZE:'Interface: client detokenize - "token" key is required in records array at index %s1 ',INVALID_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - Invalid token. token of type string is required at index %s1 in records array.",RECORDS_KEY_NOT_FOUND_GET:"Interface: client get - records object is required.",INVALID_RECORDS_IN_GET:"Interface: client get - Invalid records. records object should be an array.",EMPTY_RECORDS_GET:"Interface: client get - records array cannot be empty.",MISSING_IDS_IN_GET:'Interface: client get - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GET:"Interface: client get - Invalid ids. ids object should be an array.",INVALID_COLUMN_VALUES_IN_GET:"Interface: client get - Invalid column values. column values object should be an array.",EMPTY_IDS_IN_GET:"Interface: client get - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GET:"Interface: client get - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GET:'Interface: client get - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GET:"Interface: client get - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GET:'Interface: client get - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GET:"Interface: client get - Invalid redaction type in records array at index %s1",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",EMPTY_RECORDS_REVEAL:"Interface: reveal container - cannot invoke reveal method before creating reveal elements",MISSING_TOKEN_KEY_REVEAL:"Interface: RevealElement - token key is required ",INVALID_TOKEN_ID_REVEAL:"Interface: RevealElement - token is invalid. token of type string is required",INVALID_LABEL_REVEAL:"Interface: RevealElement - label is invalid.",INVALID_ALT_TEXT_REVEAL:"Interface: RevealElement - Invalid altText.",INVALID_FORMAT_REVEAL:"Interface: RevealElement - Invalid format type.",EMPTY_FORMAT_REVEAL:"Interface: RevealElement - Empty format value provided.",INVALID_FORMAT_VALUE_REVEAL:"Interface: RevealElement - Invalid format value provided.",INVALID_REDACTION_TYPE_REVEAL:"Interface: RevealElement - Invalid Redaction type.",ELEMENTS_NOT_MOUNTED_REVEAL:"Interface: reveal container - Cannot invoke reveal before mounting the elements",EMPTY_TABLE_IN_ADDITIONAL_FIELDS:"Interface: collect container - table cannot be empty in additionalFields at index %s1",EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:"Interface: collect container - fields cannot be empty in additionalFields at index %s1",EMPTY_TOKEN_IN_DETOKENIZE:"Interface: client detokenize - token cannot be empty in records array at index %s1",EMPTY_SKYFLOWID_IN_GET:"Interface: client get - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GET:"Interface: client get - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GET:"Interface: client get - redaction cannot be empty in records array at index %s1",EMPTY_TOKEN_ID_REVEAL:"Interface: RevealElement - token cannot be empty",FETCH_RECORDS_REJECTED:"Interface: client detokenize - detokenize request is rejected.",INSERT_RECORDS_REJECTED:"Interface: client insert - insert request is rejected.",GET_REJECTED:"Interface: client get - get request is rejected.",FAILED_REVEAL:"Interface: reveal conatiner - Failed to reveal data",MISSING_TABLE_IN_COLLECT:'Interface: collect element - "table" key is required.',EMPTY_TABLE_IN_COLLECT:"Interface: collect element - table cannot be empty.",EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:"Interface: collect element - id cannot be empty.",INVALID_TABLE_IN_COLLECT:"Interface: collect element - Invalid table. table of type string is required",INVALID_SKYFLOWID_IN_COLLECT:"Interface: collect element - Invalid id. id of type string is required",MISSING_COLUMN_IN_COLLECT:'Interface: collect element - "column" key is required.',MISSING_SKYFLOWID_IN_COLLECT:'Interface: collect element - "skyflowID" key is required in file type element',EMPTY_COLUMN_IN_COLLECT:"Interface: collect element - column cannot be empty.",INVALID_COLUMN_IN_COLLECT:"Interface: collect element - Invalid column. column of type string is required",UNIQUE_ELEMENT_NAME:"The element name has to unique: %s1",ELEMENTS_NOT_MOUNTED:"Interface: collect container - Elements should be mounted before invoking collect",DUPLICATE_ELEMENT:"Interface: collect container - Duplicate column %s1 found in %s2.",DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:"Interface: collect container - Duplicate column %s1 found in %s2 in additional fields",MISSING_ELEMENT_TYPE:'Interface:container element with type {TYPE} - Invalid element type. "type" key is required.',EMPTY_ELEMENT_TYPE:"Interface:container element with type {TYPE} - Invalid element type. type cannot be empty.",INVALID_ELEMENT_TYPE:"Interface:container element with type {TYPE} - invalid element type. type not found",INVALID_ELEMENT_SELECTOR:"Interface: container element with type {TYPE} - Div cannot be found.",CANNOT_CHANGE_ELEMENT:"Element can't be changed.",INVALID_IFRAME:"Error occured while creating an iframe",INVALID_FIELD:"Invalid Field.",FRAME_NOT_FOUND:"Interface: collect element - %s1 frame not found:",COMPLETE_AND_VALID_INPUTS:"Interface: collect container - Provide complete and valid inputs for %s1",REQUIRED_PARAMS_NOT_PROVIDED:"Interface: collect element - Required params are not provided.",INVALID_EVENT_TYPE:"Interface: collect element - Provide a valid event type.",INVALID_EVENT_LISTENER:'Interface: "on" on CollectElement - Provide valid event listener.',MISSING_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Second argument is missing. handler cannot be empty.',INVALID_HANDLER_IN_EVENT_LISTENER:'Interface: "on" on CollectElement - Invalid handler. handler should be of type function.',UNKNOWN_ERROR:"Unknown Error.",NETWORK_ERROR:"A network error occurred. This could be a CORS issue or a dropped internet connection. It is not possible for us to know. Please reach out to skyflow if you see this error",CONNECTION_ERROR:"Error while initializing the connection.",ERROR_OCCURED:"Error occurred.",INVALID_VALIDATIONS_TYPE:"Interface: collect element - Invalid validations type.",MISSING_VALIDATION_RULE_TYPE:"Interface: collect element - Type is missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_TYPE:"Interface: collect element - Invalid ValidationRuleType at index %s1 in validations array",MISSING_VALIDATION_RULE_PARAMS:"Interface: collect element - params are missing in validationRule at index %s1 in validations array",INVALID_VALIDATION_RULE_PARAMS:"Interface: collect element - Invalid ValidationRule params at index %s1 in validations array",MISSING_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Missing regex in ValidationRule params at index %s1 in validations array",INVALID_REGEX_IN_REGEX_MATCH_RULE:"Interface: collect element - Invalid regex in ValidationRule params at index %s1 in validations array",MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:"Interface: collect element - Either min or max is required in ValidationRule params at index %s1 in validations array",MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Missing element in ValidationRule params at index %s1 in validations array",INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:"Interface: collect element - Invalid collect element in ValidationRule params at index %s1 in validations array",ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",EMPTY_ELEMENT_IN_MOUNT:"Interface: mount element with type %s1 - Mount cannot be empty.",VALIDATION_FAILED:"Validation failed",REVEAL_ELEMENT_ERROR_STATE:"unable to reveal, since one or more element(s) have setError",INVALID_FILE_TYPE:"Interface: collect element - Invalid File Type",INVALID_FILE_SIZE:"Interface: collect element - Invalid File Size",NO_FILE_SELECTED:"Interface: collect element - No File Selected",INVALID_UPSERT_OPTION_TYPE:"Invalid upsert option, should be an array",EMPTY_UPSERT_OPTIONS_ARRAY:"upsert option cannot be an empty array, atleast one object of table and column is required.",INVALID_UPSERT_OPTION_OBJECT_TYPE:"Invalid upsert object at index %s1, an object of table and column is required.",MISSING_TABLE_IN_UPSERT_OPTION:'"table" key is required in upsert options object at index %s1',MISSING_COLUMN_IN_UPSERT_OPTION:'"column" key is required in upsert option at index %s1',INVALID_TABLE_IN_UPSERT_OPTION:"Invalid table in upsert object at index %s1, table of type non empty string is required",INVALID_COLUMN_IN_UPSERT_OPTION:"Invalid column in upsert object at index %s1, column of type non empty string is required",INVALID_RECORD_COLUMN_VALUE:"Invalid Record Column value.",MISSING_RECORD_COLUMN_VALUE:"Column Values is required when Column Name is specified.",MISSING_RECORD_COLUMN_NAME:"Column Name is required when Column Values are specified.",INVALID_RECORD_COLUMN_VALUE_TYPE:"Invalid Type of Records Column Values.",INVALID_COLUMN_VALUES_TYPE:"Invalid column values type, should be an Array.",EMPTY_RECORD_COLUMN_VALUES:"Record column values cannot be empty.",EMPTY_COLUMN_VALUE:"Column Value is empty.",MISSING_IDS_OR_COLUMN_VALUES_IN_GET:'Interface: client get - "ids" key or "columnValues" key is missing.',SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:"ids and columnName can not be specified together.",GET_BY_SKYFLOWID_RESOLVED:"%s1 - GetById request is resolved.",RECORDS_KEY_NOT_FOUND_GETBYID:"Interface: client getById - records object is required.",INVALID_RECORDS_IN_GETBYID:"Interface: client getById - Invalid records. records object should be an array.",EMPTY_RECORDS_GETBYID:"Interface: client getById - records array cannot be empty.",MISSING_IDS_IN_GETBYID:'Interface: client getById - "ids" key is required in records array at index %s1',INVALID_IDS_IN_GETBYID:"Interface: client getById - Invalid ids. ids object should be an array.",EMPTY_IDS_IN_GETBYID:"Interface: client getById - ids array cannot be empty at index %s1",INVALID_SKYFLOWID_TYPE_IN_GETBYID:"Interface: client getById - Invalid skyflowId in ids array at index %s1",MISSING_TABLE_IN_GETBYID:'Interface: client getById - "table" key is required in records array at index %s1',INVALID_TABLE_IN_GETBYID:"Interface: client getById - table of type string is required at index %s1 in records array.",MISSING_REDACTION_IN_GETBYID:'Interface: client getById - "redaction" key is required in records array at index %s1',INVALID_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - Invalid redaction type in records array at index %s1",EMPTY_SKYFLOWID_IN_GETBYID:"Interface: client getById - id cannot be empty in records array at index %s1",EMPTY_TABLE_IN_GETBYID:"Interface: client getById - table cannot be empty in records array at index %s1",EMPTY_REDACTION_TYPE_IN_GETBYID:"Interface: client getById - redaction cannot be empty in records array at index %s1",GET_BY_SKYFLOWID_REJECTED:"Interface: client getById - getById request is rejected.",MISSING_COMPOSABLE_LAYOUT_KEY:"Interface: client container - layout is required in composable container options.",EMPTY_COMPOSABLE_LAYOUT_ARRAY:"Interface: client container - layout array cannot be empty in composable container options.",INVALID_COMPOSABLE_LAYOUT_TYPE:"Interface: client container - invalid layout value, layout should be of type array of numbers in composable container options.",NEGATIVE_VALUES_COMPOSABLE_LAYOUT:"Interface: client container - layout array should only have postive numbers in composable container options.",MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:"Interface: composable container mount - created elements count should be equal to sum of layout values.",MISSING_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - options object is required for composable container.",INVALID_COMPOSABLE_CONTAINER_OPTIONS:"Interface: client composable container - invalid options value, should be an object type.",COMPOSABLE_CONTAINER_NOT_MOUNTED:"Interface: composable collect - container should be mounted before invoking collect.",INVALID_BOOLEAN_OPTIONS:"Interface: container create - Invaild %s1 in options, %s1 of type boolean is required.",INVALID_INPUT_OPTIONS_FORMAT:"Interface: container create - Invalid type, format must be of non-empty string type.",INVALID_INPUT_OPTIONS_TRANSLATION:"Interface: container create - Invalid type, translation must be of non-empty object type.",EMPTY_COLLECT_CUSTOM_FORMAT:"Interface: container create - %s1 cannot be empty object."},le={INVALID_EXPIRATION_DATE_FORMAT:"EXPIRATION_DATE format must be in one of %s1, the format is set to default MM/YY",INVALID_EXPIRATION_YEAR_FORMAT:"EXPIRATION_YEAR format must be in one of %s1, the format is set to default YY",UNABLE_TO_SET_VALUE_IN_PROD_ENV:"%s1 setValue() cannot invoked while in PROD env. It is Not Recommeded",UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV:"%s1 clearValue() cannot invoked while in PROD env. It is Not Recommeded",COLLECT_ALT_TEXT_DEPERECATED:"altText is DEPERECATED, passing altText will not have any effect",GET_BY_ID_DEPRECATED:"getById is deprecated, use new get method",INPUT_FORMATTING_NOT_SUPPROTED:"format or translation are not supported on %s1 element type.",INVALID_INPUT_TRANSLATION:"invalid or unsupported translation provided for %s1 element type."},de="collect_controller",ce="reveal_controller",Ee="element",_e="INSERT",Ie="DETOKENIZE",he="GET_BY_SKYFLOWID",ue="GET",pe="DELETE",fe={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED"},Ne="FRAME_READY",Te="TOKENIZATION_REQUEST",ve="INPUT_EVENT",Oe="DESTROY FRAME",Le="SET_VALUE",Ae="REVEAL_REQUEST",me="REVEAL_FRAME_READY",Re="PUREJS_REQUEST",ye="PUREJS_FRAME_READY",De="GET_BEARER_TOKEN",Se="COLLECT_ELEMENT_SET_ERROR",Ce="REVEAL_ELEMENT_SET_ERROR",ge="REVEAL_ELEMENT_UPDATE_OPTIONS",be="FILE_UPLOAD",we="COMPOSABLE_UPDATE_OPTIONS",Me="TOKEN",Pe="ALT_TEXT",Ue="ELEMENT_MOUNTED",Ve="ALL_ELEMENTS_MOUNTED",ke="COMPOSABLE_CONTAINER_MOUNTED",Ye="COLLECT_CONTAINER_MOUNTED",xe="REVEAL_CONTAINER_MOUNTED";var Fe,Ge;!function(e){e.CVV="CVV",e.EXPIRATION_DATE="EXPIRATION_DATE",e.CARD_NUMBER="CARD_NUMBER",e.CARDHOLDER_NAME="CARDHOLDER_NAME",e.INPUT_FIELD="INPUT_FIELD",e.PIN="PIN",e.EXPIRATION_MONTH="EXPIRATION_MONTH",e.EXPIRATION_YEAR="EXPIRATION_YEAR",e.FILE_INPUT="FILE_INPUT"}(Fe||(Fe={})),function(e){e.VISA="VISA",e.MASTERCARD="MASTERCARD",e.AMEX="AMEX",e.DINERS_CLUB="DINERS_CLUB",e.DISCOVER="DISCOVER",e.JCB="JCB",e.MAESTRO="MAESTRO",e.UNIONPAY="UNIONPAY",e.HIPERCARD="HIPERCARD",e.DEFAULT="DEFAULT",e.UNKNOWN="UNKNOWN"}(Ge||(Ge={}));const Be={[Ge.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[Ge.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ge.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[Ge.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ge.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[Ge.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ge.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ge.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ge.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ge.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[Ge.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},je={textarea:{name:"textarea",attributes:{type:"textarea"},sensitive:!1},checkbox:{name:"checkbox",attributes:{type:"checkbox"},sensitive:!1},radio:{name:"radio",attributes:{type:"radio"},sensitive:!1},dropdown:{name:"dropdown",attributes:{type:"select"},sensitive:!1},[Fe.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[Fe.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:Be[Ge.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[Fe.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[Fe.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[Fe.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{maxLength:4,type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[Fe.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[Fe.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[Fe.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/},[Fe.FILE_INPUT]:{name:"FILE_INPUT",sensitive:!0,attributes:{type:"file"}}},Xe="XXXX-XXXX-XXXX-XXXX",$e={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},We={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},Ke={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ze={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};ze.BASE,ze.BASE,ze.BASE,ze.REQUIRED_ASTERISK;const He={[Ge.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[Ge.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[Ge.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[Ge.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[Ge.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[Ge.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ge.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[Ge.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[Ge.MAESTRO]:{regex:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/,maxCardLength:19,cardLengthRange:[12,13,14,15,16,17,18,19]}};Ge.DEFAULT,Ge.AMEX,Ge.DINERS_CLUB,Ge.DISCOVER,Ge.HIPERCARD,Ge.JCB,Ge.MAESTRO,Ge.MASTERCARD,Ge.UNIONPAY,Ge.VISA;const qe="MM/YY",Je=[qe,"YYYY/MM","YY/MM","MM/YYYY"],Ze=["YY","YYYY"];var Qe;!function(e){e.APPLICATIONORJSON="application/json",e.TEXTORPLAIN="text/plain",e.TEXTORXML="text/xml",e.FORMURLENCODED="application/x-www-form-urlencoded",e.FORMDATA="multipart/form-data"}(Qe||(Qe={})),Fe.CARD_NUMBER,Fe.EXPIRATION_DATE,Fe.EXPIRATION_MONTH,Fe.EXPIRATION_YEAR,Fe.CVV,Fe.EXPIRATION_DATE,Fe.CARD_NUMBER,Fe.CARDHOLDER_NAME,Fe.INPUT_FIELD,ae.INVALID_COLLECT_VALUE,Fe.PIN,Fe.EXPIRATION_MONTH,Fe.EXPIRATION_YEAR,Fe.FILE_INPUT,ae.INVALID_COLLECT_VALUE,Fe.CVV,Fe.EXPIRATION_DATE,Fe.CARD_NUMBER,Fe.CARDHOLDER_NAME,Fe.INPUT_FIELD,ae.DEFAULT_REQUIRED_COLLECT_VALUE,Fe.PIN,Fe.EXPIRATION_MONTH,Fe.EXPIRATION_YEAR,Fe.FILE_INPUT,ae.DEFAULT_REQUIRED_COLLECT_VALUE;const et=[Fe.CARDHOLDER_NAME,Fe.EXPIRATION_MONTH,Fe.FILE_INPUT,Fe.PIN,Fe.CVV],tt={X:"[0-9]"};class it{constructor(){this.events={}}on(e,t,i=!1){this.events[e]?this.events[e].push({priority:i,callback:t}):this.events[e]=[{priority:i,callback:t}]}off(e,t){const i=this.events[e];if(!i)return;const n=i.findIndex((e=>e.callback===t));i.splice(n,1)}_emit(e,...t){const i=this.events[e];i&&i.forEach((e=>{e.callback(...t)}))}hasListener(e){const t=this.events[e];return!!t&&t.length>0}resetEvents(){const e={};Object.keys(this.events).forEach((t=>{const i=this.events[t];if(i&&i.length>0){const n=[];i.forEach((e=>{e.priority&&n.push(e)})),e[t]=n}})),this.events=e}static createChild(e){e.prototype=Object.create(it.prototype,{constructor:e})}}const nt={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},ot={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%; height: 100%",allow:"clipboard-read; clipboard-write"},st=(e,t)=>{Object.keys(t).forEach((i=>{if(Object.prototype.hasOwnProperty.call(t,i)){const n=t[i];null==n?e.removeAttribute(i):e.setAttribute(i,n)}}))};var rt=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},ot),e);return Object.assign(t.style,$e),st(t,i),t.getAttribute("id")||(t.id=t.name),t};const at=()=>nt.IFRAME_SECURE_SITE,lt=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function dt(e){return JSON.parse(JSON.stringify(e))}class ct{constructor(){this.listeners=[],this.isDestroyed=!1}on(e,t){se.on(e,t),this.listeners.push({eventName:e,callback:t})}off(e,t){se.off(e,t);const i=this.listeners.findIndex((t=>t.eventName===e));-1!==i&&this.listeners.splice(i,1)}emit(e,t,i=void 0){se.emit(e,t,i)}hasListener(e){return-1!==this.listeners.findIndex((t=>t.eventName===e))}teardown(){this.listeners.forEach((e=>{se.off(e.eventName,e.handler)})),this.listeners=[]}}var Et,_t,It,ht,ut,pt,ft;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Et||(Et={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(_t||(_t={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(It||(It={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(ht||(ht={})),function(e){e.DEV="DEV",e.PROD="PROD"}(ut||(ut={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(pt||(pt={})),function(e){e.REGEX_MATCH_RULE="REGEX_MATCH_RULE",e.LENGTH_MATCH_RULE="LENGTH_MATCH_RULE",e.ELEMENT_VALUE_MATCH_RULE="ELEMENT_VALUE_MATCH_RULE"}(ft||(ft={}));const Nt={DEBUG:{showDebugLogs:!0,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},INFO:{showDebugLogs:!1,showInfoLogs:!0,showWarnLogs:!0,showErrorLogs:!0},WARN:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!0,showErrorLogs:!0},ERROR:{showDebugLogs:!1,showInfoLogs:!1,showWarnLogs:!1,showErrorLogs:!0}},Tt={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},vt="[Skyflow]",Ot=(e,t,i)=>{if(i&&Nt[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Nt[i];t===pt.LOG&&n?console.log(`${ht.DEBUG}: ${vt} ${e}`):t===pt.LOG&&o?console.log(`${ht.INFO}: ${vt} ${e}`):t===pt.WARN&&s?console.warn(`${ht.WARN}: ${vt} ${e}`):t===pt.ERROR&&r&&console.error(`${ht.ERROR}: ${vt} ${e}`)}},Lt=(...e)=>{const t=e[0],i=e.filter(((e,t)=>0!==t));return t?t.replace(/%s[0-9]+/g,(e=>{const t=e.replace("%s","")-1;return i[t]})):""},At=(e="")=>{const t=e.split(":");if("group"===t[1])return"composable container";let i=atob(t[2]);return-1!==i.indexOf(":")&&(i=i.substring(0,i.indexOf(":"))),i};class mt extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Lt(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Rt={INVALID_FIELD:{code:400,description:ae.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:ae.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:ae.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:ae.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:ae.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:ae.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:ae.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:ae.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:ae.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:ae.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:ae.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:ae.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:ae.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:ae.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:ae.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:ae.MISSING_COLUMN_IN_COLLECT},MISSING_SKYFLOWID_IN_COLLECT:{code:400,description:ae.MISSING_SKYFLOWID_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:ae.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:ae.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:ae.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:ae.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:ae.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:ae.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:ae.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:ae.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:ae.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:ae.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:ae.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:ae.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:ae.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:ae.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:ae.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:ae.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:ae.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:ae.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:ae.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:ae.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:ae.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:ae.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:ae.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:ae.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:ae.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:ae.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:ae.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:ae.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_GET},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:ae.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:ae.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:ae.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:ae.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:ae.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:ae.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:ae.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:ae.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:ae.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:ae.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:ae.INVALID_ID_IN_DELETE},EMPTY_RECORDS_REVEAL:{code:400,description:ae.EMPTY_RECORDS_REVEAL},MISSING_TOKEN_KEY_REVEAL:{code:400,description:ae.MISSING_TOKEN_KEY_REVEAL},INVALID_TOKEN_ID_REVEAL:{code:400,description:ae.INVALID_TOKEN_ID_REVEAL},INVALID_LABEL_REVEAL:{code:400,description:ae.INVALID_LABEL_REVEAL},INVALID_ALT_TEXT_REVEAL:{code:400,description:ae.INVALID_ALT_TEXT_REVEAL},INVALID_FORMAT_REVEAL:{code:400,description:ae.INVALID_FORMAT_REVEAL},EMPTY_FORMAT_REVEAL:{code:400,description:ae.EMPTY_FORMAT_REVEAL},INVALID_FORMAT_VALUE_REVEAL:{code:400,description:ae.INVALID_FORMAT_VALUE_REVEAL},INVALID_REDACTION_TYPE_REVEAL:{code:400,description:ae.INVALID_REDACTION_TYPE_REVEAL},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:ae.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:ae.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:ae.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:ae.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:ae.EMPTY_REDACTION_TYPE_IN_GET},EMPTY_TOKEN_ID_REVEAL:{code:400,description:ae.EMPTY_TOKEN_ID_REVEAL},DUPLICATE_ELEMENT:{code:400,description:ae.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:ae.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:ae.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:ae.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:ae.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:ae.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:ae.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:ae.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:ae.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:ae.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:ae.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:ae.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:ae.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:ae.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:ae.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:ae.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:ae.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:ae.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:ae.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:ae.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:ae.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:ae.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:ae.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:ae.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ae.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:ae.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:ae.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:ae.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:ae.EMPTY_ELEMENT_IN_MOUNT},REVEAL_ELEMENT_ERROR_STATE:{code:400,description:ae.REVEAL_ELEMENT_ERROR_STATE},INVALID_FILE_TYPE:{code:400,description:ae.INVALID_FILE_TYPE},INVALID_FILE_SIZE:{code:400,description:ae.INVALID_FILE_SIZE},NO_FILE_SELECTED:{code:400,description:ae.NO_FILE_SELECTED},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:ae.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:ae.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:ae.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:ae.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:ae.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:ae.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:ae.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:ae.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:ae.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:ae.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:ae.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:ae.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:ae.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:ae.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:ae.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:ae.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:ae.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:ae.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:ae.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:ae.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:ae.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:ae.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:ae.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:ae.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:ae.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:ae.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:ae.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:ae.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:ae.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:ae.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:ae.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:ae.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ae.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:ae.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:ae.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:ae.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:ae.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:ae.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:ae.INVALID_INPUT_OPTIONS_TRANSLATION}},yt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Rt.RECORDS_KEY_NOT_FOUND,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new mt(Rt.INVALID_RECORDS_IN_INSERT,[],!0);if(0===i.length)throw new mt(Rt.EMPTY_RECORDS_IN_INSERT,[],!0);if(i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Rt.MISSING_TABLE_IN_INSERT,[`${t}`],!0);if(!e.table)throw new mt(Rt.EMPTY_TABLE_IN_INSERT,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Rt.INVALID_TABLE_IN_INSERT,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new mt(Rt.MISSING_FIELDS_IN_INSERT,[`${t}`],!0);if(!e.fields)throw new mt(Rt.EMPTY_FIELDS_IN_INSERT,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new mt(Rt.INVALID_FIELDS_IN_INSERT,[`${t}`],!0)})),t&&t.tokens&&"boolean"!=typeof t.tokens)throw new mt(Rt.INVALID_TOKENS_IN_INSERT,[],!0)},Dt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Rt.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new mt(Rt.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new mt(Rt.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);t.forEach(((e,t)=>{var i,n,o,s;if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Rt.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new mt(Rt.EMPTY_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(void 0!==(null===(i=e.fields)||void 0===i?void 0:i.skyflowID)){if(!(null===(n=e.fields)||void 0===n?void 0:n.skyflowID))throw new mt(Rt.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!("string"==typeof(null===(o=e.fields)||void 0===o?void 0:o.skyflowID)||(null===(s=e.fields)||void 0===s?void 0:s.skyflowID)instanceof String))throw new mt(Rt.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Rt.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new mt(Rt.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new mt(Rt.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new mt(Rt.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},St=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Rt.RECORDS_KEY_NOT_FOUND_DETOKENIZE);const{records:t}=e;if(!t||!Array.isArray(t))throw new mt(Rt.INVALID_RECORDS_IN_DETOKENIZE);if(0===t.length)throw new mt(Rt.EMPTY_RECORDS_DETOKENIZE);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"token"))throw new mt(Rt.MISSING_TOKEN_IN_DETOKENIZE,[`${t}`]);if(!e.token)throw new mt(Rt.EMPTY_TOKEN_IN_DETOKENIZE,[`${t}`]);if(!("string"==typeof e.token||e.token instanceof String))throw new mt(Rt.INVALID_TOKEN_IN_DETOKENIZE,[`${t}`]);const i=e.redaction;if(i&&!Object.values(Et).includes(i))throw new mt(Rt.INVALID_REDACTION_TYPE_IN_DETOKENIZE,[`${t}`])}))},Ct=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Rt.RECORDS_KEY_NOT_FOUND_GET);const{records:t}=e;if(!t||!Array.isArray(t))throw new mt(Rt.INVALID_RECORDS_IN_GET,[]);if(0===t.length)throw new mt(Rt.EMPTY_RECORDS_GET);t.forEach(((e,t)=>{var i,n,o;if(0===Object.keys(e).length)throw new mt(Rt.EMPTY_RECORDS_GET);if(0===(null===(i=e.ids)||void 0===i?void 0:i.length))throw new mt(Rt.EMPTY_IDS_IN_GET,[`${t}`]);if(!(null==e.ids||e.ids&&Array.isArray(e.ids)))throw new mt(Rt.INVALID_IDS_IN_GET,[`${t}`]);if(null===(n=e.ids)||void 0===n||n.forEach((e=>{if(!e)throw new mt(Rt.EMPTY_SKYFLOWID_IN_GET,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new mt(Rt.INVALID_SKYFLOWID_TYPE_IN_GET,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Rt.MISSING_TABLE_IN_GET,[`${t}`]);if(!e.table)throw new mt(Rt.EMPTY_TABLE_IN_GET,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Rt.INVALID_TABLE_IN_GET,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new mt(Rt.MISSING_REDACTION_IN_GET,[`${t}`]);if(!e.redaction)throw new mt(Rt.EMPTY_REDACTION_TYPE_IN_GET,[`${t}`]);if(!Object.values(Et).includes(e.redaction))throw new mt(Rt.INVALID_REDACTION_TYPE_IN_GET,[`${t}`]);if(!0===Object.prototype.hasOwnProperty.call(e,"ids")&&!0===Object.prototype.hasOwnProperty.call(e,"columnName"))throw new mt(Rt.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED,[`${t}`]);if(Object.prototype.hasOwnProperty.call(e,"columnName")){if(!Object.prototype.hasOwnProperty.call(e,"columnName")||!Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new mt(Rt.MISSING_RECORD_COLUMN_VALUE,[`${t}`])}else if(!1===Object.prototype.hasOwnProperty.call(e,"ids")&&!1===Object.prototype.hasOwnProperty.call(e,"columnValues"))throw new mt(Rt.MISSING_IDS_OR_COLUMN_VALUES_IN_GET,[`${t}`]);if(0===(null===(o=e.columnValues)||void 0===o?void 0:o.length))throw new mt(Rt.EMPTY_RECORD_COLUMN_VALUES,[`${t}`]);if(!(null==e.columnValues||e.columnValues&&Array.isArray(e.columnValues)))throw new mt(Rt.INVALID_COLUMN_VALUES_IN_GET,[`${t}`]);if(void 0!==e.columnName&&void 0===e.columnValues)throw new mt(Rt.MISSING_RECORD_COLUMN_VALUE,[`${t}`]);if(void 0===e.columnName&&void 0!==e.columnValues)throw new mt(Rt.MISSING_RECORD_COLUMN_NAME,[`${t}`]);const s=e.columnName;if(null!=s&&"string"!=typeof s)throw new mt(Rt.INVALID_RECORD_COLUMN_VALUE,[`${t}`]);const r=e.columnValues;if(null!=r){if(0===r.length||null===r)throw new mt(Rt.EMPTY_RECORD_COLUMN_VALUES,[`${t}`]);r.forEach((e=>{if(""===e||null===e)throw new mt(Rt.EMPTY_COLUMN_VALUE,[`${t}`]);if("string"!=typeof e)throw new mt(Rt.INVALID_RECORD_COLUMN_VALUE_TYPE,[`${t}`])}))}}))},gt=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Rt.RECORDS_KEY_NOT_FOUND_GETBYID);const{records:t}=e;if(!t||!Array.isArray(t))throw new mt(Rt.INVALID_RECORDS_IN_GETBYID,[]);if(0===t.length)throw new mt(Rt.EMPTY_RECORDS_GETBYID);t.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"ids"))throw new mt(Rt.MISSING_IDS_IN_GETBYID,[`${t}`]);if(!e.ids||!Array.isArray(e.ids))throw new mt(Rt.INVALID_IDS_IN_GETBYID,[`${t}`]);if(0===e.ids.length)throw new mt(Rt.EMPTY_IDS_IN_GETBYID,[`${t}`]);if(e.ids.forEach((e=>{if(!e)throw new mt(Rt.EMPTY_SKYFLOWID_IN_GETBYID,[`${t}`]);if(!("string"==typeof e||e instanceof String))throw new mt(Rt.INVALID_SKYFLOWID_TYPE_IN_GETBYID,[`${t}`])})),!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Rt.MISSING_TABLE_IN_GETBYID,[`${t}`]);if(!e.table)throw new mt(Rt.EMPTY_TABLE_IN_GETBYID,[`${t}`]);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Rt.INVALID_TABLE_IN_GETBYID,[`${t}`]);if(!Object.prototype.hasOwnProperty.call(e,"redaction"))throw new mt(Rt.MISSING_REDACTION_IN_GETBYID,[`${t}`]);if(!e.redaction)throw new mt(Rt.EMPTY_REDACTION_TYPE_IN_GETBYID,[`${t}`]);if(!Object.values(Et).includes(e.redaction))throw new mt(Rt.INVALID_REDACTION_TYPE_IN_GETBYID,[`${t}`])}))},bt=(e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new mt(Rt.RECORDS_KEY_NOT_FOUND_DELETE,[],!0);const{records:i}=e;if(!i||!Array.isArray(i))throw new mt(Rt.INVALID_RECORDS_IN_DELETE,[],!0);if(0===i.length)throw new mt(Rt.EMPTY_RECORDS_IN_DELETE,[],!0);i.forEach(((e,t)=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Rt.MISSING_TABLE_IN_DELETE,[`${t}`],!0);if(!e.table)throw new mt(Rt.EMPTY_TABLE_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.table||e.table instanceof String))throw new mt(Rt.INVALID_TABLE_IN_DELETE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"id"))throw new mt(Rt.MISSING_ID_IN_DELETE,[`${t}`],!0);if(!e.id)throw new mt(Rt.EMPTY_ID_IN_DELETE,[`${t}`],!0);if(!("string"==typeof e.id||e.id instanceof String))throw new mt(Rt.INVALID_ID_IN_DELETE,[`${t}`],!0)}))},wt=e=>{if(0===e.length)throw new mt(Rt.EMPTY_RECORDS_REVEAL);e.forEach((e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"token"))throw new mt(Rt.MISSING_TOKEN_KEY_REVEAL);if(!e.token)throw new mt(Rt.EMPTY_TOKEN_ID_REVEAL);if(!("string"==typeof e.token||e.token instanceof String))throw new mt(Rt.INVALID_TOKEN_ID_REVEAL);const t=e.redaction;if(t&&!Object.values(Et).includes(t))throw new mt(Rt.INVALID_REDACTION_TYPE_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"label")&&"string"!=typeof e.label)throw new mt(Rt.INVALID_LABEL_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"altText")&&"string"!=typeof e.altText)throw new mt(Rt.INVALID_ALT_TEXT_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new mt(Rt.INVALID_FORMAT_REVEAL);if(Object.prototype.hasOwnProperty.call(e,"format")&&""===e.format)throw new mt(Rt.EMPTY_FORMAT_REVEAL)}))},Mt=e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0},Pt=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},Ut=e=>{if(!Object.prototype.hasOwnProperty.call(e,"vaultID"))throw new mt(Rt.VAULTID_IS_REQUIRED,[],!0);if(!e.vaultID)throw new mt(Rt.EMPTY_VAULTID_IN_INIT,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"vaultURL"))throw new mt(Rt.VAULTURL_IS_REQUIRED,[],!0);if(!e.vaultURL)throw new mt(Rt.EMPTY_VAULTURL_IN_INIT,[],!0);if(e.vaultURL&&!Mt(e.vaultURL))throw new mt(Rt.INVALID_VAULTURL_IN_INIT,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new mt(Rt.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},Vt=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new mt(Rt.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new mt(Rt.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&Ot(le.COLLECT_ALT_TEXT_DEPERECATED,pt.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new mt(Rt.INVALID_SKYFLOWID_IN_COLLECT,[],!0);if(e.type===Fe.FILE_INPUT&&!Object.keys(e).includes("skyflowID"))throw new mt(Rt.MISSING_SKYFLOWID_IN_COLLECT,[],!0)},kt=e=>{if(!e||!Array.isArray(e))throw new mt(Rt.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new mt(Rt.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new mt(Rt.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new mt(Rt.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new mt(Rt.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new mt(Rt.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new mt(Rt.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Yt=e=>"boolean"==typeof e,xt=e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new mt(Rt.INVALID_INPUT_OPTIONS_FORMAT,[],!0);if(Object.prototype.hasOwnProperty.call(e,"translation")&&("object"!=typeof e.translation||"[object Object]"!==Object.prototype.toString.call(e.translation)))throw new mt(Rt.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}};function Ft(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const Gt=(e,t,i)=>{if("string"!=typeof e)return e;if(t===Fe.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=Ge.DEFAULT;return Object.entries(He).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==Ge.DEFAULT&&t===Ge.AMEX?6:8;return e.length>i?e.replace(new RegExp(`.(?=.{0,${(null==e?void 0:e.length)-i-1}}$)`,"g"),"X"):e}return e}return i?e:void 0};class Bt{constructor(e,t,i,n){this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new mt(Rt.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new mt(Rt.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}st(this.iframe,{src:at()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=rt({name:this.name})}}class jt{}var Xt,$t,Wt,Kt,zt,Ht,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,di;const ci="Element";class Ei extends jt{constructor(e,t,o,s,r=!1,a,l,d,c){var E;super(),this.type=eo.COLLECT,Xt.set(this,void 0),$t.set(this,!1),Wt.set(this,void 0),Kt.set(this,void 0),zt.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),Ht.set(this,void 0),qt.set(this,new it),Jt.set(this,void 0),Zt.set(this,new ct),Qt.set(this,void 0),ei.set(this,[]),ti.set(this,!1),ii.set(this,void 0),ni.set(this,void 0),oi.set(this,!1),this.getID=()=>i(this,Xt,"f"),this.mount=e=>{var t;if(!e)throw new mt(Rt.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,t)=>{if(e.name===i(this,Qt,"f").name){t(i(this,Ht,"f")),i(this,di,"f").call(this);const e=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(i[n[o]]=e[n[o]])}return i}(i(this,Wt,"f")[0],["name"]);i(this,Kt,"f").length>1?i(this,Kt,"f").forEach(((e,t)=>{i(this,Jt,"f")&&i(this,Jt,"f")._emit(`${fe.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,Wt,"f")[t]),{elementType:e.elementType}))})):i(this,qt,"f")._emit(fe.READY,Object.assign({},e)),i(this,Zt,"f").off(Ne+this.containerId,o),Ot(`${Lt(re.ELEMENT_MOUNTED,ci,At(i(this,Qt,"f").name))} `,pt.LOG,i(this,ii,"f").logLevel),i(this,ei,"f").forEach((e=>e())),n(this,ei,[],"f")}};if(i(this,Kt,"f").length>1)i(this,Qt,"f").mount(e),i(this,Zt,"f").on(Ne+this.containerId,o);else{if(i(this,oi,"f"))return i(this,Qt,"f").mount(e),void i(this,Zt,"f").on(Ne+this.containerId,o);null===(t=i(this,Jt,"f"))||void 0===t||t.on(Ye,(t=>{(null==t?void 0:t.containerId)===this.containerId&&(i(this,Qt,"f").mount(e),i(this,Zt,"f").on(Ne+this.containerId,o))}))}},this.unmount=()=>{i(this,Qt,"f").unmount()},this.update=e=>{let t=dt(e);const o=()=>{i(this,$t,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,Ht,Ii(i(this,Ht,"f"),t),"f"),n(this,Kt,hi(i(this,Ht,"f")),"f"),i(this,$t,"f")?i(this,Zt,"f").emit(Le,{name:i(this,Qt,"f").name,options:i(this,Kt,"f")[0],isSingleElementAPI:!0}):(i(this,Kt,"f").forEach((e=>{i(this,Zt,"f").emit(Le,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,Zt,"f").emit(Le,{name:i(this,Qt,"f").name,options:i(this,Ht,"f"),isSingleElementAPI:!1})),i(this,di,"f").call(this)};i(this,ti,"f")?o():i(this,ei,"f").push(o)},si.set(this,(e=>{i(this,$t,"f")||i(this,qt,"f").on(Le,(()=>{e(i(this,Kt,"f"))}),!0)})),this.updateElement=e=>{i(this,Zt,"f").emit(Le,{name:e.elementName,options:e,isSingleElementAPI:!0})},ri.set(this,(()=>{i(this,Wt,"f").forEach(((e,t)=>{if(0===t){i(this,zt,"f").isEmpty=e.isEmpty,i(this,zt,"f").isComplete=e.isComplete,i(this,zt,"f").isValid=e.isValid,i(this,zt,"f").isFocused=e.isFocused,i(this,zt,"f").isRequired=e.isRequired,i(this,zt,"f").value={};const n=i(this,Kt,"f")[t].elementName,o=e.value&&Gt(e.value,e.elementType,i(this,ni,"f"));i(this,$t,"f")?i(this,zt,"f").value=o:i(this,zt,"f").value[n]=o}else i(this,zt,"f").isEmpty=i(this,zt,"f").isEmpty||e.isEmpty,i(this,zt,"f").isComplete=i(this,zt,"f").isComplete&&e.isComplete,i(this,zt,"f").isValid=i(this,zt,"f").isValid&&e.isValid,i(this,zt,"f").isFocused=i(this,zt,"f").isFocused||e.isFocused,i(this,zt,"f").isRequired=i(this,zt,"f").isRequired||e.isRequired,i(this,zt,"f").value||(i(this,zt,"f").value={}),i(this,Kt,"f")[t].sensitive||(i(this,zt,"f").value[i(this,Kt,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,zt,"f").isEmpty,isComplete:i(this,zt,"f").isComplete,isValid:i(this,zt,"f").isValid,isFocused:i(this,zt,"f").isFocused,value:i(this,zt,"f").value,required:i(this,zt,"f").isRequired}),this.getOptions=()=>{let e=dt(i(this,Ht,"f"));return i(this,$t,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},ai.set(this,(e=>{i(this,qt,"f").on(Oe,(()=>{const t=i(this,Kt,"f").map((e=>e.elementName));i(this,$t,"f")||t.push(i(this,Qt,"f").name),e(t)}),!0)})),li.set(this,(()=>{i(this,Zt,"f").on(ve,(e=>{if(i(this,$t,"f")&&e.event===fe.READY&&e.name===i(this,Qt,"f").name)i(this,qt,"f")._emit(fe.READY);else{const t=i(this,Kt,"f").length>1;i(this,Kt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case fe.FOCUS:r=fe.FOCUS;break;case fe.BLUR:r=fe.BLUR;break;case fe.CHANGE:r=fe.CHANGE;break;case fe.READY:r=fe.READY;break;case fe.SUBMIT:return void(null===(s=i(this,Jt,"f"))||void 0===s||s._emit(fe.SUBMIT));default:throw new mt(Rt.INVALID_EVENT_TYPE,[],!0)}i(this,Wt,"f")[o].isEmpty=e.value.isEmpty,i(this,Wt,"f")[o].isValid=e.value.isValid,i(this,Wt,"f")[o].isComplete=e.value.isComplete,i(this,Wt,"f")[o].isFocused=e.value.isFocused,i(this,Wt,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,Wt,"f")[o].value=e.value.value:i(this,Wt,"f")[o].value=void 0,r=t?`${r}:${e.name}`:r,i(this,ri,"f").call(this);const a=Object.assign(Object.assign({},i(this,Wt,"f")[o]),{elementType:n.elementType});t&&i(this,Jt,"f")?i(this,Jt,"f")._emit(r,a):i(this,qt,"f")._emit(r,a)}}))}}))})),di.set(this,(()=>{const{rows:e}=i(this,Ht,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==je.radio.name&&e.elementType!==je.checkbox.name&&(e.value=void 0)}))})),n(this,Kt,hi(i(this,Ht,"f")),"f")})),this.containerId=s.containerId,n(this,Xt,e,"f"),n(this,ii,d,"f"),n(this,Ht,Ii(t),"f"),n(this,Kt,hi(t),"f"),n(this,$t,r,"f"),c&&n(this,Jt,c,"f"),n(this,ni,Tt[i(this,ii,"f").env].doesReturnValue,"f"),this.elementType=i(this,$t,"f")?i(this,Kt,"f")[0].elementType:"group",n(this,Wt,[],"f"),i(this,Kt,"f").forEach((e=>{i(this,Wt,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,ni,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,Qt,new Bt(i(this,Ht,"f").elementName,o,this.containerId,i(this,ii,"f").logLevel),"f"),i(this,li,"f").call(this),i(this,ai,"f").call(this,a),i(this,si,"f").call(this,l),Ot(Lt(re.CREATED_ELEMENT,ci,At(i(this,Qt,"f").name)),pt.LOG,i(this,ii,"f").logLevel),n(this,oi,s.isMounted,"f"),null===(E=i(this,Jt,"f"))||void 0===E||E.on(Ye,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,oi,!0,"f")})),i(this,Zt,"f").on(fe.MOUNTED,(e=>{s.type===eo.COMPOSABLE?i(this,Kt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,ti,!0,"f"))})):e.name===i(this,Kt,"f")[0].elementName&&(i(this,Kt,"f")[0].isMounted=!0,n(this,ti,!0,"f"))}))}on(e,t){if(!Object.values(fe).includes(e))throw new mt(Rt.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new mt(Rt.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new mt(Rt.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,qt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,Qt,"f").name}isMounted(){return i(this,ti,"f")}isValidElement(){for(let e=0;e<i(this,Kt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,Kt,"f")[e],"table"))throw new mt(Rt.MISSING_TABLE_IN_COLLECT,[],!0);if(!i(this,Kt,"f")[e].table)throw new mt(Rt.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof i(this,Kt,"f")[e].table||i(this,Kt,"f")[e].table instanceof String))throw new mt(Rt.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(i(this,Kt,"f")[e],"column"))throw new mt(Rt.MISSING_COLUMN_IN_COLLECT,[],!0);if(!i(this,Kt,"f")[e].column)throw new mt(Rt.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof i(this,Kt,"f")[e].column||i(this,Kt,"f")[e].column instanceof String))throw new mt(Rt.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==i(this,Kt,"f")[e].skyflowID&&!i(this,Kt,"f")[e].skyflowID)throw new mt(Rt.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){i(this,Zt,"f").emit(Se,{name:Ft(i(this,Qt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,Zt,"f").emit(Se,{name:Ft(i(this,Qt,"f").name),isTriggerError:!1})}setValue(e){i(this,ii,"f").env!==ut.PROD?i(this,$t,"f")&&i(this,Zt,"f").emit(Le,{name:i(this,Qt,"f").name,options:Object.assign(Object.assign({},i(this,Kt,"f")[0]),{value:e}),isSingleElementAPI:!0}):Ot(Lt(le.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,Kt,"f")[0].elementType),pt.WARN,i(this,ii,"f").logLevel)}clearValue(){i(this,ii,"f").env!==ut.PROD?i(this,$t,"f")&&i(this,Zt,"f").emit(Le,{name:i(this,Qt,"f").name,options:Object.assign(Object.assign({},i(this,Kt,"f")[0]),{value:""}),isSingleElementAPI:!0}):Ot(Lt(le.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,Kt,"f")[0].elementType),pt.WARN,i(this,ii,"f").logLevel)}}function _i(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(je,e))throw new mt(Rt.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new mt(Rt.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new mt(Rt.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(ft).includes(e.type))throw new mt(Rt.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new mt(Rt.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new mt(Rt.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===ft.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new mt(Rt.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===ft.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new mt(Rt.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE,[`${t}`],!0)}))}if(Object.prototype.hasOwnProperty.call(i,"name")&&i.name!==t.name)throw new Error("Name attribute can't be updated");if((i=Object.assign(Object.assign({},t),i)).mask||i.replacePattern){const{type:t}=je[e].attributes;"text"===t&&"textarea"===t&&"email"===t||(delete i.mask,delete i.replacePattern)}if(void 0===!i.mask&&!Array.isArray(i.mask))throw new Error("mask option has to be array or undefined");if(Array.isArray(i.mask)){const e=i.mask;if("string"!=typeof e[0]||e[1]&&"object"!=typeof e[1])throw new Error("mask array values has to be string")}if(Array.isArray(i.replacePattern)){const e=i.replacePattern;if("string"!=typeof e[0]||e[1]&&"string"!=typeof e[1])throw new Error("replacePatterns array values has to be string")}if((e===je.radio.name||e===je.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==je.dropdown.name||i.options&&Array.isArray(i.options)&&0!==i.options.length))throw new Error("Element dropdown requires options attribute with an array of objects containing value and text attributes")}function Ii(e,t={},i=!0){return(t=Object.assign(Object.assign({},e),t)).rows.forEach(((n,o)=>{const s=n,r=e.rows[o];t.rows[o]=Object.assign(Object.assign({},r),s),s.elements.forEach(((e,t)=>{var n,o;const a=r.elements[t],l=e;if(l.elementType&&a.elementType!==l.elementType&&a.elementName&&a.elementName!==l.elementName)throw new Error(ae.CANNOT_CHANGE_ELEMENT);_i(a.elementType,a,l),s.elements[t]=Object.assign(Object.assign(Object.assign({},a),l),{elementName:a.elementName});const d=l.classes||{},c=l.styles||{};c.base=Object.assign(Object.assign({},Ke),c.base),l.classes=d,l.styles=c;const E=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},_=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ze).forEach((i=>{if(e[i]||t[i])switch(i){case ze.BASE:t[i]=Object.assign({},t[i]);break;case ze.FOCUS:t[ze.BASE]=Object.assign(Object.assign({},t[ze.BASE]),{":focus":Object.assign({},t[ze.BASE]&&t[ze.BASE][":focus"])});break;case ze.WEBPACKAUTOFILL:t[ze.BASE]=Object.assign(Object.assign({},t[ze.BASE]),{":-webkit-autofill":Object.assign({},t[ze.BASE]&&t[ze.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ze.BASE]),t[i])}})),Object.keys(t).forEach((e=>{const i=t[e][":-webkit-autofill"];"object"==typeof i&&Object.keys(i).forEach((e=>{i[e]&&!i[e].includes("!important")&&(i[e]=`${i[e]} !important`)}))}))}(E,_),l.labelStyles={labelClasses:E},l.labelStyles.styles=_}))})),t}Xt=new WeakMap,$t=new WeakMap,Wt=new WeakMap,Kt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,ei=new WeakMap,ti=new WeakMap,ii=new WeakMap,ni=new WeakMap,oi=new WeakMap,si=new WeakMap,ri=new WeakMap,ai=new WeakMap,li=new WeakMap,di=new WeakMap;const hi=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},ui=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===ft.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new mt(Rt.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof Ei)))throw new mt(Rt.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof Ei&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===ft.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Pt(e.params.regex))throw new mt(Rt.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Pt(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},pi=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(et.includes(e)?(Ot(Lt(le.INPUT_FORMATTING_NOT_SUPPROTED,e),pt.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===je.INPUT_FIELD.name&&(xt(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:tt]}),null==n||delete n.format,null==n||delete n.translation)),e===je.CARD_NUMBER.name){Object.prototype.hasOwnProperty.call(n,"enableCardIcon")||(n=Object.assign(Object.assign({},n),{enableCardIcon:!0}));let e=" ";(null==n?void 0:n.format)===Xe&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===je.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&Je.includes(o),e||Ot(Lt(le.INVALID_EXPIRATION_DATE_FORMAT,Je.toString()),pt.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():qe}),null==n||delete n.translation}else if(e===je.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&Ze.includes(e))(n.format.toUpperCase()),e||Ot(Lt(le.INVALID_EXPIRATION_YEAR_FORMAT,Ze.toString()),pt.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():"YY"}),null==n||delete n.translation}var o;if(Object.prototype.hasOwnProperty.call(n,"enableCardIcon")&&!Yt(n.enableCardIcon))throw new mt(Rt.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Yt(n.enableCopy))throw new mt(Rt.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Yt(n.required))throw new mt(Rt.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function fi(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=crypto.getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*16|0;return("x"===e?t:3&t|8).toString(16)}))}class Ni{}var Ti,vi,Oi,Li,Ai,mi,Ri,yi,Di,Si,Ci,gi;const bi="CollectContainer";class wi extends Ni{constructor(e,t,o,s){super(),Ti.set(this,void 0),vi.set(this,{}),Oi.set(this,void 0),Li.set(this,void 0),Ai.set(this,void 0),this.type=eo.COLLECT,mi.set(this,void 0),Ri.set(this,!1),this.create=(e,t={required:!1})=>{Vt(e,i(this,Li,"f").logLevel);const n=ui(e),o=pi(e.type,t,i(this,Li,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n})]}]};return i(this,yi,"f").call(this,s,!0)},yi.set(this,((e,t=!1)=>{const n=[],o=dt(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;_i(i,t),t.sensitive=t.sensitive||je[i].sensitive,t.replacePattern=t.replacePattern||je[i].replacePattern,t.mask=t.mask||je[i].mask,t.isMounted=!1,t.elementType!==je.radio.name&&t.elementType!==je.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${Ee}:${t.elementType}:${btoa(fi())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=t?n[0].elementName:`${Ee}:group:${btoa(o.name)}`,t&&!i(this,vi,"f")[n[0].elementName]&&i(this,gi,"f").call(this,n[0].name))throw new mt(Rt.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=i(this,vi,"f")[o.elementName];if(s)t?s.update(n[0]):s.update(o);else{const e=fi();s=new Ei(e,o,i(this,Oi,"f"),{containerId:i(this,Ti,"f"),isMounted:i(this,Ri,"f"),type:this.type},t,i(this,Si,"f"),i(this,Ci,"f"),i(this,Li,"f"),i(this,mi,"f")),i(this,vi,"f")[o.elementName]=s,i(this,Ai,"f")[e]=s}return t||n.forEach((e=>{const t=e.elementName;i(this,vi,"f")[t]?i(this,vi,"f")[t].update(e):i(this,vi,"f")[t]=this.create(e.elementType,s)})),s})),Di.set(this,(e=>{Object.keys(i(this,vi,"f")).forEach((t=>{t===e&&delete i(this,vi,"f")[t]}))})),Si.set(this,(e=>{e.forEach((e=>{i(this,Di,"f").call(this,e)}))})),Ci.set(this,(e=>{e.forEach((e=>{i(this,vi,"f")[e.elementName]&&i(this,vi,"f")[e.elementName].update(e)}))})),gi.set(this,(e=>{const t=Object.keys(i(this,vi,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1})),this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{Ut(i(this,Oi,"f").clientJSON.config);if(Object.values(i(this,vi,"f")).forEach((e=>{if(!e.isMounted())throw new mt(Rt.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Yt(e.tokens))throw new mt(Rt.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Dt(e.additionalFields),(null==e?void 0:e.upsert)&&kt(null==e?void 0:e.upsert),se.emit(Te+i(this,Ti,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(Ot(`${JSON.stringify(null==e?void 0:e.error)}`,pt.ERROR,i(this,Li,"f").logLevel),n(null==e?void 0:e.error)):(Ot(Lt(re.COLLECT_SUBMIT_SUCCESS,bi),pt.LOG,i(this,Li,"f").logLevel),t(e))})),Ot(Lt(re.EMIT_EVENT,bi,Te),pt.LOG,i(this,Li,"f").logLevel)}catch(e){Ot(`${e.message}`,pt.ERROR,i(this,Li,"f").logLevel),n(e)}})),this.uploadFiles=e=>new Promise(((t,n)=>{try{Ut(i(this,Oi,"f").clientJSON.config);Object.values(i(this,vi,"f")).forEach((e=>{if(!e.isMounted())throw new mt(Rt.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),se.emit(be+i(this,Ti,"f"),Object.assign({},e),(e=>{!e||(null==e?void 0:e.error)?(Ot(`${JSON.stringify(null==e?void 0:e.error)}`,pt.ERROR,i(this,Li,"f").logLevel),n(null==e?void 0:e.error)):(Ot(Lt(re.COLLECT_SUBMIT_SUCCESS,bi),pt.LOG,i(this,Li,"f").logLevel),t(e))})),Ot(Lt(re.EMIT_EVENT,bi,be),pt.LOG,i(this,Li,"f").logLevel)}catch(e){Ot(`${e.message}`,pt.ERROR,i(this,Li,"f").logLevel),n(e)}})),n(this,Ti,fi(),"f"),n(this,Oi,t,"f"),n(this,Ai,o,"f"),n(this,Li,s,"f"),n(this,mi,new it,"f");const r=rt({name:`${de}:${i(this,Ti,"f")}:${i(this,Li,"f").logLevel}`});st(r,{src:at()}),lt(r,Object.assign({},We)),Ot(Lt(re.CREATE_COLLECT_CONTAINER,bi),pt.LOG,i(this,Li,"f").logLevel);const a=(e,o)=>{e.name===de+i(this,Ti,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,Ri,!0,"f"),i(this,mi,"f")._emit(Ye,{containerId:i(this,Ti,"f")}),se.target(nt.IFRAME_SECURE_ORGIN).off(Ne+i(this,Ti,"f"),a))};se.target(nt.IFRAME_SECURE_ORGIN).on(Ne+i(this,Ti,"f"),a),document.body.append(r)}}Ti=new WeakMap,vi=new WeakMap,Oi=new WeakMap,Li=new WeakMap,Ai=new WeakMap,mi=new WeakMap,Ri=new WeakMap,yi=new WeakMap,Di=new WeakMap,Si=new WeakMap,Ci=new WeakMap,gi=new WeakMap;var Mi=function(e,t){for(var i,n=-1,o=e.length;++n<o;){var s=t(e[n]);void 0!==s&&(i=void 0===i?s:i+s)}return i},Pi=function(e){return e};var Ui,Vi,ki,Yi,xi,Fi,Gi,Bi,ji,Xi,$i,Wi,Ki,zi,Hi,qi,Ji,Zi,Qi,en,tn,nn,on,sn=R((function(e){return e&&e.length?Mi(e,Pi):0}));class rn{constructor(e,t){Ui.set(this,void 0),Vi.set(this,void 0),this.type=eo.COMPOSABLE,ki.set(this,!1),Yi.set(this,!1),this.update=e=>{n(this,Yi,!0,"f"),i(this,ki,"f")?(i(this,Vi,"f")._emit(we,{elementName:i(this,Ui,"f"),elementOptions:e}),n(this,Yi,!1,"f")):i(this,Yi,"f")&&i(this,Vi,"f").on(`${It.READY}:${i(this,Ui,"f")}`,(()=>{i(this,Vi,"f")._emit(we,{elementName:i(this,Ui,"f"),elementOptions:e}),n(this,ki,!0,"f"),n(this,Yi,!1,"f")}))},n(this,Ui,e,"f"),n(this,Vi,t,"f"),i(this,Vi,"f").on(`${It.READY}:${i(this,Ui,"f")}`,(()=>{n(this,ki,!0,"f")}))}on(e,t){if(!Object.values(fe).includes(e))throw new mt(Rt.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new mt(Rt.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new mt(Rt.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Vi,"f").on(`${e}:${i(this,Ui,"f")}`,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}}Ui=new WeakMap,Vi=new WeakMap,ki=new WeakMap,Yi=new WeakMap;const an="CollectContainer";class ln extends Ni{constructor(e,t,o,s){super(),xi.set(this,void 0),Fi.set(this,{}),Gi.set(this,void 0),Bi.set(this,{rows:[]}),ji.set(this,[]),Xi.set(this,void 0),$i.set(this,void 0),Wi.set(this,void 0),Ki.set(this,!1),zi.set(this,void 0),Hi.set(this,void 0),this.type=eo.COMPOSABLE,qi.set(this,!1),Ji.set(this,{}),this.create=(e,t={required:!1})=>{Vt(e,i(this,Xi,"f").logLevel);const n=ui(e),o=pi(e.type,t,i(this,Xi,"f").logLevel),s=`${Ee}:${e.type}:${btoa(fi())}`;return i(this,ji,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new rn(s,i(this,Wi,"f"))},Zi.set(this,((e,t=!1)=>{const o=[];if(n(this,Ji,dt(e),"f"),i(this,Ji,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;_i(i,t),t.sensitive=t.sensitive||je[i].sensitive,t.replacePattern=t.replacePattern||je[i].replacePattern,t.mask=t.mask||je[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),i(this,Ji,"f").elementName=t?o[0].elementName:`${Ee}:group:${btoa(i(this,Ji,"f").name)}`,t&&!i(this,Fi,"f")[o[0].elementName]&&i(this,nn,"f").call(this,o[0].name))throw new mt(Rt.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=i(this,Fi,"f")[i(this,Ji,"f").elementName];if(s)t?s.update(o[0]):s.update(i(this,Ji,"f"));else{const e=fi();s=new Ei(e,i(this,Ji,"f"),i(this,Gi,"f"),{containerId:i(this,xi,"f"),isMounted:i(this,qi,"f"),type:this.type},!0,i(this,en,"f"),i(this,tn,"f"),i(this,Xi,"f"),i(this,Wi,"f")),i(this,Fi,"f")[i(this,Ji,"f").elementName]=s,i(this,$i,"f")[e]=s}return s})),Qi.set(this,(e=>{Object.keys(i(this,Fi,"f")).forEach((t=>{t===e&&delete i(this,Fi,"f")[t]}))})),en.set(this,(e=>{e.forEach((e=>{i(this,Qi,"f").call(this,e)}))})),tn.set(this,(e=>{e.forEach((e=>{i(this,Fi,"f")[e.elementName]&&i(this,Fi,"f")[e.elementName].update(e)}))})),nn.set(this,(e=>{const t=Object.keys(i(this,Fi,"f"));for(let i=0;i<t.length;i+=1)if(atob(t[i].split(":")[2])===e)return!0;return!1})),this.on=(e,t)=>{if(!Object.values(fe).includes(e))throw new mt(Rt.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new mt(Rt.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new mt(Rt.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Wi,"f").on(fe.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new mt(Rt.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:t}=i(this,zi,"f");if(sn(t)!==i(this,ji,"f").length)throw new mt(Rt.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(t.forEach(((e,t)=>{i(this,Bi,"f").rows=[...i(this,Bi,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,Bi,"f").rows[t].elements.push(i(this,ji,"f")[o]),o++})),i(this,zi,"f").styles&&(i(this,Bi,"f").styles=Object.assign({},i(this,zi,"f").styles)),i(this,zi,"f").errorTextStyles&&(i(this,Bi,"f").errorTextStyles=Object.assign({},i(this,zi,"f").errorTextStyles)),i(this,qi,"f"))return n(this,Hi,i(this,Zi,"f").call(this,i(this,Bi,"f"),!1),"f"),i(this,Hi,"f").mount(e),void n(this,Ki,!0,"f");i(this,Wi,"f").on(ke+i(this,xi,"f"),(()=>{n(this,Hi,i(this,Zi,"f").call(this,i(this,Bi,"f"),!1),"f"),i(this,Hi,"f").mount(e),n(this,Ki,!0,"f")}))},this.unmount=()=>{i(this,Hi,"f").unmount()},this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(Ut(i(this,Gi,"f").clientJSON.config),!i(this,Ki,"f"))throw new mt(Rt.COMPOSABLE_CONTAINER_NOT_MOUNTED,[],!0);hi(i(this,Ji,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new mt(Rt.ELEMENTS_NOT_MOUNTED,[],!0)}));if(Object.values(i(this,Fi,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new mt(Rt.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&Dt(e.additionalFields),(null==e?void 0:e.upsert)&&kt(null==e?void 0:e.upsert),se.emit(Te+i(this,xi,"f"),Object.assign(Object.assign({},e),{tokens:void 0===(null==e?void 0:e.tokens)||e.tokens}),(e=>{!e||(null==e?void 0:e.error)?(Ot(`${JSON.stringify(null==e?void 0:e.error)}`,pt.ERROR,i(this,Xi,"f").logLevel),n(null==e?void 0:e.error)):(Ot(Lt(re.COLLECT_SUBMIT_SUCCESS,an),pt.LOG,i(this,Xi,"f").logLevel),t(e))})),Ot(Lt(re.EMIT_EVENT,an,Te),pt.LOG,i(this,Xi,"f").logLevel)}catch(e){Ot(`${e.message}`,pt.ERROR,i(this,Xi,"f").logLevel),n(e)}})),on.set(this,(()=>{i(this,Wi,"f").on(we,(e=>{let t;const n=i(this,ji,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,Hi,"f")&&i(this,Hi,"f").updateElement(Object.assign({},n[t]))}))})),n(this,xi,fi(),"f"),n(this,Gi,t,"f"),n(this,$i,o,"f"),n(this,Xi,s,"f"),n(this,zi,e,"f"),n(this,Wi,new it,"f");const r=rt({name:`${de}:${i(this,xi,"f")}:${i(this,Xi,"f").logLevel}`});st(r,{src:at()}),lt(r,Object.assign({},We)),Ot(Lt(re.CREATE_COLLECT_CONTAINER,an),pt.LOG,i(this,Xi,"f").logLevel);const a=(e,o)=>{e.name===de+i(this,xi,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,qi,!0,"f"),i(this,Wi,"f")._emit(ke+i(this,xi,"f"),{containerId:i(this,xi,"f")}),se.target(nt.IFRAME_SECURE_ORGIN).off(Ne+i(this,xi,"f"),a))};se.target(nt.IFRAME_SECURE_ORGIN).on(Ne+i(this,xi,"f"),a),document.body.append(r),i(this,on,"f").call(this)}}var dn,cn,En,_n,In,hn,un,pn,fn,Nn;xi=new WeakMap,Fi=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,ji=new WeakMap,Xi=new WeakMap,$i=new WeakMap,Wi=new WeakMap,Ki=new WeakMap,zi=new WeakMap,Hi=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,en=new WeakMap,tn=new WeakMap,nn=new WeakMap,on=new WeakMap;class Tn extends jt{constructor(e,t={},o,s,r,a){super(),dn.set(this,void 0),cn.set(this,void 0),En.set(this,void 0),_n.set(this,void 0),In.set(this,!1),hn.set(this,!1),un.set(this,void 0),pn.set(this,void 0),fn.set(this,!1),Nn.set(this,void 0),n(this,pn,r,"f"),n(this,cn,o,"f"),n(this,En,Object.assign(Object.assign({},e),(e=>{let t={};if(e){if(t=Object.assign({},e),Object.prototype.hasOwnProperty.call(t,"enableCopy")&&!Yt(t.enableCopy))throw new mt(Rt.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(t,"format")||Object.prototype.hasOwnProperty.call(t,"translation")){const e=[];t.format&&e.push(t.format),e.push(null),t.translation?e.push(t.translation):t.format&&e.push(tt),t=Object.assign(Object.assign({},t),3===e.length?{mask:e}:{}),null==t||delete t.format,null==t||delete t.translation}}return t})(t)),"f"),n(this,_n,s.containerId,"f"),n(this,fn,s.isMounted,"f"),n(this,Nn,s.eventEmitter,"f"),n(this,un,a,"f"),n(this,dn,new Bt(`reveal:${btoa(fi())}`,{metaData:o},i(this,_n,"f"),i(this,un,"f").logLevel),"f"),i(this,fn,"f")||i(this,Nn,"f").on(xe,(e=>{(null==e?void 0:e.containerId)===i(this,_n,"f")&&n(this,fn,!0,"f")})),Ot(Lt(re.CREATED_ELEMENT,"RevealElement",`${e.token||""} reveal `),pt.LOG,i(this,un,"f").logLevel)}getID(){return i(this,pn,"f")}mount(e){var t;if(!e)throw new mt(Rt.EMPTY_ELEMENT_IN_MOUNT,["RevealElement"],!0);const o=(e,t)=>{e.name===i(this,dn,"f").name&&(t(Object.assign(Object.assign({},i(this,cn,"f")),{record:i(this,En,"f"),context:i(this,un,"f")})),se.off(me,o),se.emit(Ue+i(this,_n,"f"),{id:i(this,En,"f").token,containerId:i(this,_n,"f")}),n(this,In,!0,"f"))};if(i(this,fn,"f"))return i(this,dn,"f").mount(e),void se.target(nt.IFRAME_SECURE_ORGIN).on(me,o);null===(t=i(this,Nn,"f"))||void 0===t||t.on(xe,(t=>{(null==t?void 0:t.containerId)===i(this,_n,"f")&&(i(this,dn,"f").mount(e),se.target(nt.IFRAME_SECURE_ORGIN).on(me,o))}))}iframeName(){return i(this,dn,"f").name}isMounted(){return i(this,In,"f")}hasToken(){return!!i(this,En,"f").token}isClientSetError(){return i(this,hn,"f")}getRecordData(){return i(this,En,"f")}setError(e){se.emit(Ce,{name:i(this,dn,"f").name,isTriggerError:!0,clientErrorText:e}),n(this,hn,!0,"f")}resetError(){se.emit(Ce,{name:i(this,dn,"f").name,isTriggerError:!1}),n(this,hn,!1,"f")}setAltText(e){se.emit(ge,{name:i(this,dn,"f").name,updateType:Pe,updatedValue:e})}clearAltText(){se.emit(ge,{name:i(this,dn,"f").name,updateType:Pe,updatedValue:null})}setToken(e){n(this,En,Object.assign(Object.assign({},i(this,En,"f")),{token:e}),"f"),se.emit(ge,{name:i(this,dn,"f").name,updateType:Me,updatedValue:e})}unmount(){i(this,dn,"f").unmount()}}var vn,On,Ln,An,mn,Rn,yn,Dn,Sn,Cn,gn;dn=new WeakMap,cn=new WeakMap,En=new WeakMap,_n=new WeakMap,In=new WeakMap,hn=new WeakMap,un=new WeakMap,pn=new WeakMap,fn=new WeakMap,Nn=new WeakMap;const bn="RevealContainer";class wn extends Ni{constructor(e,t,o){super(),vn.set(this,[]),On.set(this,[]),Ln.set(this,[]),An.set(this,void 0),mn.set(this,void 0),Rn.set(this,void 0),yn.set(this,!1),Dn.set(this,!1),Sn.set(this,void 0),Cn.set(this,void 0),gn.set(this,void 0),this.type=eo.REVEAL,n(this,An,e,"f"),n(this,Cn,t,"f"),n(this,mn,fi(),"f"),n(this,Rn,new it,"f"),n(this,Sn,o,"f");const s=rt({name:`${ce}:${i(this,mn,"f")}`});st(s,{src:at()}),lt(s,Object.assign({},We)),Ot(Lt(re.CREATE_REVEAL_CONTAINER,bn),pt.LOG,i(this,Sn,"f").logLevel);const r=(t,s)=>{t.name===ce&&(s(Object.assign(Object.assign({},e),{clientJSON:Object.assign(Object.assign({},e.clientJSON),{config:Object.assign({},e.clientJSON.config),context:o})})),n(this,gn,!0,"f"),i(this,Rn,"f")._emit(xe,{containerId:i(this,mn,"f")}),se.target(nt.IFRAME_SECURE_ORGIN).off(me+i(this,mn,"f"),r))};se.target(nt.IFRAME_SECURE_ORGIN).on(me+i(this,mn,"f"),r),document.body.append(s),se.target(window.location.origin).on(Ue+i(this,mn,"f"),(e=>{i(this,Ln,"f").push(e),n(this,Dn,i(this,Ln,"f").length===i(this,On,"f").length,"f"),i(this,yn,"f")&&i(this,Dn,"f")&&i(this,Rn,"f")._emit(Ve+i(this,mn,"f"),{containerId:i(this,mn,"f")})}))}create(e,t){const n=fi();xt(t);const o=new Tn(e,t,i(this,An,"f"),{containerId:i(this,mn,"f"),isMounted:i(this,gn,"f"),eventEmitter:i(this,Rn,"f")},n,i(this,Sn,"f"));return i(this,On,"f").push(o),i(this,Cn,"f")[n]=o,o}reveal(){return n(this,yn,!0,"f"),i(this,Dn,"f")?new Promise(((e,t)=>{try{Ut(i(this,An,"f").clientJSON.config),Ot(Lt(re.VALIDATE_REVEAL_RECORDS,bn),pt.LOG,i(this,Sn,"f").logLevel),i(this,On,"f").forEach((e=>{if(e.isClientSetError())throw new mt(Rt.REVEAL_ELEMENT_ERROR_STATE);i(this,vn,"f").push(e.getRecordData())})),wt(i(this,vn,"f")),se.emit(Ae+i(this,mn,"f"),{records:i(this,vn,"f")},(o=>{n(this,Ln,[],"f"),n(this,vn,[],"f"),o.error?(Ot(ae.FAILED_REVEAL,pt.ERROR,i(this,Sn,"f").logLevel),t(o.error)):(Ot(Lt(re.REVEAL_SUBMIT_SUCCESS,bn),pt.LOG,i(this,Sn,"f").logLevel),e(o))})),Ot(Lt(re.EMIT_EVENT,bn,Ae),pt.LOG,i(this,Sn,"f").logLevel)}catch(e){Ot(`Error: ${e.message}`,pt.ERROR,i(this,Sn,"f").logLevel),t(e)}})):new Promise(((e,t)=>{try{Ut(i(this,An,"f").clientJSON.config),Ot(Lt(re.VALIDATE_REVEAL_RECORDS,bn),pt.LOG,i(this,Sn,"f").logLevel);const o=setTimeout((()=>{Ot(ae.ELEMENTS_NOT_MOUNTED_REVEAL,pt.ERROR,i(this,Sn,"f").logLevel),t(ae.ELEMENTS_NOT_MOUNTED_REVEAL)}),3e4);i(this,On,"f").forEach((e=>{if(e.isClientSetError())throw clearTimeout(o),new mt(Rt.REVEAL_ELEMENT_ERROR_STATE);i(this,vn,"f").push(e.getRecordData())})),wt(i(this,vn,"f")),i(this,Rn,"f").on(Ve+i(this,mn,"f"),(()=>{clearTimeout(o),se.emit(Ae+i(this,mn,"f"),{records:i(this,vn,"f")},(o=>{n(this,vn,[],"f"),n(this,Ln,[],"f"),o.error?(Ot(ae.FAILED_REVEAL,pt.ERROR,i(this,Sn,"f").logLevel),t(o.error)):(Ot(Lt(re.REVEAL_SUBMIT_SUCCESS,bn),pt.LOG,i(this,Sn,"f").logLevel),e(o))}))}))}catch(e){Ot(e.message,pt.ERROR,i(this,Sn,"f").logLevel),t(e)}}))}}var Mn,Pn,Un,Vn;vn=new WeakMap,On=new WeakMap,Ln=new WeakMap,An=new WeakMap,mn=new WeakMap,Rn=new WeakMap,yn=new WeakMap,Dn=new WeakMap,Sn=new WeakMap,Cn=new WeakMap,gn=new WeakMap;const kn="SkyflowContainer";class Yn{constructor(e,t){var o,s;Mn.set(this,void 0),Pn.set(this,void 0),Un.set(this,!1),Vn.set(this,void 0),n(this,Pn,e,"f"),n(this,Mn,(null===(s=null===(o=i(this,Pn,"f").toJSON())||void 0===o?void 0:o.metaData)||void 0===s?void 0:s.uuid)||"","f"),n(this,Vn,t,"f");const r=rt({name:`skyflow_controller:${i(this,Mn,"f")}`});st(r,{src:at()}),lt(r,Object.assign({},We)),document.body.append(r),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+i(this,Mn,"f"),((e,o)=>{Ot(Lt(re.CAPTURE_PUREJS_FRAME,kn),pt.LOG,i(this,Vn,"f").logLevel),o({client:i(this,Pn,"f"),context:t}),n(this,Un,!0,"f")})),Ot(Lt(re.PUREJS_CONTROLLER_INITIALIZED,kn),pt.LOG,i(this,Vn,"f").logLevel)}detokenize(e){return i(this,Un,"f")?new Promise(((t,n)=>{try{Ut(i(this,Pn,"f").config),Ot(Lt(re.VALIDATE_DETOKENIZE_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),St(e),se.emit(Re+i(this,Mn,"f"),{type:Ie,records:e.records},(e=>{e.error?n(e.error):t(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,Ie),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),n(e)}})):new Promise(((t,n)=>{try{Ut(i(this,Pn,"f").config),Ot(Lt(re.VALIDATE_DETOKENIZE_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),St(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+i(this,Mn,"f"),(()=>{se.emit(Re+i(this,Mn,"f"),{type:Ie,records:e.records},(e=>{e.error?n(e.error):t(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,Ie),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),n(e)}}))}insert(e,t){return i(this,Un,"f")?new Promise(((n,o)=>{Ut(i(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_RECORDS,kn),pt.LOG,i(this,Vn,"f").logLevel),(null==(t=t?Object.assign(Object.assign({},t),{tokens:void 0===(null==t?void 0:t.tokens)||t.tokens}):{tokens:!0})?void 0:t.upsert)&&kt(t.upsert),yt(e,t),se.emit(Re+i(this,Mn,"f"),{type:_e,records:e,options:t},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,i(this,Vn,"f").logLevel),o(e.error)):n(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,_e),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ut(i(this,Pn,"f").config),Ot(Lt(re.VALIDATE_RECORDS,kn),pt.LOG,i(this,Vn,"f").logLevel),(null==(t=t?Object.assign(Object.assign({},t),{tokens:void 0===(null==t?void 0:t.tokens)||t.tokens}):{tokens:!0})?void 0:t.upsert)&&kt(t.upsert),yt(e,t),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+i(this,Mn,"f"),(()=>{se.emit(Re+i(this,Mn,"f"),{type:_e,records:e,options:t},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,i(this,Vn,"f").logLevel),o(e.error)):n(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,_e),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),o(e)}}))}getById(e){return i(this,Un,"f")?new Promise(((t,n)=>{Ut(i(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_GET_BY_ID_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),gt(e),se.emit(Re+i(this,Mn,"f"),{type:he,records:e.records},(e=>{e.error?n(e.error):t(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,he),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),n(e)}})):new Promise(((t,n)=>{try{Ut(i(this,Pn,"f").config),Ot(Lt(re.VALIDATE_GET_BY_ID_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),gt(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+i(this,Mn,"f"),(()=>{se.emit(Re+i(this,Mn,"f"),{type:he,records:e.records},(e=>{e.error?n(e.error):t(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,he),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),n(e)}}))}get(e){return i(this,Un,"f")?new Promise(((t,n)=>{Ut(i(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_GET_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),Ct(e),se.emit(Re+i(this,Mn,"f"),{type:ue,records:e.records},(e=>{e.error?n(e.error):t(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,ue),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),n(e)}})):new Promise(((t,n)=>{try{Ut(i(this,Pn,"f").config),Ot(Lt(re.VALIDATE_GET_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),Ct(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+i(this,Mn,"f"),(()=>{se.emit(Re+i(this,Mn,"f"),{type:ue,records:e.records},(e=>{e.error?n(e.error):t(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,ue),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),n(e)}}))}delete(e,t){return i(this,Un,"f")?new Promise(((n,o)=>{Ut(i(this,Pn,"f").config);try{Ot(Lt(re.VALIDATE_DELETE_INPUT,kn),pt.LOG,i(this,Vn,"f").logLevel),bt(e),se.emit(Re+i(this,Mn,"f"),{type:pe,records:e,options:t},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,i(this,Vn,"f").logLevel),o(e.error)):n(e)})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,pe),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),o(e)}})):new Promise(((n,o)=>{try{Ut(i(this,Pn,"f").config),Ot(Lt(re.VALIDATE_RECORDS,kn),pt.LOG,i(this,Vn,"f").logLevel),bt(e),se.target(nt.IFRAME_SECURE_ORGIN).on(ye+i(this,Mn,"f"),(()=>{se.emit(Re+i(this,Mn,"f"),{type:pe,records:e,options:t},(e=>{e.error?(Ot(`${JSON.stringify(e.error)}`,pt.ERROR,i(this,Vn,"f").logLevel),o(e.error)):n(e)}))})),Ot(Lt(re.EMIT_PURE_JS_REQUEST,kn,pe),pt.LOG,i(this,Vn,"f").logLevel)}catch(e){Ot(e.message,pt.ERROR,i(this,Vn,"f").logLevel),o(e)}}))}}function xn(e){this.message=e}Mn=new WeakMap,Pn=new WeakMap,Un=new WeakMap,Vn=new WeakMap,xn.prototype=new Error,xn.prototype.name="InvalidCharacterError";var Fn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new xn("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,o=0,s=0,r="";n=t.charAt(s++);~n&&(i=o%4?64*i+n:n,o++%4)?r+=String.fromCharCode(255&i>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r};function Gn(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(Fn(e).replace(/(.)/g,(function(e,t){var i=t.charCodeAt(0).toString(16).toUpperCase();return i.length<2&&(i="0"+i),"%"+i})))}(t)}catch(e){return Fn(t)}}function Bn(e){this.message=e}Bn.prototype=new Error,Bn.prototype.name="InvalidTokenError";const jn=e=>{try{if(!e)return!1;if(t=e,"[object String]"!==Object.prototype.toString.call(t))return!1;let i=!1;const n=function(e,t){if("string"!=typeof e)throw new Bn("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Gn(e.split(".")[i]))}catch(e){throw new Bn("Invalid token specified: "+e.message)}}(e),o=(new Date).getTime()/1e3,s=n.exp;return s&&o>s&&(i=!0),!i}catch(e){return!1}var t};var Xn,$n,Wn,Kn,zn,Hn,qn,Jn,Zn,Qn,eo,to={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class io{constructor(e,t){Xn.set(this,void 0),this.request=e=>new Promise(((t,n)=>{var o,s,r,a;const l=new XMLHttpRequest;if(l){if(l.open(e.requestMethod,e.url),e.headers){const t=function(e,t,i){var n,o,s,r,a;const l={sdkName:e.name,sdkVersion:e.version},d=function(e,t){return""!==e?`${e}`:`${t.sdkName}@${t.sdkVersion}`}(t.sdkVersion,l),c=function(e){var t,i,n,o,s,r,a,l,d,c,E,_;let I=null,h=null;return/Windows/.test(e)?(I="Windows",h=null!==(i=null===(t=/Windows NT (\d+\.\d+)/.exec(e))||void 0===t?void 0:t[1])&&void 0!==i?i:null):/Android/.test(e)?(I="Android",h=null!==(o=null===(n=/Android (\d+\.\d+)/.exec(e))||void 0===n?void 0:n[1])&&void 0!==o?o:null):/iOS/.test(e)||/iPhone/.test(e)?(I="iOS",h=null!==(a=null===(r=null===(s=/OS (\d+[._]\d+[._]?\d*)/.exec(e))||void 0===s?void 0:s[1])||void 0===r?void 0:r.replace(/_/g,"."))&&void 0!==a?a:null):/Mac OS X/.test(e)?(I="Mac OS X",h=null!==(c=null===(d=null===(l=/Mac OS X (\d+([._]\d+)*)/.exec(e))||void 0===l?void 0:l[1])||void 0===d?void 0:d.replace(/_/g,"."))&&void 0!==c?c:null):/Linux/.test(e)&&(I="Linux",h=null!==(_=null===(E=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===E?void 0:E[2])&&void 0!==_?_:null),{os:I,version:h}}(i.userAgent),E=function(e){let t="",i="";if(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")){t="Internet Explorer";const n=e.match(/(MSIE|rv:)\s?([\d.]+)/);n&&(i=n[2])}else if(-1!==e.indexOf("Edge")){t="Microsoft Edge";const n=e.match(/Edge\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Chrome")){t="Google Chrome";const n=e.match(/Chrome\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Firefox")){t="Mozilla Firefox";const n=e.match(/Firefox\/([\d.]+)/);n&&(i=n[1])}else if(-1!==e.indexOf("Safari")){t="Apple Safari";const n=e.match(/Version\/([\d.]+)/);n&&(i=n[1])}return{browserName:t,browserVersion:i}}(i.userAgent);var _;return{sdk_name_version:d,sdk_client_device_model:(_=i.userAgent,/(ipad|tablet)/gi.test(_)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(_)?"mobile":"desktop"),sdk_os_version:null!==(n=i.platform)&&void 0!==n?n:`${null!==(o=c.os)&&void 0!==o?o:""} ${null!==(s=c.version)&&void 0!==s?s:""}`,sdk_runtime_details:`${null!==(r=E.browserName)&&void 0!==r?r:""} ${null!==(a=E.browserVersion)&&void 0!==a?a:""}`}}(to,i(this,Xn,"f"),navigator);e.headers["sky-metadata"]=JSON.stringify(t);const{headers:n}=e;Object.keys(e.headers).forEach((e=>{"content-type"===e&&n[e]&&n[e].includes(Qe.FORMDATA)||l.setRequestHeader(e,n[e])}))}(null===(s=null===(o=e.headers)||void 0===o?void 0:o["content-type"])||void 0===s?void 0:s.includes(Qe.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(Qe.FORMDATA))?l.send(e.body):l.send(JSON.stringify(Object.assign({},e.body))),l.onload=()=>{var e,i,o;const s=l.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};s.forEach((e=>{const t=e.split(": "),i=t.shift()||"",n=t.join(": ");r[i]=n}));const a=r["content-type"],d=r["x-request-id"];if(l.status<200||l.status>=400)if(a&&a.includes("application/json")){let t=JSON.parse(l.response);(null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.message)&&(t=d?`${null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.message} - requestId: ${d}`:null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.message),n(new mt({code:l.status,description:t},[],!0))}else a&&a.includes("text/plain")?n(new mt({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new mt({code:l.status,description:d?`${ae.ERROR_OCCURED} - requestId: ${d}`:ae.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&t(JSON.parse(l.response)),t(l.response)},l.onerror=()=>{n(new mt(Rt.NETWORK_ERROR,[],!0))}}else n(new mt(Rt.CONNECTION_ERROR,[],!0))})),this.config=e,n(this,Xn,t,"f")}toJSON(){return{config:this.config,metaData:i(this,Xn,"f")}}static fromJSON(e){return new io(e.config,e.metaData)}}Xn=new WeakMap,function(e){e.COLLECT="COLLECT",e.REVEAL="REVEAL",e.COMPOSABLE="COMPOSABLE"}(eo||(eo={}));const no="Skyflow";class oo{constructor(e){var t,o;$n.set(this,void 0),Wn.set(this,fi()),Kn.set(this,{uuid:i(this,Wn,"f"),clientDomain:window.location.origin}),zn.set(this,void 0),Hn.set(this,""),qn.set(this,void 0),Jn.set(this,void 0),Zn.set(this,void 0),Qn.set(this,void 0);const s=localStorage.getItem("sdk_version")||"";i(this,Kn,"f").sdkVersion=s,n(this,$n,new io(Object.assign({},e),i(this,Kn,"f")),"f"),n(this,Jn,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ht.ERROR,"f"),n(this,Zn,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||ut.PROD,"f"),n(this,Qn,{},"f"),n(this,zn,new Yn(i(this,$n,"f"),{logLevel:i(this,Jn,"f"),env:i(this,Zn,"f")}),"f");se.target(nt.IFRAME_SECURE_ORGIN).on(De+i(this,Wn,"f"),((e,t)=>{Ot(Lt(re.CAPTURED_BEARER_TOKEN_EVENT,no),pt.LOG,i(this,Jn,"f")),!i(this,$n,"f").config.getBearerToken||i(this,Hn,"f")&&jn(i(this,Hn,"f"))?(Ot(Lt(re.REUSE_BEARER_TOKEN,no),pt.LOG,i(this,Jn,"f")),t({authToken:i(this,Hn,"f")})):i(this,$n,"f").config.getBearerToken().then((e=>{jn(e)?(Ot(Lt(re.BEARER_TOKEN_RESOLVED,no),pt.LOG,i(this,Jn,"f")),n(this,Hn,e,"f"),t({authToken:i(this,Hn,"f")})):(Ot(ae.INVALID_BEARER_TOKEN,pt.ERROR,i(this,Jn,"f")),t({error:ae.INVALID_BEARER_TOKEN}))})).catch((e=>{Ot(ae.BEARER_TOKEN_REJECTED,pt.ERROR,i(this,Jn,"f")),t({error:e})}))})),Ot(Lt(re.BEARER_TOKEN_LISTENER,no),pt.LOG,i(this,Jn,"f")),Ot(Lt(re.CURRENT_ENV,no,i(this,Zn,"f")),pt.LOG,i(this,Jn,"f")),Ot(Lt(re.CURRENT_LOG_LEVEL,no,i(this,Jn,"f")),pt.LOG,i(this,Jn,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||ht.ERROR;!function(e){var t,i,n,o;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&Mt(null===(i=null==e?void 0:e.options)||void 0===i?void 0:i.customElementsURL)){const t=null===(n=null==e?void 0:e.options)||void 0===n?void 0:n.customElementsURL,i=new URL(t),s=`${i.protocol}//${i.hostname}`;nt.IFRAME_SECURE_ORGIN=s,nt.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}}(e),Ot(Lt(re.INITIALIZE_CLIENT,no),pt.LOG,i);const n=e;var o;n.vaultURL="string"!=typeof(o=e.vaultURL)?o:"/"===(null==o?void 0:o.trim().slice(-1))?o.slice(0,-1):o.trim();const s=new oo(n);return Ot(Lt(re.CLIENT_INITIALIZED,no),pt.LOG,i),s}container(e,t){switch(e){case eo.COLLECT:{const n=new wi(t,Object.assign(Object.assign({},i(this,Kn,"f")),{clientJSON:i(this,$n,"f").toJSON(),containerType:e}),i(this,Qn,"f"),{logLevel:i(this,Jn,"f"),env:i(this,Zn,"f")});return Ot(Lt(re.COLLECT_CONTAINER_CREATED,no),pt.LOG,i(this,Jn,"f")),n}case eo.REVEAL:{const t=new wn(Object.assign(Object.assign({},i(this,Kn,"f")),{clientJSON:i(this,$n,"f").toJSON(),containerType:e}),i(this,Qn,"f"),{logLevel:i(this,Jn,"f")});return Ot(Lt(re.REVEAL_CONTAINER_CREATED,no),pt.LOG,i(this,Jn,"f")),t}case eo.COMPOSABLE:{(e=>{if(!e)throw new mt(Rt.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new mt(Rt.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new mt(Rt.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new mt(Rt.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new mt(Rt.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new mt(Rt.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new mt(Rt.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new mt(Rt.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(t);const n=new ln(t,Object.assign(Object.assign({},i(this,Kn,"f")),{clientJSON:i(this,$n,"f").toJSON(),containerType:e}),i(this,Qn,"f"),{logLevel:i(this,Jn,"f"),env:i(this,Zn,"f")});return Ot(Lt(re.COLLECT_CONTAINER_CREATED,no),pt.LOG,i(this,Jn,"f")),n}default:if(!e)throw new mt(Rt.EMPTY_CONTAINER_TYPE,[],!0);throw new mt(Rt.INVALID_CONTAINER_TYPE,[],!0)}}insert(e,t){return Ot(Lt(re.INSERT_TRIGGERED,no),pt.LOG,i(this,Jn,"f")),i(this,zn,"f").insert(e,t)}detokenize(e){return Ot(Lt(re.DETOKENIZE_TRIGGERED,no),pt.LOG,i(this,Jn,"f")),i(this,zn,"f").detokenize(e)}getById(e){return Ot(le.GET_BY_ID_DEPRECATED,pt.WARN,i(this,Jn,"f")),Ot(Lt(re.GET_BY_ID_TRIGGERED,no),pt.LOG,i(this,Jn,"f")),i(this,zn,"f").getById(e)}get(e){return Ot(Lt(re.GET_TRIGGERED,no),pt.LOG,i(this,Jn,"f")),i(this,zn,"f").get(e)}delete(e,t){return Ot(Lt(re.DELETE_TRIGGERED,no),pt.LOG,i(this,Jn,"f")),i(this,zn,"f").delete(e,t)}static get ContainerType(){return eo}static get ElementType(){return Fe}static get RedactionType(){return Et}static get RequestMethod(){return _t}static get LogLevel(){return ht}static get EventName(){return It}static get Env(){return ut}static get ValidationRuleType(){return ft}}$n=new WeakMap,Wn=new WeakMap,Kn=new WeakMap,zn=new WeakMap,Hn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap;class so{constructor(e){this.loadFunction=e,this.loadScript()}get loader(){return this.loadingPromise||(this.loadingPromise=this.loadScript()),this.loadingPromise}loadScript(){return t(this,void 0,void 0,(function*(){return this.loadingPromise||(this.loadingPromise=new Promise(((e,t)=>{this.loadFunction().then((t=>{t&&e(t)}),(()=>{t()})).catch((()=>{}))}))),this.loadingPromise}))}}class ro extends L{constructor(e){super("span",{id:e.id,className:"payrails-store-instrument"}),this.options=e,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var e;return!!(null===(e=this.element.querySelector("input"))||void 0===e?void 0:e.checked)}createHTML(){var e,t,i,n,o,s,r,a,l;const d=(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.labels)||void 0===i?void 0:i.saveInstrument)||(null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",c=`${this.id}-checkbox`;(null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${c}"><input type="checkbox" id="${c}" name="${c}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var e,t;Object.keys((null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.storeInstrumentCheckbox)||{}).forEach((e=>{var t,i,n;this.element.style[e]=null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.storeInstrumentCheckbox)||void 0===n?void 0:n[e]}))}addListeners(){this.element.addEventListener("change",(e=>{var t,i,n,o;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),e.stopPropagation(),e.stopImmediatePropagation()}))}}class ao extends L{constructor(e,i){var n,o;super(e,i),this.options=i,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new ro(Object.assign(Object.assign({},i),{id:`${null===(o=this.options)||void 0===o?void 0:o.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,n;null===(n=null===(t=null==i?void 0:i.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(t,e)}))}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var e,t;return(null===(e=this.storeInstrumentCheckbox)||void 0===e?void 0:e.isChecked)||(null===(t=this.options)||void 0===t?void 0:t.alwaysStoreInstrument)||!1}}class lo extends ao{constructor(e,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=i,this.options=n,this.appleButton=null,this.paymentExecutor=new f(e,i),this.loadScript=new so((()=>t(this,void 0,void 0,(function*(){const e=document.createElement("script");return e.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",new Promise(((i,n)=>{e.onload=()=>t(this,void 0,void 0,(function*(){var e,t,n;(yield this.isApplePayAvailable())?(null===(n=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===n||n.call(t),i(!0)):i(!1)})),e.onerror=()=>{n()},document.body.appendChild(e)}))}))))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{yield this.loadScript.loader,yield this.mountApplePayButton()}catch(e){}}))})()}unmount(){var e,t;null===(t=null===(e=this.appleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.appleButton),super.unmount()}isApplePayAvailable(){return t(this,void 0,void 0,(function*(){if(!(null===window||void 0===window?void 0:window.ApplePaySession))return!1;return yield ApplePaySession.canMakePayments()}))}mountApplePayButton(){var e,i,n,o,s;return t(this,void 0,void 0,(function*(){if(null===window||void 0===window?void 0:window.ApplePaySession)try{if(!this.isApplePayAvailable())return;null===(i=null===(e=this.options.events)||void 0===e?void 0:e.onApplePayAvailable)||void 0===i||i.call(e);const t=(null===(n=this.options.styles)||void 0===n?void 0:n.type)||"buy",r=(null===(o=this.options.styles)||void 0===o?void 0:o.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${r}" type="${t}" locale="en-GB"></apple-pay-button>`,null===(s=this.storeInstrumentCheckbox)||void 0===s||s.mount(this.selector);const a=this.element.querySelector("apple-pay-button");null==a||a.setAttribute("style","width: 100%;"),null==a||a.addEventListener("click",(()=>{this.createApplePaySession()}))}catch(e){}}))}createApplePaySession(){const e=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=e,{amount:s}=this.sdkConfig;try{const e={countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}},r=new ApplePaySession(3,e);return r.onvalidatemerchant=e=>t(this,void 0,void 0,(function*(){const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:e.validationURL,clientDomain:this.options.clientDomain}),i=t.data.data;r.completeMerchantValidation(i)})),r.onpaymentauthorized=e=>t(this,void 0,void 0,(function*(){var t,i,n,o,s,a,l,d,c,E,_,I;try{const E=yield this.onApplePayAuthorized(e.payment.token);if("authorizeSuccessful"===(null===(t=null==E?void 0:E.finalState)||void 0===t?void 0:t.code))(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)&&(null===(s=this.options)||void 0===s||s.events.onAuthorizeFailed());r.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(a=this.options)||void 0===a?void 0:a.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c||c.onAuthorizeSuccess(E))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(_=null===(E=this.options)||void 0===E?void 0:E.events)||void 0===_?void 0:_.onAuthorizeFailed)&&(null===(I=this.options)||void 0===I||I.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(e){return t(this,void 0,void 0,(function*(){const t={paymentData:e.paymentData,transactionIdentifier:e.transactionIdentifier,paymentNetwork:e.paymentMethod.network,paymentInstrumentName:e.paymentMethod.displayName},i=[{paymentMethodCode:"applePay",integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(i)}))}}const{CARD_NUMBER:co,CVV:Eo,CARDHOLDER_NAME:_o,EXPIRATION_MONTH:Io,EXPIRATION_YEAR:ho}=exports.ElementType,uo={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},po=[{type:_o,placeholder:"Card holder",styles:Object.assign(Object.assign({},uo),{base:Object.assign(Object.assign({},uo.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:co,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},uo),{base:Object.assign(Object.assign({},uo.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:Io,placeholder:"MM",styles:Object.assign(Object.assign({},uo),{base:Object.assign(Object.assign({},uo.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:ho,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},uo),{base:Object.assign(Object.assign({},uo.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:Eo,placeholder:"CVC",styles:Object.assign(Object.assign({},uo),{base:Object.assign(Object.assign({},uo.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class fo extends ao{get bin(){return this.collectContainer.bin}constructor(e,t){var i,n,o,s,r;super("div",Object.assign(Object.assign({},t),{translations:Object.assign(Object.assign({},null==t?void 0:t.translations),{labels:Object.assign(Object.assign({},null===(i=null==t?void 0:t.translations)||void 0===i?void 0:i.labels),{saveInstrument:null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==t?void 0:t.styles)||void 0===s?void 0:s.storeCardCheckbox},null==t?void 0:t.styles),id:"payrails-card-form"})),this.collectContainer=e,this.options=t,this.formFields=[],(null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),po.forEach((({type:e,styles:i,format:n,placeholder:o})=>{var s,r,a,l,d,c,E;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&e===exports.ElementType.CARDHOLDER_NAME)return;const _=new No(this.collectContainer,{type:e,label:null===(a=null===(r=null==t?void 0:t.translations)||void 0===r?void 0:r.labels)||void 0===a?void 0:a[e],placeholder:(null===(d=null===(l=null==t?void 0:t.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[e])||o,labelStyles:this.prepareLabelStyles(e),inputStyles:this.prepareInputStyles(i,e),format:n,events:{onFocus:null===(E=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===E?void 0:E.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(_)})),this.subElements.push(this.collectContainer),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var e,t,i;this.formFields.reduce(((e,t)=>e&&t.isReady),!0)&&(null===(i=null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onReady)||void 0===i||i.call(t))}prepareLabelStyles(e){return["base"].reduce(((t,i)=>{var n,o,s,r,a,l,d,c;return t[i]=Object.assign(Object.assign(Object.assign({},null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.base),null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.labels)||void 0===a?void 0:a.all),null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===c?void 0:c[e]),t}),{})}prepareInputStyles(e,t){var i;let n=JSON.parse(JSON.stringify(e));return(null===(i=this.options)||void 0===i?void 0:i.showCardHolderName)&&t===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),n=Object.assign(Object.assign({},e),{base:Object.assign(Object.assign({},uo.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var i,o,s,r,a,l,d,c;n[e]=Object.assign(Object.assign(Object.assign({},n[e]),null===(r=null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===r?void 0:r[e]),null===(c=null===(d=null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[t])||void 0===c?void 0:c[e])})),n}get isValid(){return this.formFields.reduce(((e,t)=>e&&t.isValid),!0)}get cardNetwork(){var e,t;return null!==(t=null===(e=this.formFields.find((e=>Boolean(e.cardNetwork))))||void 0===e?void 0:e.cardNetwork)&&void 0!==t?t:""}onChange(){var e,t,i,n;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onChange)&&(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n||n.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}collectValues(){var e;return t(this,void 0,void 0,(function*(){return{tokenizedCardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}))}}class No{constructor(e,t){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:i}=t,n=e.createCollectElement(t);(null==i?void 0:i.onFocus)&&n.on("FOCUS",i.onFocus),n.on("READY",(()=>{var e,i;this.isReady=!0,null===(i=null===(e=t.events)||void 0===e?void 0:e.onReady)||void 0===i||i.call(e)})),n.on("CHANGE",(e=>{const{isEmpty:t,isValid:n,network:o}=e;this.isValid=!t&&n,this.cardNetwork=null!=o?o:"",(null==i?void 0:i.onChange)&&i.onChange(this)}))}}class To extends L{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new vo((()=>{(null==t?void 0:t.onCardChange)&&t.onCardChange(e)}),e);this.listItems.push(i),this.subElements.push(i)}))}reset(){this.element.querySelectorAll("input").forEach((e=>e.checked=!1))}}class vo extends L{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=this.createCardLabel(t),o=document.createElement("label");o.setAttribute("for",i),o.addEventListener("click",e);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),o.appendChild(s);const r=document.createElement("span");r.innerText=n,o.appendChild(r),this.element.appendChild(o)}createCardLabel({data:e={}}){return`****${null==e?void 0:e.suffix}`}}class Oo extends L{constructor(e="Authorization failed, please try again."){super("div",{id:"authorization-failed-message"}),this.element.innerText=e,this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div>${e}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}}class Lo extends L{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Payment successful"}</div`}}class Ao extends L{constructor(e,t,i){super("div",{id:e,className:"payrails-dropin-item"}),this.events=i,this.isActive=!1;const n=`payrails-dropin-item-${e}`,o=document.createElement("label");o.setAttribute("for",n);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",n),s.setAttribute("value",n),this.input=s,o.appendChild(s),this.label=o;const r=document.createElement("span");o.appendChild(r),r.innerText=t,this.element.appendChild(o)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(this.selector),this.label.style.marginBottom="8px",this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}}class mo extends Ao{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.label.style.marginBottom="8px",this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){super.mount(`#${this.loadElementId}`)}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}unmount(){var e;super.unmount(),null===(e=document.querySelector(`#${this.loadElementId}`))||void 0===e||e.remove()}}class Ro extends mo{constructor(e,t,i){var n,o;super("apple-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Apple Pay"),this.loadElementId="apple-pay-dropin-load-element",this.component=new lo(e,t,Object.assign(Object.assign({},i),{events:{onApplePayAvailable:()=>{this.mountAfterAvailable()}}}))}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}}class yo extends Ao{constructor(e,t){super("payrails-credit-card-wrapper","Card"),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new Do(e,t)}activate(){var e,t;this.label.style.marginBottom="8px",this.cardFormShown||(this.cardFormShown=!0,null===(e=this.component)||void 0===e||e.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}deactivate(){var e;this.isActive&&(this.label.style.marginBottom="0",this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class Do extends L{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}const So={apiVersion:2,apiVersionMinor:0};class Co extends ao{constructor(e,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=i,this.options=n,this.googleButton=null,this.paymentExecutor=new f(e,i),this.loadScript=new so((()=>t(this,void 0,void 0,(function*(){const e=document.createElement("script");return e.src="https://pay.google.com/gp/p/js/pay.js",new Promise(((t,i)=>{e.onload=()=>{const e=new google.payments.api.PaymentsClient({environment:this.options.environment||"TEST"}),n=Object.assign(Object.assign({},So),{allowedPaymentMethods:this.execution.googlePayConfig});e.isReadyToPay(n).then((n=>{var o,s,r;n?(null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onGooglePayAvailable)||void 0===r||r.call(s),t(e)):i()}),i)},e.onerror=()=>{i()},document.body.appendChild(e)}))}))))}sdkLoaded(e){var i,n,o,s,r,a,l,d;return t(this,void 0,void 0,(function*(){try{const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",E=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",_=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",I=(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.buttonLocale)||void 0;return this.googleButton=e.createButton({buttonColor:c,buttonType:E,buttonSizeMode:_,buttonLocale:I,onClick:()=>t(this,void 0,void 0,(function*(){var e,t,i;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){if(!(yield null===(i=this.options)||void 0===i?void 0:i.events.onPaymentButtonClicked()))return}yield this.onPaymentButtonClicked()})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}catch(e){throw console.error("Google pay can not be initialized",e),new Error(e.message)}}))}onLoadPaymentData(e){var i,n,o,s;return t(this,void 0,void 0,(function*(){const t=[{paymentMethodCode:"googlePay",integrationType:"api",paymentInstrumentData:{paymentToken:e.paymentMethodData.tokenizationData.token},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],r=yield this.paymentExecutor.pay(t);(null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&(null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s||s.onAuthorizeSuccess(r))}))}onPaymentButtonClicked(){var e,i,n,o,s;return t(this,void 0,void 0,(function*(){const t=Object.assign({},So);t.allowedPaymentMethods=this.execution.googlePayConfig,t.transactionInfo={totalPriceStatus:"FINAL",totalPrice:null===(e=this.sdkConfig.amount)||void 0===e?void 0:e.value,currencyCode:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.currency,countryCode:null===(s=null===(o=null===(n=this.execution.meta)||void 0===n?void 0:n.customer)||void 0===o?void 0:o.country)||void 0===s?void 0:s.code};(yield this.loadScript.loader).loadPaymentData(t).then((e=>{this.onLoadPaymentData(e)})).catch((e=>{var t,i,n;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&(null===(n=this.options)||void 0===n||n.events.onAuthorizeFailed(e))}))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;try{const t=yield this.loadScript.loader,i=yield this.sdkLoaded(t);this.element.appendChild(i),null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(this.selector)}catch(e){}}))})()}unmount(){var e,t,i;null===(t=null===(e=this.googleButton)||void 0===e?void 0:e.parentElement)||void 0===t||t.removeChild(this.googleButton),null===(i=this.storeInstrumentCheckbox)||void 0===i||i.unmount(),super.unmount()}}class go extends mo{constructor(e,t,i){var n,o;super("google-pay-dropin",(null===(o=null===(n=i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"Google Pay"),this.loadElementId="google-pay-dropin-load-element",this.component=new Co(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}mount(e){const t=document.querySelector(e);if(!t)throw new Error(`Element with selector "${e}" not found in in the DOM`);const i=document.createElement("div");i.setAttribute("id",this.loadElementId),i.setAttribute("style","width: 100%;"),t.appendChild(i)}}
|
|
1
|
+
!function(){"use strict";var t;let e;exports.ElementType=void 0,(t=exports.ElementType||(exports.ElementType={})).CARD_NUMBER="CARD_NUMBER",t.CARDHOLDER_NAME="CARDHOLDER_NAME",t.CVV="CVV",t.EXPIRATION_MONTH="EXPIRATION_MONTH",t.EXPIRATION_YEAR="EXPIRATION_YEAR";const n=new Uint8Array(16);function i(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(n)}const o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));var s,a={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function r(t,e,n){if(a.randomUUID&&!e&&!t)return a.randomUUID();const s=(t=t||{}).random||(t.rng||i)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,e){n=n||0;for(let t=0;t<16;++t)e[n+t]=s[t];return e}return function(t,e=0){return(o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]).toLowerCase()}(s)}!function(t){t.GET="GET",t.POST="POST"}(s||(s={}));const l=async({url:t,method:e=s.GET,token:n,body:i})=>{const o={method:e,headers:Object.assign(Object.assign(Object.assign({},h()),c(n)),v())};e===s.POST&&(o.body=JSON.stringify(i||{}));const a=await fetch(t,o),r=await a.json();if([401,403].includes(a.status))throw new d(t,e);if(!a.ok)throw new u(t,e,r);return{ok:a.ok,req:Object.assign({url:t},o),res:r}};class d extends Error{constructor(t,e){super(`[${e}] ${t} unauthorized`)}}class u extends Error{constructor(t,e,n){super(`[${e}] ${t} unsuccessful`),this.res=n}}const c=t=>({authorization:`Bearer ${t}`}),h=()=>({"x-idempotency-key":r()}),v=()=>({"x-client-version":"2.7.11-RC.0","x-client-type":"web-sdk"});class p{constructor(t,e,n){this.sdkConfig=t,this.execution=e,this.returnLinks=n}async pay(t){const e=(await this.authorize(t)).res.links.execution;return await this.pollForAuthorizationResult(e)}async authorize(t){if(!this.execution.authorizeLink||!this.sdkConfig.amount)throw new Error("SDK was not initialized with workflow execution");const{success:e="https://payrails.io/success",error:n="https://payrails.io/error",cancel:i="https://payrails.io/cancel"}=this.returnLinks||{};return l({url:this.execution.authorizeLink,method:s.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:t,returnInfo:{success:e,cancel:i,error:n}}})}async confirm(t,e={}){const n=await l({url:t,method:s.POST,token:this.sdkConfig.token,body:{data:e}}),i=await this.pollForAuthorizationResult(n.res.links.execution);if(i.finalState)return i;const o=i.response.status.slice().sort(((t,e)=>new Date(e.time).getTime()-new Date(t.time).getTime()))[0].time,{res:a}=await this.getExecution(n.res.links.execution,void 0,o);return{finalState:a.status.find((({code:t,time:e})=>["authorizeSuccessful","authorizeFailed"].includes(t)&&new Date(e)>new Date(o))),response:a}}async pollForAuthorizationResult(t,e=0){const n=(await this.getExecution(t)).res,i=n.status,o=["authorizePending","authorizeSuccessful","authorizeFailed"],s=i.find((({code:t})=>"authorizeRequested"===t));if(!s&&e<10)return await new Promise((t=>setTimeout(t,300))),this.pollForAuthorizationResult(t,e+1);if(!s)throw new Error("Authorization was not requested");const a=i.find((({code:t,time:e})=>"confirmRequested"===t&&new Date(e)>new Date(s.time))),r=a?a.time:s.time;let l=i.find((({code:t,time:e})=>o.includes(t)&&new Date(e)>new Date(r)));if(!l){const{res:e}=await this.getExecution(t,void 0,r);return l=e.status.find((({code:t,time:e})=>o.includes(t)&&new Date(e)>new Date(r))),{finalState:l,response:e}}return{finalState:l,response:n}}async getExecution(t,e,n){const i=new URLSearchParams;e&&e.length>0&&i.append("waitWhile[status]",`[${e.map((t=>`"${t}"`)).join(",")}]`),n&&i.append("waitWhile[lastStatusTime]",n);const o=`${t}${i.toString()?"?":""}${i.toString()}`;return l({url:o,token:this.sdkConfig.token})}async createApplePaySession(t){return l({url:t.requestUrl,method:s.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:t.sessionUrl,clientDomain:t.clientDomain||window.location.host}}})}}var m,y,g;!function(t){t.CARD="card",t.GOOGLE_PAY="googlePay",t.PAYPAL="payPal",t.APPLE_PAY="applePay"}(m||(m={})),function(t){t.ENABLED="enabled",t.CREATED="created"}(y||(y={}));class b{constructor(t){this.executionResponse=t}get lookup(){return this.executionResponse.initialResults.find((({body:{name:t}})=>"lookup"===t))}get holderReference(){return this.executionResponse.holderReference}get savedCreditCards(){return this.getStoredInstrumentForPaymentMethod(m.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(m.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(m.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(m.APPLE_PAY)}get paypalConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===m.PAYPAL));if(!t)throw new Error("trying to initialize paypal without config");return t.config||{}}get googlePayConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===m.GOOGLE_PAY));if(!t)throw new Error("trying to initialize google pay without config");return t?[t.config]:[]}isPaymentMethodAvailable(t){return this.availablePaymentMethods.some((({paymentMethodCode:e})=>e===t))}get applePayConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===m.APPLE_PAY));if(!t)throw new Error("apple pay config not found");return t.config.parameters}get url(){return this.response.links.self}get response(){return this.executionResponse}get meta(){return this.executionResponse.meta}get availablePaymentMethods(){var t;return(null===(t=this.lookup)||void 0===t?void 0:t.body.data.paymentCompositionOptions)||[]}get authorizeLink(){var t;return null===(t=this.lookup)||void 0===t?void 0:t.body.links.authorize.href}get createSessionLink(){return this.response.links.startPaymentSession.href}get storedPaymentInstruments(){return this.availablePaymentMethods.flatMap((t=>t.paymentInstruments||[]))}getStoredInstrumentForPaymentMethod(t){var e;return(null===(e=this.availablePaymentMethods.find((({paymentMethodCode:e})=>e===t)))||void 0===e?void 0:e.paymentInstruments)||[]}}class f{constructor(t,{id:e="",className:n=""}={}){this.subElements=[];const i=document.createElement(t);e&&(this.id=e,i.setAttribute("id",e)),n&&i.setAttribute("class",n),this.element=i}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new Error("Element id is not set");return`#${this.id}`}mount(t){const e=document.querySelector(t);if(!e)throw new Error(`Element with selector "${t}" not found in in the DOM`);e.appendChild(this.element),this.subElements.forEach((t=>{if(!this.id)throw new Error("Sub elements can not be rendered, please set id for the element");t.mount(this.selector)}))}unmount(){var t;this.subElements.forEach((t=>t.unmount())),null===(t=this.parentElement)||void 0===t||t.removeChild(this.element)}}class C extends f{get bin(){var t;return this.selectedInstrument?this.selectedInstrument.data.bin?this.selectedInstrument.data.bin:"":(null===(t=this.cardForm)||void 0===t?void 0:t.bin)||""}constructor(t,e,n,i){var o;super("button",{id:"payrails-card-payment-button"}),this.sdkConfig=t,this.execution=e,this.options=n,this.returnLinks=i,this.selectedInstrument=null,this.element.innerText=(null===(o=null==n?void 0:n.translations)||void 0===o?void 0:o.label)||"Pay",this.element.addEventListener("click",this.onPay.bind(this)),this.element.addEventListener("mouseenter",(()=>{var t;this.element.classList.contains("disabled")||(this.element.classList.add("hover"),this.setStyles((null===(t=this.options.styles)||void 0===t?void 0:t.hover)||{}))})),this.element.addEventListener("mouseleave",(()=>{var t;this.element.classList.contains("disabled")||(this.element.classList.remove("hover"),this.removeStyles((null===(t=this.options.styles)||void 0===t?void 0:t.hover)||{}))})),this.paymentExecutor=new p(this.sdkConfig,this.execution,this.returnLinks)}setDisabled(t){var e,n,i,o,s;this.element.classList.contains("disabled")!==t&&(null===(n=null===(e=this.options.events)||void 0===e?void 0:e.onStateChanged)||void 0===n||n.call(e,t?"disabled":"enabled")),this.element.disabled=t,t?(this.element.classList.add("disabled"),(null===(i=this.options.styles)||void 0===i?void 0:i.disabled)&&this.setStyles(this.options.styles.disabled)):(this.element.classList.remove("disabled"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.disabled)||{}),(null===(s=this.options.styles)||void 0===s?void 0:s.base)&&this.setStyles(this.options.styles.base))}setSavedCreditCard(t){console.warn("setSavedCreditCard is deprecated, please use setSavedInstrument"),this.setSavedInstrument(t)}setSavedInstrument(t){this.selectedInstrument=t,this.setDisabled(!1)}setStyles(t){var e;const n=Object.assign(Object.assign({},null===(e=this.options.styles)||void 0===e?void 0:e.base),t);Object.keys(n).forEach((t=>{this.element.style[t]=n[t]}))}removeStyles(t){var e;const n=Object.keys((null===(e=this.options.styles)||void 0===e?void 0:e.base)||{});Object.keys(t).forEach((t=>{var e,i;n.includes(t)?this.element.style[t]=null===(i=null===(e=this.options.styles)||void 0===e?void 0:e.base)||void 0===i?void 0:i[t]:this.element.style[t]=""}))}setLabel(t){this.element.innerText=t}setCardForm(t){this.cardForm=t}triggerLoading(t){var e,n,i,o;const s=this.element.offsetWidth;this.element.style.minWidth=`${s}px`,t?(this.element.innerHTML='<div class="dot-flashing"></div>',this.element.classList.add("loading"),(null===(e=this.options.styles)||void 0===e?void 0:e.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=(null===(i=null===(n=this.options)||void 0===n?void 0:n.translations)||void 0===i?void 0:i.label)||"Pay",this.element.classList.remove("loading"),this.removeStyles((null===(o=this.options.styles)||void 0===o?void 0:o.loading)||{}))}onAuthorizationFailed(t){var e,n;this.setDisabled(!1),this.triggerLoading(!1),(null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed)&&(null===(n=this.options.events)||void 0===n||n.onAuthorizeFailed(t))}async onPay(){var t,e,n,i,o,s,a,r,l,u;if(this.setDisabled(!0),this.triggerLoading(!0),null===(t=this.options.events)||void 0===t?void 0:t.onPaymentButtonClicked)try{if(!1===await(null===(e=this.options.events)||void 0===e?void 0:e.onPaymentButtonClicked({bin:this.bin||""})))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked resolved to false"})}catch(t){return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.VALIDATION_FAILED,message:"Callback passed to onPaymentButtonClicked threw an error"})}try{const t=[{paymentMethodCode:m.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(n=this.selectedInstrument)||void 0===n?void 0:n.id)t[0].paymentInstrumentId=null===(i=this.selectedInstrument)||void 0===i?void 0:i.id,t[0].paymentMethodCode=null===(o=this.selectedInstrument)||void 0===o?void 0:o.paymentMethod;else{const{tokenizedCardData:e,storeInstrument:n,enrollInstrumentToNetworkOffers:i}=await this.collectCardFormValues();t[0].paymentInstrumentData={vaultToken:null==e?void 0:e.instrumentId,card:{numberToken:null==e?void 0:e.card_number,securityCodeToken:null==e?void 0:e.security_code}},t[0].storeInstrument=n,t[0].enrollInstrumentToNetworkOffers=i}const e=await this.paymentExecutor.pay(t);this.handleAuthorizationResult(e)}catch(t){t instanceof d||[401,403].includes(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.code)?(null===(r=null===(a=this.options.events)||void 0===a?void 0:a.onPaymentSessionExpired)||void 0===r||r.call(a),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"API token is not valid or expired."})):t.toString().includes("Invalid token")?(null===(u=null===(l=this.options.events)||void 0===l?void 0:l.onPaymentSessionExpired)||void 0===u||u.call(l),this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:"Vault token is not valid or expired."})):this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.UNKNOWN_ERROR,message:t.toString(),rawError:t})}}handleAuthorizationResult(t){var e,n,i;switch(null===(e=null==t?void 0:t.finalState)||void 0===e?void 0:e.code){case"authorizeSuccessful":this.triggerLoading(!1),(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();break;case"authorizePending":"3ds"===(null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.actionRequired)&&this.handle3ds(t);break;default:this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed."})}}handle3ds(t){var e,n,i,o;try{null===(n=null===(e=this.options.events)||void 0===e?void 0:e.onThreeDSecureChallenge)||void 0===n||n.call(e)}catch(t){}const s=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.links["3ds"];if(s){const t=[[250,400],[390,400],[500,600],[600,400]],e=screen.width,n=t.reduce(((t,n)=>e>n[0]?n:t),[250,400]),i=document.createElement("iframe");i.setAttribute("id","payrails-3ds-frame"),i.setAttribute("src",s),i.setAttribute("width",n[0].toString()),i.setAttribute("height",n[1].toString());const a=document.createElement("div");a.setAttribute("id","payrails-3ds-challenge"),a.appendChild(i);const r=document.createElement("div");r.addEventListener("click",(async()=>{r.remove()})),r.setAttribute("id","payrails-3ds-popup-background"),r.appendChild(a);const l=async t=>{var e,n,i;if(t.data&&'{"type":"3DS-challenge-completed"}'===t.data){window.removeEventListener("message",l),r.remove();if(!(await this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:t})=>"authorizeSuccessful"===t))&&(null===(e=this.options.events)||void 0===e?void 0:e.onAuthorizeFailed))return void this.onAuthorizationFailed({code:exports.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."});if(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)return void(null===(i=this.options.events)||void 0===i||i.onAuthorizeSuccess())}};null===(o=document.querySelector("body"))||void 0===o||o.appendChild(r),window.addEventListener("message",l),a.style.width=`${n[0]+4}px`,a.style.height=`${n[1]+4}px`}}async collectCardFormValues(){if(!this.cardForm)throw new Error("Trying to collect values from non-existent card form");return await this.cardForm.collectValues()}}exports.AuthorizationFailureReasons=void 0,(g=exports.AuthorizationFailureReasons||(exports.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",g.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",g.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",g.UNKNOWN_ERROR="UNKNOWN_ERROR";class w{constructor(t){this.loadFunction=t,this.loadScript()}get loader(){return this.loadingPromise||(this.loadingPromise=this.loadScript()),this.loadingPromise}async loadScript(){return this.loadingPromise||(this.loadingPromise=new Promise(((t,e)=>{this.loadFunction().then((e=>{e&&t(e)}),(()=>{e()})).catch((()=>{}))}))),this.loadingPromise}}class A extends f{constructor(t){super("span",{id:t.id,className:"payrails-store-instrument"}),this.options=t,this.createHTML(),this.applyStyles(),this.addListeners()}get isChecked(){var t;return!!(null===(t=this.element.querySelector("input"))||void 0===t?void 0:t.checked)}createHTML(){var t,e,n,i,o,s,a,r,l;const d=(null===(n=null===(e=null===(t=this.options)||void 0===t?void 0:t.translations)||void 0===e?void 0:e.labels)||void 0===n?void 0:n.saveInstrument)||(null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.storeInstrument)||"Save instrument for future payments",u=`${this.id}-checkbox`;(null===(l=null===(r=null===(a=this.options)||void 0===a?void 0:a.translations)||void 0===r?void 0:r.labels)||void 0===l?void 0:l.saveInstrument)&&console.warn("The saveInstrument label is deprecated, please use storeInstrument instead"),this.element.innerHTML=`<label for="${u}"><input type="checkbox" id="${u}" name="${u}" class="payrails-store-instrument-checkbox">${d}</label>`}applyStyles(){var t,e;Object.keys((null===(e=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===e?void 0:e.storeInstrumentCheckbox)||{}).forEach((t=>{var e,n,i;this.element.style[t]=null===(i=null===(n=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===n?void 0:n.storeInstrumentCheckbox)||void 0===i?void 0:i[t]}))}addListeners(){this.element.addEventListener("change",(t=>{var e,n,i,o;(null===(n=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)&&(null===(o=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===o||o.onSaveInstrumentCheckboxChanged({checked:this.isChecked})),t.stopPropagation(),t.stopImmediatePropagation()}))}}class k extends f{constructor(t,e){var n,i;super(t,e),this.options=e,this.storeInstrumentCheckbox=null,(null===(n=this.options)||void 0===n?void 0:n.showStoreInstrumentCheckbox)&&(this.storeInstrumentCheckbox=new A(Object.assign(Object.assign({},e),{id:`${null===(i=this.options)||void 0===i?void 0:i.id}-store-instrument-checkbox`,events:{onSaveInstrumentCheckboxChanged:async t=>{var n,i;null===(i=null===(n=null==e?void 0:e.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(n,t)}}})),this.subElements.push(this.storeInstrumentCheckbox))}get shouldStoreInstrument(){var t,e;return(null===(t=this.storeInstrumentCheckbox)||void 0===t?void 0:t.isChecked)||(null===(e=this.options)||void 0===e?void 0:e.alwaysStoreInstrument)||!1}}class E extends k{constructor(t,e,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-apple-pay-button"})),this.sdkConfig=t,this.execution=e,this.options=n,this.appleButton=null,this.paymentExecutor=new p(t,e),this.loadScript=new w((async()=>{const t=document.createElement("script");return t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",new Promise(((e,n)=>{t.onload=async()=>{var t,n,i;await this.isApplePayAvailable()?(null===(i=null===(n=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===n?void 0:n.onApplePayAvailable)||void 0===i||i.call(n),e(!0)):e(!1)},t.onerror=()=>{n()},document.body.appendChild(t)}))}))}mount(t){super.mount(t),(async()=>{try{await this.loadScript.loader,await this.mountApplePayButton()}catch(t){}})()}unmount(){var t,e;null===(e=null===(t=this.appleButton)||void 0===t?void 0:t.parentElement)||void 0===e||e.removeChild(this.appleButton),super.unmount()}async isApplePayAvailable(){if(!(null===window||void 0===window?void 0:window.ApplePaySession))return!1;return await ApplePaySession.canMakePayments()}async mountApplePayButton(){var t,e,n;if(null===window||void 0===window?void 0:window.ApplePaySession)try{if(!this.isApplePayAvailable())return;null===(e=null===(t=this.options.events)||void 0===t?void 0:t.onApplePayAvailable)||void 0===e||e.call(t),this.element.innerHTML='<apple-pay-button buttonstyle="black" type="buy" locale="en-GB"></apple-pay-button>',null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const i=this.element.querySelector("apple-pay-button");null==i||i.setAttribute("style","width: 100%;"),null==i||i.addEventListener("click",(()=>{this.createApplePaySession()}))}catch(t){}}createApplePaySession(){const t=this.execution.applePayConfig,{countryCode:e,supportedNetworks:n,merchantCapabilities:i}=t,{amount:o}=this.sdkConfig;try{const t={countryCode:e,currencyCode:o.currency,merchantCapabilities:i,supportedNetworks:n,total:{label:"",type:"final",amount:o.value}},s=new ApplePaySession(3,t);return s.onvalidatemerchant=async t=>{const{res:e}=await this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:t.validationURL,clientDomain:this.options.clientDomain}),n=e.data.data;s.completeMerchantValidation(n)},s.onpaymentauthorized=async t=>{var e,n,i,o,a,r,l,d,u,c,h,v;try{const c=await this.onApplePayAuthorized(t.payment.token);if("authorizeSuccessful"===(null===(e=null==c?void 0:c.finalState)||void 0===e?void 0:e.code))(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess();else s.completePayment(ApplePaySession.STATUS_FAILURE),(null===(o=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===o?void 0:o.onAuthorizeFailed)&&(null===(a=this.options)||void 0===a||a.events.onAuthorizeFailed());s.completePayment(ApplePaySession.STATUS_SUCCESS),(null===(l=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===l?void 0:l.onAuthorizeSuccess)&&(null===(u=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===u||u.onAuthorizeSuccess(c))}catch(t){s.completePayment(ApplePaySession.STATUS_FAILURE),(null===(h=null===(c=this.options)||void 0===c?void 0:c.events)||void 0===h?void 0:h.onAuthorizeFailed)&&(null===(v=this.options)||void 0===v||v.events.onAuthorizeFailed(t))}},s.begin(),s}catch(t){return null}}async onApplePayAuthorized(t){const e={paymentData:t.paymentData,transactionIdentifier:t.transactionIdentifier,paymentNetwork:t.paymentMethod.network,paymentInstrumentName:t.paymentMethod.displayName},n=[{paymentMethodCode:"applePay",integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(e)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return await this.paymentExecutor.pay(n)}}const{CARD_NUMBER:P,CVV:x,CARDHOLDER_NAME:I,EXPIRATION_MONTH:S,EXPIRATION_YEAR:O}=exports.ElementType,_={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},T=[{type:I,placeholder:"Card holder",styles:Object.assign(Object.assign({},_),{base:Object.assign(Object.assign({},_.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:P,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},_),{base:Object.assign(Object.assign({},_.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px",textIndent:"0"}),cardIcon:{position:"absolute",right:"8px",height:"24px",bottom:"calc(50% - 12px)"}})},{type:S,placeholder:"MM",styles:Object.assign(Object.assign({},_),{base:Object.assign(Object.assign({},_.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:O,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},_),{base:Object.assign(Object.assign({},_.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:x,placeholder:"CVC",styles:Object.assign(Object.assign({},_),{base:Object.assign(Object.assign({},_.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class R extends k{get bin(){return this.collectContainer.bin}constructor(t,e){var n,i,o,s,a;super("div",Object.assign(Object.assign({},e),{translations:Object.assign(Object.assign({},null==e?void 0:e.translations),{labels:Object.assign(Object.assign({},null===(n=null==e?void 0:e.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(o=null===(i=null==e?void 0:e.translations)||void 0===i?void 0:i.labels)||void 0===o?void 0:o.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s.storeCardCheckbox},null==e?void 0:e.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=e,this.formFields=[],(null===(a=null==e?void 0:e.styles)||void 0===a?void 0:a.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),T.forEach((({type:t,styles:n,format:i,placeholder:o})=>{var s,a,r,l,d,u,c;if(!(null===(s=this.options)||void 0===s?void 0:s.showCardHolderName)&&t===exports.ElementType.CARDHOLDER_NAME)return;const h=new L(this.collectContainer,{type:t,label:null===(r=null===(a=null==e?void 0:e.translations)||void 0===a?void 0:a.labels)||void 0===r?void 0:r[t],placeholder:(null===(d=null===(l=null==e?void 0:e.translations)||void 0===l?void 0:l.placeholders)||void 0===d?void 0:d[t])||o,labelStyles:this.prepareLabelStyles(t),inputStyles:this.prepareInputStyles(n,t),format:i,events:{onFocus:null===(c=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===c?void 0:c.onFocus,onChange:this.onChange.bind(this),onReady:this.triggerOnReady.bind(this)}});this.formFields.push(h)})),this.subElements.push(this.collectContainer),this.storeInstrumentCheckbox&&this.subElements.push(this.storeInstrumentCheckbox)}show(){this.element.style.display="flex"}hide(){this.element.style.display="none"}triggerOnReady(){var t,e,n;this.formFields.reduce(((t,e)=>t&&e.isReady),!0)&&(null===(n=null===(e=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===e?void 0:e.onReady)||void 0===n||n.call(e))}prepareLabelStyles(t){return["base"].reduce(((e,n)=>{var i,o,s,a,r,l,d,u;return e[n]=Object.assign(Object.assign(Object.assign({},null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.base),null===(r=null===(a=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===a?void 0:a.labels)||void 0===r?void 0:r.all),null===(u=null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.labels)||void 0===u?void 0:u[t]),e}),{})}prepareInputStyles(t,e){var n;let i=JSON.parse(JSON.stringify(t));return(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&e===exports.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),i=Object.assign(Object.assign({},t),{base:Object.assign(Object.assign({},_.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((t=>{var n,o,s,a,r,l,d,u;i[t]=Object.assign(Object.assign(Object.assign({},i[t]),null===(a=null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.inputFields)||void 0===s?void 0:s.all)||void 0===a?void 0:a[t]),null===(u=null===(d=null===(l=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===l?void 0:l.inputFields)||void 0===d?void 0:d[e])||void 0===u?void 0:u[t])})),i}get isValid(){return this.formFields.reduce(((t,e)=>t&&e.isValid),!0)}get cardNetwork(){var t,e;return null!==(e=null===(t=this.formFields.find((t=>Boolean(t.cardNetwork))))||void 0===t?void 0:t.cardNetwork)&&void 0!==e?e:""}onChange(){var t,e,n,i;(null===(e=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===e?void 0:e.onChange)&&(null===(i=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===i||i.onChange({isValid:this.isValid,cardNetwork:this.cardNetwork,bin:this.bin}))}async collectValues(){var t;return{tokenizedCardData:await this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(null===(t=this.options)||void 0===t?void 0:t.enrollInstrumentToNetworkOffers)}}}class L{constructor(t,e){this.isValid=!1,this.isReady=!1,this.cardNetwork="";const{events:n}=e,i=t.createCollectElement(e);(null==n?void 0:n.onFocus)&&i.on("FOCUS",n.onFocus),i.on("READY",(()=>{var t,n;this.isReady=!0,null===(n=null===(t=e.events)||void 0===t?void 0:t.onReady)||void 0===n||n.call(t)})),i.on("CHANGE",(t=>{const{isEmpty:e,isValid:i,network:o}=t;this.isValid=!e&&i,this.cardNetwork=null!=o?o:"",(null==n?void 0:n.onChange)&&n.onChange(this)}))}}class B extends f{constructor(t,e){super("div",{id:"payrails-card-list"}),this.workflowExecution=t,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((t=>{const n=new F((()=>{(null==e?void 0:e.onCardChange)&&e.onCardChange(t)}),t);this.listItems.push(n),this.subElements.push(n)}))}reset(){this.element.querySelectorAll("input").forEach((t=>t.checked=!1))}}class F extends f{constructor(t,e){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${e.id}`});const{id:n}=e,i=this.createCardLabel(e),o=document.createElement("label");o.setAttribute("for",n),o.addEventListener("click",t);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",n),s.setAttribute("value",n),o.appendChild(s);const a=document.createElement("span");a.innerText=i,o.appendChild(a),this.element.appendChild(o)}createCardLabel({data:t={}}){return`****${null==t?void 0:t.suffix}`}}class j extends f{constructor(t="Authorization failed, please try again."){super("div",{id:"authorization-failed-message"}),this.element.innerText=t,this.element.innerHTML=`\n <div>\n <svg class="checkmark-cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark-cross_circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark-cross_check" fill="none" d="M14.1 14.1l23.8 23.8 m0,-23.8 l-23.8,23.8"/>\n </svg>\n </div>\n <div>${t}</div>`,this.element.addEventListener("click",(t=>{t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),this.unmount()}))}}class z extends f{constructor(t){var e;super("div",{id:"payrails-authorization-success-msg"}),this.element.innerHTML=`\n <div class="checkmark-wrapper">\n <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">\n <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>\n <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>\n </svg>\n </div>\n <div id="payrails-authorization-success">${(null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.label)||"Payment successful"}</div`}}class N extends f{constructor(t,e,n){super("div",{id:t,className:"payrails-dropin-item"}),this.events=n,this.isActive=!1;const i=`payrails-dropin-item-${t}`,o=document.createElement("label");o.setAttribute("for",i);const s=document.createElement("input");s.setAttribute("type","radio"),s.setAttribute("name","payment-option"),s.setAttribute("id",i),s.setAttribute("value",i),this.input=s,o.appendChild(s),this.label=o;const a=document.createElement("span");o.appendChild(a),a.innerText=e,this.element.appendChild(o)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var t,e;this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",null===(t=this.component)||void 0===t||t.unmount(),(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}activate(){var t,e;this.isActive||(null===(t=this.component)||void 0===t||t.mount(this.selector),this.label.style.marginBottom="8px",this.isActive=!0,(null===(e=this.events)||void 0===e?void 0:e.onActivate)&&this.events.onActivate())}}class D extends N{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.label.style.marginBottom="8px",this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.label.style.marginBottom="0",this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){super.mount(`#${this.loadElementId}`)}mount(t){const e=document.querySelector(t);if(!e)throw new Error(`Element with selector "${t}" not found in in the DOM`);const n=document.createElement("div");n.setAttribute("id",this.loadElementId),n.setAttribute("style","width: 100%;"),e.appendChild(n)}unmount(){var t;super.unmount(),null===(t=document.querySelector(`#${this.loadElementId}`))||void 0===t||t.remove()}}class M extends D{constructor(t,e,n){var i,o;super("apple-pay-dropin",(null===(o=null===(i=n.translations)||void 0===i?void 0:i.labels)||void 0===o?void 0:o.label)||"Apple Pay"),this.loadElementId="apple-pay-dropin-load-element",this.component=new E(t,e,Object.assign(Object.assign({},n),{events:{onApplePayAvailable:()=>{this.mountAfterAvailable()}}}))}mount(t){const e=document.querySelector(t);if(!e)throw new Error(`Element with selector "${t}" not found in in the DOM`);const n=document.createElement("div");n.setAttribute("id",this.loadElementId),n.setAttribute("style","width: 100%;"),e.appendChild(n)}}class U extends N{constructor(t,e){super("payrails-credit-card-wrapper","Card"),this.cardForm=t,this.paymentButton=e,this.cardFormShown=!1,this.component=new $(t,e)}activate(){var t,e;this.label.style.marginBottom="8px",this.cardFormShown||(this.cardFormShown=!0,null===(t=this.component)||void 0===t||t.mount(this.selector)),this.isActive||(this.paymentButton.selectedInstrument=null,this.paymentButton.mount(this.selector),this.paymentButton.setDisabled(!this.cardForm.isValid),this.paymentButton.mount("#payrails-card-form"),this.input.checked=!0,this.cardForm.show(),this.isActive=!0,(null===(e=this.events)||void 0===e?void 0:e.onActivate)&&this.events.onActivate())}deactivate(){var t;this.isActive&&(this.label.style.marginBottom="0",this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}}class $ extends f{constructor(t,e){super("div",{id:"payrails-form-container"}),this.subElements.push(t,e)}}const V={apiVersion:2,apiVersionMinor:0};class H extends k{constructor(t,e,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-google-pay-button"})),this.sdkConfig=t,this.execution=e,this.options=n,this.googleButton=null,this.paymentExecutor=new p(t,e),this.loadScript=new w((async()=>{const t=document.createElement("script");return t.src="https://pay.google.com/gp/p/js/pay.js",new Promise(((e,n)=>{t.onload=()=>{const t=new google.payments.api.PaymentsClient({environment:this.options.environment||"TEST"}),i=Object.assign(Object.assign({},V),{allowedPaymentMethods:this.execution.googlePayConfig});t.isReadyToPay(i).then((i=>{var o,s,a;i?(null===(a=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onGooglePayAvailable)||void 0===a||a.call(s),e(t)):n()}),n)},t.onerror=()=>{n()},document.body.appendChild(t)}))}))}async sdkLoaded(t){var e,n,i,o,s,a,r,l;try{const d=(null===(n=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(o=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===o?void 0:o.buttonType)||"long",c=(null===(a=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",h=(null===(l=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===l?void 0:l.buttonLocale)||void 0;return this.googleButton=t.createButton({buttonColor:d,buttonType:u,buttonSizeMode:c,buttonLocale:h,onClick:async()=>{var t,e,n;if(null===(e=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===e?void 0:e.onPaymentButtonClicked){if(!await(null===(n=this.options)||void 0===n?void 0:n.events.onPaymentButtonClicked()))return}await this.onPaymentButtonClicked()},allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}catch(t){throw console.error("Google pay can not be initialized",t),new Error(t.message)}}async onLoadPaymentData(t){var e,n,i,o;const s=[{paymentMethodCode:"googlePay",integrationType:"api",paymentInstrumentData:{paymentToken:t.paymentMethodData.tokenizationData.token},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],a=await this.paymentExecutor.pay(s);(null===(n=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&(null===(o=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===o||o.onAuthorizeSuccess(a))}async onPaymentButtonClicked(){var t,e,n,i,o;const s=Object.assign({},V);s.allowedPaymentMethods=this.execution.googlePayConfig,s.transactionInfo={totalPriceStatus:"FINAL",totalPrice:null===(t=this.sdkConfig.amount)||void 0===t?void 0:t.value,currencyCode:null===(e=this.sdkConfig.amount)||void 0===e?void 0:e.currency,countryCode:null===(o=null===(i=null===(n=this.execution.meta)||void 0===n?void 0:n.customer)||void 0===i?void 0:i.country)||void 0===o?void 0:o.code};(await this.loadScript.loader).loadPaymentData(s).then((t=>{this.onLoadPaymentData(t)})).catch((t=>{var e,n,i;(null===(n=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===n?void 0:n.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed(t))}))}mount(t){super.mount(t),(async()=>{var t;try{const e=await this.loadScript.loader,n=await this.sdkLoaded(e);this.element.appendChild(n),null===(t=this.storeInstrumentCheckbox)||void 0===t||t.mount(this.selector)}catch(t){}})()}unmount(){var t,e,n;null===(e=null===(t=this.googleButton)||void 0===t?void 0:t.parentElement)||void 0===e||e.removeChild(this.googleButton),null===(n=this.storeInstrumentCheckbox)||void 0===n||n.unmount(),super.unmount()}}class G extends D{constructor(t,e,n){var i,o;super("google-pay-dropin",(null===(o=null===(i=n.translations)||void 0===i?void 0:i.labels)||void 0===o?void 0:o.label)||"Google Pay"),this.loadElementId="google-pay-dropin-load-element",this.component=new H(t,e,Object.assign(Object.assign({},n),{events:Object.assign(Object.assign({},n.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}mount(t){const e=document.querySelector(t);if(!e)throw new Error(`Element with selector "${t}" not found in in the DOM`);const n=document.createElement("div");n.setAttribute("id",this.loadElementId),n.setAttribute("style","width: 100%;"),e.appendChild(n)}}
|
|
2
2
|
/*!
|
|
3
3
|
* paypal-js v5.1.4 (2022-11-29T23:08:21.847Z)
|
|
4
4
|
* Copyright 2020-present, PayPal, Inc. All rights reserved.
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/function bo(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],i=e["data-merchant-id"],n="",o="";Array.isArray(t)?t.length>1?(n="*",o=t.toString()):n=t.toString():"string"==typeof t&&t.length>0?n=t:"string"==typeof i&&i.length>0&&(n="*",o=i);e["merchant-id"]=n,e["data-merchant-id"]=o}(e);var i=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,i){var n=e[i].toString();return"data-"===i.substring(0,5)?t.dataAttributes[i]=n:t.queryParams[i]=n,t}),{queryParams:{},dataAttributes:{}}),n=i.queryParams,o=i.dataAttributes;return{url:"".concat(t,"?").concat(wo(n)),dataAttributes:o}}function wo(e){var t="";return Object.keys(e).forEach((function(i){0!==t.length&&(t+="&"),t+=i+"="+e[i]})),t}function Mo(e,t){void 0===t&&(t={});var i=document.createElement("script");return i.src=e,Object.keys(t).forEach((function(e){i.setAttribute(e,t[e]),"data-csp-nonce"===e&&i.setAttribute("nonce",t["data-csp-nonce"])})),i}function Po(e,t){if(void 0===t&&(t=Uo()),ko(e,t),"undefined"==typeof window)return t.resolve(null);var i=bo(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Vo(s);return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=Mo(e,t),o=i.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var s=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==n.dataset[e]&&(s=!1)})),s?i:null}(n,o)&&r?t.resolve(r):function(e,t){void 0===t&&(t=Uo());ko(e,t);var i=e.url,n=e.attributes;if("string"!=typeof i||0===i.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new t((function(e,t){if("undefined"==typeof window)return e();!function(e){var t=e.url,i=e.attributes,n=e.onSuccess,o=e.onError,s=Mo(t,i);s.onerror=o,s.onload=n,document.head.insertBefore(s,document.head.firstElementChild)}({url:i,attributes:n,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(i,'" failed to load.'));return window.fetch?fetch(i).then((function(i){return 200===i.status&&t(e),i.text()})).then((function(e){var i=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(i))})).catch((function(e){t(e)})):t(e)}})}))}({url:n,attributes:o},t).then((function(){var e=Vo(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Uo(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Vo(e){return window[e]}function ko(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}class Yo extends ao{constructor(e,i,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(t=this.button)||void 0===t||t.close(),this.paypalLoader=null,this.paypalLoader=new so(this.loadPaypal.bind(this)),this.button=yield this.paypalLoader.loader,this.button.render(`#${this.buttonWrapperId}`),null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onSaveInstrumentCheckboxChanged)||void 0===o||o.call(n,e)}))})})),this.sdkConfig=e,this.execution=i,this.options=n,this.paypalLoader=null,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var e,t,i,n,o,s,r;const a=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=yield this.paymentExecutor.pay(a),d=null===(i=null===(t=null===(e=l.response.links.confirm)||void 0===e?void 0:e.action)||void 0===t?void 0:t.parameters)||void 0===i?void 0:i.orderId;if(!d)throw null===(s=null===(o=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new xo("No order id returned");return this.confirmLink=null===(r=l.response.links.confirm)||void 0===r?void 0:r.href,d})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new f(e,i),this.paypalLoader=new so(this.loadPaypal.bind(this)),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=this.execution.paypalConfig,t=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize",i=yield Po({"client-id":e.clientId,components:"buttons,funding-eligibility",intent:t,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument});if(i){return yield this.createPaypalButton(i)}throw new Error("Paypal not available")}))}createPaypalButton(e){var i,n,o;return t(this,void 0,void 0,(function*(){if(!e.Buttons)throw new Error("Paypal button not available");const t=yield e.Buttons(this.createPayPalButtonConfig());return t.isEligible()?(null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===o||o.call(n),t):null}))}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:()=>t(this,void 0,void 0,(function*(){var e,t,i,n;const o=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=yield this.paymentExecutor.pay(o);return this.confirmLink=null===(e=s.response.links.confirm)||void 0===e?void 0:e.href,(null===(n=null===(i=null===(t=s.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.tokenId)||""}))})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var e,i,n,o,s,r,a,l,d,c;return{fundingSource:"paypal",style:{color:(null===(i=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===i?void 0:i.color)||"gold",height:(null===(o=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.height)||40,label:(null===(r=null===(s=this.options)||void 0===s?void 0:s.styles)||void 0===r?void 0:r.label)||"paypal",shape:(null===(l=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===l?void 0:l.shape)||"rect",tagline:(null===(c=null===(d=this.options)||void 0===d?void 0:d.styles)||void 0===c?void 0:c.tagline)||!1},onError:e=>{var t,i;(null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(e)},onClick:(e,i)=>t(this,void 0,void 0,(function*(){var e,t;if(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onPaymentButtonClicked){return(yield this.options.events.onPaymentButtonClicked())?i.resolve():i.reject()}}))}}approvePayment(e){var i,n,o,s,r,a,l,d,c,E;return t(this,void 0,void 0,(function*(){if(!this.confirmLink)throw null===(o=null===(n=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n),new xo("No confirm link");const t={};this.shouldStoreInstrument&&e.billingToken&&(t.tokenId=e.billingToken),this.fraudNetGuid&&(t.riskSessionCorrelationId=this.fraudNetGuid);const _=yield this.paymentExecutor.confirm(this.confirmLink,t);"authorizeSuccessful"===(null===(s=_.finalState)||void 0===s?void 0:s.code)?null===(l=null===(a=null===(r=this.options)||void 0===r?void 0:r.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===l||l.call(a):null===(E=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===E||E.call(c)}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;this.paypalLoader||(this.paypalLoader=new so(this.loadPaypal.bind(this)));const t=yield this.paypalLoader.loader;this.button=t;try{null===(e=this.storeInstrumentCheckbox)||void 0===e||e.mount(`#${this.checkboxWrapperId}`),yield null==t?void 0:t.render(`#${this.buttonWrapperId}`)}catch(e){throw new Fo(e.message)}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,super.unmount()}}class xo extends Error{constructor(e){super(`PaypalOrderError: ${e}`),this.name="PaypalOrderError"}}class Fo extends Error{constructor(e){super(`PaypalButtonError: ${e}`),this.name="PaypalButtonError"}}class Go extends mo{constructor(e,t,i){var n,o;super("payrails-paypal-button-dropin",(null===(o=null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels)||void 0===o?void 0:o.label)||"PayPal"),this.loadElementId="paypal-dropin-load-element",this.component=new Yo(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Bo extends Ao{constructor(e,t,i){var n,o,s;const r=e.paymentMethod===N.PAYPAL?`${null===(n=e.data)||void 0===n?void 0:n.email}`:`${null===(o=e.data)||void 0===o?void 0:o.bin}**${null===(s=e.data)||void 0===s?void 0:s.suffix}`;super(`payrails-payment-instrument-${e.id}`,r,{onActivate:()=>{i(e),this.component.setDisabled(!1)}}),this.component=t}}class jo extends L{constructor(e,t,i,n,o){var s,r;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=e,this.dropinConfig=t,this.execution=i,this.sdkConfig=n,this.returnLinks=o;void 0!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===r?void 0:r.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const a=new Map;this.execution.storedPaymentInstruments.forEach((e=>{var t;if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton(null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton);const i=new Bo(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}));a.set(i.identifier,i)}})),this.execution.availablePaymentMethods.forEach((({paymentMethodCode:e})=>{var t,i,n,o,s;switch(e){case N.PAYPAL:this.paypal=new Go(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.payPal),{styles:null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.paypalButton,events:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onSaveInstrumentCheckboxChanged:e=>{this.dropinConfig.events.onSaveInstrumentCheckboxChanged&&this.dropinConfig.events.onSaveInstrumentCheckboxChanged(e)}}})),a.set(this.paypal.identifier,this.paypal);break;case N.CARD:this.creditCard=new yo(this.createCardForm(),this.createCardPaymentButton(null===(n=this.dropinConfig.translations)||void 0===n?void 0:n.cardPaymentButton)),a.set(this.creditCard.identifier,this.creditCard);break;case N.GOOGLE_PAY:this.googlePay=new go(this.sdkConfig,this.execution,Object.assign({events:{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:this.dropinConfig.events.onPaymentButtonClicked},styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.googlePayButton},null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.googlePay)),a.set(this.googlePay.identifier,this.googlePay);break;case N.APPLE_PAY:this.applePay=this.createApplePayButton(),a.set(this.applePay.identifier,this.applePay)}})),this.element.addEventListener("change",(e=>{var t,i;const n=(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)||"";a.forEach((e=>{e.deactivate()})),null===(i=a.get(n))||void 0===i||i.activate()})),this.subElements.push(...Array.from(a.values()))}createCardForm(){var e,t;if(!this.cardForm){const i=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,n=Boolean(null==i?void 0:i.showStoreInstrumentCheckbox),o=Boolean(null==i?void 0:i.showCardHolderName),s=Boolean(null==i?void 0:i.alwaysStoreInstrument);this.cardForm=new fo(this.collectContainer,{showStoreInstrumentCheckbox:n,showCardHolderName:o,alwaysStoreInstrument:s,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,events:{onFocus:()=>{var e;null===(e=this.creditCard)||void 0===e||e.activate()},onChange:({isValid:e})=>{var t;null===(t=this.cardPaymentButton)||void 0===t||t.setDisabled(!e)},onSaveInstrumentCheckboxChanged:e=>{this.dropinConfig.events.onSaveInstrumentCheckboxChanged&&this.dropinConfig.events.onSaveInstrumentCheckboxChanged(e)}}})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t;return new Ro(this.sdkConfig,this.execution,Object.assign(Object.assign({events:{onAuthorizeSuccess:e=>{var t;if(e)if("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:this.dropinConfig.events.onPaymentButtonClicked}},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton}))}createCardPaymentButton(e){return this.cardPaymentButton||(this.cardPaymentButton=new A(this.sdkConfig,this.execution,{translations:e,events:Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this)})},this.returnLinks)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n;this.subElements.forEach((e=>e.unmount())),new Lo({translations:{label:null===(i=null===(t=null===(e=this.dropinConfig)||void 0===e?void 0:e.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.success}}).mount(this.selector),(null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}onAuthorizeFailed(e){var t,i,n,o;new Oo(null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail).mount(this.selector),null===(o=null===(n=this.dropinConfig.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n,e)}isStoredInstrumentEnabled(e){var t,i,n,o,s,r;switch(e){case N.CARD:return!1!==(null===(i=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showStoredInstruments)||!1!==(null===(o=null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.cards)||void 0===o?void 0:o.showExistingCards);case N.PAYPAL:case N.GOOGLE_PAY:case N.APPLE_PAY:return!1!==(null===(r=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[e])||void 0===r?void 0:r.showStoredInstruments);default:return!1}}}const Xo=()=>{[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"]].forEach((([e,t])=>{if(!document.getElementById(t)){const i=document.createElement("link");i.id=t,i.rel="preload",i.as="script",i.href=e,document.head.appendChild(i)}}))},$o={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class Wo{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}createCollectElement(e){const t={required:!!e.required,enableCardIcon:!1!==e.enableCardIcon},i=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(e.type)},e),{type:e.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":e.type}),e.format?Object.assign(Object.assign({},t),{format:e.format}):t);return this.attachCustomEventHandler(i)}mount(e){if("COLLECT"===this.containerType)throw new Error("Collect container cannot be mounted");const t="payrails-container-wrapper";this.element=document.createElement("span"),this.element.setAttribute("id",t);const i=document.querySelector(e);if(!i)throw new Error(`Element with selector ${e} does not exist`);i.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${t}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return t(this,void 0,void 0,(function*(){const{records:e}=yield this.__container.collect(),{skyflow_id:t,card_number:i,cardholder_name:n,expiry_month:o,expiry_year:s,security_code:r}=e[0].fields;return{instrumentId:t,card_number:i,cardholder_name:n,expiry_month:o,expiry_year:s,security_code:r}}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),{instrumentId:i,card_number:n,cardholder_name:o,expiry_month:s,expiry_year:r,security_code:a}=t,d=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,c=this.sdkConfig.token,_=this.sdkConfig.holderReference;if(!d)throw new Error("Save instrument URL not available!");const I=yield(({url:e,token:t,instrumentId:i,holderReference:n,providerId:o,providerConfigId:s,meta:r,storeInstrument:a=!1,futureUsage:d="CardOnFile"})=>E({url:e,token:t,method:l.POST,body:{holderReference:n,storeInstrument:a,futureUsage:d,paymentMethod:"card",token:{providerId:o,providerConfigId:s,reference:i,type:"vault",meta:r}}}))({url:d,token:c,instrumentId:i,holderReference:_,providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,meta:{skyflow_id:i,card_number:n,cardholder_name:o,expiry_month:s,expiry_year:r,security_code:a},storeInstrument:e.storeInstrument||!1,futureUsage:e.futureUsage||"CardOnFile"});return I.res}))}attachCustomEventHandler(e){return new Proxy(e,{get:(e,t)=>{if("on"!==t)return e[t];return((i,n)=>{e[t].call(e,i,(e=>{"CHANGE"===i?(e.elementType===exports.ElementType.CARD_NUMBER&&(e.network=function(e){for(const[t,i]of Object.entries($o))if(i.test(e))return t;return""}(e.value),e.bin=this.formatBin(e.value),this.bin=this.formatBin(e.value)),n(e)):n(e)}))}).bind(e)}})}formatBin(e){return e.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Ko{constructor(e,t,i){this.pageId=e,this.sdkConfig=t,this.environment=i,this.guid=c().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=c(),this.scriptId=c(),this.execution=new O(t.execution)}mount(){this.loadFraudnet(this.pageId)}unmount(){var e,t;null===(e=document.getElementById(this.configId))||void 0===e||e.remove(),null===(t=document.getElementById(this.scriptId))||void 0===t||t.remove()}loadFraudnet(e){this.unmount();const t=this.createFraudnetConfig(e);document.body.appendChild(t);const i=document.createElement("script");i.setAttribute("id",this.scriptId),i.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(i)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(e){const t=document.createElement("script");return t.setAttribute("type","application/json"),t.setAttribute("fncls",this.fnclsVal),t.setAttribute("id",this.configId),t.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${e}`,sandbox:"TEST"===this.environment}),t}}class zo{static init(e,t){const i=JSON.parse(atob(e.data)),{vaultConfiguration:{vaultId:n,vaultUrl:o,token:s},execution:r}=i,a=oo.init({vaultID:n,vaultURL:o,getBearerToken:()=>Promise.resolve(s)}),l=new O(r);return l.isPaymentMethodAvailable(N.CARD)&&Xo(),new zo(i,a,l,t)}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout)throw new Error("Layout configuration is required");return this.__container=new Wo(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;if(!this.execution)throw new Error("SDK was not initialized with workflow execution");return new Co(this.sdkConfiguration,this.execution,Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}applePayButton(e){if(!this.execution)throw new Error("SDK was not initialized with workflow execution");return new lo(this.sdkConfiguration,this.execution,e)}cardList(e){return this.__cardList||(this.__cardList=new To(this.execution,{onCardChange:t=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=t,this.__cardPaymentButton.setDisabled(!1)),null==e||e.onCardChange(t)}})),this.__cardList}cardForm(e){var t,i;if(!this.__cardForm){const n=this.getContainerLayout(null==e?void 0:e.showCardHolderName);this.__container=this.collectContainer(Object.assign(Object.assign({layout:n,errorTextStyles:{base:{display:"none"}}},null===(t=null==e?void 0:e.styles)||void 0===t?void 0:t.errorTextStyles),{styles:{base:null===(i=null==e?void 0:e.styles)||void 0===i?void 0:i.base}})),this.__cardForm=new fo(this.__container,Object.assign(Object.assign({},e),{events:Object.assign(Object.assign({},null==e?void 0:e.events),{onChange:t=>{var i;this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(i=null==e?void 0:e.events)||void 0===i?void 0:i.onChange)&&e.events.onChange(t)},onFocus:()=>{var t;this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(t=null==e?void 0:e.events)||void 0===t?void 0:t.onFocus)&&e.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(e){var t,i,n;const o=this.getContainerLayout(null===(i=null===(t=e.paymentMethodsConfiguration)||void 0===t?void 0:t.cards)||void 0===i?void 0:i.showCardHolderName);return this.__container=this.collectContainer({layout:o,errorTextStyles:{base:{display:"none"}}}),new jo(this.__container,e,this.execution,this.sdkConfiguration,(null===(n=this.options)||void 0===n?void 0:n.returnLinks)||{})}getSavedCreditCards(){return this.execution.savedCreditCards}paymentButton(e){var t;return this.__cardPaymentButton||(this.__cardPaymentButton=new A(this.sdkConfiguration,this.execution,e,(null===(t=this.options)||void 0===t?void 0:t.returnLinks)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.__paypalButton=new Yo(this.sdkConfiguration,this.execution,Object.assign(Object.assign({},e),{fraudNetGuid:(null==e?void 0:e.fraudNetGuid)||(null===(t=this.__fraudNet)||void 0===t?void 0:t.guid)})),this.__paypalButton}getSavedPaypalAccounts(){return this.execution.savedPaypalAccounts||[]}fraudNet(e){var t;return this.__fraudNet||(this.__fraudNet=new Ko(e,this.sdkConfiguration,(null===(t=this.options)||void 0===t?void 0:t.environment)||"TEST")),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}constructor(e,t,i,n){var o;this.sdkConfiguration=e,this.vaultClient=t,this.execution=i,this.options=n,(null===(o=null==n?void 0:n.events)||void 0===o?void 0:o.onClientInitialized)&&n.events.onClientInitialized(this.execution)}getContainerLayout(e){return e?[1,1,3]:[1,3]}}zo.preloadCardForm=Xo,exports.Payrails=zo}();
|
|
17
|
+
*/function q(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL),function(t){var e=t["merchant-id"],n=t["data-merchant-id"],i="",o="";Array.isArray(e)?e.length>1?(i="*",o=e.toString()):i=e.toString():"string"==typeof e&&e.length>0?i=e:"string"==typeof n&&n.length>0&&(i="*",o=n);t["merchant-id"]=i,t["data-merchant-id"]=o}(t);var n=Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})).reduce((function(e,n){var i=t[n].toString();return"data-"===n.substring(0,5)?e.dataAttributes[n]=i:e.queryParams[n]=i,e}),{queryParams:{},dataAttributes:{}}),i=n.queryParams,o=n.dataAttributes;return{url:"".concat(e,"?").concat(Y(i)),dataAttributes:o}}function Y(t){var e="";return Object.keys(t).forEach((function(n){0!==e.length&&(e+="&"),e+=n+"="+t[n]})),e}function W(t,e){void 0===e&&(e={});var n=document.createElement("script");return n.src=t,Object.keys(e).forEach((function(t){n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])})),n}function X(t,e){if(void 0===e&&(e=J()),Z(t,e),"undefined"==typeof window)return e.resolve(null);var n=q(t),i=n.url,o=n.dataAttributes,s=o["data-namespace"]||"paypal",a=K(s);return function(t,e){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var i=W(t,e),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(i.dataset).length)return null;var s=!0;return Object.keys(o.dataset).forEach((function(t){o.dataset[t]!==i.dataset[t]&&(s=!1)})),s?n:null}(i,o)&&a?e.resolve(a):function(t,e){void 0===e&&(e=J());Z(t,e);var n=t.url,i=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==i&&"object"!=typeof i)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof window)return t();!function(t){var e=t.url,n=t.attributes,i=t.onSuccess,o=t.onError,s=W(e,n);s.onerror=o,s.onload=i,document.head.insertBefore(s,document.head.firstElementChild)}({url:n,attributes:i,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&e(t),n.text()})).then((function(t){var n=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);e(new Error(n))})).catch((function(t){e(t)})):e(t)}})}))}({url:i,attributes:o},e).then((function(){var t=K(s);if(t)return t;throw new Error("The window.".concat(s," global variable is not available."))}))}function J(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function K(t){return window[t]}function Z(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}class Q extends k{constructor(t,e,n){super("div",Object.assign(Object.assign({},n),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==n?void 0:n.events),{onSaveInstrumentCheckboxChanged:async t=>{var e,n,i,o;null===(e=this.button)||void 0===e||e.close(),this.paypalLoader=null,this.paypalLoader=new w(this.loadPaypal.bind(this)),this.button=await this.paypalLoader.loader,this.button.render(`#${this.buttonWrapperId}`),null===(o=null===(i=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===o||o.call(i,t)}})})),this.sdkConfig=t,this.execution=e,this.options=n,this.paypalLoader=null,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=async()=>{var t,e,n,i,o,s,a;const r=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],l=await this.paymentExecutor.pay(r),d=null===(n=null===(e=null===(t=l.response.links.confirm)||void 0===t?void 0:t.action)||void 0===e?void 0:e.parameters)||void 0===n?void 0:n.orderId;if(!d)throw null===(s=null===(o=null===(i=this.options)||void 0===i?void 0:i.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o),new tt("No order id returned");return this.confirmLink=null===(a=l.response.links.confirm)||void 0===a?void 0:a.href,d},this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new p(t,e),this.paypalLoader=new w(this.loadPaypal.bind(this)),this.fraudNetGuid=null==n?void 0:n.fraudNetGuid}async loadPaypal(){const t=this.execution.paypalConfig,e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize",n=await X({"client-id":t.clientId,components:"buttons,funding-eligibility",intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument,"data-namespace":"payrailsPaypal"});if(n){return await this.createPaypalButton(n)}throw new Error("Paypal not available")}async createPaypalButton(t){var e,n,i;if(!t.Buttons)throw new Error("Paypal button not available");const o=await t.Buttons(this.createPayPalButtonConfig());return o.isEligible()?(null===(i=null===(n=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===n?void 0:n.onPaypalAvailable)||void 0===i||i.call(n),o):null}createPayPalButtonConfig(){return this.shouldStoreInstrument?this.createBillingAgreementConfig():this.createOneTimeOrderConfig()}createBillingAgreementConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{onApprove:this.approvePayment.bind(this),createBillingAgreement:async()=>{var t,e,n,i;const o=[{paymentMethodCode:"payPal",integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],s=await this.paymentExecutor.pay(o);return this.confirmLink=null===(t=s.response.links.confirm)||void 0===t?void 0:t.href,(null===(i=null===(n=null===(e=s.response.links.confirm)||void 0===e?void 0:e.action)||void 0===n?void 0:n.parameters)||void 0===i?void 0:i.tokenId)||""}})}createOneTimeOrderConfig(){return Object.assign(Object.assign({},this.createBaseConfig()),{createOrder:this.createOneTimeOrder.bind(this),onApprove:this.approvePayment.bind(this)})}createBaseConfig(){var t,e,n,i,o,s,a,r,l,d;return{fundingSource:"paypal",style:{color:(null===(e=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===e?void 0:e.color)||"gold",height:(null===(i=null===(n=this.options)||void 0===n?void 0:n.styles)||void 0===i?void 0:i.height)||40,label:(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.label)||"paypal",shape:(null===(r=null===(a=this.options)||void 0===a?void 0:a.styles)||void 0===r?void 0:r.shape)||"rect",tagline:(null===(d=null===(l=this.options)||void 0===l?void 0:l.styles)||void 0===d?void 0:d.tagline)||!1},onError:t=>{var e,n;(null===(n=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===n?void 0:n.onAuthorizeFailed)&&this.options.events.onAuthorizeFailed(t)},onClick:async(t,e)=>{var n,i;if(null===(i=null===(n=this.options)||void 0===n?void 0:n.events)||void 0===i?void 0:i.onPaymentButtonClicked){return await this.options.events.onPaymentButtonClicked()?e.resolve():e.reject()}}}}async approvePayment(t){var e,n,i,o,s,a,r,l,d,u;if(!this.confirmLink)throw null===(i=null===(n=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===i||i.call(n),new tt("No confirm link");const c={};this.shouldStoreInstrument&&t.billingToken&&(c.tokenId=t.billingToken),this.fraudNetGuid&&(c.riskSessionCorrelationId=this.fraudNetGuid);"authorizeSuccessful"===(null===(o=(await this.paymentExecutor.confirm(this.confirmLink,c)).finalState)||void 0===o?void 0:o.code)?null===(r=null===(a=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===a?void 0:a.onAuthorizeSuccess)||void 0===r||r.call(a):null===(u=null===(d=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===d?void 0:d.onAuthorizeFailed)||void 0===u||u.call(d)}mount(t){super.mount(t),(async()=>{var t;this.paypalLoader||(this.paypalLoader=new w(this.loadPaypal.bind(this)));const e=await this.paypalLoader.loader;this.button=e;try{null===(t=this.storeInstrumentCheckbox)||void 0===t||t.mount(`#${this.checkboxWrapperId}`),await(null==e?void 0:e.render(`#${this.buttonWrapperId}`))}catch(t){throw new et(t.message)}})()}unmount(){var t;null===(t=this.button)||void 0===t||t.close(),this.paypalLoader=null,super.unmount()}}class tt extends Error{constructor(t){super(`PaypalOrderError: ${t}`),this.name="PaypalOrderError"}}class et extends Error{constructor(t){super(`PaypalButtonError: ${t}`),this.name="PaypalButtonError"}}class nt extends D{constructor(t,e,n){var i,o;super("payrails-paypal-button-dropin",(null===(o=null===(i=null==n?void 0:n.translations)||void 0===i?void 0:i.labels)||void 0===o?void 0:o.label)||"PayPal"),this.loadElementId="paypal-dropin-load-element",this.component=new Q(t,e,Object.assign(Object.assign({},n),{events:Object.assign(Object.assign({},null==n?void 0:n.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class it extends N{constructor(t,e,n){var i,o,s;const a=t.paymentMethod===m.PAYPAL?`${null===(i=t.data)||void 0===i?void 0:i.email}`:`${null===(o=t.data)||void 0===o?void 0:o.bin}**${null===(s=t.data)||void 0===s?void 0:s.suffix}`;super(`payrails-payment-instrument-${t.id}`,a,{onActivate:()=>{n(t),this.component.setDisabled(!1)}}),this.component=e}}class ot extends f{constructor(t,e,n,i,o){var s,a;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=t,this.dropinConfig=e,this.execution=n,this.sdkConfig=i,this.returnLinks=o;void 0!==(null===(a=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.cards)||void 0===a?void 0:a.showExistingCards)&&console.warn("The `showExistingCards` option is deprecated and will be removed in a future version. Please use `showStoredInstruments` instead.");const r=new Map;this.execution.storedPaymentInstruments.forEach((t=>{var e;if(this.isStoredInstrumentEnabled(t.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton(null===(e=this.dropinConfig.translations)||void 0===e?void 0:e.cardPaymentButton);const n=new it(t,this.cardPaymentButton,(t=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=t)}));r.set(n.identifier,n)}})),this.execution.availablePaymentMethods.forEach((({paymentMethodCode:t})=>{var e,n,i,o,s,a;switch(t){case m.PAYPAL:this.paypal=new nt(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.paypalButton,events:{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onSaveInstrumentCheckboxChanged:t=>{this.dropinConfig.events.onSaveInstrumentCheckboxChanged&&this.dropinConfig.events.onSaveInstrumentCheckboxChanged(t)}}})),r.set(this.paypal.identifier,this.paypal);break;case m.CARD:this.creditCard=new U(this.createCardForm(),this.createCardPaymentButton(null===(i=this.dropinConfig.translations)||void 0===i?void 0:i.cardPaymentButton)),r.set(this.creditCard.identifier,this.creditCard);break;case m.GOOGLE_PAY:this.googlePay=new G(this.sdkConfig,this.execution,Object.assign({events:{onAuthorizeSuccess:t=>{var e;if(t)if("authorizeSuccessful"===(null===(e=null==t?void 0:t.finalState)||void 0===e?void 0:e.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:this.dropinConfig.events.onPaymentButtonClicked},styles:null===(o=this.dropinConfig.styles)||void 0===o?void 0:o.googlePayButton},null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s.googlePay)),r.set(this.googlePay.identifier,this.googlePay);break;case m.APPLE_PAY:this.applePay=new M(this.sdkConfig,this.execution,Object.assign({events:{onAuthorizeSuccess:t=>{var e;if(t)if("authorizeSuccessful"===(null===(e=null==t?void 0:t.finalState)||void 0===e?void 0:e.code))this.onAuthorizeSuccess();else this.onAuthorizeFailed()},onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onPaymentButtonClicked:this.dropinConfig.events.onPaymentButtonClicked}},null===(a=this.dropinConfig.paymentMethodsConfiguration)||void 0===a?void 0:a.applePay)),r.set(this.applePay.identifier,this.applePay)}})),this.element.addEventListener("change",(t=>{var e,n;const i=(null===(e=null==t?void 0:t.target)||void 0===e?void 0:e.value)||"";r.forEach((t=>{t.deactivate()})),null===(n=r.get(i))||void 0===n||n.activate()})),this.subElements.push(...Array.from(r.values()))}createCardForm(){var t,e;if(!this.cardForm){const n=null===(t=this.dropinConfig.paymentMethodsConfiguration)||void 0===t?void 0:t.cards,i=Boolean(null==n?void 0:n.showStoreInstrumentCheckbox),o=Boolean(null==n?void 0:n.showCardHolderName),s=Boolean(null==n?void 0:n.alwaysStoreInstrument);this.cardForm=new R(this.collectContainer,{showStoreInstrumentCheckbox:i,showCardHolderName:o,alwaysStoreInstrument:s,translations:null===(e=this.dropinConfig.translations)||void 0===e?void 0:e.cardForm,events:{onFocus:()=>{var t;null===(t=this.creditCard)||void 0===t||t.activate()},onChange:({isValid:t})=>{var e;null===(e=this.cardPaymentButton)||void 0===e||e.setDisabled(!t)},onSaveInstrumentCheckboxChanged:t=>{this.dropinConfig.events.onSaveInstrumentCheckboxChanged&&this.dropinConfig.events.onSaveInstrumentCheckboxChanged(t)}}})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createCardPaymentButton(t){return this.cardPaymentButton||(this.cardPaymentButton=new C(this.sdkConfig,this.execution,{translations:t,events:Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this)})},this.returnLinks)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var t,e,n,i;this.subElements.forEach((t=>t.unmount())),new z({translations:{label:null===(n=null===(e=null===(t=this.dropinConfig)||void 0===t?void 0:t.translations)||void 0===e?void 0:e.paymentResult)||void 0===n?void 0:n.success}}).mount(this.selector),(null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}onAuthorizeFailed(t){var e,n,i,o;new j(null===(n=null===(e=this.dropinConfig.translations)||void 0===e?void 0:e.paymentResult)||void 0===n?void 0:n.fail).mount(this.selector),null===(o=null===(i=this.dropinConfig.events)||void 0===i?void 0:i.onAuthorizeFailed)||void 0===o||o.call(i,t)}isStoredInstrumentEnabled(t){var e,n,i,o,s,a;switch(t){case m.CARD:return!1!==(null===(n=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards)||void 0===n?void 0:n.showStoredInstruments)||!1!==(null===(o=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===o?void 0:o.showExistingCards);case m.PAYPAL:case m.GOOGLE_PAY:case m.APPLE_PAY:return!1!==(null===(a=null===(s=this.dropinConfig.paymentMethodsConfiguration)||void 0===s?void 0:s[t])||void 0===a?void 0:a.showStoredInstruments);default:return!1}}}const st=()=>{[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"]].forEach((([t,e])=>{if(!document.getElementById(e)){const n=document.createElement("link");n.id=e,n.rel="preload",n.as="script",n.href=t,document.head.appendChild(n)}}))},at={visa:/^4\d*/,mastercard:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,amex:/^3[47]\d*/,diners:/^(36|38|30[0-5])\d*/,discover:/^(6011|65|64[4-9]|622)\d*/,jcb:/^35\d*/,hipercard:/^606282\d*/,unionpay:/^62\d*/,maestro:/^(5018|5020|5038|5043|5[6-9]|6020|6304|6703|6759|676[1-3])\d*/};class rt{constructor(t,e,n){this.sdkConfig=n,this.bin="",this.containerType="COMPOSABLE",this.cardTableName=e.cardTableName||"cards",this.containerType=e.containerType||"COMPOSABLE",this.__container=t.container(this.containerType,e)}createCollectElement(t){const e={required:!!t.required,enableCardIcon:!1!==t.enableCardIcon},n=this.__container.create(Object.assign(Object.assign({table:this.cardTableName,labelStyles:{},errorTextStyles:{},column:this.elementToFieldMap.get(t.type)},t),{type:t.type===exports.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},e),{format:t.format}):e);return this.attachCustomEventHandler(n)}mount(t){if("COLLECT"===this.containerType)throw new Error("Collect container cannot be mounted");const e="payrails-container-wrapper";this.element=document.createElement("span"),this.element.setAttribute("id",e);const n=document.querySelector(t);if(!n)throw new Error(`Element with selector ${t} does not exist`);n.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${e}`)}),50)}unmount(){this.element&&this.element.remove()}async collect(){const{records:t}=await this.__container.collect(),{skyflow_id:e,card_number:n,cardholder_name:i,expiry_month:o,expiry_year:s,security_code:a}=t[0].fields;return{instrumentId:e,card_number:n,cardholder_name:i,expiry_month:o,expiry_year:s,security_code:a}}async tokenize(t){const e=await this.collect(),{instrumentId:n,card_number:i,cardholder_name:o,expiry_month:a,expiry_year:r,security_code:d}=e,u=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,c=this.sdkConfig.token,h=this.sdkConfig.holderReference;if(!u)throw new Error("Save instrument URL not available!");const v=await(({url:t,token:e,instrumentId:n,holderReference:i,providerId:o,providerConfigId:a,meta:r,storeInstrument:d=!1,futureUsage:u="CardOnFile"})=>l({url:t,token:e,method:s.POST,body:{holderReference:i,storeInstrument:d,futureUsage:u,paymentMethod:"card",token:{providerId:o,providerConfigId:a,reference:n,type:"vault",meta:r}}}))({url:u,token:c,instrumentId:n,holderReference:h,providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,meta:{skyflow_id:n,card_number:i,cardholder_name:o,expiry_month:a,expiry_year:r,security_code:d},storeInstrument:t.storeInstrument||!1,futureUsage:t.futureUsage||"CardOnFile"});return v.res}attachCustomEventHandler(t){return new Proxy(t,{get:(t,e)=>{if("on"!==e)return t[e];return((n,i)=>{t[e].call(t,n,(t=>{"CHANGE"===n?(t.elementType===exports.ElementType.CARD_NUMBER&&(t.network=function(t){for(const[e,n]of Object.entries(at))if(n.test(t))return e;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),i(t)):i(t)}))}).bind(t)}})}formatBin(t){return t.replace(/-|X/g,"")}get elementToFieldMap(){return new Map([[exports.ElementType.CARD_NUMBER,"card_number"],[exports.ElementType.CARDHOLDER_NAME,"cardholder_name"],[exports.ElementType.CVV,"security_code"],[exports.ElementType.EXPIRATION_MONTH,"expiry_month"],[exports.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class lt{constructor(t,e,n){this.pageId=t,this.sdkConfig=e,this.environment=n,this.guid=r().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=r(),this.scriptId=r(),this.execution=new b(e.execution)}mount(){this.loadFraudnet(this.pageId)}unmount(){var t,e;null===(t=document.getElementById(this.configId))||void 0===t||t.remove(),null===(e=document.getElementById(this.scriptId))||void 0===e||e.remove()}loadFraudnet(t){this.unmount();const e=this.createFraudnetConfig(t);document.body.appendChild(e);const n=document.createElement("script");n.setAttribute("id",this.scriptId),n.src="https://c.paypal.com/da/r/fb.js",document.body.appendChild(n)}get payPalConfig(){return this.execution.paypalConfig}createFraudnetConfig(t){const e=document.createElement("script");return e.setAttribute("type","application/json"),e.setAttribute("fncls",this.fnclsVal),e.setAttribute("id",this.configId),e.innerText=JSON.stringify({f:this.guid,s:`${this.payPalConfig.merchantId}_${t}`,sandbox:"TEST"===this.environment}),e}}var dt=require("skyflow-js").default;class ut{static init(t,e){const n=JSON.parse(atob(t.data)),{vaultConfiguration:{vaultId:i,vaultUrl:o,token:s},execution:a}=n,r=dt.init({vaultID:i,vaultURL:o,getBearerToken:()=>Promise.resolve(s)}),l=new b(a);return l.isPaymentMethodAvailable(m.CARD)&&st(),new ut(n,r,l,e)}update(t){this.sdkConfiguration.amount=t}collectContainer(t){if("COMPOSABLE"===t.containerType&&!t.layout)throw new Error("Layout configuration is required");return this.__container=new rt(this.vaultClient,Object.assign(Object.assign({},t),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(t){var e;if(!this.execution)throw new Error("SDK was not initialized with workflow execution");return new H(this.sdkConfiguration,this.execution,Object.assign({environment:null===(e=this.options)||void 0===e?void 0:e.environment},t))}applePayButton(t){if(!this.execution)throw new Error("SDK was not initialized with workflow execution");return new E(this.sdkConfiguration,this.execution,t)}cardList(t){return this.__cardList||(this.__cardList=new B(this.execution,{onCardChange:e=>{this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=e,this.__cardPaymentButton.setDisabled(!1)),null==t||t.onCardChange(e)}})),this.__cardList}cardForm(t){var e,n;if(!this.__cardForm){const i=this.getContainerLayout(null==t?void 0:t.showCardHolderName);this.__container=this.collectContainer(Object.assign(Object.assign({layout:i,errorTextStyles:{base:{display:"none"}}},null===(e=null==t?void 0:t.styles)||void 0===e?void 0:e.errorTextStyles),{styles:{base:null===(n=null==t?void 0:t.styles)||void 0===n?void 0:n.base}})),this.__cardForm=new R(this.__container,Object.assign(Object.assign({},t),{events:Object.assign(Object.assign({},null==t?void 0:t.events),{onChange:e=>{var n;this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(n=null==t?void 0:t.events)||void 0===n?void 0:n.onChange)&&t.events.onChange(e)},onFocus:()=>{var e;this.__cardList&&this.__cardList.reset(),this.__cardPaymentButton&&(this.__cardPaymentButton.selectedInstrument=null,this.__cardForm&&this.__cardPaymentButton.setDisabled(!this.__cardForm.isValid)),(null===(e=null==t?void 0:t.events)||void 0===e?void 0:e.onFocus)&&t.events.onFocus()}})}))}return this.__cardPaymentButton&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardForm}dropin(t){var e,n,i;const o=this.getContainerLayout(null===(n=null===(e=t.paymentMethodsConfiguration)||void 0===e?void 0:e.cards)||void 0===n?void 0:n.showCardHolderName);return this.__container=this.collectContainer({layout:o,errorTextStyles:{base:{display:"none"}}}),new ot(this.__container,t,this.execution,this.sdkConfiguration,(null===(i=this.options)||void 0===i?void 0:i.returnLinks)||{})}getSavedCreditCards(){return this.execution.savedCreditCards}paymentButton(t){var e;return this.__cardPaymentButton||(this.__cardPaymentButton=new C(this.sdkConfiguration,this.execution,t,(null===(e=this.options)||void 0===e?void 0:e.returnLinks)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(t){var e;return this.__paypalButton=new Q(this.sdkConfiguration,this.execution,Object.assign(Object.assign({},t),{fraudNetGuid:(null==t?void 0:t.fraudNetGuid)||(null===(e=this.__fraudNet)||void 0===e?void 0:e.guid)})),this.__paypalButton}getSavedPaypalAccounts(){return this.execution.savedPaypalAccounts||[]}fraudNet(t){var e;return this.__fraudNet||(this.__fraudNet=new lt(t,this.sdkConfiguration,(null===(e=this.options)||void 0===e?void 0:e.environment)||"TEST")),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}constructor(t,e,n,i){var o;this.sdkConfiguration=t,this.vaultClient=e,this.execution=n,this.options=i,(null===(o=null==i?void 0:i.events)||void 0===o?void 0:o.onClientInitialized)&&i.events.onClientInitialized(this.execution)}getContainerLayout(t){return t?[1,1,3]:[1,3]}}ut.preloadCardForm=st,exports.Payrails=ut}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payrails/web-sdk",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.11-RC.0",
|
|
4
4
|
"description": "SDK providing tokenization options on the client for merchants",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "payrails.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@types/applepayjs": "3.0.4",
|
|
13
|
-
"@types/googlepay": "0.7.1"
|
|
13
|
+
"@types/googlepay": "0.7.1",
|
|
14
|
+
"skyflow-js": "1.30.0"
|
|
14
15
|
}
|
|
15
16
|
}
|
package/payrails.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="applepayjs" />
|
|
2
2
|
/// <reference types="googlepay" />
|
|
3
|
+
import Skyflow from 'skyflow-js';
|
|
4
|
+
|
|
3
5
|
interface SaveInstrumentResponse {
|
|
4
6
|
id: string;
|
|
5
7
|
createdAt: string;
|
|
@@ -29,313 +31,6 @@ interface SaveInstrumentResponse {
|
|
|
29
31
|
futureUsage?: string;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
declare enum ElementType$1 {
|
|
33
|
-
CVV = "CVV",
|
|
34
|
-
EXPIRATION_DATE = "EXPIRATION_DATE",
|
|
35
|
-
CARD_NUMBER = "CARD_NUMBER",
|
|
36
|
-
CARDHOLDER_NAME = "CARDHOLDER_NAME",
|
|
37
|
-
INPUT_FIELD = "INPUT_FIELD",
|
|
38
|
-
PIN = "PIN",
|
|
39
|
-
EXPIRATION_MONTH = "EXPIRATION_MONTH",
|
|
40
|
-
EXPIRATION_YEAR = "EXPIRATION_YEAR",
|
|
41
|
-
FILE_INPUT = "FILE_INPUT"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
declare enum RedactionType {
|
|
45
|
-
DEFAULT = "DEFAULT",
|
|
46
|
-
PLAIN_TEXT = "PLAIN_TEXT",
|
|
47
|
-
MASKED = "MASKED",
|
|
48
|
-
REDACTED = "REDACTED"
|
|
49
|
-
}
|
|
50
|
-
declare enum RequestMethod {
|
|
51
|
-
GET = "GET",
|
|
52
|
-
POST = "POST",
|
|
53
|
-
PUT = "PUT",
|
|
54
|
-
PATCH = "PATCH",
|
|
55
|
-
DELETE = "DELETE"
|
|
56
|
-
}
|
|
57
|
-
declare enum EventName {
|
|
58
|
-
CHANGE = "CHANGE",
|
|
59
|
-
READY = "READY",
|
|
60
|
-
FOCUS = "FOCUS",
|
|
61
|
-
BLUR = "BLUR",
|
|
62
|
-
SUBMIT = "SUBMIT"
|
|
63
|
-
}
|
|
64
|
-
declare enum LogLevel {
|
|
65
|
-
WARN = "WARN",
|
|
66
|
-
INFO = "INFO",
|
|
67
|
-
DEBUG = "DEBUG",
|
|
68
|
-
ERROR = "ERROR"
|
|
69
|
-
}
|
|
70
|
-
declare enum Env {
|
|
71
|
-
DEV = "DEV",
|
|
72
|
-
PROD = "PROD"
|
|
73
|
-
}
|
|
74
|
-
declare enum ValidationRuleType {
|
|
75
|
-
REGEX_MATCH_RULE = "REGEX_MATCH_RULE",
|
|
76
|
-
LENGTH_MATCH_RULE = "LENGTH_MATCH_RULE",
|
|
77
|
-
ELEMENT_VALUE_MATCH_RULE = "ELEMENT_VALUE_MATCH_RULE"
|
|
78
|
-
}
|
|
79
|
-
interface IInsertRecordInput {
|
|
80
|
-
records: IInsertRecord[];
|
|
81
|
-
}
|
|
82
|
-
interface IInsertRecord {
|
|
83
|
-
table: string;
|
|
84
|
-
fields: Record<string, any>;
|
|
85
|
-
skyflowID?: string;
|
|
86
|
-
}
|
|
87
|
-
interface IRevealRecord {
|
|
88
|
-
token: string;
|
|
89
|
-
redaction?: RedactionType;
|
|
90
|
-
}
|
|
91
|
-
interface IRevealResponseType {
|
|
92
|
-
records?: Record<string, string>[];
|
|
93
|
-
errors?: Record<string, any>[];
|
|
94
|
-
}
|
|
95
|
-
interface IDetokenizeInput {
|
|
96
|
-
records: IRevealRecord[];
|
|
97
|
-
}
|
|
98
|
-
interface IGetRecord {
|
|
99
|
-
ids?: string[];
|
|
100
|
-
redaction: RedactionType;
|
|
101
|
-
table: string;
|
|
102
|
-
columnName?: string;
|
|
103
|
-
columnValues?: string[];
|
|
104
|
-
}
|
|
105
|
-
interface IGetInput {
|
|
106
|
-
records: IGetRecord[];
|
|
107
|
-
}
|
|
108
|
-
interface ISkyflowIdRecord {
|
|
109
|
-
ids: string[];
|
|
110
|
-
redaction: RedactionType;
|
|
111
|
-
table: string;
|
|
112
|
-
}
|
|
113
|
-
interface IGetByIdInput {
|
|
114
|
-
records: ISkyflowIdRecord[];
|
|
115
|
-
}
|
|
116
|
-
interface Context {
|
|
117
|
-
logLevel: LogLevel;
|
|
118
|
-
env: Env;
|
|
119
|
-
}
|
|
120
|
-
interface IValidationRule {
|
|
121
|
-
type: ValidationRuleType;
|
|
122
|
-
params: any;
|
|
123
|
-
}
|
|
124
|
-
interface IUpsertOption {
|
|
125
|
-
table: string;
|
|
126
|
-
column: string;
|
|
127
|
-
}
|
|
128
|
-
interface IInsertOptions {
|
|
129
|
-
tokens?: boolean;
|
|
130
|
-
upsert?: IUpsertOption[];
|
|
131
|
-
}
|
|
132
|
-
interface IDeleteRecord {
|
|
133
|
-
id: String;
|
|
134
|
-
table: String;
|
|
135
|
-
}
|
|
136
|
-
interface IDeleteOptions {
|
|
137
|
-
}
|
|
138
|
-
interface IDeleteRecordInput {
|
|
139
|
-
options?: IDeleteOptions;
|
|
140
|
-
records: IDeleteRecord[];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
interface IUpsertOptions {
|
|
144
|
-
table: string;
|
|
145
|
-
column: string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
declare abstract class Container {
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
declare class EventEmitter {
|
|
152
|
-
events: Record<string, {
|
|
153
|
-
priority: boolean;
|
|
154
|
-
callback: Function;
|
|
155
|
-
}[]>;
|
|
156
|
-
constructor();
|
|
157
|
-
on(event: string, callback: Function, priority?: boolean): void;
|
|
158
|
-
off(event: string, callback: Function): void;
|
|
159
|
-
_emit(event: string, ...args: any[]): void;
|
|
160
|
-
hasListener(event: string): boolean;
|
|
161
|
-
resetEvents(): void;
|
|
162
|
-
static createChild(ChildObject: any): void;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
declare abstract class SkyflowElement {
|
|
166
|
-
abstract mount(domElementSelector: any): any;
|
|
167
|
-
abstract unmount(): any;
|
|
168
|
-
abstract setError(clientErrorText: string): any;
|
|
169
|
-
abstract resetError(): any;
|
|
170
|
-
abstract iframeName(): any;
|
|
171
|
-
abstract getID(): any;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
declare class CollectElement extends SkyflowElement {
|
|
175
|
-
#private;
|
|
176
|
-
elementType: string;
|
|
177
|
-
type: string;
|
|
178
|
-
containerId: string;
|
|
179
|
-
constructor(elementId: string, elementGroup: any, metaData: any, container: any, isSingleElementAPI: boolean | undefined, destroyCallback: Function, updateCallback: Function, context: Context, groupEventEmitter?: EventEmitter);
|
|
180
|
-
getID: () => string;
|
|
181
|
-
mount: (domElement: any) => void;
|
|
182
|
-
unmount: () => void;
|
|
183
|
-
update: (group: any) => void;
|
|
184
|
-
updateElement: (elementOptions: any) => void;
|
|
185
|
-
getState: () => {
|
|
186
|
-
isEmpty: boolean;
|
|
187
|
-
isComplete: boolean;
|
|
188
|
-
isValid: boolean;
|
|
189
|
-
isFocused: boolean;
|
|
190
|
-
value: string | Object | Blob | undefined;
|
|
191
|
-
required: boolean;
|
|
192
|
-
};
|
|
193
|
-
getOptions: () => any;
|
|
194
|
-
on(eventName: string, handler: any): void;
|
|
195
|
-
iframeName(): string;
|
|
196
|
-
isMounted(): boolean;
|
|
197
|
-
isValidElement(): boolean;
|
|
198
|
-
setError(clientErrorText: string): void;
|
|
199
|
-
resetError(): void;
|
|
200
|
-
setValue(elementValue: string): void;
|
|
201
|
-
clearValue(): void;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
interface CollectElementInput$1 {
|
|
205
|
-
table?: string;
|
|
206
|
-
column?: string;
|
|
207
|
-
inputStyles?: object;
|
|
208
|
-
label?: string;
|
|
209
|
-
labelStyles?: object;
|
|
210
|
-
errorTextStyles?: object;
|
|
211
|
-
placeholder?: string;
|
|
212
|
-
type: ElementType$1;
|
|
213
|
-
altText?: string;
|
|
214
|
-
validations?: IValidationRule[];
|
|
215
|
-
skyflowID?: string;
|
|
216
|
-
}
|
|
217
|
-
interface ICollectOptions$1 {
|
|
218
|
-
tokens?: boolean;
|
|
219
|
-
additionalFields?: IInsertRecordInput;
|
|
220
|
-
upsert?: Array<IUpsertOptions>;
|
|
221
|
-
}
|
|
222
|
-
declare class CollectContainer extends Container {
|
|
223
|
-
#private;
|
|
224
|
-
type: string;
|
|
225
|
-
constructor(options: any, metaData: any, skyflowElements: any, context: any);
|
|
226
|
-
create: (input: CollectElementInput$1, options?: any) => CollectElement;
|
|
227
|
-
collect: (options?: ICollectOptions$1) => Promise<unknown>;
|
|
228
|
-
uploadFiles: (options: any) => Promise<unknown>;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
declare class ComposableElement {
|
|
232
|
-
#private;
|
|
233
|
-
type: string;
|
|
234
|
-
constructor(name: any, eventEmitter: any);
|
|
235
|
-
on(eventName: string, handler: any): void;
|
|
236
|
-
update: (options: any) => void;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
interface CollectElementInput {
|
|
240
|
-
table?: string;
|
|
241
|
-
column?: string;
|
|
242
|
-
inputStyles?: object;
|
|
243
|
-
label?: string;
|
|
244
|
-
labelStyles?: object;
|
|
245
|
-
errorTextStyles?: object;
|
|
246
|
-
placeholder?: string;
|
|
247
|
-
type: ElementType$1;
|
|
248
|
-
altText?: string;
|
|
249
|
-
validations?: IValidationRule[];
|
|
250
|
-
skyflowID?: string;
|
|
251
|
-
}
|
|
252
|
-
interface ICollectOptions {
|
|
253
|
-
tokens?: boolean;
|
|
254
|
-
additionalFields?: IInsertRecordInput;
|
|
255
|
-
upsert?: Array<IUpsertOptions>;
|
|
256
|
-
}
|
|
257
|
-
declare class ComposableContainer extends Container {
|
|
258
|
-
#private;
|
|
259
|
-
type: string;
|
|
260
|
-
constructor(options: any, metaData: any, skyflowElements: any, context: any);
|
|
261
|
-
create: (input: CollectElementInput, options?: any) => ComposableElement;
|
|
262
|
-
on: (eventName: string, handler: any) => void;
|
|
263
|
-
mount: (domElement: any) => void;
|
|
264
|
-
unmount: () => void;
|
|
265
|
-
collect: (options?: ICollectOptions) => Promise<unknown>;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
declare class RevealElement extends SkyflowElement {
|
|
269
|
-
#private;
|
|
270
|
-
constructor(record: IRevealElementInput, options: IRevealElementOptions | undefined, metaData: any, container: any, elementId: string, context: Context);
|
|
271
|
-
getID(): string;
|
|
272
|
-
mount(domElementSelector: any): void;
|
|
273
|
-
iframeName(): string;
|
|
274
|
-
isMounted(): boolean;
|
|
275
|
-
hasToken(): boolean;
|
|
276
|
-
isClientSetError(): boolean;
|
|
277
|
-
getRecordData(): any;
|
|
278
|
-
setError(clientErrorText: string): void;
|
|
279
|
-
resetError(): void;
|
|
280
|
-
setAltText(altText: string): void;
|
|
281
|
-
clearAltText(): void;
|
|
282
|
-
setToken(token: string): void;
|
|
283
|
-
unmount(): void;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
interface IRevealElementInput {
|
|
287
|
-
token?: string;
|
|
288
|
-
redaction?: RedactionType;
|
|
289
|
-
inputStyles?: object;
|
|
290
|
-
label?: string;
|
|
291
|
-
labelStyles?: object;
|
|
292
|
-
altText?: string;
|
|
293
|
-
errorTextStyles?: object;
|
|
294
|
-
}
|
|
295
|
-
interface IRevealElementOptions {
|
|
296
|
-
enableCopy?: boolean;
|
|
297
|
-
format?: string;
|
|
298
|
-
translation?: Record<string, string>;
|
|
299
|
-
}
|
|
300
|
-
declare class RevealContainer extends Container {
|
|
301
|
-
#private;
|
|
302
|
-
type: string;
|
|
303
|
-
constructor(metaData: any, skyflowElements: any, context: any);
|
|
304
|
-
create(record: IRevealElementInput, options?: IRevealElementOptions): RevealElement;
|
|
305
|
-
reveal(): Promise<unknown>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
declare enum ContainerType {
|
|
309
|
-
COLLECT = "COLLECT",
|
|
310
|
-
REVEAL = "REVEAL",
|
|
311
|
-
COMPOSABLE = "COMPOSABLE"
|
|
312
|
-
}
|
|
313
|
-
interface ISkyflow {
|
|
314
|
-
vaultID?: string;
|
|
315
|
-
vaultURL?: string;
|
|
316
|
-
getBearerToken: () => Promise<string>;
|
|
317
|
-
options?: Record<string, any>;
|
|
318
|
-
}
|
|
319
|
-
declare class Skyflow {
|
|
320
|
-
#private;
|
|
321
|
-
constructor(config: ISkyflow);
|
|
322
|
-
static init(config: ISkyflow): Skyflow;
|
|
323
|
-
container(type: ContainerType, options?: Record<string, any>): RevealContainer | CollectContainer | ComposableContainer;
|
|
324
|
-
insert(records: IInsertRecordInput, options: IInsertOptions): Promise<any>;
|
|
325
|
-
detokenize(detokenizeInput: IDetokenizeInput): Promise<IRevealResponseType>;
|
|
326
|
-
getById(getByIdInput: IGetByIdInput): Promise<unknown>;
|
|
327
|
-
get(getInput: IGetInput): Promise<unknown>;
|
|
328
|
-
delete(records: IDeleteRecordInput, options: IDeleteOptions): Promise<unknown>;
|
|
329
|
-
static get ContainerType(): typeof ContainerType;
|
|
330
|
-
static get ElementType(): typeof ElementType$1;
|
|
331
|
-
static get RedactionType(): typeof RedactionType;
|
|
332
|
-
static get RequestMethod(): typeof RequestMethod;
|
|
333
|
-
static get LogLevel(): typeof LogLevel;
|
|
334
|
-
static get EventName(): typeof EventName;
|
|
335
|
-
static get Env(): typeof Env;
|
|
336
|
-
static get ValidationRuleType(): typeof ValidationRuleType;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
34
|
declare enum ElementType {
|
|
340
35
|
CARD_NUMBER = "CARD_NUMBER",
|
|
341
36
|
CARDHOLDER_NAME = "CARDHOLDER_NAME",
|
|
@@ -557,10 +252,6 @@ interface ApplePayButtonOptions extends StoreInstrumentElementOptions {
|
|
|
557
252
|
events?: PaymentEvents & {
|
|
558
253
|
onApplePayAvailable?: () => void;
|
|
559
254
|
};
|
|
560
|
-
styles?: {
|
|
561
|
-
type?: 'plain' | 'buy' | 'addMoney' | 'book' | 'checkout' | 'continue' | 'contribute' | 'donate' | 'inStore' | 'order' | 'reload' | 'rent' | 'setUp' | 'subscribe' | 'support' | 'tip' | 'topUp';
|
|
562
|
-
style?: 'white' | 'whiteOutline' | 'black' | 'automatic';
|
|
563
|
-
} & StoreInstrumentElementOptions['styles'];
|
|
564
255
|
}
|
|
565
256
|
declare global {
|
|
566
257
|
interface Window {
|
|
@@ -834,7 +525,6 @@ declare class Dropin extends PayrailsElement {
|
|
|
834
525
|
private paypal;
|
|
835
526
|
constructor(collectContainer: PayrailsCollectContainer, dropinConfig: DropinConfiguration, execution: WorkflowExecution, sdkConfig: SdkConfiguration, returnLinks: RedirectReturnLinks);
|
|
836
527
|
private createCardForm;
|
|
837
|
-
private createApplePayButton;
|
|
838
528
|
private createCardPaymentButton;
|
|
839
529
|
private onAuthorizeSuccess;
|
|
840
530
|
private onAuthorizeFailed;
|
|
@@ -873,7 +563,6 @@ interface DropinConfiguration {
|
|
|
873
563
|
styles?: {
|
|
874
564
|
googlePayButton?: GooglePayButtonOptions['styles'];
|
|
875
565
|
paypalButton?: PaypalDropinOptions['styles'];
|
|
876
|
-
applePayButton?: ApplePayButtonOptions['styles'];
|
|
877
566
|
};
|
|
878
567
|
}
|
|
879
568
|
|
|
@@ -1044,4 +733,4 @@ interface TokenizeOptions {
|
|
|
1044
733
|
storeInstrument?: boolean;
|
|
1045
734
|
}
|
|
1046
735
|
|
|
1047
|
-
export {
|
|
736
|
+
export { AuthorizationFailureReasons, CardFormOptions, CardListOptions, CardPaymentButtonOptions, ElementType, GooglePayButtonOptions, InitOptions, PaymentEvents, Payrails, PayrailsAmount, PayrailsClientOptions, PayrailsContainerType, PayrailsSecureField, SaveInstrumentResponse, WorkflowExecutionResponse };
|