@payrails/web-sdk 5.9.0 → 5.10.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 +4 -4
- package/package.json +1 -1
- package/payrails.js +4 -4
package/payrails.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
!function(e){"use strict";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}e.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"}(e.ElementType||(e.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Colect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:card.onpay_callback_failed":{description:"Callback passed to onPaymentButtonClicked threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class o extends Error{constructor(e,t){var n;const{description:s,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=s?s:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,o)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=o}(r);var a={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,r=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,a=(e,t)=>{for(var o in t||(t={}))n.call(t,o)&&r(e,o,t[o]);if(i)for(var o of i(t))s.call(t,o)&&r(e,o,t[o]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var l=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(l||{}),d=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(d||{});class c{log(e,t){console.log(JSON.stringify({level:e,mssg:t.mssg,error:t.error,withMetada:t.withMetada,extra:t.extra}))}}var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{};function E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _,h,I,p={},m={},f={},v={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.subscribers=N.childWindows=N.prefix=void 0,N.prefix="/*framebus*/",N.childWindows=[],N.subscribers={};var T,A={},O={};Object.defineProperty(O,"__esModule",{value:!0}),O.hasOpener=void 0,O.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.isntString=void 0,y.isntString=function(e){return"string"!=typeof e};var R,L,g={},S={},C={};Object.defineProperty(C,"__esModule",{value:!0}),C.sendMessage=void 0,C.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var D,P={},b={};function M(){if(D)return b;D=1,Object.defineProperty(b,"__esModule",{value:!0}),b.Framebus=void 0;var e=G(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return b.Framebus=i,b}var w,U,k=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},Y={},x={};Object.defineProperty(x,"__esModule",{value:!0});var F,V,B={};function G(){return V||(V=1,e=p,t=u&&u.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=u&&u.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(_)return m;_=1,Object.defineProperty(m,"__esModule",{value:!0}),m.detach=m.attach=void 0;var e=G(),t=!1;return m.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},m.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},m}(),e),i(function(){if(h)return f;h=1,Object.defineProperty(f,"__esModule",{value:!0}),f.broadcastToChildWindows=void 0;var e=G();return f.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},f}(),e),i(function(){if(I)return v;I=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=G();return v.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},v}(),e),i(N,e),i(function(){if(T)return A;T=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var e=G();return A.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},A}(),e),i(O,e),i(y,e),i(function(){if(R)return g;R=1,Object.defineProperty(g,"__esModule",{value:!0}),g.onMessage=void 0;var e=G();return g.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},g}(),e),i(function(){if(L)return S;L=1,Object.defineProperty(S,"__esModule",{value:!0}),S.packagePayload=void 0;var e=G();return S.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},S}(),e),i(C,e),i(function(){if(w)return P;w=1;var e=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P,"__esModule",{value:!0}),P.subscribeReplier=void 0;var t=M(),i=e(k);return P.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},P}(),e),i(function(){if(U)return Y;U=1,Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscriptionArgsInvalid=void 0;var e=G();return Y.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},Y}(),e),i(x,e),i(function(){if(F)return B;F=1,Object.defineProperty(B,"__esModule",{value:!0}),B.unpackPayload=void 0;var e=G();return B.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},B}(),e)),p;var e,t,i}var j=G(),X=M();(0,j.attach)();const H=E(X.Framebus);class W{constructor(e){this.origin=null,this.listeners=[],this.bus=new H(e)}static getInstance(){return W.instance||(W.instance=new W),W.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class z{constructor(){this.bus=W.getInstance()}log(e,t){this.bus.emit(d.ERROR,{level:e,event:t})}}var K=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===$}(e)}(e)},$="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function q(e,t){return!1!==t.clone&&t.isMergeableObject(e)?te((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function J(e,t,i){return e.concat(t).map((function(e){return q(e,i)}))}function Z(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function Q(e,t){try{return t in e}catch(e){return!1}}function ee(e,t,i){var n={};return i.isMergeableObject(e)&&Z(e).forEach((function(t){n[t]=q(e[t],i)})),Z(t).forEach((function(o){(function(e,t){return Q(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(Q(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return te;var i=t.customMerge(e);return"function"==typeof i?i:te}(o,i)(e[o],t[o],i):n[o]=q(t[o],i))})),n}function te(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||J,i.isMergeableObject=i.isMergeableObject||K,i.cloneUnlessOtherwiseSpecified=q;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):ee(e,t,i):q(t,i)}te.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return te(e,i,t)}),{})};const ie=E(te);class ne{constructor(){this.state={}}static getInstance(){return ne.instance||(ne.instance=new ne),ne.instance}getState(e){return this.state[e]}setState(e){this.state=ie(this.state,e)}}const oe=ne.getInstance(),se=()=>window&&window.navigator,re=()=>window&&window.screen,ae=()=>({resolution:`${re().width}x${re().height}`,user_agent:se().userAgent,language:se().language}),le=[l.PAYRAILS_API_AUTHORIZATION_ERROR];class de{constructor(e){this.adapter=[new z],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new c)}static init(e){de.instance=new de(e)}static getLogger(){return de.instance}initGlobalState(e){oe.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){oe.setState(e)}log(e,t,i){var n;this.enabled&&-1===le.indexOf(null==(n=null==i?void 0:i.error)?void 0:n.name)&&this.adapter.forEach((n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:a(a({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})}))}constructMetadata(){return{device:ae(),payrails:oe.getState("payrails"),sdk:oe.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=de,e.getDeviceInfo=ae}(a);for(var l,d=[],c=0;c<256;++c)d.push((c+256).toString(16).slice(1));var u=new Uint8Array(16);function E(){if(!l&&!(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(u)}var _,h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I(e,t,i){if(h.randomUUID&&!t&&!e)return h.randomUUID();var n=(e=e||{}).random||(e.rng||E)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var o=0;o<16;++o)t[i+o]=n[o];return t}return function(e,t=0){return(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST"}(_||(_={}));const p=({url:e,method:i=_.GET,token:n,body:o})=>t(void 0,void 0,void 0,(function*(){const t={method:i,headers:Object.assign(Object.assign(Object.assign({},A()),T(n)),O())};i===_.POST&&(t.body=JSON.stringify(o||{}));const s=yield fetch(e,t),r=yield s.json();if([401,403].includes(s.status))throw new m(e,i);if(429===s.status)throw new v(e,i);if(!s.ok)throw new f(e,i);return{ok:s.ok,req:Object.assign({url:e},t),res:r}}));class m extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class f extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class v extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class N extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const T=e=>({authorization:`Bearer ${e}`}),A=()=>({"x-idempotency-key":I()}),O=()=>{const e={version:"5.9.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},y=(i,n)=>t(void 0,void 0,void 0,(function*(){var t,o;if(null==i?void 0:i.onPaymentButtonClicked)try{const o=yield i.onPaymentButtonClicked(n);if(!o){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return a.PayrailsLogger.error(n.message,{error:n}),null===(t=null==i?void 0:i.onAuthorizeFailed)||void 0===t||t.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),o}}catch(t){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:t});return a.PayrailsLogger.error(n.message,{error:n}),null===(o=i.onAuthorizeFailed)||void 0===o||o.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0})),R={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class L{static getInstance(){return this.instance||(this.instance=new L),this.instance}constructor(e=""){this.lastActionRequestTime=e,L.instance=this}}class g{constructor(e,t,i=R,n=680,o=60,s=2e3,r=5,a=L.getInstance()){this.sdkConfig=e,this.execution=t,this.returnLinks=i,this.POLL_INTERVAL=n,this.MAX_POLL_ATTEMPTS=o,this.POLL_INITIAL_DELAY=s,this.POLL_ERROR_COUNT_MULTIPLIER=r,this.paymentStatus=a}pay(e){return t(this,void 0,void 0,(function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(e,i={}){return t(this,void 0,void 0,(function*(){try{const t=yield p({url:e,method:_.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,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(e,i,n=0){return t(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new N(e,_.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const t=yield p({url:e,token:this.sdkConfig.token});return i&&!t.res.status.find((({time:e})=>new Date(e)>new Date(i)))?(yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+1)):t}catch(t){if(t instanceof f)return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(t instanceof v)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(e,i,n+1);throw t}}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return p({url:e.requestUrl,method:_.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const{success:t,error:i,cancel:n}=this.returnLinks;return p({url:this.execution.authorizeLink,method:_.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i}}})}))}wait(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}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,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,i+1);if(!s){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(s.time))),d=l?l.time:s.time;if(d===this.paymentStatus.lastActionRequestTime)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,i+1);this.paymentStatus.lastActionRequestTime=d;let c=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d)));if(!c){const{res:t}=yield this.getExecution(e,d);return c=t.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:t}}return{finalState:c,response:t}}))}}class S{constructor(e,t,i,n,o=C.THREE_DS){this.link=e,this.execution=t,this.paymentExecutor=i,this.options=n,this.type=o,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===C.THREE_DS?this.THREE_DS_SIZES.reduce(((e,t)=>this.SCREEN_WIDTH>t[0]?t:e),[250,400]):[this.SCREEN_WIDTH-50,this.SCREEN_HEIGHT-50]}get popupBackground(){if(this.internalPopupBackground)return this.internalPopupBackground;{const e=document.createElement("div");e.addEventListener("click",(()=>{e.remove()})),e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popup(){const e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){const e=document.createElement("iframe");return e.setAttribute("id","payrails-frame"),e.setAttribute("src",this.link),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e}handleMessages(){const i=n=>t(this,void 0,void 0,(function*(){var t,o,s,l;if(n.data&&'{"type":"3DS-challenge-completed"}'===n.data){if(window.removeEventListener("message",i),(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(l=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===l||l.call(s);else{const i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);a.PayrailsLogger.error(i.message,{error:i}),null===(o=null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)||void 0===o||o.call(t,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",i)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var C,D,P,b,M,w;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(C||(C={}));class U{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const o=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];o&&(this.options.redirectFor3DS?window.location.assign(o):new S(o,this.execution,this.paymentExecutor,this.options).mount())}}e.PAYMENT_METHOD_CODES=void 0,(D=e.PAYMENT_METHOD_CODES||(e.PAYMENT_METHOD_CODES={})).CARD="card",D.GOOGLE_PAY="googlePay",D.PAYPAL="payPal",D.APPLE_PAY="applePay",D.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(P||(P={}));class k{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(e.PAYMENT_METHOD_CODES.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.APPLE_PAY)}get paypalConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.PAYPAL));if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return t.config||{}}get googlePayConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return t?[t.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.APPLE_PAY));if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}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 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(){var e;return null===(e=this.response.links.startPaymentSession)||void 0===e?void 0:e.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)||[]}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct"}(b||(b={})),e.INTEGRATION_TYPE=void 0,(M=e.INTEGRATION_TYPE||(e.INTEGRATION_TYPE={})).API="api",M.HPP="hpp";class Y{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)}))}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class x extends Y{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.returnInfo=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 g(this.sdkConfig,this.execution,this.returnInfo)}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 i,n,o,s,l,d,c,u;return t(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),!(yield y(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let t=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(i=this.selectedInstrument)||void 0===i?void 0:i.id)t[0].paymentInstrumentId=null===(n=this.selectedInstrument)||void 0===n?void 0:n.id,t[0].paymentMethodCode=null===(o=this.selectedInstrument)||void 0===o?void 0:o.paymentMethod;else{if(!this.cardForm){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw a.PayrailsLogger.error(e.message,{error:e}),e}t=this.sdkConfig.usePayrailsFrames?yield this.constructEncryptedPayment(t):yield this.constructTokenizedPayment(t)}const s=yield this.paymentExecutor.pay(t);this.handleAuthorizationResult(s)}catch(t){let i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof m||[401,403].includes(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.code)?(null===(d=null===(l=this.options.events)||void 0===l?void 0:l.onPaymentSessionExpired)||void 0===d||d.call(l),i.message="API token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})):t.toString().includes("Invalid token")?(null===(u=null===(c=this.options.events)||void 0===c?void 0:c.onPaymentSessionExpired)||void 0===u||u.call(c),i.message="Vault token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i})):i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})}}))}constructTokenizedPayment(e){return t(this,void 0,void 0,(function*(){const{storeInstrument:t,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData={vaultToken:null==n?void 0:n.instrumentId,card:{numberToken:null==n?void 0:n.card_number,securityCodeToken:null==n?void 0:n.security_code}},e[0].storeInstrument=t,e[0].enrollInstrumentToNetworkOffers=i,e}))}constructEncryptedPayment(e){return t(this,void 0,void 0,(function*(){const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign({},t),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,e}))}handleAuthorizationResult(t){var i,n,o;let s;switch(null===(i=null==t?void 0:t.finalState)||void 0===i?void 0:i.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===(o=null==t?void 0:t.response)||void 0===o?void 0:o.actionRequired)&&new U(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.execution,this.paymentExecutor).handle3ds(t);break;default:s=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),a.PayrailsLogger.error(s.message,{error:s,extra:{result:t}}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:s.message})}}}e.AuthorizationFailureReasons=void 0,(w=e.AuthorizationFailureReasons||(e.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",w.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",w.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",w.UNKNOWN_ERROR="UNKNOWN_ERROR";var F={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,s,r,a={},l={},d={},c={},u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={},h={};Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var p,m,f={},v={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.sendMessage=void 0,N.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var T,A={},O={};function y(){if(T)return O;T=1,Object.defineProperty(O,"__esModule",{value:!0}),O.Framebus=void 0;var e=M(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return O.Framebus=i,O}var R,L,g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},S={},C={};Object.defineProperty(C,"__esModule",{value:!0});var D,P,b={};function M(){return P||(P=1,e=a,i=t&&t.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=t&&t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),o(function(){if(n)return l;n=1,Object.defineProperty(l,"__esModule",{value:!0}),l.detach=l.attach=void 0;var e=M(),t=!1;return l.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},l.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},l}(),e),o(function(){if(s)return d;s=1,Object.defineProperty(d,"__esModule",{value:!0}),d.broadcastToChildWindows=void 0;var e=M();return d.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},d}(),e),o(function(){if(r)return c;r=1,Object.defineProperty(c,"__esModule",{value:!0}),c.broadcast=void 0;var e=M();return c.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},c}(),e),o(u,e),o(function(){if(E)return _;E=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=M();return _.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},_}(),e),o(h,e),o(I,e),o(function(){if(p)return f;p=1,Object.defineProperty(f,"__esModule",{value:!0}),f.onMessage=void 0;var e=M();return f.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},f}(),e),o(function(){if(m)return v;m=1,Object.defineProperty(v,"__esModule",{value:!0}),v.packagePayload=void 0;var e=M();return v.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},v}(),e),o(N,e),o(function(){if(R)return A;R=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(A,"__esModule",{value:!0}),A.subscribeReplier=void 0;var i=y(),n=e(g);return A.subscribeReplier=function(e,t){var o=(0,n.default)();return i.Framebus.target({origin:t}).on(o,(function n(s,r){e(s,r),i.Framebus.target({origin:t}).off(o,n)})),o},A}(),e),o(function(){if(L)return S;L=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscriptionArgsInvalid=void 0;var e=M();return S.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},S}(),e),o(C,e),o(function(){if(D)return b;D=1,Object.defineProperty(b,"__esModule",{value:!0}),b.unpackPayload=void 0;var e=M();return b.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},b}(),e)),a;var e,i,o}var w=M(),U=y();(0,w.attach)();const k=i(U.Framebus);class Y{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=Y,e.getEventBus=()=>Y.getInstance()}(F);const V={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.",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.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted 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",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."},B={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_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",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",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.",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.',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",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."},G={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."},j="collect_controller",X="element",H={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},W="FRAME_READY",z="TOKENIZATION_REQUEST",K="INPUT_EVENT",$="DESTROY FRAME",q="SET_VALUE",J="GET_BEARER_TOKEN",Z="COLLECT_ELEMENT_SET_ERROR",Q="COMPOSABLE_UPDATE_OPTIONS",ee="COMPOSABLE_CONTAINER_MOUNTED",te="COLLECT_CONTAINER_MOUNTED";var ie,ne;!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"}(ie||(ie={})),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"}(ne||(ne={}));const oe={[ne.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[ne.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ne.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ne.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[ne.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},se={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},[ie.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ie.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:oe[ne.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ie.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ie.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ie.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ie.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ie.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ie.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},re="XXXX-XXXX-XXXX-XXXX",ae={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},le={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},de={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ce={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};ce.BASE,ce.REQUIRED_ASTERISK;const ue={[ne.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[ne.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[ne.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[ne.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[ne.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[ne.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ne.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[ne.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ne.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]}};ne.DEFAULT,ne.AMEX,ne.DINERS_CLUB,ne.DISCOVER,ne.HIPERCARD,ne.JCB,ne.MAESTRO,ne.MASTERCARD,ne.UNIONPAY,ne.VISA;const Ee="MM/YY",_e=[Ee,"YYYY/MM","YY/MM","MM/YYYY"],he=["YY","YYYY"];var Ie;!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"}(Ie||(Ie={})),ie.CARD_NUMBER,ie.EXPIRATION_DATE,ie.EXPIRATION_MONTH,ie.EXPIRATION_YEAR,ie.CVV,ie.EXPIRATION_DATE,ie.CARD_NUMBER,ie.CARDHOLDER_NAME,ie.INPUT_FIELD,B.INVALID_COLLECT_VALUE,ie.PIN,ie.EXPIRATION_MONTH,ie.EXPIRATION_YEAR,ie.CVV,ie.EXPIRATION_DATE,ie.CARD_NUMBER,ie.CARDHOLDER_NAME,ie.INPUT_FIELD,B.DEFAULT_REQUIRED_COLLECT_VALUE,ie.PIN,ie.EXPIRATION_MONTH,ie.EXPIRATION_YEAR;const pe=[ie.CARDHOLDER_NAME,ie.EXPIRATION_MONTH,ie.PIN,ie.CVV],me={X:"[0-9]"};class fe{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(fe.prototype,{constructor:e})}}
|
|
1
|
+
!function(e){"use strict";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}e.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"}(e.ElementType||(e.ElementType={})),"function"==typeof SuppressedError&&SuppressedError;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(t||{});const i={"payrails:client:init.config_malformed":{description:"The provided configuration string is invalid. Please ensure it matches the required format and structure as defined in the documentation",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:unknown":{description:"Unknown Client",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unauthorized":{description:"Unauthorized access to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:too_many_requests":{description:"Too many requests to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unsuccessful":{description:"Unsuccessful request to the Payrails API",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:collectContainer.unmountable":{description:"Collect container cannot be mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.ui_element_missing":{description:"Colect container element does not exist",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:pay.card_form_missing":{description:"Trying to collect values from non-existent card form",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.gpay_loading_error":{description:"Google pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_loading_error":{description:"Paypal can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_order_creation":{description:"Paypal order creation failed",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.paypal_button_error":{description:"PaypalButtonError occurred",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.parent_element_missing":{description:"Parent element not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.subelements_render_error":{description:"Subelements could not be rendered. Please set id for the element first.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:api_url_not_found":{description:"API URL not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:workflow_execution_not_found":{description:"Workflow execution not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.paypal_config_missing":{description:"Paypal config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:authorization_not_requested":{description:"Authorization was not requested",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.gpay_config_missing":{description:"Google pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:mount.applepay_loading_error":{description:"Apple pay can not be initialized",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:init.applepay_config_missing":{description:"Apple pay config not found",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_creation_failed":{description:"Error occured while creating an iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:card_form:iframe_url_missing":{description:"Iframe URL is missing",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:card.onpay_callback_failed":{description:"Callback passed to onPaymentButtonClicked threw an error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authentication_error":{description:"Authentication error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:unknown":{description:"Unknown API error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.pay_error":{description:"Error occured while executing a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.confirm_error":{description:"Error occured while confirming a payment",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:api:request_authorization_error":{description:"Authorization error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:payment_executor.3ds_error":{description:"Authorization failed after 3DS challenge.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.element_not_mounted_in_element_match_rule":{description:"Interface: collect element - collect element is not mounted in ValidationRule params at index %s1 in validations array",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.required_params_not_provided":{description:"Interface: collect element - Required params are not provided.",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.client_connection":{description:"Interface: collect container - client connection not established. client info has not reached iframes",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_not_found":{description:"Interface: collect element - frame not found:",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.complete_and_valid_inputs":{description:"Interface: collect container - Provide complete and valid inputs",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.collect_element_not_mounted":{description:"Interface: composable collect - collect element is not mounted",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_loading_error":{description:"Interface: collect element - Error occured while loading iframe",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails.card_form.iframe_csp_error":{description:"Interface: collect element - Content Security Policy error",docUrl:"https://docs.payrails.com/docs/sdk#initializing-the-sdk"},"payrails:client:generic_redirect.missing.redirect_link":{description:"[Generic Redirect] Missing redirect link in response"}};var n=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(n||{});class o extends Error{constructor(e,t){var n;const{description:s,docUrl:r,cause:a}=null!=t?t:{},{description:l,docUrl:d}=i[e]||{},c=null!=(n=null!=s?s:l)?n:"An unknown error occurred",u=null!=r?r:d;super(c),this.name=e,this.docUrl=u,this.cause=a,this.message=c,Error.captureStackTrace&&Error.captureStackTrace(this,o)}toJSON(){return{name:this.name,message:this.message,docUrl:this.docUrl,stack:this.stack,cause:this.cause}}}e.ERROR_CODES=t,e.PAYRAILS_OBSERVABILITY_EVENTS=n,e.PayrailsError=o}(r);var a={};!function(e){var t=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,r=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,a=(e,t)=>{for(var o in t||(t={}))n.call(t,o)&&r(e,o,t[o]);if(i)for(var o of i(t))s.call(t,o)&&r(e,o,t[o]);return e};Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var l=(e=>(e.PAYRAILS_CLIENT_CONFIG_MALFORMED="payrails:client:init.config_malformed",e.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT="payrails:client:collectContainer.unmountable",e.PAYRAILS_CLIENT_UI_ELEMENT_MISSING="payrails:client:mount.ui_element_missing",e.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING="payrails:client:mount.parent_element_missing",e.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR="payrails:client:mount.subelements_render_error",e.PAYRAILS_CLIENT_CARD_FORM_MISSING="payrails:client:pay.card_form_missing",e.PAYRAILS_CLIENT_GPAY_LOADING_ERROR="payrails:client:mount.gpay_loading_error",e.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING="payrails:client:init.gpay_config_missing",e.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR="payrails:client:mount.applepay_loading_error",e.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING="payrails:client:init.applepay_config_missing",e.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR="payrails:client:init.paypal_loading_error",e.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING="payrails:client:init.paypal_config_missing",e.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION="payrails:client:init.paypal_order_creation",e.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT="payrails:client:mount.paypal_button_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR="payrails:client:payment_executor.pay_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR="payrails:client:payment_executor.3ds_error",e.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR="payrails:client:payment_executor.confirm_error",e.PAYRAILS_API_UNAUTHORIZED="payrails:api:unauthorized",e.PAYRAILS_API_TOO_MANY_REQUESTS="payrails:api:too_many_requests",e.PAYRAILS_API_UNSUCCESSFUL="payrails:api:unsuccessful",e.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED="payrails:api:authorization_not_requested",e.PAYRAILS_API_AUTHENTICATION_ERROR="payrails:api:request_authentication_error",e.PAYRAILS_API_AUTHORIZATION_ERROR="payrails:api:request_authorization_error",e.PAYRAILS_CLIENT_API_URL_NOT_FOUND="payrails:client:api_url_not_found",e.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND="payrails:client:workflow_execution_not_found",e.PAYRAILS_CARD_FORM_CREATION_FAILED="payrails:card_form:iframe_creation_failed",e.PAYRAILS_CARD_FORM_IFRAME_URL_MISSING="payrails:card_form:iframe_url_missing",e.PAYRAILS_CLIENT_UNKNOWN_ERROR="payrails:client:unknown",e.PAYRAILS_API_UNKNOWN_ERROR="payrails:api:unknown",e.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED="payrails:client:card.onpay_callback_failed",e.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE="payrails.card_form.element_not_mounted_in_element_match_rule",e.PAYRAILS_CARD_FORM_REQUIRED_PARAMS_NOT_PROVIDED="payrails.card_form.required_params_not_provided",e.PAYRAILS_CARD_FORM_CLIENT_CONNECTION="payrails.card_form.client_connection",e.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND="payrails.card_form.iframe_not_found",e.PAYRAILS_CARD_FORM_IFRAME_LOADING_ERROR="payrails.card_form.iframe_loading_error",e.PAYRAILS_CARD_FORM_CSP_ERROR="payrails.card_form.iframe_csp_error",e.PAYRAILS_CARD_FORM_COMPLETE_AND_VALID_INPUTS="payrails.card_form.complete_and_valid_inputs",e.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED="payrails.card_form.collect_element_not_mounted",e.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK="payrails:client:generic_redirect.missing.redirect_link",e))(l||{}),d=(e=>(e.ERROR="payrails:error",e.INFO="payrails:info",e.DEBUG="payrails:debug",e.WARN="payrails:warn",e))(d||{});class c{log(e,t){console.log(JSON.stringify({level:e,mssg:t.mssg,error:t.error,withMetada:t.withMetada,extra:t.extra}))}}var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{};function E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _,h,I,p={},m={},f={},v={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.subscribers=N.childWindows=N.prefix=void 0,N.prefix="/*framebus*/",N.childWindows=[],N.subscribers={};var T,A={},y={};Object.defineProperty(y,"__esModule",{value:!0}),y.hasOpener=void 0,y.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var O={};Object.defineProperty(O,"__esModule",{value:!0}),O.isntString=void 0,O.isntString=function(e){return"string"!=typeof e};var R,L,g={},S={},C={};Object.defineProperty(C,"__esModule",{value:!0}),C.sendMessage=void 0,C.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var D,P={},b={};function M(){if(D)return b;D=1,Object.defineProperty(b,"__esModule",{value:!0}),b.Framebus=void 0;var e=G(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return b.Framebus=i,b}var w,U,k=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},Y={},x={};Object.defineProperty(x,"__esModule",{value:!0});var F,V,B={};function G(){return V||(V=1,e=p,t=u&&u.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),i=u&&u.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||t(i,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(_)return m;_=1,Object.defineProperty(m,"__esModule",{value:!0}),m.detach=m.attach=void 0;var e=G(),t=!1;return m.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},m.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},m}(),e),i(function(){if(h)return f;h=1,Object.defineProperty(f,"__esModule",{value:!0}),f.broadcastToChildWindows=void 0;var e=G();return f.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},f}(),e),i(function(){if(I)return v;I=1,Object.defineProperty(v,"__esModule",{value:!0}),v.broadcast=void 0;var e=G();return v.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},v}(),e),i(N,e),i(function(){if(T)return A;T=1,Object.defineProperty(A,"__esModule",{value:!0}),A.dispatch=void 0;var e=G();return A.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},A}(),e),i(y,e),i(O,e),i(function(){if(R)return g;R=1,Object.defineProperty(g,"__esModule",{value:!0}),g.onMessage=void 0;var e=G();return g.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},g}(),e),i(function(){if(L)return S;L=1,Object.defineProperty(S,"__esModule",{value:!0}),S.packagePayload=void 0;var e=G();return S.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},S}(),e),i(C,e),i(function(){if(w)return P;w=1;var e=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(P,"__esModule",{value:!0}),P.subscribeReplier=void 0;var t=M(),i=e(k);return P.subscribeReplier=function(e,n){var o=(0,i.default)();return t.Framebus.target({origin:n}).on(o,(function i(s,r){e(s,r),t.Framebus.target({origin:n}).off(o,i)})),o},P}(),e),i(function(){if(U)return Y;U=1,Object.defineProperty(Y,"__esModule",{value:!0}),Y.subscriptionArgsInvalid=void 0;var e=G();return Y.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},Y}(),e),i(x,e),i(function(){if(F)return B;F=1,Object.defineProperty(B,"__esModule",{value:!0}),B.unpackPayload=void 0;var e=G();return B.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},B}(),e)),p;var e,t,i}var j=G(),X=M();(0,j.attach)();const H=E(X.Framebus);class W{constructor(e){this.origin=null,this.listeners=[],this.bus=new H(e)}static getInstance(){return W.instance||(W.instance=new W),W.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}class z{constructor(){this.bus=W.getInstance()}log(e,t){this.bus.emit(d.ERROR,{level:e,event:t})}}var K=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===$}(e)}(e)},$="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function q(e,t){return!1!==t.clone&&t.isMergeableObject(e)?te((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function J(e,t,i){return e.concat(t).map((function(e){return q(e,i)}))}function Z(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function Q(e,t){try{return t in e}catch(e){return!1}}function ee(e,t,i){var n={};return i.isMergeableObject(e)&&Z(e).forEach((function(t){n[t]=q(e[t],i)})),Z(t).forEach((function(o){(function(e,t){return Q(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,o)||(Q(e,o)&&i.isMergeableObject(t[o])?n[o]=function(e,t){if(!t.customMerge)return te;var i=t.customMerge(e);return"function"==typeof i?i:te}(o,i)(e[o],t[o],i):n[o]=q(t[o],i))})),n}function te(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||J,i.isMergeableObject=i.isMergeableObject||K,i.cloneUnlessOtherwiseSpecified=q;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):ee(e,t,i):q(t,i)}te.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return te(e,i,t)}),{})};const ie=E(te);class ne{constructor(){this.state={}}static getInstance(){return ne.instance||(ne.instance=new ne),ne.instance}getState(e){return this.state[e]}setState(e){this.state=ie(this.state,e)}}const oe=ne.getInstance(),se=()=>window&&window.navigator,re=()=>window&&window.screen,ae=()=>({resolution:`${re().width}x${re().height}`,user_agent:se().userAgent,language:se().language}),le=[l.PAYRAILS_API_AUTHORIZATION_ERROR];class de{constructor(e){this.adapter=[new z],this.enabled=e.enabled||!0,this.initGlobalState(e),e.logLevel=e.logLevel||"error","debug"===e.logLevel&&this.addAdapter(new c)}static init(e){de.instance=new de(e)}static getLogger(){return de.instance}initGlobalState(e){oe.setState({payrails:e.payrails,sdk:e.sdk})}static setState(e){oe.setState(e)}log(e,t,i){var n;this.enabled&&-1===le.indexOf(null==(n=null==i?void 0:i.error)?void 0:n.name)&&this.adapter.forEach((n=>{n.log(e,{mssg:t,error:null==i?void 0:i.error,withMetada:a(a({},this.constructMetadata()),null==i?void 0:i.withMetada),extra:null==i?void 0:i.extra})}))}constructMetadata(){return{device:ae(),payrails:oe.getState("payrails"),sdk:oe.getState("sdk")}}addAdapter(e){this.adapter.push(e)}static log(e,t){this.getLogger().log("info",e,t)}static debug(e,t){this.getLogger().log("debug",e,t)}static info(e,t){this.getLogger().log("info",e,t)}static warn(e,t){this.getLogger().log("warning",e,t)}static error(e,t){this.getLogger().log("error",e,t)}static exception(e,t){this.error(e,t)}}e.PayrailsLogger=de,e.getDeviceInfo=ae}(a);for(var l,d=[],c=0;c<256;++c)d.push((c+256).toString(16).slice(1));var u=new Uint8Array(16);function E(){if(!l&&!(l="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(u)}var _,h={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I(e,t,i){if(h.randomUUID&&!t&&!e)return h.randomUUID();var n=(e=e||{}).random||(e.rng||E)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){i=i||0;for(var o=0;o<16;++o)t[i+o]=n[o];return t}return function(e,t=0){return(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase()}(n)}!function(e){e.GET="GET",e.POST="POST"}(_||(_={}));const p=({url:e,method:i=_.GET,token:n,body:o})=>t(void 0,void 0,void 0,(function*(){const t={method:i,headers:Object.assign(Object.assign(Object.assign({},A()),T(n)),y())};i===_.POST&&(t.body=JSON.stringify(o||{}));const s=yield fetch(e,t),r=yield s.json();if([401,403].includes(s.status))throw new m(e,i);if(429===s.status)throw new v(e,i);if(!s.ok)throw new f(e,i);return{ok:s.ok,req:Object.assign({url:e},t),res:r}}));class m extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNAUTHORIZED,{description:`[${t}] ${e} unauthorized`})}}class f extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_UNSUCCESSFUL,{description:`[${t}] ${e} unsuccessful`})}}class v extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} too many requests`})}}class N extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_API_TOO_MANY_REQUESTS,{description:`[${t}] ${e} max poll attempts exceeded.`})}}const T=e=>({authorization:`Bearer ${e}`}),A=()=>({"x-idempotency-key":I()}),y=()=>{const e={version:"5.10.0",type:"web-sdk"};return{"x-client-version":e.version,"x-client-type":e.type}},O=(i,n)=>t(void 0,void 0,void 0,(function*(){var t,o;if(null==i?void 0:i.onPaymentButtonClicked)try{const o=yield i.onPaymentButtonClicked(n);if(!o){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked resolved to false"});return a.PayrailsLogger.error(n.message,{error:n}),null===(t=null==i?void 0:i.onAuthorizeFailed)||void 0===t||t.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),o}}catch(t){const n=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_ONPAY_CALLBACK_FAILED,{description:"Callback passed to onPaymentButtonClicked threw an error",cause:t});return a.PayrailsLogger.error(n.message,{error:n}),null===(o=i.onAuthorizeFailed)||void 0===o||o.call(i,{code:e.AuthorizationFailureReasons.VALIDATION_FAILED,message:n.message}),!1}return!0})),R={success:"https://payrails.io/success",error:"https://payrails.io/error",cancel:"https://payrails.io/cancel"};class L{static getInstance(){return this.instance||(this.instance=new L),this.instance}constructor(e=""){this.lastActionRequestTime=e,L.instance=this}}class g{constructor(e,t,i=R,n=680,o=60,s=2e3,r=5,a=L.getInstance()){this.sdkConfig=e,this.execution=t,this.returnLinks=i,this.POLL_INTERVAL=n,this.MAX_POLL_ATTEMPTS=o,this.POLL_INITIAL_DELAY=s,this.POLL_ERROR_COUNT_MULTIPLIER=r,this.paymentStatus=a}pay(e){return t(this,void 0,void 0,(function*(){try{const t=(yield this.authorize(e)).res.links.execution;return yield this.pollForAuthorizationResult(t)}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_PAY_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}confirm(e,i={}){return t(this,void 0,void 0,(function*(){try{const t=yield p({url:e,method:_.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,o);return{finalState:s.status.find((({code:e,time:t})=>["authorizeSuccessful","authorizeFailed"].includes(e)&&new Date(t)>new Date(o))),response:s}}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_CONFIRM_ERROR,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),e}}))}getExecution(e,i,n=0){return t(this,void 0,void 0,(function*(){if(n>this.MAX_POLL_ATTEMPTS)throw new N(e,_.GET);0===n&&i&&(yield this.wait(this.POLL_INITIAL_DELAY));try{const t=yield p({url:e,token:this.sdkConfig.token});return i&&!t.res.status.find((({time:e})=>new Date(e)>new Date(i)))?(yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+1)):t}catch(t){if(t instanceof f)return yield this.wait(this.POLL_INTERVAL),this.getExecution(e,i,n+this.POLL_ERROR_COUNT_MULTIPLIER);if(t instanceof v)return yield this.wait(this.POLL_INTERVAL*n),this.getExecution(e,i,n+1);throw t}}))}createApplePaySession(e){return t(this,void 0,void 0,(function*(){return p({url:e.requestUrl,method:_.POST,token:this.sdkConfig.token,body:{integrationType:"api",paymentMethodCode:"applePay",amount:this.sdkConfig.amount,meta:{sessionURL:e.sessionUrl,clientContext:{host:e.clientDomain||window.location.host}}}})}))}authorize(e){return t(this,void 0,void 0,(function*(){if(!this.execution.authorizeLink||!this.sdkConfig.amount){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND,{description:"SDK was not initialized with workflow execution"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const{success:t,error:i,cancel:n}=this.returnLinks;return p({url:this.execution.authorizeLink,method:_.POST,token:this.sdkConfig.token,body:{amount:this.sdkConfig.amount,paymentComposition:e,returnInfo:{success:t,cancel:n,error:i}}})}))}wait(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}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,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,i+1);if(!s){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_NOT_REQUESTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}const l=n.find((({code:e,time:t})=>"confirmRequested"===e&&new Date(t)>new Date(s.time))),d=l?l.time:s.time;if(d===this.paymentStatus.lastActionRequestTime)return yield new Promise((e=>setTimeout(e,this.POLL_INTERVAL))),this.pollForAuthorizationResult(e,i+1);this.paymentStatus.lastActionRequestTime=d;let c=n.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d)));if(!c){const{res:t}=yield this.getExecution(e,d);return c=t.status.find((({code:e,time:t})=>o.includes(e)&&new Date(t)>new Date(d))),{finalState:c,response:t}}return{finalState:c,response:t}}))}}class S{constructor(e,t,i,n,o=C.THREE_DS){this.link=e,this.execution=t,this.paymentExecutor=i,this.options=n,this.type=o,this.THREE_DS_SIZES=[[250,400],[390,400],[500,600],[600,400]],this.internalPopupBackground=null,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight}get iframeSize(){return this.type===C.THREE_DS?this.THREE_DS_SIZES.reduce(((e,t)=>this.SCREEN_WIDTH>t[0]?t:e),[250,400]):[this.SCREEN_WIDTH-50,this.SCREEN_HEIGHT-50]}get popupBackground(){if(this.internalPopupBackground)return this.internalPopupBackground;{const e=document.createElement("div");e.setAttribute("id","payrails-popup-background"),e.appendChild(this.popup),this.internalPopupBackground=e}return this.internalPopupBackground}get popup(){const e=document.createElement("div");return e.setAttribute("id","payrails-popup"),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e.appendChild(this.iframe),e.style.width=`${this.iframeSize[0]+4}px`,e.style.height=`${this.iframeSize[1]+4}px`,e}get iframe(){const e=document.createElement("iframe");return e.setAttribute("id","payrails-frame"),e.setAttribute("src",this.link),e.setAttribute("width",this.iframeSize[0].toString()),e.setAttribute("height",this.iframeSize[1].toString()),e}handleMessages(){const i=n=>t(this,void 0,void 0,(function*(){var t,o,s,l;if(n.data&&'{"type":"3DS-challenge-completed"}'===n.data){if(window.removeEventListener("message",i),(yield this.paymentExecutor.getExecution(this.execution.url)).res.status.find((({code:e})=>"authorizeSuccessful"===e)))null===(l=null===(s=this.options.events)||void 0===s?void 0:s.onAuthorizeSuccess)||void 0===l||l.call(s);else{const i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYMENT_EXECUTOR_3DS_ERROR);a.PayrailsLogger.error(i.message,{error:i}),null===(o=null===(t=this.options.events)||void 0===t?void 0:t.onAuthorizeFailed)||void 0===o||o.call(t,{code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:"Authorization failed after 3DS challenge."})}this.unmount()}}));window.addEventListener("message",i)}mount(){var e;this.popup.remove(),null===(e=document.querySelector("body"))||void 0===e||e.appendChild(this.popupBackground),this.handleMessages()}unmount(){this.popupBackground.remove(),this.internalPopupBackground=null}}var C,D,P,b,M,w;!function(e){e[e.THREE_DS=0]="THREE_DS",e[e.GENERIC_REDIRECT=1]="GENERIC_REDIRECT"}(C||(C={}));class U{constructor(e,t,i){this.options=e,this.execution=t,this.paymentExecutor=i}handle3ds(e){var t,i,n;try{null===(i=null===(t=this.options.events)||void 0===t?void 0:t.onThreeDSecureChallenge)||void 0===i||i.call(t)}catch(e){}const o=null===(n=null==e?void 0:e.response)||void 0===n?void 0:n.links["3ds"];o&&(this.options.redirectFor3DS?window.location.assign(o):new S(o,this.execution,this.paymentExecutor,this.options).mount())}}e.PAYMENT_METHOD_CODES=void 0,(D=e.PAYMENT_METHOD_CODES||(e.PAYMENT_METHOD_CODES={})).CARD="card",D.GOOGLE_PAY="googlePay",D.PAYPAL="payPal",D.APPLE_PAY="applePay",D.GENERIC_REDIRECT="genericRedirect",function(e){e.ENABLED="enabled",e.CREATED="created",e.DELETED="deleted",e.DISABLED="disabled",e.INVALID="invalid",e.TRANSIENT="transient"}(P||(P={}));class k{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(e.PAYMENT_METHOD_CODES.CARD)}get savedPaypalAccounts(){return this.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.PAYPAL)}get savedGooglePayAccounts(){return this.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.GOOGLE_PAY)}get savedApplePayAccounts(){return this.getStoredInstrumentForPaymentMethod(e.PAYMENT_METHOD_CODES.APPLE_PAY)}get paypalConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.PAYPAL));if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return t.config||{}}get googlePayConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.GOOGLE_PAY));if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}return t?[t.config]:[]}isPaymentMethodAvailable(e){return this.availablePaymentMethods.some((({paymentMethodCode:t})=>t===e))}get applePayConfig(){const t=this.availablePaymentMethods.find((({paymentMethodCode:t})=>t===e.PAYMENT_METHOD_CODES.APPLE_PAY));if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_CONFIG_MISSING);throw a.PayrailsLogger.error(e.message,{error:e,extra:{availablePaymentMethods:this.availablePaymentMethods}}),e}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 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(){var e;return null===(e=this.response.links.startPaymentSession)||void 0===e?void 0:e.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)||[]}}!function(e){e.REDIRECT="redirect",e.DIRECT="direct"}(b||(b={})),e.INTEGRATION_TYPE=void 0,(M=e.INTEGRATION_TYPE||(e.INTEGRATION_TYPE={})).API="api",M.HPP="hpp";class Y{constructor(e,{id:t="",className:i=""}={}){this.subElements=[];const n=document.createElement(e);t&&(this.id=t,n.setAttribute("id",t)),i&&(Array.isArray(i)?n.setAttribute("class",function(...e){return e.filter(Boolean).join(" ")}(...i)):n.setAttribute("class",i)),this.element=n}get parentElement(){return this.element.parentElement}get selector(){if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);return`#${this.id}`}mount(e){const t=document.querySelector(e);if(!t)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING,{description:`Element with selector "${e}" not found in in the DOM`});this.clean(),t.appendChild(this.element),this.subElements.forEach((e=>{if(!this.id)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_SUBELEMENTS_RENDER_ERROR);e.mount(this.selector)}))}clean(){var e;null===(e=document.getElementById(this.element.id))||void 0===e||e.remove()}unmount(){var e;this.subElements.forEach((e=>e.unmount())),null===(e=this.parentElement)||void 0===e||e.removeChild(this.element)}}class x extends Y{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.returnInfo=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 g(this.sdkConfig,this.execution,this.returnInfo)}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 i,n,o,s,l,d,c,u;return t(this,void 0,void 0,(function*(){if(this.setDisabled(!0),this.triggerLoading(!0),!(yield O(this.options.events,{bin:this.bin||""})))return this.setDisabled(!1),void this.triggerLoading(!1);try{let t=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.CARD,integrationType:"api",amount:this.sdkConfig.amount,storeInstrument:!1}];if(null===(i=this.selectedInstrument)||void 0===i?void 0:i.id)t[0].paymentInstrumentId=null===(n=this.selectedInstrument)||void 0===n?void 0:n.id,t[0].paymentMethodCode=null===(o=this.selectedInstrument)||void 0===o?void 0:o.paymentMethod;else{if(!this.cardForm){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CARD_FORM_MISSING);throw a.PayrailsLogger.error(e.message,{error:e}),e}t=this.sdkConfig.usePayrailsFrames?yield this.constructEncryptedPayment(t):yield this.constructTokenizedPayment(t)}const s=yield this.paymentExecutor.pay(t);this.handleAuthorizationResult(s)}catch(t){let i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHENTICATION_ERROR,{cause:t});t instanceof m||[401,403].includes(null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.code)?(null===(d=null===(l=this.options.events)||void 0===l?void 0:l.onPaymentSessionExpired)||void 0===d||d.call(l),i.message="API token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})):t.toString().includes("Invalid token")?(null===(u=null===(c=this.options.events)||void 0===c?void 0:c.onPaymentSessionExpired)||void 0===u||u.call(c),i.message="Vault token is not valid or expired.",a.PayrailsLogger.error(i.message,{error:i})):i=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_UNKNOWN_ERROR,{cause:t}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHENTICATION_ERROR,message:i.message})}}))}constructTokenizedPayment(e){return t(this,void 0,void 0,(function*(){const{storeInstrument:t,enrollInstrumentToNetworkOffers:i,cardData:n}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData={vaultToken:null==n?void 0:n.instrumentId,card:{numberToken:null==n?void 0:n.card_number,securityCodeToken:null==n?void 0:n.security_code}},e[0].storeInstrument=t,e[0].enrollInstrumentToNetworkOffers=i,e}))}constructEncryptedPayment(e){return t(this,void 0,void 0,(function*(){const{cardData:t,storeInstrument:i,enrollInstrumentToNetworkOffers:n}=yield this.cardForm.collectValues();return e[0].paymentInstrumentData=Object.assign({},t),e[0].storeInstrument=i,e[0].enrollInstrumentToNetworkOffers=n,e}))}handleAuthorizationResult(t){var i,n,o;let s;switch(null===(i=null==t?void 0:t.finalState)||void 0===i?void 0:i.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===(o=null==t?void 0:t.response)||void 0===o?void 0:o.actionRequired)&&new U(Object.assign(Object.assign({},this.options),{events:Object.assign(Object.assign({},this.options.events),{onAuthorizeFailed:e=>{this.onAuthorizationFailed(e)}})}),this.execution,this.paymentExecutor).handle3ds(t);break;default:s=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_API_AUTHORIZATION_ERROR),a.PayrailsLogger.error(s.message,{error:s,extra:{result:t}}),this.onAuthorizationFailed({code:e.AuthorizationFailureReasons.AUTHORIZATION_ERROR,message:s.message})}}}e.AuthorizationFailureReasons=void 0,(w=e.AuthorizationFailureReasons||(e.AuthorizationFailureReasons={})).VALIDATION_FAILED="VALIDATION_FAILED",w.AUTHORIZATION_ERROR="AUTHORIZATION_ERROR",w.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",w.UNKNOWN_ERROR="UNKNOWN_ERROR";var F={};!function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==o?o:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,s,r,a={},l={},d={},c={},u={};Object.defineProperty(u,"__esModule",{value:!0}),u.subscribers=u.childWindows=u.prefix=void 0,u.prefix="/*framebus*/",u.childWindows=[],u.subscribers={};var E,_={},h={};Object.defineProperty(h,"__esModule",{value:!0}),h.hasOpener=void 0,h.hasOpener=function(e){return e.top===e&&null!=e.opener&&e.opener!==e&&!0!==e.opener.closed};var I={};Object.defineProperty(I,"__esModule",{value:!0}),I.isntString=void 0,I.isntString=function(e){return"string"!=typeof e};var p,m,f={},v={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.sendMessage=void 0,N.sendMessage=function(e,t,i){try{e.postMessage(t,i)}catch(e){}};var T,A={},y={};function O(){if(T)return y;T=1,Object.defineProperty(y,"__esModule",{value:!0}),y.Framebus=void 0;var e=M(),t="undefined"!=typeof window&&window.Promise,i=function(){function i(e){void 0===e&&(e={}),this.origin=e.origin||"*",this.channel=e.channel||"",this.verifyDomain=e.verifyDomain,this.targetFrames=e.targetFrames||[],this.limitBroadcastToFramesArray=Boolean(e.targetFrames),this.isDestroyed=!1,this.listeners=[],this.hasAdditionalChecksForOnListeners=Boolean(this.verifyDomain||this.limitBroadcastToFramesArray)}return i.setPromise=function(e){i.Promise=e},i.target=function(e){return new i(e)},i.prototype.addTargetFrame=function(e){this.limitBroadcastToFramesArray&&this.targetFrames.push(e)},i.prototype.include=function(t){return null!=t&&null!=t.Window&&t.constructor===t.Window&&(e.childWindows.push(t),!0)},i.prototype.target=function(e){return i.target(e)},i.prototype.emit=function(t,i,n){if(this.isDestroyed)return!1;var o=this.origin;if(t=this.namespaceEvent(t),(0,e.isntString)(t))return!1;if((0,e.isntString)(o))return!1;"function"==typeof i&&(n=i,i=void 0);var s=(0,e.packagePayload)(t,o,i,n);return!!s&&(this.limitBroadcastToFramesArray?this.targetFramesAsWindows().forEach((function(t){(0,e.sendMessage)(t,s,o)})):(0,e.broadcast)(s,{origin:o,frame:window.top||window.self}),!0)},i.prototype.emitAsPromise=function(e,t){var n=this;return new i.Promise((function(i,o){n.emit(e,t,(function(e){i(e)}))||o(new Error('Listener not added for "'.concat(e,'"')))}))},i.prototype.on=function(t,i){if(this.isDestroyed)return!1;var n=this,o=this.origin,s=i;return t=this.namespaceEvent(t),!(0,e.subscriptionArgsInvalid)(t,s,o)&&(this.hasAdditionalChecksForOnListeners&&(s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];n.passesVerifyDomainCheck(this&&this.origin)&&n.hasMatchingTargetFrame(this&&this.source)&&i.apply(void 0,e)}),this.listeners.push({eventName:t,handler:s,originalHandler:i}),e.subscribers[o]=e.subscribers[o]||{},e.subscribers[o][t]=e.subscribers[o][t]||[],e.subscribers[o][t].push(s),!0)},i.prototype.off=function(t,i){var n=i;if(this.isDestroyed)return!1;if(this.verifyDomain)for(var o=0;o<this.listeners.length;o++){var s=this.listeners[o];s.originalHandler===i&&(n=s.handler)}t=this.namespaceEvent(t);var r=this.origin;if((0,e.subscriptionArgsInvalid)(t,n,r))return!1;var a=e.subscribers[r]&&e.subscribers[r][t];if(!a)return!1;for(o=0;o<a.length;o++)if(a[o]===n)return a.splice(o,1),!0;return!1},i.prototype.teardown=function(){if(!this.isDestroyed){this.isDestroyed=!0;for(var e=0;e<this.listeners.length;e++){var t=this.listeners[e];this.off(t.eventName,t.handler)}this.listeners.length=0}},i.prototype.passesVerifyDomainCheck=function(e){return!this.verifyDomain||this.checkOrigin(e)},i.prototype.targetFramesAsWindows=function(){return this.limitBroadcastToFramesArray?this.targetFrames.map((function(e){return e instanceof HTMLIFrameElement?e.contentWindow:e})).filter((function(e){return e})):[]},i.prototype.hasMatchingTargetFrame=function(e){if(!this.limitBroadcastToFramesArray)return!0;var t=this.targetFramesAsWindows().find((function(t){return t===e}));return Boolean(t)},i.prototype.checkOrigin=function(e){var t,i=document.createElement("a");return i.href=location.href,t="https:"===i.protocol?i.host.replace(/:443$/,""):"http:"===i.protocol?i.host.replace(/:80$/,""):i.host,i.protocol+"//"+t===e||!this.verifyDomain||this.verifyDomain(e)},i.prototype.namespaceEvent=function(e){return this.channel?"".concat(this.channel,":").concat(e):e},i.Promise=t,i}();return y.Framebus=i,y}var R,L,g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},S={},C={};Object.defineProperty(C,"__esModule",{value:!0});var D,P,b={};function M(){return P||(P=1,e=a,i=t&&t.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(t,i);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,o)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=t&&t.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)},Object.defineProperty(e,"__esModule",{value:!0}),o(function(){if(n)return l;n=1,Object.defineProperty(l,"__esModule",{value:!0}),l.detach=l.attach=void 0;var e=M(),t=!1;return l.attach=function(){t||"undefined"==typeof window||(t=!0,window.addEventListener("message",e.onMessage,!1))},l.detach=function(){t=!1,window.removeEventListener("message",e.onMessage,!1)},l}(),e),o(function(){if(s)return d;s=1,Object.defineProperty(d,"__esModule",{value:!0}),d.broadcastToChildWindows=void 0;var e=M();return d.broadcastToChildWindows=function(t,i,n){for(var o=e.childWindows.length-1;o>=0;o--){var s=e.childWindows[o];s.closed?e.childWindows.splice(o,1):n!==s&&(0,e.broadcast)(t,{origin:i,frame:s.top})}},d}(),e),o(function(){if(r)return c;r=1,Object.defineProperty(c,"__esModule",{value:!0}),c.broadcast=void 0;var e=M();return c.broadcast=function t(i,n){var o,s=0,r=n.origin,a=n.frame;try{for(a.postMessage(i,r),(0,e.hasOpener)(a)&&a.opener.top!==window.top&&t(i,{origin:r,frame:a.opener.top});o=a.frames[s];)t(i,{origin:r,frame:o}),s++}catch(e){}},c}(),e),o(u,e),o(function(){if(E)return _;E=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dispatch=void 0;var e=M();return _.dispatch=function(t,i,n,o,s){if(e.subscribers[t]&&e.subscribers[t][i]){var r=[];n&&r.push(n),o&&r.push(o);for(var a=0;a<e.subscribers[t][i].length;a++)e.subscribers[t][i][a].apply(s,r)}},_}(),e),o(h,e),o(I,e),o(function(){if(p)return f;p=1,Object.defineProperty(f,"__esModule",{value:!0}),f.onMessage=void 0;var e=M();return f.onMessage=function(t){if(!(0,e.isntString)(t.data)){var i=(0,e.unpackPayload)(t);if(i){var n=i.eventData,o=i.reply;(0,e.dispatch)("*",i.event,n,o,t),(0,e.dispatch)(t.origin,i.event,n,o,t),(0,e.broadcastToChildWindows)(t.data,i.origin,t.source)}}},f}(),e),o(function(){if(m)return v;m=1,Object.defineProperty(v,"__esModule",{value:!0}),v.packagePayload=void 0;var e=M();return v.packagePayload=function(t,i,n,o){var s,r={event:t,origin:i};"function"==typeof o&&(r.reply=(0,e.subscribeReplier)(o,i)),r.eventData=n;try{s=e.prefix+JSON.stringify(r)}catch(e){throw new Error("Could not stringify event: ".concat(e.message))}return s},v}(),e),o(N,e),o(function(){if(R)return A;R=1;var e=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(A,"__esModule",{value:!0}),A.subscribeReplier=void 0;var i=O(),n=e(g);return A.subscribeReplier=function(e,t){var o=(0,n.default)();return i.Framebus.target({origin:t}).on(o,(function n(s,r){e(s,r),i.Framebus.target({origin:t}).off(o,n)})),o},A}(),e),o(function(){if(L)return S;L=1,Object.defineProperty(S,"__esModule",{value:!0}),S.subscriptionArgsInvalid=void 0;var e=M();return S.subscriptionArgsInvalid=function(t,i,n){return!!(0,e.isntString)(t)||"function"!=typeof i||(0,e.isntString)(n)},S}(),e),o(C,e),o(function(){if(D)return b;D=1,Object.defineProperty(b,"__esModule",{value:!0}),b.unpackPayload=void 0;var e=M();return b.unpackPayload=function(t){var i;if(t.data.slice(0,e.prefix.length)!==e.prefix)return!1;try{i=JSON.parse(t.data.slice(e.prefix.length))}catch(e){return!1}if(i.reply){var n=t.origin,o=t.source,s=i.reply;i.reply=function(t){if(o){var i=(0,e.packagePayload)(s,n,t);i&&o.postMessage(i,n)}}}return i},b}(),e)),a;var e,i,o}var w=M(),U=O();(0,w.attach)();const k=i(U.Framebus);class Y{constructor(e){this.origin=null,this.listeners=[],this.bus=new k(e)}static getInstance(){return Y.instance||(Y.instance=new Y),Y.instance}on(e,t){return this.bus.on(e,t)}off(e,t){return this.bus.off(e,t)}emit(e,t,i=void 0){return this.bus.emit(e,t,i)}target(e){return this.bus.target(e)}}e.IframeEventBus=Y,e.getEventBus=()=>Y.getInstance()}(F);const V={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.",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.",CREATED_ELEMENT:"%s1 - Created %s2 element.",ELEMENT_MOUNTED:"%s1 - %s2 Element mounted.",COLLECT_SUBMIT_SUCCESS:"%s1 - Data has been collected successfully.",INSERT_DATA_SUCCESS:"%s1 - Data has been inserted 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",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."},B={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_TOKENS_IN_GET:"Interface: client get - Invalid tokens in options. tokens of type boolean is required.",TOKENS_GET_COLUMN_NOT_SUPPORTED:"Interface: client get - column_name or column_values cannot be used with tokens in options.",REDACTION_WITH_TOKENS_NOT_SUPPORTED:"Interface: client get - redaction cannot be used when tokens are true in options.",INVALID_REDACTION_TYPE_IN_DETOKENIZE:"Interface: client get - Invalid redaction type in records array at index %s1",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",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.",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.',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",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."},G={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."},j="collect_controller",X="element",H={CHANGE:"CHANGE",READY:"READY",FOCUS:"FOCUS",BLUR:"BLUR",ESCAPE:"ESCAPE",CLICK:"CLICK",ERROR:"ERROR",SUCCESS:"SUCCESS",SUBMIT:"SUBMIT",CREATED:"CREATED",MOUNTED:"MOUNTED",HEIGHT:"HEIGHT"},W="FRAME_READY",z="TOKENIZATION_REQUEST",K="INPUT_EVENT",$="DESTROY FRAME",q="SET_VALUE",J="GET_BEARER_TOKEN",Z="COLLECT_ELEMENT_SET_ERROR",Q="COMPOSABLE_UPDATE_OPTIONS",ee="COMPOSABLE_CONTAINER_MOUNTED",te="COLLECT_CONTAINER_MOUNTED";var ie,ne;!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"}(ie||(ie={})),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"}(ne||(ne={}));const oe={[ne.AMEX]:["XXXX XXXXXX XXXXX",{X:"[0-9]"}],[ne.VISA]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ne.MASTERCARD]:["XXXX XXXX XXXX XXXX",{X:"[0-9]"}],[ne.DISCOVER]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.DINERS_CLUB]:["XXXX XXXXXX XXXXXX",{X:"[0-9]"}],[ne.JCB]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.MAESTRO]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.UNIONPAY]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.HIPERCARD]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.DEFAULT]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}],[ne.UNKNOWN]:["XXXX XXXX XXXX XXXX XXX",{X:"[0-9]"}]},se={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},[ie.CARDHOLDER_NAME]:{name:"cardHolderName",attributes:{type:"text",autocomplete:"cc-name"},sensitive:!0,regex:/^([a-zA-Z\\ \\,\\.\\-\\']{2,})$/},[ie.CARD_NUMBER]:{name:"CARD_NUMBER",attributes:{type:"text",autocomplete:"cc-number",inputmode:"numeric"},sensitive:!0,mask:oe[ne.DEFAULT],regex:/$|^[\s]*?([0-9]{2,6}[ -]?){3,5}[\s]*/},[ie.EXPIRATION_DATE]:{name:"EXPIRATION_DATE",attributes:{type:"text",autocomplete:"cc-exp",inputmode:"numeric"},sensitive:!0},[ie.EXPIRATION_MONTH]:{name:"EXPIRATION_MONTH",attributes:{maxLength:2,type:"text",inputmode:"numeric",autocomplete:"cc-exp-month"},sensitive:!0,mask:["XX",{X:"[0-9]"}]},[ie.EXPIRATION_YEAR]:{name:"EXPIRATION_YEAR",attributes:{type:"text",inputmode:"numeric",autocomplete:"cc-exp-year"},sensitive:!0},[ie.CVV]:{name:"CVV",attributes:{type:"text",inputmode:"numeric",maxLength:4},sensitive:!0,regex:/^$|^[0-9]{3,4}$/},[ie.INPUT_FIELD]:{name:"INPUT_FIELD",sensitive:!0,attributes:{type:"text"}},[ie.PIN]:{name:"PIN",attributes:{type:"text",inputmode:"numeric",maxLength:12,minLength:4},sensitive:!0,regex:/^$|^[0-9]{4,12}$/}},re="XXXX-XXXX-XXXX-XXXX",ae={height:"100%",width:"100%",margin:0,padding:0,border:0,position:"absolute",top:0,left:0,"user-select":"none"},le={position:"absolute",top:0,width:0,height:0,visibility:"hidden",left:"-99999999px","user-select":"none"},de={width:"100%",height:"100%",border:"0",padding:"0",margin:"0",outline:"none"},ce={WEBPACKAUTOFILL:"-webkit-autofill",BASE:"base",FOCUS:"focus",COMPLETE:"complete",EMPTY:"empty",INVALID:"invalid",GLOBAL:"global",REQUIRED_ASTERISK:"requiredAsterisk"};ce.BASE,ce.REQUIRED_ASTERISK;const ue={[ne.VISA]:{regex:/^4\d*/,maxCardLength:19,cardLengthRange:[13,16]},[ne.MASTERCARD]:{regex:/^(5[1-5]|222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720)\d*/,maxCardLength:16,cardLengthRange:[16]},[ne.AMEX]:{regex:/^3[47]\d*/,maxCardLength:15,cardLengthRange:[15]},[ne.DINERS_CLUB]:{regex:/^(36|38|30[0-5])\d*/,maxCardLength:16,cardLengthRange:[14,15,16,17,18,19]},[ne.DISCOVER]:{regex:/^(6011|65|64[4-9]|622)\d*/,maxCardLength:16,cardLengthRange:[16,17,18,19]},[ne.JCB]:{regex:/^35\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ne.HIPERCARD]:{regex:/^606282\d*/,maxCardLength:19,cardLengthRange:[14,15,16,17,18,19]},[ne.UNIONPAY]:{regex:/^62\d*/,maxCardLength:19,cardLengthRange:[16,17,18,19]},[ne.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]}};ne.DEFAULT,ne.AMEX,ne.DINERS_CLUB,ne.DISCOVER,ne.HIPERCARD,ne.JCB,ne.MAESTRO,ne.MASTERCARD,ne.UNIONPAY,ne.VISA;const Ee="MM/YY",_e=[Ee,"YYYY/MM","YY/MM","MM/YYYY"],he=["YY","YYYY"];var Ie;!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"}(Ie||(Ie={})),ie.CARD_NUMBER,ie.EXPIRATION_DATE,ie.EXPIRATION_MONTH,ie.EXPIRATION_YEAR,ie.CVV,ie.EXPIRATION_DATE,ie.CARD_NUMBER,ie.CARDHOLDER_NAME,ie.INPUT_FIELD,B.INVALID_COLLECT_VALUE,ie.PIN,ie.EXPIRATION_MONTH,ie.EXPIRATION_YEAR,ie.CVV,ie.EXPIRATION_DATE,ie.CARD_NUMBER,ie.CARDHOLDER_NAME,ie.INPUT_FIELD,B.DEFAULT_REQUIRED_COLLECT_VALUE,ie.PIN,ie.EXPIRATION_MONTH,ie.EXPIRATION_YEAR;const pe=[ie.CARDHOLDER_NAME,ie.EXPIRATION_MONTH,ie.PIN,ie.CVV],me={X:"[0-9]"};class fe{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(fe.prototype,{constructor:e})}}
|
|
2
2
|
/* @copyright
|
|
3
3
|
Copyright (c) 2022 Skyflow, Inc.
|
|
4
|
-
*/const ve={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},Ne="https://assets.payrails.io/dad8cb0/card/index.html",Te="https://assets.payrails.io",Ae={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},Oe=(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 ye=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},Ae),e);return Object.assign(t.style,ae),Oe(t,i),t.getAttribute("id")||(t.id=t.name),t};const Re=()=>ve.IFRAME_SECURE_SITE,Le=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function ge(e){return JSON.parse(JSON.stringify(e))}var Se,Ce,De,Pe,be,Me,we;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Se||(Se={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Ce||(Ce={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(De||(De={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Pe||(Pe={})),function(e){e.DEV="DEV",e.PROD="PROD"}(be||(be={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(Me||(Me={})),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"}(we||(we={}));const Ue={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}},ke={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Ye="[Skyflow]",xe=(e,t,i)=>{if(i&&Ue[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Ue[i];t===Me.LOG&&n?console.log(`${Pe.DEBUG}: ${Ye} ${e}`):t===Me.LOG&&o?console.log(`${Pe.INFO}: ${Ye} ${e}`):t===Me.WARN&&s?console.warn(`${Pe.WARN}: ${Ye} ${e}`):t===Me.ERROR&&r&&console.error(`${Pe.ERROR}: ${Ye} ${e}`)}},Fe=(...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]})):""},Ve=(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 Be extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Fe(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Ge={INVALID_FIELD:{code:400,description:B.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:B.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:B.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:B.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:B.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:B.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:B.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:B.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:B.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:B.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:B.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:B.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:B.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:B.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:B.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:B.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:B.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:B.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:B.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:B.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:B.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:B.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:B.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:B.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:B.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:B.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:B.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:B.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:B.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:B.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:B.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:B.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:B.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:B.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:B.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:B.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:B.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:B.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:B.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:B.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:B.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:B.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:B.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:B.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:B.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:B.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:B.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:B.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:B.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:B.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:B.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:B.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:B.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:B.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:B.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:B.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:B.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:B.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:B.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:B.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:B.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:B.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:B.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:B.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:B.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:B.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:B.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:B.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:B.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:B.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:B.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:B.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:B.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:B.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:B.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:B.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:B.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:B.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:B.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:B.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:B.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:B.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:B.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:B.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:B.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:B.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:B.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:B.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:B.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:B.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:B.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:B.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:B.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:B.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:B.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:B.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:B.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:B.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:B.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:B.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:B.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:B.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:B.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:B.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:B.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:B.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:B.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:B.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:B.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:B.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:B.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:B.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:B.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:B.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:B.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:B.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:B.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:B.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:B.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:B.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:B.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:B.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:B.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:B.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:B.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:B.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:B.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:B.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:B.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:B.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:B.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:B.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:B.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:B.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:B.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:B.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:B.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:B.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:B.INVALID_INPUT_OPTIONS_TRANSLATION}},je=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Be(Ge.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Be(Ge.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Be(Ge.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 Be(Ge.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Be(Ge.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 Be(Ge.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 Be(Ge.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Be(Ge.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Be(Ge.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Be(Ge.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Be(Ge.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Xe=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},He=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Be(Ge.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},We=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Be(Ge.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Be(Ge.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&xe(G.COLLECT_ALT_TEXT_DEPERECATED,Me.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Be(Ge.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},ze=e=>{if(!e||!Array.isArray(e))throw new Be(Ge.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Be(Ge.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Be(Ge.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Be(Ge.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Be(Ge.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Be(Ge.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Be(Ge.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Ke=e=>"boolean"==typeof e;function $e(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const qe=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ie.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=ne.DEFAULT;return Object.entries(ue).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==ne.DEFAULT&&t===ne.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};function Je(e){var t,i,n,o,s;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(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}`;ve.IFRAME_SECURE_ORGIN=s,ve.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}if(null===(s=e.options)||void 0===s?void 0:s.deserializedData.usePayrailsFrames){if(!ve.IFRAME_SECURE_ORGIN||!ve.IFRAME_SECURE_SITE){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:ve.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:ve.IFRAME_SECURE_SITE}}),e}ve.IFRAME_SECURE_ORGIN=Te,ve.IFRAME_SECURE_SITE=Ne}}class Ze{constructor(e,t,i,n){this.setAttributess=e=>{Oe(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new Be(Ge.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Be(Ge.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}Oe(this.iframe,{src:Re()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==`${e}px`&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=ye({name:this.name})}}class Qe{}var et,tt,it,nt,ot,st,rt,at,lt,dt,ct,ut,Et,_t,ht,It,pt,mt,ft,vt;const Nt="Element";class Tt extends Qe{constructor(e,t,o,s,r=!1,a,l,d,c){var u;super(),this.type=bi.COLLECT,et.set(this,void 0),tt.set(this,!1),it.set(this,void 0),nt.set(this,void 0),ot.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),st.set(this,void 0),rt.set(this,new fe),at.set(this,void 0),lt.set(this,F.getEventBus()),dt.set(this,void 0),ct.set(this,[]),ut.set(this,!1),Et.set(this,void 0),_t.set(this,void 0),ht.set(this,!1),this.getID=()=>i(this,et,"f"),this.mount=e=>{var t;if(!e)throw new Be(Ge.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,t)=>{if(e.name===i(this,dt,"f").name){t(i(this,st,"f")),i(this,vt,"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,it,"f")[0],["name"]);i(this,nt,"f").length>1?i(this,nt,"f").forEach(((e,t)=>{i(this,at,"f")&&i(this,at,"f")._emit(`${H.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,it,"f")[t]),{elementType:e.elementType}))})):i(this,rt,"f")._emit(H.READY,Object.assign({},e)),i(this,lt,"f").off(W+this.containerId,o),xe(`${Fe(V.ELEMENT_MOUNTED,Nt,Ve(i(this,dt,"f").name))} `,Me.LOG,i(this,Et,"f").logLevel),i(this,ct,"f").forEach((e=>e())),n(this,ct,[],"f")}};if(i(this,nt,"f").length>1)i(this,dt,"f").mount(e),i(this,lt,"f").on(W+this.containerId,o);else{if(i(this,ht,"f"))return i(this,dt,"f").mount(e),void i(this,lt,"f").on(W+this.containerId,o);null===(t=i(this,at,"f"))||void 0===t||t.on(te,(t=>{(null==t?void 0:t.containerId)===this.containerId&&(i(this,dt,"f").mount(e),i(this,lt,"f").on(W+this.containerId,o))}))}},this.unmount=()=>{i(this,dt,"f").unmount()},this.update=e=>{let t=ge(e);const o=()=>{i(this,tt,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,st,Ot(i(this,st,"f"),t),"f"),n(this,nt,yt(i(this,st,"f")),"f"),i(this,tt,"f")?i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:i(this,nt,"f")[0],isSingleElementAPI:!0}):(i(this,nt,"f").forEach((e=>{i(this,lt,"f").emit(q,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:i(this,st,"f"),isSingleElementAPI:!1})),i(this,vt,"f").call(this)};i(this,ut,"f")?o():i(this,ct,"f").push(o)},It.set(this,(e=>{i(this,tt,"f")||i(this,rt,"f").on(q,(()=>{e(i(this,nt,"f"))}),!0)})),this.updateElement=e=>{i(this,lt,"f").emit(q,{name:e.elementName,options:e,isSingleElementAPI:!0})},pt.set(this,(()=>{i(this,it,"f").forEach(((e,t)=>{if(0===t){i(this,ot,"f").isEmpty=e.isEmpty,i(this,ot,"f").isComplete=e.isComplete,i(this,ot,"f").isValid=e.isValid,i(this,ot,"f").isFocused=e.isFocused,i(this,ot,"f").isRequired=e.isRequired,i(this,ot,"f").value={};const n=i(this,nt,"f")[t].elementName,o=e.value&&qe(e.value,e.elementType,i(this,_t,"f"));i(this,tt,"f")?i(this,ot,"f").value=o:i(this,ot,"f").value[n]=o}else i(this,ot,"f").isEmpty=i(this,ot,"f").isEmpty||e.isEmpty,i(this,ot,"f").isComplete=i(this,ot,"f").isComplete&&e.isComplete,i(this,ot,"f").isValid=i(this,ot,"f").isValid&&e.isValid,i(this,ot,"f").isFocused=i(this,ot,"f").isFocused||e.isFocused,i(this,ot,"f").isRequired=i(this,ot,"f").isRequired||e.isRequired,i(this,ot,"f").value||(i(this,ot,"f").value={}),i(this,nt,"f")[t].sensitive||(i(this,ot,"f").value[i(this,nt,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,ot,"f").isEmpty,isComplete:i(this,ot,"f").isComplete,isValid:i(this,ot,"f").isValid,isFocused:i(this,ot,"f").isFocused,value:i(this,ot,"f").value,required:i(this,ot,"f").isRequired}),this.getOptions=()=>{let e=ge(i(this,st,"f"));return i(this,tt,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},mt.set(this,(e=>{i(this,rt,"f").on($,(()=>{const t=i(this,nt,"f").map((e=>e.elementName));i(this,tt,"f")||t.push(i(this,dt,"f").name),e(t)}),!0)})),ft.set(this,(()=>{i(this,lt,"f").on(K,(e=>{if(i(this,tt,"f")&&e.event===H.READY&&e.name===i(this,dt,"f").name)i(this,rt,"f")._emit(H.READY);else{const t=i(this,nt,"f").length>1;i(this,nt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case H.FOCUS:r=H.FOCUS;break;case H.BLUR:r=H.BLUR;break;case H.CHANGE:r=H.CHANGE;break;case H.READY:r=H.READY;break;case H.SUBMIT:return void(null===(s=i(this,at,"f"))||void 0===s||s._emit(H.SUBMIT));default:throw new Be(Ge.INVALID_EVENT_TYPE,[],!0)}i(this,it,"f")[o].isEmpty=e.value.isEmpty,i(this,it,"f")[o].isValid=e.value.isValid,i(this,it,"f")[o].isComplete=e.value.isComplete,i(this,it,"f")[o].isFocused=e.value.isFocused,i(this,it,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,it,"f")[o].value=e.value.value:i(this,it,"f")[o].value=void 0,r=t?`${r}:${e.name}`:r,i(this,lt,"f").emit(H.HEIGHT+i(this,dt,"f").name,{},(e=>{i(this,dt,"f").setIframeHeight(e.height)})),i(this,pt,"f").call(this);const a=Object.assign(Object.assign({},i(this,it,"f")[o]),{elementType:n.elementType});t&&i(this,at,"f")?i(this,at,"f")._emit(r,a):i(this,rt,"f")._emit(r,a)}}))}}))})),vt.set(this,(()=>{const{rows:e}=i(this,st,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==se.radio.name&&e.elementType!==se.checkbox.name&&(e.value=void 0)}))})),n(this,nt,yt(i(this,st,"f")),"f")})),this.containerId=s.containerId,n(this,et,e,"f"),n(this,Et,d,"f"),n(this,st,Ot(t),"f"),n(this,nt,yt(t),"f"),n(this,tt,r,"f"),c&&n(this,at,c,"f"),n(this,_t,ke[i(this,Et,"f").env].doesReturnValue,"f"),this.elementType=i(this,tt,"f")?i(this,nt,"f")[0].elementType:"group",n(this,it,[],"f"),i(this,nt,"f").forEach((e=>{i(this,it,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,_t,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,dt,new Ze(i(this,st,"f").elementName,o,this.containerId,i(this,Et,"f").logLevel),"f"),i(this,ft,"f").call(this),i(this,mt,"f").call(this,a),i(this,It,"f").call(this,l),xe(Fe(V.CREATED_ELEMENT,Nt,Ve(i(this,dt,"f").name)),Me.LOG,i(this,Et,"f").logLevel),n(this,ht,s.isMounted,"f"),null===(u=i(this,at,"f"))||void 0===u||u.on(te,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,ht,!0,"f")}));const E=e=>{e.height&&e.height>0&&i(this,dt,"f").setIframeHeight(e.height)};i(this,lt,"f").on(H.MOUNTED,(e=>{s.type===bi.COMPOSABLE?i(this,nt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,ut,!0,"f"))})):e.name===i(this,nt,"f")[0].elementName&&(i(this,nt,"f")[0].isMounted=!0,n(this,ut,!0,"f")),i(this,lt,"f").emit(H.HEIGHT+i(this,dt,"f").name,{},E)}))}on(e,t){if(!Object.values(H).includes(e))throw new Be(Ge.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Be(Ge.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Be(Ge.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,rt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,dt,"f").name}isMounted(){return i(this,ut,"f")}isValidElement(){for(let e=0;e<i(this,nt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,nt,"f")[e],"table"))throw new Be(Ge.MISSING_TABLE_IN_COLLECT,[],!0);if(!i(this,nt,"f")[e].table)throw new Be(Ge.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof i(this,nt,"f")[e].table||i(this,nt,"f")[e].table instanceof String))throw new Be(Ge.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(i(this,nt,"f")[e],"column"))throw new Be(Ge.MISSING_COLUMN_IN_COLLECT,[],!0);if(!i(this,nt,"f")[e].column)throw new Be(Ge.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof i(this,nt,"f")[e].column||i(this,nt,"f")[e].column instanceof String))throw new Be(Ge.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==i(this,nt,"f")[e].skyflowID&&!i(this,nt,"f")[e].skyflowID)throw new Be(Ge.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){i(this,lt,"f").emit(Z,{name:$e(i(this,dt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,lt,"f").emit(Z,{name:$e(i(this,dt,"f").name),isTriggerError:!1})}setValue(e){i(this,Et,"f").env!==be.PROD?i(this,tt,"f")&&i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:Object.assign(Object.assign({},i(this,nt,"f")[0]),{value:e}),isSingleElementAPI:!0}):xe(Fe(G.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,nt,"f")[0].elementType),Me.WARN,i(this,Et,"f").logLevel)}clearValue(){i(this,Et,"f").env!==be.PROD?i(this,tt,"f")&&i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:Object.assign(Object.assign({},i(this,nt,"f")[0]),{value:""}),isSingleElementAPI:!0}):xe(Fe(G.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,nt,"f")[0].elementType),Me.WARN,i(this,Et,"f").logLevel)}}function At(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(se,e))throw new Be(Ge.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Be(Ge.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Be(Ge.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(we).includes(e.type))throw new Be(Ge.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Be(Ge.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Be(Ge.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===we.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Be(Ge.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===we.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Be(Ge.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}=se[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===se.radio.name||e===se.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==se.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 Ot(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(B.CANNOT_CHANGE_ELEMENT);At(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({},de),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},E=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ce).forEach((i=>{if(e[i]||t[i])switch(i){case ce.BASE:t[i]=Object.assign({},t[i]);break;case ce.FOCUS:t[ce.BASE]=Object.assign(Object.assign({},t[ce.BASE]),{":focus":Object.assign({},t[ce.BASE]&&t[ce.BASE][":focus"])});break;case ce.WEBPACKAUTOFILL:t[ce.BASE]=Object.assign(Object.assign({},t[ce.BASE]),{":-webkit-autofill":Object.assign({},t[ce.BASE]&&t[ce.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ce.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`)}))}))}(u,E),l.labelStyles={labelClasses:u},l.labelStyles.styles=E}))})),t}et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Et=new WeakMap,_t=new WeakMap,ht=new WeakMap,It=new WeakMap,pt=new WeakMap,mt=new WeakMap,ft=new WeakMap,vt=new WeakMap;const yt=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Rt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===we.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Be(Ge.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof Tt)))throw new Be(Ge.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof Tt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===we.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Xe(e.params.regex))throw new Be(Ge.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Xe(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Lt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(pe.includes(e)?(xe(Fe(G.INPUT_FORMATTING_NOT_SUPPROTED,e),Me.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===se.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Be(Ge.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 Be(Ge.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:me]}),null==n||delete n.format,null==n||delete n.translation)),e===se.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)===re&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===se.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&_e.includes(o),e||xe(Fe(G.INVALID_EXPIRATION_DATE_FORMAT,_e.toString()),Me.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():Ee}),null==n||delete n.translation}else if(e===se.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&he.includes(e))(n.format.toUpperCase()),e||xe(Fe(G.INVALID_EXPIRATION_YEAR_FORMAT,he.toString()),Me.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")&&!Ke(n.enableCardIcon))throw new Be(Ge.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Ke(n.enableCopy))throw new Be(Ge.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Ke(n.required))throw new Be(Ge.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function gt(){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 St{}var Ct,Dt,Pt,bt,Mt,wt,Ut,kt,Yt,xt,Ft,Vt;const Bt="CollectContainer";class Gt extends St{constructor(e,t,o,s){super(),Ct.set(this,void 0),Dt.set(this,{}),Pt.set(this,void 0),bt.set(this,void 0),Mt.set(this,void 0),this.type=bi.COLLECT,wt.set(this,void 0),Ut.set(this,!1),this.create=(e,t={required:!1})=>{We(e,i(this,bt,"f").logLevel);const n=Rt(e),o=Lt(e.type,t,i(this,bt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),o),{validations:n})]}]};return i(this,kt,"f").call(this,s,!0)},kt.set(this,((e,t=!1)=>{const n=[],o=ge(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||se[i].sensitive,t.replacePattern=t.replacePattern||se[i].replacePattern,t.mask=t.mask||se[i].mask,t.isMounted=!1,t.elementType!==se.radio.name&&t.elementType!==se.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${X}:${t.elementType}:${btoa(gt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=t?n[0].elementName:`${X}:group:${btoa(o.name)}`,t&&!i(this,Dt,"f")[n[0].elementName]&&i(this,Vt,"f").call(this,n[0].name))throw new Be(Ge.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=i(this,Dt,"f")[o.elementName];if(s)t?s.update(n[0]):s.update(o);else{const e=gt();s=new Tt(e,o,i(this,Pt,"f"),{containerId:i(this,Ct,"f"),isMounted:i(this,Ut,"f"),type:this.type},t,i(this,xt,"f"),i(this,Ft,"f"),i(this,bt,"f"),i(this,wt,"f")),i(this,Dt,"f")[o.elementName]=s,i(this,Mt,"f")[e]=s}return t||n.forEach((e=>{const t=e.elementName;i(this,Dt,"f")[t]?i(this,Dt,"f")[t].update(e):i(this,Dt,"f")[t]=this.create(e.elementType,s)})),s})),Yt.set(this,(e=>{Object.keys(i(this,Dt,"f")).forEach((t=>{t===e&&delete i(this,Dt,"f")[t]}))})),xt.set(this,(e=>{e.forEach((e=>{i(this,Yt,"f").call(this,e)}))})),Ft.set(this,(e=>{e.forEach((e=>{i(this,Dt,"f")[e.elementName]&&i(this,Dt,"f")[e.elementName].update(e)}))})),Vt.set(this,(e=>{const t=Object.keys(i(this,Dt,"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{if(He(i(this,Pt,"f").clientJSON.config),Object.values(i(this,Dt,"f")).forEach((e=>{if(!e.isMounted())throw new Be(Ge.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Ke(e.tokens))throw new Be(Ge.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&je(e.additionalFields),(null==e?void 0:e.upsert)&&ze(null==e?void 0:e.upsert),this.bus.emit(z+i(this,Ct,"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)?(xe(`${JSON.stringify(null==e?void 0:e.error)}`,Me.ERROR,i(this,bt,"f").logLevel),n(null==e?void 0:e.error)):(xe(Fe(V.COLLECT_SUBMIT_SUCCESS,Bt),Me.LOG,i(this,bt,"f").logLevel),t(e))})),xe(Fe(V.EMIT_EVENT,Bt,z),Me.LOG,i(this,bt,"f").logLevel)}catch(e){xe(`${e.message}`,Me.ERROR,i(this,bt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=F.getEventBus(),n(this,Ct,gt(),"f"),n(this,Pt,t,"f"),n(this,Mt,o,"f"),n(this,bt,s,"f"),n(this,wt,new fe,"f"),this.iframe=ye({name:`${j}:${i(this,Ct,"f")}:${i(this,bt,"f").logLevel}`}),Oe(this.iframe,{src:Re()}),Le(this.iframe,Object.assign({},le)),xe(Fe(V.CREATE_COLLECT_CONTAINER,Bt),Me.LOG,i(this,bt,"f").logLevel);const r=(e,o)=>{e.name===j+i(this,Ct,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,Ut,!0,"f"),i(this,wt,"f")._emit(te,{containerId:i(this,Ct,"f")}),this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).off(W+i(this,Ct,"f"),r))};this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).on(W+i(this,Ct,"f"),r),document.body.append(this.iframe)}}Ct=new WeakMap,Dt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,Yt=new WeakMap,xt=new WeakMap,Ft=new WeakMap,Vt=new WeakMap;var jt,Xt,Ht,Wt,zt,Kt,$t,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,di,ci,ui,Ei=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},_i=function(e){return e},hi=s((function(e){return e&&e.length?Ei(e,_i):0}));class Ii{constructor(e,t){jt.set(this,void 0),Xt.set(this,void 0),this.type=bi.COMPOSABLE,Ht.set(this,!1),Wt.set(this,!1),this.update=e=>{n(this,Wt,!0,"f"),i(this,Ht,"f")?(i(this,Xt,"f")._emit(Q,{elementName:i(this,jt,"f"),elementOptions:e}),n(this,Wt,!1,"f")):i(this,Wt,"f")&&i(this,Xt,"f").on(`${De.READY}:${i(this,jt,"f")}`,(()=>{i(this,Xt,"f")._emit(Q,{elementName:i(this,jt,"f"),elementOptions:e}),n(this,Ht,!0,"f"),n(this,Wt,!1,"f")}))},n(this,jt,e,"f"),n(this,Xt,t,"f"),i(this,Xt,"f").on(`${De.READY}:${i(this,jt,"f")}`,(()=>{n(this,Ht,!0,"f")}))}on(e,t){if(!Object.values(H).includes(e))throw new Be(Ge.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Be(Ge.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Be(Ge.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Xt,"f").on(`${e}:${i(this,jt,"f")}`,(e=>{void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value&&(e.value=e.value.slice(0,6)),delete e.isComplete,delete e.name,t(e)}))}}jt=new WeakMap,Xt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap;const pi="CollectContainer";class mi extends St{constructor(e,t,o,s){super(),zt.set(this,void 0),Kt.set(this,{}),$t.set(this,void 0),qt.set(this,{rows:[]}),Jt.set(this,[]),Zt.set(this,void 0),Qt.set(this,void 0),ei.set(this,void 0),ti.set(this,!1),ii.set(this,void 0),ni.set(this,void 0),this.type=bi.COMPOSABLE,oi.set(this,!1),si.set(this,{}),this.create=(e,t={required:!1})=>{We(e,i(this,Zt,"f").logLevel);const n=Rt(e),o=Lt(e.type,t,i(this,Zt,"f").logLevel),s=`${X}:${e.type}:${btoa(gt())}`;return i(this,Jt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new Ii(s,i(this,ei,"f"))},ri.set(this,((e,t=!1)=>{const o=[];if(n(this,si,ge(e),"f"),i(this,si,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||se[i].sensitive,t.replacePattern=t.replacePattern||se[i].replacePattern,t.mask=t.mask||se[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),i(this,si,"f").elementName=t?o[0].elementName:`${X}:group:${btoa(i(this,si,"f").name)}`,t&&!i(this,Kt,"f")[o[0].elementName]&&i(this,ci,"f").call(this,o[0].name))throw new Be(Ge.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=i(this,Kt,"f")[i(this,si,"f").elementName];if(s)t?s.update(o[0]):s.update(i(this,si,"f"));else{const e=gt();s=new Tt(e,i(this,si,"f"),i(this,$t,"f"),{containerId:i(this,zt,"f"),isMounted:i(this,oi,"f"),type:this.type},!0,i(this,li,"f"),i(this,di,"f"),i(this,Zt,"f"),i(this,ei,"f")),i(this,Kt,"f")[i(this,si,"f").elementName]=s,i(this,Qt,"f")[e]=s}return s})),ai.set(this,(e=>{Object.keys(i(this,Kt,"f")).forEach((t=>{t===e&&delete i(this,Kt,"f")[t]}))})),li.set(this,(e=>{e.forEach((e=>{i(this,ai,"f").call(this,e)}))})),di.set(this,(e=>{e.forEach((e=>{i(this,Kt,"f")[e.elementName]&&i(this,Kt,"f")[e.elementName].update(e)}))})),ci.set(this,(e=>{const t=Object.keys(i(this,Kt,"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(H).includes(e))throw new Be(Ge.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Be(Ge.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Be(Ge.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,ei,"f").on(H.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new Be(Ge.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:t}=i(this,ii,"f");if(hi(t)!==i(this,Jt,"f").length)throw new Be(Ge.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(t.forEach(((e,t)=>{i(this,qt,"f").rows=[...i(this,qt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,qt,"f").rows[t].elements.push(i(this,Jt,"f")[o]),o++})),i(this,ii,"f").styles&&(i(this,qt,"f").styles=Object.assign({},i(this,ii,"f").styles)),i(this,ii,"f").errorTextStyles&&(i(this,qt,"f").errorTextStyles=Object.assign({},i(this,ii,"f").errorTextStyles)),i(this,oi,"f"))return n(this,ni,i(this,ri,"f").call(this,i(this,qt,"f"),!1),"f"),i(this,ni,"f").mount(e),void n(this,ti,!0,"f");i(this,ei,"f").on(ee+i(this,zt,"f"),(()=>{n(this,ni,i(this,ri,"f").call(this,i(this,qt,"f"),!1),"f"),i(this,ni,"f").mount(e),n(this,ti,!0,"f")}))},this.unmount=()=>{var e;null===(e=i(this,ni,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(He(i(this,$t,"f").clientJSON.config),!i(this,ti,"f")){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}if(yt(i(this,si,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Be(Ge.ELEMENTS_NOT_MOUNTED,[],!0)})),Object.values(i(this,Kt,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Be(Ge.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&je(e.additionalFields),(null==e?void 0:e.upsert)&&ze(null==e?void 0:e.upsert),this.bus.emit(z+i(this,zt,"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)?(xe(`${JSON.stringify(null==e?void 0:e.error)}`,Me.ERROR,i(this,Zt,"f").logLevel),n(null==e?void 0:e.error)):(xe(Fe(V.COLLECT_SUBMIT_SUCCESS,pi),Me.LOG,i(this,Zt,"f").logLevel),t(e))})),xe(Fe(V.EMIT_EVENT,pi,z),Me.LOG,i(this,Zt,"f").logLevel)}catch(e){xe(`${e.message}`,Me.ERROR,i(this,Zt,"f").logLevel),n(e)}})),ui.set(this,(()=>{i(this,ei,"f").on(Q,(e=>{let t;const n=i(this,Jt,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,ni,"f")&&i(this,ni,"f").updateElement(Object.assign({},n[t]))}))})),this.bus=F.getEventBus(),n(this,zt,gt(),"f"),n(this,$t,t,"f"),n(this,Qt,o,"f"),n(this,Zt,s,"f"),n(this,ii,e,"f"),n(this,ei,new fe,"f"),this.iframe=ye({name:`${j}:${i(this,zt,"f")}:${i(this,Zt,"f").logLevel}`}),Oe(this.iframe,{src:Re()}),Le(this.iframe,Object.assign({},le)),xe(Fe(V.CREATE_COLLECT_CONTAINER,pi),Me.LOG,i(this,Zt,"f").logLevel);const l=(e,o)=>{e.name===j+i(this,zt,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,oi,!0,"f"),i(this,ei,"f")._emit(ee+i(this,zt,"f"),{containerId:i(this,zt,"f")}),this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).off(W+i(this,zt,"f"),l))};this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).on(W+i(this,zt,"f"),l),document.body.append(this.iframe),i(this,ui,"f").call(this)}}function fi(e){this.message=e}zt=new WeakMap,Kt=new WeakMap,$t=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,ci=new WeakMap,ui=new WeakMap,fi.prototype=new Error,fi.prototype.name="InvalidCharacterError";var vi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new fi("'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 Ni(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(vi(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 vi(t)}}function Ti(e){this.message=e}Ti.prototype=new Error,Ti.prototype.name="InvalidTokenError";const Ai=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 Ti("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Ni(e.split(".")[i]))}catch(e){throw new Ti("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 Oi,yi,Ri,Li,gi,Si,Ci,Di,Pi,bi,Mi={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class wi{constructor(e,t){Oi.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,u,E;let _=null,h=null;return/Windows/.test(e)?(_="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)?(_="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)?(_="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)?(_="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)&&(_="Linux",h=null!==(E=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==E?E:null),{os:_,version:h}}(i.userAgent),u=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 E;return{sdk_name_version:d,sdk_client_device_model:(E=i.userAgent,/(ipad|tablet)/gi.test(E)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(E)?"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=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Mi,i(this,Oi,"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(Ie.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(Ie.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(Ie.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 Be({code:l.status,description:t},[],!0))}else a&&a.includes("text/plain")?n(new Be({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Be({code:l.status,description:d?`${B.ERROR_OCCURED} - requestId: ${d}`:B.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&t(JSON.parse(l.response)),t(l.response)},l.onerror=()=>{n(new Be(Ge.NETWORK_ERROR,[],!0))}}else n(new Be(Ge.CONNECTION_ERROR,[],!0))})),this.config=e,n(this,Oi,t,"f")}toJSON(){return{config:this.config,metaData:i(this,Oi,"f")}}static fromJSON(e){return new wi(e.config,e.metaData)}}Oi=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(bi||(bi={}));const Ui="Skyflow";class ki{constructor(e){var t,o;yi.set(this,void 0),Ri.set(this,gt()),Li.set(this,{uuid:i(this,Ri,"f"),clientDomain:window.location.origin}),gi.set(this,""),Si.set(this,void 0),Ci.set(this,void 0),Di.set(this,void 0),Pi.set(this,void 0),this.bus=F.getEventBus();const s=localStorage.getItem("sdk_version")||"";i(this,Li,"f").sdkVersion=s,n(this,yi,new wi(Object.assign({},e),i(this,Li,"f")),"f"),n(this,Ci,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Pe.ERROR,"f"),n(this,Di,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||be.PROD,"f"),n(this,Pi,{},"f"),this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).on(J+i(this,Ri,"f"),((e,t)=>{xe(Fe(V.CAPTURED_BEARER_TOKEN_EVENT,Ui),Me.LOG,i(this,Ci,"f")),!i(this,yi,"f").config.getBearerToken||i(this,gi,"f")&&Ai(i(this,gi,"f"))?(xe(Fe(V.REUSE_BEARER_TOKEN,Ui),Me.LOG,i(this,Ci,"f")),t({authToken:i(this,gi,"f")})):i(this,yi,"f").config.getBearerToken().then((e=>{Ai(e)?(xe(Fe(V.BEARER_TOKEN_RESOLVED,Ui),Me.LOG,i(this,Ci,"f")),n(this,gi,e,"f"),t({authToken:i(this,gi,"f")})):(xe(B.INVALID_BEARER_TOKEN,Me.ERROR,i(this,Ci,"f")),t({error:B.INVALID_BEARER_TOKEN}))})).catch((e=>{xe(B.BEARER_TOKEN_REJECTED,Me.ERROR,i(this,Ci,"f")),t({error:e})}))})),xe(Fe(V.BEARER_TOKEN_LISTENER,Ui),Me.LOG,i(this,Ci,"f")),xe(Fe(V.CURRENT_ENV,Ui,i(this,Di,"f")),Me.LOG,i(this,Ci,"f")),xe(Fe(V.CURRENT_LOG_LEVEL,Ui,i(this,Ci,"f")),Me.LOG,i(this,Ci,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Pe.ERROR;Je(e),xe(Fe(V.INITIALIZE_CLIENT,Ui),Me.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 ki(n);return xe(Fe(V.CLIENT_INITIALIZED,Ui),Me.LOG,i),s}container(e,t){switch(e){case bi.COLLECT:{const n=new Gt(t,Object.assign(Object.assign({},i(this,Li,"f")),{clientJSON:i(this,yi,"f").toJSON(),containerType:e}),i(this,Pi,"f"),{logLevel:i(this,Ci,"f"),env:i(this,Di,"f")});return xe(Fe(V.COLLECT_CONTAINER_CREATED,Ui),Me.LOG,i(this,Ci,"f")),n}case bi.COMPOSABLE:{(e=>{if(!e)throw new Be(Ge.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Be(Ge.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Be(Ge.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Be(Ge.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Be(Ge.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Be(Ge.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Be(Ge.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Be(Ge.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(t);const n=new mi(t,Object.assign(Object.assign({},i(this,Li,"f")),{clientJSON:i(this,yi,"f").toJSON(),containerType:e}),i(this,Pi,"f"),{logLevel:i(this,Ci,"f"),env:i(this,Di,"f")});return xe(Fe(V.COLLECT_CONTAINER_CREATED,Ui),Me.LOG,i(this,Ci,"f")),n}default:if(!e)throw new Be(Ge.EMPTY_CONTAINER_TYPE,[],!0);throw new Be(Ge.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return bi}static get ElementType(){return ie}static get RedactionType(){return Se}static get RequestMethod(){return Ce}static get LogLevel(){return Pe}static get EventName(){return De}static get Env(){return be}static get ValidationRuleType(){return we}}function Yi(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,n,o=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:{}}),s=o.queryParams,r=o.dataAttributes;return{url:"".concat(t,"?").concat((i=s,n="",Object.keys(i).forEach((function(e){0!==n.length&&(n+="&"),n+=e+"="+i[e]})),n)),dataAttributes:r}}function xi(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 Fi(e,t){if(void 0===t&&(t=Vi()),Gi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Yi(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Bi(s);
|
|
4
|
+
*/const ve={IFRAME_SECURE_SITE:"https://js.skyflow.com/v1/elements/index.html",IFRAME_SECURE_ORGIN:"https://js.skyflow.com"},Ne="https://assets.payrails.io/2ab28a7/card/index.html",Te="https://assets.payrails.io",Ae={src:"about:blank",frameBorder:0,allowtransparency:!0,scrolling:"no",style:"width: 100%;",allow:"clipboard-read; clipboard-write"},ye=(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 Oe=(e={})=>{const t=document.createElement("iframe"),i=Object.assign(Object.assign({},Ae),e);return Object.assign(t.style,ae),ye(t,i),t.getAttribute("id")||(t.id=t.name),t};const Re=()=>ve.IFRAME_SECURE_SITE,Le=(e,t)=>{Object.keys(t).forEach((i=>{Object.prototype.hasOwnProperty.call(t,i)&&(e.style[i]=t[i])}))};function ge(e){return JSON.parse(JSON.stringify(e))}var Se,Ce,De,Pe,be,Me,we;!function(e){e.DEFAULT="DEFAULT",e.PLAIN_TEXT="PLAIN_TEXT",e.MASKED="MASKED",e.REDACTED="REDACTED"}(Se||(Se={})),function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.PATCH="PATCH",e.DELETE="DELETE"}(Ce||(Ce={})),function(e){e.CHANGE="CHANGE",e.READY="READY",e.FOCUS="FOCUS",e.BLUR="BLUR",e.SUBMIT="SUBMIT"}(De||(De={})),function(e){e.WARN="WARN",e.INFO="INFO",e.DEBUG="DEBUG",e.ERROR="ERROR"}(Pe||(Pe={})),function(e){e.DEV="DEV",e.PROD="PROD"}(be||(be={})),function(e){e.LOG="LOG",e.WARN="WARN",e.ERROR="ERROR"}(Me||(Me={})),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"}(we||(we={}));const Ue={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}},ke={PROD:{doesReturnValue:!1},DEV:{doesReturnValue:!0}},Ye="[Skyflow]",xe=(e,t,i)=>{if(i&&Ue[i]){const{showDebugLogs:n,showInfoLogs:o,showWarnLogs:s,showErrorLogs:r}=Ue[i];t===Me.LOG&&n?console.log(`${Pe.DEBUG}: ${Ye} ${e}`):t===Me.LOG&&o?console.log(`${Pe.INFO}: ${Ye} ${e}`):t===Me.WARN&&s?console.warn(`${Pe.WARN}: ${Ye} ${e}`):t===Me.ERROR&&r&&console.error(`${Pe.ERROR}: ${Ye} ${e}`)}},Fe=(...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]})):""},Ve=(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 Be extends Error{constructor(e,t,i=!1){const n={code:e.code,description:t&&(null==t?void 0:t.length)>0?Fe(e.description,...t):e.description};super(n.description),i?this.error=n:this.errors=[n]}}const Ge={INVALID_FIELD:{code:400,description:B.INVALID_FIELD},VAULTID_IS_REQUIRED:{code:400,description:B.VAULTID_IS_REQUIRED},EMPTY_VAULTID_IN_INIT:{code:400,description:B.EMPTY_VAULTID_IN_INIT},VAULTURL_IS_REQUIRED:{code:400,description:B.VAULTURL_IS_REQUIRED},EMPTY_VAULTURL_IN_INIT:{code:400,description:B.EMPTY_VAULTURL_IN_INIT},INVALID_VAULTURL_IN_INIT:{code:400,description:B.INVALID_VAULTURL_IN_INIT},GET_BEARER_TOKEN_IS_REQUIRED:{code:400,description:B.GET_BEARER_TOKEN_IS_REQUIRED},EMPTY_CONTAINER_TYPE:{code:400,description:B.EMPTY_CONTAINER_TYPE},INVALID_CONTAINER_TYPE:{code:400,description:B.INVALID_CONTAINER_TYPE},UNIQUE_ELEMENT_NAME:{code:400,description:B.UNIQUE_ELEMENT_NAME},ELEMENTS_NOT_MOUNTED:{code:400,description:B.ELEMENTS_NOT_MOUNTED},MISSING_TABLE_IN_COLLECT:{code:400,description:B.MISSING_TABLE_IN_COLLECT},EMPTY_TABLE_IN_COLLECT:{code:400,description:B.EMPTY_TABLE_IN_COLLECT},EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_COLLECT:{code:400,description:B.INVALID_TABLE_IN_COLLECT},INVALID_SKYFLOWID_IN_COLLECT:{code:400,description:B.INVALID_SKYFLOWID_IN_COLLECT},MISSING_COLUMN_IN_COLLECT:{code:400,description:B.MISSING_COLUMN_IN_COLLECT},EMPTY_COLUMN_IN_COLLECT:{code:400,description:B.EMPTY_TABLE_IN_COLLECT},INVALID_COLUMN_IN_COLLECT:{code:400,description:B.INVALID_COLUMN_IN_COLLECT},CLIENT_CONNECTION:{code:400,description:B.CLIENT_CONNECTION},RECORDS_KEY_NOT_FOUND:{code:404,description:B.RECORDS_KEY_NOT_FOUND},EMPTY_RECORDS_IN_INSERT:{code:400,description:B.EMPTY_RECORDS_IN_INSERT},INVALID_RECORDS_IN_INSERT:{code:404,description:B.INVALID_RECORDS_IN_INSERT},INVALID_TABLE_IN_INSERT:{code:400,description:B.INVALID_TABLE_IN_INSERT},EMPTY_TABLE_IN_INSERT:{code:400,description:B.EMPTY_TABLE_IN_INSERT},MISSING_TABLE_IN_INSERT:{code:400,description:B.MISSING_TABLE_IN_INSERT},EMPTY_FIELDS_IN_INSERT:{code:400,description:B.EMPTY_FIELDS_IN_INSERT},MISSING_FIELDS_IN_INSERT:{code:404,description:B.MISSING_FIELDS_IN_INSERT},INVALID_FIELDS_IN_INSERT:{code:404,description:B.INVALID_FIELDS_IN_INSERT},INVALID_TOKENS_IN_INSERT:{code:404,description:B.INVALID_TOKENS_IN_INSERT},RECORDS_KEY_NOT_FOUND_DETOKENIZE:{code:404,description:B.RECORDS_KEY_NOT_FOUND_DETOKENIZE},EMPTY_RECORDS_DETOKENIZE:{code:400,description:B.EMPTY_RECORDS_DETOKENIZE},INVALID_RECORDS_IN_DETOKENIZE:{code:404,description:B.INVALID_RECORDS_IN_DETOKENIZE},MISSING_TOKEN_IN_DETOKENIZE:{code:400,description:B.MISSING_TOKEN_IN_DETOKENIZE},INVALID_TOKEN_IN_DETOKENIZE:{code:400,description:B.INVALID_TOKEN_IN_DETOKENIZE},RECORDS_KEY_NOT_FOUND_GET:{code:400,description:B.RECORDS_KEY_NOT_FOUND_GET},INVALID_RECORDS_IN_GET:{code:400,description:B.INVALID_RECORDS_IN_GET},EMPTY_RECORDS_GET:{code:400,description:B.EMPTY_RECORDS_GET},MISSING_IDS_IN_GET:{code:400,description:B.MISSING_IDS_IN_GET},INVALID_IDS_IN_GET:{code:400,description:B.INVALID_IDS_IN_GET},INVALID_COLUMN_VALUES_IN_GET:{code:400,description:B.INVALID_COLUMN_VALUES_IN_GET},EMPTY_IDS_IN_GET:{code:400,description:B.EMPTY_IDS_IN_GET},INVALID_SKYFLOWID_TYPE_IN_GET:{code:400,description:B.INVALID_SKYFLOWID_TYPE_IN_GET},MISSING_TABLE_IN_GET:{code:400,description:B.MISSING_TABLE_IN_GET},INVALID_TABLE_IN_GET:{code:400,description:B.INVALID_TABLE_IN_GET},MISSING_REDACTION_IN_GET:{code:400,description:B.MISSING_REDACTION_IN_GET},INVALID_REDACTION_TYPE_IN_GET:{code:400,description:B.INVALID_REDACTION_TYPE_IN_GET},INVALID_TOKENS_IN_GET:{code:400,description:B.INVALID_TOKENS_IN_GET},TOKENS_GET_COLUMN_NOT_SUPPORTED:{code:400,description:B.TOKENS_GET_COLUMN_NOT_SUPPORTED},REDACTION_WITH_TOKENS_NOT_SUPPORTED:{code:400,description:B.REDACTION_WITH_TOKENS_NOT_SUPPORTED},INVALID_REDACTION_TYPE_IN_DETOKENIZE:{code:400,description:B.INVALID_REDACTION_TYPE_IN_DETOKENIZE},INVALID_TOKENS_IN_COLLECT:{code:404,description:B.INVALID_TOKENS_IN_COLLECT},RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS:{code:404,description:B.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS},INVALID_RECORDS_IN_ADDITIONAL_FIELDS:{code:404,description:B.INVALID_RECORDS_IN_ADDITIONAL_FIELDS},EMPTY_RECORDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_RECORDS_IN_ADDITIONAL_FIELDS},MISSING_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:B.MISSING_TABLE_IN_ADDITIONAL_FIELDS},INVALID_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:B.INVALID_TABLE_IN_ADDITIONAL_FIELDS},INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS:{code:400,description:B.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS},MISSING_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.MISSING_FIELDS_IN_ADDITIONAL_FIELDS},INVALID_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.INVALID_FIELDS_IN_ADDITIONAL_FIELDS},RECORDS_KEY_NOT_FOUND_DELETE:{code:400,description:B.RECORDS_KEY_NOT_FOUND_DELETE},EMPTY_RECORDS_IN_DELETE:{code:400,description:B.EMPTY_RECORDS_IN_DELETE},INVALID_RECORDS_IN_DELETE:{code:404,description:B.INVALID_RECORDS_IN_DELETE},INVALID_TABLE_IN_DELETE:{code:400,description:B.INVALID_TABLE_IN_DELETE},EMPTY_TABLE_IN_DELETE:{code:400,description:B.EMPTY_TABLE_IN_DELETE},MISSING_TABLE_IN_DELETE:{code:400,description:B.MISSING_TABLE_IN_DELETE},EMPTY_ID_IN_DELETE:{code:400,description:B.EMPTY_ID_IN_DELETE},MISSING_ID_IN_DELETE:{code:404,description:B.MISSING_ID_IN_DELETE},INVALID_ID_IN_DELETE:{code:404,description:B.INVALID_ID_IN_DELETE},EMPTY_TABLE_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_TABLE_IN_ADDITIONAL_FIELDS},EMPTY_FIELDS_IN_ADDITIONAL_FIELDS:{code:400,description:B.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS},EMPTY_TOKEN_IN_DETOKENIZE:{code:400,description:B.EMPTY_TOKEN_IN_DETOKENIZE},EMPTY_SKYFLOWID_IN_GET:{code:400,description:B.EMPTY_SKYFLOWID_IN_GET},EMPTY_TABLE_IN_GET:{code:400,description:B.EMPTY_TABLE_IN_GET},EMPTY_REDACTION_TYPE_IN_GET:{code:400,description:B.EMPTY_REDACTION_TYPE_IN_GET},DUPLICATE_ELEMENT:{code:400,description:B.DUPLICATE_ELEMENT},DUPLICATE_ELEMENT_ADDITIONAL_FIELDS:{code:400,description:B.DUPLICATE_ELEMENT_ADDITIONAL_FIELDS},MISSING_ELEMENT_TYPE:{code:400,description:B.MISSING_ELEMENT_TYPE},EMPTY_ELEMENT_TYPE:{code:400,description:B.EMPTY_ELEMENT_TYPE},INVALID_ELEMENT_TYPE:{code:400,description:B.INVALID_ELEMENT_TYPE},INVALID_ELEMENT_SELECTOR:{code:400,description:B.INVALID_ELEMENT_SELECTOR},FRAME_NOT_FOUND:{code:400,description:B.FRAME_NOT_FOUND},REQUIRED_PARAMS_NOT_PROVIDED:{code:400,description:B.REQUIRED_PARAMS_NOT_PROVIDED},INVALID_RECORD_COLUMN_VALUE:{code:400,description:B.INVALID_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_VALUE:{code:400,description:B.MISSING_RECORD_COLUMN_VALUE},MISSING_RECORD_COLUMN_NAME:{code:400,description:B.MISSING_RECORD_COLUMN_NAME},INVALID_EVENT_TYPE:{code:400,description:B.INVALID_EVENT_TYPE},INVALID_EVENT_LISTENER:{code:400,description:B.INVALID_EVENT_LISTENER},MISSING_HANDLER_IN_EVENT_LISTENER:{code:400,description:B.MISSING_HANDLER_IN_EVENT_LISTENER},INVALID_HANDLER_IN_EVENT_LISTENER:{code:400,description:B.INVALID_HANDLER_IN_EVENT_LISTENER},UNKNOWN_ERROR:{code:400,description:B.UNKNOWN_ERROR},CONNECTION_ERROR:{code:400,description:B.CONNECTION_ERROR},NETWORK_ERROR:{code:500,description:B.NETWORK_ERROR},COMPLETE_AND_VALID_INPUTS:{code:400,description:B.COMPLETE_AND_VALID_INPUTS},INVALID_VALIDATIONS_TYPE:{code:400,description:B.INVALID_VALIDATIONS_TYPE},MISSING_VALIDATION_RULE_TYPE:{code:400,description:B.MISSING_VALIDATION_RULE_TYPE},INVALID_VALIDATION_RULE_TYPE:{code:400,description:B.INVALID_VALIDATION_RULE_TYPE},MISSING_VALIDATION_RULE_PARAMS:{code:400,description:B.MISSING_VALIDATION_RULE_PARAMS},INVALID_VALIDATION_RULE_PARAMS:{code:400,description:B.INVALID_VALIDATION_RULE_PARAMS},MISSING_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:B.MISSING_REGEX_IN_REGEX_MATCH_RULE},INVALID_REGEX_IN_REGEX_MATCH_RULE:{code:400,description:B.INVALID_REGEX_IN_REGEX_MATCH_RULE},MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE:{code:400,description:B.MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE},MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:B.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE},INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE:{code:400,description:B.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE},ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE:{code:400,description:B.ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE},EMPTY_ELEMENT_IN_MOUNT:{code:400,description:B.EMPTY_ELEMENT_IN_MOUNT},INVALID_TABLE_IN_UPSERT_OPTION:{code:400,description:B.INVALID_TABLE_IN_UPSERT_OPTION},INVALID_COLUMN_IN_UPSERT_OPTION:{code:400,description:B.INVALID_COLUMN_IN_UPSERT_OPTION},INVALID_UPSERT_OPTION_TYPE:{code:400,description:B.INVALID_UPSERT_OPTION_TYPE},EMPTY_UPSERT_OPTIONS_ARRAY:{code:400,description:B.EMPTY_UPSERT_OPTIONS_ARRAY},INVALID_UPSERT_OPTION_OBJECT_TYPE:{code:400,description:B.INVALID_UPSERT_OPTION_OBJECT_TYPE},MISSING_TABLE_IN_UPSERT_OPTION:{code:400,description:B.MISSING_TABLE_IN_UPSERT_OPTION},MISSING_COLUMN_IN_UPSERT_OPTION:{code:400,description:B.MISSING_COLUMN_IN_UPSERT_OPTION},INVALID_RECORD_COLUMN_VALUE_TYPE:{code:400,description:B.INVALID_RECORD_COLUMN_VALUE_TYPE},INVALID_COLUMN_VALUES_TYPE:{code:400,description:B.INVALID_COLUMN_VALUES_TYPE},EMPTY_RECORD_COLUMN_VALUES:{code:400,description:B.EMPTY_RECORD_COLUMN_VALUES},EMPTY_COLUMN_VALUE:{code:400,description:B.EMPTY_COLUMN_VALUE},MISSING_IDS_OR_COLUMN_VALUES_IN_GET:{code:400,description:B.MISSING_IDS_OR_COLUMN_VALUES_IN_GET},SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED:{code:400,description:B.SKYFLOW_IDS_AND_COLUMN_NAME_BOTH_SPECIFIED},RECORDS_KEY_NOT_FOUND_GETBYID:{code:400,description:B.RECORDS_KEY_NOT_FOUND_GETBYID},INVALID_RECORDS_IN_GETBYID:{code:400,description:B.INVALID_RECORDS_IN_GETBYID},EMPTY_RECORDS_GETBYID:{code:400,description:B.EMPTY_RECORDS_GETBYID},MISSING_IDS_IN_GETBYID:{code:400,description:B.MISSING_IDS_IN_GETBYID},INVALID_IDS_IN_GETBYID:{code:400,description:B.INVALID_IDS_IN_GETBYID},EMPTY_IDS_IN_GETBYID:{code:400,description:B.EMPTY_IDS_IN_GETBYID},INVALID_SKYFLOWID_TYPE_IN_GETBYID:{code:400,description:B.INVALID_SKYFLOWID_TYPE_IN_GETBYID},MISSING_TABLE_IN_GETBYID:{code:400,description:B.MISSING_TABLE_IN_GETBYID},INVALID_TABLE_IN_GETBYID:{code:400,description:B.INVALID_TABLE_IN_GETBYID},MISSING_REDACTION_IN_GETBYID:{code:400,description:B.MISSING_REDACTION_IN_GETBYID},INVALID_REDACTION_TYPE_IN_GETBYID:{code:400,description:B.INVALID_REDACTION_TYPE_IN_GETBYID},EMPTY_SKYFLOWID_IN_GETBYID:{code:400,description:B.EMPTY_SKYFLOWID_IN_GETBYID},EMPTY_TABLE_IN_GETBYID:{code:400,description:B.EMPTY_TABLE_IN_GETBYID},EMPTY_REDACTION_TYPE_IN_GETBYID:{code:400,description:B.EMPTY_REDACTION_TYPE_IN_GETBYID},MISSING_COMPOSABLE_LAYOUT_KEY:{code:400,description:B.MISSING_COMPOSABLE_LAYOUT_KEY},EMPTY_COMPOSABLE_LAYOUT_ARRAY:{code:400,description:B.EMPTY_COMPOSABLE_LAYOUT_ARRAY},INVALID_COMPOSABLE_LAYOUT_TYPE:{code:400,description:B.INVALID_COMPOSABLE_LAYOUT_TYPE},NEGATIVE_VALUES_COMPOSABLE_LAYOUT:{code:400,description:B.NEGATIVE_VALUES_COMPOSABLE_LAYOUT},MISMATCH_ELEMENT_COUNT_LAYOUT_SUM:{code:400,description:B.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM},MISSING_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:B.MISSING_COMPOSABLE_CONTAINER_OPTIONS},INVALID_COMPOSABLE_CONTAINER_OPTIONS:{code:400,description:B.INVALID_COMPOSABLE_CONTAINER_OPTIONS},COMPOSABLE_CONTAINER_NOT_MOUNTED:{code:400,description:B.COMPOSABLE_CONTAINER_NOT_MOUNTED},INVALID_BOOLEAN_OPTIONS:{code:400,description:B.INVALID_BOOLEAN_OPTIONS},EMPTY_COLLECT_CUSTOM_FORMAT:{code:400,description:B.EMPTY_COLLECT_CUSTOM_FORMAT},INVALID_INPUT_OPTIONS_FORMAT:{code:400,description:B.INVALID_INPUT_OPTIONS_FORMAT},INVALID_INPUT_OPTIONS_TRANSLATION:{code:400,description:B.INVALID_INPUT_OPTIONS_TRANSLATION}},je=e=>{if(!e||!Object.prototype.hasOwnProperty.call(e,"records"))throw new Be(Ge.RECORDS_KEY_NOT_FOUND_IN_ADDITIONAL_FIELDS,[],!0);const{records:t}=e;if(!t||!Array.isArray(t))throw new Be(Ge.INVALID_RECORDS_IN_ADDITIONAL_FIELDS,[],!0);if(0===t.length)throw new Be(Ge.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 Be(Ge.MISSING_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.table)throw new Be(Ge.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 Be(Ge.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 Be(Ge.INVALID_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}if(!("string"==typeof e.table||e.table instanceof String))throw new Be(Ge.INVALID_TABLE_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"fields"))throw new Be(Ge.MISSING_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if(!e.fields)throw new Be(Ge.EMPTY_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0);if("object"!=typeof e.fields||Array.isArray(e.fields))throw new Be(Ge.INVALID_FIELDS_IN_ADDITIONAL_FIELDS,[`${t}`],!0)}))},Xe=e=>{let t=!0;try{new RegExp(e)}catch(e){t=!1}return t},He=e=>{if(!Object.prototype.hasOwnProperty.call(e,"getBearerToken"))throw new Be(Ge.GET_BEARER_TOKEN_IS_REQUIRED,[],!0)},We=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Be(Ge.MISSING_ELEMENT_TYPE,[],!0);if(!e.type)throw new Be(Ge.EMPTY_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(e,"altText")&&xe(G.COLLECT_ALT_TEXT_DEPERECATED,Me.WARN,t),Object.prototype.hasOwnProperty.call(e,"skyflowID")&&"string"!=typeof e.skyflowID)throw new Be(Ge.INVALID_SKYFLOWID_IN_COLLECT,[],!0)},ze=e=>{if(!e||!Array.isArray(e))throw new Be(Ge.INVALID_UPSERT_OPTION_TYPE,[],!0);if(!e.length)throw new Be(Ge.EMPTY_UPSERT_OPTIONS_ARRAY,[],!0);e.forEach(((e,t)=>{if(!e||"object"!=typeof e)throw new Be(Ge.INVALID_UPSERT_OPTION_OBJECT_TYPE,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"table"))throw new Be(Ge.MISSING_TABLE_IN_UPSERT_OPTION,[t],!0);if(!e.table||"string"!=typeof e.table||!e.table.length)throw new Be(Ge.INVALID_TABLE_IN_UPSERT_OPTION,[t],!0);if(!Object.prototype.hasOwnProperty.call(e,"column"))throw new Be(Ge.MISSING_COLUMN_IN_UPSERT_OPTION,[t],!0);if(!e.column||"string"!=typeof e.column||!e.column.length)throw new Be(Ge.INVALID_COLUMN_IN_UPSERT_OPTION,[t],!0)}))},Ke=e=>"boolean"==typeof e;function $e(e){const t=e.split(":");return t.length>2?(t.pop(),t.pop(),t.join(":")):""}const qe=(e,t,i)=>{if("string"!=typeof e)return e;if(t===ie.CARD_NUMBER){if(e=e&&e.replace(/\s/g,""),!i){const t=((e="")=>{const t=e.replace(/[\s-]/g,"");let i=ne.DEFAULT;return Object.entries(ue).forEach((([e,n])=>{n.regex.test(t)&&(i=e)})),i})(e),i=t!==ne.DEFAULT&&t===ne.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};function Je(e){var t,i,n,o,s;if((null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.customElementsURL)&&(e=>{if(!e||"https"!==e.substring(0,5).toLowerCase())return!1;try{if(new URL(e))return!0}catch(e){return!1}return!0})(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}`;ve.IFRAME_SECURE_ORGIN=s,ve.IFRAME_SECURE_SITE=null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.customElementsURL}if(null===(s=e.options)||void 0===s?void 0:s.deserializedData.usePayrailsFrames){if(!ve.IFRAME_SECURE_ORGIN||!ve.IFRAME_SECURE_SITE){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_IFRAME_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e,extra:{IFRAME_SECURE_ORGIN:ve.IFRAME_SECURE_ORGIN,IFRAME_SECURE_SITE:ve.IFRAME_SECURE_SITE}}),e}ve.IFRAME_SECURE_ORGIN=Te,ve.IFRAME_SECURE_SITE=Ne}}class Ze{constructor(e,t,i,n){this.setAttributess=e=>{ye(this.iframe,{src:e})},this.mount=e=>{var t;this.unmount();try{if("string"==typeof e){if(this.container=document.querySelector(e)||void 0,!this.container)throw new Be(Ge.INVALID_ELEMENT_SELECTOR,[],!0)}else{if(!(e instanceof HTMLElement))throw new Be(Ge.INVALID_ELEMENT_SELECTOR,[],!0);this.container=e}}catch(e){console.error(e)}ye(this.iframe,{src:Re()}),null===(t=this.container)||void 0===t||t.appendChild(this.iframe)},this.setIframeHeight=e=>{this.iframe.getAttribute("height")!==`${e}px`&&this.iframe.setAttribute("height",`${e}px`)},this.unmount=()=>{this.iframe.remove()},this.name=`${e}:${i}:${n}`,this.metadata=t,this.iframe=Oe({name:this.name})}}class Qe{}var et,tt,it,nt,ot,st,rt,at,lt,dt,ct,ut,Et,_t,ht,It,pt,mt,ft,vt;const Nt="Element";class Tt extends Qe{constructor(e,t,o,s,r=!1,a,l,d,c){var u;super(),this.type=bi.COLLECT,et.set(this,void 0),tt.set(this,!1),it.set(this,void 0),nt.set(this,void 0),ot.set(this,{isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:void 0,isRequired:!1}),st.set(this,void 0),rt.set(this,new fe),at.set(this,void 0),lt.set(this,F.getEventBus()),dt.set(this,void 0),ct.set(this,[]),ut.set(this,!1),Et.set(this,void 0),_t.set(this,void 0),ht.set(this,!1),this.getID=()=>i(this,et,"f"),this.mount=e=>{var t;if(!e)throw new Be(Ge.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const o=(e,t)=>{if(e.name===i(this,dt,"f").name){t(i(this,st,"f")),i(this,vt,"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,it,"f")[0],["name"]);i(this,nt,"f").length>1?i(this,nt,"f").forEach(((e,t)=>{i(this,at,"f")&&i(this,at,"f")._emit(`${H.READY}:${e.elementName}`,Object.assign(Object.assign({},i(this,it,"f")[t]),{elementType:e.elementType}))})):i(this,rt,"f")._emit(H.READY,Object.assign({},e)),i(this,lt,"f").off(W+this.containerId,o),xe(`${Fe(V.ELEMENT_MOUNTED,Nt,Ve(i(this,dt,"f").name))} `,Me.LOG,i(this,Et,"f").logLevel),i(this,ct,"f").forEach((e=>e())),n(this,ct,[],"f")}};if(i(this,nt,"f").length>1)i(this,dt,"f").mount(e),i(this,lt,"f").on(W+this.containerId,o);else{if(i(this,ht,"f"))return i(this,dt,"f").mount(e),void i(this,lt,"f").on(W+this.containerId,o);null===(t=i(this,at,"f"))||void 0===t||t.on(te,(t=>{(null==t?void 0:t.containerId)===this.containerId&&(i(this,dt,"f").mount(e),i(this,lt,"f").on(W+this.containerId,o))}))}},this.unmount=()=>{i(this,dt,"f").unmount()},this.update=e=>{let t=ge(e);const o=()=>{i(this,tt,"f")&&(t={rows:[{elements:[Object.assign({},t)]}]}),n(this,st,yt(i(this,st,"f"),t),"f"),n(this,nt,Ot(i(this,st,"f")),"f"),i(this,tt,"f")?i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:i(this,nt,"f")[0],isSingleElementAPI:!0}):(i(this,nt,"f").forEach((e=>{i(this,lt,"f").emit(q,{name:e.elementName,options:e,isSingleElementAPI:!0})})),i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:i(this,st,"f"),isSingleElementAPI:!1})),i(this,vt,"f").call(this)};i(this,ut,"f")?o():i(this,ct,"f").push(o)},It.set(this,(e=>{i(this,tt,"f")||i(this,rt,"f").on(q,(()=>{e(i(this,nt,"f"))}),!0)})),this.updateElement=e=>{i(this,lt,"f").emit(q,{name:e.elementName,options:e,isSingleElementAPI:!0})},pt.set(this,(()=>{i(this,it,"f").forEach(((e,t)=>{if(0===t){i(this,ot,"f").isEmpty=e.isEmpty,i(this,ot,"f").isComplete=e.isComplete,i(this,ot,"f").isValid=e.isValid,i(this,ot,"f").isFocused=e.isFocused,i(this,ot,"f").isRequired=e.isRequired,i(this,ot,"f").value={};const n=i(this,nt,"f")[t].elementName,o=e.value&&qe(e.value,e.elementType,i(this,_t,"f"));i(this,tt,"f")?i(this,ot,"f").value=o:i(this,ot,"f").value[n]=o}else i(this,ot,"f").isEmpty=i(this,ot,"f").isEmpty||e.isEmpty,i(this,ot,"f").isComplete=i(this,ot,"f").isComplete&&e.isComplete,i(this,ot,"f").isValid=i(this,ot,"f").isValid&&e.isValid,i(this,ot,"f").isFocused=i(this,ot,"f").isFocused||e.isFocused,i(this,ot,"f").isRequired=i(this,ot,"f").isRequired||e.isRequired,i(this,ot,"f").value||(i(this,ot,"f").value={}),i(this,nt,"f")[t].sensitive||(i(this,ot,"f").value[i(this,nt,"f")[t].elementName]=e.value||"")}))})),this.getState=()=>({isEmpty:i(this,ot,"f").isEmpty,isComplete:i(this,ot,"f").isComplete,isValid:i(this,ot,"f").isValid,isFocused:i(this,ot,"f").isFocused,value:i(this,ot,"f").value,required:i(this,ot,"f").isRequired}),this.getOptions=()=>{let e=ge(i(this,st,"f"));return i(this,tt,"f")?e=e.rows[0].elements[0]:e.rows.forEach((e=>{e.elements.forEach((e=>{delete e.elementName}))})),delete e.elementName,e},mt.set(this,(e=>{i(this,rt,"f").on($,(()=>{const t=i(this,nt,"f").map((e=>e.elementName));i(this,tt,"f")||t.push(i(this,dt,"f").name),e(t)}),!0)})),ft.set(this,(()=>{i(this,lt,"f").on(K,(e=>{if(i(this,tt,"f")&&e.event===H.READY&&e.name===i(this,dt,"f").name)i(this,rt,"f")._emit(H.READY);else{const t=i(this,nt,"f").length>1;i(this,nt,"f").forEach(((n,o)=>{var s;if(e.name===n.elementName){let r="";switch(e.event){case H.FOCUS:r=H.FOCUS;break;case H.BLUR:r=H.BLUR;break;case H.CHANGE:r=H.CHANGE;break;case H.READY:r=H.READY;break;case H.SUBMIT:return void(null===(s=i(this,at,"f"))||void 0===s||s._emit(H.SUBMIT));default:throw new Be(Ge.INVALID_EVENT_TYPE,[],!0)}i(this,it,"f")[o].isEmpty=e.value.isEmpty,i(this,it,"f")[o].isValid=e.value.isValid,i(this,it,"f")[o].isComplete=e.value.isComplete,i(this,it,"f")[o].isFocused=e.value.isFocused,i(this,it,"f")[o].isRequired=e.value.isRequired,Object.prototype.hasOwnProperty.call(e.value,"value")?i(this,it,"f")[o].value=e.value.value:i(this,it,"f")[o].value=void 0,r=t?`${r}:${e.name}`:r,i(this,lt,"f").emit(H.HEIGHT+i(this,dt,"f").name,{},(e=>{i(this,dt,"f").setIframeHeight(e.height)})),i(this,pt,"f").call(this);const a=Object.assign(Object.assign({},i(this,it,"f")[o]),{elementType:n.elementType});t&&i(this,at,"f")?i(this,at,"f")._emit(r,a):i(this,rt,"f")._emit(r,a)}}))}}))})),vt.set(this,(()=>{const{rows:e}=i(this,st,"f");e.forEach((e=>{e.elements.forEach((e=>{e.elementType!==se.radio.name&&e.elementType!==se.checkbox.name&&(e.value=void 0)}))})),n(this,nt,Ot(i(this,st,"f")),"f")})),this.containerId=s.containerId,n(this,et,e,"f"),n(this,Et,d,"f"),n(this,st,yt(t),"f"),n(this,nt,Ot(t),"f"),n(this,tt,r,"f"),c&&n(this,at,c,"f"),n(this,_t,ke[i(this,Et,"f").env].doesReturnValue,"f"),this.elementType=i(this,tt,"f")?i(this,nt,"f")[0].elementType:"group",n(this,it,[],"f"),i(this,nt,"f").forEach((e=>{i(this,it,"f").push({isEmpty:!0,isComplete:!1,isValid:!1,isFocused:!1,value:i(this,_t,"f")?"":void 0,elementType:e.elementType,name:e.elementName,isRequired:!1})})),n(this,dt,new Ze(i(this,st,"f").elementName,o,this.containerId,i(this,Et,"f").logLevel),"f"),i(this,ft,"f").call(this),i(this,mt,"f").call(this,a),i(this,It,"f").call(this,l),xe(Fe(V.CREATED_ELEMENT,Nt,Ve(i(this,dt,"f").name)),Me.LOG,i(this,Et,"f").logLevel),n(this,ht,s.isMounted,"f"),null===(u=i(this,at,"f"))||void 0===u||u.on(te,(e=>{(null==e?void 0:e.containerId)===this.containerId&&n(this,ht,!0,"f")}));const E=e=>{e.height&&e.height>0&&i(this,dt,"f").setIframeHeight(e.height)};i(this,lt,"f").on(H.MOUNTED,(e=>{s.type===bi.COMPOSABLE?i(this,nt,"f").forEach((t=>{e.name===t.elementName&&(t.isMounted=!0,n(this,ut,!0,"f"))})):e.name===i(this,nt,"f")[0].elementName&&(i(this,nt,"f")[0].isMounted=!0,n(this,ut,!0,"f")),i(this,lt,"f").emit(H.HEIGHT+i(this,dt,"f").name,{},E)}))}on(e,t){if(!Object.values(H).includes(e))throw new Be(Ge.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Be(Ge.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Be(Ge.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,rt,"f").on(e,(e=>{void 0===e.value&&(e.value=""),delete e.isComplete,delete e.name,t(e)}))}iframeName(){return i(this,dt,"f").name}isMounted(){return i(this,ut,"f")}isValidElement(){for(let e=0;e<i(this,nt,"f").length;e+=1){if(!Object.prototype.hasOwnProperty.call(i(this,nt,"f")[e],"table"))throw new Be(Ge.MISSING_TABLE_IN_COLLECT,[],!0);if(!i(this,nt,"f")[e].table)throw new Be(Ge.EMPTY_TABLE_IN_COLLECT,[],!0);if(!("string"==typeof i(this,nt,"f")[e].table||i(this,nt,"f")[e].table instanceof String))throw new Be(Ge.INVALID_TABLE_IN_COLLECT,[],!0);if(!Object.prototype.hasOwnProperty.call(i(this,nt,"f")[e],"column"))throw new Be(Ge.MISSING_COLUMN_IN_COLLECT,[],!0);if(!i(this,nt,"f")[e].column)throw new Be(Ge.EMPTY_COLUMN_IN_COLLECT,[],!0);if(!("string"==typeof i(this,nt,"f")[e].column||i(this,nt,"f")[e].column instanceof String))throw new Be(Ge.INVALID_COLUMN_IN_COLLECT,[],!0);if(void 0!==i(this,nt,"f")[e].skyflowID&&!i(this,nt,"f")[e].skyflowID)throw new Be(Ge.EMPTY_SKYFLOW_ID_IN_ADDITIONAL_FIELDS,[],!0)}return!0}setError(e){i(this,lt,"f").emit(Z,{name:$e(i(this,dt,"f").name),isTriggerError:!0,clientErrorText:e})}resetError(){i(this,lt,"f").emit(Z,{name:$e(i(this,dt,"f").name),isTriggerError:!1})}setValue(e){i(this,Et,"f").env!==be.PROD?i(this,tt,"f")&&i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:Object.assign(Object.assign({},i(this,nt,"f")[0]),{value:e}),isSingleElementAPI:!0}):xe(Fe(G.UNABLE_TO_SET_VALUE_IN_PROD_ENV,i(this,nt,"f")[0].elementType),Me.WARN,i(this,Et,"f").logLevel)}clearValue(){i(this,Et,"f").env!==be.PROD?i(this,tt,"f")&&i(this,lt,"f").emit(q,{name:i(this,dt,"f").name,options:Object.assign(Object.assign({},i(this,nt,"f")[0]),{value:""}),isSingleElementAPI:!0}):xe(Fe(G.UNABLE_TO_CLEAR_VALUE_IN_PROD_ENV,i(this,nt,"f")[0].elementType),Me.WARN,i(this,Et,"f").logLevel)}}function At(e,t,i={}){if("group"!==e&&!Object.prototype.hasOwnProperty.call(se,e))throw new Be(Ge.INVALID_ELEMENT_TYPE,[],!0);if(Object.prototype.hasOwnProperty.call(t,"validations")){if(!Array.isArray(t.validations))throw new Be(Ge.INVALID_VALIDATIONS_TYPE,[],!0);t.validations.forEach(((e,t)=>{if(!Object.prototype.hasOwnProperty.call(e,"type"))throw new Be(Ge.MISSING_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.values(we).includes(e.type))throw new Be(Ge.INVALID_VALIDATION_RULE_TYPE,[`${t}`],!0);if(!Object.prototype.hasOwnProperty.call(e,"params"))throw new Be(Ge.MISSING_VALIDATION_RULE_PARAMS,[`${t}`],!0);if("object"!=typeof e.params||Array.isArray(e.params)||null===e.params)throw new Be(Ge.INVALID_VALIDATION_RULE_PARAMS,[`${t}`],!0);if(e.type===we.REGEX_MATCH_RULE){if(!Object.prototype.hasOwnProperty.call(e.params,"regex"))throw new Be(Ge.MISSING_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0)}else if(e.type===we.LENGTH_MATCH_RULE&&!Object.prototype.hasOwnProperty.call(e.params,"min")&&!Object.prototype.hasOwnProperty.call(e.params,"max"))throw new Be(Ge.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}=se[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===se.radio.name||e===se.checkbox.name)&&!i.value)throw new Error("Elements radio and checkbox requires value attribute");if(!(e!==se.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 yt(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(B.CANNOT_CHANGE_ELEMENT);At(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({},de),c.base),l.classes=d,l.styles=c;const u=(null===(n=null==l?void 0:l.labelStyles)||void 0===n?void 0:n.classes)||{},E=(null===(o=null==l?void 0:l.labelStyles)||void 0===o?void 0:o.styles)||{};i&&function(e,t){Object.values(ce).forEach((i=>{if(e[i]||t[i])switch(i){case ce.BASE:t[i]=Object.assign({},t[i]);break;case ce.FOCUS:t[ce.BASE]=Object.assign(Object.assign({},t[ce.BASE]),{":focus":Object.assign({},t[ce.BASE]&&t[ce.BASE][":focus"])});break;case ce.WEBPACKAUTOFILL:t[ce.BASE]=Object.assign(Object.assign({},t[ce.BASE]),{":-webkit-autofill":Object.assign({},t[ce.BASE]&&t[ce.BASE][":-webkit-autofill"])});break;default:t[i]=Object.assign(Object.assign({},t[ce.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`)}))}))}(u,E),l.labelStyles={labelClasses:u},l.labelStyles.styles=E}))})),t}et=new WeakMap,tt=new WeakMap,it=new WeakMap,nt=new WeakMap,ot=new WeakMap,st=new WeakMap,rt=new WeakMap,at=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,Et=new WeakMap,_t=new WeakMap,ht=new WeakMap,It=new WeakMap,pt=new WeakMap,mt=new WeakMap,ft=new WeakMap,vt=new WeakMap;const Ot=e=>{const{rows:t}=e,i=[];return t.forEach((e=>{e.elements.forEach((e=>{i.push(e)}))})),i},Rt=e=>{const t=e.validations;return t&&Array.isArray(t)&&t.length>0&&t.forEach(((e,t)=>{if(e&&e.type===we.ELEMENT_VALUE_MATCH_RULE){if(e.params&&!Object.prototype.hasOwnProperty.call(e.params,"element"))throw new Be(Ge.MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);if(e.params&&(null==e.params.element||!(e.params.element instanceof Tt)))throw new Be(Ge.INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE,[`${t}`],!0);e.params&&e.params.element&&e.params.element instanceof Tt&&(e.params.element=e.params.element.iframeName())}else if(e&&e.type===we.REGEX_MATCH_RULE){if(e.params&&e.params.regex&&!Xe(e.params.regex))throw new Be(Ge.INVALID_REGEX_IN_REGEX_MATCH_RULE,[`${t}`],!0);e.params&&e.params.regex&&Xe(e.params.regex)&&(e.params.regex=e.params.regex.toString())}})),t},Lt=(e,t,i)=>{let n=Object.assign({required:!1},t);if((Object.prototype.hasOwnProperty.call(n,"format")||Object.prototype.hasOwnProperty.call(n,"translation"))&&(pe.includes(e)?(xe(Fe(G.INPUT_FORMATTING_NOT_SUPPROTED,e),Me.WARN,i),null==n||delete n.format,null==n||delete n.translation):e===se.INPUT_FIELD.name&&((e=>{if(e){if(Object.prototype.hasOwnProperty.call(e,"format")&&"string"!=typeof e.format)throw new Be(Ge.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 Be(Ge.INVALID_INPUT_OPTIONS_TRANSLATION,[],!0)}})(t),n=Object.assign(Object.assign({},n),{mask:[n.format,n.translation?n.translation:me]}),null==n||delete n.format,null==n||delete n.translation)),e===se.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)===re&&(e="-"),n=Object.assign(Object.assign({},n),{cardSeperator:e}),null==n||delete n.format,null==n||delete n.translation}else if(e===se.EXPIRATION_DATE.name){let e=!1;n.format&&(e=!!(o=n.format.toUpperCase())&&_e.includes(o),e||xe(Fe(G.INVALID_EXPIRATION_DATE_FORMAT,_e.toString()),Me.WARN,i)),n=Object.assign(Object.assign({},n),{format:e?n.format.toUpperCase():Ee}),null==n||delete n.translation}else if(e===se.EXPIRATION_YEAR.name){let e=!1;n.format&&(e=(e=>!!e&&he.includes(e))(n.format.toUpperCase()),e||xe(Fe(G.INVALID_EXPIRATION_YEAR_FORMAT,he.toString()),Me.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")&&!Ke(n.enableCardIcon))throw new Be(Ge.INVALID_BOOLEAN_OPTIONS,["enableCardIcon"],!0);if(Object.prototype.hasOwnProperty.call(n,"enableCopy")&&!Ke(n.enableCopy))throw new Be(Ge.INVALID_BOOLEAN_OPTIONS,["enableCopy"],!0);if(Object.prototype.hasOwnProperty.call(n,"required")&&!Ke(n.required))throw new Be(Ge.INVALID_BOOLEAN_OPTIONS,["required"],!0);return n};function gt(){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 St{}var Ct,Dt,Pt,bt,Mt,wt,Ut,kt,Yt,xt,Ft,Vt;const Bt="CollectContainer";class Gt extends St{constructor(e,t,o,s){super(),Ct.set(this,void 0),Dt.set(this,{}),Pt.set(this,void 0),bt.set(this,void 0),Mt.set(this,void 0),this.type=bi.COLLECT,wt.set(this,void 0),Ut.set(this,!1),this.create=(e,t={required:!1})=>{We(e,i(this,bt,"f").logLevel);const n=Rt(e),o=Lt(e.type,t,i(this,bt,"f").logLevel),s={rows:[{elements:[Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column,accept:t.allowedFileType},e),o),{validations:n})]}]};return i(this,kt,"f").call(this,s,!0)},kt.set(this,((e,t=!1)=>{const n=[],o=ge(e);if(o.rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||se[i].sensitive,t.replacePattern=t.replacePattern||se[i].replacePattern,t.mask=t.mask||se[i].mask,t.isMounted=!1,t.elementType!==se.radio.name&&t.elementType!==se.checkbox.name||(t.elementName=`${t.elementName}:${btoa(t.value)}`),t.elementName=`${X}:${t.elementType}:${btoa(gt())}`,t.label=e.label,t.skyflowID=e.skyflowID,n.push(t)}))})),o.elementName=t?n[0].elementName:`${X}:group:${btoa(o.name)}`,t&&!i(this,Dt,"f")[n[0].elementName]&&i(this,Vt,"f").call(this,n[0].name))throw new Be(Ge.UNIQUE_ELEMENT_NAME,[`${n[0].name}`],!0);let s=i(this,Dt,"f")[o.elementName];if(s)t?s.update(n[0]):s.update(o);else{const e=gt();s=new Tt(e,o,i(this,Pt,"f"),{containerId:i(this,Ct,"f"),isMounted:i(this,Ut,"f"),type:this.type},t,i(this,xt,"f"),i(this,Ft,"f"),i(this,bt,"f"),i(this,wt,"f")),i(this,Dt,"f")[o.elementName]=s,i(this,Mt,"f")[e]=s}return t||n.forEach((e=>{const t=e.elementName;i(this,Dt,"f")[t]?i(this,Dt,"f")[t].update(e):i(this,Dt,"f")[t]=this.create(e.elementType,s)})),s})),Yt.set(this,(e=>{Object.keys(i(this,Dt,"f")).forEach((t=>{t===e&&delete i(this,Dt,"f")[t]}))})),xt.set(this,(e=>{e.forEach((e=>{i(this,Yt,"f").call(this,e)}))})),Ft.set(this,(e=>{e.forEach((e=>{i(this,Dt,"f")[e.elementName]&&i(this,Dt,"f")[e.elementName].update(e)}))})),Vt.set(this,(e=>{const t=Object.keys(i(this,Dt,"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{if(He(i(this,Pt,"f").clientJSON.config),Object.values(i(this,Dt,"f")).forEach((e=>{if(!e.isMounted())throw new Be(Ge.ELEMENTS_NOT_MOUNTED,[],!0);e.isValidElement()})),Object.prototype.hasOwnProperty.call(e,"tokens")&&!Ke(e.tokens))throw new Be(Ge.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&je(e.additionalFields),(null==e?void 0:e.upsert)&&ze(null==e?void 0:e.upsert),this.bus.emit(z+i(this,Ct,"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)?(xe(`${JSON.stringify(null==e?void 0:e.error)}`,Me.ERROR,i(this,bt,"f").logLevel),n(null==e?void 0:e.error)):(xe(Fe(V.COLLECT_SUBMIT_SUCCESS,Bt),Me.LOG,i(this,bt,"f").logLevel),t(e))})),xe(Fe(V.EMIT_EVENT,Bt,z),Me.LOG,i(this,bt,"f").logLevel)}catch(e){xe(`${e.message}`,Me.ERROR,i(this,bt,"f").logLevel),n(e)}})),this.unmount=()=>{this.iframe.remove()},this.bus=F.getEventBus(),n(this,Ct,gt(),"f"),n(this,Pt,t,"f"),n(this,Mt,o,"f"),n(this,bt,s,"f"),n(this,wt,new fe,"f"),this.iframe=Oe({name:`${j}:${i(this,Ct,"f")}:${i(this,bt,"f").logLevel}`}),ye(this.iframe,{src:Re()}),Le(this.iframe,Object.assign({},le)),xe(Fe(V.CREATE_COLLECT_CONTAINER,Bt),Me.LOG,i(this,bt,"f").logLevel);const r=(e,o)=>{e.name===j+i(this,Ct,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,Ut,!0,"f"),i(this,wt,"f")._emit(te,{containerId:i(this,Ct,"f")}),this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).off(W+i(this,Ct,"f"),r))};this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).on(W+i(this,Ct,"f"),r),document.body.append(this.iframe)}}Ct=new WeakMap,Dt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,Mt=new WeakMap,wt=new WeakMap,Ut=new WeakMap,kt=new WeakMap,Yt=new WeakMap,xt=new WeakMap,Ft=new WeakMap,Vt=new WeakMap;var jt,Xt,Ht,Wt,zt,Kt,$t,qt,Jt,Zt,Qt,ei,ti,ii,ni,oi,si,ri,ai,li,di,ci,ui,Ei=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},_i=function(e){return e},hi=s((function(e){return e&&e.length?Ei(e,_i):0}));class Ii{constructor(e,t){jt.set(this,void 0),Xt.set(this,void 0),this.type=bi.COMPOSABLE,Ht.set(this,!1),Wt.set(this,!1),this.update=e=>{n(this,Wt,!0,"f"),i(this,Ht,"f")?(i(this,Xt,"f")._emit(Q,{elementName:i(this,jt,"f"),elementOptions:e}),n(this,Wt,!1,"f")):i(this,Wt,"f")&&i(this,Xt,"f").on(`${De.READY}:${i(this,jt,"f")}`,(()=>{i(this,Xt,"f")._emit(Q,{elementName:i(this,jt,"f"),elementOptions:e}),n(this,Ht,!0,"f"),n(this,Wt,!1,"f")}))},n(this,jt,e,"f"),n(this,Xt,t,"f"),i(this,Xt,"f").on(`${De.READY}:${i(this,jt,"f")}`,(()=>{n(this,Ht,!0,"f")}))}on(e,t){if(!Object.values(H).includes(e))throw new Be(Ge.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Be(Ge.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Be(Ge.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,Xt,"f").on(`${e}:${i(this,jt,"f")}`,(e=>{void 0===e.value&&(e.value=""),"CARD_NUMBER"===e.elementType&&e.value&&(e.value=e.value.slice(0,6)),delete e.isComplete,delete e.name,t(e)}))}}jt=new WeakMap,Xt=new WeakMap,Ht=new WeakMap,Wt=new WeakMap;const pi="CollectContainer";class mi extends St{constructor(e,t,o,s){super(),zt.set(this,void 0),Kt.set(this,{}),$t.set(this,void 0),qt.set(this,{rows:[]}),Jt.set(this,[]),Zt.set(this,void 0),Qt.set(this,void 0),ei.set(this,void 0),ti.set(this,!1),ii.set(this,void 0),ni.set(this,void 0),this.type=bi.COMPOSABLE,oi.set(this,!1),si.set(this,{}),this.create=(e,t={required:!1})=>{We(e,i(this,Zt,"f").logLevel);const n=Rt(e),o=Lt(e.type,t,i(this,Zt,"f").logLevel),s=`${X}:${e.type}:${btoa(gt())}`;return i(this,Jt,"f").push(Object.assign(Object.assign(Object.assign({elementType:e.type,name:e.column},e),o),{validations:n,elementName:s})),new Ii(s,i(this,ei,"f"))},ri.set(this,((e,t=!1)=>{const o=[];if(n(this,si,ge(e),"f"),i(this,si,"f").rows.forEach((e=>{e.elements.forEach((e=>{const t=e,{elementType:i}=t;At(i,t),t.sensitive=t.sensitive||se[i].sensitive,t.replacePattern=t.replacePattern||se[i].replacePattern,t.mask=t.mask||se[i].mask,t.isMounted=!1,t.label=e.label,t.skyflowID=e.skyflowID,o.push(t)}))})),i(this,si,"f").elementName=t?o[0].elementName:`${X}:group:${btoa(i(this,si,"f").name)}`,t&&!i(this,Kt,"f")[o[0].elementName]&&i(this,ci,"f").call(this,o[0].name))throw new Be(Ge.UNIQUE_ELEMENT_NAME,[`${o[0].name}`],!0);let s=i(this,Kt,"f")[i(this,si,"f").elementName];if(s)t?s.update(o[0]):s.update(i(this,si,"f"));else{const e=gt();s=new Tt(e,i(this,si,"f"),i(this,$t,"f"),{containerId:i(this,zt,"f"),isMounted:i(this,oi,"f"),type:this.type},!0,i(this,li,"f"),i(this,di,"f"),i(this,Zt,"f"),i(this,ei,"f")),i(this,Kt,"f")[i(this,si,"f").elementName]=s,i(this,Qt,"f")[e]=s}return s})),ai.set(this,(e=>{Object.keys(i(this,Kt,"f")).forEach((t=>{t===e&&delete i(this,Kt,"f")[t]}))})),li.set(this,(e=>{e.forEach((e=>{i(this,ai,"f").call(this,e)}))})),di.set(this,(e=>{e.forEach((e=>{i(this,Kt,"f")[e.elementName]&&i(this,Kt,"f")[e.elementName].update(e)}))})),ci.set(this,(e=>{const t=Object.keys(i(this,Kt,"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(H).includes(e))throw new Be(Ge.INVALID_EVENT_LISTENER,[],!0);if(!t)throw new Be(Ge.MISSING_HANDLER_IN_EVENT_LISTENER,[],!0);if("function"!=typeof t)throw new Be(Ge.INVALID_HANDLER_IN_EVENT_LISTENER,[],!0);i(this,ei,"f").on(H.SUBMIT,(()=>{t()}))},this.mount=e=>{if(!e)throw new Be(Ge.EMPTY_ELEMENT_IN_MOUNT,["CollectElement"],!0);const{layout:t}=i(this,ii,"f");if(hi(t)!==i(this,Jt,"f").length)throw new Be(Ge.MISMATCH_ELEMENT_COUNT_LAYOUT_SUM,[],!0);let o=0;if(t.forEach(((e,t)=>{i(this,qt,"f").rows=[...i(this,qt,"f").rows,{elements:[]}];for(let n=0;n<e;n++)i(this,qt,"f").rows[t].elements.push(i(this,Jt,"f")[o]),o++})),i(this,ii,"f").styles&&(i(this,qt,"f").styles=Object.assign({},i(this,ii,"f").styles)),i(this,ii,"f").errorTextStyles&&(i(this,qt,"f").errorTextStyles=Object.assign({},i(this,ii,"f").errorTextStyles)),i(this,oi,"f"))return n(this,ni,i(this,ri,"f").call(this,i(this,qt,"f"),!1),"f"),i(this,ni,"f").mount(e),void n(this,ti,!0,"f");i(this,ei,"f").on(ee+i(this,zt,"f"),(()=>{n(this,ni,i(this,ri,"f").call(this,i(this,qt,"f"),!1),"f"),i(this,ni,"f").mount(e),n(this,ti,!0,"f")}))},this.unmount=()=>{var e;null===(e=i(this,ni,"f"))||void 0===e||e.unmount(),this.iframe.remove()},this.collect=(e={tokens:!0})=>new Promise(((t,n)=>{try{if(He(i(this,$t,"f").clientJSON.config),!i(this,ti,"f")){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_COLLECT_ELEMENT_NOT_MOUNTED);throw a.PayrailsLogger.error(e.message,{error:e}),e}if(Ot(i(this,si,"f")).forEach((e=>{if(!(null==e?void 0:e.isMounted))throw new Be(Ge.ELEMENTS_NOT_MOUNTED,[],!0)})),Object.values(i(this,Kt,"f")).forEach((e=>{e.isValidElement()})),e&&e.tokens&&"boolean"!=typeof e.tokens)throw new Be(Ge.INVALID_TOKENS_IN_COLLECT,[],!0);(null==e?void 0:e.additionalFields)&&je(e.additionalFields),(null==e?void 0:e.upsert)&&ze(null==e?void 0:e.upsert),this.bus.emit(z+i(this,zt,"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)?(xe(`${JSON.stringify(null==e?void 0:e.error)}`,Me.ERROR,i(this,Zt,"f").logLevel),n(null==e?void 0:e.error)):(xe(Fe(V.COLLECT_SUBMIT_SUCCESS,pi),Me.LOG,i(this,Zt,"f").logLevel),t(e))})),xe(Fe(V.EMIT_EVENT,pi,z),Me.LOG,i(this,Zt,"f").logLevel)}catch(e){xe(`${e.message}`,Me.ERROR,i(this,Zt,"f").logLevel),n(e)}})),ui.set(this,(()=>{i(this,ei,"f").on(Q,(e=>{let t;const n=i(this,Jt,"f").map(((i,n)=>i.elementName===e.elementName?(t=n,Object.assign({elementName:i.elementName},e.elementOptions)):i));i(this,ni,"f")&&i(this,ni,"f").updateElement(Object.assign({},n[t]))}))})),this.bus=F.getEventBus(),n(this,zt,gt(),"f"),n(this,$t,t,"f"),n(this,Qt,o,"f"),n(this,Zt,s,"f"),n(this,ii,e,"f"),n(this,ei,new fe,"f"),this.iframe=Oe({name:`${j}:${i(this,zt,"f")}:${i(this,Zt,"f").logLevel}`}),ye(this.iframe,{src:Re()}),Le(this.iframe,Object.assign({},le)),xe(Fe(V.CREATE_COLLECT_CONTAINER,pi),Me.LOG,i(this,Zt,"f").logLevel);const l=(e,o)=>{e.name===j+i(this,zt,"f")&&(o(Object.assign(Object.assign({},t),{clientJSON:Object.assign(Object.assign({},t.clientJSON),{config:Object.assign({},t.clientJSON.config)}),context:s})),n(this,oi,!0,"f"),i(this,ei,"f")._emit(ee+i(this,zt,"f"),{containerId:i(this,zt,"f")}),this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).off(W+i(this,zt,"f"),l))};this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).on(W+i(this,zt,"f"),l),document.body.append(this.iframe),i(this,ui,"f").call(this)}}function fi(e){this.message=e}zt=new WeakMap,Kt=new WeakMap,$t=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,ci=new WeakMap,ui=new WeakMap,fi.prototype=new Error,fi.prototype.name="InvalidCharacterError";var vi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new fi("'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 Ni(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(vi(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 vi(t)}}function Ti(e){this.message=e}Ti.prototype=new Error,Ti.prototype.name="InvalidTokenError";const Ai=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 Ti("Invalid token specified");var i=!0===(t=t||{}).header?0:1;try{return JSON.parse(Ni(e.split(".")[i]))}catch(e){throw new Ti("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 yi,Oi,Ri,Li,gi,Si,Ci,Di,Pi,bi,Mi={name:"skyflow-js",preferGlobal:!0,analyze:!1,version:"1.30.1",author:"Skyflow",description:"Skyflow JavaScript SDK"};class wi{constructor(e,t){yi.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,u,E;let _=null,h=null;return/Windows/.test(e)?(_="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)?(_="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)?(_="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)?(_="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)&&(_="Linux",h=null!==(E=null===(u=/Linux( \w+)*?\/([\w.]+)/.exec(e))||void 0===u?void 0:u[2])&&void 0!==E?E:null),{os:_,version:h}}(i.userAgent),u=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 E;return{sdk_name_version:d,sdk_client_device_model:(E=i.userAgent,/(ipad|tablet)/gi.test(E)?"tablet":/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile/.test(E)?"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=u.browserName)&&void 0!==r?r:""} ${null!==(a=u.browserVersion)&&void 0!==a?a:""}`}}(Mi,i(this,yi,"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(Ie.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(Ie.FORMURLENCODED))||(null===(a=null===(r=e.headers)||void 0===r?void 0:r["content-type"])||void 0===a?void 0:a.includes(Ie.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 Be({code:l.status,description:t},[],!0))}else a&&a.includes("text/plain")?n(new Be({code:l.status,description:d?`${l.response} - requestId: ${d}`:l.response},[],!0)):n(new Be({code:l.status,description:d?`${B.ERROR_OCCURED} - requestId: ${d}`:B.ERROR_OCCURED},[],!0));a&&a.includes("application/json")&&t(JSON.parse(l.response)),t(l.response)},l.onerror=()=>{n(new Be(Ge.NETWORK_ERROR,[],!0))}}else n(new Be(Ge.CONNECTION_ERROR,[],!0))})),this.config=e,n(this,yi,t,"f")}toJSON(){return{config:this.config,metaData:i(this,yi,"f")}}static fromJSON(e){return new wi(e.config,e.metaData)}}yi=new WeakMap,function(e){e.COLLECT="COLLECT",e.COMPOSABLE="COMPOSABLE"}(bi||(bi={}));const Ui="Skyflow";class ki{constructor(e){var t,o;Oi.set(this,void 0),Ri.set(this,gt()),Li.set(this,{uuid:i(this,Ri,"f"),clientDomain:window.location.origin}),gi.set(this,""),Si.set(this,void 0),Ci.set(this,void 0),Di.set(this,void 0),Pi.set(this,void 0),this.bus=F.getEventBus();const s=localStorage.getItem("sdk_version")||"";i(this,Li,"f").sdkVersion=s,n(this,Oi,new wi(Object.assign({},e),i(this,Li,"f")),"f"),n(this,Ci,(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Pe.ERROR,"f"),n(this,Di,(null===(o=null==e?void 0:e.options)||void 0===o?void 0:o.env)||be.PROD,"f"),n(this,Pi,{},"f"),this.bus.target({origin:ve.IFRAME_SECURE_ORGIN}).on(J+i(this,Ri,"f"),((e,t)=>{xe(Fe(V.CAPTURED_BEARER_TOKEN_EVENT,Ui),Me.LOG,i(this,Ci,"f")),!i(this,Oi,"f").config.getBearerToken||i(this,gi,"f")&&Ai(i(this,gi,"f"))?(xe(Fe(V.REUSE_BEARER_TOKEN,Ui),Me.LOG,i(this,Ci,"f")),t({authToken:i(this,gi,"f")})):i(this,Oi,"f").config.getBearerToken().then((e=>{Ai(e)?(xe(Fe(V.BEARER_TOKEN_RESOLVED,Ui),Me.LOG,i(this,Ci,"f")),n(this,gi,e,"f"),t({authToken:i(this,gi,"f")})):(xe(B.INVALID_BEARER_TOKEN,Me.ERROR,i(this,Ci,"f")),t({error:B.INVALID_BEARER_TOKEN}))})).catch((e=>{xe(B.BEARER_TOKEN_REJECTED,Me.ERROR,i(this,Ci,"f")),t({error:e})}))})),xe(Fe(V.BEARER_TOKEN_LISTENER,Ui),Me.LOG,i(this,Ci,"f")),xe(Fe(V.CURRENT_ENV,Ui,i(this,Di,"f")),Me.LOG,i(this,Ci,"f")),xe(Fe(V.CURRENT_LOG_LEVEL,Ui,i(this,Ci,"f")),Me.LOG,i(this,Ci,"f"))}static init(e){var t;const i=(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t.logLevel)||Pe.ERROR;Je(e),xe(Fe(V.INITIALIZE_CLIENT,Ui),Me.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 ki(n);return xe(Fe(V.CLIENT_INITIALIZED,Ui),Me.LOG,i),s}container(e,t){switch(e){case bi.COLLECT:{const n=new Gt(t,Object.assign(Object.assign({},i(this,Li,"f")),{clientJSON:i(this,Oi,"f").toJSON(),containerType:e}),i(this,Pi,"f"),{logLevel:i(this,Ci,"f"),env:i(this,Di,"f")});return xe(Fe(V.COLLECT_CONTAINER_CREATED,Ui),Me.LOG,i(this,Ci,"f")),n}case bi.COMPOSABLE:{(e=>{if(!e)throw new Be(Ge.MISSING_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if("object"!=typeof e)throw new Be(Ge.INVALID_COMPOSABLE_CONTAINER_OPTIONS,[],!0);if(!Object.prototype.hasOwnProperty.call(e,"layout"))throw new Be(Ge.MISSING_COMPOSABLE_LAYOUT_KEY,[],!0);if(!e.layout)throw new Be(Ge.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(!Array.isArray(e.layout))throw new Be(Ge.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(0===e.layout.length)throw new Be(Ge.EMPTY_COMPOSABLE_LAYOUT_ARRAY,[],!0);e.layout.forEach((e=>{if("number"!=typeof e)throw new Be(Ge.INVALID_COMPOSABLE_LAYOUT_TYPE,[],!0);if(e<0)throw new Be(Ge.NEGATIVE_VALUES_COMPOSABLE_LAYOUT,[],!0)}))})(t);const n=new mi(t,Object.assign(Object.assign({},i(this,Li,"f")),{clientJSON:i(this,Oi,"f").toJSON(),containerType:e}),i(this,Pi,"f"),{logLevel:i(this,Ci,"f"),env:i(this,Di,"f")});return xe(Fe(V.COLLECT_CONTAINER_CREATED,Ui),Me.LOG,i(this,Ci,"f")),n}default:if(!e)throw new Be(Ge.EMPTY_CONTAINER_TYPE,[],!0);throw new Be(Ge.INVALID_CONTAINER_TYPE,[],!0)}}static get ContainerType(){return bi}static get ElementType(){return ie}static get RedactionType(){return Se}static get RequestMethod(){return Ce}static get LogLevel(){return Pe}static get EventName(){return De}static get Env(){return be}static get ValidationRuleType(){return we}}function Yi(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,n,o=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:{}}),s=o.queryParams,r=o.dataAttributes;return{url:"".concat(t,"?").concat((i=s,n="",Object.keys(i).forEach((function(e){0!==n.length&&(n+="&"),n+=e+"="+i[e]})),n)),dataAttributes:r}}function xi(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 Fi(e,t){if(void 0===t&&(t=Vi()),Gi(e,t),"undefined"==typeof window)return t.resolve(null);var i=Yi(e),n=i.url,o=i.dataAttributes,s=o["data-namespace"]||"paypal",r=Bi(s);
|
|
5
5
|
/*!
|
|
6
6
|
* paypal-js v5.1.4 (2022-11-29T23:08:21.847Z)
|
|
7
7
|
* Copyright 2020-present, PayPal, Inc. All rights reserved.
|
|
@@ -18,8 +18,8 @@ Copyright (c) 2022 Skyflow, Inc.
|
|
|
18
18
|
* See the License for the specific language governing permissions and
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
|
-
return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=xi(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=Vi()),Gi(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=xi(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=Bi(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Vi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Bi(e){return window[e]}function Gi(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.")}yi=new WeakMap,Ri=new WeakMap,Li=new WeakMap,gi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,Di=new WeakMap,Pi=new WeakMap;class ji{static load(e,t){if(e===Xi.PayPal){if(!t)throw new Error("PayPal config is required");return ji.loadPayPalScript(t)}return ji.loadScript(e)}static reset(){ji.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/dad8cb0/card";[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"],[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].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)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(ji.scriptMap.has(t))return ji.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>{t()},i.onerror=t=>{n(ji.logLoadError(e,new Error(t.toString())))}}));return ji.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:e,currency:i,vault:n,intent:o}){return t(this,void 0,void 0,(function*(){try{const t=yield Fi({"client-id":e,components:"buttons,funding-eligibility",intent:o,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(t)return t}catch(e){throw ji.logLoadError(Xi.PayPal,e)}throw ji.logLoadError(Xi.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[Xi.ApplePay,r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[Xi.GooglePay,r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[Xi.PayPal,r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new r.PayrailsError(i.get(e)||r.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return a.PayrailsLogger.error(n.message,{error:n}),n}}var Xi;ji.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(Xi||(Xi={}));class Hi extends Y{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()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class Wi extends Y{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 Hi(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 zi extends Wi{static isApplePayAvailable(){return t(this,void 0,void 0,(function*(){try{return yield ji.load(Xi.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.appleButton=null,this.paymentExecutor=new g(e,t),zi.isApplePayAvailable().then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{(yield zi.isApplePayAvailable())&&(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()}mountApplePayButton(){var e,i,n;return t(this,void 0,void 0,(function*(){try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",s=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${s}" type="${o}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){(yield y(this.options.events))&&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.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},r.onpaymentauthorized=e=>t(this,void 0,void 0,(function*(){var t,i,n,o,s,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(e.payment.token);"authorizeSuccessful"===(null===(t=null==u?void 0:u.finalState)||void 0===t?void 0:t.code)?(null===(i=this.options.events)||void 0===i?void 0:i.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess():(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(u))}catch(e){r.completePayment(ApplePaySession.STATUS_FAILURE),(null===(E=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===E?void 0:E.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(e))}})),r.begin(),r}catch(e){return null}}onApplePayAuthorized(i){return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},i),{paymentNetwork:i.paymentMethod.network,paymentInstrumentName:i.paymentMethod.displayName}),n=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(n)}))}}const{CARD_NUMBER:Ki,CVV:$i,CARDHOLDER_NAME:qi,EXPIRATION_MONTH:Ji,EXPIRATION_YEAR:Zi}=e.ElementType,Qi={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},en=[{type:qi,placeholder:"Card holder",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Ki,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.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:Ji,placeholder:"MM",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:Zi,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:$i,placeholder:"CVC",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class tn extends Wi{get bin(){return this.collectContainer.bin}constructor(t,i){var n,o,s,r,a;super("div",Object.assign(Object.assign({},i),{translations:Object.assign(Object.assign({},null==i?void 0:i.translations),{labels:Object.assign(Object.assign({},null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(s=null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.storeCardCheckbox},null==i?void 0:i.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=i,this.formFields=[],(null===(a=null==i?void 0:i.styles)||void 0===a?void 0:a.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),en.forEach((({type:t,styles:n,format:o,placeholder:s})=>{var r,a,l,d,c,u,E;if(!(null===(r=this.options)||void 0===r?void 0:r.showCardHolderName)&&t===e.ElementType.CARDHOLDER_NAME)return;const _=new nn(this.collectContainer,{type:t,label:null===(l=null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l[t],placeholder:(null===(c=null===(d=null==i?void 0:i.translations)||void 0===d?void 0:d.placeholders)||void 0===c?void 0:c[t])||s,labelStyles:this.prepareLabelStyles(t),inputStyles:this.prepareInputStyles(n,t),format:o,events:{onFocus:null===(E=null===(u=this.options)||void 0===u?void 0:u.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)}tokenize(e){return this.collectContainer.tokenize(e)}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),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(t,i){var n;let o=JSON.parse(JSON.stringify(t));return(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&i===e.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),o=Object.assign(Object.assign({},t),{base:Object.assign(Object.assign({},Qi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var t,n,s,r,a,l,d,c;o[e]=Object.assign(Object.assign(Object.assign({},o[e]),null===(r=null===(s=null===(n=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===n?void 0:n.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[i])||void 0===c?void 0:c[e])})),o}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(){return t(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard())}}))}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}class nn{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 on extends Y{constructor(e,t,i,n,o){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=o,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const s=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",s);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",s),a.setAttribute("value",s),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",(()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))})),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var sn;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(sn||(sn={}));const rn="https://assets.payrails.io/img/";class an extends on{constructor(e,t,i,n){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,an.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(t){var i;if(t.paymentMethod!==e.PAYMENT_METHOD_CODES.CARD)return"";switch(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.network){case sn.AMEX:return rn+"amex.svg";case sn.DINERS:return rn+"diners-club.svg";case sn.DISCOVER:return rn+"discover.svg";case sn.HIPERCARD:return rn+"hipercard.svg";case sn.JCB:return rn+"jcb.svg";case sn.MAESTRO:return rn+"maestro.svg";case sn.MASTERCARD:return rn+"mastercard.svg";case sn.UNIONPAY:return rn+"unionpay.svg";case sn.VISA:return rn+"visa.svg"}return rn+"default.svg"}}class ln extends Y{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new dn((()=>{(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 dn extends Y{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",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.className="payment-option-text",o.appendChild(r);const a=document.createElement("img");a.src=an.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class cn extends Y{constructor(e){var t;super("div",{id:"authorization-failed-message"});const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),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>${i}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class un extends Y{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),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`}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class En extends on{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw a.PayrailsLogger.error(e.message,{error:e}),e}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 _n extends En{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",void 0,void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new zi(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class hn extends on{constructor(e,t,i,n){super("payrails-credit-card-wrapper","Card",void 0,n,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new In(e,t)}activate(){var e,t;this.applyActiveStyles(),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.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class In extends Y{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class pn extends Y{constructor(e){var t,i,n,o;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(o=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==o?o:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){var e,i;return t(this,void 0,void 0,(function*(){if((null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}this.triggerLoading(!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]=""}))}triggerLoading(e){var t,i,n;this.isDisabled=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const mn={label:"Generic redirect"};class fn extends Y{constructor(e,t,i,n){super("div",{id:`payrails-generic-redirect-${i.paymentMethod.paymentMethodCode}`}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n;const o=this.buildRedirectButton();this.element.appendChild(o.getElement()),this.paymentExecutor=new g(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new pn({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:mn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var e,i,n,o;return t(this,void 0,void 0,(function*(){if(yield y(null!==(e=this.options.events)&&void 0!==e?e:{}))try{const e=null===(i=this.execution.availablePaymentMethods.find((({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode)))||void 0===i?void 0:i.integrationType;if(!e)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const t=(yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:e,amount:this.sdkConfig.amount}])).response.links.redirect;if(!t)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return new Promise(((e,i)=>{window.location.href=t,setTimeout((()=>i(new Error("Timed out doing a redirect to the auth response link"))),3e3)}))}catch(e){e instanceof r.PayrailsError&&a.PayrailsLogger.error(e.message,{error:e}),null===(o=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n)}}))}}const vn=t=>t===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:t,button:{label:`Pay with ${t}`}}};class Nn extends on{constructor(e,t,i,n){var o,s,r,a;super(`payrails-${i.paymentMethod.paymentMethodCode}-dropin-element`,(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||vn(i.paymentMethod.paymentMethodCode).translations.label,void 0,null==i?void 0:i.events,null===(s=null==i?void 0:i.styles)||void 0===s?void 0:s.element),this.sdkConfig=e,this.execution=t,this.returnInfo=n,this.component=new fn(this.sdkConfig,this.execution,{styles:(null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r[i.paymentMethod.paymentMethodCode])||{},translations:(null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.button)||vn(i.paymentMethod.paymentMethodCode).translations.button,events:null==i?void 0:i.events,paymentMethod:i.paymentMethod},this.returnInfo)}}const Tn={apiVersion:2,apiVersionMinor:0};class An extends Wi{static getSDKClient(i=e.PayrailsEnvironment.TEST,n){return t(this,void 0,void 0,(function*(){return yield ji.load(Xi.GooglePay),An.googleSDKClient||(An.googleSDKClient=new google.payments.api.PaymentsClient({environment:i,merchantInfo:n})),An.googleSDKClient}))}static isGooglePayAvailable(i,n=e.PayrailsEnvironment.TEST,o){return t(this,void 0,void 0,(function*(){try{const e=yield An.getSDKClient(n,o),t=Object.assign(Object.assign({},Tn),{allowedPaymentMethods:i}),{result:s}=yield e.isReadyToPay(t);return s}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.googleButton=null,this.paymentExecutor=new g(e,t),An.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(e){var i,n,o,s,r,a,l,d;return t(this,void 0,void 0,(function*(){const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",E=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(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:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>t(this,void 0,void 0,(function*(){(yield y(this.options.events))&&(yield this.authorize(e))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(i){var n,o,s,r,a,l,d,c;return t(this,void 0,void 0,(function*(){const t=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(i)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],u=yield this.paymentExecutor.pay(t);"authorizePending"===(null===(n=null==u?void 0:u.finalState)||void 0===n?void 0:n.code)?new U(this.options,this.execution,this.paymentExecutor).handle3ds(u):"authorizeSuccessful"===(null===(o=null==u?void 0:u.finalState)||void 0===o?void 0:o.code)?null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===r?void 0:r.onAuthorizeSuccess)||void 0===a||a.call(r):null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===d?void 0:d.onAuthorizeFailed)||void 0===c||c.call(d,u)}))}authorize(e){var i,n,o,s,r,a,l,d;return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Tn),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.value,currencyCode:null===(n=this.sdkConfig.amount)||void 0===n?void 0:n.currency,countryCode:null===(a=null===(r=null===(s=null===(o=this.execution.meta)||void 0===o?void 0:o.order)||void 0===s?void 0:s.billingAddress)||void 0===r?void 0:r.country)||void 0===a?void 0:a.code},merchantInfo:{merchantId:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=this.options.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});e.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{if(yield An.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield An.getSDKClient(this.options.environment,this.options.merchantInfo),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()}}An.googleSDKClient=null;class On extends En{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",void 0,i.events,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new An(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class yn extends Wi{constructor(i,n,o){super("div",Object.assign(Object.assign({},o),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==o?void 0:o.events),{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(o=this.button)||void 0===o||o.close();const s=yield this.loadPaypal();s&&(this.button=s,yield this.button.render(`#${this.buttonWrapperId}`))}))})})),this.sdkConfig=i,this.execution=n,this.options=o,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a;const l=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],d=yield this.paymentExecutor.pay(l),c=null===(n=null===(i=null===(t=d.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.orderId;if(!c)throw null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===r||r.call(s),new Rn("No order id returned");return this.confirmLink=null===(a=d.response.links.confirm)||void 0===a?void 0:a.href,c})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new g(i,n),this.fraudNetGuid=null==o?void 0:o.fraudNetGuid}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=yield ji.load(Xi.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize";return{clientId:this.execution.paypalConfig.clientId,intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){var i,n,o;return t(this,void 0,void 0,(function*(){if(!e.Buttons)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const t=e.Buttons(this.createPayPalButtonConfig());return 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}))}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 t,i,n,o;const s=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],r=yield this.paymentExecutor.pay(s);return this.confirmLink=null===(t=r.response.links.confirm)||void 0===t?void 0:t.href,(null===(o=null===(n=null===(i=r.response.links.confirm)||void 0===i?void 0:i.action)||void 0===n?void 0:n.parameters)||void 0===o?void 0:o.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;return(yield y(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}))}}approvePayment(e){var i,n,o,s,r,a,l,d,c,u;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 Rn("No confirm link");const t={};this.shouldStoreInstrument&&e.billingToken&&(t.tokenId=e.billingToken),this.fraudNetGuid&&(t.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,t);"authorizeSuccessful"===(null===(s=E.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===(u=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===u||u.call(c)}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;const t=yield this.loadPaypal();t&&(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){const t=new Ln(e.message,e);throw a.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class Rn extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Ln extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class gn extends En{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",void 0,void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new yn(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Sn extends Y{constructor(t,i,n,o,s){var r,a;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=t,this.clientConfig=i,this.dropinConfig=n,this.execution=o,this.sdkConfig=s,this.applyStyles(),void 0!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.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 l=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);l.set(t.identifier,t)}}));const d={[e.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[e.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[e.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};this.execution.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&d[t]){d[t];const e=d[t]();l.set(e.identifier,e)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);l.set(t.identifier,t)}})),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)||"";l.forEach((e=>{e.deactivate()})),null===(i=l.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(l.values()))}isHppIntegration(t){var i;return t.paymentMethodCode===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(i=t.clientConfig)||void 0===i?void 0:i.flow)===b.REDIRECT}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new an(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createHppIntegrationElement(e){var t,i,n,o,s,l;const d=e.paymentMethodCode;if(!d){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw a.PayrailsLogger.error(t.message,{error:t}),t}return new Nn(this.sdkConfig,this.execution,{paymentMethod:e,styles:{element:null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.element,button:null===(s=null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o[d])||void 0===s?void 0:s.button},translations:null===(l=this.dropinConfig.translations)||void 0===l?void 0:l[d],events:this.getElementEvents()},this.clientConfig.returnInfo)}get totalPaymentOptions(){return this.execution.availablePaymentMethods.length+this.execution.storedPaymentInstruments.length}createCreditCardButton(){var e;return this.creditCard=new hn(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var t,i,n;return this.googlePay=new On(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||e.PayrailsEnvironment.TEST,events:this.getElementEvents(),redirectFor3DS:this.clientConfig.redirectFor3DS,styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.googlePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)},null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new gn(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:this.getElementEvents()})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const o=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,s=Boolean(null==o?void 0:o.showStoreInstrumentCheckbox),r=Boolean(null==o?void 0:o.showCardHolderName),a=Boolean(null==o?void 0:o.alwaysStoreInstrument);this.cardForm=new tn(this.collectContainer,{showStoreInstrumentCheckbox:s,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{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=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i;return this.applePay=new _n(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)?this.onAuthorizeSuccess():this.onAuthorizeFailed())}})},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new x(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,redirectFor3DS:this.clientConfig.redirectFor3DS,events:this.getElementEvents()},this.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,o,s;this.subElements.forEach((e=>e.unmount())),new un({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},styles:null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),(null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()}})}onAuthorizeFailed(e){var t,i,n,o,s;new cn({translations:{label:null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed}).mount(this.selector),null===(s=null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o,e)}isStoredInstrumentEnabled(t){var i,n,o,s,r,a;switch(t){case e.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showStoredInstruments)&&!1!==(null===(s=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===s?void 0:s.showExistingCards);case e.PAYMENT_METHOD_CODES.PAYPAL:case e.PAYMENT_METHOD_CODES.GOOGLE_PAY:case e.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r[t])||void 0===a?void 0:a.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container)}}const Cn={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 Dn{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}static init(e,t,i){return this.instance&&this.instance.__container.unmount(),this.instance=new Dn(e,t,i),this.instance}createCollectElement(t){const i={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===e.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},i),{format:t.format}):i);return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message),e}this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw a.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${this.id}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return t(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw a.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return t(this,void 0,void 0,(function*(){const e=(yield this.__container.collect()).records,{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}}))}collectPayrailsData(){return t(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const o=yield(({url:e,token:t,body:i})=>p({url:e,token:t,method:_.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)});return o.res}))}constructSaveInstrumentBody(e,t){var i,n;const o={holderReference:this.sdkConfig.holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return this.sdkConfig.usePayrailsFrames?o.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId}:o.token={providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,reference:e.instrumentId,type:"card",meta:{skyflow_id:e.instrumentId,card_number:e.card_number,cardholder_name:e.cardholder_name,expiry_month:e.expiry_month,expiry_year:e.expiry_year,security_code:e.security_code}},o}attachCustomEventHandler(t){return new Proxy(t,{get:(t,i)=>"on"!==i?t[i]:((n,o)=>{t[i].call(t,n,(t=>{"CHANGE"===n?(t.elementType===e.ElementType.CARD_NUMBER&&(t.network=function(e){for(const[t,i]of Object.entries(Cn))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),o(t)):o(t)}))}).bind(t)})}formatBin(e){return e.replace(/-|X/g,"").slice(0,6)}get elementToFieldMap(){return new Map([[e.ElementType.CARD_NUMBER,"card_number"],[e.ElementType.CARDHOLDER_NAME,"cardholder_name"],[e.ElementType.CVV,"security_code"],[e.ElementType.EXPIRATION_MONTH,"expiry_month"],[e.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Pn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=I().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=I(),this.scriptId=I()}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}}const bn=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/dad8cb0/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
|
|
21
|
+
return function(e,t){var i=document.querySelector('script[src="'.concat(e,'"]'));if(null===i)return null;var n=xi(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=Vi()),Gi(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=xi(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=Bi(s);if(e)return e;throw new Error("The window.".concat(s," global variable is not available."))}))}function Vi(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function Bi(e){return window[e]}function Gi(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.")}Oi=new WeakMap,Ri=new WeakMap,Li=new WeakMap,gi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,Di=new WeakMap,Pi=new WeakMap;class ji{static load(e,t){if(e===Xi.PayPal){if(!t)throw new Error("PayPal config is required");return ji.loadPayPalScript(t)}return ji.loadScript(e)}static reset(){ji.scriptMap.clear()}static preloadCardForm(){const e="https://assets.payrails.io/2ab28a7/card";[["https://js.skyflow.com/v1/elements/index.js","payrails-iframe-js-v1"],["https://js.skyflow.com/v1/elements/index.html","payrails-iframe-html-v1"],[`${e}/index.js`,"payrails-iframe-js-v2"],[`${e}/index.html`,"payrails-iframe-html-v2"]].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)}}))}static loadScript(e){const t=`payrails-script-${JSON.stringify(e)}`;if(ji.scriptMap.has(t))return ji.scriptMap.get(t);const i=document.createElement("script");i.src=e,i.id=t;const n=new Promise(((t,n)=>{i.onload=()=>{t()},i.onerror=t=>{n(ji.logLoadError(e,new Error(t.toString())))}}));return ji.scriptMap.set(t,n),document.body.appendChild(i),n}static loadPayPalScript({clientId:e,currency:i,vault:n,intent:o}){return t(this,void 0,void 0,(function*(){try{const t=yield Fi({"client-id":e,components:"buttons,funding-eligibility",intent:o,currency:i,vault:n,"data-namespace":"payrailsPaypal"});if(t)return t}catch(e){throw ji.logLoadError(Xi.PayPal,e)}throw ji.logLoadError(Xi.PayPal)}))}constructor(){}static logLoadError(e,t){const i=new Map([[Xi.ApplePay,r.ERROR_CODES.PAYRAILS_CLIENT_APPLEPAY_LOADING_ERROR],[Xi.GooglePay,r.ERROR_CODES.PAYRAILS_CLIENT_GPAY_LOADING_ERROR],[Xi.PayPal,r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR]]),n=new r.PayrailsError(i.get(e)||r.ERROR_CODES.PAYRAILS_CLIENT_UNKNOWN_ERROR,{cause:t,description:null==t?void 0:t.message});return a.PayrailsLogger.error(n.message,{error:n}),n}}var Xi;ji.scriptMap=new Map,function(e){e.ApplePay="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",e.GooglePay="https://pay.google.com/gp/p/js/pay.js",e.PayPal="paypal-sdk"}(Xi||(Xi={}));class Hi extends Y{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()})),this.element.addEventListener("click",(e=>{e.stopPropagation(),e.stopImmediatePropagation()}))}}class Wi extends Y{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 Hi(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 zi extends Wi{static isApplePayAvailable(){return t(this,void 0,void 0,(function*(){try{return yield ji.load(Xi.ApplePay),ApplePaySession.canMakePayments()}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-apple-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.appleButton=null,this.paymentExecutor=new g(e,t),zi.isApplePayAvailable().then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onApplePayAvailable)||void 0===n||n.call(i))}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){try{(yield zi.isApplePayAvailable())&&(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()}mountApplePayButton(){var e,i,n;return t(this,void 0,void 0,(function*(){try{const o=(null===(e=this.options.styles)||void 0===e?void 0:e.type)||"buy",s=(null===(i=this.options.styles)||void 0===i?void 0:i.style)||"black";this.element.innerHTML=`<apple-pay-button buttonstyle="${s}" type="${o}" locale="en-GB"></apple-pay-button>`,null===(n=this.storeInstrumentCheckbox)||void 0===n||n.mount(this.selector);const r=this.element.querySelector("apple-pay-button");null==r||r.setAttribute("style","width: 100%;"),null==r||r.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){yield this.createApplePaySession()}))))}catch(e){}}))}createApplePaySession(){return t(this,void 0,void 0,(function*(){const e=this.execution.applePayConfig,{countryCode:i,supportedNetworks:n,merchantCapabilities:o}=e,{amount:s}=this.sdkConfig;try{const e=new ApplePaySession(3,{countryCode:i,currencyCode:s.currency,merchantCapabilities:o,supportedNetworks:n,total:{label:"",type:"final",amount:s.value}});return e.onvalidatemerchant=i=>t(this,void 0,void 0,(function*(){const{res:t}=yield this.paymentExecutor.createApplePaySession({requestUrl:this.execution.createSessionLink,sessionUrl:i.validationURL,clientDomain:this.options.clientDomain}),n=t.data.data;e.completeMerchantValidation(n)})),e.oncancel=()=>{var e,t,i;(null===(t=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===t?void 0:t.onAuthorizeFailed)&&(null===(i=this.options)||void 0===i||i.events.onAuthorizeFailed())},e.onpaymentauthorized=i=>t(this,void 0,void 0,(function*(){var t,n,o,s,r,a,l,d,c,u,E,_;try{const u=yield this.onApplePayAuthorized(i.payment.token);"authorizeSuccessful"===(null===(t=null==u?void 0:u.finalState)||void 0===t?void 0:t.code)?(null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeSuccess)&&this.options.events.onAuthorizeSuccess():(e.completePayment(ApplePaySession.STATUS_FAILURE),(null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeFailed)&&(null===(r=this.options)||void 0===r||r.events.onAuthorizeFailed())),e.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(u))}catch(t){e.completePayment(ApplePaySession.STATUS_FAILURE),(null===(E=null===(u=this.options)||void 0===u?void 0:u.events)||void 0===E?void 0:E.onAuthorizeFailed)&&(null===(_=this.options)||void 0===_||_.events.onAuthorizeFailed(t))}})),(yield O(this.options.events))&&e.begin(),e}catch(e){return null}}))}onApplePayAuthorized(i){return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},i),{paymentNetwork:i.paymentMethod.network,paymentInstrumentName:i.paymentMethod.displayName}),n=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.APPLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(t)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}];return yield this.paymentExecutor.pay(n)}))}}const{CARD_NUMBER:Ki,CVV:$i,CARDHOLDER_NAME:qi,EXPIRATION_MONTH:Ji,EXPIRATION_YEAR:Zi}=e.ElementType,Qi={base:{border:"none",padding:"10px 16px",color:"#1d1d1d",backgroundColor:"#fff"},invalid:{backgroundColor:"#f9e1e1",borderColor:"#f25226",border:"1px solid"}},en=[{type:qi,placeholder:"Card holder",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{border:"1px solid #eae8ee",padding:"10px 16px",borderTopLeftRadius:"4px",borderTopRightRadius:"4px"})})},{type:Ki,placeholder:"1234 1234 1234 1234",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.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:Ji,placeholder:"MM",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{borderBottom:"1px solid #eae8ee",borderLeft:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomLeftRadius:"4px"})})},{type:Zi,placeholder:"YY",format:"YY",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee"})})},{type:$i,placeholder:"CVC",styles:Object.assign(Object.assign({},Qi),{base:Object.assign(Object.assign({},Qi.base),{borderBottom:"1px solid #eae8ee",borderRight:"1px solid #eae8ee",borderBottomRightRadius:"4px"})})}];class tn extends Wi{get bin(){return this.collectContainer.bin}constructor(t,i){var n,o,s,r,a;super("div",Object.assign(Object.assign({},i),{translations:Object.assign(Object.assign({},null==i?void 0:i.translations),{labels:Object.assign(Object.assign({},null===(n=null==i?void 0:i.translations)||void 0===n?void 0:n.labels),{saveInstrument:null===(s=null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.labels)||void 0===s?void 0:s.saveCreditCard})}),styles:Object.assign({storeInstrumentCheckbox:null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r.storeCardCheckbox},null==i?void 0:i.styles),id:"payrails-card-form"})),this.collectContainer=t,this.options=i,this.formFields=[],(null===(a=null==i?void 0:i.styles)||void 0===a?void 0:a.storeCardCheckbox)&&console.warn("The `storeCardCheckbox` option for styles is deprecated. Please use `storeInstrumentCheckbox` instead."),en.forEach((({type:t,styles:n,format:o,placeholder:s})=>{var r,a,l,d,c,u,E;if(!(null===(r=this.options)||void 0===r?void 0:r.showCardHolderName)&&t===e.ElementType.CARDHOLDER_NAME)return;const _=new nn(this.collectContainer,{type:t,label:null===(l=null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.labels)||void 0===l?void 0:l[t],placeholder:(null===(c=null===(d=null==i?void 0:i.translations)||void 0===d?void 0:d.placeholders)||void 0===c?void 0:c[t])||s,labelStyles:this.prepareLabelStyles(t),inputStyles:this.prepareInputStyles(n,t),format:o,events:{onFocus:null===(E=null===(u=this.options)||void 0===u?void 0:u.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)}tokenize(e){return this.collectContainer.tokenize(e)}show(){var e,t;const i=document.getElementById(this.collectContainer.id);if(!i){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message,{error:e}),e}Object.assign(i.style,null===(t=null===(e=this.options)||void 0===e?void 0:e.styles)||void 0===t?void 0:t.wrapper),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(t,i){var n;let o=JSON.parse(JSON.stringify(t));return(null===(n=this.options)||void 0===n?void 0:n.showCardHolderName)&&i===e.ElementType.CARD_NUMBER&&(this.element.setAttribute("class","with-card-holder"),o=Object.assign(Object.assign({},t),{base:Object.assign(Object.assign({},Qi.base),{border:"1px solid #eae8ee",borderTop:"none",padding:"10px 16px",textIndent:"0"})})),["base","complete","empty","focus","invalid","cardIcon","copyIcon"].forEach((e=>{var t,n,s,r,a,l,d,c;o[e]=Object.assign(Object.assign(Object.assign({},o[e]),null===(r=null===(s=null===(n=null===(t=this.options)||void 0===t?void 0:t.styles)||void 0===n?void 0:n.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[i])||void 0===c?void 0:c[e])})),o}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(){return t(this,void 0,void 0,(function*(){return{cardData:yield this.collectContainer.collect(),storeInstrument:this.shouldStoreInstrument,enrollInstrumentToNetworkOffers:Boolean(this.enforceEnrollInstrumentToNetworkOffersForMasterCard())}}))}enforceEnrollInstrumentToNetworkOffersForMasterCard(){var e;return"mastercard"!==this.cardNetwork&&(null===(e=this.options)||void 0===e?void 0:e.enrollInstrumentToNetworkOffers)}}class nn{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 on extends Y{constructor(e,t,i,n,o){super("div",{id:e,className:"payrails-dropin-item"}),this.events=n,this.styles=o,this.isActive=!1,this.mountContainerClass="payrails-dropin-item-container",this.applyBaseStyles();const s=`payrails-dropin-item-${e}`,r=document.createElement("label");r.setAttribute("for",s);const a=document.createElement("input");if(a.setAttribute("type","radio"),a.setAttribute("name","payment-option"),a.setAttribute("id",s),a.setAttribute("value",s),this.input=a,r.appendChild(a),this.label=r,i){const e=document.createElement("img");e.src=null!=i?i:"",e.className="payrails-store-instrument-icon",r.appendChild(e)}const l=document.createElement("span");r.appendChild(l),l.innerText=t,this.element.addEventListener("click",(()=>{var e,t;null===(t=(e=this.label).onchange)||void 0===t||t.call(e,new Event("change"))})),this.element.appendChild(r);const d=document.createElement("div");d.setAttribute("class",this.mountContainerClass),this.element.appendChild(d)}get identifier(){return`payrails-dropin-item-${this.id}`}deactivate(){var e,t;this.isActive&&(this.isActive=!1,this.input.checked=!1,this.applyBaseStyles(),null===(e=this.component)||void 0===e||e.unmount(),(null===(t=this.events)||void 0===t?void 0:t.onDeactivate)&&this.events.onDeactivate())}applyBaseStyles(){var e,t;this.element.classList.remove("active"),Object.keys((null===(e=this.styles)||void 0===e?void 0:e.active)||{}).forEach((e=>{this.element.style.removeProperty(e)})),Object.assign(this.element.style,null===(t=this.styles)||void 0===t?void 0:t.base)}applyActiveStyles(){var e,t;this.element.classList.add("active"),Object.assign(this.element.style,null===(e=this.styles)||void 0===e?void 0:e.base,null===(t=this.styles)||void 0===t?void 0:t.active)}activate(){var e,t;this.isActive||(null===(e=this.component)||void 0===e||e.mount(`${this.selector} .${this.mountContainerClass}`),this.applyActiveStyles(),this.input.checked=!0,this.isActive=!0,(null===(t=this.events)||void 0===t?void 0:t.onActivate)&&this.events.onActivate())}mount(e){var t,i;super.mount(e),null===(i=null===(t=this.events)||void 0===t?void 0:t.onAvailable)||void 0===i||i.call(t)}}var sn;!function(e){e.AMEX="amex",e.DINERS="diners",e.DISCOVER="discover",e.HIPERCARD="hipercard",e.JCB="jcb",e.MAESTRO="maestro",e.MASTERCARD="mastercard",e.UNIONPAY="unionpay",e.VISA="visa"}(sn||(sn={}));const rn="https://assets.payrails.io/img/";class an extends on{constructor(e,t,i,n){const o=e.displayName&&""!==e.displayName?e.displayName:"Unavailable";super(`payrails-payment-instrument-${e.id}`,o,an.getInstrumentIcon(e),{onActivate:()=>{i(e),this.component.setDisabled(!1)}},n),this.component=t}static getInstrumentIcon(t){var i;if(t.paymentMethod!==e.PAYMENT_METHOD_CODES.CARD)return"";switch(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.network){case sn.AMEX:return rn+"amex.svg";case sn.DINERS:return rn+"diners-club.svg";case sn.DISCOVER:return rn+"discover.svg";case sn.HIPERCARD:return rn+"hipercard.svg";case sn.JCB:return rn+"jcb.svg";case sn.MAESTRO:return rn+"maestro.svg";case sn.MASTERCARD:return rn+"mastercard.svg";case sn.UNIONPAY:return rn+"unionpay.svg";case sn.VISA:return rn+"visa.svg"}return rn+"default.svg"}}class ln extends Y{constructor(e,t){super("div",{id:"payrails-card-list"}),this.workflowExecution=e,this.listItems=[],this.workflowExecution.savedCreditCards.forEach((e=>{const i=new dn((()=>{(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 dn extends Y{constructor(e,t){super("div",{className:"payrails-card-list-item",id:`payrails-card-list-item-${t.id}`});const{id:i}=t,n=t.displayName&&""!==t.displayName?t.displayName:"Unavailable",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.className="payment-option-text",o.appendChild(r);const a=document.createElement("img");a.src=an.getInstrumentIcon(t),a.className="payment-option-icon",r.appendChild(a),r.appendChild(document.createTextNode(n)),this.element.appendChild(o)}}class cn extends Y{constructor(e){var t;super("div",{id:"authorization-failed-message"});const i=(null===(t=null==e?void 0:e.translations)||void 0===t?void 0:t.label)||"Authorization failed, please try again.";this.element.innerText=i,this.setStyles((null==e?void 0:e.styles)||{}),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>${i}</div>`,this.element.addEventListener("click",(e=>{e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),this.unmount()}))}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class un extends Y{constructor(e){var t;super("div",{id:"payrails-authorization-success-msg"}),this.setStyles((null==e?void 0:e.styles)||{}),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`}setStyles(e){Object.keys(e).forEach((t=>{this.element.style[t]=e[t]}))}}class En extends on{constructor(){super(...arguments),this.buttonShown=!1}activate(){if(!this.buttonShown)return super.activate(),void(this.buttonShown=!0);this.applyActiveStyles(),this.isActive=!0,this.element.querySelector(this.component.selector).style.display="block"}deactivate(){this.isActive&&(this.isActive=!1,this.applyBaseStyles(),this.element.querySelector(this.component.selector).style.display="none")}mountAfterAvailable(){var e,t;super.mount(`#${this.loadElementId}`),null===(t=null===(e=this.events)||void 0===e?void 0:e.onAvailable)||void 0===t||t.call(e)}mount(e){const t=document.querySelector(e);if(!t){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_UI_ELEMENT_MISSING);throw a.PayrailsLogger.error(e.message,{error:e}),e}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 _n extends En{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",void 0,void 0,i.styles),this.loadElementId="apple-pay-dropin-load-element",this.component=new zi(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onApplePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class hn extends on{constructor(e,t,i,n){super("payrails-credit-card-wrapper","Card",void 0,n,i),this.cardForm=e,this.paymentButton=t,this.cardFormShown=!1,this.component=new In(e,t)}activate(){var e,t;this.applyActiveStyles(),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.applyBaseStyles(),this.paymentButton.unmount(),this.cardForm.hide(),this.isActive=!1,(null===(e=this.events)||void 0===e?void 0:e.onDeactivate)&&this.events.onDeactivate())}}class In extends Y{constructor(e,t){super("div",{id:"payrails-form-container"}),this.subElements.push(e,t)}}class pn extends Y{constructor(e){var t,i,n,o;super("button",{id:e.id,className:"payrails-generic-button",styles:null!==(i=null===(t=e.styles)||void 0===t?void 0:t.base)&&void 0!==i?i:{}}),this.options=e,this.isDisabled=!1,this.element.innerText=null==e?void 0:e.translations.label,e.styles&&this.setStyles(null!==(o=null===(n=e.styles)||void 0===n?void 0:n.base)&&void 0!==o?o:{}),this.element.addEventListener("click",this.onClick.bind(this)),this.element.addEventListener("mouseenter",(()=>{var e;this.isDisabled||this.setStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})})),this.element.addEventListener("mouseleave",(()=>{var e;this.isDisabled||this.removeStyles((null===(e=this.options.styles)||void 0===e?void 0:e.hover)||{})}))}getElement(){return this.element}onClick(){var e,i;return t(this,void 0,void 0,(function*(){if((null===(i=null===(e=this.options)||void 0===e?void 0:e.events)||void 0===i?void 0:i.onClick)&&!this.isDisabled){try{this.triggerLoading(!0),yield this.options.events.onClick()}catch(e){throw this.triggerLoading(!1),e}this.triggerLoading(!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]=""}))}triggerLoading(e){var t,i,n;this.isDisabled=e,e?(this.element.innerHTML='\n <div class="dot-flashing-container">\n <div class="dot-flashing"></div>\n <span class="dot-flashing-text" aria-hidden="true">Loading</span>\n </div>\n ',(null===(t=this.options.styles)||void 0===t?void 0:t.loading)&&this.setStyles(this.options.styles.loading)):(this.element.innerText=null===(i=this.options)||void 0===i?void 0:i.translations.label,this.removeStyles((null===(n=this.options.styles)||void 0===n?void 0:n.loading)||{}))}}const mn={label:"Generic redirect"};class fn extends Y{constructor(e,t,i,n){super("div",{id:`payrails-generic-redirect-${i.paymentMethod.paymentMethodCode}`}),this.sdkConfig=e,this.execution=t,this.options=i,this.returnInfo=n;const o=this.buildRedirectButton();this.element.appendChild(o.getElement()),this.paymentExecutor=new g(e,t,this.returnInfo)}buildRedirectButton(){var e,t,i;return new pn({id:"payrails-generic-redirect-button",translations:{label:null!==(t=null===(e=this.options.translations)||void 0===e?void 0:e.label)&&void 0!==t?t:mn.label},events:{onClick:this.onClick.bind(this)},styles:null!==(i=this.options.styles)&&void 0!==i?i:{}})}onClick(){var e,i,n,o;return t(this,void 0,void 0,(function*(){if(yield O(null!==(e=this.options.events)&&void 0!==e?e:{}))try{const e=null===(i=this.execution.availablePaymentMethods.find((({paymentMethodCode:e})=>e===this.options.paymentMethod.paymentMethodCode)))||void 0===i?void 0:i.integrationType;if(!e)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED);const t=(yield this.paymentExecutor.pay([{paymentMethodCode:this.options.paymentMethod.paymentMethodCode,integrationType:e,amount:this.sdkConfig.amount}])).response.links.redirect;if(!t)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_GENERIC_REDIRECT_MISSING_REDIRECT_LINK);return new Promise(((e,i)=>{window.location.href=t,setTimeout((()=>i(new Error("Timed out doing a redirect to the auth response link"))),3e3)}))}catch(e){e instanceof r.PayrailsError&&a.PayrailsLogger.error(e.message,{error:e}),null===(o=null===(n=this.options.events)||void 0===n?void 0:n.onAuthorizeFailed)||void 0===o||o.call(n)}}))}}const vn=t=>t===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT?{translations:{label:"Mercado Pago",button:{label:"Pay with Mercado Pago"}}}:{translations:{label:t,button:{label:`Pay with ${t}`}}};class Nn extends on{constructor(e,t,i,n){var o,s,r,a;super(`payrails-${i.paymentMethod.paymentMethodCode}-dropin-element`,(null===(o=null==i?void 0:i.translations)||void 0===o?void 0:o.label)||vn(i.paymentMethod.paymentMethodCode).translations.label,void 0,null==i?void 0:i.events,null===(s=null==i?void 0:i.styles)||void 0===s?void 0:s.element),this.sdkConfig=e,this.execution=t,this.returnInfo=n,this.component=new fn(this.sdkConfig,this.execution,{styles:(null===(r=null==i?void 0:i.styles)||void 0===r?void 0:r[i.paymentMethod.paymentMethodCode])||{},translations:(null===(a=null==i?void 0:i.translations)||void 0===a?void 0:a.button)||vn(i.paymentMethod.paymentMethodCode).translations.button,events:null==i?void 0:i.events,paymentMethod:i.paymentMethod},this.returnInfo)}}const Tn={apiVersion:2,apiVersionMinor:0};class An extends Wi{static getSDKClient(i=e.PayrailsEnvironment.TEST,n){return t(this,void 0,void 0,(function*(){return yield ji.load(Xi.GooglePay),An.googleSDKClient||(An.googleSDKClient=new google.payments.api.PaymentsClient({environment:i,merchantInfo:n})),An.googleSDKClient}))}static isGooglePayAvailable(i,n=e.PayrailsEnvironment.TEST,o){return t(this,void 0,void 0,(function*(){try{const e=yield An.getSDKClient(n,o),t=Object.assign(Object.assign({},Tn),{allowedPaymentMethods:i}),{result:s}=yield e.isReadyToPay(t);return s}catch(e){return!1}}))}constructor(e,t,i){super("div",Object.assign(Object.assign({},i),{id:"payrails-google-pay-button"})),this.sdkConfig=e,this.execution=t,this.options=i,this.googleButton=null,this.paymentExecutor=new g(e,t),An.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo).then((e=>{var t,i,n;e&&(null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onGooglePayAvailable)||void 0===n||n.call(i))}))}sdkLoaded(e){var i,n,o,s,r,a,l,d;return t(this,void 0,void 0,(function*(){const c=(null===(n=null===(i=this.options)||void 0===i?void 0:i.styles)||void 0===n?void 0:n.buttonColor)||"black",u=(null===(s=null===(o=this.options)||void 0===o?void 0:o.styles)||void 0===s?void 0:s.buttonType)||"long",E=(null===(a=null===(r=this.options)||void 0===r?void 0:r.styles)||void 0===a?void 0:a.buttonSizeMode)||"fill",_=(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:u,buttonSizeMode:E,buttonLocale:_,onClick:()=>t(this,void 0,void 0,(function*(){(yield O(this.options.events))&&(yield this.authorize(e))})),allowedPaymentMethods:this.execution.googlePayConfig}),this.element.appendChild(this.googleButton),this.googleButton}))}onLoadPaymentData(i){var n,o,s,r,a,l,d,c;return t(this,void 0,void 0,(function*(){const t=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.GOOGLE_PAY,integrationType:"api",paymentInstrumentData:{paymentToken:JSON.stringify(i)},amount:this.sdkConfig.amount,storeInstrument:this.shouldStoreInstrument}],u=yield this.paymentExecutor.pay(t);"authorizePending"===(null===(n=null==u?void 0:u.finalState)||void 0===n?void 0:n.code)?new U(this.options,this.execution,this.paymentExecutor).handle3ds(u):"authorizeSuccessful"===(null===(o=null==u?void 0:u.finalState)||void 0===o?void 0:o.code)?null===(a=null===(r=null===(s=this.options)||void 0===s?void 0:s.events)||void 0===r?void 0:r.onAuthorizeSuccess)||void 0===a||a.call(r):null===(c=null===(d=null===(l=this.options)||void 0===l?void 0:l.events)||void 0===d?void 0:d.onAuthorizeFailed)||void 0===c||c.call(d,u)}))}authorize(e){var i,n,o,s,r,a,l,d;return t(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},Tn),{allowedPaymentMethods:this.execution.googlePayConfig,transactionInfo:{totalPriceStatus:"FINAL",totalPrice:null===(i=this.sdkConfig.amount)||void 0===i?void 0:i.value,currencyCode:null===(n=this.sdkConfig.amount)||void 0===n?void 0:n.currency,countryCode:null===(a=null===(r=null===(s=null===(o=this.execution.meta)||void 0===o?void 0:o.order)||void 0===s?void 0:s.billingAddress)||void 0===r?void 0:r.country)||void 0===a?void 0:a.code},merchantInfo:{merchantId:(null===(l=this.options.merchantInfo)||void 0===l?void 0:l.merchantId)||"",merchantName:(null===(d=this.options.merchantInfo)||void 0===d?void 0:d.merchantName)||""}});e.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{if(yield An.isGooglePayAvailable(this.execution.googlePayConfig,this.options.environment,this.options.merchantInfo)){const t=yield An.getSDKClient(this.options.environment,this.options.merchantInfo),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()}}An.googleSDKClient=null;class yn extends En{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",void 0,i.events,i.styles),this.loadElementId="google-pay-dropin-load-element",this.component=new An(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},i.events),{onGooglePayAvailable:()=>{this.mountAfterAvailable()}})}))}}class On extends Wi{constructor(i,n,o){super("div",Object.assign(Object.assign({},o),{id:"payrails-paypal-button",events:Object.assign(Object.assign({},null==o?void 0:o.events),{onSaveInstrumentCheckboxChanged:e=>t(this,void 0,void 0,(function*(){var t,i,n,o;null===(n=null===(i=null===(t=this.options)||void 0===t?void 0:t.events)||void 0===i?void 0:i.onSaveInstrumentCheckboxChanged)||void 0===n||n.call(i,e),null===(o=this.button)||void 0===o||o.close();const s=yield this.loadPaypal();s&&(this.button=s,yield this.button.render(`#${this.buttonWrapperId}`))}))})})),this.sdkConfig=i,this.execution=n,this.options=o,this.buttonWrapperId="payrails-paypal-button-wrapper",this.checkboxWrapperId="payrails-paypal-checkbox-wrapper",this.createOneTimeOrder=()=>t(this,void 0,void 0,(function*(){var t,i,n,o,s,r,a;const l=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!1}],d=yield this.paymentExecutor.pay(l),c=null===(n=null===(i=null===(t=d.response.links.confirm)||void 0===t?void 0:t.action)||void 0===i?void 0:i.parameters)||void 0===n?void 0:n.orderId;if(!c)throw null===(r=null===(s=null===(o=this.options)||void 0===o?void 0:o.events)||void 0===s?void 0:s.onAuthorizeFailed)||void 0===r||r.call(s),new Rn("No order id returned");return this.confirmLink=null===(a=d.response.links.confirm)||void 0===a?void 0:a.href,c})),this.loadPaypal().catch((()=>{})),this.element.innerHTML=`<div id="${this.buttonWrapperId}"></div><div id="${this.checkboxWrapperId}"></div>`,this.paymentExecutor=new g(i,n),this.fraudNetGuid=null==o?void 0:o.fraudNetGuid}loadPaypal(){return t(this,void 0,void 0,(function*(){const e=yield ji.load(Xi.PayPal,this.paypalScriptConfig);return yield this.createPaypalButton(e)}))}get paypalScriptConfig(){const e=this.shouldStoreInstrument?"tokenize":"Instant"===this.execution.paypalConfig.captureMode?"capture":"authorize";return{clientId:this.execution.paypalConfig.clientId,intent:e,currency:this.sdkConfig.amount.currency,vault:this.shouldStoreInstrument}}createPaypalButton(e){var i,n,o;return t(this,void 0,void 0,(function*(){if(!e.Buttons)throw new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_LOADING_ERROR);const t=e.Buttons(this.createPayPalButtonConfig());return 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}))}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 t,i,n,o;const s=[{paymentMethodCode:e.PAYMENT_METHOD_CODES.PAYPAL,integrationType:"api",amount:this.sdkConfig.amount,paymentInstrumentData:{providerData:{riskSessionCorrelationId:this.fraudNetGuid}},storeInstrument:!0}],r=yield this.paymentExecutor.pay(s);return this.confirmLink=null===(t=r.response.links.confirm)||void 0===t?void 0:t.href,(null===(o=null===(n=null===(i=r.response.links.confirm)||void 0===i?void 0:i.action)||void 0===n?void 0:n.parameters)||void 0===o?void 0:o.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;return(yield O(null===(e=this.options)||void 0===e?void 0:e.events))?i.resolve():i.reject()}))}}approvePayment(e){var i,n,o,s,r,a,l,d,c,u;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 Rn("No confirm link");const t={};this.shouldStoreInstrument&&e.billingToken&&(t.tokenId=e.billingToken),this.fraudNetGuid&&(t.riskSessionCorrelationId=this.fraudNetGuid);const E=yield this.paymentExecutor.confirm(this.confirmLink,t);"authorizeSuccessful"===(null===(s=E.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===(u=null===(c=null===(d=this.options)||void 0===d?void 0:d.events)||void 0===c?void 0:c.onAuthorizeFailed)||void 0===u||u.call(c)}))}mount(e){super.mount(e),(()=>{t(this,void 0,void 0,(function*(){var e;const t=yield this.loadPaypal();t&&(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){const t=new Ln(e.message,e);throw a.PayrailsLogger.error(t.message,{error:t}),t}}))})()}unmount(){var e;null===(e=this.button)||void 0===e||e.close(),super.unmount()}}class Rn extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_ORDER_CREATION,{description:`PaypalOrderError: ${e}`,cause:t})}}class Ln extends r.PayrailsError{constructor(e,t){super(r.ERROR_CODES.PAYRAILS_CLIENT_PAYPAL_BUTTON_MOUNT,{description:`PaypalButtonError: ${e}`,cause:t})}}class gn extends En{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",void 0,void 0,null==i?void 0:i.styles),this.loadElementId="paypal-dropin-load-element",this.component=new On(e,t,Object.assign(Object.assign({},i),{events:Object.assign(Object.assign({},null==i?void 0:i.events),{onPaypalAvailable:()=>{this.mountAfterAvailable()}})}))}}class Sn extends Y{constructor(t,i,n,o,s){var r,a;super("fieldset",{id:"payrails-dropin-component"}),this.collectContainer=t,this.clientConfig=i,this.dropinConfig=n,this.execution=o,this.sdkConfig=s,this.applyStyles(),void 0!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r.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 l=new Map;this.execution.storedPaymentInstruments.forEach((e=>{if(this.isStoredInstrumentEnabled(e.paymentMethod)){this.cardPaymentButton=this.createCardPaymentButton();const t=this.createStoredInstrumentElement(e);l.set(t.identifier,t)}}));const d={[e.PAYMENT_METHOD_CODES.CARD]:this.createCreditCardButton.bind(this),[e.PAYMENT_METHOD_CODES.PAYPAL]:this.createPayPalButton.bind(this),[e.PAYMENT_METHOD_CODES.GOOGLE_PAY]:this.createGooglePayButton.bind(this),[e.PAYMENT_METHOD_CODES.APPLE_PAY]:this.createApplePayButton.bind(this)};this.execution.availablePaymentMethods.forEach((e=>{const t=e.paymentMethodCode;if(t&&d[t]){d[t];const e=d[t]();l.set(e.identifier,e)}else if(this.isHppIntegration(e)&&t){const t=this.createHppIntegrationElement(e);l.set(t.identifier,t)}})),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)||"";l.forEach((e=>{e.deactivate()})),null===(i=l.get(n))||void 0===i||i.activate()})),1===this.totalPaymentOptions&&this.element.classList.add("payrails-dropin-component--single"),this.subElements.push(...Array.from(l.values()))}isHppIntegration(t){var i;return t.paymentMethodCode===e.PAYMENT_METHOD_CODES.GENERIC_REDIRECT||(null===(i=t.clientConfig)||void 0===i?void 0:i.flow)===b.REDIRECT}createStoredInstrumentElement(e){var t;return this.cardPaymentButton=this.createCardPaymentButton(),new an(e,this.cardPaymentButton,(e=>{this.cardPaymentButton&&(this.cardPaymentButton.selectedInstrument=e)}),null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.element)}createHppIntegrationElement(e){var t,i,n,o,s,l;const d=e.paymentMethodCode;if(!d){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{description:`Payment method code is missing for payment method - ${JSON.stringify(e)}`});throw a.PayrailsLogger.error(t.message,{error:t}),t}return new Nn(this.sdkConfig,this.execution,{paymentMethod:e,styles:{element:null===(i=null===(t=this.dropinConfig)||void 0===t?void 0:t.styles)||void 0===i?void 0:i.element,button:null===(s=null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o[d])||void 0===s?void 0:s.button},translations:null===(l=this.dropinConfig.translations)||void 0===l?void 0:l[d],events:this.getElementEvents()},this.clientConfig.returnInfo)}get totalPaymentOptions(){return this.execution.availablePaymentMethods.length+this.execution.storedPaymentInstruments.length}createCreditCardButton(){var e;return this.creditCard=new hn(this.createCardForm(),this.createCardPaymentButton(),null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.element,this.getElementEvents()),this.creditCard}createGooglePayButton(){var t,i,n;return this.googlePay=new yn(this.sdkConfig,this.execution,Object.assign({environment:this.clientConfig.environment||e.PayrailsEnvironment.TEST,events:this.getElementEvents(),redirectFor3DS:this.clientConfig.redirectFor3DS,styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.googlePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)},null===(n=this.dropinConfig.paymentMethodsConfiguration)||void 0===n?void 0:n.googlePay)),this.googlePay}createPayPalButton(){var e,t,i;return this.paypal=new gn(this.sdkConfig,this.execution,Object.assign(Object.assign({},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.payPal),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.paypalButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element),events:this.getElementEvents()})),this.paypal}createCardForm(){var e,t,i,n;if(!this.cardForm){const o=null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.cards,s=Boolean(null==o?void 0:o.showStoreInstrumentCheckbox),r=Boolean(null==o?void 0:o.showCardHolderName),a=Boolean(null==o?void 0:o.alwaysStoreInstrument);this.cardForm=new tn(this.collectContainer,{showStoreInstrumentCheckbox:s,showCardHolderName:r,alwaysStoreInstrument:a,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardForm,styles:Object.assign(Object.assign({},null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.cardForm),null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.element),events:Object.assign(Object.assign({},this.getElementEvents()),{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=>{var t,i;null===(i=null===(t=this.dropinConfig.events)||void 0===t?void 0:t.onSaveInstrumentCheckboxChanged)||void 0===i||i.call(t,e)}})})}return this.cardPaymentButton&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardForm}createApplePayButton(){var e,t,i;return this.applePay=new _n(this.sdkConfig,this.execution,Object.assign(Object.assign({events:Object.assign(Object.assign({},this.getElementEvents()),{onAuthorizeSuccess:e=>{var t;e&&("authorizeSuccessful"===(null===(t=null==e?void 0:e.finalState)||void 0===t?void 0:t.code)?this.onAuthorizeSuccess():this.onAuthorizeFailed())}})},null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.applePay),{styles:Object.assign(Object.assign({},null===(t=this.dropinConfig.styles)||void 0===t?void 0:t.applePayButton),null===(i=this.dropinConfig.styles)||void 0===i?void 0:i.element)})),this.applePay}createCardPaymentButton(){var e,t;return this.cardPaymentButton||(this.cardPaymentButton=new x(this.sdkConfig,this.execution,{styles:null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.cardPaymentButton,translations:null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.cardPaymentButton,redirectFor3DS:this.clientConfig.redirectFor3DS,events:this.getElementEvents()},this.clientConfig.returnInfo)),this.cardForm&&this.cardPaymentButton.setCardForm(this.cardForm),this.cardPaymentButton}onAuthorizeSuccess(){var e,t,i,n,o,s;this.subElements.forEach((e=>e.unmount())),new un({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},styles:null===(o=null===(n=this.dropinConfig)||void 0===n?void 0:n.styles)||void 0===o?void 0:o.authSuccess}).mount(this.selector),(null===(s=this.dropinConfig.events)||void 0===s?void 0:s.onAuthorizeSuccess)&&this.dropinConfig.events.onAuthorizeSuccess()}getElementEvents(){return Object.assign(Object.assign({},this.dropinConfig.events),{onAuthorizeSuccess:this.onAuthorizeSuccess.bind(this),onAuthorizeFailed:this.onAuthorizeFailed.bind(this),onAvailable:()=>{var e;(1===this.totalPaymentOptions||(null===(e=this.dropinConfig.paymentMethodsConfiguration)||void 0===e?void 0:e.preselectFirstPaymentOption))&&this.subElements[0].activate()}})}onAuthorizeFailed(e){var t,i,n,o,s;new cn({translations:{label:null===(i=null===(t=this.dropinConfig.translations)||void 0===t?void 0:t.paymentResult)||void 0===i?void 0:i.fail},styles:null===(n=this.dropinConfig.styles)||void 0===n?void 0:n.authFailed}).mount(this.selector),null===(s=null===(o=this.dropinConfig.events)||void 0===o?void 0:o.onAuthorizeFailed)||void 0===s||s.call(o,e)}isStoredInstrumentEnabled(t){var i,n,o,s,r,a;switch(t){case e.PAYMENT_METHOD_CODES.CARD:return!1!==(null===(n=null===(i=this.dropinConfig.paymentMethodsConfiguration)||void 0===i?void 0:i.cards)||void 0===n?void 0:n.showStoredInstruments)&&!1!==(null===(s=null===(o=this.dropinConfig.paymentMethodsConfiguration)||void 0===o?void 0:o.cards)||void 0===s?void 0:s.showExistingCards);case e.PAYMENT_METHOD_CODES.PAYPAL:case e.PAYMENT_METHOD_CODES.GOOGLE_PAY:case e.PAYMENT_METHOD_CODES.APPLE_PAY:return!1!==(null===(a=null===(r=this.dropinConfig.paymentMethodsConfiguration)||void 0===r?void 0:r[t])||void 0===a?void 0:a.showStoredInstruments);default:return!1}}applyStyles(){var e;(null===(e=this.dropinConfig.styles)||void 0===e?void 0:e.container)&&Object.assign(this.element.style,this.dropinConfig.styles.container)}}const Cn={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 Dn{constructor(e,t,i){this.sdkConfig=i,this.bin="",this.id="payrails-container-wrapper",this.containerType="COMPOSABLE",this.cardTableName=t.cardTableName||"cards",this.containerType=t.containerType||"COMPOSABLE",this.__container=e.container(this.containerType,t)}static init(e,t,i){return this.instance&&this.instance.__container.unmount(),this.instance=new Dn(e,t,i),this.instance}createCollectElement(t){const i={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===e.ElementType.CARDHOLDER_NAME?"INPUT_FIELD":t.type}),t.format?Object.assign(Object.assign({},i),{format:t.format}):i);return this.attachCustomEventHandler(n)}mount(e){if("COLLECT"===this.containerType){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message),e}this.element=document.createElement("span"),this.element.setAttribute("id",this.id);const t=document.querySelector(e);if(!t){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_PARENT_ELEMENT_MISSING);throw a.PayrailsLogger.error(t.message,{error:t,extra:{elementSelector:e}}),t}t.appendChild(this.element),window.setTimeout((()=>{this.__container.mount(`#${this.id}`)}),50)}unmount(){this.element&&this.element.remove()}collect(){return t(this,void 0,void 0,(function*(){try{return this.sdkConfig.usePayrailsFrames?yield this.collectPayrailsData():yield this.collectSkyflowData()}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CARD_FORM_ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE,{description:"Error collecting data from the iframe!"});throw a.PayrailsLogger.error(t.message,{error:t}),t}}))}collectSkyflowData(){return t(this,void 0,void 0,(function*(){const e=(yield this.__container.collect()).records,{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}}))}collectPayrailsData(){return t(this,void 0,void 0,(function*(){const e=yield this.__container.collect();return Object.assign(Object.assign({},e),{vaultProviderConfigId:this.sdkConfig.vaultConfiguration.providerConfigId})}))}tokenize(e){return t(this,void 0,void 0,(function*(){const t=yield this.collect(),i=this.sdkConfig.vaultConfiguration.links.saveInstrument.href,n=this.sdkConfig.token;if(!i){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_API_URL_NOT_FOUND,{description:"Save instrument URL not available!"});throw a.PayrailsLogger.error(e.message,{error:e}),e}const o=yield(({url:e,token:t,body:i})=>p({url:e,token:t,method:_.POST,body:i}))({url:i,token:n,body:this.constructSaveInstrumentBody(t,e)});return o.res}))}constructSaveInstrumentBody(e,t){var i,n;const o={holderReference:this.sdkConfig.holderReference,paymentMethod:"card",storeInstrument:null!==(i=null==t?void 0:t.storeInstrument)&&void 0!==i&&i,futureUsage:null!==(n=null==t?void 0:t.futureUsage)&&void 0!==n?n:"CardOnFile"};return this.sdkConfig.usePayrailsFrames?o.data={encryptedData:e.encryptedData,vaultProviderConfigId:e.vaultProviderConfigId}:o.token={providerId:this.sdkConfig.vaultConfiguration.providerId,providerConfigId:this.sdkConfig.vaultConfiguration.providerConfigId,reference:e.instrumentId,type:"card",meta:{skyflow_id:e.instrumentId,card_number:e.card_number,cardholder_name:e.cardholder_name,expiry_month:e.expiry_month,expiry_year:e.expiry_year,security_code:e.security_code}},o}attachCustomEventHandler(t){return new Proxy(t,{get:(t,i)=>"on"!==i?t[i]:((n,o)=>{t[i].call(t,n,(t=>{"CHANGE"===n?(t.elementType===e.ElementType.CARD_NUMBER&&(t.network=function(e){for(const[t,i]of Object.entries(Cn))if(i.test(e))return t;return""}(t.value),t.bin=this.formatBin(t.value),this.bin=this.formatBin(t.value)),o(t)):o(t)}))}).bind(t)})}formatBin(e){return e.replace(/-|X/g,"").slice(0,6)}get elementToFieldMap(){return new Map([[e.ElementType.CARD_NUMBER,"card_number"],[e.ElementType.CARDHOLDER_NAME,"cardholder_name"],[e.ElementType.CVV,"security_code"],[e.ElementType.EXPIRATION_MONTH,"expiry_month"],[e.ElementType.EXPIRATION_YEAR,"expiry_year"]])}}class Pn{constructor(e,t,i){this.pageId=e,this.execution=t,this.environment=i,this.guid=I().replace(/-/g,""),this.fnclsVal="fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99",this.configId=I(),this.scriptId=I()}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}}const bn=()=>{const e=document.getElementById("sdk-observer");return e||(()=>{const e=document.createElement("iframe");return e.id="sdk-observer",e.src="https://assets.payrails.io/2ab28a7/observability/index.html",e.width="1px",e.height="1px",document.body.appendChild(e),e})()};
|
|
22
22
|
/* @copyright
|
|
23
23
|
Copyright (c) 2023 Payrails (https://www.payrails.com/)
|
|
24
24
|
*/
|
|
25
|
-
class Mn{static init(t,i){var n,o,s,l,d,c,u,E,_,h;try{bn(),a.PayrailsLogger.init({enabled:(null===(n=null==i?void 0:i.telemetry)||void 0===n?void 0:n.enabled)||!0,logLevel:(null===(o=null==i?void 0:i.telemetry)||void 0===o?void 0:o.logLevel)||"error",environment:(null==i?void 0:i.environment)||"TEST",sdk:{name:"web-sdk",version:"5.
|
|
25
|
+
class Mn{static init(t,i){var n,o,s,l,d,c,u,E,_,h;try{bn(),a.PayrailsLogger.init({enabled:(null===(n=null==i?void 0:i.telemetry)||void 0===n?void 0:n.enabled)||!0,logLevel:(null===(o=null==i?void 0:i.telemetry)||void 0===o?void 0:o.logLevel)||"error",environment:(null==i?void 0:i.environment)||"TEST",sdk:{name:"web-sdk",version:"5.10.0"}});const r=JSON.parse(atob(t.data)),I=Boolean(r.vaultConfiguration.encryptionPublicKey);a.PayrailsLogger.setState({payrails:{execution_id:null===(s=r.execution)||void 0===s?void 0:s.id,holder_reference:r.holderReference,vault_provider:r.vaultConfiguration.vaultType,merchant_reference:null===(l=r.execution)||void 0===l?void 0:l.merchantReference,frames_type:I?"payrails":"skyflow",workflow:{code:(null===(c=null===(d=r.execution)||void 0===d?void 0:d.workflow)||void 0===c?void 0:c.code)||"",version:(null===(E=null===(u=r.execution)||void 0===u?void 0:u.workflow)||void 0===E?void 0:E.version)||0}}});const{vaultConfiguration:{vaultId:p,vaultUrl:m,token:f},execution:v}=r,N=ki.init({vaultID:p,vaultURL:m,getBearerToken:()=>Promise.resolve(f),options:{initResponse:t,deserializedData:Object.assign(Object.assign({},r),{usePayrailsFrames:I}),logLevel:(null===(h=null===(_=null==i?void 0:i.telemetry)||void 0===_?void 0:_.logLevel)||void 0===h?void 0:h.toUpperCase())||"ERROR"}});let T;return v&&(T=new k(v),T.isPaymentMethodAvailable(e.PAYMENT_METHOD_CODES.CARD)&&ji.preloadCardForm()),new Mn(Object.assign(Object.assign({},r),{usePayrailsFrames:I}),N,T,i)}catch(e){const t=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_CONFIG_MALFORMED,{cause:e});throw a.PayrailsLogger.error(t.message,{error:t}),t}}update(e){this.sdkConfiguration.amount=e}collectContainer(e){if("COMPOSABLE"===e.containerType&&!e.layout){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_COLLECT_CONTAINER_MOUNT);throw a.PayrailsLogger.error(e.message,{error:e}),e}return this.__container=Dn.init(this.vaultClient,Object.assign(Object.assign({},e),{cardTableName:this.sdkConfiguration.vaultConfiguration.cardTableName}),this.sdkConfiguration),this.__container}googlePayButton(e){var t;return this.logIntegrationMode("elements"),new An(this.sdkConfiguration,this.safeExecution,Object.assign({environment:null===(t=this.options)||void 0===t?void 0:t.environment},e))}isGooglePayAvailable(e){var t;return An.isGooglePayAvailable(this.safeExecution.googlePayConfig,null===(t=this.options)||void 0===t?void 0:t.environment,e)}applePayButton(e){if(this.logIntegrationMode("elements"),!this.execution){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e}),e}return new zi(this.sdkConfiguration,this.execution,e)}isApplePayAvailable(){return zi.isApplePayAvailable()}cardList(e){return this.logIntegrationMode("elements"),this.__cardList||(this.__cardList=new ln(this.safeExecution,{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.logIntegrationMode("elements"),!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 tn(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;this.logIntegrationMode("dropin");const n=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:n,errorTextStyles:{base:{display:"none"}}}),this.__dropin=new Sn(this.__container,this.options||{},e,this.safeExecution,this.sdkConfiguration),this.__dropin}getSavedCreditCards(){return this.logIntegrationMode("elements"),this.safeExecution.savedCreditCards}getSavedGooglePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedGooglePayAccounts}getSavedApplePayAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedApplePayAccounts}getStoredInstruments(){return this.logIntegrationMode("elements"),this.safeExecution.storedPaymentInstruments}getAvailablePaymentMethods(){return this.logIntegrationMode("elements"),this.safeExecution.availablePaymentMethods.map((({paymentMethodCode:e})=>e)).filter((e=>!!e))}paymentButton(e){var t;return this.logIntegrationMode("elements"),this.__cardPaymentButton||(this.__cardPaymentButton=new x(this.sdkConfiguration,this.safeExecution,e,(null===(t=this.options)||void 0===t?void 0:t.returnInfo)||{})),this.__cardPaymentButton.setDisabled(!0),this.__cardForm&&this.__cardPaymentButton.setCardForm(this.__cardForm),this.__cardPaymentButton}paypalButton(e){var t;return this.logIntegrationMode("elements"),this.__paypalButton=new On(this.sdkConfiguration,this.safeExecution,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}genericRedirectButton(e){return this.logIntegrationMode("elements"),this.__genericRedirectButton=new fn(this.sdkConfiguration,this.safeExecution,e),this.__genericRedirectButton}getSavedPaypalAccounts(){return this.logIntegrationMode("elements"),this.safeExecution.savedPaypalAccounts||[]}fraudNet(t){var i;return this.__fraudNet||(this.__fraudNet=new Pn(t,this.safeExecution,(null===(i=this.options)||void 0===i?void 0:i.environment)||e.PayrailsEnvironment.TEST)),this.__paypalButton&&(this.__paypalButton.fraudNetGuid=this.__fraudNet.guid),this.__fraudNet}get safeExecution(){if(!this.execution){const e=new r.PayrailsError(r.ERROR_CODES.PAYRAILS_CLIENT_WORKFLOW_EXECUTION_NOT_FOUND);throw a.PayrailsLogger.error(e.message,{error:e}),e}return this.execution}logIntegrationMode(e){a.PayrailsLogger.setState({sdk:{integration_mode:e}})}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]}}var wn;Mn.preloadCardForm=ji.preloadCardForm,e.PayrailsEnvironment=void 0,(wn=e.PayrailsEnvironment||(e.PayrailsEnvironment={})).TEST="TEST",wn.PRODUCTION="PRODUCTION",e.Payrails=Mn,window.Payrails=Mn}({});
|